Constructor
new CmcdManager(player, config)
A CmcdManager maintains CMCD state as well as a collection of utility functions.
Parameters:
Name | Type | Description |
---|---|---|
player |
shaka.Player | |
config |
shaka.extern.CmcdConfiguration |
- Source:
Members
CmcdKeys :Array<string>
Type:
- Array<string>
Properties:
Name | Value | Type | Description |
---|---|---|---|
V1Keys |
["br","bl","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"] | Array<string> | |
V2CommonKeys |
["br","ab","bl","tbl","bs","cdn","cid","ltc","mtp","pr","sf","sid","bg","sta","st","ts","tpb","tb","lb","tab","lab","pt","ec","msd","v","sn"] | Array<string> | |
V2RequestModeKeys |
["ab","bl","tbl","bs","cdn","cid","d","dl","ltc","mtp","nor","ot","pr","rtp","sf","sid","bg","sta","st","su","ts","tpb","tb","lb","tab","lab","pt","ec","msd","v"] | Array<string> | |
V2ResponseModeKeys |
["d","dl","nor","ot","rtp","rc","su","ttfb","ttfbb","ttlb","url","cmsdd","cmsds"] | Array<string> | |
V2EventKeys |
["e","sta"] | Array<string> | |
CmcdV2Events |
["ps","e","t","c","b","m","um","pe","pc"] | Array<string> | |
CmcdV2PlayStates |
["s","p","a","w","k","r","f","e","q","d"] | Array<string> |
- Source:
CmcdMode :string
Type:
- string
Properties:
Name | Value | Type | Description |
---|---|---|---|
REQUEST |
request | string | |
RESPONSE |
response | string | |
EVENT |
event | string |
- Source:
CmcdV2Constants :number
Type:
- number
Properties:
Name | Value | Type | Description |
---|---|---|---|
TIME_INTERVAL_DEFAULT_VALUE |
10 | number |
- Source:
CmcdV2Keys :string
Type:
- string
Properties:
Name | Value | Type | Description |
---|---|---|---|
TIMESTAMP |
ts | string | |
TIME_INTERVAL_EVENT |
t | string |
- Source:
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 | |
LOW_LATENCY_DASH |
ld | string | |
HLS |
h | string | |
LOW_LATENCY_HLS |
lh | 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
Type:
- number
Properties:
Name | Value | Type | Description |
---|---|---|---|
VERSION_1 |
1 | number | |
VERSION_2 |
2 | number |
- Source:
cmcdSequenceNumbers_ :Object<string, {request: number, response: number}>
Type:
- Object<string, {request: number, response: number}>
- Source:
playbackPlayingTime_ :number|undefined
Type:
- number | undefined
- Source:
playbackPlayTime_ :number|undefined
Type:
- number | undefined
- Source:
requestTimestampMap_ :Map<!shaka.extern.Request, number>
Type:
- Map<!shaka.extern.Request, number>
- Source:
sf_ :shaka.util.CmcdManager.StreamingFormat|undefined
Streaming format
Type:
- shaka.util.CmcdManager.StreamingFormat | undefined
- 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
applyCmcdDataToRequest_(outputnon-null, requestnon-null, useHeaders)
Modifies an existing request object by adding CMCD data to it.
Parameters:
Name | Type | Description |
---|---|---|
output |
CmcdData | The CMCD data to apply. |
request |
shaka.extern.Request | The request object to modify. |
useHeaders |
boolean | Whether to use headers or query parameters. |
- Source:
applyManifestData(requestnon-null, context)
Apply CMCD data to a manifest request.
Parameters:
Name | Type | Description |
---|---|---|
request |
shaka.extern.Request | The request to apply CMCD data to |
context |
shaka.extern.RequestContext | The request context |
- Source:
applyRequest_(requestnon-null, datanon-null)
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 |
- Source:
applyRequestData(typenon-null, requestnon-null, contextopt)
Apply CMCD data to a request.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | The request type | |
request |
shaka.extern.Request | The request to apply CMCD data to | |
context |
shaka.extern.RequestContext |
<optional> |
The request context |
- Source:
applyRequestSegmentData(requestnon-null, context)
Apply CMCD data to a segment request
Parameters:
Name | Type | Description |
---|---|---|
request |
shaka.extern.Request | |
context |
shaka.extern.RequestContext | The request context |
- Source:
applyResponse_(responsenon-null, datanon-null)
Apply CMCD data to a response.
Parameters:
Name | Type | Description |
---|---|---|
response |
shaka.extern.Response | The request to apply CMCD data to |
data |
CmcdData | The data object |
- Source:
applyResponseData(typenon-null, responsenon-null, contextopt)
Apply CMCD data to a response.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
shaka.net.NetworkingEngine.RequestType | The request type | |
response |
shaka.extern.Response | The response to apply CMCD data to | |
context |
shaka.extern.RequestContext |
<optional> |
The request context |
- Source:
applyResponseSegmentData(responsenon-null, context)
Apply CMCD data to a segment response
Parameters:
Name | Type | Description |
---|---|---|
response |
shaka.extern.Response | |
context |
shaka.extern.RequestContext | The request context |
- Source:
applyTextData(requestnon-null)
Apply CMCD data to a text request
Parameters:
Name | Type | Description |
---|---|---|
request |
shaka.extern.Request |
- Source:
calculateMSD_() → {number|undefined}
Calculate measured start delay
- Source:
Returns:
- Type
- number | undefined
calculateRtp_(stream, segment) → {number}
Calculate requested maximum throughput
Parameters:
Name | Type | Description |
---|---|---|
stream |
shaka.extern.Stream | |
segment |
shaka.media.SegmentReference |
- Source:
Returns:
- Type
- number
checkValidKeys_(includeKeys, allowedKeys, mode) → {Array<string>}
Checks if the keys in `includeKeys` are valid against a list of
`allowedKeys`. It logs an error for any invalid key and returns a new array
containing only the valid keys. If `includeKeys` is empty or not provided,
it returns all `allowedKeys`.
Parameters:
Name | Type | Description |
---|---|---|
includeKeys |
Array<string> | Keys to validate. |
allowedKeys |
Array<string> | The list of allowed keys. |
mode |
string | Mode ('query', 'header' or 'event') for error logging. |
- Source:
Returns:
A new array containing only the valid keys.
- Type
- Array<string>
configure(config)
Called by the Player to provide an updated configuration any time it
changes.
Parameters:
Name | Type | Description |
---|---|---|
config |
shaka.extern.CmcdConfiguration |
- Source:
createData_() → {CmcdData}
Create baseline CMCD data
- Source:
Returns:
- Type
- CmcdData
filterKeys_(data, includeKeys) → {CmcdData}
Filter the CMCD data object to include only the keys specified in the
configuration.
Parameters:
Name | Type | Description |
---|---|---|
data |
CmcdData | |
includeKeys |
Array<string> |
- 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
getCmcdTargetHash_(objnon-null) → {string}
Creates a stable string key from a configuration object.
This is used to uniquely identify a CMCD target.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The object to hash. |
- Source:
Returns:
- Type
- string
getCurrentTime_() → {number}
Get player time.
- Source:
Returns:
- Type
- number
getDataForSegment_(context, requestUrinullable) → {CmcdData}
Get CMCD data for a segment.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
context |
shaka.extern.RequestContext | The request context | |
requestUri |
string |
<nullable> |
- Source:
Returns:
- Type
- CmcdData
getEventModeEnabledTargets_() → {Array<shaka.extern.CmcdTarget>}
- Source:
Returns:
- Type
- Array<shaka.extern.CmcdTarget>
getGenericData_(datanon-null, modenon-null) → {CmcdData}
Get generic CMCD data.
Parameters:
Name | Type | Description |
---|---|---|
data |
CmcdData | The data object |
mode |
shaka.util.CmcdManager.CmcdMode |
- Source:
Returns:
- Type
- CmcdData
getObjectType_(context) → {shaka.util.CmcdManager.ObjectType|undefined}
The CMCD object type.
Parameters:
Name | Type | Description |
---|---|---|
context |
shaka.extern.RequestContext | The request context |
- Source:
Returns:
- Type
- shaka.util.CmcdManager.ObjectType | undefined
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
getRemainingBufferLength_(type) → {number}
Get the remaining buffer length for a media type in milliseconds
Parameters:
Name | Type | Description |
---|---|---|
type |
string |
- Source:
Returns:
- Type
- number
getStreamFormat_(type) → {shaka.util.CmcdManager.StreamingFormat|undefined}
Get the stream format
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.net.NetworkingEngine.AdvancedRequestType | The request's advanced type |
- Source:
Returns:
- Type
- shaka.util.CmcdManager.StreamingFormat | undefined
getTopBandwidth_(type) → {number}
Get the highest bandwidth for a given type.
Parameters:
Name | Type | Description |
---|---|---|
type |
shaka.util.CmcdManager.ObjectType | undefined |
- Source:
Returns:
- Type
- number
isValidEvent_(includeEvents, data) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
includeEvents |
Array<string> | |
data |
CmcdData |
- Source:
Returns:
- Type
- boolean
onPlaybackPlay_()
Set playbackPlayTime_ when the play event is triggered
- Source:
removeCmcdQueryFromUri_(uri) → {string}
Removes the CMCD query parameter from a URI.
Parameters:
Name | Type | Description |
---|---|---|
uri |
string |
- Source:
Returns:
- Type
- string
reportEvent_(eventType, extraData)
Parameters:
Name | Type | Description |
---|---|---|
eventType |
string | |
extraData |
CmcdData |
- Source:
sendCmcdRequest_(cmcdDatanon-null, target, responseopt)
Creates and sends a new, out-of-band request to a CMCD endpoint.
This is used for event and response reporting.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cmcdData |
CmcdData | The CMCD data to send. | |
target |
shaka.extern.CmcdTarget | The CMCD target configuration. | |
response |
shaka.extern.Response |
<optional> |
Optional response object to update, used by the applyResponse flow. |
- Source:
setBuffering(buffering)
Set the buffering state
Parameters:
Name | Type | Description |
---|---|---|
buffering |
boolean |
- Source:
setLowLatency(lowLatency)
Set the low latency
Parameters:
Name | Type | Description |
---|---|---|
lowLatency |
boolean |
- Source:
setMediaElement(mediaElement)
Set media element and setup event listeners
Parameters:
Name | Type | Description |
---|---|---|
mediaElement |
HTMLMediaElement | The video element |
- Source:
setStartTimeOfLoad(startTimeOfLoad)
Set start time of load if autoplay is enabled
Parameters:
Name | Type | Description |
---|---|---|
startTimeOfLoad |
number |
- Source:
setupEventModeTimeInterval_()
Sets up TimeInterval timer for CMCD 'EVENT' mode targets.
- Source:
stopAndClearEventTimers_()
Stops and clears all the event timers for timeInterval
- Source:
urlToRelativePath_(url, base) → {string}
Constructs a relative path from a URL
Parameters:
Name | Type | Description |
---|---|---|
url |
string | |
base |
string |
- Source:
Returns:
- Type
- string