DualStreamer

open class DualStreamer(val context: Context, val withAudio: Boolean = true, val withVideo: Boolean = true, firstEndpointFactory: IEndpointInternal.Factory = DynamicEndpointFactory(), secondEndpointFactory: IEndpointInternal.Factory = DynamicEndpointFactory(), defaultRotation: Int = context.displayRotation) : IDualStreamer, IAudioDualStreamer, IVideoDualStreamer

A class that handles 2 outputs.

For example, you can use it to live stream and record simultaneously.

Parameters

context

the application context

withAudio

Boolean.true to capture audio. It can't be changed after instantiation.

withVideo

Boolean.true to capture video. It can't be changed after instantiation.

firstEndpointFactory

the IEndpointInternal implementation of the first output. By default, it is a DynamicEndpoint.

secondEndpointFactory

the IEndpointInternal implementation of the second output. By default, it is a DynamicEndpoint.

defaultRotation

the default rotation in Surface rotation (Surface.ROTATION_0, ...). By default, it is the current device orientation.

Constructors

Link copied to clipboard
constructor(context: Context, withAudio: Boolean = true, withVideo: Boolean = true, firstEndpointFactory: IEndpointInternal.Factory = DynamicEndpointFactory(), secondEndpointFactory: IEndpointInternal.Factory = DynamicEndpointFactory(), defaultRotation: Int = context.displayRotation)

Properties

Link copied to clipboard

Advanced settings for the audio processor.

Link copied to clipboard
open override val audioSourceFlow: StateFlow<IAudioSource?>

An audio source flow to access to advanced settings.

Link copied to clipboard
protected val context: Context
Link copied to clipboard

First output of the streamer.

Link copied to clipboard
open override val isOpenFlow: StateFlow<Boolean>

Whether any of the output is opening.

Link copied to clipboard

Whether the video source has a preview.

Link copied to clipboard
open override val isStreamingFlow: StateFlow<Boolean>

Whether any of the output is streaming.

Link copied to clipboard

Second output of the streamer.

Link copied to clipboard
open override val throwableFlow: StateFlow<Throwable?>

Returns the last throwable that occurred.

Link copied to clipboard
open override val videoSourceFlow: StateFlow<IVideoSource?>

A video source flow to access to advanced settings.

Link copied to clipboard
val withAudio: Boolean = true
Link copied to clipboard
val withVideo: Boolean = true

Functions

Link copied to clipboard
open suspend override fun close()

Closes the outputs. Same as calling first.close and second.close.

Link copied to clipboard
open suspend override fun release()

Clean and reset the streamer.

Link copied to clipboard

Clean and reset the streamer synchronously.

Link copied to clipboard

Sets activity result from ComponentActivity.registerForActivityResult callback.

Link copied to clipboard
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
open suspend override fun setAudioConfig(audioConfig: DualStreamerAudioConfig)

Sets audio configuration.

Link copied to clipboard
open suspend override fun setAudioSource(audioSourceFactory: IAudioSourceInternal.Factory)

Sets the audio source.

Link copied to clipboard
@RequiresPermission(value = "android.permission.CAMERA")
suspend fun IWithVideoSource.setCameraId(cameraId: String)

Sets the camera id.

Link copied to clipboard
@RequiresPermission(value = "android.permission.RECORD_AUDIO")
suspend fun setConfig(audioConfig: DualStreamerAudioConfig, videoConfig: DualStreamerVideoConfig)

Configures both video and audio settings.

Link copied to clipboard
suspend fun IWithVideoSource.setPreview(surface: Surface)

Sets the preview surface.

suspend fun IWithVideoSource.setPreview(surfaceHolder: SurfaceHolder)

Sets a preview surface holder.

suspend fun IWithVideoSource.setPreview(surfaceView: SurfaceView)
suspend fun IWithVideoSource.setPreview(textureView: TextureView)

Sets a preview surface.

Link copied to clipboard
open suspend override fun setTargetRotation(rotation: Int)

Sets the target rotation.

Link copied to clipboard
open suspend override fun setVideoConfig(videoConfig: DualStreamerVideoConfig)

Sets video configuration.

Link copied to clipboard
open suspend override fun setVideoSource(videoSourceFactory: IVideoSourceInternal.Factory)

Sets the video source.

Link copied to clipboard

Starts video preview.

suspend fun IWithVideoSource.startPreview(surface: Surface)
@RequiresPermission(value = "android.permission.CAMERA")
suspend fun IWithVideoSource.startPreview(surfaceHolder: SurfaceHolder)
@RequiresPermission(value = "android.permission.CAMERA")
suspend fun IWithVideoSource.startPreview(surfaceView: SurfaceView)
@RequiresPermission(value = "android.permission.CAMERA")
suspend fun IWithVideoSource.startPreview(textureView: TextureView)

Sets preview surface and start video preview.

Link copied to clipboard
open suspend override fun startStream()

Starts audio/video stream.

Link copied to clipboard

Stops video preview.

Link copied to clipboard
open suspend override fun stopStream()

Stops audio/video stream.