MediaStreamTrackProcessor Class
Reads the media of a track as a stream (https://w3c.github.io/mediacapture-transform/#track-processor): the readable stream of the scripts gives a VideoFrame for each frame of a video track, or an AudioData for each block of samples of an audio track. The frames that arrive while no read is pending are buffered (MediaStreamTrackProcessorInit.MaxBufferSize, 1 by default): the oldest one is closed and discarded when the buffer is full. The stream is closed when the track ends.
public sealed class MediaStreamTrackProcessorRemarks
The specification exposes the interface in the dedicated workers only; it is also exposed in the windows, with the constructor that takes a track (the legacy API of Chromium, https://github.com/w3c/mediacapture-transform/blob/main/explainer.md#mediastreamtrackprocessor). The frames of a source that produces them (a VideoTrackGenerator, a track transferred from another thread) are read as they arrive; the other sources (a camera, a canvas, a media element...) are sampled on the clock of the event loop, at the frame rate of the track (30 frames per second when it has none), and by blocks of 10 ms for the audio.
See also
Constructors
| Name | Description |
|---|---|
| MediaStreamTrackProcessor(MediaStreamTrack, ushort?) | Creates a processor of a track (the legacy constructor of Chromium). |
| MediaStreamTrackProcessor(MediaStreamTrackProcessorInit) | Creates a processor of a track (https://w3c.github.io/mediacapture-transform/#dom-mediastreamtrackprocessor-mediastreamtrackprocessor). |
MediaStreamTrackProcessor overloads
MediaStreamTrackProcessor(MediaStreamTrack, ushort?)
InsertableStreams.csCreates a processor of a track (the legacy constructor of Chromium).
public MediaStreamTrackProcessor(MediaStreamTrack track, ushort? maxBufferSize = null)Parameters
trackMediaStreamTrack- The track to read.
maxBufferSizeushort?- The number of frames buffered while no read is pending (1 by default).
Exceptions
TypeErrorException- The track is ended or transferred.
See also
MediaStreamTrackProcessor(MediaStreamTrackProcessorInit)
InsertableStreams.csCreates a processor of a track (https://w3c.github.io/mediacapture-transform/#dom-mediastreamtrackprocessor-mediastreamtrackprocessor).
public MediaStreamTrackProcessor(MediaStreamTrackProcessorInit init)Parameters
initMediaStreamTrackProcessorInit- The track and the size of the buffer.
Exceptions
TypeErrorException- The track is not a track or a handle, or it is ended or transferred.
See also
Properties
| Name | Description |
|---|---|
| DiscardedFrames | Gets the number of frames discarded because the buffer was full. |
| Readable | Gets the ReadableStream of the frames (an object of the realm of the scripts: the frames are read by the scripts). |
| TotalFrames | Gets the number of frames received from the track (including the discarded ones). |
DiscardedFrames
InsertableStreams.csGets the number of frames discarded because the buffer was full.
public ulong DiscardedFrames { get; }Readable
InsertableStreams.csGets the ReadableStream of the frames (an object of the realm of the scripts: the frames are read by the scripts).
public object Readable { get; }TotalFrames
InsertableStreams.csGets the number of frames received from the track (including the discarded ones).
public ulong TotalFrames { get; }