From 53e6d7c44c7f0df9b7855e72d86baa211f7a9e02 Mon Sep 17 00:00:00 2001 From: Theodore Abshire Date: Wed, 9 Feb 2022 01:19:44 -0800 Subject: [PATCH] fix: Probe for containerless format support. Issue #2337 Change-Id: I909a1c09cac270cd4127a2ddd2ce5506d6ef0f35 --- demo/main.js | 3 +++ lib/hls/hls_parser.js | 18 ++---------------- lib/media/media_source_engine.js | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/demo/main.js b/demo/main.js index 659bd485f8..4c5e24df77 100644 --- a/demo/main.js +++ b/demo/main.js @@ -726,6 +726,9 @@ shakaDemo.Main = class { if (asset.features.includes(shakaAssets.Feature.MP2TS)) { mimeTypes.push('video/mp2t'); } + if (asset.features.includes(shakaAssets.Feature.CONTAINERLESS)) { + mimeTypes.push('audio/aac'); + } const hasSupportedMimeType = mimeTypes.some((type) => { return this.support_.media[type]; }); diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index f7fcebc81d..3fb4c49914 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -18,6 +18,7 @@ goog.require('shaka.log'); goog.require('shaka.media.DrmEngine'); goog.require('shaka.media.InitSegmentReference'); goog.require('shaka.media.ManifestParser'); +goog.require('shaka.media.MediaSourceEngine'); goog.require('shaka.media.PresentationTimeline'); goog.require('shaka.media.SegmentIndex'); goog.require('shaka.media.SegmentReference'); @@ -1442,9 +1443,7 @@ shaka.hls.HlsParser = class { } // MediaSource expects no codec strings combined with raw formats. - if (shaka.hls.HlsParser.RAW_FORMATS.includes(mimeType)) { - // TODO(#2337): Translate the raw codecs string to a corresponding - // containered version, so that audio-only raw format streams can work. + if (shaka.media.MediaSourceEngine.RAW_FORMATS.includes(mimeType)) { codecs = ''; } @@ -2411,19 +2410,6 @@ shaka.hls.HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_ = { }; -/** - * MIME types of raw formats. - * - * @const {!Array.} - */ -shaka.hls.HlsParser.RAW_FORMATS = [ - 'audio/aac', - 'audio/ac3', - 'audio/ec3', - 'audio/mpeg', -]; - - /** * @const {!Object.} * @private diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 6f8fd95f3c..d1bf5f4732 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -196,6 +196,8 @@ shaka.media.MediaSourceEngine = class { // TTML types 'application/ttml+xml', 'application/mp4; codecs="stpp"', + // Containerless types + ...shaka.media.MediaSourceEngine.RAW_FORMATS, ]; const support = {}; @@ -1172,3 +1174,16 @@ shaka.media.MediaSourceEngine.SourceBufferMode_ = { SEQUENCE: 'sequence', SEGMENTS: 'segments', }; + + +/** + * MIME types of raw formats. + * + * @const {!Array.} + */ +shaka.media.MediaSourceEngine.RAW_FORMATS = [ + 'audio/aac', + 'audio/ac3', + 'audio/ec3', + 'audio/mpeg', +];