/*
* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Diagnostics;
using static Interop;
using NativeWebRTC = Interop.NativeWebRTC;
namespace Tizen.Multimedia.Remoting
{
///
/// Provides the ability to control WebRTC.
///
/// 9
public partial class WebRTC
{
internal IntPtr Handle
{
get
{
ValidateNotDisposed();
return _handle.DangerousGetHandle();
}
}
///
/// Gets the state of the WebRTC.
///
/// The current state of the WebRTC.
/// The WebRTC has already been disposed.
/// 9
public WebRTCState State
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetState(Handle, out WebRTCState state).
ThrowIfFailed("Failed to retrieve the state of the WebRTC");
Debug.Assert(Enum.IsDefined(typeof(WebRTCState), state));
return state;
}
}
///
/// Gets the Ice gathering state of the WebRTC.
///
/// The current Ice gathering state of the WebRTC.
/// The WebRTC has already been disposed.
/// 9
public WebRTCIceGatheringState IceGatheringState
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetIceGatheringState(Handle, out WebRTCIceGatheringState state).
ThrowIfFailed("Failed to retrieve the state of the WebRTC");
Debug.Assert(Enum.IsDefined(typeof(WebRTCIceGatheringState), state));
return state;
}
}
///
/// Gets the signaling state of the WebRTC.
///
/// The current signaling state of the WebRTC.
/// The WebRTC has already been disposed.
/// 9
public WebRTCSignalingState SignalingState
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetSignalingState(Handle, out WebRTCSignalingState state).
ThrowIfFailed("Failed to retrieve the state of the WebRTC");
Debug.Assert(Enum.IsDefined(typeof(WebRTCSignalingState), state));
return state;
}
}
///
/// Gets the peer connection state of the WebRTC.
///
/// The current peer connection state of the WebRTC.
/// The WebRTC has already been disposed.
/// 9
public WebRTCPeerConnectionState PeerConnectionState
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetPeerConnectionState(Handle, out WebRTCPeerConnectionState state).
ThrowIfFailed("Failed to retrieve the state of the WebRTC");
Debug.Assert(Enum.IsDefined(typeof(WebRTCPeerConnectionState), state));
return state;
}
}
///
/// Gets the ICE connection state of the WebRTC.
///
/// The current ICE connection state of the WebRTC.
/// The WebRTC has already been disposed.
/// 9
public WebRTCIceConnectionState IceConnectionState
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetIceConnectionState(Handle, out WebRTCIceConnectionState state).
ThrowIfFailed("Failed to retrieve the state of the WebRTC");
Debug.Assert(Enum.IsDefined(typeof(WebRTCIceConnectionState), state));
return state;
}
}
///
/// Gets or sets the STUN server url.
///
/// The STUN server url
/// STUN server URI is null.
/// The WebRTC has already been disposed.
/// 9
public string StunServer
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetStunServer(Handle, out string server).
ThrowIfFailed("Failed to get stun server name");
return server;
}
set
{
ValidateNotDisposed();
if (value == null)
{
throw new ArgumentNullException(nameof(value), "Stun server name is null.");
}
NativeWebRTC.SetStunServer(Handle, value).
ThrowIfFailed("Failed to set stun server name");
}
}
///
/// Gets or sets the ICE transport policy.
///
/// The policy of ICE transport
/// The WebRTC has already been disposed.
/// 9
public IceTransportPolicy IceTransportPolicy
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetIceTransportPolicy(Handle, out IceTransportPolicy policy).
ThrowIfFailed("Failed to get ICE transport policy");
return policy;
}
set
{
ValidateNotDisposed();
NativeWebRTC.SetIceTransportPolicy(Handle, value).
ThrowIfFailed("Failed to set ICE transport policy");
}
}
///
/// Gets or sets the bundle policy.
/// The default bundle policy is .
///
/// The policy of bundle
/// The WebRTC has already been disposed.
/// 10
public WebRTCBundlePolicy BundlePolicy
{
get
{
ValidateNotDisposed();
NativeWebRTC.GetBundlePolicy(Handle, out WebRTCBundlePolicy bundlePolicy).
ThrowIfFailed("Failed to get bundle policy");
return bundlePolicy;
}
set
{
ValidateNotDisposed();
NativeWebRTC.SetBundlePolicy(Handle, value).
ThrowIfFailed("Failed to set bundle policy");
}
}
}
}