Class PeerConnection
High-level wrapper for Unity WebRTC functionalities. This is the API entry point for establishing a connection with a remote peer.
Namespace: Microsoft.MixedReality.WebRTC.Unity
Assembly: cs.temp.dll.dll
Syntax
public class PeerConnection : MonoBehaviour
Fields
AutoInitializeOnStart
Flag to initialize the peer connection on MonoBehaviour.Start().
Declaration
public bool AutoInitializeOnStart
Field Value
Type | Description |
---|---|
Boolean |
AutoLogErrorsToUnityConsole
Flag to log all errors to the Unity console automatically.
Declaration
public bool AutoLogErrorsToUnityConsole
Field Value
Type | Description |
---|---|
Boolean |
IceCredential
Optional credential for the ICE servers.
Declaration
public string IceCredential
Field Value
Type | Description |
---|---|
String |
IceServers
Set of ICE servers the WebRTC library will use to try to establish a connection.
Declaration
public List<ConfigurableIceServer> IceServers
Field Value
Type | Description |
---|---|
List<ConfigurableIceServer> |
IceUsername
Optional username for the ICE servers.
Declaration
public string IceUsername
Field Value
Type | Description |
---|---|
String |
OnError
Event that occurs when a WebRTC error occurs
Declaration
public WebRTCErrorEvent OnError
Field Value
Type | Description |
---|---|
WebRTCErrorEvent |
OnInitialized
Event fired after the peer connection is initialized and ready for use.
Declaration
public UnityEvent OnInitialized
Field Value
Type | Description |
---|---|
UnityEvent |
OnShutdown
Event fired after the peer connection is shut down and cannot be used anymore.
Declaration
public UnityEvent OnShutdown
Field Value
Type | Description |
---|---|
UnityEvent |
Signaler
Signaler to use to establish the connection.
Declaration
public Signaler Signaler
Field Value
Type | Description |
---|---|
Signaler |
Properties
Peer
Retrieves the underlying peer connection object once initialized.
Declaration
public PeerConnection Peer { get; }
Property Value
Type | Description |
---|---|
PeerConnection |
Remarks
If OnInitialized has not fired, this will be null
.
Methods
GetVideoCaptureDevicesAsync()
Enumerate the video capture devices available as a WebRTC local video feed source.
Declaration
public static Task<List<VideoCaptureDevice>> GetVideoCaptureDevicesAsync()
Returns
Type | Description |
---|---|
Task<List<VideoCaptureDevice>> | The list of local video capture devices available to WebRTC. |
InitializeAsync(CancellationToken)
Initialize the underlying WebRTC libraries
Declaration
public Task InitializeAsync(CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token |
Returns
Type | Description |
---|---|
Task |
Remarks
This function is asynchronous, to monitor it's status bind a handler to OnInitialized and OnError
Uninitialize()
Uninitialize the underlying WebRTC library, effectively cleaning up the allocated peer connection.
Declaration
public void Uninitialize()
Remarks
Peer will be null
afterward.