Class: shaka.msf.draft18.MessageWriter

Constructor

new MessageWriter(codecnon-null, initialSizeopt)

Parameters:
Name Type Attributes Default Description
codec shaka.extern.MsfCodec
initialSize number <optional>
1024
Source:

Members

FilterType :number

The SUBSCRIPTION_FILTER Filter Types this player sends (draft-18 section 5.1.2). Draft-20 and draft-21 have no Filter Type, and draft-22 numbers its own differently.
Type:
  • number
Properties:
Name Value Type Description
ABSOLUTE_START 3 number
Source:

Parameter :number

The parameter types this player sends on a SUBSCRIBE or a FETCH. Draft-20 renamed 0x21 from SUBSCRIPTION_FILTER to LOCATION_FILTER and changed what its value holds, but the code point is the same in both, so there is one constant rather than one per draft.
Type:
  • number
Properties:
Name Value Type Description
FORWARD 16 number
SUBSCRIBER_PRIORITY 32 number
LOCATION_FILTER 33 number
FILL_PARAMETERS 35 number
Source:

PARAMETER_ENCODINGS_ :Map<number, shaka.msf.draft18.MessageWriter.ParameterEncoding>

The encoding of the Message Parameter types defined across draft-18, draft-20 and draft-21. The types are numbers rather than bigint so that building this map needs no BigInt at load time.
Type:
Source:

ParameterEncoding :number

How a Message Parameter's value is encoded (draft-18 section 10.2).
Type:
  • number
Properties:
Name Value Type Description
UINT8 0 number
VARINT 1 number
LOCATION 2 number
LENGTH_PREFIXED 3 number
LOCATION_FILTER 4 number
Source:

Methods

fetchRange(msg) → {{start: shaka.msf.Utils.Location, end: shaka.msf.Utils.Location}}

The Location range a FETCH covers, filling in the default the callers that do not care rely on. Shared with draft-20, which carries the same range in a parameter instead of in the message.
Parameters:
Name Type Description
msg {startLocation: (shaka.msf.Utils.Location|undefined), endLocation: (shaka.msf.Utils.Location|undefined)}
Source:
Returns:
Type
{start: shaka.msf.Utils.Location, end: shaka.msf.Utils.Location}

encodeVarIntField(valuesnon-null) → {Uint8Array}

Encodes a sequence of var ints into a standalone byte field, for the parameters whose value is itself a var int structure rather than a single integer.
Parameters:
Name Type Description
values Array<bigint>
Source:
Returns:
Type
Uint8Array

fillCurrentGroupParam() → {shaka.msf.Utils.KeyValuePair}

The SUBSCRIBE parameter that also delivers the current Group from its first Object, or null when this draft has none and a Joining FETCH has to be sent instead, as it does in draft-18.
Source:
Returns:
Type
shaka.msf.Utils.KeyValuePair

getBytes() → {Uint8Array}

Source:
Returns:
Type
Uint8Array

getParameterEncoding(type) → {shaka.msf.draft18.MessageWriter.ParameterEncoding}

How this draft encodes the value of a Message Parameter type, or null for a type it does not define. Since draft-18 that is set per type rather than by the parity rule Properties use, so a type nobody told us about cannot be stepped over when reading a response.
Parameters:
Name Type Description
type number
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter.ParameterEncoding

locationFilterParam(startLocation) → {shaka.msf.Utils.KeyValuePair}

The parameter that makes a SUBSCRIBE start at a given Location rather than at the live edge, which is what seeking into already-published content needs. Draft-18 spells it SUBSCRIPTION_FILTER (0x21): a Filter Type followed by the fields that type takes. AbsoluteStart takes a Start Location and no end, so the subscription runs from there to the live edge and onwards, and the draft says outright that the Start Location MAY be smaller than the publisher's Largest Object (section 5.1.2). Draft-20 keeps the parameter type and changes its contents, so the draft-20 writer overrides this.
Parameters:
Name Type Description
startLocation shaka.msf.Utils.Location
Source:
Returns:
Type
shaka.msf.Utils.KeyValuePair

marshal(type, writeContent) → {shaka.msf.draft18.MessageWriter}

Writes the var int type and 16-bit length around a payload.
Parameters:
Name Type Description
type shaka.msf.draft18.MessageTypeId
writeContent function()
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

marshalFetch(msg) → {shaka.msf.draft18.MessageWriter}

A standalone FETCH. Start and End are Location structures rather than the four loose var ints draft-16 used, and the range is a field of the message rather than a parameter, which is what draft-20 changed. The range is an inclusive pair of absolute Locations, so the zeroed pair the caller may leave out asks for exactly the Object at {0, 0}, not for the whole track. Draft-20 says the same thing with a LOCATION_FILTER.
Parameters:
Name Type Description
msg {requestId: bigint, namespace: Array<string>, trackName: string, startLocation: (shaka.msf.Utils.Location|undefined), endLocation: (shaka.msf.Utils.Location|undefined), params: (Array<shaka.msf.Utils.KeyValuePair>|undefined)}
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

marshalJoiningFetch(msg) → {shaka.msf.draft18.MessageWriter}

A Relative Joining FETCH: the Groups leading up to a subscription's Joining Location, contiguous with what the subscription delivers after it (draft-18 section 10.12.2). Joining Start 0 asks for the current Group from its first Object.
Parameters:
Name Type Description
msg {requestId: bigint, joiningRequestId: bigint, joiningStart: bigint, params: (Array<shaka.msf.Utils.KeyValuePair>|undefined)}
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

marshalRequestOk(paramsopt) → {shaka.msf.draft18.MessageWriter}

REQUEST_OK answers PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, TRACK_STATUS and the rest. It carries no Request ID: it goes back on the request's own bidirectional stream.
Parameters:
Name Type Attributes Description
params Array<shaka.msf.Utils.KeyValuePair> | undefined <optional>
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

marshalSetup(optionsnon-null) → {shaka.msf.draft18.MessageWriter}

Draft-17 collapsed CLIENT_SETUP and SERVER_SETUP into one message whose payload is nothing but Setup Options, uncounted and bounded by the message length.
Parameters:
Name Type Description
options Array<shaka.msf.Utils.KeyValuePair>
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

marshalSubscribe(msg) → {shaka.msf.draft18.MessageWriter}

Parameters:
Name Type Description
msg {requestId: bigint, namespace: Array<string>, trackName: string, params: (Array<shaka.msf.Utils.KeyValuePair>|undefined)}
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

marshalSubscribeNamespace(msg) → {shaka.msf.draft18.MessageWriter}

Parameters:
Name Type Description
msg {requestId: bigint, namespace: Array<string>, params: (Array<shaka.msf.Utils.KeyValuePair>|undefined)}
Source:
Returns:
Type
shaka.msf.draft18.MessageWriter

reset()

Resets the buffer to start writing from the beginning.
Source:

writeKeyValuePairs(pairsnon-null, isParameterListopt)

Writes delta-encoded Key-Value-Pairs without a count prefix, which is how Setup Options are framed: they span the whole message payload and are bounded by the message length. Draft-22 gave LOCATION_FILTER a value that leads with its own Location Filter Type rather than a length, so a parameter list asks getParameterEncoding() whether an odd type's value carries a length. Setup Options always do.
Parameters:
Name Type Attributes Default Description
pairs Array<shaka.msf.Utils.KeyValuePair>
isParameterList boolean <optional>
false
Source:

writeLocation(location)

Parameters:
Name Type Description
location shaka.msf.Utils.Location
Source:

writeNamespace(namespace)

A Track Namespace is a count of fields followed by each length-prefixed field.
Parameters:
Name Type Description
namespace Array<string>
Source:

writeParameters(pairs)

Writes a count-prefixed parameter list, which is how every message other than SETUP frames its parameters.
Parameters:
Name Type Description
pairs Array<shaka.msf.Utils.KeyValuePair> | undefined
Source:

writeString(str)

Parameters:
Name Type Description
str string
Source:

writeVarInt(value)

Parameters:
Name Type Description
value bigint | number
Source: