Constructor
new Session(webTransportnon-null, controlWriternon-null, dialectnon-null, confignon-null, messageWriterFactory)
Parameters:
| Name | Type | Description |
|---|---|---|
webTransport |
WebTransport | |
controlWriter |
shaka.msf.Writer | Our outgoing control stream, already carrying our SETUP. |
dialect |
shaka.extern.MsfDialect | |
config |
shaka.extern.MsfManifestConfiguration | |
messageWriterFactory |
function | Builds a writer for this draft's control messages. |
- Implements:
- Source:
Members
fetchCallbacks_ :Map<bigint, !shaka.msf.Utils.ObjectCallback>
Type:
- Map<bigint, !shaka.msf.Utils.ObjectCallback>
- Source:
messageWriterFactory_ :function(): !shaka.msf.draft18.MessageWriter
Type:
- function(): !shaka.msf.draft18.MessageWriter
- Source:
publishNamespaceCallbacks_ :Set<function(Array<string>)>
Type:
- Set<function(Array<string>)>
- Source:
subscribeStreams_ :Map<bigint, {reader: !shaka.msf.Reader, writer: !shaka.msf.Writer}>
The request stream each subscription lives on, by track alias. The
stream IS the subscription, so it is what has to be torn down to
withdraw one.
Type:
- Map<bigint, {reader: !shaka.msf.Reader, writer: !shaka.msf.Writer}>
- Source:
Methods
awaitResponse_(readernon-null, okType, description) → {Promise<{type: number, length: number}>}
Waits for the response to a request, which is either a REQUEST_OK-shaped
acknowledgement or a REQUEST_ERROR.
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader | |
okType |
number | The success message type for this request. |
description |
string | Used in error messages. |
Returns:
The response header.
The reader is left positioned just after it.
- Type
- Promise<{type: number, length: number}>
buildSubscribeParams_(writernon-null, startLocationopt, nullable) → {Array<shaka.msf.Utils.KeyValuePair>}
Builds the parameter list carried by SUBSCRIBE. Draft-16 moved the
subscriber priority, forward flag, filter and group order out of fixed
fields into parameters, and draft-18 keeps them there. Every one of them
has a default, so the shortest legal list is the empty one.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
writer |
shaka.msf.draft18.MessageWriter | The writer this SUBSCRIBE is going out on, which owns how a start Location is encoded. | |
startLocation |
shaka.msf.Utils.Location |
<optional> <nullable> |
Returns:
- Type
- Array<shaka.msf.Utils.KeyValuePair>
close(codeopt, reasonopt) → {Promise}
Closes the underlying transport.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
code |
number |
<optional> |
|
reason |
string |
<optional> |
- Implements:
- Source:
Returns:
- Type
- Promise
configure(confignon-null)
Parameters:
| Name | Type | Description |
|---|---|---|
config |
shaka.extern.MsfManifestConfiguration |
- Implements:
- Source:
deliver_(trackAlias, obj) → {Promise}
Delivers an object, waiting briefly for the subscription to be registered
if the data stream beat the SUBSCRIBE_OK.
Parameters:
| Name | Type | Description |
|---|---|---|
trackAlias |
bigint | |
obj |
shaka.msf.Utils.MOQObject |
Returns:
- Type
- Promise
fetch(namespace, trackName, callback) → {Promise}
Retrieves a track once rather than subscribing to it. Resolves when the
request has been accepted; objects arrive on the callback.
Parameters:
| Name | Type | Description |
|---|---|---|
namespace |
Array<string> | |
trackName |
string | |
callback |
shaka.extern.MsfObjectCallback |
- Implements:
- Source:
Returns:
- Type
- Promise
getNextRequestId_() → {bigint}
Client Request IDs are even and start at 0.
Returns:
- Type
- bigint
handleFetchStream_(readernon-null) → {Promise}
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader |
Returns:
- Type
- Promise
handleIncomingStream_(streamnon-null) → {Promise}
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
ReadableStream |
Returns:
- Type
- Promise
handlePeerControlStream_(readernon-null) → {Promise}
Reads the peer's SETUP and then keeps the control stream open for GOAWAY
and namespace announcements.
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader | Positioned just after the SETUP type. |
Returns:
- Type
- Promise
handleSubgroupStream_(readernon-null, streamType) → {Promise}
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader | |
streamType |
bigint |
Returns:
- Type
- Promise
isSubgroupStreamType_(streamType) → {boolean}
Draft-18 SUBGROUP_HEADER types have bit 4 set, spanning 0x10-0x1F,
0x30-0x3F, 0x50-0x5F and 0x70-0x7F.
Parameters:
| Name | Type | Description |
|---|---|---|
streamType |
bigint |
Returns:
- Type
- boolean
listenOnRequestStream_(readernon-null, trackAlias) → {Promise}
Keeps reading a subscription's request stream after the SUBSCRIBE_OK so
that PUBLISH_DONE closes the track.
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader | |
trackAlias |
bigint |
Returns:
- Type
- Promise
logStreamFailure_(context, error)
Streams end for reasons that are not a failure of ours: the peer resets
one it no longer needs, and every stream on a session fails at once when
the session goes away, which the session itself already reports. Neither
is worth an error in the log.
Parameters:
| Name | Type | Description |
|---|---|---|
context |
string | |
error |
* |
onNamespacePublished(callback) → {function}
Registers a callback for namespaces the peer announces it can serve.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function |
- Implements:
- Source:
Returns:
Unregisters the callback.
- Type
- function
openRequest_(requestBytesnon-null) → {Promise<{reader: !shaka.msf.Reader, writer: !shaka.msf.Writer}>}
Opens a bidirectional stream, writes a request onto it and returns both
halves: the reader the response arrives on, and the writer, which is
kept only so the stream can be torn down to withdraw the request. The
stream is the correlation, so nothing is registered anywhere.
Parameters:
| Name | Type | Description |
|---|---|---|
requestBytes |
Uint8Array |
Returns:
- Type
- Promise<{reader: !shaka.msf.Reader, writer: !shaka.msf.Writer}>
readMessageHeader_(readernon-null) → {Promise<{type: number, length: number}>}
Reads one control message header from a stream.
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader |
Returns:
- Type
- Promise<{type: number, length: number}>
release()
Request that this object release all internal references.
- Inherited From:
- Implements:
- Source:
skipRest_(readernon-null, header, bytesConsumed) → {Promise}
Discards whatever is left of a message payload the caller stopped
reading part way through.
Parameters:
| Name | Type | Description |
|---|---|---|
reader |
shaka.msf.Reader | |
header |
{type: number, length: number} | |
bytesConsumed |
number |
Returns:
- Type
- Promise
startListeningForStreams_() → {Promise}
Reads incoming unidirectional streams. Each is either the peer's control
stream, which begins with SETUP, or object data.
Returns:
- Type
- Promise
subscribe(namespace, trackName, callback, startLocationopt, nullable) → {Promise<bigint>}
Subscribes to a track, delivering its objects to the callback until
unsubscribed. Resolves with the track alias assigned by the publisher.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
namespace |
Array<string> | ||
trackName |
string | ||
callback |
shaka.extern.MsfObjectCallback | ||
startLocation |
shaka.extern.MsfLocation |
<optional> <nullable> |
Where delivery should begin, for a subscription that is not meant to start at the live edge, which is what a seek into published-but-not-yet-received content needs. Every draft carries it, though not alike: draft-14 as fields of the SUBSCRIBE message, draft-16 and draft-18 in the SUBSCRIPTION_FILTER parameter, draft-20 in LOCATION_FILTER. A publisher may still refuse it, in which case the subscription fails rather than silently starting somewhere else. |
- Implements:
- Source:
Returns:
- Type
- Promise<bigint>
unsubscribe(trackAlias) → {Promise}
Stops delivery for a subscription.
Parameters:
| Name | Type | Description |
|---|---|---|
trackAlias |
bigint |
- Implements:
- Source:
Returns:
- Type
- Promise
watchForSessionEnd_()
A session the peer hangs up on resets every stream on it at once, and
each of those failures would otherwise be logged as an error of its own.
Watch the transport instead: once the session is gone, its stream errors
are expected, and the reason the session ended is the one worth reporting.
- Source: