From d2ccc62ab8171ba3528cc32b02141137edc0a58b Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Sat, 11 Jan 2020 15:23:45 -0800 Subject: [PATCH] Recognize and reject raw AAC in HLS This makes the HLS parser recognize raw AAC, but refuse to play it. It will not play correctly until we have full support for containerless formats at the MediaSource level. Closes #1083 (raw AAC, can't do anything more for this right now) Issue #2337 (full support for containerless formats in general) Change-Id: I50c7f06a1aa08d515f4d9f74603954a6d015dc29 --- demo/common/assets.js | 2 ++ lib/hls/hls_parser.js | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/demo/common/assets.js b/demo/common/assets.js index 6ad758aacd..58bd58628f 100644 --- a/demo/common/assets.js +++ b/demo/common/assets.js @@ -934,6 +934,8 @@ shakaAssets.testAssets = [ /* iconUri= */ 'https://storage.googleapis.com/shaka-asset-icons/apple_test_pattern.png', /* manifestUri= */ 'https://storage.googleapis.com/shaka-demo-assets/apple-advanced-stream-ts/master.m3u8', /* source= */ shakaAssets.Source.APPLE) + // Disabled until we support raw AAC: https://github.com/google/shaka-player/issues/2337 + .markAsDisabled() .addFeature(shakaAssets.Feature.HLS) .addFeature(shakaAssets.Feature.MP2TS) .addFeature(shakaAssets.Feature.CAPTIONS) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index a952328d5d..781e892549 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -1159,6 +1159,12 @@ shaka.hls.HlsParser = class { /** @type {string} */ const mimeType = await this.guessMimeType_(type, codecs, playlist); + // MediaSource expects no codec strings combined with raw formats. + // TODO(#2337): Replace with a flag indicating a raw format. + if (mimeType == 'audio/mpeg' || mimeType == 'audio/aac') { + codecs = ''; + } + const mediaSequenceTag = shaka.hls.Utils.getFirstTagWithName(playlist.tags, 'EXT-X-MEDIA-SEQUENCE'); @@ -1622,10 +1628,12 @@ shaka.hls.HlsParser = class { shaka.log.v1('Fetching segment to find start time'); - if (mimeType == 'audio/mpeg') { - // There is no standard way to embed timestamps in mp3 files, so the - // start time is presumably 0. - return 0; + if (mimeType == 'audio/mpeg' || mimeType == 'audio/aac') { + // Raw MP3 and AAC files contain no timestamps. + // Don't return a false timestamp. We want to treat them as aligning to + // their corresponding video segments. + // TODO(#2337): Avoid trying to fetch timestamps for raw formats. + return null; } if (mimeType == 'video/mp4' || mimeType == 'audio/mp4') { @@ -1660,16 +1668,6 @@ shaka.hls.HlsParser = class { return null; } - - // TODO(vaage): Add support for additional formats. - // Formats: - // - WebM - // - AAC - // - // Since we want to add more formats, how would a more general registry - // system work to allow additional formats to be "plugged-into" the - // parser. - throw new shaka.util.Error( shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.MANIFEST, @@ -2275,6 +2273,7 @@ shaka.hls.HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_ = { 'm4a': 'audio/mp4', // MPEG2-TS also uses video/ for audio: https://bit.ly/TsMse 'ts': 'video/mp2t', + 'aac': 'audio/aac', };