[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_transceiver_codec")]
internal static extern WebRTCErrorCode GetTransceiverCodec(IntPtr handle, uint sourceId, MediaType type, out TransceiverCodec codec);
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_payload_type")]
+ internal static extern WebRTCErrorCode SetPaylodType(IntPtr handle, uint sourceId, TransceiverCodec codec, uint payloadType);
+
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_payload_type")]
+ internal static extern WebRTCErrorCode GetPaylodType(IntPtr handle, uint sourceId, TransceiverCodec codec, out uint payloadType);
+
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_pause")]
internal static extern WebRTCErrorCode SetPause(IntPtr handle, uint sourceId, MediaType type, bool pause);
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_local_description")]
internal static extern WebRTCErrorCode SetLocalDescription(IntPtr handle, string description);
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_get_local_description")]
+ internal static extern WebRTCErrorCode GetLocalDescription(IntPtr handle, out IntPtr description);
+
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_remote_description")]
internal static extern WebRTCErrorCode SetRemoteDescription(IntPtr handle, string description);
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_get_remote_description")]
+ internal static extern WebRTCErrorCode GetRemoteDescription(IntPtr handle, out IntPtr description);
+
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_add_ice_candidate")]
internal static extern WebRTCErrorCode AddIceCandidate(IntPtr handle, string candidate);
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_foreach_stats")]
internal static extern WebRTCErrorCode ForeachStats(IntPtr handle, int typeMask, RetrieveStatsCallback callback, IntPtr userData = default);
-
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_set_error_cb")]
internal static extern WebRTCErrorCode SetErrorOccurredCb(IntPtr handle, ErrorOccurredCallback callback, IntPtr userData = default);
}
}
+ /// <summary>
+ /// Sets the RTP payload type of given <paramref name="codec"/>.
+ /// </summary>
+ /// <remarks>
+ /// <paramref name="payloadType"/> should be greater than or equal to 96 and less than or equal to 127.
+ /// </remarks>
+ /// <param name="codec">The transceiver codec.</param>
+ /// <param name="payloadType">The RTP payload type.</param>
+ /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+ /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="payloadType"/> is less than 96 or greater than 127.
+ /// </exception>
+ /// <seealso cref="SupportedTransceiverCodecs"/>
+ /// <since_tizen> 12 </since_tizen>
+ public void SetPayloadType(TransceiverCodec codec, uint payloadType)
+ {
+ if (!SourceId.HasValue)
+ {
+ throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+ }
+ if (payloadType < 96 || payloadType > 127)
+ {
+ throw new ArgumentOutOfRangeException(nameof(payloadType), payloadType, "Valid range : 96 <= payloadType <= 127");
+ }
+
+ NativeWebRTC.SetPaylodType(WebRtc.Handle, SourceId.Value, codec, payloadType).
+ ThrowIfFailed("Failed to set payload type");
+ }
+
+ /// <summary>
+ /// Gets the RTP payload type of given <paramref name="codec"/>.
+ /// </summary>
+ /// <param name="codec">The transceiver codec.</param>
+ /// <returns>The RTP payload type.</returns>
+ /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+ /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+ /// <seealso cref="SupportedTransceiverCodecs"/>
+ /// <since_tizen> 12 </since_tizen>
+ public uint GetPayloadType(TransceiverCodec codec)
+ {
+ if (!SourceId.HasValue)
+ {
+ throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+ }
+
+ NativeWebRTC.GetPaylodType(WebRtc.Handle, SourceId.Value, codec, out uint payloadType).
+ ThrowIfFailed("Failed to get payload type");
+
+ return payloadType;
+ }
+
/// <summary>
/// Enables the audio loopback. The local audio will be played with <paramref name="policy"/>.
/// </summary>
/// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
/// <seealso cref="CreateOfferAsync()"/>
/// <seealso cref="CreateAnswerAsync()"/>
+ /// <seealso cref="GetLocalDescription()"/>
/// <since_tizen> 9 </since_tizen>
public void SetLocalDescription(string description)
{
ValidationUtil.ValidateIsNullOrEmpty(description, nameof(description));
- NativeWebRTC.SetLocalDescription(Handle, description).ThrowIfFailed("Failed to set description.");
+ NativeWebRTC.SetLocalDescription(Handle, description).ThrowIfFailed("Failed to set local description.");
+ }
+
+ /// <summary>
+ /// Gets the session description for a local peer.
+ /// </summary>
+ /// <returns>The local session description string</returns>
+ /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+ /// <seealso cref="SetLocalDescription()"/>
+ /// <since_tizen> 12 </since_tizen>
+ public string GetLocalDescription()
+ {
+ ValidateNotDisposed();
+
+ IntPtr description = IntPtr.Zero;
+ try
+ {
+ NativeWebRTC.GetLocalDescription(Handle, out description).ThrowIfFailed("Failed to get local description.");
+
+ return Marshal.PtrToStringAnsi(description);
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(description);
+ }
}
/// <summary>
/// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
/// <seealso cref="CreateOfferAsync()"/>
/// <seealso cref="CreateAnswerAsync()"/>
+ /// <seealso cref="GetRemoteDescription()"/>
/// <since_tizen> 9 </since_tizen>
public void SetRemoteDescription(string description)
{
ValidationUtil.ValidateIsNullOrEmpty(description, nameof(description));
- NativeWebRTC.SetRemoteDescription(Handle, description).ThrowIfFailed("Failed to set description.");
+ NativeWebRTC.SetRemoteDescription(Handle, description).ThrowIfFailed("Failed to set remote description.");
+ }
+
+ /// <summary>
+ /// Gets the session description of the remote peer's current offer or answer.
+ /// </summary>
+ /// <value>The remote session description string</value>
+ /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+ /// <seealso cref="SetRemoteDescription"/>
+ /// <since_tizen> 12 </since_tizen>
+ public string GetRemoteDescription()
+ {
+ ValidateNotDisposed();
+
+ IntPtr description = IntPtr.Zero;
+ try
+ {
+ NativeWebRTC.GetRemoteDescription(Handle, out description).ThrowIfFailed("Failed to get remote description.");
+
+ return Marshal.PtrToStringAnsi(description);
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(description);
+ }
}
/// <summary>