diff --git a/lib/cea/mp4_cea_parser.js b/lib/cea/mp4_cea_parser.js index 7d6d4ddb1ae..7ce9dab82a4 100644 --- a/lib/cea/mp4_cea_parser.js +++ b/lib/cea/mp4_cea_parser.js @@ -23,12 +23,7 @@ shaka.cea.Mp4CeaParser = class { /** * @param {string} mimeType */ - constructor(mimeType) { - /** - * @private {string} - */ - this.mimeType_ = mimeType; - + constructor() { /** * SEI data processor. * @private @@ -116,10 +111,6 @@ shaka.cea.Mp4CeaParser = class { .box('stbl', Mp4Parser.children) .fullBox('stsd', Mp4Parser.sampleDescription) - .box('encv', () => { - encrypted = true; - }) - // These are the various boxes that signal a codec. // Use these to set bistreamFormat_. .box('avc1', bitstreamFormatSetter(BitstreamFormat.H264)) @@ -130,6 +121,17 @@ shaka.cea.Mp4CeaParser = class { .box('dvh1', bitstreamFormatSetter(BitstreamFormat.H265)) .box('dvhe', bitstreamFormatSetter(BitstreamFormat.H265)) + .box('encv', Mp4Parser.children); + // These are the various boxes that signal a codec in + // encrypted segments + // Use these to set bistreamFormat_. + .box('avcC', bitstreamFormatSetter(BitstreamFormat.H264)) + .box('hvcE', bitstreamFormatSetter(BitstreamFormat.H265)) + .box('hvcC', bitstreamFormatSetter(BitstreamFormat.H265)) + // Dobly vision is also H265. + .box('dvcC', bitstreamFormatSetter(BitstreamFormat.H265)) + .box('dvvC', bitstreamFormatSetter(BitstreamFormat.H265)) + .parse(initSegment, /* partialOkay= */ true); // At least one track should exist, and each track should have a @@ -142,21 +144,6 @@ shaka.cea.Mp4CeaParser = class { shaka.util.Error.Code.INVALID_MP4_CEA); } - // If the content is encrypted we have no way of knowing the - // bitstreamformat, so we try to get it from the mimetype. - if (encrypted && this.bitstreamFormat_ == BitstreamFormat.UNKNOWN) { - if (this.mimeType_.includes('avc1.') || - this.mimeType_.includes('avc3.')) { - this.bitstreamFormat_ = BitstreamFormat.H264; - } - if (this.mimeType_.includes('hev1.') || - this.mimeType_.includes('hvc1.') || - this.mimeType_.includes('dvh1.') || - this.mimeType_.includes('dvhe.')) { - this.bitstreamFormat_ = BitstreamFormat.H265; - } - } - if (this.bitstreamFormat_ == BitstreamFormat.UNKNOWN) { shaka.log.alwaysWarn( 'Unable to determine bitstream format for CEA parsing!'); diff --git a/lib/media/closed_caption_parser.js b/lib/media/closed_caption_parser.js index 29d5cc2802a..a657bb2d923 100644 --- a/lib/media/closed_caption_parser.js +++ b/lib/media/closed_caption_parser.js @@ -62,7 +62,7 @@ shaka.media.ClosedCaptionParser = class { if (mimeType.toLowerCase().includes('video/mp4')) { // MP4 Parser to extract closed caption packets from H.264/H.265 video. - this.ceaParser_ = new shaka.cea.Mp4CeaParser(mimeType); + this.ceaParser_ = new shaka.cea.Mp4CeaParser(); } if (mimeType.toLowerCase().includes('video/mp2t')) { // TS Parser to extract closed caption packets from H.264 video. diff --git a/test/cea/mp4_cea_parser_unit.js b/test/cea/mp4_cea_parser_unit.js index 282c7f7a186..3f93c65bc82 100644 --- a/test/cea/mp4_cea_parser_unit.js +++ b/test/cea/mp4_cea_parser_unit.js @@ -50,7 +50,7 @@ describe('Mp4CeaParser', () => { }); it('parses cea data from mp4 stream', () => { - const cea708Parser = new shaka.cea.Mp4CeaParser('video/mp4'); + const cea708Parser = new shaka.cea.Mp4CeaParser(); const expectedCea708Packet = new Uint8Array([ 0xb5, 0x00, 0x31, 0x47, 0x41, 0x39, 0x34, 0x03, @@ -71,7 +71,7 @@ describe('Mp4CeaParser', () => { }); it('parses an invalid init segment', () => { - const cea708Parser = new shaka.cea.Mp4CeaParser('video/mp4'); + const cea708Parser = new shaka.cea.Mp4CeaParser(); const expected = Util.jasmineError(new shaka.util.Error( shaka.util.Error.Severity.CRITICAL,