Class: shaka.util.CmcdManager

A CmcdManager maintains CMCD state as well as a collection of utility functions.

Constructor

new CmcdManager(playerInterface, config)

A CmcdManager maintains CMCD state as well as a collection of utility functions.

Parameters:
Name Type Description
playerInterface shaka.util.CmcdManager.PlayerInterface
config shaka.extern.CmcdConfiguration
Source:

Members

ObjectType :string

Type:
  • string
Properties:
Name Value Type Description
MANIFEST m string
AUDIO a string
VIDEO v string
MUXED av string
INIT i string
CAPTION c string
TIMED_TEXT tt string
KEY k string
OTHER o string
Source:

StreamingFormat :string

Type:
  • string
Properties:
Name Value Type Description
DASH d string
HLS h string
SMOOTH s string
OTHER o string
Source:

StreamType :string

Type:
  • string
Properties:
Name Value Type Description
VOD v string
LIVE l string
Source:

Version :number

The CMCD spec version
Type:
  • number
Source:

buffering_ :boolean

Type:
  • boolean
Source:

playbackStarted_ :boolean

Type:
  • boolean
Source:

sid_ :string

Session ID
Type:
  • string
Source:

starved_ :boolean

Type:
  • boolean
Source:

Methods

appendQueryToUri(uri, query) → {string}

Append query args to a uri.
Parameters:
Name Type Description
uri string
query string
Source:
Returns:
Type
string

serialize(data) → {string}

Serialize a CMCD data object according to the rules defined in the section 3.2 of [CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf).
Parameters:
Name Type Description
data CmcdData The CMCD data object
Source:
Returns:
Type
string

toHeaders(data) → {Object}

Convert a CMCD data object to request headers according to the rules defined in the section 2.1 and 3.2 of [CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf).
Parameters:
Name Type Description
data CmcdData The CMCD data object
Source:
Returns:
Type
Object

toQuery(data) → {string}

Convert a CMCD data object to query args according to the rules defined in the section 2.2 and 3.2 of [CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf).
Parameters:
Name Type Description
data CmcdData The CMCD data object
Source:
Returns:
Type
string

appendSrcData(uri, mimeType) → {string}

Apply CMCD data to streams loaded via src=.
Parameters:
Name Type Description
uri string
mimeType string
Source:
Returns:
Type
string

appendTextTrackData(uri) → {string}

Apply CMCD data to side car text track uri.
Parameters:
Name Type Description
uri string
Source:
Returns:
Type
string

apply_(requestnon-null, datanon-null, useHeaders)

Apply CMCD data to a request.
Parameters:
Name Type Description
request shaka.extern.Request The request to apply CMCD data to
data CmcdData The data object
useHeaders boolean Send data via request headers
Source:

applyManifestData(requestnon-null, manifestInfo)

Apply CMCD data to a manifest request.
Parameters:
Name Type Description
request shaka.extern.Request The request to apply CMCD data to
manifestInfo shaka.util.CmcdManager.ManifestInfo The manifest format
Source:

applySegmentData(requestnon-null, segmentInfo)

Apply CMCD data to a segment request
Parameters:
Name Type Description
request shaka.extern.Request
segmentInfo shaka.util.CmcdManager.SegmentInfo
Source:

applyTextData(requestnon-null)

Apply CMCD data to a text request
Parameters:
Name Type Description
request shaka.extern.Request
Source:

createData_() → {CmcdData}

Create baseline CMCD data
Source:
Returns:
Type
CmcdData

getBufferLength_(type) → {number}

Get the buffer length for a media type in milliseconds
Parameters:
Name Type Description
type string
Source:
Returns:
Type
number

getObjectType_(segmentInfo)

The CMCD object type.
Parameters:
Name Type Description
segmentInfo shaka.util.CmcdManager.SegmentInfo
Source:

getObjectTypeFromMimeType_(mimeTypenon-null) → {shaka.util.CmcdManager.ObjectType|undefined}

The CMCD object type from mimeType.
Parameters:
Name Type Description
mimeType string
Source:
Returns:
Type
shaka.util.CmcdManager.ObjectType | undefined

getStreamType_() → {shaka.util.CmcdManager.StreamType}

Get the stream type
Source:
Returns:
Type
shaka.util.CmcdManager.StreamType

getTopBandwidth_(type) → {number}

Get the highest bandwidth for a given type.
Parameters:
Name Type Description
type string
Source:
Returns:
Type
number

setBuffering(buffering)

Set the buffering state
Parameters:
Name Type Description
buffering boolean
Source:

Type Definitions

ManifestInfo

Type:
Properties:
Name Type Description
format shaka.util.CmcdManager.StreamingFormat The manifest's stream format
Source:

PlayerInterface

Type:
  • {getBandwidthEstimate: function(): number, getBufferedInfo: function(): shaka.extern.BufferedInfo, getCurrentTime: function(): number, getVariantTracks: function(): Array.<shaka.extern.Track>, getPlaybackRate: function(): number, isLive: function(): boolean}
Properties:
Name Type Description
getBandwidthEstimate function Get the estimated bandwidth in bits per second.
getBufferedInfo function Get information about what the player has buffered.
getCurrentTime function Get the current time
getVariantTracks function Get the variant tracks
getPlaybackRate function Get the playback rate
isLive function Get if the player is playing live content.
Source:

SegmentInfo

Type:
  • {type: string, init: boolean, duration: number, mimeType: string, codecs: string, bandwidth: (number|undefined)}
Properties:
Name Type Description
type string The media type
init boolean Flag indicating whether the segment is an init segment
duration number The duration of the segment in seconds
mimeType string The segment's mime type
codecs string The segment's codecs
bandwidth number | undefined The segment's variation bandwidth
Source: