Class: shaka.msf.MediaTimeline

Members

entries_ :Array<shaka.msf.MediaTimeline.Entry>

Explicit entries, sorted ascending by media time.
Type:
Source:

entriesByLocation_ :Map<string, shaka.msf.MediaTimeline.Entry>

The same entries, keyed by Location. It keeps a record repeated across an incremental update from being stored twice, and answers a lookup by Location without walking the list.
Type:
Source:

Methods

atIndex_(template, index) → {shaka.msf.MediaTimeline.Entry}

Expands a template at one index, per the formulas in MSF section 7.4.1.
Parameters:
Name Type Description
template shaka.msf.MediaTimeline.Template
index bigint
Source:
Returns:
Type
shaka.msf.MediaTimeline.Entry

key_(group, object) → {string}

Parameters:
Name Type Description
group bigint
object bigint
Source:
Returns:
Type
string

parseEntry_(record) → {shaka.msf.MediaTimeline.Entry}

Reads one record of the explicit format: a media presentation timestamp in milliseconds, a Location as a two-number array, and a wallclock time in milliseconds since the epoch.
Parameters:
Name Type Description
record *
Source:
Returns:
Type
shaka.msf.MediaTimeline.Entry

parseTemplate_(templatenon-null) → {shaka.msf.MediaTimeline.Template}

Reads the six mandatory values of the template format, in the fixed order MSF section 7.4.1 gives them.
Parameters:
Name Type Description
template Array<*>
Source:
Returns:
Type
shaka.msf.MediaTimeline.Template

readIndex_(value) → {bigint}

Reads a Group or Object ID, which are MoQT var ints and so cannot be negative or fractional.
Parameters:
Name Type Description
value *
Source:
Returns:
Type
bigint

readNumber_(value) → {number}

Parameters:
Name Type Description
value *
Source:
Returns:
The value when it is a finite JSON Number, else null.
Type
number

addObject(datanon-null, independent) → {boolean}

Takes in one Object of a media timeline track. The first Object of each Group is independent: it carries every record accessible at that point, so it replaces what came before rather than adding to it, and a record that has aged out of it is gone from the timeline too. The Objects after it in the same Group carry only what is new (MSF section 7.3).
Parameters:
Name Type Description
data Uint8Array The Object payload, a JSON document.
independent boolean Whether this is the first Object of a Group.
Source:
Returns:
True if the timeline changed.
Type
boolean

entryForTime_(time) → {shaka.msf.MediaTimeline.Entry}

The entry covering a presentation time: the last one at or before it.
Parameters:
Name Type Description
time number In seconds.
Source:
Returns:
Type
shaka.msf.MediaTimeline.Entry

getEndTime() → {number}

The latest media time an explicit record describes, in seconds, or null when there are none. A template has no end: it extrapolates as far as it is asked to. The live edge is the presentation timeline's business, not this class's, so a template-only timeline answers null here rather than inventing one.
Source:
Returns:
Type
number

getStartTime() → {number}

The earliest media time this timeline describes, in seconds, or null when it describes nothing. For an explicit timeline this is the oldest record the publisher still offers, which is the start of the seekable range. For a template it is the start of the presentation, which the publisher asserts is addressable.
Source:
Returns:
Type
number

isEmpty() → {boolean}

Whether anything is known at all. An empty timeline answers null to every lookup, and the parser treats it as though there were no timeline.
Source:
Returns:
Type
boolean

locationForTime(time) → {shaka.msf.Utils.Location}

The Location to subscribe from in order to receive the media that covers the given presentation time, or null when the timeline cannot say. The answer is the entry at or before that time, because a subscription that started at the entry after it would skip the content asked for.
Parameters:
Name Type Description
time number In seconds.
Source:
Returns:
Type
shaka.msf.Utils.Location

setTemplate(templatenon-null) → {boolean}

Takes in the `template` field of a catalog track.
Parameters:
Name Type Description
template Array<*>
Source:
Returns:
True if the template was usable.
Type
boolean

timeForLocation(location) → {number}

The presentation time of the media at a Location, in seconds, or null when the timeline does not describe that Location.
Parameters:
Name Type Description
location shaka.msf.Utils.Location
Source:
Returns:
Type
number

wallClockForTime(time) → {number}

The wallclock time at which the media at the given presentation time was encoded, in milliseconds since the epoch, or null when it is not known. MSF says a publisher that does not know it sends 0, which is also what a VOD asset carries, so a zero is reported as "not known" rather than as 1 January 1970.
Parameters:
Name Type Description
time number In seconds.
Source:
Returns:
Type
number

Type Definitions

Entry

One media timeline record: the media presentation time of an Object, in seconds, where it sits in the track, and when it was encoded, in milliseconds since the epoch, or 0 when that is not known.
Type:
  • {time: number, group: bigint, object: bigint, wallClock: number}
Source:

Template

A parsed media timeline template. Times are seconds for the start and milliseconds for the intervals, matching how each is used: the start is compared against presentation times, the intervals are multiplied by an index.
Type:
  • {startTime: number, deltaTime: number, startGroup: bigint, startObject: bigint, deltaGroup: bigint, deltaObject: bigint, startWallClock: number, deltaWallClock: number}
Source: