2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Diagnostics;
20 using NativeWebRTC = Interop.NativeWebRTC;
22 namespace Tizen.Multimedia.Remoting
25 /// Provides the ability to control WebRTC.
27 /// <since_tizen> 9 </since_tizen>
28 public partial class WebRTC
30 internal IntPtr Handle
34 ValidateNotDisposed();
35 return _handle.DangerousGetHandle();
40 /// Gets the state of the WebRTC.
42 /// <value>The current state of the WebRTC.</value>
43 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
44 /// <since_tizen> 9 </since_tizen>
45 public WebRTCState State
49 ValidateNotDisposed();
51 NativeWebRTC.GetState(Handle, out WebRTCState state).
52 ThrowIfFailed("Failed to retrieve the state of the WebRTC");
54 Debug.Assert(Enum.IsDefined(typeof(WebRTCState), state));
61 /// Gets the Ice gathering state of the WebRTC.
63 /// <value>The current Ice gathering state of the WebRTC.</value>
64 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
65 /// <since_tizen> 9 </since_tizen>
66 public WebRTCIceGatheringState IceGatheringState
70 ValidateNotDisposed();
72 NativeWebRTC.GetIceGatheringState(Handle, out WebRTCIceGatheringState state).
73 ThrowIfFailed("Failed to retrieve the state of the WebRTC");
75 Debug.Assert(Enum.IsDefined(typeof(WebRTCIceGatheringState), state));
82 /// Gets the signaling state of the WebRTC.
84 /// <value>The current signaling state of the WebRTC.</value>
85 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
86 /// <since_tizen> 9 </since_tizen>
87 public WebRTCSignalingState SignalingState
91 ValidateNotDisposed();
93 NativeWebRTC.GetSignalingState(Handle, out WebRTCSignalingState state).
94 ThrowIfFailed("Failed to retrieve the state of the WebRTC");
96 Debug.Assert(Enum.IsDefined(typeof(WebRTCSignalingState), state));
103 /// Gets the peer connection state of the WebRTC.
105 /// <value>The current peer connection state of the WebRTC.</value>
106 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
107 /// <since_tizen> 9 </since_tizen>
108 public WebRTCPeerConnectionState PeerConnectionState
112 ValidateNotDisposed();
114 NativeWebRTC.GetPeerConnectionState(Handle, out WebRTCPeerConnectionState state).
115 ThrowIfFailed("Failed to retrieve the state of the WebRTC");
117 Debug.Assert(Enum.IsDefined(typeof(WebRTCPeerConnectionState), state));
124 /// Gets the ICE connection state of the WebRTC.
126 /// <value>The current ICE connection state of the WebRTC.</value>
127 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
128 /// <since_tizen> 9 </since_tizen>
129 public WebRTCIceConnectionState IceConnectionState
133 ValidateNotDisposed();
135 NativeWebRTC.GetIceConnectionState(Handle, out WebRTCIceConnectionState state).
136 ThrowIfFailed("Failed to retrieve the state of the WebRTC");
138 Debug.Assert(Enum.IsDefined(typeof(WebRTCIceConnectionState), state));
145 /// Gets or sets the STUN server url.
147 /// <value>The STUN server url</value>
148 /// <exception cref="ArgumentNullException">STUN server URI is null.</exception>
149 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
150 /// <since_tizen> 9 </since_tizen>
151 public string StunServer
155 ValidateNotDisposed();
157 NativeWebRTC.GetStunServer(Handle, out string server).
158 ThrowIfFailed("Failed to get stun server name");
164 ValidateNotDisposed();
168 throw new ArgumentNullException(nameof(value), "Stun server name is null.");
171 NativeWebRTC.SetStunServer(Handle, value).
172 ThrowIfFailed("Failed to set stun server name");
177 /// Gets or sets the ICE transport policy.
179 /// <value>The policy of ICE transport</value>
180 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
181 /// <since_tizen> 9 </since_tizen>
182 public IceTransportPolicy IceTransportPolicy
186 ValidateNotDisposed();
188 NativeWebRTC.GetIceTransportPolicy(Handle, out IceTransportPolicy policy).
189 ThrowIfFailed("Failed to get ICE transport policy");
195 ValidateNotDisposed();
197 NativeWebRTC.SetIceTransportPolicy(Handle, value).
198 ThrowIfFailed("Failed to set ICE transport policy");
203 /// Gets or sets the bundle policy.<br/>
204 /// The default bundle policy is <see cref="WebRTCBundlePolicy.MaxBundle"/>.
206 /// <value>The policy of bundle</value>
207 /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
208 /// <since_tizen> 10 </since_tizen>
209 public WebRTCBundlePolicy BundlePolicy
213 ValidateNotDisposed();
215 NativeWebRTC.GetBundlePolicy(Handle, out WebRTCBundlePolicy bundlePolicy).
216 ThrowIfFailed("Failed to get bundle policy");
222 ValidateNotDisposed();
224 NativeWebRTC.SetBundlePolicy(Handle, value).
225 ThrowIfFailed("Failed to set bundle policy");