docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class RTCRtpEncodingParameters

    Represents the parameters for a codec used to encode the track's media.

    Inheritance
    object
    RTCRtpEncodingParameters
    Namespace: Unity.WebRTC
    Assembly: Unity.WebRTC.dll
    Syntax
    public class RTCRtpEncodingParameters
    Remarks

    Represents the configuration for encoding a media track's codec, detailing properties like active state, bitrate, framerate, RTP stream ID, and video scaling, enabling precise control of media transmission.

    Examples
    [SerializeField]
    Camera cam;
    
    void Call()
    {
        MediaStream videoStream = cam.CaptureStream(WebRTCSettings.StreamSize.x, WebRTCSettings.StreamSize.y);
        RTCRtpTransceiverInit init = new RTCRtpTransceiverInit()
        {
            direction = RTCRtpTransceiverDirection.SendOnly,
            sendEncodings = new RTCRtpEncodingParameters[] {
                new RTCRtpEncodingParameters { maxFramerate = 30 }
            },
        };
        MediaStreamTrack videoTrack = videoStream.GetTracks().First();
        RTCRtpTransceiver transceiver = peerConnection.AddTransceiver(videoTrack, init);
    }

    Constructors

    RTCRtpEncodingParameters()

    Creates a new RTCRtpEncodingParameters object.

    Declaration
    public RTCRtpEncodingParameters()
    Remarks

    A constructor creates an instance of RTCRtpEncodingParameters.

    Examples
    RTCRtpEncodingParameters parameters = new RTCRtpEncodingParameters();

    Fields

    active

    Indicates whether the encoding is sent.

    Declaration
    public bool active
    Field Value
    Type Description
    bool
    Remarks

    By default, the value is true. Setting it to false stops the transmission but does not cause the SSRC to be removed.

    maxBitrate

    Specifies the maximum number of bits per second allocated for encoding tracks.

    Declaration
    public ulong? maxBitrate
    Field Value
    Type Description
    ulong?
    Remarks

    maxBitrate defines the maximum encoding bitrate using TIAS bandwidth, not including protocol overhead. Factors like maxFramerate and network capacity can further limit this rate. Video tracks may drop frames, and audio tracks might pause if bitrates are too low, balancing quality and efficiency.

    maxFramerate

    Specifies the maximum number of frames per second allocated for encoding tracks.

    Declaration
    public uint? maxFramerate
    Field Value
    Type Description
    uint?

    minBitrate

    Specifies the minimum number of bits per second allocated for encoding tracks.

    Declaration
    public ulong? minBitrate
    Field Value
    Type Description
    ulong?

    rid

    Specifies an RTP stream ID (RID) for the RID header extension.

    Declaration
    public string rid
    Field Value
    Type Description
    string
    Remarks

    The value can be set only during transceiver creation and not modifiable with RTCRtpSender.SetParameters.

    scaleResolutionDownBy

    Specifies a scaling factor for reducing the resolution of video tracks during encoding.

    Declaration
    public double? scaleResolutionDownBy
    Field Value
    Type Description
    double?
    Remarks

    scaleResolutionDownBy property scales down video resolutions for encoding. With the default value 1.0 preserves the original size. Values above 1.0 reduce dimensions, helping optimize bandwidth and processing needs. Values below 1.0 are invalid.

    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)