Skip to content

Commit

Permalink
feat(MediaCap): Support multiplex content with MediaCap
Browse files Browse the repository at this point in the history
If we have a multiplexd content with audio and video, we combine
the audio and video codecs in the manifest parser.
For example, a multiplexed stream would be with:
mimeType="video/mp4", codecs="avc1.64001e,mp4a.40.2".

When sending the request to MediaCapabilities.decodingInfo(), we
need to have the config for both audio and video to get the result
as "supported".
The video config would be:
contentType='video/mp4, codecs="avc1.64001e"'.
The audio config would be:
contentType='audio/mp4, codecs="mp4a.40.2"'.

Issue #1391

Change-Id: I74a8580c07228e9600dc40c611ebd5d34f8cd7ee
  • Loading branch information
michellezhuogg committed Mar 23, 2021
1 parent acfa1a8 commit 966a756
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,25 @@ shaka.util.StreamUtils = class {
};

if (video) {
let audioCodec;
let videoCodec = video.codecs;

// For multiplexed streams with audio+video codecs, the config should have
// AudioConfiguration and VideoConfiguration.
if (video.codecs.includes(',')) {
[videoCodec, audioCodec] = video.codecs.split(',');
const audioFullType = shaka.util.MimeUtils.getFullOrConvertedType(
video.mimeType, audioCodec, ContentType.AUDIO);
mediaDecodingConfig['audio'] = {
contentType: audioFullType,
channels: 2,
bitrate: variant.bandwidth || 1,
samplerate: 1,
spatialRendering: false,
};
}
const fullType = shaka.util.MimeUtils.getFullOrConvertedType(
video.mimeType, video.codecs, ContentType.VIDEO);
video.mimeType, videoCodec, ContentType.VIDEO);
// VideoConfiguration
mediaDecodingConfig['video'] = {
contentType: fullType,
Expand Down
18 changes: 18 additions & 0 deletions test/util/stream_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,24 @@ describe('StreamUtils', () => {
});
});

describe('getDecodingInfosForVariants', () => {
it('for multiplexd content', async () => {
manifest = shaka.test.ManifestGenerator.generate((manifest) => {
manifest.addVariant(0, (variant) => {
variant.addVideo(1, (stream) => {
stream.mime('video/mp2t', 'avc1.4d400d,mp4a.40.2');
});
});
});

await shaka.util.StreamUtils.getDecodingInfosForVariants(
manifest.variants);
expect(manifest.variants.length).toBeTruthy();
expect(manifest.variants[0].decodingInfos.length).toBe(1);
expect(manifest.variants[0].decodingInfos[0].supported).toBeTruthy();
});
});

describe('filterManifest', () => {
let fakeDrmEngine;

Expand Down

0 comments on commit 966a756

Please sign in to comment.