Skip to content

Commit

Permalink
feat: add presentationTime as an attribute on each SegmentTemplate se…
Browse files Browse the repository at this point in the history
…gment (#139)
  • Loading branch information
gesinger authored Jul 27, 2021
1 parent 39109d0 commit a972b8c
Show file tree
Hide file tree
Showing 11 changed files with 556 additions and 174 deletions.
13 changes: 12 additions & 1 deletion src/segment/segmentTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,25 @@ export const segmentsFromTemplate = (attributes, segmentTimeline) => {
templateValues.Time = segment.time;

const uri = constructTemplateUrl(attributes.media || '', templateValues);
// See DASH spec section 5.3.9.2.2
// - if timescale isn't present on any level, default to 1.
const timescale = attributes.timescale || 1;
// - if presentationTimeOffset isn't present on any level, default to 0
const presentationTimeOffset = attributes.presentationTimeOffset || 0;
// presentationTimeOffset has already been adjusted by the timescale
const presentationTime =
// Even if the @t attribute is not specified for the segment, segment.time is
// calculated in mpd-parser prior to this, so it's assumed to be available.
attributes.periodStart + (segment.time / timescale) - presentationTimeOffset;

const map = {
uri,
timeline: segment.timeline,
duration: segment.duration,
resolvedUri: resolveUrl(attributes.baseUrl || '', uri),
map: mapSegment,
number: segment.number
number: segment.number,
presentationTime
};

if (attributes.presentationTimeOffset) {
Expand Down
Loading

0 comments on commit a972b8c

Please sign in to comment.