fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack > Class Template Referenceabstract

A collection of audio/video tracks. More...

Public Member Functions

void addOnAudioDestroyed (fm.liveswitch.IAction0 value)
 Adds a handler that is raised when the audio track is destroyed. More...
 
void addOnAudioLevel (fm.liveswitch.IAction1< Double > value)
 Adds a handler that is raised periodically when the audio's level is calculated. More...
 
void addOnVideoDestroyed (fm.liveswitch.IAction0 value)
 Adds a handler that is raised when the video track is destroyed. More...
 
void addOnVideoSize (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Adds a handler that is raised whenever the video's frame size is known, once per frame. More...
 
void addOnVideoSizeChange (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Adds a handler that is raised whenever the video's frame size changes. More...
 
void destroy ()
 Destroys all non-persistent internal objects encapsulated by the Media class. More...
 
int getAudioLevelInterval ()
 Gets the interval in milliseconds between fm.liveswitch.Media#addOnAudioLevel events. More...
 
TAudioTrack[] getAudioTracks ()
 Gets all audio tracks from this media. More...
 
boolean getIsRecordingAudio ()
 Gets whether audio is being recorded locally. More...
 
boolean getIsRecordingVideo ()
 Gets whether video is being recorded locally. More...
 
fm.liveswitch.Size getVideoSize ()
 Gets the size of the video track. More...
 
TVideoTrack[] getVideoTracks ()
 Gets all video tracks from this media. More...
 
fm.liveswitch.Future< fm.liveswitch.VideoBuffergrabVideoFrame ()
 Gets the next frame from the video track once it is rendered. More...
 
 Media ()
 Initializes a new instance of the fm.liveswitch.Media class. More...
 
void removeOnAudioDestroyed (fm.liveswitch.IAction0 value)
 Removes a handler that is raised when the audio track is destroyed. More...
 
void removeOnAudioLevel (fm.liveswitch.IAction1< Double > value)
 Removes a handler that is raised periodically when the audio's level is calculated. More...
 
void removeOnVideoDestroyed (fm.liveswitch.IAction0 value)
 Removes a handler that is raised when the video track is destroyed. More...
 
void removeOnVideoSize (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Removes a handler that is raised whenever the video's frame size is known, once per frame. More...
 
void removeOnVideoSizeChange (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Removes a handler that is raised whenever the video's frame size changes. More...
 
void setAudioLevelInterval (int value)
 Sets the interval in milliseconds between fm.liveswitch.Media#addOnAudioLevel events. More...
 
- Public Member Functions inherited from fm.liveswitch.MediaBase< TAudioTrack, TVideoTrack >
abstract void addOnAudioDestroyed (fm.liveswitch.IAction0 value)
 Adds a handler that is raised when the audio track is destroyed. More...
 
abstract void addOnAudioLevel (fm.liveswitch.IAction1< Double > value)
 Adds a handler that is raised periodically when the audio's level is calculated. More...
 
abstract void addOnVideoDestroyed (fm.liveswitch.IAction0 value)
 Adds a handler that is raised when the video track is destroyed. More...
 
abstract void addOnVideoSize (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Adds a handler that is raised whenever the video's frame size is known, once per frame. More...
 
abstract void addOnVideoSizeChange (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Adds a handler that is raised whenever the video's frame size changes. More...
 
abstract void destroy ()
 Destroys this media stack. More...
 
double getAudioGain ()
 Gets the gain (input amplification) of the audio track. More...
 
abstract int getAudioLevelInterval ()
 Gets the interval in milliseconds between fm.liveswitch.MediaBase#addOnAudioLevel events. More...
 
boolean getAudioMuted ()
 Gets a value indicating whether the audio is muted. More...
 
TIAudioTrack getAudioTrack ()
 Gets the audio track from this media. More...
 
abstract TIAudioTrack[] getAudioTracks ()
 Gets all audio tracks from this media. More...
 
double getAudioVolume ()
 Gets the audio volume on the audio track. More...
 
String getId ()
 Gets the unique identifier of this media. More...
 
boolean getVideoMuted ()
 Gets a value indicating whether the video track is muted. More...
 
abstract fm.liveswitch.Size getVideoSize ()
 Gets the size of the last processed video frame, if known. More...
 
TIVideoTrack getVideoTrack ()
 Gets the video track from this media. More...
 
abstract TIVideoTrack[] getVideoTracks ()
 Gets all video tracks from this media. More...
 
abstract fm.liveswitch.Future< fm.liveswitch.VideoBuffergrabVideoFrame ()
 Gets the next raw video frame. More...
 
 MediaBase ()
 Initializes a new instance of the fm.liveswitch.MediaBase class. More...
 
abstract void removeOnAudioDestroyed (fm.liveswitch.IAction0 value)
 Removes a handler that is raised when the audio track is destroyed. More...
 
abstract void removeOnAudioLevel (fm.liveswitch.IAction1< Double > value)
 Removes a handler that is raised periodically when the audio's level is calculated. More...
 
abstract void removeOnVideoDestroyed (fm.liveswitch.IAction0 value)
 Removes a handler that is raised when the video track is destroyed. More...
 
abstract void removeOnVideoSize (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Removes a handler that is raised whenever the video's frame size is known, once per frame. More...
 
abstract void removeOnVideoSizeChange (fm.liveswitch.IAction1< fm.liveswitch.Size > value)
 Removes a handler that is raised whenever the video's frame size changes. More...
 
void setAudioGain (double value)
 Sets the gain (input amplification) of the audio track. More...
 
abstract void setAudioLevelInterval (int value)
 Sets the interval in milliseconds between fm.liveswitch.MediaBase#addOnAudioLevel events. More...
 
void setAudioMuted (boolean value)
 Sets a value indicating whether the audio is muted. More...
 
void setAudioVolume (double value)
 Sets the audio volume on the audio track. More...
 
void setId (String value)
 Sets the unique identifier of this media. More...
 
void setVideoMuted (boolean value)
 Sets a value indicating whether the video track is muted. More...
 

Protected Member Functions

void addAudioTrack (TAudioTrack audioTrack)
 Adds an audio track. More...
 
void addVideoTrack (TVideoTrack videoTrack)
 Adds a video track. More...
 
abstract TAudioTrack[] arrayFromAudioTracks (java.util.ArrayList< TAudioTrack > tracks)
 Creates an array of tracks from a list of audio tracks. More...
 
abstract TVideoTrack[] arrayFromVideoTracks (java.util.ArrayList< TVideoTrack > tracks)
 Creates an array of tracks from a list of video tracks. More...
 
abstract java.util.ArrayList< TAudioTrack > createAudioTrackCollection ()
 Creates an audio track collection. More...
 
abstract java.util.ArrayList< TVideoTrack > createVideoTrackCollection ()
 Creates a video track collection. More...
 
boolean removeAudioTrack (TAudioTrack audioTrack)
 Removes an audio track. More...
 
boolean removeVideoTrack (TVideoTrack videoTrack)
 Removes a video track. More...
 
void setIsRecordingAudio (boolean value)
 Sets whether audio is being recorded locally. More...
 
void setIsRecordingVideo (boolean value)
 Sets whether video is being recorded locally. More...
 

Detailed Description

A collection of audio/video tracks.

Constructor & Destructor Documentation

◆ Media()

fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.Media ( )

Initializes a new instance of the fm.liveswitch.Media class.

Member Function Documentation

◆ addAudioTrack()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addAudioTrack ( TAudioTrack  audioTrack)
protected

Adds an audio track.

Parameters
audioTrackThe audio track.

◆ addOnAudioDestroyed()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addOnAudioDestroyed ( fm.liveswitch.IAction0  value)

Adds a handler that is 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.

◆ addOnAudioLevel()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addOnAudioLevel ( fm.liveswitch.IAction1< Double >  value)

Adds a handler that is 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.

◆ addOnVideoDestroyed()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addOnVideoDestroyed ( fm.liveswitch.IAction0  value)

Adds a handler that is 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.

◆ addOnVideoSize()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addOnVideoSize ( fm.liveswitch.IAction1< fm.liveswitch.Size value)

Adds a handler that is 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.

◆ addOnVideoSizeChange()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addOnVideoSizeChange ( fm.liveswitch.IAction1< fm.liveswitch.Size value)

Adds a handler that is 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.

◆ addVideoTrack()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.addVideoTrack ( TVideoTrack  videoTrack)
protected

Adds a video track.

Parameters
videoTrackThe video track.

◆ arrayFromAudioTracks()

abstract TAudioTrack [] fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.arrayFromAudioTracks ( java.util.ArrayList< TAudioTrack >  tracks)
abstractprotected

Creates an array of tracks from a list of audio tracks.

Parameters
tracksThe list of tracks.

◆ arrayFromVideoTracks()

abstract TVideoTrack [] fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.arrayFromVideoTracks ( java.util.ArrayList< TVideoTrack >  tracks)
abstractprotected

Creates an array of tracks from a list of video tracks.

Parameters
tracksThe list of tracks.

◆ createAudioTrackCollection()

abstract java.util.ArrayList<TAudioTrack> fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.createAudioTrackCollection ( )
abstractprotected

Creates an audio track collection.

Reimplemented in fm.liveswitch.LocalMedia.

◆ createVideoTrackCollection()

abstract java.util.ArrayList<TVideoTrack> fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.createVideoTrackCollection ( )
abstractprotected

Creates a video track collection.

Reimplemented in fm.liveswitch.LocalMedia.

◆ destroy()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.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.

Reimplemented in fm.liveswitch.RtcLocalMedia< TView >.

◆ getAudioLevelInterval()

int fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.getAudioLevelInterval ( )

Gets the interval in milliseconds between fm.liveswitch.Media#addOnAudioLevel events.

Defaults to 200.

◆ getAudioTracks()

TAudioTrack [] fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.getAudioTracks ( )

Gets all audio tracks from this media.

◆ getIsRecordingAudio()

boolean fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.getIsRecordingAudio ( )

Gets whether audio is being recorded locally.

◆ getIsRecordingVideo()

boolean fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.getIsRecordingVideo ( )

Gets whether video is being recorded locally.

◆ getVideoSize()

fm.liveswitch.Size fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.getVideoSize ( )

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.

◆ getVideoTracks()

TVideoTrack [] fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.getVideoTracks ( )

Gets all video tracks from this media.

◆ 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.

Returns
A future video buffer.

◆ removeAudioTrack()

boolean fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeAudioTrack ( TAudioTrack  audioTrack)
protected

Removes an audio track.

Parameters
audioTrackThe audio track.

◆ removeOnAudioDestroyed()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeOnAudioDestroyed ( fm.liveswitch.IAction0  value)

Removes a handler that is 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.

◆ removeOnAudioLevel()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeOnAudioLevel ( fm.liveswitch.IAction1< Double >  value)

Removes a handler that is 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.

◆ removeOnVideoDestroyed()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeOnVideoDestroyed ( fm.liveswitch.IAction0  value)

Removes a handler that is 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.

◆ removeOnVideoSize()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeOnVideoSize ( fm.liveswitch.IAction1< fm.liveswitch.Size value)

Removes a handler that is 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.

◆ removeOnVideoSizeChange()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeOnVideoSizeChange ( fm.liveswitch.IAction1< fm.liveswitch.Size value)

Removes a handler that is 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.

◆ removeVideoTrack()

boolean fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.removeVideoTrack ( TVideoTrack  videoTrack)
protected

Removes a video track.

Parameters
videoTrackThe video track.

◆ setAudioLevelInterval()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.setAudioLevelInterval ( int  value)

Sets the interval in milliseconds between fm.liveswitch.Media#addOnAudioLevel events.

Defaults to 200.

◆ setIsRecordingAudio()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.setIsRecordingAudio ( boolean  value)
protected

Sets whether audio is being recorded locally.

◆ setIsRecordingVideo()

void fm.liveswitch.Media< TAudioTrack extends fm.liveswitch.AudioTrack, TVideoTrack extends fm.liveswitch.VideoTrack >.setIsRecordingVideo ( boolean  value)
protected

Sets whether video is being recorded locally.