From 06f8a520481d92c13ded928b8f553c6dc31ae230 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Wed, 2 Aug 2023 15:28:07 +0900 Subject: [PATCH] [WebRTC] Add Mute API for audio track --- .../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 d6301cf0842..9b6e81607d0 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 extern WebRTCErrorCode ForeachSupportedTransceiverCodec(IntPtr h [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 af49ca2fcfc..3862f679cc6 100755 --- a/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs +++ b/src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs @@ -79,7 +79,7 @@ public Display Display { 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 @@ public WebRTCDisplayMode DisplayMode { 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 @@ public WebRTCDisplayMode DisplayMode { 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 @@ public bool DisplayVisible { 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 @@ public bool DisplayVisible { 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). @@ -189,6 +189,39 @@ public bool DisplayVisible } } + /// + /// 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. /// @@ -228,7 +261,7 @@ public void ApplyAudioStreamPolicy(AudioStreamPolicy policy) 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);