Skip to content

Commit

Permalink
Recognize and reject raw AAC in HLS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joeyparrish committed Jan 13, 2020
1 parent 9909c2b commit d2ccc62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 2 additions & 0 deletions demo/common/assets.js
Expand Up @@ -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)
Expand Down
27 changes: 13 additions & 14 deletions lib/hls/hls_parser.js
Expand Up @@ -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');

Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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',
};


Expand Down

0 comments on commit d2ccc62

Please sign in to comment.