Skip to content

Commit

Permalink
fix(DASH): Fix dynamic manifests from edgeware (#4914)
Browse files Browse the repository at this point in the history
Fixes #4913

---------

Co-authored-by: Joey Parrish <[email protected]>
Co-authored-by: Joey Parrish <[email protected]>
  • Loading branch information
3 people committed Jan 30, 2023
1 parent 0705ce4 commit 247229b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 41 deletions.
22 changes: 17 additions & 5 deletions lib/dash/segment_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,23 @@ shaka.dash.SegmentTemplate = class {
const periodEnd = context.periodInfo.duration ?
context.periodInfo.start + context.periodInfo.duration : Infinity;

// Don't fit live content, since it might receive more segments.
// Unless that live content is multi-period; it's safe to fit every period
// but the last one, since only the last period might receive new
// segments.
const shouldFit = periodEnd != Infinity;
/* When to fit segments. All refactors should honor/update this table:
*
* | dynamic | infinite | last | should | notes |
* | | period | period | fit | |
* | ------- | -------- | ------ | ------ | ------------------------- |
* | F | F | X | T | typical VOD |
* | F | T | X | X | impossible: infinite VOD |
* | T | F | F | T | typical live, old period |
* | T | F | T | F | typical IPR |
* | T | T | F | X | impossible: old, infinite |
* | T | T | T | F | typical live, new period |
*/

// We never fit the final period of dynamic content, which could be
// infinite live (with no limit to fit to) or IPR (which would expand the
// most recent segment to the end of the presentation).
const shouldFit = !(context.dynamic && context.periodInfo.isLastPeriod);

if (segmentIndex) {
if (shouldFit) {
Expand Down
36 changes: 0 additions & 36 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,42 +195,6 @@ describe('DashParser Manifest', () => {
}));
});

it('rejects periods after one without duration', async () => {
const periodContents = [
' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
' <Representation bandwidth="100">',
' <SegmentTemplate startNumber="1" media="l-$Number$.mp4">',
' <SegmentTimeline>',
' <S t="0" d="10" />',
' </SegmentTimeline>',
' </SegmentTemplate>',
' </Representation>',
' </AdaptationSet>',
].join('\n');
const template = [
'<MPD mediaPresentationDuration="PT75S">',
' <Period id="1">',
'%(periodContents)s',
' </Period>',
' <Period id="2">',
'%(periodContents)s',
' </Period>',
'</MPD>',
].join('\n');
const source = sprintf(template, {periodContents: periodContents});

fakeNetEngine.setResponseText('dummy://foo', source);
/** @type {shaka.extern.Manifest} */
const manifest = await parser.start('dummy://foo', playerInterface);
const video = manifest.variants[0].video;
await video.createSegmentIndex();

// The first period has a segment from 0-10.
// With the second period skipping, we should fail to find a segment at 10.
expect(video.segmentIndex.find(0)).not.toBe(null);
expect(video.segmentIndex.find(10)).toBe(null);
});

it('calculates Period times when missing', async () => {
const periodContents = [
' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
Expand Down

0 comments on commit 247229b

Please sign in to comment.