Skip to main content

Class: Producer

Coordinates video and audio encoding and publishing.

Use addVideo() and addAudio() to configure tracks, then call start() to begin encoding. The returned ChannelProducer can be passed to a Client for publishing to subscribers.

Example

const producer = new Producer(timeSource)
producer.addVideo(videoTrack, videoConfig)
producer.addAudio(audioTrack, audioConfig)
const channelProducer = await producer.start(namespace)

Methods

addAudio()

addAudio(track, config): this

Add an audio track for encoding.

Parameters

track

MediaStreamTrack

config

AudioConfig

Returns

this


addVideo()

addVideo(track, config): this

Add a video track for encoding.

Parameters

track

MediaStreamTrack

config

VideoConfig

Returns

this


start()

start(namespace): Promise<ChannelProducer>

Start encoding and return a ChannelProducer to pass to a Client.

Parameters

namespace

Namespace

Returns

Promise<ChannelProducer>