Skip to content

Commit

Permalink
demo: Probe for containerless format support (#3931)
Browse files Browse the repository at this point in the history
Issue #2337
  • Loading branch information
theodab committed Feb 9, 2022
1 parent 6034db8 commit b005a7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
3 changes: 3 additions & 0 deletions demo/main.js
Expand Up @@ -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];
});
Expand Down
18 changes: 2 additions & 16 deletions lib/hls/hls_parser.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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 = '';
}

Expand Down Expand Up @@ -2411,19 +2410,6 @@ shaka.hls.HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_ = {
};


/**
* MIME types of raw formats.
*
* @const {!Array.<string>}
*/
shaka.hls.HlsParser.RAW_FORMATS = [
'audio/aac',
'audio/ac3',
'audio/ec3',
'audio/mpeg',
];


/**
* @const {!Object.<string, string>}
* @private
Expand Down
15 changes: 15 additions & 0 deletions lib/media/media_source_engine.js
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -1172,3 +1174,16 @@ shaka.media.MediaSourceEngine.SourceBufferMode_ = {
SEQUENCE: 'sequence',
SEGMENTS: 'segments',
};


/**
* MIME types of raw formats.
*
* @const {!Array.<string>}
*/
shaka.media.MediaSourceEngine.RAW_FORMATS = [
'audio/aac',
'audio/ac3',
'audio/ec3',
'audio/mpeg',
];

0 comments on commit b005a7c

Please sign in to comment.