MediaStream
Class that represents a media stream object.
Public Fields
ActiveAudioTrack
Gets the active audio track.
public MediaStream.Track ActiveAudioTrack { get; set; }
Type | Description |
---|---|
MediaStream.Track | Struct that represents a media stream track object. |
ActiveVideoTrack
Gets the active video track.
public MediaStream.Track ActiveVideoTrack { get; set; }
Type | Description |
---|---|
MediaStream.Track | Struct that represents a media stream track object. |
AudioTracks
Gets all audio tracks.
public List< MediaStream.Track > AudioTracks { get; set; }
Type | Description |
---|---|
List< MediaStream.Track > | Struct that represents a media stream track object. |
Id
Gets the id of this media stream.
public string Id = new HashSet<PeerConnection>() { get; set; }
IsLocal
Gets a value indicating whether the media stream is local or not.
public bool IsLocal { get; set; }
ParentConnections
Gets the connections associated with this media stream. Remote media streams will have just 1 connection, while local streams can have more than one, depending on the app setup.
public HashSet< MLWebRTC.PeerConnection > ParentConnections { get; set; }
Type | Description |
---|---|
HashSet< MLWebRTC.PeerConnection > | Class that represents a connection used by the MLWebRTC API. |
Tracks
Gets the list of tracks associated with this media stream.
public List< MediaStream.Track > Tracks { get; set; }
Type | Description |
---|---|
List< MediaStream.Track > | Struct that represents a media stream track object. |
VideoTracks
Gets all video tracks.
public List< MediaStream.Track > VideoTracks { get; set; }
Type | Description |
---|---|
List< MediaStream.Track > | Struct that represents a media stream track object. |
Public Methods
MLResult AddLocalTrack
Adds a local track to the media stream.
public MLResult AddLocalTrack(
MLWebRTC.MediaStream.Track track
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.MediaStream.Track | connection | The connection to use. |
track | The local track to add. |
Returns:
MediaStream Create
Creates an initialized local MediaStream object.
public static MediaStream Create(
string id
)
Parameters
Type | Name | Description |
---|---|---|
string | id | The id to give the media stream. |
Returns: An initialized MediaStream object.
MediaStream CreateWithAppDefinedVideoTrack
Creates an initialized local MediaStream object and it's tracks with the given video source.
public static MediaStream CreateWithAppDefinedVideoTrack(
string id,
MLWebRTC.AppDefinedVideoSource appDefinedVideoSource,
Track.AudioType audioType,
string audioTrackId ="",
MLWebRTC.AppDefinedAudioSource localDefinedAudioSource =null
)
Parameters
Type | Name | Description |
---|---|---|
string | connection | Connection to use. |
MLWebRTC.AppDefinedVideoSource | id | The id to give the media stream. |
Track.AudioType | appDefinedVideoSource | The defined video source to use. |
string | audioTrackId | |
MLWebRTC.AppDefinedAudioSource | localDefinedAudioSource | Class that represents an app defined video source that can be used by the MLWebRTC API. |
Returns: An initialized MediaStream object.
MediaStream CreateWithBuiltInTracks
Creates an initialized local MediaStream object and it's tracks with the given video type. Recommended to use CreateWithAppDefinedVideoTrack() in production, with sample video 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 MediaStream CreateWithBuiltInTracks(
string id,
Track.VideoType videoType,
Track.AudioType audioType,
string videoTrackId ="",
string audioTrackId =""
)
Parameters
Type | Name | Description |
---|---|---|
string | connection | Connection to use. |
Track.VideoType | id | The id to give the media stream. |
Track.AudioType | videoType | The type of video to use. |
string | videoTrackId | |
string | audioTrackId |
Returns: An initialized MediaStream object.
void DestroyLocal
Destroys this stream and it's associated tracks.
public void DestroyLocal()
MLResult RemoveLocalTrack
Removes a local track from the media stream.
public MLResult RemoveLocalTrack(
MLWebRTC.MediaStream.Track track
)
Parameters
Type | Name | Description |
---|---|---|
MLWebRTC.MediaStream.Track | connection | The connection to use. |
track | The local track to add. |
Returns:
MLResult SelectTrack
Sets the given track as the active track of it's kind and enables it.
public MLResult SelectTrack(
MediaStream.Track track
)
Parameters
Type | Name | Description |
---|---|---|
MediaStream.Track | track | The track to make active. |
MLResult UnSelectTrack
Sets the given track to longer be the active track of it's kind and disables.
public MLResult UnSelectTrack(
MediaStream.Track track
)
Parameters
Type | Name | Description |
---|---|---|
MediaStream.Track | track | The track to make inactive. |