Class VideoFrameQueue<T>
Small queue of video frames received from a source and pending delivery to a sink. Used as temporary buffer between the WebRTC callback (push model) and the video player rendering (pull model). This also handles dropping frames when the source is faster than the sink, by limiting the maximum queue length.
Implements
Namespace: Microsoft.MixedReality.WebRTC
Assembly: Microsoft.MixedReality.WebRTC.dll
Syntax
public class VideoFrameQueue<T> : object, IVideoFrameQueue where T : class, IVideoFrameStorage, new()
Type Parameters
Name | Description |
---|---|
T | The type of video frame storage |
Constructors
| Improve this Doc View SourceVideoFrameQueue(Int32)
Create a new queue with a maximum frame length.
Declaration
public VideoFrameQueue(int maxQueueLength)
Parameters
Type | Name | Description |
---|---|---|
Int32 | maxQueueLength | Maxmimum number of frames to enqueue before starting to drop incoming frames |
Properties
| Improve this Doc View SourceDequeuedFramesPerSecond
Get the number of frames enqueued per seconds. This is generally an average statistics representing how fast a video sink consumes some video frames, typically to render them.
Declaration
public float DequeuedFramesPerSecond { get; }
Property Value
Type | Description |
---|---|
Single |
DroppedFramesPerSecond
Get the number of frames dropped per seconds. This is generally an average statistics representing how many frames were enqueued by a video source but not dequeued fast enough by a video sink, meaning the video sink renders at a slower framerate than the source can produce.
Declaration
public float DroppedFramesPerSecond { get; }
Property Value
Type | Description |
---|---|
Single |
QueuedFramesPerSecond
Get the number of frames enqueued per seconds. This is generally an average statistics representing how fast a video source produces some video frames.
Declaration
public float QueuedFramesPerSecond { get; }
Property Value
Type | Description |
---|---|
Single |
Methods
| Improve this Doc View SourceClear()
Clear the queue and drop all frames currently pending.
Declaration
public void Clear()
Enqueue(Argb32VideoFrame)
Try to enqueue a new video frame encoded in raw ARGB format. If the internal queue reached its maximum capacity, do nothing and drop the frame.
Declaration
public bool Enqueue(Argb32VideoFrame frame)
Parameters
Type | Name | Description |
---|---|---|
Argb32VideoFrame | frame | The video frame to enqueue |
Returns
Type | Description |
---|---|
Boolean | Return |
Remarks
This should only be used if the queue has storage for a compatible video frame encoding.
Enqueue(I420AVideoFrame)
Enqueue a new video frame encoded in I420+Alpha format. If the internal queue reached its maximum capacity, do nothing and drop the frame.
Declaration
public bool Enqueue(I420AVideoFrame frame)
Parameters
Type | Name | Description |
---|---|---|
I420AVideoFrame | frame | The video frame to enqueue |
Returns
Type | Description |
---|---|
Boolean | Return |
Remarks
This should only be used if the queue has storage for a compatible video frame encoding.
RecycleStorage(T)
Recycle a frame storage, putting it back into the internal pool for later reuse. This prevents deallocation and reallocation of a frame, and decreases pressure on the garbage collector.
Declaration
public void RecycleStorage(T frame)
Parameters
Type | Name | Description |
---|---|---|
T | frame | The unused frame storage to recycle for a later new frame |
TrackLateFrame()
Track statistics for a late frame, which short-circuits the queue and is delivered as soon as it is received.
Declaration
public void TrackLateFrame()
TryDequeue(out T)
Try to dequeue a video frame, usually to be consumed by a video sink (video player).
Declaration
public bool TryDequeue(out T frame)
Parameters
Type | Name | Description |
---|---|---|
T | frame | On success, returns the dequeued frame. |
Returns
Type | Description |
---|---|
Boolean | Return |