Skip to content

Commit 8741a13

Browse files
authored
Merge pull request #1060 from Unity-Technologies/dw24-web-rtc
doc: Improve documentation of WebRTC
2 parents 264855e + ecff9a5 commit 8741a13

File tree

1 file changed

+90
-22
lines changed

1 file changed

+90
-22
lines changed

Runtime/Scripts/WebRTC.cs

Lines changed: 90 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,17 @@ public enum NativeLoggingSeverity
631631
};
632632

633633
/// <summary>
634-
///
634+
/// Provides utilities and management functions for integrating WebRTC functionality.
635635
/// </summary>
636+
/// <remarks>
637+
/// `WebRTC` class provides a set of static methods and properties to manage the WebRTC functionality.
638+
/// </remarks>
639+
/// <example>
640+
/// <code lang="cs"><![CDATA[
641+
/// StartCoroutine(WebRTC.Update());
642+
/// ]]></code>
643+
/// </example>
644+
/// <seealso cref="WebRTCSettings"/>
636645
public static class WebRTC
637646
{
638647
#if UNITY_IOS
@@ -673,9 +682,17 @@ internal static void InitializeInternal(bool limitTextureSize = true, bool enabl
673682
}
674683

675684
/// <summary>
676-
///
685+
/// Updates the texture data for all video tracks at the end of each frame.
677686
/// </summary>
678-
/// <returns></returns>
687+
/// <remarks>
688+
/// `Update` method updates the texture data for all video tracks at the end of each frame.
689+
/// </remarks>
690+
/// <returns>`IEnumerator` to facilitate coroutine execution.</returns>
691+
/// <example>
692+
/// <code lang="cs"><![CDATA[
693+
/// StartCoroutine(WebRTC.Update());
694+
/// ]]></code>
695+
/// </example>
679696
public static IEnumerator Update()
680697
{
681698
var instruction = new WaitForEndOfFrame();
@@ -715,15 +732,22 @@ public static IEnumerator Update()
715732
}
716733

717734
/// <summary>
718-
/// Executes any pending tasks generated asynchronously during the WebRTC runtime.
735+
/// Executes any pending tasks generated asynchronously during the WebRTC runtime.
719736
/// </summary>
737+
/// <remarks>
738+
/// `ExecutePendingTasks` method processes pending tasks generated during WebRTC operations until reaching the specified timeout.
739+
/// </remarks>
720740
/// <param name="millisecondTimeout">
721-
/// The amount of time in milliseconds that the task queue can take before task execution will cease.
741+
/// The maximum time in milliseconds for which to process the task queue before task execution stops.
722742
/// </param>
723743
/// <returns>
724-
/// <c>true</c> if all pending tasks were completed within <see cref="millisecondTimeout"/> milliseconds and <c>false</c>
725-
/// otherwise.
744+
/// `true` if all pending tasks were completed within <see cref="millisecondTimeout"/> milliseconds and `false` otherwise.
726745
/// </returns>
746+
/// <example>
747+
/// <code lang="cs"><![CDATA[
748+
/// WebRTC.ExecutePendingTasks(100);
749+
/// ]]></code>
750+
/// </example>
727751
public static bool ExecutePendingTasks(int millisecondTimeout)
728752
{
729753
if (s_syncContext is ExecutableUnitySynchronizationContext executableContext)
@@ -735,7 +759,7 @@ public static bool ExecutePendingTasks(int millisecondTimeout)
735759
}
736760

737761
/// <summary>
738-
///
762+
/// Controls whether texture size constraints are applied during WebRTC streaming.
739763
/// </summary>
740764
public static bool enableLimitTextureSize
741765
{
@@ -744,8 +768,8 @@ public static bool enableLimitTextureSize
744768
}
745769

746770
/// <summary>
747-
/// Get & set the logger to use when logging debug messages inside the WebRTC package.
748-
/// By default will use Debug.unityLogger.
771+
/// Logger used for capturing debug messages within the WebRTC package.
772+
/// Defaults to Debug.unityLogger.
749773
/// </summary>
750774
/// <exception cref="ArgumentNullException">Throws if setting a null logger.</exception>
751775
public static ILogger Logger
@@ -766,10 +790,18 @@ public static ILogger Logger
766790
}
767791

768792
/// <summary>
769-
/// Configure native logging settings for WebRTC.
793+
/// Configures native logging settings for WebRTC.
770794
/// </summary>
795+
/// <remarks>
796+
/// `ConfigureNativeLogging` method is used to enable or disable native logging and set the native logging level.
797+
/// </remarks>
771798
/// <param name="enableNativeLogging">Enables or disable native logging.</param>
772799
/// <param name="nativeLoggingSeverity">Sets the native logging level.</param>
800+
/// <example>
801+
/// <code lang="cs"><![CDATA[
802+
/// WebRTC.ConfigureNativeLogging(true, NativeLoggingSeverity.Warning);
803+
/// ]]></code>
804+
/// </example>
773805
public static void ConfigureNativeLogging(bool enableNativeLogging, NativeLoggingSeverity nativeLoggingSeverity)
774806
{
775807
if (enableNativeLogging)
@@ -870,9 +902,18 @@ internal static RTCError ValidateTextureSize(int width, int height, RuntimePlatf
870902
}
871903

872904
/// <summary>
873-
///
905+
/// Checks whether the specified graphics format is supported.
874906
/// </summary>
875-
/// <param name="format"></param>
907+
/// <remarks>
908+
/// `ValidateGraphicsFormat` method checks whether the provided `GraphicsFormat` is compatible with the current graphics device.
909+
/// This method throws an `ArgumentException` if the format is not supported.
910+
/// </remarks>
911+
/// <param name="format">`GraphicsFormat` value to be validated.</param>
912+
/// <example>
913+
/// <code lang="cs"><![CDATA[
914+
/// WebRTC.ValidateGraphicsFormat(format);
915+
/// ]]></code>
916+
/// </example>
876917
public static void ValidateGraphicsFormat(GraphicsFormat format)
877918
{
878919
// can't recognize legacy format
@@ -893,21 +934,40 @@ public static void ValidateGraphicsFormat(GraphicsFormat format)
893934
}
894935

895936
/// <summary>
896-
///
937+
/// Determines the appropriate RenderTextureFormat for a given GraphicsDeviceType.
897938
/// </summary>
898-
/// <param name="type"></param>
899-
/// <returns></returns>
939+
/// <remarks>
940+
/// `GetSupportedRenderTextureFormat` method determines the appropriate `RenderTextureFormat` for a given `GraphicsDeviceType`.
941+
/// </remarks>
942+
/// <param name="type">`GraphicsDeviceType` for which `RenderTextureFormat` is being determined.</param>
943+
/// <returns>`RenderTextureFormat` value for the specified `GraphicsDeviceType`.</returns>
944+
/// <example>
945+
/// <code lang="cs"><![CDATA[
946+
/// RenderTextureFormat format = WebRTC.GetSupportedRenderTextureFormat(GraphicsDeviceType.Direct3D11);
947+
/// ]]></code>
948+
/// </example>
900949
public static RenderTextureFormat GetSupportedRenderTextureFormat(GraphicsDeviceType type)
901950
{
902951
var graphicsFormat = GetSupportedGraphicsFormat(type);
903952
return GraphicsFormatUtility.GetRenderTextureFormat(graphicsFormat);
904953
}
905954

906955
/// <summary>
907-
///
956+
/// Determines the appropriate GraphicsFormat for a given GraphicsDeviceType.
908957
/// </summary>
909-
/// <param name="type"></param>
910-
/// <returns></returns>
958+
/// <remarks>
959+
/// `GetSupportedGraphicsFormat` method determines the appropriate `GraphicsFormat` for a given `GraphicsDeviceType`.
960+
/// </remarks>
961+
/// <param name="type">`GraphicsDeviceType` for which `GraphicsFormat` is being determined.</param>
962+
/// <returns>`GraphicsFormat` value for the specified `GraphicsDeviceType`.</returns>
963+
/// <example>
964+
/// <code lang="cs"><![CDATA[
965+
/// int width = WebRTCSettings.StreamSize.x;
966+
/// int height = WebRTCSettings.StreamSize.y;
967+
/// GraphicsFormat format = WebRTC.GetSupportedGraphicsFormat(GraphicsDeviceType.Direct3D11);
968+
/// RenderTexture texture = new RenderTexture(width, height, 0, format);
969+
/// ]]></code>
970+
/// </example>
911971
public static GraphicsFormat GetSupportedGraphicsFormat(GraphicsDeviceType type)
912972
{
913973
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
@@ -947,10 +1007,18 @@ public static GraphicsFormat GetSupportedGraphicsFormat(GraphicsDeviceType type)
9471007
}
9481008

9491009
/// <summary>
950-
///
1010+
/// Determines the appropriate TextureFormat for a given GraphicsDeviceType.
9511011
/// </summary>
952-
/// <param name="type"></param>
953-
/// <returns></returns>
1012+
/// <remarks>
1013+
/// `GetSupportedTextureFormat` method determines the appropriate `TextureFormat` for a given `GraphicsDeviceType`.
1014+
/// </remarks>
1015+
/// <param name="type">`GraphicsDeviceType` for which `TextureFormat` is being determined.</param>
1016+
/// <returns>`TextureFormat` value for the specified `GraphicsDeviceType`.</returns>
1017+
/// <example>
1018+
/// <code lang="cs"><![CDATA[
1019+
/// TextureFormat format = WebRTC.GetSupportedTextureFormat(GraphicsDeviceType.Direct3D11);
1020+
/// ]]></code>
1021+
/// </example>
9541022
public static TextureFormat GetSupportedTextureFormat(GraphicsDeviceType type)
9551023
{
9561024
var graphicsFormat = GetSupportedGraphicsFormat(type);

0 commit comments

Comments
 (0)