Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Probe for containerless format support. #3931

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demo/main.js
Original file line number Diff line number Diff line change
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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only try audio/aac if there are other possible formats? (audio/mpeg for example)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I should probably have the mime type be a separate feature flag, then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for the purpose of filtering assets in the demo, and I have not encountered an up-to-date browser in the last several years that doesn't support AAC.

In the library, we have the parsed manifest and knowledge of the exact format/codec, so querying for support there is more accurate and detailed. At this level, though, I think checking for raw AAC support is enough to enable what containerless content we have in the demo.

And if it turns out that I'm wrong, we can always change it later. :-)

}
const hasSupportedMimeType = mimeTypes.some((type) => {
return this.support_.media[type];
});
Expand Down
18 changes: 2 additions & 16 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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',
];