Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebRTC] Add Mute API for audio track #5440

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Tizen.Multimedia.Remoting/Interop/Interop.WebRTC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
45 changes: 39 additions & 6 deletions src/Tizen.Multimedia.Remoting/WebRTC/MediaStreamTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).
Expand All @@ -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));
Expand All @@ -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).
Expand All @@ -181,14 +181,47 @@ 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).
ThrowIfFailed("Failed to set display status.");
}
}

/// <summary>
/// Gets or sets the mute status of the audio track.
/// </summary>
/// <value>true if audio is muted, otherwise false. The default value is false.</value>
/// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
/// <exception cref="InvalidOperationException">This MediaStreamTrack is not Audio.</exception>
/// <since_tizen> 11 </since_tizen>
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.");
}
}

/// <summary>
/// Applies the audio stream policy to remote track.
/// </summary>
Expand Down Expand Up @@ -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);
Expand Down
Loading