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

Ignore representations which use incompatible codecs for TrickMode #2984

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
11 changes: 7 additions & 4 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,17 @@ shaka.dash.DashParser = class {

// Attach trick mode tracks to normal tracks.
for (const trickModeSet of trickModeAdaptationSets) {
// There may be multiple trick mode streams, but we do not currently
// support that. Just choose one.
const trickModeVideo = trickModeSet.streams[0];
const targetId = trickModeSet.trickModeFor;
for (const normalSet of normalAdaptationSets) {
if (normalSet.id == targetId) {
for (const stream of normalSet.streams) {
stream.trickModeVideo = trickModeVideo;
const MimeUtils = shaka.util.MimeUtils;
// There may be multiple trick mode streams, but we do not
// currently support that. Just choose one.
// TODO: https://github.com/google/shaka-player/issues/1528
stream.trickModeVideo = trickModeSet.streams.find((trickStream) =>
MimeUtils.getCodecBase(stream.codecs) ==
MimeUtils.getCodecBase(trickStream.codecs));
}
}
}
Expand Down
32 changes: 30 additions & 2 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,14 +978,14 @@ describe('DashParser Manifest', () => {
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet id="1" mimeType="video/mp4">',
' <Representation bandwidth="1">',
' <Representation bandwidth="1" codecs="avc1.4d401f">',
' <SegmentTemplate media="1.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' <AdaptationSet id="2" mimeType="video/mp4">',
' <EssentialProperty value="1" ',
' schemeIdUri="http://dashif.org/guidelines/trickmode" />',
' <Representation bandwidth="1">',
' <Representation bandwidth="1" codecs="avc1.4d401f">',
' <SegmentTemplate media="2.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
Expand All @@ -1008,6 +1008,34 @@ describe('DashParser Manifest', () => {
}));
});

it('ignore incompatible trickmode tracks', async () => {
const manifestText = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet id="1" mimeType="video/mp4">',
' <Representation bandwidth="1" codecs="avc1.4d401f">',
' <SegmentTemplate media="1.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' <AdaptationSet id="2" mimeType="video/mp4">',
' <EssentialProperty value="1" ',
' schemeIdUri="http://dashif.org/guidelines/trickmode" />',
' <Representation bandwidth="1" codecs="foo">',
' <SegmentTemplate media="2.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].join('\n');

fakeNetEngine.setResponseText('dummy://foo', manifestText);
/** @type {shaka.extern.Manifest} */
const manifest = await parser.start('dummy://foo', playerInterface);
expect(manifest.variants.length).toBe(1);
expect(manifest.textStreams.length).toBe(0);
expect(manifest.variants[0].video.trickModeVideo).toBeUndefined();
});

it('skips unrecognized EssentialProperty elements', async () => {
const manifestText = [
'<MPD minBufferTime="PT75S">',
Expand Down