PeerConnection
Class that represents a connection used by the MLWebRTC API.
Public Fields
IceCandidate
Gets the ice candidate chosen by the connection.
public MLWebRTC.IceCandidate IceCandidate { get; set; }
Type | Description |
---|---|
MLWebRTC.IceCandidate | Class that represents an ice candidate used by the MLWebRTC API. |
IceServers
Gets the ice servers used for the connection.
public MLWebRTC.IceServer [] IceServers { get; set; }
Type | Description |
---|---|
MLWebRTC.IceServer [] | Class that represents an ice server used by the MLWebRTC API. |
Public Methods
MLResult AddLocalTrack
Adds a local track to the connection.
public MLResult AddLocalTrack(
MLWebRTC.MediaStream.Track trackToAdd
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.MediaStream.Track | trackToAdd | Track to add to the connection. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent.
MLResult AddRemoteIceCandidate
Adds an ice candidate to the connection.
public MLResult AddRemoteIceCandidate(
MLWebRTC.IceCandidate iceCandidate
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.IceCandidate | iceCandidate | The ice candidate to add. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed.
bool ContainsTrack
public bool ContainsTrack(
MediaStream.Track track
)
Parameters
Type | Name | Description |
---|---|---|
MediaStream.Track | track | Struct that represents a media stream track object. |
MLResult CreateOffer
Creates the offer for the connection.
public MLResult CreateOffer()
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent.
PeerConnection CreateRemote
Creates an initialized PeerConnection object.
public static PeerConnection CreateRemote(
MLWebRTC.IceServer [] iceServers,
out MLResult result
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.IceServer [] | iceServers | The ice servers to create the connection with. |
out MLResult | result | The MLResult object of the inner platform call(s). |
Returns: An initialized PeerConnection object.
PeerConnection CreateRemote
Creates an initialized PeerConnection object with a forward proxy configuration.
public static PeerConnection CreateRemote(
MLWebRTC.IceServer [] iceServers,
MLWebRTC.ProxyConfig proxyConfig,
out MLResult result
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.IceServer [] | iceServers | The ice servers to create the connection with. |
MLWebRTC.ProxyConfig | proxyConfig | Configuration for the forward proxy. |
out MLResult | result | The MLResult object of the inner platform call(s). |
Returns: An initialized PeerConnection object.
MLResult Destroy
Destroys the connection.
public MLResult Destroy()
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent.
MLResult HasFailed
Gets if the connection has failed or not.
public MLResult HasFailed(
out bool failed
)
Parameters
Type | Name | Description |
---|---|---|
out bool | failed | True if connection has failed. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed.
MLResult IsConnected
Gets if the connection is currently connected or not.
public MLResult IsConnected(
out bool connected
)
Parameters
Type | Name | Description |
---|---|---|
out bool | connected | True if connected. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed.
delegate void OnConnectedDelegate
Delegate describing the callback necessary to monitor if a connection has been made.
public delegate void OnConnectedDelegate(
MLWebRTC.PeerConnection connection
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
delegate void OnDataChannelReceivedDelegate
A delegate that describes the requirements of the OnDataChannelReceivedDelegate callback.
public delegate void OnDataChannelReceivedDelegate(
MLWebRTC.PeerConnection connection,
MLWebRTC.DataChannel dataChannel
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
MLWebRTC.DataChannel | dataChannel | The data channel that was added to the connection. |
delegate void OnDisconnectedDelegate
Delegate describing the callback necessary to monitor if a disconnection has been made.
public delegate void OnDisconnectedDelegate(
MLWebRTC.PeerConnection connection
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
delegate void OnErrorDelegate
Delegate describing the callback necessary to monitor errors.
public delegate void OnErrorDelegate(
MLWebRTC.PeerConnection connection,
string message
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
string | message | The error message. |
delegate void OnIceGatheringCompletedDelegate
Delegate describing the callback necessary to notify that all ICEs have been gathered.
public delegate void OnIceGatheringCompletedDelegate(
MLWebRTC.PeerConnection connection
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
delegate void OnLocalAnswerCreatedDelegate
Delegate describing the callback necessary to monitor when an answer to an offer is sent.
public delegate void OnLocalAnswerCreatedDelegate(
MLWebRTC.PeerConnection connection,
string sendAnswer
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
string | sendAnswer | The json of the answer sent. |
delegate void OnLocalIceCandidateFoundDelegate
Delegate describing the callback necessary to monitor when an ice candidate is sent.
public delegate void OnLocalIceCandidateFoundDelegate(
MLWebRTC.PeerConnection connection,
MLWebRTC.IceCandidate iceCandidate
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
MLWebRTC.IceCandidate | iceCandidate | The ice candidate that was sent. |
delegate void OnLocalOfferCreatedDelegate
Delegate describing the callback necessary to monitor when an offer is sent.
public delegate void OnLocalOfferCreatedDelegate(
MLWebRTC.PeerConnection connection,
string sdpSend
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.PeerConnection | connection | The connection the event was invoked on. |
string | sdpSend | The json of the offer sent. |
delegate void OnTrackAddedMultipleStreamsDelegate
A delegate that describes the requirements of the OnTrackAddedDelegate callback.
public delegate void OnTrackAddedMultipleStreamsDelegate(
List< MLWebRTC.MediaStream > mediaStreams,
MLWebRTC.MediaStream.Track addedTrack
)
Parameters
Type | Name | Description |
---|---|---|
List< MLWebRTC.MediaStream > | mediaStreams | The media stream associated with the added track. |
MLWebRTC.MediaStream.Track | addedTrack | The track that was added to the connection. |
delegate void OnTrackRemovedMultipleStreamsDelegate
A delegate that describes the requirements of the OnTrackRemovedDelegate callback.
public delegate void OnTrackRemovedMultipleStreamsDelegate(
List< MLWebRTC.MediaStream > mediaStreams,
MLWebRTC.MediaStream.Track removedTrack
)
Parameters
Type | Name | Description |
---|---|---|
List< MLWebRTC.MediaStream > | mediaStreams | The media stream associated with the removed track. |
MLWebRTC.MediaStream.Track | removedTrack | The track that was removed from the connection. |
MLResult RemoveLocalTrack
Removes a local track to the connection.
public MLResult RemoveLocalTrack(
MLWebRTC.MediaStream.Track trackToRemove
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.MediaStream.Track | trackToRemove | Track to remove to the connection. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent.
MLResult SetRemoteAnswer
Sets the remote answer for the connection.
public MLResult SetRemoteAnswer(
string remoteAnswer
)
Parameters
Type | Name | Description |
---|---|---|
string | remoteAnswer | The answer to set. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed.
MLResult SetRemoteOffer
Sets the remote offer for the connection.
public MLResult SetRemoteOffer(
string remoteOffer
)
Parameters
Type | Name | Description |
---|---|---|
string | remoteOffer | The offer to set. |
Returns: MLResult.Result will be MLResult.Code.Ok if destroying all handles was successful. MLResult.Result will be MLResult.Code.WebRTCResultInstanceNotCreated if MLWebRTC instance was not created. MLResult.Result will be MLResult.Code.WebRTCResultMismatchingHandle if an incorrect handle was sent. MLResult.Result will be MLResult.Code.InvalidParam if an invalid parameter was passed.
Public Events
OnConnected
Event invoked for when a connection between a local and remote peer is established.
public OnConnectedDelegate OnConnected()
OnDataChannelReceived
Event invoked for when a data channel is received by a connection.
public OnDataChannelReceivedDelegate OnDataChannelReceived()
OnDisconnected
Event invoked for when a connection between a local and remote peer is destroyed.
public OnDisconnectedDelegate OnDisconnected()
OnError
Event invoked for when an error occurs.
public OnErrorDelegate OnError()
OnIceGatheringCompleted
Event invoked for when ice gathering completed.
public OnIceGatheringCompletedDelegate OnIceGatheringCompleted()
OnLocalAnswerCreated
Event invoked for when an answer is sent.
public OnLocalAnswerCreatedDelegate OnLocalAnswerCreated()
OnLocalIceCandidateFound
Event invoked for when an ice candidate is sent.
public OnLocalIceCandidateFoundDelegate OnLocalIceCandidateFound()
OnLocalOfferCreated
Event invoked for when an offer is sent.
public OnLocalOfferCreatedDelegate OnLocalOfferCreated()
OnTrackAddedMultipleStreams
Event invoked for when a track is added to a connection.
public OnTrackAddedMultipleStreamsDelegate OnTrackAddedMultipleStreams()
OnTrackRemovedMultipleStreams
Event invoked for when a track is removed from a connection.
public OnTrackRemovedMultipleStreamsDelegate OnTrackRemovedMultipleStreams()