[WebRTC] Fix bugs (#3526)
authorHaesu Gwon <haesu.gwon@samsung.com>
Mon, 13 Sep 2021 06:03:07 +0000 (15:03 +0900)
committerGitHub <noreply@github.com>
Mon, 13 Sep 2021 06:03:07 +0000 (15:03 +0900)
* [WebRTC] Fix bugs ans Change MediaFileSource to internal API

src/Tizen.Multimedia.Remoting/WebRTC/MediaFileSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs
src/Tizen.Multimedia.Remoting/WebRTC/WebRTC.cs
src/Tizen.Multimedia.Remoting/WebRTC/WebRTCDataChannel.cs

index 42db970..10933f9 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using System;
+using System.ComponentModel;
 using System.Diagnostics;
 using NativeWebRTC = Interop.NativeWebRTC;
 
@@ -30,6 +31,7 @@ namespace Tizen.Multimedia.Remoting
     /// <seealso cref="WebRTC.AddSource"/>
     /// <seealso cref="WebRTC.AddSources"/>
     /// <since_tizen> 9 </since_tizen>
+    [EditorBrowsable(EditorBrowsableState.Never)]
     public sealed class MediaFileSource : MediaSource
     {
         private string _path;
@@ -41,6 +43,7 @@ namespace Tizen.Multimedia.Remoting
         /// <param name="path">The file path.</param>
         /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
         /// <since_tizen> 9 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public MediaFileSource(MediaType type, string path) : base(type)
         {
             _path = path ?? throw new ArgumentNullException(nameof(path), "path is null");
index 688d752..de9a226 100755 (executable)
@@ -67,13 +67,22 @@ namespace Tizen.Multimedia.Remoting
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed of.</exception>
         /// <exception cref="ArgumentException">The value has already been assigned to another WebRTC.</exception>
-        /// <exception cref="InvalidOperationException">The WebRTC is not called in <see cref="WebRTC.TrackAdded"/> event.</exception>
+        /// <exception cref="InvalidOperationException">
+        /// The WebRTC is not called in <see cref="WebRTC.TrackAdded"/> event.
+        /// -or-<br/>
+        /// This MediaStreamTrack is not Video.
+        /// </exception>
         /// <since_tizen> 9 </since_tizen>
         public Display Display
         {
             get => _display;
             set
             {
+                if (Type != MediaType.Video)
+                {
+                    throw new InvalidOperationException("This property is only for video.");
+                }
+
                 if (value == null)
                 {
                     throw new ArgumentNullException(nameof(value), "Display cannot be null.");
@@ -116,6 +125,7 @@ namespace Tizen.Multimedia.Remoting
         /// </remarks>
         /// <value>A <see cref="WebRTCDisplayMode"/> that specifies the display mode.</value>
         /// <exception cref="ArgumentException">Display mode type is incorrect.</exception>
+        /// <exception cref="InvalidOperationException"><see cref="Display"/> is not set.</exception>
         /// <since_tizen> 9 </since_tizen>
         public WebRTCDisplayMode DisplayMode
         {
@@ -142,12 +152,13 @@ namespace Tizen.Multimedia.Remoting
         /// <remarks>
         /// This property is meaningful only in overlay or EVAS surface display type.
         /// </remarks>
+        /// <exception cref="InvalidOperationException"><see cref="Display"/> is not set.</exception>
         /// <since_tizen> 9 </since_tizen>
         public bool DisplayVisible
         {
             get
             {
-                NativeWebRTC.GetDisplayVisible(_webRtc.Handle, _trackId,out bool val).
+                NativeWebRTC.GetDisplayVisible(_webRtc.Handle, _trackId, out bool val).
                     ThrowIfFailed("Failed to get visible status");
 
                 return val;
@@ -175,6 +186,8 @@ namespace Tizen.Multimedia.Remoting
         /// <see cref="WebRTC.AudioFrameEncoded"/> was set.<br/>
         /// -or-<br/>
         /// This method was not called in <see cref="WebRTC.TrackAdded"/> event.
+        /// -or-<br/>
+        /// This MediaStreamTrack is not Audio.
         /// </exception>
         /// <exception cref="NotSupportedException">
         ///     <see cref="AudioStreamType"/> of <paramref name="policy"/> is not supported on the current platform.
index b4fd253..b077eb3 100755 (executable)
@@ -88,7 +88,6 @@ namespace Tizen.Multimedia.Remoting
         /// <summary>
         /// Releases all resources used by the current instance.
         /// </summary>
-        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
         /// <since_tizen> 9 </since_tizen>
         public void Dispose()
         {
@@ -130,7 +129,6 @@ namespace Tizen.Multimedia.Remoting
 
             if (_handle != null)
             {
-                UnregisterEvents();
                 _handle.Dispose();
                 _disposed = true;
             }
@@ -231,32 +229,13 @@ namespace Tizen.Multimedia.Remoting
         }
 
         /// <summary>
-        /// Creates SDP offer to start a new WebRTC connection to a remote peer.
-        /// </summary>
-        /// <remarks>The WebRTC must be in the <see cref="WebRTCState.Negotiating"/></remarks>
-        /// <returns>The SDP offer.</returns>
-        /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
-        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
-        /// <seealso cref="CreateOfferAsync()"/>
-        /// <since_tizen> 9 </since_tizen>
-        public string CreateOffer()
-        {
-            ValidateWebRTCState(WebRTCState.Negotiating);
-
-            NativeWebRTC.CreateSDPOffer(Handle, new SafeBundleHandle(), out string offer).
-                    ThrowIfFailed("Failed to create offer");
-
-            return offer;
-        }
-
-        /// <summary>
         /// Creates SDP offer asynchronously to start a new WebRTC connection to a remote peer.
         /// </summary>
         /// <remarks>The WebRTC must be in the <see cref="WebRTCState.Negotiating"/></remarks>
         /// <returns>The SDP offer.</returns>
         /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
-        /// <seealso cref="CreateOffer()"/>
+        /// <seealso cref="CreateAnswerAsync()"/>
         /// <since_tizen> 9 </since_tizen>
         public async Task<string> CreateOfferAsync()
         {
@@ -279,36 +258,13 @@ namespace Tizen.Multimedia.Remoting
         }
 
         /// <summary>
-        /// Creates SDP answer to an offer received from a remote peer.
-        /// </summary>
-        /// <remarks>
-        /// The WebRTC must be in the <see cref="WebRTCState.Negotiating"/>.<br/>
-        /// The SDP offer must be set by <see cref="SetRemoteDescription"/> before creating answer.
-        /// </remarks>
-        /// <returns>The SDP answer.</returns>
-        /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
-        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
-        /// <seealso cref="CreateAnswerAsync()"/>
-        /// <seealso cref="SetRemoteDescription(string)"/>
-        /// <since_tizen> 9 </since_tizen>
-        public string CreateAnswer()
-        {
-            ValidateWebRTCState(WebRTCState.Negotiating);
-
-            NativeWebRTC.CreateSDPAnswer(Handle, new SafeBundleHandle(), out string answer).
-                    ThrowIfFailed("Failed to create answer");
-
-            return answer;
-        }
-
-        /// <summary>
         /// Creates SDP answer asynchronously with option to an offer received from a remote peer.
         /// </summary>
         /// <remarks>The WebRTC must be in the <see cref="WebRTCState.Negotiating"/></remarks>
         /// <returns>The SDP answer.</returns>
         /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
-        /// <seealso cref="CreateAnswer()"/>
+        /// <seealso cref="CreateOfferAsync()"/>
         /// <since_tizen> 9 </since_tizen>
         public async Task<string> CreateAnswerAsync()
         {
@@ -339,8 +295,8 @@ namespace Tizen.Multimedia.Remoting
         /// <exception cref="ArgumentNullException">The description is null.</exception>
         /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
-        /// <seealso cref="CreateOffer()"/>
-        /// <seealso cref="CreateAnswer()"/>
+        /// <seealso cref="CreateOfferAsync()"/>
+        /// <seealso cref="CreateAnswerAsync()"/>
         /// <since_tizen> 9 </since_tizen>
         public void SetLocalDescription(string description)
         {
@@ -360,8 +316,8 @@ namespace Tizen.Multimedia.Remoting
         /// <exception cref="ArgumentNullException">The description is null.</exception>
         /// <exception cref="InvalidOperationException">The WebRTC is not in the valid state.</exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
-        /// <seealso cref="CreateOffer()"/>
-        /// <seealso cref="CreateAnswer()"/>
+        /// <seealso cref="CreateOfferAsync()"/>
+        /// <seealso cref="CreateAnswerAsync()"/>
         /// <since_tizen> 9 </since_tizen>
         public void SetRemoteDescription(string description)
         {
@@ -422,7 +378,6 @@ namespace Tizen.Multimedia.Remoting
         /// The WebRTC must be in the <see cref="WebRTCState.Idle"/>.<br/>
         /// Each MediaSource requires different feature or privilege.<br/>
         /// <see cref="MediaCameraSource"/> needs camera feature and privilege.<br/>
-        /// <see cref="MediaFileSource"/> needs mediastorage or externalstorage privilege.<br/>
         /// <see cref="MediaMicrophoneSource"/> needs microphone feature and recorder privilege.<br/>
         /// </remarks>
         /// <param name="source">The media sources to add.</param>
@@ -470,7 +425,6 @@ namespace Tizen.Multimedia.Remoting
         /// The WebRTC must be in the <see cref="WebRTCState.Idle"/>.<br/>
         /// Each MediaSource requires different feature or privilege.<br/>
         /// <see cref="MediaCameraSource"/> needs camera feature and privilege.<br/>
-        /// <see cref="MediaFileSource"/> needs mediastorage or externalstorage privilege.<br/>
         /// <see cref="MediaMicrophoneSource"/> needs microphone feature and recorder privilege.<br/>
         /// </remarks>
         /// <param name="sources">The media sources to add.</param>
index 3a8a5c9..df8eb66 100755 (executable)
@@ -122,6 +122,7 @@ namespace Tizen.Multimedia.Remoting
         /// Sends a string data across the data channel to the remote peer.
         /// </summary>
         /// <param name="data">The string data to send</param>
+        /// <exception cref="ObjectDisposedException">The WebRTCDataChannel has already been disposed.</exception>
         /// <since_tizen> 9 </since_tizen>
         public void Send(string data)
         {
@@ -135,6 +136,7 @@ namespace Tizen.Multimedia.Remoting
         /// Sends byte data across the data channel to the remote peer.
         /// </summary>
         /// <param name="data">The byte data to send</param>
+        /// <exception cref="ObjectDisposedException">The WebRTCDataChannel has already been disposed.</exception>
         /// <since_tizen> 9 </since_tizen>
         public void Send(byte[] data)
         {
@@ -155,7 +157,6 @@ namespace Tizen.Multimedia.Remoting
         /// <summary>
         /// Releases all resources used by the current instance.
         /// </summary>
-        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
         /// <since_tizen> 9 </since_tizen>
         public void Dispose()
         {