docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class VideoStreamTrack

    Represents a single video track within a stream

    Inheritance
    object
    RefCountedObject
    MediaStreamTrack
    VideoStreamTrack
    Implements
    IDisposable
    Inherited Members
    MediaStreamTrack.Enabled
    MediaStreamTrack.ReadyState
    MediaStreamTrack.Kind
    MediaStreamTrack.Id
    MediaStreamTrack.Stop()
    RefCountedObject.disposed
    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

    Texture object that provides the input source for the video stream and is used in creating the video track.

    CopyTexture copyTexture

    By default, textures are copied vertically flipped, using CopyTextureHelper.VerticalFlipCopy, use Graphics.Blit for copy as is, CopyTextureHelper for flip, or write your own CopyTexture function.

    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
    MediaStreamTrack
    WebRTC

    Properties

    DataPtr

    Pointer to the video stream data in the native memory.

    Declaration
    public IntPtr DataPtr { get; }
    Property Value
    Type Description
    IntPtr
    See Also
    MediaStreamTrack
    WebRTC

    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
    MediaStreamTrack
    WebRTC

    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
    MediaStreamTrack
    WebRTC

    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
    MediaStreamTrack
    WebRTC

    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
    MediaStreamTrack
    WebRTC

    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
    MediaStreamTrack
    WebRTC

    Methods

    Dispose()

    Disposes of VideoStremTrack

    Declaration
    public override void Dispose()
    Overrides
    MediaStreamTrack.Dispose()
    Remarks

    Dispose method disposes of the VideoStreamTrack and releases the associated resources.

    Examples
    videoStreamTrack.Dispose();
    See Also
    MediaStreamTrack
    WebRTC

    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;
    }
    See Also
    RTCPeerConnection

    Implements

    IDisposable

    See Also

    MediaStreamTrack
    WebRTC
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)