[WebRTC] Add new APIs for MediaNullSource and change MediaFileSource ctor (#4558)
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 21 Sep 2022 23:57:53 +0000 (08:57 +0900)
committerGitHub <noreply@github.com>
Wed, 21 Sep 2022 23:57:53 +0000 (08:57 +0900)
* [WebRTC] Add new APIs for MediaNullSource and change MediaFileSource ctor

src/Tizen.Multimedia.Remoting/WebRTC/MediaCameraSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaFileSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaMicrophoneSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaNullSource.cs [new file with mode: 0755]
src/Tizen.Multimedia.Remoting/WebRTC/MediaPacketSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaScreenSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaSource.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaTestSource.cs

index c6829b3..50a3411 100755 (executable)
@@ -91,5 +91,7 @@ namespace Tizen.Multimedia.Remoting
 
             WebRtc = null;
         }
+
+        internal override MediaSourceType MediaSourceType => MediaSourceType.Camera;
     }
 }
index 1c6ba9e..24c52ff 100755 (executable)
@@ -37,11 +37,10 @@ namespace Tizen.Multimedia.Remoting
         /// <summary>
         /// Initializes a new instance of the <see cref="MediaFileSource"/> class.
         /// </summary>
-        /// <param name="type">The <see cref="MediaType"/> of file source.</param>
         /// <param name="path">The file path.</param>
         /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
         /// <since_tizen> 10 </since_tizen>
-        public MediaFileSource(MediaType type, string path) : base(type)
+        public MediaFileSource(string path) : base()
         {
             _path = path ?? throw new ArgumentNullException(nameof(path), "path is null");
         }
@@ -82,6 +81,99 @@ namespace Tizen.Multimedia.Remoting
             }
         }
 
+        /// <summary>
+        /// Gets the transceiver direction for receiving media stream.
+        /// </summary>
+        /// <param name="type">The media type.</param>
+        /// <returns>The transceiver direction.</returns>
+        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <since_tizen> 10 </since_tizen>
+        public TransceiverDirection GetTransceiverDirection(MediaType type)
+        {
+            if (!SourceId.HasValue)
+            {
+                throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+            }
+
+            NativeWebRTC.GetTransceiverDirection(WebRtc.Handle, SourceId.Value, type, out TransceiverDirection direction).
+                ThrowIfFailed("Failed to get transceiver direction.");
+
+            return direction;
+        }
+
+        /// <summary>
+        /// Sets the transceiver direction for receiving media stream.
+        /// </summary>
+        /// <remarks>
+        /// The WebRTC must be in the <see cref="WebRTCState.Idle"/> state when transceiver direction is set.
+        /// </remarks>
+        /// <param name="type">The media type.</param>
+        /// <param name="direction">The transceiver direction.</param>
+        /// <exception cref="InvalidOperationException">
+        ///     MediaSource is not attached yet.<br/>
+        /// -or-<br/>
+        ///     The WebRTC is not in the valid state.
+        /// </exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <since_tizen> 10 </since_tizen>
+        public void SetTransceiverDirection(MediaType type, TransceiverDirection direction)
+        {
+            if (!SourceId.HasValue)
+            {
+                throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+            }
+
+            WebRtc.ValidateWebRTCState(WebRTCState.Idle);
+
+            NativeWebRTC.SetTransceiverDirection(WebRtc.Handle, SourceId.Value, type, direction).
+                ThrowIfFailed("Failed to set transceiver direction");
+        }
+
+        /// <summary>
+        /// Gets the pause status of media file source.
+        /// </summary>
+        /// <param name="type">The media type.</param>
+        /// <returns>The pause status.</returns>
+        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <since_tizen> 10 </since_tizen>
+        public bool GetPause(MediaType type)
+        {
+            if (!SourceId.HasValue)
+            {
+                throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+            }
+
+            WebRtc.ValidateWebRTCState(WebRTCState.Idle);
+
+            NativeWebRTC.GetPause(WebRtc.Handle, SourceId.Value, MediaType, out bool isPaused).
+                ThrowIfFailed("Failed to get pause");
+
+            return isPaused;
+        }
+
+        /// <summary>
+        /// Sets the pause status of media file source.
+        /// </summary>
+        /// <param name="type">The media type.</param>
+        /// <param name="isPaused">The pause status.</param>
+        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <since_tizen> 10 </since_tizen>
+        public void SetPause(MediaType type, bool isPaused)
+        {
+            if (!SourceId.HasValue)
+            {
+                throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+            }
+
+            WebRtc.ValidateWebRTCState(WebRTCState.Idle);
+
+            NativeWebRTC.SetPause(WebRtc.Handle, SourceId.Value, type, isPaused).
+                ThrowIfFailed("Failed to set pause");
+        }
+
         internal override void OnAttached(WebRTC webRtc)
         {
             Debug.Assert(webRtc != null);
@@ -108,5 +200,7 @@ namespace Tizen.Multimedia.Remoting
 
             WebRtc = null;
         }
+
+        internal override MediaSourceType MediaSourceType => MediaSourceType.File;
     }
 }
index e5adf91..d4cd5d0 100755 (executable)
@@ -59,6 +59,8 @@ namespace Tizen.Multimedia.Remoting
             WebRtc = (WebRTC)null;
         }
 
+        internal override MediaSourceType MediaSourceType => MediaSourceType.Microphone;
+
         /// <summary>
         /// Applies the audio stream policy to <see cref="MediaMicrophoneSource"/>.
         /// </summary>
diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/MediaNullSource.cs b/src/Tizen.Multimedia.Remoting/WebRTC/MediaNullSource.cs
new file mode 100755 (executable)
index 0000000..9100998
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using NativeWebRTC = Interop.NativeWebRTC;
+
+namespace Tizen.Multimedia.Remoting
+{
+    /// <summary>Represents a null source.</summary>
+    /// <remarks>
+    /// If you add this source, WebRTC only receives media stream.<br/>
+    /// <see cref="TransceiverDirection"/> is set <see cref="TransceiverDirection.RecvOnly"/> by default.
+    /// </remarks>
+    /// <seealso cref="WebRTC.AddSource"/>
+    /// <since_tizen> 10 </since_tizen>
+    public sealed class MediaNullSource : MediaSource
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MediaNullSource"/> class.
+        /// </summary>
+        /// <remarks>TransceiverCodec should be set to receive audio, video stream.</remarks>
+        /// <seealso cref="SetTransceiverCodec"/>
+        /// <since_tizen> 10 </since_tizen>
+        public MediaNullSource() : base() {}
+
+        /// <summary>
+        /// Gets the transceiver codec for receiving media stream.
+        /// </summary>
+        /// <param name="type">The media type.</param>
+        /// <returns>The transceiver codec.</returns>
+        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <seealso cref="SetTransceiverCodec"/>
+        /// <since_tizen> 10 </since_tizen>
+        public TransceiverCodec GetTransceiverCodec(MediaType type)
+        {
+            if (!SourceId.HasValue)
+            {
+                throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+            }
+
+            NativeWebRTC.GetTransceiverCodec(WebRtc.Handle, SourceId.Value, type, out TransceiverCodec codec).
+                ThrowIfFailed("Failed to get transceiver codec");
+
+            return codec;
+        }
+
+        /// <summary>
+        /// Sets the transceiver codec for receiving media stream.
+        /// </summary>
+        /// <remarks>
+        /// The WebRTC must be in the <see cref="WebRTCState.Idle"/> state when transceiver codec is set.<br/>
+        ///
+        /// </remarks>
+        /// <param name="type">The media type.</param>
+        /// <param name="codec">The transceiver codec.</param>
+        /// <exception cref="InvalidOperationException">
+        ///     MediaSource is not attached yet.<br/>
+        /// -or-<br/>
+        ///     The WebRTC is not in the valid state.
+        /// </exception>
+        /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <seealso cref="GetTransceiverCodec"/>
+        /// <since_tizen> 10 </since_tizen>
+        public void SetTransceiverCodec(MediaType type, TransceiverCodec codec)
+        {
+            if (!SourceId.HasValue)
+            {
+                throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+            }
+
+            WebRtc.ValidateWebRTCState(WebRTCState.Idle);
+
+            NativeWebRTC.SetTransceiverCodec(WebRtc.Handle, SourceId.Value, type, codec).
+                ThrowIfFailed("Failed to set transceiver codec");
+        }
+
+        /// <summary>
+        /// Retrieves the supported transceiver codecs.
+        /// </summary>
+        /// <param name="type">The media type.</param>
+        /// <returns>The supported transceiver codecs.</returns>
+        /// <exception cref="InvalidOperationException">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 ReadOnlyCollection<TransceiverCodec> GetSupportedTransceiverCodecs(MediaType type)
+        {
+            return new ReadOnlyCollection<TransceiverCodec>(ForeachSupportedTransceiverCodecs(type));
+        }
+
+        internal override void OnAttached(WebRTC webRtc)
+        {
+            Debug.Assert(webRtc != null);
+
+            if (WebRtc != null)
+            {
+                throw new InvalidOperationException("The source is has already been assigned to another WebRTC.");
+            }
+
+            NativeWebRTC.AddMediaSource(webRtc.Handle, MediaSourceType.Null, out uint sourceId).
+                ThrowIfFailed("Failed to add MediaNullSource.");
+
+            WebRtc = webRtc;
+            SourceId = sourceId;
+            TransceiverDirection = TransceiverDirection.RecvOnly;
+        }
+
+        internal override void OnDetached(WebRTC webRtc)
+        {
+            NativeWebRTC.RemoveMediaSource(webRtc.Handle, SourceId.Value).
+                ThrowIfFailed("Failed to remove MediaNullSource.");
+
+            WebRtc = null;
+        }
+    }
+}
index 0f54275..6ead6c7 100755 (executable)
@@ -283,5 +283,7 @@ namespace Tizen.Multimedia.Remoting
 
             WebRtc = null;
         }
+
+        internal override MediaSourceType MediaSourceType => MediaSourceType.MediaPacket;
     }
 }
index 41d23fe..f9af677 100755 (executable)
@@ -57,5 +57,7 @@ namespace Tizen.Multimedia.Remoting
 
             WebRtc = null;
         }
+
+        internal override MediaSourceType MediaSourceType => MediaSourceType.Screen;
     }
 }
index d843633..df3af92 100755 (executable)
@@ -50,6 +50,12 @@ namespace Tizen.Multimedia.Remoting
             MediaType = mediaType;
         }
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MediaSource"/> class.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        protected MediaSource() { }
+
         internal void AttachTo(WebRTC webRtc)
         {
             if (IsDetached)
@@ -70,12 +76,25 @@ namespace Tizen.Multimedia.Remoting
 
         internal abstract void OnDetached(WebRTC webRtc);
 
+        internal virtual MediaSourceType MediaSourceType => MediaSourceType.Null;
+
         /// <summary>
         /// Gets or sets the transceiver direction of current media source.
         /// </summary>
+        /// <remarks>
+        /// If user want to set each audio, video direction in <see cref="MediaFileSource"/>,
+        /// please use <see cref="MediaFileSource.SetTransceiverDirection"/>. (Since API level 10)<br/>
+        /// In <see cref="MediaNullSource"/>, only <see cref="TransceiverDirection.SendRecv"/> can be set.(Since API level 10)
+        /// </remarks>
         /// <value>A <see cref="TransceiverDirection"/> that specifies the transceiver direction.</value>
-        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     MediaSource is not attached yet.<br/>
+        /// -or-<br/>
+        ///     <see cref="TransceiverDirection.SendOnly"/> or <see cref="TransceiverDirection.SendRecv"/> is set for MediaNullSource. (Since API level 10)
+        /// </exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <seealso cref="MediaFileSource.GetTransceiverDirection"/>
+        /// <seealso cref="MediaFileSource.SetTransceiverDirection"/>
         /// <since_tizen> 9 </since_tizen>
         public TransceiverDirection TransceiverDirection
         {
@@ -85,6 +104,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
+                if (this is MediaNullSource)
+                {
+                    return TransceiverDirection.RecvOnly;
+                }
 
                 NativeWebRTC.GetTransceiverDirection(WebRtc.Handle, SourceId.Value, MediaType, out TransceiverDirection mode).
                     ThrowIfFailed("Failed to get transceiver direction.");
@@ -97,9 +120,28 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
+                if (this is MediaNullSource)
+                {
+                    if (value != TransceiverDirection.RecvOnly)
+                    {
+                        throw new InvalidOperationException("Only RecvOnly is allowed for MediaNullSource.");
+                    }
 
-                NativeWebRTC.SetTransceiverDirection(WebRtc.Handle, SourceId.Value, MediaType, value).
-                    ThrowIfFailed("Failed to get transceiver direction.");
+                    return;
+                }
+
+                if (this is MediaNullSource || this is MediaFileSource)
+                {
+                    NativeWebRTC.SetTransceiverDirection(WebRtc.Handle, SourceId.Value, MediaType.Audio, value).
+                        ThrowIfFailed("Failed to set audio transceiver direction.");
+                    NativeWebRTC.SetTransceiverDirection(WebRtc.Handle, SourceId.Value, MediaType.Video, value).
+                        ThrowIfFailed("Failed to set video transceiver direction.");
+                }
+                else
+                {
+                    NativeWebRTC.SetTransceiverDirection(WebRtc.Handle, SourceId.Value, MediaType, value).
+                        ThrowIfFailed("Failed to set transceiver direction.");
+                }
             }
         }
 
@@ -108,6 +150,8 @@ namespace Tizen.Multimedia.Remoting
         /// </summary>
         /// <remarks>
         /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>.<br/>
+        /// If <see cref="MediaNullSource"/>, please use <see cref="MediaNullSource.GetTransceiverCodec"/>
+        /// or <see cref="MediaNullSource.SetTransceiverCodec"/> instead.<br/>
         /// The WebRTC must be in the <see cref="WebRTCState.Idle"/> state when transceiver codec is set.
         /// </remarks>
         /// <value>The transceiver codec.</value>
@@ -119,6 +163,8 @@ namespace Tizen.Multimedia.Remoting
         /// The WebRTC is not in the valid state.
         /// </exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <seealso cref="MediaNullSource.GetTransceiverCodec"/>
+        /// <seealso cref="MediaNullSource.SetTransceiverCodec"/>
         /// <since_tizen> 10 </since_tizen>
         public TransceiverCodec TransceiverCodec
         {
@@ -128,7 +174,7 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
-                if (this is MediaFileSource || this is MediaPacketSource)
+                if (this is MediaFileSource || this is MediaPacketSource || this is MediaNullSource)
                 {
                     throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
                 }
@@ -144,7 +190,7 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
-                if (this is MediaFileSource || this is MediaPacketSource)
+                if (this is MediaFileSource || this is MediaPacketSource || this is MediaNullSource)
                 {
                     throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
                 }
@@ -160,11 +206,14 @@ namespace Tizen.Multimedia.Remoting
         /// Retrieves the supported transceiver codecs.
         /// </summary>
         /// <remarks>
-        /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>.
+        /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>.<br/>
+        /// If user want to get supported codecs for each audio or video in <see cref="MediaNullSource"/>,
+        /// please use <see cref="MediaNullSource.GetSupportedTransceiverCodecs"/> instead.
         /// </remarks>
         /// <returns>The transceiver codecs.</returns>
         /// <exception cref="InvalidOperationException">This MediaSource is not supported type of MediaSource.</exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <seealso cref="MediaNullSource.GetSupportedTransceiverCodecs"/>
         /// <since_tizen> 10 </since_tizen>
         public ReadOnlyCollection<TransceiverCodec> SupportedTransceiverCodecs
         {
@@ -174,83 +223,73 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
                 }
-
-                var codecs = new List<TransceiverCodec>();
-                Exception caught = null;
-
-                NativeWebRTC.RetrieveTransceiverCodecCallback cb = (codec, _) =>
-                {
-                    try
-                    {
-                        codecs.Add(codec);
-                    }
-                    catch (Exception e)
-                    {
-                        caught = e;
-                        return false;
-                    }
-
-                    return true;
-                };
-
-                using (var cbKeeper = ObjectKeeper.Get(cb))
+                if (this is MediaNullSource)
                 {
-                    NativeWebRTC.ForeachSupportedTransceiverCodec(WebRtc.Handle, GetMediaSourceType(), MediaType, cb).
-                        ThrowIfFailed("failed to retrieve stats");
+                    var codecs = ForeachSupportedTransceiverCodecs(MediaType.Audio);
+                    codecs.AddRange(ForeachSupportedTransceiverCodecs(MediaType.Video));
 
-                    if (caught != null)
-                    {
-                        throw caught;
-                    }
+                    return new ReadOnlyCollection<TransceiverCodec>(codecs);
                 }
 
-                return new ReadOnlyCollection<TransceiverCodec>(codecs);
+                return new ReadOnlyCollection<TransceiverCodec>(ForeachSupportedTransceiverCodecs(MediaType));
             }
         }
 
-        private MediaSourceType GetMediaSourceType()
+        internal List<TransceiverCodec> ForeachSupportedTransceiverCodecs(MediaType type)
         {
-            if (this is MediaTestSource)
+            var codecs = new List<TransceiverCodec>();
+            Exception caught = null;
+
+            NativeWebRTC.RetrieveTransceiverCodecCallback cb = (codec, _) =>
             {
-                if (MediaType == MediaType.Audio)
+                try
                 {
-                    return MediaSourceType.AudioTest;
+                    codecs.Add(codec);
                 }
-                else
+                catch (Exception e)
                 {
-                    return MediaSourceType.VideoTest;
+                    caught = e;
+                    return false;
                 }
-            }
-            else if (this is MediaMicrophoneSource)
-            {
-                return MediaSourceType.Microphone;
-            }
-            else if (this is MediaCameraSource)
-            {
-                return MediaSourceType.Camera;
-            }
-            else if (this is MediaScreenSource)
-            {
-                return MediaSourceType.Screen;
-            }
-            else if (this is MediaFileSource)
-            {
-                return MediaSourceType.File;
-            }
-            else if (this is MediaPacketSource)
+
+                return true;
+            };
+
+            using (var cbKeeper = ObjectKeeper.Get(cb))
             {
-                return MediaSourceType.MediaPacket;
+                try
+                {
+                    NativeWebRTC.ForeachSupportedTransceiverCodec(WebRtc.Handle, MediaSourceType.Null, type, cb).
+                        ThrowIfFailed("failed to retrieve stats");
+                }
+                catch
+                {
+                    Log.Info(WebRTCLog.Tag, "This is not error in csharp.");
+                }
+
+                if (caught != null)
+                {
+                    throw caught;
+                }
             }
 
-            return MediaSourceType.Null;
+            return codecs;
         }
 
         /// <summary>
         /// Gets or sets the pause status of current media source.
         /// </summary>
+        /// If <see cref="MediaFileSource"/>, please use <see cref="MediaFileSource.GetPause"/>
+        /// or <see cref="MediaFileSource.SetPause"/> instead.<br/> (Since API level 10)
         /// <value>A value that specifies the pause status.</value>
-        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     MediaSource is not attached yet.<br/>
+        /// -or-<br/>
+        ///     This MediaSource is not supported type of MediaSource. (Since API level 10)
+        /// </exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+        /// <seealso cref="MediaFileSource.GetPause"/>
+        /// <seealso cref="MediaFileSource.SetPause"/>
         /// <since_tizen> 9 </since_tizen>
         public bool Pause
         {
@@ -260,6 +299,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
+                if (this is MediaFileSource || this is MediaNullSource)
+                {
+                    throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+                }
 
                 NativeWebRTC.GetPause(WebRtc.Handle, SourceId.Value, MediaType, out bool isPaused).
                     ThrowIfFailed("Failed to get pause");
@@ -272,6 +315,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
+                if (this is MediaFileSource || this is MediaNullSource)
+                {
+                    throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+                }
 
                 NativeWebRTC.SetPause(WebRtc.Handle, SourceId.Value, MediaType, value).
                     ThrowIfFailed("Failed to set pause");
@@ -281,8 +328,15 @@ namespace Tizen.Multimedia.Remoting
         /// <summary>
         /// Gets or sets the mute status of the current media source.
         /// </summary>
+        /// <remarks>
+        /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>, <see cref="MediaNullSource"/>. (Since API level 10)
+        /// </remarks>
         /// <value>A value that specifies the mute status.</value>
-        /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+        /// <exception cref="InvalidOperationException">
+        ///     MediaSource is not attached yet.<br/>
+        /// -or-<br/>
+        ///     This MediaSource is not supported type of MediaSource. (Since API level 10)
+        /// </exception>
         /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
         /// <since_tizen> 9 </since_tizen>
         public bool Mute
@@ -293,6 +347,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
+                if (this is MediaFileSource || this is MediaPacketSource || this is MediaNullSource)
+                {
+                    throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+                }
 
                 NativeWebRTC.GetMute(WebRtc.Handle, SourceId.Value, MediaType, out bool isMuted).
                     ThrowIfFailed("Failed to get mute");
@@ -305,6 +363,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
                 }
+                if (this is MediaFileSource || this is MediaPacketSource || this is MediaNullSource)
+                {
+                    throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+                }
 
                 NativeWebRTC.SetMute(WebRtc.Handle, SourceId.Value, MediaType, value).
                     ThrowIfFailed("Failed to set mute");
@@ -319,6 +381,8 @@ namespace Tizen.Multimedia.Remoting
         ///     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> 9 </since_tizen>
@@ -334,6 +398,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     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.GetVideoResolution(WebRtc.Handle, SourceId.Value, out int width, out int height).
                     ThrowIfFailed("Failed to get video resolution");
@@ -350,6 +418,10 @@ namespace Tizen.Multimedia.Remoting
                 {
                     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.SetVideoResolution(WebRtc.Handle, SourceId.Value, value.Width, value.Height).
                     ThrowIfFailed("Failed to set video resolution");
@@ -424,7 +496,7 @@ namespace Tizen.Multimedia.Remoting
         /// Gets or sets the encoder bitrate of the current media source.
         /// </summary>
         /// <remarks>
-        /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>.<br/>
+        /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>.
         /// </remarks>
         /// <value>A value that specifies the encoder bitrate.</value>
         /// <exception cref="ArgumentException">EncoderBitrate is less than or equal to zero.</exception>
index 84f38bd..d3226b8 100755 (executable)
@@ -28,6 +28,8 @@ namespace Tizen.Multimedia.Remoting
     /// <since_tizen> 9 </since_tizen>
     public sealed class MediaTestSource : MediaSource
     {
+        private MediaSourceType _mediaSourceType;
+
         /// <summary>
         /// Initializes a new instance of the <see cref="MediaTestSource"/> class.
         /// </summary>
@@ -42,9 +44,9 @@ namespace Tizen.Multimedia.Remoting
                 throw new InvalidOperationException("The source is has already been assigned to another WebRTC.");
             }
 
-            var type = MediaType == MediaType.Video ? MediaSourceType.VideoTest : MediaSourceType.AudioTest;
+            _mediaSourceType = MediaType == MediaType.Video ? MediaSourceType.VideoTest : MediaSourceType.AudioTest;
 
-            NativeWebRTC.AddMediaSource(webRtc.Handle, type, out uint sourceId).
+            NativeWebRTC.AddMediaSource(webRtc.Handle, _mediaSourceType, out uint sourceId).
                 ThrowIfFailed($"Failed to add {MediaType.ToString()} MediaTestSource.");
 
             WebRtc = webRtc;
@@ -58,5 +60,7 @@ namespace Tizen.Multimedia.Remoting
 
             WebRtc = null;
         }
+
+        internal override MediaSourceType MediaSourceType => _mediaSourceType;
     }
 }