NativeBindings
Native bindings for the MLWebRTC.PeerConnection class.
Inherits from:
MagicLeapNativeBindings
Public Methods
MLResult.Code CreateRemoteConnection
Creates a remote connection and sets up the native callbacks.
public static MLResult.Code CreateRemoteConnection(
MLWebRTC.IceServer [] iceServers,
out PeerConnection connection
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.IceServer [] | iceServers | The ice servers to create the connection with. |
out PeerConnection | connection | The created connection object. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection was successfully created. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code CreateRemoteConnection
Creates a remote connection with a forward proxy configuration and sets up the native callbacks.
public static MLResult.Code CreateRemoteConnection(
MLWebRTC.IceServer [] iceServers,
MLWebRTC.ProxyConfig proxyConfig,
out PeerConnection connection
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.IceServer [] | iceServers | The ice servers to create the connection with. |
MLWebRTC.ProxyConfig | proxyConfig | The forward proxy configuration. |
out PeerConnection | connection | The created connection object. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection was successfully created. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionAddLocalSourceTrackEx
Add a local source as a media track to the connection.
public MLResult.Code MLWebRTCConnectionAddLocalSourceTrackEx(
ulong connectionHandle,
ulong localSourceHandle,
ref MLWebRTCTrackInfo trackInfo
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection to set the local source to. |
ulong | localSourceHandle | The handle to the local source to set onto the connection. |
ref MLWebRTCTrackInfo | trackInfo | Information about the track to be added |
Returns: MLResult.Result will be MLResult.Code.Ok if the source was successfully set on the connection. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionAddRemoteIceCandidate
Adds a remote ice candidate from a connection.
public MLResult.Code MLWebRTCConnectionAddRemoteIceCandidate(
ulong connectionHandle,
in MLWebRTCConnectionIceCandidate candidate
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection to send the ice candidate to. |
in MLWebRTCConnectionIceCandidate | candidate | The ice candidate to send. |
Returns: MLResult.Result will be MLResult.Code.Ok if the ice candidate was successfully sent. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionCreate
Creates a WebRTC connection.
public MLResult.Code MLWebRTCConnectionCreate(
in MLWebRTCConnectionConfig config,
in MLWebRTCConnectionEventCallbacks callbacks,
out ulong connectionHandle
)
Parameters
Type | Name | Description |
---|---|---|
in MLWebRTCConnectionConfig | config | The configuration that holds the ice servers. |
in MLWebRTCConnectionEventCallbacks | callbacks | The object that holds all the callbacks that will be invoked natively. |
out ulong | connectionHandle | The handle of the connection to return to the caller. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection was successfully created. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionCreateOffer
Creates an offer with a connection.
public MLResult.Code MLWebRTCConnectionCreateOffer(
ulong connectionHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection creating the offer. |
Returns: MLResult.Result will be MLResult.Code.Ok if the offer was successfully created. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionDestroy
Destroys a WebRTC connection.
public MLResult.Code MLWebRTCConnectionDestroy(
ulong connectionHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection to destroy. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection was successfully destroyed. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionHasFailed
Gets if a connection has failed
public MLResult.Code MLWebRTCConnectionHasFailed(
ulong connectionHandle,
out bool hasFailed
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection in question. |
out bool | hasFailed | Used to return to the user to determine if the connection has failed or not. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection status was successfully queried. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionIsConnected
Gets if a connection is currently connected.
public MLResult.Code MLWebRTCConnectionIsConnected(
ulong connectionHandle,
out bool isConnected
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection in question. |
out bool | isConnected | Used to return to the user to determine if the connection is connected or not. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection status was successfully queried. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionProcessEvents
Processes events of a connection, responsible for callbacks being invoked natively.
public MLResult.Code MLWebRTCConnectionProcessEvents(
ulong connectionHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection to process events from. |
Returns: MLResult.Result will be MLResult.Code.Ok if the connection had it's events successfully processed. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionRemoveLocalSourceTrack
Sets the local source of a connection.
public MLResult.Code MLWebRTCConnectionRemoveLocalSourceTrack(
ulong connectionHandle,
ulong localSourceHandle
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection to set the local source to. |
ulong | localSourceHandle | The handle to the local source to set onto the connection. |
Returns: MLResult.Result will be MLResult.Code.Ok if the source was successfully set on the connection. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionSetRemoteAnswer
Sets the answer to an offer from a remote connection.
public MLResult.Code MLWebRTCConnectionSetRemoteAnswer(
ulong connectionHandle,
string answer
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection answering to the offer. |
string | answer | The json formatted answer string to set. |
Returns: MLResult.Result will be MLResult.Code.Ok if the answer was successfully set. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
MLResult.Code MLWebRTCConnectionSetRemoteOffer
Sets an offer from a remote connection.
public MLResult.Code MLWebRTCConnectionSetRemoteOffer(
ulong connectionHandle,
string offer
)
Parameters
Type | Name | Description |
---|---|---|
ulong | connectionHandle | The handle to the connection responding to the offer. |
string | offer | The offer string. |
Returns: MLResult.Result will be MLResult.Code.Ok if the offer was successfully set. MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error.
delegate void OnConnectedDelegate
A delegate that describes the requirements of the OnConnectedDelegate callback.
public delegate void OnConnectedDelegate(
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | context | Pointer to a context object. |
delegate void OnDataChannelReceivedDelegate
A delegate that describes the requirements of the OnDataChannelReceivedDelegate callback.
public delegate void OnDataChannelReceivedDelegate(
ulong remoteDataChanelHandle,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
ulong | remoteDataChanelHandle | The handle to the newly received data channel. |
IntPtr | context | Pointer to a context object. |
delegate void OnDisconnectedDelegate
A delegate that describes the requirements of the OnDisconnectedDelegate callback.
public delegate void OnDisconnectedDelegate(
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | context | Pointer to a context object. |
delegate void OnErrorDelegate
A delegate that describes the requirements of the OnError callback.
public delegate void OnErrorDelegate(
string message,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
string | message | The error message. |
IntPtr | context | Pointer to a context object. |
delegate void OnIceGatheringCompletedDelegate
A delegate that describes the requirements of the OnIceGatheringCompleted callback.
public delegate void OnIceGatheringCompletedDelegate(
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | context | Pointer to a context object. |
delegate void OnLocalAnswerCreatedDelegate
A delegate that describes the requirements of the OnSendAnswer callback.
public delegate void OnLocalAnswerCreatedDelegate(
string answer,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
string | answer | The json formatted answer string. |
IntPtr | context | Pointer to a context object. |
delegate void OnLocalIceCandidateFoundDelegate
A delegate that describes the requirements of the OnSendIceCandidate callback.
public delegate void OnLocalIceCandidateFoundDelegate(
in MLWebRTCConnectionIceCandidate iceCandidate,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
in MLWebRTCConnectionIceCandidate | iceCandidate | The ice candidate object that was sent. |
IntPtr | context | Pointer to a context object. |
delegate void OnLocalOfferCreatedDelegate
A delegate that describes the requirements of the OnSendOfferDelegate callback.
public delegate void OnLocalOfferCreatedDelegate(
string offer,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
string | offer | The json formatted offer string. |
IntPtr | context | Pointer to a context object. |
delegate void OnTrackAddedDelegate
A delegate that describes the requirements of the OnTrackAddedDelegate callback.
public delegate void OnTrackAddedDelegate(
in MLWebRTC.Source.NativeBindings.MLWebRTCSource sourceNative,
uint numStreamIds,
IntPtr streamIdsPtr,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
in MLWebRTC.Source.NativeBindings.MLWebRTCSource | sourceNative | The native source object that was added. |
uint | numStreamIds | The number of streams this track belongs to. |
IntPtr | streamIdsPtr | The names of the streams this track belongs to. |
IntPtr | context | Pointer to a context object. |
delegate void OnTrackRemovedDelegate
A delegate that describes the requirements of the OnTrackRemovedDelegate callback.
public delegate void OnTrackRemovedDelegate(
ulong remoteSourceHandle,
IntPtr context
)
Parameters
Type | Name | Description |
---|---|---|
ulong | remoteSourceHandle | The handle to the removed source. |
IntPtr | context | Pointer to a context object. |