Class WebRTC
Provides utilities and management functions for integrating WebRTC functionality.
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 |
|
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 |
|
Returns
Type | Description |
---|---|
GraphicsFormat |
|
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 |
|
Returns
Type | Description |
---|---|
RenderTextureFormat |
|
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 |
|
Returns
Type | Description |
---|---|
TextureFormat |
|
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 |
|
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 |
|
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);