[WebRTC] Add IsLooping API for MediaFileSource (#4261)
authorHaesu Gwon <haesu.gwon@samsung.com>
Thu, 9 Jun 2022 03:01:08 +0000 (12:01 +0900)
committerGitHub <noreply@github.com>
Thu, 9 Jun 2022 03:01:08 +0000 (12:01 +0900)
* [WebRTC] Add Looping API for MediaFileSource

src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs
src/Tizen.Multimedia.Remoting/WebRTC/MediaFileSource.cs

index 3fdc1ce..b4d9e9c 100755 (executable)
@@ -113,6 +113,12 @@ internal static partial class Interop
         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_file_source_set_path")]
         internal static extern WebRTCErrorCode SetFileSourcePath(IntPtr handle, uint sourceId, string path);
 
+        [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_file_source_set_looping")]
+        internal static extern WebRTCErrorCode SetFileSourceLooping(IntPtr handle, uint sourceId, bool looping);
+
+        [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_file_source_get_looping")]
+        internal static extern WebRTCErrorCode GetFileSourceLooping(IntPtr handle, uint sourceId, out bool looping);
+
         [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_transceiver_direction")]
         internal static extern WebRTCErrorCode GetTransceiverDirection(IntPtr handle, uint sourceId, MediaType type, out TransceiverDirection mode);
 
index 9698754..1c6ba9e 100755 (executable)
@@ -46,6 +46,42 @@ namespace Tizen.Multimedia.Remoting
             _path = path ?? throw new ArgumentNullException(nameof(path), "path is null");
         }
 
+        /// <summary>
+        /// Gets or sets the looping mode of the file source.
+        /// </summary>
+        /// <value>
+        /// true if the transfer starts again from the beginning of the file source after reaching the end of the file; otherwise, false\n
+        /// The default value is false.
+        /// </value>
+        /// <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 IsLooping
+        {
+            get
+            {
+                if (!SourceId.HasValue)
+                {
+                    return false;
+                }
+
+                NativeWebRTC.GetFileSourceLooping(WebRtc.Handle, SourceId.Value, out bool isLooping).
+                    ThrowIfFailed("Failed to get looping mode");
+
+                return isLooping;
+            }
+            set
+            {
+                if (!SourceId.HasValue)
+                {
+                    throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+                }
+
+                NativeWebRTC.SetFileSourceLooping(WebRtc.Handle, SourceId.Value, value).
+                    ThrowIfFailed("Failed to set looping mode");
+            }
+        }
+
         internal override void OnAttached(WebRTC webRtc)
         {
             Debug.Assert(webRtc != null);