[Multimedia] Deprecate constructors related to ElmSharp (#4540)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Remoting / WebRTC / WebRTC.Properties.cs
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Diagnostics;
19 using static Interop;
20 using NativeWebRTC = Interop.NativeWebRTC;
21
22 namespace Tizen.Multimedia.Remoting
23 {
24     /// <summary>
25     /// Provides the ability to control WebRTC.
26     /// </summary>
27     /// <since_tizen> 9 </since_tizen>
28     public partial class WebRTC
29     {
30         internal IntPtr Handle
31         {
32             get
33             {
34                 ValidateNotDisposed();
35                 return _handle.DangerousGetHandle();
36             }
37         }
38
39         /// <summary>
40         /// Gets the state of the WebRTC.
41         /// </summary>
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
46         {
47             get
48             {
49                 ValidateNotDisposed();
50
51                 NativeWebRTC.GetState(Handle, out WebRTCState state).
52                     ThrowIfFailed("Failed to retrieve the state of the WebRTC");
53
54                 Debug.Assert(Enum.IsDefined(typeof(WebRTCState), state));
55
56                 return state;
57             }
58         }
59
60         /// <summary>
61         /// Gets the Ice gathering state of the WebRTC.
62         /// </summary>
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
67         {
68             get
69             {
70                 ValidateNotDisposed();
71
72                 NativeWebRTC.GetIceGatheringState(Handle, out WebRTCIceGatheringState state).
73                     ThrowIfFailed("Failed to retrieve the state of the WebRTC");
74
75                 Debug.Assert(Enum.IsDefined(typeof(WebRTCIceGatheringState), state));
76
77                 return state;
78             }
79         }
80
81         /// <summary>
82         /// Gets the signaling state of the WebRTC.
83         /// </summary>
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
88         {
89             get
90             {
91                 ValidateNotDisposed();
92
93                 NativeWebRTC.GetSignalingState(Handle, out WebRTCSignalingState state).
94                     ThrowIfFailed("Failed to retrieve the state of the WebRTC");
95
96                 Debug.Assert(Enum.IsDefined(typeof(WebRTCSignalingState), state));
97
98                 return state;
99             }
100         }
101
102         /// <summary>
103         /// Gets the peer connection state of the WebRTC.
104         /// </summary>
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
109         {
110             get
111             {
112                 ValidateNotDisposed();
113
114                 NativeWebRTC.GetPeerConnectionState(Handle, out WebRTCPeerConnectionState state).
115                     ThrowIfFailed("Failed to retrieve the state of the WebRTC");
116
117                 Debug.Assert(Enum.IsDefined(typeof(WebRTCPeerConnectionState), state));
118
119                 return state;
120             }
121         }
122
123         /// <summary>
124         /// Gets the ICE connection state of the WebRTC.
125         /// </summary>
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
130         {
131             get
132             {
133                 ValidateNotDisposed();
134
135                 NativeWebRTC.GetIceConnectionState(Handle, out WebRTCIceConnectionState state).
136                     ThrowIfFailed("Failed to retrieve the state of the WebRTC");
137
138                 Debug.Assert(Enum.IsDefined(typeof(WebRTCIceConnectionState), state));
139
140                 return state;
141             }
142         }
143
144         /// <summary>
145         /// Gets or sets the STUN server url.
146         /// </summary>
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
152         {
153             get
154             {
155                 ValidateNotDisposed();
156
157                 NativeWebRTC.GetStunServer(Handle, out string server).
158                     ThrowIfFailed("Failed to get stun server name");
159
160                 return server;
161             }
162             set
163             {
164                 ValidateNotDisposed();
165
166                 if (value == null)
167                 {
168                     throw new ArgumentNullException(nameof(value), "Stun server name is null.");
169                 }
170
171                 NativeWebRTC.SetStunServer(Handle, value).
172                     ThrowIfFailed("Failed to set stun server name");
173             }
174         }
175
176         /// <summary>
177         /// Gets or sets the ICE transport policy.
178         /// </summary>
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
183         {
184             get
185             {
186                 ValidateNotDisposed();
187
188                 NativeWebRTC.GetIceTransportPolicy(Handle, out IceTransportPolicy policy).
189                     ThrowIfFailed("Failed to get ICE transport policy");
190
191                 return policy;
192             }
193             set
194             {
195                 ValidateNotDisposed();
196
197                 NativeWebRTC.SetIceTransportPolicy(Handle, value).
198                     ThrowIfFailed("Failed to set ICE transport policy");
199             }
200         }
201
202         /// <summary>
203         /// Gets or sets the bundle policy.<br/>
204         /// The default bundle policy is <see cref="WebRTCBundlePolicy.MaxBundle"/>.
205         /// </summary>
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
210         {
211             get
212             {
213                 ValidateNotDisposed();
214
215                 NativeWebRTC.GetBundlePolicy(Handle, out WebRTCBundlePolicy bundlePolicy).
216                     ThrowIfFailed("Failed to get bundle policy");
217
218                 return bundlePolicy;
219             }
220             set
221             {
222                 ValidateNotDisposed();
223
224                 NativeWebRTC.SetBundlePolicy(Handle, value).
225                     ThrowIfFailed("Failed to set bundle policy");
226             }
227         }
228     }
229 }