[WebRTC] Add new APIs for VideoFrameRate and bundle policy (#4381)
authorHaesu Gwon <haesu.gwon@samsung.com>
Mon, 18 Jul 2022 07:59:19 +0000 (16:59 +0900)
committerGitHub <noreply@github.com>
Mon, 18 Jul 2022 07:59:19 +0000 (16:59 +0900)
* [WebRTC] Add new APIs for VideoFrameRate and bundle policy

src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.Properties.cs
src/Tizen.Multimedia.Remoting/WebRTC/WebRTCEnums.cs

index b4d9e9c..614c6f2 100755 (executable)
@@ -143,6 +143,12 @@ internal static partial class Interop
         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_video_resolution")]
         internal static extern WebRTCErrorCode GetVideoResolution(IntPtr handle, uint sourceId, out int width, out int height);
 
+        [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_video_framerate")]
+        internal static extern WebRTCErrorCode SetVideoFrameRate(IntPtr handle, uint sourceId, int frameRate);
+
+        [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_video_framerate")]
+        internal static extern WebRTCErrorCode GetVideoFrameRate(IntPtr handle, uint sourceId, out int frameRate);
+
         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_audio_loopback")]
         internal static extern WebRTCErrorCode SetAudioLoopback(IntPtr handle, uint sourceId, AudioStreamPolicyHandle streamInfo, out uint trackId);
 
@@ -152,6 +158,12 @@ internal static partial class Interop
         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_video_loopback_to_ecore_wl")]
         internal static extern WebRTCErrorCode SetEcoreVideoLoopback(IntPtr handle, uint sourceId, IntPtr display, out uint trackId);
 
+        [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_bundle_policy")]
+        internal static extern WebRTCErrorCode SetBundlePolicy(IntPtr handle, WebRTCBundlePolicy bundlePolicy);
+
+        [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_get_bundle_policy")]
+        internal static extern WebRTCErrorCode GetBundlePolicy(IntPtr handle, out WebRTCBundlePolicy bundlePolicy);
+
         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_mic_source_set_sound_stream_info")]
         internal static extern WebRTCErrorCode SetAudioStreamPolicyToMicrophoneSource(IntPtr handle, uint sourceId, AudioStreamPolicyHandle streamInfo);
 
index 83a808a..d91c223 100755 (executable)
@@ -171,11 +171,11 @@ namespace Tizen.Multimedia.Remoting
         /// <summary>
         /// Gets or sets the video resolution of the current media source.
         /// </summary>
-        /// <value>A value that specifies the mute status.</value>
+        /// <value>A value that specifies the video resolution.</value>
         /// <exception cref="InvalidOperationException">
         ///     MediaSource is not attached yet.<br/>
         /// -or-<br/>
-        ///     This MediaSource is not Video
+        ///     This MediaSource is not Video.
         /// </exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
         /// <since_tizen> 9 </since_tizen>
@@ -214,6 +214,70 @@ namespace Tizen.Multimedia.Remoting
         }
 
         /// <summary>
+        /// Gets or sets the video frame rate of the current media source.
+        /// </summary>
+        /// <remarks>
+        /// This API is only supported in video media source, especially <see cref="MediaCameraSource"/>,
+        /// <see cref="MediaScreenSource"/>, <see cref="MediaTestSource"/>.<br/>
+        /// </remarks>
+        /// <value>A value that specifies the video frame rate.</value>
+        /// <exception cref="ArgumentException">VideoFrameRate is less than or equal to zero.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     MediaSource is not attached yet.<br/>
+        /// -or-<br/>
+        ///     This MediaSource is not Video.
+        /// -or-<br/>
+        ///     This MediaSource is not supported type of MediaSource.
+        /// </exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <since_tizen> 10 </since_tizen>
+        public int VideoFrameRate
+        {
+            get
+            {
+                if (!SourceId.HasValue)
+                {
+                    throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+                }
+                if (MediaType != MediaType.Video)
+                {
+                    throw new InvalidOperationException("This property is only for video.");
+                }
+                if (this is MediaFileSource || this is MediaPacketSource)
+                {
+                    throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+                }
+
+                NativeWebRTC.GetVideoFrameRate(WebRtc.Handle, SourceId.Value, out int frameRate).
+                    ThrowIfFailed("Failed to get video frame rate");
+
+                return frameRate;
+            }
+            set
+            {
+                if (value <= 0)
+                {
+                    throw new ArgumentException($"VideoFrameRate should be greater than zero.");
+                }
+                if (!SourceId.HasValue)
+                {
+                    throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+                }
+                if (MediaType != MediaType.Video)
+                {
+                    throw new InvalidOperationException("This property is only for video.");
+                }
+                if (this is MediaFileSource || this is MediaPacketSource)
+                {
+                    throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+                }
+
+                NativeWebRTC.SetVideoFrameRate(WebRtc.Handle, SourceId.Value, value).
+                    ThrowIfFailed("Failed to set video frame rate");
+            }
+        }
+
+        /// <summary>
         /// Enables the audio loopback. The local audio will be played with <paramref name="policy"/>.
         /// </summary>
         /// <param name="policy">The <see cref="AudioStreamPolicy"/> to apply.</param>
index cdb0a77..d2cc86c 100755 (executable)
@@ -199,5 +199,32 @@ namespace Tizen.Multimedia.Remoting
                     ThrowIfFailed("Failed to set ICE transport policy");
             }
         }
+
+        /// <summary>
+        /// Gets or sets the bundle policy.<br/>
+        /// The default bundle policy is <see cref="WebRTCBundlePolicy.MaxBundle"/>.
+        /// </summary>
+        /// <value>The policy of bundle</value>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <since_tizen> 10 </since_tizen>
+        public WebRTCBundlePolicy BundlePolicy
+        {
+            get
+            {
+                ValidateNotDisposed();
+
+                NativeWebRTC.GetBundlePolicy(Handle, out WebRTCBundlePolicy bundlePolicy).
+                    ThrowIfFailed("Failed to get bundle policy");
+
+                return bundlePolicy;
+            }
+            set
+            {
+                ValidateNotDisposed();
+
+                NativeWebRTC.SetBundlePolicy(Handle, value).
+                    ThrowIfFailed("Failed to set bundle policy");
+            }
+        }
     }
 }
index 31d6f4b..dea0dee 100755 (executable)
@@ -346,6 +346,26 @@ namespace Tizen.Multimedia.Remoting
     }
 
     /// <summary>
+    /// Specifies the bundle policy.
+    /// </summary>
+    /// <remarks>
+    /// The details of bundle policy enum is described in https://www.w3.org/TR/webrtc/#rtcbundlepolicy-enum.
+    /// </remarks>
+    /// <since_tizen> 10 </since_tizen>
+    public enum WebRTCBundlePolicy
+    {
+        /// <summary>
+        /// No bundle.
+        /// </summary>
+        None,
+
+        /// <summary>
+        /// Bundle all media tracks into a stream when it's transfered to remote peer.
+        /// </summary>
+        MaxBundle
+    }
+
+    /// <summary>
     /// Specifies the signaling message type.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]