Track
Struct that represents a media stream track object.
Inherited by:
UnityEngine.XR.MagicLeap.MLWebRTC.AppDefinedSource
Public Fields
Id
Track name
public string Id { get; set; }
IsLocal
Gets or sets a value indicating whether the track is local or not.
public bool IsLocal { get; set; }
ParentConnection
Gets a reference to the associated connection of the track.
public MLWebRTC.PeerConnection ParentConnection { get; set; }
Type | Description |
---|---|
MLWebRTC.PeerConnection | Class that represents a connection used by the MLWebRTC API. |
Streams
Gets the list of streams associated with this track.
public List< MediaStream > Streams { get; set; }
Type | Description |
---|---|
List< MediaStream > | Class that represents a media stream object. |
TrackType
Gets the string that determines the type of track this is.
public Type TrackType { get; set; }
Type | Description |
---|---|
Type | Defines the types of tracks that can exist. |
Public Methods
Track CreateAudioTrackFromMicrophone
Creates an initialized Track object.
public static Track CreateAudioTrackFromMicrophone(
out MLResult result,
string trackId =""
)
Parameters
Type | Name | Description |
---|---|---|
out MLResult | result | The MLResult object of the inner platform call(s). |
string | trackId |
Returns: An initialized Track object.
Track CreateAudioTrackFromSource
Creates an initialized Track object.
public static Track CreateAudioTrackFromSource(
out MLResult result,
string trackId =""
)
Parameters
Type | Name | Description |
---|---|---|
out MLResult | result | The MLResult object of the inner platform call(s). |
string | trackId |
Returns: An initialized Track object.
Track CreateVideoTrack
Creates an initialized Track object. Recommended to use app defined video sources in production, with sample sources provided as MLCameraVideoSource and MLMRCameraVideoSource in the UnityEngine.XR.MagicLeap namespace since those sources provide more information about and control over various error cases and handle special cases like app pause/resume and device standby/reality/active.
public static Track CreateVideoTrack(
VideoType videoType,
out MLResult result,
string trackId =""
)
Parameters
Type | Name | Description |
---|---|---|
VideoType | videoType | The type of video source to use. |
out MLResult | result | The MLResult object of the inner platform call(s). |
string | inputContext | The InputContext object to start the MLMRCamera API with. |
Returns: An initialized Track object.
MLResult DestroyLocal
Destroys the Track and its associated media source.
public virtual MLResult DestroyLocal()
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.
Reimplemented by: DestroyLocal, DestroyLocal
MLResult GetEnabled
Gets if a track is currently enabled or not.
public MLResult GetEnabled(
out bool isEnabled
)
Parameters
Type | Name | Description |
---|---|---|
out bool | isEnabled | True if the track is enabled. |
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 SetEnabled
Sets a track to be enabled or disabled.
public MLResult SetEnabled(
bool isEnabled
)
Parameters
Type | Name | Description |
---|---|---|
bool | isEnabled | True if the track should be enabled. |
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.
Protected Methods
HandleDeviceActive
Sets this track to enabled during the lifecycle active event. Override for custom behavior.
protected virtual void HandleDeviceActive()
HandleDeviceReality
Disables this track during the lifecycle reality events. Override for custom behavior.
protected virtual void HandleDeviceReality()
HandleDeviceStandby
Disables this track during the lifecycle standby event. Override for custom behavior.
protected virtual void HandleDeviceStandby()
OnApplicationPause
Reacts to when the application is paused (after subscribing to MLDevice). Override for custom behavior.
protected virtual void OnApplicationPause(
bool pause
)
Parameters
Type | Name | Description |
---|---|---|
bool | pause | True if paused. |
Reimplemented by: OnApplicationPause
Protected Attributes
wasEnabledBeforeLifecycleStateChange
Caches if the track was enabled before a lifestyle event change.
protected bool wasEnabledBeforeLifecycleStateChange = false;
Public Enums
AudioType
Defines the natively supported audio types.
Enumerator | Value | Description |
---|---|---|
None | No audio source. | |
Microphone | Natively uses Microphone as audio source. | |
Defined | Uses a custom audio source. |
Type
Defines the types of tracks that can exist.
Enumerator | Value | Description |
---|---|---|
Audio | Audio track type. | |
Video | Video track type. |
VideoType
Defines the natively supported video types. It is recommended to use app defined video sources in production, with sample sources provided as MLWebRTC.MLCameraVideoSource in the UnityEngine.XR.MagicLeap namespace since those sources provide more information about and control over the camera configuration.
Enumerator | Value | Description |
---|---|---|
None | No video source. | |
MLCamera | Natively uses MLCamera as video source. | |
MLMRCamera | Natively uses MLMRCamera as video source. | |
VirtualOnly | Natively uses VirtualOnly as video source. |