docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class RTCRtpTransceiver

    Describes a permanent pairing of an RTCRtpSender and an RTCRtpReceiver.

    Inheritance
    object
    RefCountedObject
    RTCRtpTransceiver
    Implements
    IDisposable
    Inherited Members
    RefCountedObject.disposed
    Namespace: Unity.WebRTC
    Assembly: Unity.WebRTC.dll
    Syntax
    public class RTCRtpTransceiver : RefCountedObject, IDisposable
    Remarks

    RTCRtpTransceiver class is used to represent a permanent pairing of an RTCRtpSender and an RTCRtpReceiver, along with shared state.

    Examples
    RTCRtpCapabilities capabilities = RTCRtpSender.GetCapabilities(TrackKind.Video);
    RTCRtpTransceiver transceiver = peerConnection.GetTransceivers().First();
    RTCErrorType error = transceiver.SetCodecPreferences(capabilities.codecs);
    if (error.errorType != RTCErrorType.None)
    {
        Debug.LogError($"Failed to set codec preferences: {error.message}");
    }

    Properties

    CurrentDirection

    This property indicates the transceiver's current directionality, or null if the transceiver is stopped or has never participated in an exchange of offers and answers. To change the transceiver's directionality, set the value of the Direction property.

    Declaration
    public RTCRtpTransceiverDirection? CurrentDirection { get; }
    Property Value
    Type Description
    RTCRtpTransceiverDirection?
    See Also
    RTCPeerConnection

    Direction

    This is used to set the transceiver's desired direction and will be used in calls to CreateOffer and CreateAnswer.

    Declaration
    public RTCRtpTransceiverDirection Direction { get; set; }
    Property Value
    Type Description
    RTCRtpTransceiverDirection
    See Also
    RTCPeerConnection

    Mid

    Specifies the negotiated media ID (mid) that uniquely identifies the pairing of the sender and receiver agreed upon by local and remote peers.

    Declaration
    public string Mid { get; }
    Property Value
    Type Description
    string
    See Also
    RTCPeerConnection

    Receiver

    RTCRtpReceiver object that handles receiving and decoding incoming media data for the transceiver's stream.

    Declaration
    public RTCRtpReceiver Receiver { get; }
    Property Value
    Type Description
    RTCRtpReceiver
    See Also
    RTCPeerConnection

    Sender

    RTCRtpSender object that handles encoding and sending outgoing media data for the transceiver's stream.

    Declaration
    public RTCRtpSender Sender { get; }
    Property Value
    Type Description
    RTCRtpSender
    See Also
    RTCPeerConnection

    Methods

    Dispose()

    Disposes of RTCRtpTransceiver.

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

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

    Examples
    transceiver.Dispose();
    See Also
    RTCPeerConnection

    ~RTCRtpTransceiver()

    Finalizer for RTCRtpTransceiver.

    Declaration
    protected ~RTCRtpTransceiver()
    Remarks

    Ensures that resources are released by calling the Dispose method

    See Also
    RTCPeerConnection

    SetCodecPreferences(RTCRtpCodecCapability[])

    Specifies the codecs for decoding received data on this transceiver, arranged in order of decreasing preference.

    Declaration
    public RTCErrorType SetCodecPreferences(RTCRtpCodecCapability[] codecs)
    Parameters
    Type Name Description
    RTCRtpCodecCapability[] codecs

    An array of RTCRtpCodecCapability objects arranged by preference to determine the codecs used for receiving and sending data streams. If it is empty, the codec configurations are all reset to the defaults.

    Returns
    Type Description
    RTCErrorType

    RTCErrorType value.

    Remarks

    SetCodecPreferences method sets codec preferences for negotiating data encoding with a remote peer. It requires reordering supported codecs by preference and applying them to influence the negotiation process. When initiating an RTCPeerConnection, set codecs before calling CreateOffer or CreateAnswer. Changing codecs during a session requires a new negotiation but does not automatically trigger the OnNegotiationNeeded event.

    Examples
    RTCRtpCapabilities capabilities = RTCRtpSender.GetCapabilities(TrackKind.Video);
    RTCRtpTransceiver transceiver = peerConnection.GetTransceivers().First();
    RTCErrorType error = transceiver.SetCodecPreferences(capabilities.codecs);
    if (error.errorType != RTCErrorType.None)
    {
        Debug.LogError($"Failed to set codec preferences: {error.message}");
    }
    See Also
    RTCPeerConnection

    Stop()

    Stops the transceiver permanently by stopping both the associated RTCRtpSender and RTCRtpReceiver.

    Declaration
    public RTCErrorType Stop()
    Returns
    Type Description
    RTCErrorType

    RTCErrorType value.

    Remarks

    Calling Stop method stops the sender from sending media immediately, closes RTP streams with an RTCP "BYE" message, and the receiver stops receiving media. The receiver's track ceases, and the transceiver's direction changes to Stopped.

    Examples
    RTCErrorType error = transceiver.Stop();
    if (error.errorType != RTCErrorType.None)
    {
        Debug.LogError($"Failed to stop transceiver: {error.message}");
    }
    See Also
    RTCPeerConnection

    Implements

    IDisposable

    See Also

    RTCPeerConnection
    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)