Interface: ElementContext
Given to init, one per element instance.
Properties
catalog?
readonlyoptionalcatalog?:CatalogReader
Set for elements the catalog loads, and inherited by what they load.
client
readonlyclient:MOQtailClient
Always the current client, it changes after a reconnect.
player
readonlyplayer:PlayerHandle
signal
readonlysignal:AbortSignal
Aborted when the instance is destroyed.
tracks
readonlytracks: readonly (object&object&object)[]
The tracks this instance was loaded for, empty without a catalog.
worker?
readonlyoptionalworker?:object
Set while the player has a worker and the definition's threads allows it.
bridge()
bridge(
pad):void
Sends them to receive() on the main thread instead. Each worker pad the element takes needs one of the two.
Parameters
pad
Returns
void
create()
create<
E>(name,request?):Remote<E>
Creates the engine serveWorker registered as name. Calls on it queue until it exists, and a failure to create it reaches context.fail.
Type Parameters
E
E extends Engine
Parameters
name
string
request?
options?
object
The engine's init.options.
outputs?
Pad[]
Source pads of the element, carrying THREAD worker: the engine's init.outputs, in order.
report?
(report) => void
The engine's init.report.
transfer?
Transferable[]
Transferred with options, for example an OffscreenCanvas.
Returns
Remote<E>
has()
has(
name):boolean
Parameters
name
string
Returns
boolean
inWorker()
inWorker(
pad):boolean
Whether pad is a worker pad, or a sink pad one feeds.
Parameters
pad
Returns
boolean
link()
link(
pad,engine):void
Sends the items of pad, a sink pad fed by a worker pad, to engine in the worker.
Parameters
pad
engine
Remote<Engine>
Returns
void
Methods
attach()
attach(
element):void
Called by the BaseElement constructor, so the player hears what the instance emits.
Parameters
element
Returns
void
cost()
cost(
track):Promise<number|undefined>
How many transforms the chain would load to take the pad of the source probe() picks for track to a declared sink. Undefined when none is reached, or an element on the way doesn't supports the track. 0 without declared sinks, or for a source whose definition doesn't say what pad it makes. Worked out from capabilities, not negotiate: a declared transform that declines a pad it could take, as WebCodecs does past its first, still gets transforms loaded for it.
Parameters
track
Returns
Promise<number | undefined>
fail()
fail(
error):void
Reports a fatal error from outside receive(), such as a decoder's or an engine's.
Parameters
error
Returns
void
load()
load<
E>(definition,request?):Promise<E>
Returns the existing instance when the same definition and tracks are already loaded.
Type Parameters
E
E extends BaseElement
Parameters
definition
request?
Returns
Promise<E>
probe()
probe(
identifiers):SourceElementDefinition<SourceElement, readonly (keyofElementInterfaces)[]> |undefined
The source definition the player would pick for identifiers, as source() does.
Parameters
identifiers
Returns
SourceElementDefinition<SourceElement, readonly (keyof ElementInterfaces)[]> | undefined
release()
release(
element):Promise<void>
Drops this element's reference to one it loaded; it's destroyed once no holder is left.
Parameters
element
Returns
Promise<void>
switchSource()
switchSource(
identifiers):SourceElementDefinition<SourceElement, readonly (keyofElementInterfaces)[]> |undefined
The active plugins' switch source that ranks first for identifiers, as probe() ranks.
Parameters
identifiers
Returns
SourceElementDefinition<SourceElement, readonly (keyof ElementInterfaces)[]> | undefined