Skip to content

Commit

Permalink
Fix default case.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghouet committed May 9, 2022
1 parent ccb2c69 commit 786105a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/util/mime_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ shaka.util.MimeUtils = class {
* @return {string}
*/
static getNormalizedCodec(codecString) {
switch (shaka.util.MimeUtils.getCodecBase(codecString)) {
const cb = shaka.util.MimeUtils.getCodecBase(codecString);
switch (cb) {
case 'avc1':
case 'avc3':
return 'avc'; // H264
Expand All @@ -115,7 +116,7 @@ shaka.util.MimeUtils = class {
case 'dvhe':
return 'dovi'; // Dolby Vision
}
return codecString;
return cb;
}

/**
Expand Down
19 changes: 16 additions & 3 deletions test/util/periods_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,12 +1027,22 @@ describe('PeriodCombiner', () => {
stream6.bandwidth = 120000;
stream6.codecs = 'avc3.42001f';

const stream7 = makeVideoStream(1080);
stream7.originalId = '7';
stream7.bandwidth = 120000;
stream7.codecs = 'vp09.00.10.08';

const stream8 = makeVideoStream(1080);
stream8.originalId = '8';
stream8.bandwidth = 120000;
stream8.codecs = 'vp09.01.20.08.01';

/** @type {!Array.<shaka.util.PeriodCombiner.Period>} */
const periods = [
{
id: '0',
videoStreams: [
stream1, stream3, stream5,
stream1, stream3, stream5, stream7,
],
audioStreams: [],
textStreams: [],
Expand All @@ -1041,7 +1051,7 @@ describe('PeriodCombiner', () => {
{
id: '1',
videoStreams: [
stream2, stream4, stream6,
stream2, stream4, stream6, stream8,
],
audioStreams: [],
textStreams: [],
Expand All @@ -1051,7 +1061,7 @@ describe('PeriodCombiner', () => {

await combiner.combinePeriods(periods, /* isDynamic= */ true);
const variants = combiner.getVariants();
expect(variants.length).toBe(3);
expect(variants.length).toBe(4);
// We can use the originalId field to see what each track is composed of.
const video1 = variants[0].video;
expect(video1.originalId).toBe('1,2');
Expand All @@ -1061,6 +1071,9 @@ describe('PeriodCombiner', () => {

const video3 = variants[2].video;
expect(video3.originalId).toBe('5,6');

const video4 = variants[3].video;
expect(video4.originalId).toBe('7,8');
});

it('Matches streams with most roles in common', async () => {
Expand Down

0 comments on commit 786105a

Please sign in to comment.