Skip to main content

Class: WebrtcIngest

Represents a Vindral WebrtcIngest instance

The most most essential methods when using the WebrtcIngest class are:

  • connect() - establish connection with WebRTC ingest server
  • setVideoTrack() - sets video track (if any), called before starting broadcast
  • setAudioTrack() - sets audio track (if any), called before starting broadcast
  • broadcast() - starts sending the actual stream to make it accessible for viewers
  • unload() - unloads the instance, its very important that this is called when cleaning up the instance, otherwise background timers may leak.

The WebrtcIngest instance will emit a variety of events during its lifetime. Use .on("event-name", callback) to listen to these events. See WebrtcIngestEvents for the events types that can be emitted.

See Vindral examples repository and the WebRTC Ingest docs for usage examples.

Hierarchy

Accessors

broadcastState

get broadcastState(): BroadcastState

The unique session ID given to the WebrtcIngest by the server

Returns

BroadcastState


connectionState

get connectionState(): ConnectionState

The unique session ID given to the WebrtcIngest by the server

Returns

ConnectionState


id

get id(): string

The unique session ID given to the WebrtcIngest by the server

Returns

string


stats

get stats(): IWebrtcIngestStats

Represents the current session state

Returns

IWebrtcIngestStats

Methods

broadcast

broadcast(): void

Starts the actual stream. This will initiate the actual broadcast and make the stream available for viewers.

Returns

void


connect

connect(): Promise<void>

Will try to connect to the server. Throws if neither channel id + jwt or streamKey is undefined.

Returns

Promise<void>


getStatistics

getStatistics(): Statistics

This method collects a statistics report from internal modules. While many of the report's properties are documented, the report may also contain undocumented properties used internally or temporarily for monitoring and improving the performance of the service.

Use undocumented properties at your own risk.

Returns

Statistics


setAudioTrack

setAudioTrack(track, overrides?): Promise<void>

Sets the audio track. If this is called a second time, there will be a playback gap for viewers.

Parameters

NameType
trackMediaStreamTrack
overrides?AudioTrackOverrides

Returns

Promise<void>


setVideoTrack

setVideoTrack(track, overrides?): Promise<void>

Sets the video track. If this is called a second time, there will be a playback gap for viewers. Important: If the resolution is changed, the playback may not work correctly. For gapless playback but with interchanging sources, we recommend streaming from a canvas and just changing the contents of the canvas. In effect, not having to use setVideoTrack more than once.

Parameters

NameType
trackMediaStreamTrack
overrides?VideoTrackOverrides

Returns

Promise<void>


unload

unload(): void

Unloads / disconnects the session. You may not reuse the WebrtcIngest instance after this call. Instead, create a new instance.

Returns

void


updateAuthenticationToken

updateAuthenticationToken(token): void

Updates the authentication token runtime. Use with care, as updating an existing working token with an invalid token will shut down the session.

Parameters

NameType
tokenstring

Returns

void