Skip to content

Commit

Permalink
fix(dash): Account for bandwidth before filtering text stream (#3765)
Browse files Browse the repository at this point in the history
We filter out text streams that are duplicates, before persenting
them to the end user. A duplicate is detected by checking if
various values on the streams are the same.
However, we were not checking for bandwidth. This could lead to a
text stream being marked as a duplicate if it had the same language,
label, etc as another, even if they did not contain the same text.
This changes the utility to also check bandwidth.

Closes #3724
  • Loading branch information
king-prawns committed Mar 22, 2022
1 parent f6d5b10 commit 0b04aec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -33,6 +33,7 @@ Enson Choy <enson.choy@harmonicinc.com>
Esteban Dosztal <edosztal@gmail.com>
Fadomire <fadomire@gmail.com>
Gil Gonen <gil.gonen@gmail.com>
Giorgio Gamberoni <giorgio.gamberoni@gmail.com>
Giuseppe Samela <giuseppe.samela@gmail.com>
Google Inc. <*@google.com>
Itay Kinnrot <Itay.Kinnrot@Kaltura.com>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Expand Up @@ -50,6 +50,7 @@ Esteban Dosztal <edosztal@gmail.com>
Fadomire <fadomire@gmail.com>
François Beaufort <fbeaufort@google.com>
Gil Gonen <gil.gonen@gmail.com>
Giorgio Gamberoni <giorgio.gamberoni@gmail.com>
Giuseppe Samela <giuseppe.samela@gmail.com>
Hichem Taoufik <hichem@code-it.fr>
Itay Kinnrot <itay.kinnrot@kaltura.com>
Expand Down
1 change: 1 addition & 0 deletions lib/util/periods.js
Expand Up @@ -301,6 +301,7 @@ shaka.util.PeriodCombiner = class {
t1.label == t2.label &&
t1.codecs == t2.codecs &&
t1.mimeType == t2.mimeType &&
t1.bandwidth == t2.bandwidth &&
ArrayUtils.hasSameElements(t1.roles, t2.roles)) {
duplicate = true;
}
Expand Down
15 changes: 13 additions & 2 deletions test/util/periods_unit.js
Expand Up @@ -477,7 +477,7 @@ describe('PeriodCombiner', () => {
a3.originalId = 'a3';
a3.bandwidth = 97065;
a3.roles = ['role1', 'role2'];
a2.codecs = 'mp4a.40.2';
a3.codecs = 'mp4a.40.2';

// a4 has a different label from a3, and should not
// be filtered out.
Expand All @@ -500,14 +500,24 @@ describe('PeriodCombiner', () => {
const t1 = makeTextStream('en');
t1.originalId = 't1';
t1.roles = ['role1'];
t1.bandwidth = 1158;

const t2 = makeTextStream('en');
t2.originalId = 't2';
t2.roles = ['role1', 'role2'];
t2.bandwidth = 1172;

const t3 = makeTextStream('en');
t3.originalId = 't3';
t3.roles = ['role1'];
t3.bandwidth = 1158;

// t4 has a different bandwidth from t3, and should not
// be filtered out.
const t4 = makeTextStream('en');
t4.originalId = 't4';
t4.roles = ['role1'];
t4.bandwidth = 1186;

// i1 and i3 are duplicates.
const i1 = makeImageStream(240);
Expand Down Expand Up @@ -539,6 +549,7 @@ describe('PeriodCombiner', () => {
t1,
t2,
t3,
t4,
],
imageStreams: [
i1,
Expand All @@ -565,7 +576,7 @@ describe('PeriodCombiner', () => {
}

const textStreams = combiner.getTextStreams();
expect(textStreams.length).toBe(2);
expect(textStreams.length).toBe(3);

// t3 should've been filtered out
const textIds = textStreams.map((t) => t.originalId);
Expand Down

0 comments on commit 0b04aec

Please sign in to comment.