Skip to content

Commit

Permalink
fix: Transmux containerless to the correct mimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed May 2, 2023
1 parent 866ddb0 commit 532ea3d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
18 changes: 0 additions & 18 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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 @@ -1918,9 +1917,6 @@ shaka.hls.HlsParser = class {
// segment index, then download when createSegmentIndex is called.
const stream = this.makeStreamObject_(codecs, type, language, primary, name,
channelsCount, closedCaptions, characteristics, forced, spatialAudio);
if (shaka.media.MediaSourceEngine.RAW_FORMATS.includes(stream.mimeType)) {
stream.codecs = '';
}
const streamInfo = {
stream,
type,
Expand Down Expand Up @@ -1983,9 +1979,6 @@ shaka.hls.HlsParser = class {
stream.drmInfos = realStream.drmInfos;
stream.keyIds = realStream.keyIds;
stream.mimeType = realStream.mimeType;
if (shaka.media.MediaSourceEngine.RAW_FORMATS.includes(stream.mimeType)) {
stream.codecs = '';
}

// Since we lazy-loaded this content, the player may need to create new
// sessions for the DRM info in this stream.
Expand All @@ -2000,10 +1993,6 @@ shaka.hls.HlsParser = class {
// To aid manifest filtering, assume before loading that all video
// renditions have the same MIME type. (And likewise for audio.)
otherStreamInfo.stream.mimeType = realStream.mimeType;
if (shaka.media.MediaSourceEngine.RAW_FORMATS
.includes(otherStreamInfo.stream.mimeType)) {
otherStreamInfo.stream.codecs = '';
}
}
}
}
Expand Down Expand Up @@ -2134,13 +2123,6 @@ shaka.hls.HlsParser = class {
streamInfo.stream.segmentIndex.fit(/* periodStart= */ 0, minDuration);
}
}
// MediaSource expects no codec strings combined with raw formats.
for (const streamInfo of streamInfos) {
const stream = streamInfo.stream;
if (shaka.media.MediaSourceEngine.RAW_FORMATS.includes(stream.mimeType)) {
stream.codecs = '';
}
}
this.notifySegmentsForStreams_(streamInfos.map((s) => s.stream));
if (this.config_.hls.ignoreManifestProgramDateTime) {
this.syncStreamsWithSequenceNumber_(streamInfos);
Expand Down
12 changes: 9 additions & 3 deletions lib/transmuxer/muxjs_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ goog.require('shaka.transmuxer.TransmuxerEngine');
goog.require('shaka.util.BufferUtils');
goog.require('shaka.util.Error');
goog.require('shaka.util.ManifestParserUtils');
goog.require('shaka.util.MimeUtils');
goog.require('shaka.util.PublicPromise');
goog.require('shaka.util.Uint8ArrayUtils');

Expand Down Expand Up @@ -85,7 +86,7 @@ shaka.transmuxer.MuxjsTransmuxer = class {
}

if (isAac) {
return Capabilities.isTypeSupported(this.convertAacCodecs_());
return Capabilities.isTypeSupported(this.convertAacCodecs_(mimeType));
}

if (contentType) {
Expand Down Expand Up @@ -130,7 +131,7 @@ shaka.transmuxer.MuxjsTransmuxer = class {
*/
convertCodecs(contentType, mimeType) {
if (this.isAacContainer_(mimeType)) {
return this.convertAacCodecs_();
return this.convertAacCodecs_(mimeType);
} else if (this.isTsContainer_(mimeType)) {
return this.convertTsCodecs_(contentType, mimeType);
}
Expand All @@ -140,10 +141,15 @@ shaka.transmuxer.MuxjsTransmuxer = class {

/**
* For aac stream, convert its codecs to MP4 codecs.
* @param {string} mimeType
* @return {string}
* @private
*/
convertAacCodecs_() {
convertAacCodecs_(mimeType) {
const codecs = shaka.util.MimeUtils.getCodecs(mimeType);
if (codecs != '') {
return `audio/mp4; codecs="${codecs}"`;
}
return 'audio/mp4; codecs="mp4a.40.2"';
}

Expand Down
16 changes: 16 additions & 0 deletions test/player_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,22 @@ describe('Player', () => {
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 1, 10);
});

it('with containerless formats', async () => {
player = new compiledShaka.Player(video);
// eslint-disable-next-line max-len
const url = 'https://storage.googleapis.com/shaka-demo-assets/raw-hls-audio-only/manifest.m3u8';
await player.load(url, 0);

// Ensure the video plays.
video.play();
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 5, 10);

// Seek the video, and see if it can continue playing from that point.
video.currentTime = 1790;
// Expect that we can then reach the end of the video.
await waiter.timeoutAfter(40).waitForEnd(video);
});

/**
* Gets the language of the active Variant.
* @return {string}
Expand Down

0 comments on commit 532ea3d

Please sign in to comment.