Table of Contents

Class EncodedVideoSource

Namespace
LiveKit.Rtc
Assembly
LivekitRtc.dll

Publishes pre-encoded video without decoding or re-encoding it.

public class EncodedVideoSource : IDisposable
Inheritance
EncodedVideoSource
Implements
Inherited Members

Remarks

Create a LocalVideoTrack from this source and publish it with a TrackPublishOptions whose VideoCodec matches the frames, VideoEncoder is Proto.VideoEncoderBackend.EncoderBackendPreEncoded and Simulcast is false. Feed complete access units at the intended playback rate from a single producer; the source does not pace or buffer. Poll TakeFeedback() and forward key-frame and rate-control requests to the upstream encoder, since a demuxer alone cannot produce a new key frame or adapt the bitrate.

Constructors

EncodedVideoSource(int, int)

Creates a source with the initial encoded frame dimensions.

public EncodedVideoSource(int width, int height)

Parameters

width int

Initial frame width in pixels.

height int

Initial frame height in pixels.

Properties

Height

Initial frame height in pixels.

public int Height { get; }

Property Value

int

Width

Initial frame width in pixels.

public int Width { get; }

Property Value

int

Methods

CaptureFrame(EncodedVideoFrame)

Submits a frame and returns whether the native source accepted it. The payload is copied before this method returns; acceptance does not guarantee delivery to subscribers.

public bool CaptureFrame(EncodedVideoFrame frame)

Parameters

frame EncodedVideoFrame

The encoded frame to submit.

Returns

bool

True when the native source accepted the frame, false when it was dropped.

Exceptions

InvalidOperationException

The FFI rejected the frame.

CreateTrack(string)

Creates a local video track from this source.

public LocalVideoTrack CreateTrack(string name = "video")

Parameters

name string

The name of the track.

Returns

LocalVideoTrack

A local video track fed by this source.

Dispose()

Releases the native source. Later calls to CaptureFrame(EncodedVideoFrame) throw ObjectDisposedException.

public void Dispose()

TakeFeedback()

Consumes the feedback accumulated since the previous call, including key-frame requests from late subscribers.

public EncodedVideoSourceFeedback TakeFeedback()

Returns

EncodedVideoSourceFeedback

The feedback collected since the previous call: key-frame request and rate control.