MediaMixer

class MediaMixer(context: Context, val isRunning: AtomicBoolean = AtomicBoolean(false)) : MediaOutputDataSource, CoroutineScope, DefaultLifecycleObserver, Running

Routes captured audio and composited video to registered outputs.

Attach capture sources to numbered tracks, register streams or recorders with registerOutput, and call startRunning to start capture. Call stopRunning to stop capture and dispose when the mixer is no longer needed.

Constructors

Link copied to clipboard
constructor(context: Context, isRunning: AtomicBoolean = AtomicBoolean(false))

Properties

Link copied to clipboard

Specifies the audio mixer settings.

Link copied to clipboard
Link copied to clipboard
open override val hasAudio: Boolean

Whether the source provides audio.

Link copied to clipboard
open override val hasVideo: Boolean

Whether the source provides video.

Link copied to clipboard
open override val isRunning: AtomicBoolean

Indicates whether the receiver is running.

Link copied to clipboard

Whether the torch is enabled for attached camera sources; defaults to false.

Link copied to clipboard
open override val screen: Screen

The offscreen renderer for video output.

Functions

Link copied to clipboard
suspend fun attachAudio(track: Int, audio: AudioSource?): Result<Unit>

Replaces the audio source on a track, closing the previous source first.

Link copied to clipboard
suspend fun attachVideo(track: Int, video: VideoSource?): Result<Unit>

Replaces the video source on a track, closing the previous source first.

Link copied to clipboard
suspend fun attachVideos(videos: Map<Int, VideoSource?>): Result<Unit>

Replaces the specified tracks together. All new sources are opened before any is attached to a surface, as required for concurrent Camera2 capture. If replacement fails, the previous configuration is restored and its closed sources are reopened when running.

Link copied to clipboard
fun dispose()

Stops capture, removes screen children, and clears the attached source lists.

Link copied to clipboard
open fun onCreate(owner: LifecycleOwner)
Link copied to clipboard
open fun onDestroy(owner: LifecycleOwner)
Link copied to clipboard
open fun onPause(owner: LifecycleOwner)
Link copied to clipboard
open fun onResume(owner: LifecycleOwner)
Link copied to clipboard
open fun onStart(owner: LifecycleOwner)
Link copied to clipboard
open fun onStop(owner: LifecycleOwner)
Link copied to clipboard
open override fun registerOutput(output: MediaOutput)

Registers an output instance.

Link copied to clipboard
fun setVideoEffect(track: Int, videoEffect: VideoEffect)

Applies an effect to the video screen objects currently assigned to track.

Link copied to clipboard
open override fun startRunning()

Starts capture and schedules attached sources to open asynchronously. Does nothing if already running.

Link copied to clipboard
open override fun stopRunning()

Stops capture and schedules attached sources to close asynchronously. Does nothing if already stopped.

Link copied to clipboard
open override fun unregisterOutput(output: MediaOutput)

Unregisters an output instance. A buffer delivery already in progress can still include this output.