Class VideoStreamTrack
Represents a single video track within a stream
Implements
Inherited Members
Namespace: Unity.WebRTC
Assembly: Unity.WebRTC.dll
Syntax
public class VideoStreamTrack : MediaStreamTrack, IDisposable
Remarks
VideoStreamTrack is a MediaStreamTrack that represents a single video track within a stream.
Examples
VideoStreamTrack videoStreamTrack = new VideoStreamTrack(texture);
Constructors
VideoStreamTrack(Texture, CopyTexture)
Creates a new VideoStreamTrack object.
Declaration
public VideoStreamTrack(Texture texture, CopyTexture copyTexture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture | texture |
|
| CopyTexture | copyTexture | By default, textures are copied vertically flipped, using |
Remarks
VideoStreamTrack constructor creates an instance of VideoStreamTrack with a source.
Examples
VideoStreamTrack videoStreamTrack = new VideoStreamTrack(texture, CopyTextureHelper.VerticalFlipCopy);
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
See Also
Properties
DataPtr
Pointer to the video stream data in the native memory.
Declaration
public IntPtr DataPtr { get; }
Property Value
| Type | Description |
|---|---|
| IntPtr |
See Also
Decoding
Indicates that the track is configured to decode an incoming video stream.
Declaration
public bool Decoding { get; }
Property Value
| Type | Description |
|---|---|
| bool |
See Also
Encoding
Indicates that the track is configured to encode and send a video stream to a remote peer.
Declaration
public bool Encoding { get; }
Property Value
| Type | Description |
|---|---|
| bool |
See Also
NeedReceivedVideoFlipVertically
If the value is set to true, the received video is flipped vertically.
Declaration
public static bool NeedReceivedVideoFlipVertically { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Change this property before starting to receive video.
See Also
Texture
When the track is configured to receive a video stream, represents the Texture object where the video stream is rendered.
When the track is configured to send a video stream, represents the destination Texture object to send.
Declaration
public Texture Texture { get; }
Property Value
| Type | Description |
|---|---|
| Texture |
See Also
TexturePtr
When the track is configured to receive a video stream, represents the pointer to the Texture object where the video stream is rendered.
When the track is configured to send a video stream, represents the pointer to the destination Texture object to send.
Declaration
public IntPtr TexturePtr { get; }
Property Value
| Type | Description |
|---|---|
| IntPtr |
See Also
Methods
Dispose()
Disposes of VideoStremTrack
Declaration
public override void Dispose()
Overrides
Remarks
Dispose method disposes of the VideoStreamTrack and releases the associated resources.
Examples
videoStreamTrack.Dispose();
See Also
Events
OnVideoReceived
Event to be fired when the first frame of the video is received.
Declaration
public event OnVideoReceived OnVideoReceived
Event Type
| Type | Description |
|---|---|
| OnVideoReceived |
Remarks
OnVideoReceived event is fired when the first frame of the video is received.
Examples
[SerializeField]
RawImage receivedImage;
videoStreamTrack.OnVideoReceived += (texture) =>
{
receivedImage.texture = texture;
}