Class Media<TAudioTrack, TVideoTrack>
A collection of audio/video tracks.
Implements
Inherited Members
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public abstract class Media<TAudioTrack, TVideoTrack> : MediaBase<TAudioTrack, TVideoTrack>, IMedia<TAudioTrack, TVideoTrack> where TAudioTrack : AudioTrack where TVideoTrack : VideoTrack
Type Parameters
Name | Description |
---|---|
TAudioTrack | |
TVideoTrack |
Constructors
Media()
Initializes a new instance of the Media<TAudioTrack, TVideoTrack> class.
Declaration
public Media()
Properties
AudioLevelInterval
Gets or sets the interval in milliseconds between OnAudioLevel events. Defaults to 200.
Declaration
public override int AudioLevelInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Overrides
AudioTracks
Gets all audio tracks from this media.
Declaration
public override TAudioTrack[] AudioTracks { get; }
Property Value
Type | Description |
---|---|
TAudioTrack[] |
Overrides
IsRecordingAudio
Gets or sets whether audio is being recorded locally.
Declaration
public bool IsRecordingAudio { get; protected set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsRecordingVideo
Gets or sets whether video is being recorded locally.
Declaration
public bool IsRecordingVideo { get; protected set; }
Property Value
Type | Description |
---|---|
System.Boolean |
VideoSize
Gets the size of the video track.
If there are multiple video tracks in a custom media stack, this property is bound to the first video track.
If you need to adjust a UI’s layout, use this property to check video dimensions. You can also use OnVideoSize to ensure that the code is responsive.
Declaration
public override Size VideoSize { get; }
Property Value
Type | Description |
---|---|
Size |
Overrides
VideoTracks
Gets all video tracks from this media.
Declaration
public override TVideoTrack[] VideoTracks { get; }
Property Value
Type | Description |
---|---|
TVideoTrack[] |
Overrides
Methods
AddAudioTrack(TAudioTrack)
Adds an audio track.
Declaration
protected virtual void AddAudioTrack(TAudioTrack audioTrack)
Parameters
Type | Name | Description |
---|---|---|
TAudioTrack | audioTrack | The audio track. |
AddVideoTrack(TVideoTrack)
Adds a video track.
Declaration
protected virtual void AddVideoTrack(TVideoTrack videoTrack)
Parameters
Type | Name | Description |
---|---|---|
TVideoTrack | videoTrack | The video track. |
ArrayFromAudioTracks(List<TAudioTrack>)
Creates an array of tracks from a list of audio tracks.
Declaration
protected abstract TAudioTrack[] ArrayFromAudioTracks(List<TAudioTrack> tracks)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TAudioTrack> | tracks | The list of tracks. |
Returns
Type | Description |
---|---|
TAudioTrack[] |
ArrayFromVideoTracks(List<TVideoTrack>)
Creates an array of tracks from a list of video tracks.
Declaration
protected abstract TVideoTrack[] ArrayFromVideoTracks(List<TVideoTrack> tracks)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TVideoTrack> | tracks | The list of tracks. |
Returns
Type | Description |
---|---|
TVideoTrack[] |
CreateAudioTrackCollection()
Creates an audio track collection.
Declaration
protected abstract List<TAudioTrack> CreateAudioTrackCollection()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<TAudioTrack> |
CreateVideoTrackCollection()
Creates a video track collection.
Declaration
protected abstract List<TVideoTrack> CreateVideoTrackCollection()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<TVideoTrack> |
Destroy()
Destroys all non-persistent internal objects encapsulated by the Media class.
This method iterates over all audio and video tracks and calls each track's Destroy method for non-persistent tracks.
Declaration
public override void Destroy()
Overrides
GrabVideoFrame()
Gets the next frame from the video track once it is rendered.
If there are multiple video tracks in a custom media stack, this method calls into the first video track.
This method could be used for asynchronous video processing or analysis.
Declaration
public override Future<VideoBuffer> GrabVideoFrame()
Returns
Type | Description |
---|---|
Future<VideoBuffer> | A future video buffer. |
Overrides
RemoveAudioTrack(TAudioTrack)
Removes an audio track.
Declaration
protected virtual bool RemoveAudioTrack(TAudioTrack audioTrack)
Parameters
Type | Name | Description |
---|---|---|
TAudioTrack | audioTrack | The audio track. |
Returns
Type | Description |
---|---|
System.Boolean |
RemoveVideoTrack(TVideoTrack)
Removes a video track.
Declaration
protected virtual bool RemoveVideoTrack(TVideoTrack videoTrack)
Parameters
Type | Name | Description |
---|---|---|
TVideoTrack | videoTrack | The video track. |
Returns
Type | Description |
---|---|
System.Boolean |
Events
OnAudioDestroyed
Raised when the audio track is destroyed.
If there are multiple audio tracks in a custom media stack, only the first audio track triggers this event.
Declaration
public override event Action0 OnAudioDestroyed
Event Type
Type | Description |
---|---|
Action0 |
Overrides
OnAudioLevel
Raised periodically when the audio's level is calculated.
When the media is in the Started state, the function runs multiple times per second. The frequency depends on the audio sampling rate.
Use this method to determine which audio streams are active.
If there are multiple audio tracks in a custom media stack, only the first audio track triggers this event.
Declaration
public override event Action1<double> OnAudioLevel
Event Type
Type | Description |
---|---|
Action1<System.Double> |
Overrides
OnVideoDestroyed
Raised when the video track is destroyed.
If there are multiple video tracks in a custom media stack, only the first video track triggers this event.
Declaration
public override event Action0 OnVideoDestroyed
Event Type
Type | Description |
---|---|
Action0 |
Overrides
OnVideoSize
Raised whenever the video's frame size is known, once per frame.
If there are multiple video tracks in a custom media stack, only the first video track triggers this event.
Declaration
public override event Action1<Size> OnVideoSize
Event Type
Type | Description |
---|---|
Action1<Size> |
Overrides
OnVideoSizeChange
Raised whenever the video's frame size changes.
If there are multiple video tracks in a custom media stack, only the first video track triggers this event.
Declaration
public override event Action1<Size> OnVideoSizeChange
Event Type
Type | Description |
---|---|
Action1<Size> |