Skip to content

Commit

Permalink
feat: Allow playback of HLS Media Playlist with AAC by default (shaka…
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Oct 11, 2022
1 parent 3c75d1a commit 757b34e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,16 @@ shaka.hls.HlsParser = class {
// Get necessary info for this stream, from the config. These are things
// we would normally find from the master playlist (e.g. from values on
// EXT-X-MEDIA tags).
const fullMimeType = this.config_.hls.mediaPlaylistFullMimeType;
let fullMimeType = this.config_.hls.mediaPlaylistFullMimeType;
// Try to infer the full mimetype better.
if (playlist.segments.length) {
const parsedUri = new goog.Uri(playlist.segments[0].absoluteUri);
const extension = parsedUri.getPath().split('.').pop();
if (extension === 'aac') {
fullMimeType = 'audio/aac';
}
}

const mimeType = shaka.util.MimeUtils.getBasicType(fullMimeType);
const type = mimeType.split('/')[0];
const codecs = shaka.util.MimeUtils.getCodecs(fullMimeType);
Expand Down
26 changes: 26 additions & 0 deletions test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3871,6 +3871,32 @@ describe('HlsParser', () => {
await testHlsParser(media, '', manifest);
});

it('honors hls.mediaPlaylistFullMimeType but detects AAC', async () => {
const media = [
'#EXTM3U\n',
'#EXT-X-PLAYLIST-TYPE:VOD\n',
'#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n',
'#EXTINF:5,\n',
'#EXT-X-BYTERANGE:121090@616\n',
'main.aac',
].join('');

const config = shaka.util.PlayerConfiguration.createDefault().manifest;
parser.configure(config);

const manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.sequenceMode = true;
manifest.anyTimeline();
manifest.addPartialVariant((variant) => {
variant.addPartialStream(ContentType.AUDIO, (stream) => {
stream.mime('audio/aac');
});
});
});

await testHlsParser(media, '', manifest);
});

it('syncs on sequence with ignoreManifestProgramDateTime', async () => {
const config = shaka.util.PlayerConfiguration.createDefault().manifest;
config.hls.ignoreManifestProgramDateTime = true;
Expand Down

0 comments on commit 757b34e

Please sign in to comment.