From bad2ff3c5921a76abd5b1155487a39070cfa9fad Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Fri, 4 Aug 2023 16:53:33 +0900 Subject: [PATCH] [WebRTC] Add Mute API for audio track (#5440) --- .../Interop/Interop.WebRTC.cs | 6 +++ .../WebRTC/MediaStreamTrack.cs | 45 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs b/src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs index d6301cf..9b6e816 100755 --- a/src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs +++ b/src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs @@ -199,6 +199,12 @@ internal static partial class Interop [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_sound_stream_info")] internal static extern WebRTCErrorCode SetAudioStreamPolicy(IntPtr handle, uint trackId, AudioStreamPolicyHandle streamInfo); + [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_audio_mute")] + internal static extern WebRTCErrorCode SetAudioMute(IntPtr handle, uint trackId, bool mute); + + [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_get_audio_mute")] + internal static extern WebRTCErrorCode GetAudioMute(IntPtr handle, uint trackId, out bool isMuted); + [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_display")] internal static extern WebRTCErrorCode SetDisplay(IntPtr handle, uint trackId, WebRTCDisplayType type, IntPtr display); diff --git a/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs b/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs index af49ca2..3862f67 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs @@ -79,7 +79,7 @@ namespace Tizen.Multimedia.Remoting { if (Type != MediaType.Video) { - throw new InvalidOperationException("This property is only for video."); + throw new InvalidOperationException("This property is only for video track."); } if (value == null) @@ -132,7 +132,7 @@ namespace Tizen.Multimedia.Remoting { if (Type != MediaType.Video) { - throw new InvalidOperationException("This property is only for video."); + throw new InvalidOperationException("This property is only for video track."); } NativeWebRTC.GetDisplayMode(_webRtc.Handle, _trackId, out var val). @@ -144,7 +144,7 @@ namespace Tizen.Multimedia.Remoting { if (Type != MediaType.Video) { - throw new InvalidOperationException("This property is only for video."); + throw new InvalidOperationException("This property is only for video track."); } ValidationUtil.ValidateEnum(typeof(WebRTCDisplayMode), value, nameof(value)); @@ -169,7 +169,7 @@ namespace Tizen.Multimedia.Remoting { if (Type != MediaType.Video) { - throw new InvalidOperationException("This property is only for video."); + throw new InvalidOperationException("This property is only for video track."); } NativeWebRTC.GetDisplayVisible(_webRtc.Handle, _trackId, out bool val). @@ -181,7 +181,7 @@ namespace Tizen.Multimedia.Remoting { if (Type != MediaType.Video) { - throw new InvalidOperationException("This property is only for video."); + throw new InvalidOperationException("This property is only for video track."); } NativeWebRTC.SetDisplayVisible(_webRtc.Handle, _trackId, value). @@ -190,6 +190,39 @@ namespace Tizen.Multimedia.Remoting } /// + /// Gets or sets the mute status of the audio track. + /// + /// true if audio is muted, otherwise false. The default value is false. + /// The WebRTC has already been disposed. + /// This MediaStreamTrack is not Audio. + /// 11 + public bool Mute + { + get + { + if (Type != MediaType.Audio) + { + throw new InvalidOperationException("This property is only for audio track."); + } + + NativeWebRTC.GetAudioMute(_webRtc.Handle, _trackId, out bool val). + ThrowIfFailed("Failed to get audio mute status"); + + return val; + } + set + { + if (Type != MediaType.Audio) + { + throw new InvalidOperationException("This property is only for audio track."); + } + + NativeWebRTC.SetAudioMute(_webRtc.Handle, _trackId, value). + ThrowIfFailed("Failed to set audio mute status."); + } + } + + /// /// Applies the audio stream policy to remote track. /// /// The to apply. @@ -228,7 +261,7 @@ namespace Tizen.Multimedia.Remoting if (Type != MediaType.Audio) { - throw new InvalidOperationException("Should be applied in Audio"); + throw new InvalidOperationException("This method is only for audio track."); } var ret = NativeWebRTC.SetAudioStreamPolicy(_webRtc.Handle, _trackId, policy.Handle); -- 2.7.4