StreamerPipeline

open class StreamerPipeline(val context: Context, val withAudio: Boolean = true, val withVideo: Boolean = true, audioOutputMode: StreamerPipeline.AudioOutputMode = AudioOutputMode.PUSH, val coroutineDispatcher: CoroutineDispatcher = Dispatchers.Default) : IWithVideoSource, IWithVideoRotation, IWithAudioSource

The main pipeline for the streamer.

Parameters

context

the application context

withAudio

whether the streamer has audio. It will create necessary audio components.

withVideo

whether the streamer has video. It will create necessary video components.

audioOutputMode

the audio output mode. It can be AudioOutputMode.PUSH or AudioOutputMode.CALLBACK. Only use AudioOutputMode.CALLBACK when you have a single output and its implements IAudioCallbackPipelineOutputInternal. By default, it is AudioOutputMode.PUSH.

coroutineDispatcher

the coroutine dispatcher

Constructors

Link copied to clipboard
constructor(context: Context, withAudio: Boolean = true, withVideo: Boolean = true, audioOutputMode: StreamerPipeline.AudioOutputMode = AudioOutputMode.PUSH, coroutineDispatcher: CoroutineDispatcher = Dispatchers.Default)

Types

Link copied to clipboard
Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The audio processor. It allows access to advanced audio settings.

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

The audio source. It allows access to advanced audio source settings.

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

Whether the video source has a preview.

Link copied to clipboard
val isStreamingFlow: StateFlow<Boolean>

State flow of the streaming state.

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

The video source. It allows access to advanced video source settings.

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

Functions

Link copied to clipboard
fun <T : IPipelineOutput> addOutput(output: T): T

Adds an output.

Link copied to clipboard
fun createEncodingOutput(withAudio: Boolean = this.withAudio, withVideo: Boolean = this.withVideo, endpointFactory: IEndpointInternal.Factory = DynamicEndpointFactory(), targetRotation: Int = context.displayRotation): IConfigurableAudioVideoEncodingPipelineOutput

Creates and adds an output to the pipeline.

Link copied to clipboard
protected open fun getAspectRatioMode(): AspectRatioMode

Gets the aspect ratio mode to calculate the viewport rectangle.

Link copied to clipboard
protected open fun isMirroringRequired(): Boolean

Whether the output surface needs to be mirrored.

Link copied to clipboard
suspend fun release()

Releases all resources.

Link copied to clipboard

Clean and reset the pipeline synchronously.

Link copied to clipboard
suspend fun removeOutput(output: IPipelineOutput)

Removes an output.

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
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 of all outputs.

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
suspend fun startStream()

Try to start all streams.

Link copied to clipboard

Stops video preview.

Link copied to clipboard
suspend fun stopStream()

Stops all streams.