Skip to content

Commit

Permalink
fix(media): Ignore incompatible TrickMode streams (#2984)
Browse files Browse the repository at this point in the history
Resolves: #2846
  • Loading branch information
Álvaro Velad Galván authored and joeyparrish committed Dec 14, 2020
1 parent fb019a6 commit 1e11c75
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,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 @@ -913,14 +913,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 @@ -943,6 +943,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

0 comments on commit 1e11c75

Please sign in to comment.