docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class WebRTC

    Provides utilities and management functions for integrating WebRTC functionality.

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

    WebRTC class provides a set of static methods and properties to manage the WebRTC functionality.

    Examples
    StartCoroutine(WebRTC.Update());

    Properties

    Logger

    Logger used for capturing debug messages within the WebRTC package. Defaults to Debug.unityLogger.

    Declaration
    public static ILogger Logger { get; set; }
    Property Value
    Type Description
    ILogger
    Exceptions
    Type Condition
    ArgumentNullException

    Throws if setting a null logger.

    enableLimitTextureSize

    Controls whether texture size constraints are applied during WebRTC streaming.

    Declaration
    public static bool enableLimitTextureSize { get; set; }
    Property Value
    Type Description
    bool

    Methods

    ConfigureNativeLogging(bool, NativeLoggingSeverity)

    Configures native logging settings for WebRTC.

    Declaration
    public static void ConfigureNativeLogging(bool enableNativeLogging, NativeLoggingSeverity nativeLoggingSeverity)
    Parameters
    Type Name Description
    bool enableNativeLogging

    Enables or disable native logging.

    NativeLoggingSeverity nativeLoggingSeverity

    Sets the native logging level.

    Remarks

    ConfigureNativeLogging method is used to enable or disable native logging and set the native logging level.

    Examples
    WebRTC.ConfigureNativeLogging(true, NativeLoggingSeverity.Warning);

    ExecutePendingTasks(int)

    Executes any pending tasks generated asynchronously during the WebRTC runtime.

    Declaration
    public static bool ExecutePendingTasks(int millisecondTimeout)
    Parameters
    Type Name Description
    int millisecondTimeout

    The maximum time in milliseconds for which to process the task queue before task execution stops.

    Returns
    Type Description
    bool

    true if all pending tasks were completed within millisecondTimeout milliseconds and false otherwise.

    Remarks

    ExecutePendingTasks method processes pending tasks generated during WebRTC operations until reaching the specified timeout.

    Examples
    WebRTC.ExecutePendingTasks(100);

    GetSupportedGraphicsFormat(GraphicsDeviceType)

    Determines the appropriate GraphicsFormat for a given GraphicsDeviceType.

    Declaration
    public static GraphicsFormat GetSupportedGraphicsFormat(GraphicsDeviceType type)
    Parameters
    Type Name Description
    GraphicsDeviceType type

    GraphicsDeviceType for which GraphicsFormat is being determined.

    Returns
    Type Description
    GraphicsFormat

    GraphicsFormat value for the specified GraphicsDeviceType.

    Remarks

    GetSupportedGraphicsFormat method determines the appropriate GraphicsFormat for a given GraphicsDeviceType.

    Examples
    int width = WebRTCSettings.StreamSize.x;
    int height = WebRTCSettings.StreamSize.y;
    GraphicsFormat format = WebRTC.GetSupportedGraphicsFormat(GraphicsDeviceType.Direct3D11);
    RenderTexture texture = new RenderTexture(width, height, 0, format);

    GetSupportedRenderTextureFormat(GraphicsDeviceType)

    Determines the appropriate RenderTextureFormat for a given GraphicsDeviceType.

    Declaration
    public static RenderTextureFormat GetSupportedRenderTextureFormat(GraphicsDeviceType type)
    Parameters
    Type Name Description
    GraphicsDeviceType type

    GraphicsDeviceType for which RenderTextureFormat is being determined.

    Returns
    Type Description
    RenderTextureFormat

    RenderTextureFormat value for the specified GraphicsDeviceType.

    Remarks

    GetSupportedRenderTextureFormat method determines the appropriate RenderTextureFormat for a given GraphicsDeviceType.

    Examples
    RenderTextureFormat format = WebRTC.GetSupportedRenderTextureFormat(GraphicsDeviceType.Direct3D11);

    GetSupportedTextureFormat(GraphicsDeviceType)

    Determines the appropriate TextureFormat for a given GraphicsDeviceType.

    Declaration
    public static TextureFormat GetSupportedTextureFormat(GraphicsDeviceType type)
    Parameters
    Type Name Description
    GraphicsDeviceType type

    GraphicsDeviceType for which TextureFormat is being determined.

    Returns
    Type Description
    TextureFormat

    TextureFormat value for the specified GraphicsDeviceType.

    Remarks

    GetSupportedTextureFormat method determines the appropriate TextureFormat for a given GraphicsDeviceType.

    Examples
    TextureFormat format = WebRTC.GetSupportedTextureFormat(GraphicsDeviceType.Direct3D11);

    SetGraphicsSyncTimeout(uint)

    Sets the graphics sync timeout. Graphics sync timeout determines how long the graphics device will wait on the frame copy for encoding before timing out. By default timeout is set to 60 milliseconds.

    Declaration
    public static void SetGraphicsSyncTimeout(uint nSecTimeout)
    Parameters
    Type Name Description
    uint nSecTimeout

    The timeout value specified in nanoseconds.

    Update()

    Updates the texture data for all video tracks at the end of each frame.

    Declaration
    public static IEnumerator Update()
    Returns
    Type Description
    IEnumerator

    IEnumerator to facilitate coroutine execution.

    Remarks

    Update method updates the texture data for all video tracks at the end of each frame.

    Examples
    StartCoroutine(WebRTC.Update());

    ValidateGraphicsFormat(GraphicsFormat)

    Checks whether the specified graphics format is supported.

    Declaration
    public static void ValidateGraphicsFormat(GraphicsFormat format)
    Parameters
    Type Name Description
    GraphicsFormat format

    GraphicsFormat value to be validated.

    Remarks

    ValidateGraphicsFormat method checks whether the provided GraphicsFormat is compatible with the current graphics device. This method throws an ArgumentException if the format is not supported.

    Examples
    WebRTC.ValidateGraphicsFormat(format);
    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)