Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PERIOD_FLATTENING_FAILED error when periods have different base sample types. #4206

Merged
merged 12 commits into from May 17, 2022
16 changes: 12 additions & 4 deletions lib/util/mime_utils.js
Expand Up @@ -98,7 +98,7 @@ shaka.util.MimeUtils = class {

/**
* Get the normalized codec from a codec string,
* grouping them as long as they are compatible.
* indendently of their container.
ghouet marked this conversation as resolved.
Show resolved Hide resolved
*
* @param {string} codecString
* @return {string}
Expand All @@ -112,7 +112,7 @@ shaka.util.MimeUtils = class {
case base === 'mp4a' && profile === '66':
case base === 'mp4a' && profile === '67':
case base === 'mp4a' && profile === '68':
return 'mpeg2_aac';
return 'aac';
case base === 'mp4a' && profile === '69':
case base === 'mp4a' && profile === '6b':
return 'mp3';
Expand All @@ -121,9 +121,17 @@ shaka.util.MimeUtils = class {
case base === 'mp4a' && profile === '40.5':
case base === 'mp4a' && profile === '40.05':
case base === 'mp4a' && profile === '40.29':
return 'mpeg4_aac';
return 'aac';
case base === 'mp4a' && profile === '40.42':
return 'mpeg4_xhe_aac'; // Extended HE-AAC
return 'xhe_aac'; // Extended HE-AAC
ghouet marked this conversation as resolved.
Show resolved Hide resolved
case base === 'mp4a' && profile === 'a5':
return 'ac-3'; // Dolby Digital
avelad marked this conversation as resolved.
Show resolved Hide resolved
case base === 'mp4a' && profile === 'a6':
return 'ec-3'; // Dolby Digital Plus
case base === 'mp4a' && profile === 'b2':
return 'dtsx'; // DTS:X
case base === 'mp4a' && profile === 'a9':
return 'dtsc'; // DTS Digital Surround
case base === 'avc1':
case base === 'avc3':
return 'avc'; // H264
Expand Down
32 changes: 23 additions & 9 deletions test/util/mime_utils_unit.js
Expand Up @@ -9,22 +9,36 @@ describe('MimeUtils', () => {
shaka.util.MimeUtils.getNormalizedCodec(codecs);

it('normalizes codecs', () => {
expect(getNormalizedCodec('mp4a.66')).toBe('mpeg2_aac');
expect(getNormalizedCodec('mp4a.67')).toBe('mpeg2_aac');
expect(getNormalizedCodec('mp4a.68')).toBe('mpeg2_aac');
expect(getNormalizedCodec('mp4a.66')).toBe('aac');
expect(getNormalizedCodec('mp4a.67')).toBe('aac');
expect(getNormalizedCodec('mp4a.68')).toBe('aac');

expect(getNormalizedCodec('mp3')).toBe('mp3');
expect(getNormalizedCodec('mp4a.69')).toBe('mp3');
expect(getNormalizedCodec('mp4a.6B')).toBe('mp3');
expect(getNormalizedCodec('mp4a.6b')).toBe('mp3');

expect(getNormalizedCodec('mp4a.40.2')).toBe('mpeg4_aac');
expect(getNormalizedCodec('mp4a.40.02')).toBe('mpeg4_aac');
expect(getNormalizedCodec('mp4a.40.5')).toBe('mpeg4_aac');
expect(getNormalizedCodec('mp4a.40.05')).toBe('mpeg4_aac');
expect(getNormalizedCodec('mp4a.40.29')).toBe('mpeg4_aac');
expect(getNormalizedCodec('mp4a.40.2')).toBe('aac');
expect(getNormalizedCodec('mp4a.40.02')).toBe('aac');
expect(getNormalizedCodec('mp4a.40.5')).toBe('aac');
expect(getNormalizedCodec('mp4a.40.05')).toBe('aac');
expect(getNormalizedCodec('mp4a.40.29')).toBe('aac');

expect(getNormalizedCodec('mp4a.40.42')).toBe('mpeg4_xhe_aac');
expect(getNormalizedCodec('mp4a.40.42')).toBe('xhe_aac');

expect(getNormalizedCodec('ac-3')).toBe('ac-3');
expect(getNormalizedCodec('mp4a.a5')).toBe('ac-3');
expect(getNormalizedCodec('mp4a.A5')).toBe('ac-3');

expect(getNormalizedCodec('ec-3')).toBe('ec-3');
expect(getNormalizedCodec('mp4a.a6')).toBe('ec-3');
expect(getNormalizedCodec('mp4a.A6')).toBe('ec-3');

expect(getNormalizedCodec('dtsc')).toBe('dtsc');
expect(getNormalizedCodec('mp4a.a9')).toBe('dtsc');

expect(getNormalizedCodec('dtsx')).toBe('dtsx');
expect(getNormalizedCodec('mp4a.b2')).toBe('dtsx');

expect(getNormalizedCodec('vp8')).toBe('vp8');
expect(getNormalizedCodec('vp8.0')).toBe('vp8');
Expand Down