# MultiDisplay

@RequiresApi(api = 21)
class MultiDisplay(context: Context, useOpenGL: Boolean, connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?) : DisplayBase

Created by pedro, HirogaKatageri on 2021-05-24.

Experimental Class.

It supports multiple streams of rtmp and rtsp at same time. You must set the same number of ConnectChecker that you want use.

For example. 2 RTMP and 1 RTSP: stream1, stream2, stream3 (stream1 and stream2 are ConnectChecker for RTMP. stream3 is ConnectChecker for RTSP)

MultiDisplay multiDisplay = new MultiDisplay(context, true, new ConnectChecker[]{ stream1, stream2 }, new ConnectChecker[]{ stream3 });

You can set an empty array or null if you don't want to use a specific protocol. new MultiDisplay(context, true, new ConnectChecker[]{ stream1, stream2 }, null); // RTSP protocol is not used

In order to use start, stop and other calls you must send type of stream and index to execute it. Example (using previous example interfaces):

multiDisplay.startStream(MultiType.RTMP, 1, endpoint); //stream2 is started multiDisplay.stopStream(MultiType.RTSP, 0); //stream3 is stopped multiDisplay.getStreamClient(MultiType.RTMP, 0).retry(delay, reason, backupUrl) //retry stream1

NOTE: If you call these methods nothing is executed:

multiDisplay.startStream(endpoint); multiDisplay.stopStream();

The rest of methods without MultiType and index means that you will execute that command in all streams. Read class code if you need info about any method.

## Constructors

MultiDisplay
Link copied to clipboard
constructor(context: Context, useOpenGL: Boolean, connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?)

## Properties

bitrate
Link copied to clipboard
open val bitrate: Int
glInterface
Link copied to clipboard
open val glInterface: GlInterface?
isAudioMuted
Link copied to clipboard
open val isAudioMuted: Boolean
isRecording
Link copied to clipboard
open val isRecording: Boolean
isStreaming
Link copied to clipboard
open val isStreaming: Boolean
recordStatus
Link copied to clipboard
open val recordStatus: RecordController.Status?
resolutionValue
Link copied to clipboard
open val resolutionValue: Int
streamClient
Link copied to clipboard
open override val streamClient: StreamBaseClient
streamHeight
Link copied to clipboard
open val streamHeight: Int
streamWidth
Link copied to clipboard
open val streamWidth: Int

## Functions

disableAudio
Link copied to clipboard
open fun disableAudio()

Mute microphone, can be called before, while and after stream.

enableAudio
Link copied to clipboard
open fun enableAudio()

Enable a muted microphone, can be called before, while and after stream.

forceBt709Color
Link copied to clipboard
open fun forceBt709Color(enabled: Boolean)
forceCodecType
Link copied to clipboard
open fun forceCodecType(codecTypeVideo: CodecUtil.CodecType?, codecTypeAudio: CodecUtil.CodecType?)
forceFpsLimit
Link copied to clipboard
open fun forceFpsLimit(enabled: Boolean)

Force stream to work with fps selected in prepareVideo method. Must be called before prepareVideo. This is not recommend because could produce fps problems.

getStreamClient
Link copied to clipboard
open override fun getStreamClient(): StreamBaseClient
fun getStreamClient(type: MultiType, index: Int): StreamBaseClient
pauseRecord
Link copied to clipboard
open fun pauseRecord()
prepareAudio
Link copied to clipboard
open fun prepareAudio(): Boolean

Same to call: prepareAudio(64 * 1024, 32000, true, false, false);

open fun prepareAudio(bitrate: Int, sampleRate: Int, isStereo: Boolean): Boolean
open fun prepareAudio(bitrate: Int, sampleRate: Int, isStereo: Boolean, echoCanceler: Boolean, noiseSuppressor: Boolean): Boolean
open fun prepareAudio(audioSource: Int, bitrate: Int, sampleRate: Int, isStereo: Boolean, echoCanceler: Boolean, noiseSuppressor: Boolean): Boolean

Call this method before use @startStream. If not you will do a stream without audio.

prepareInternalAudio
Link copied to clipboard
@RequiresApi(api = 29)
open fun prepareInternalAudio(): Boolean
@RequiresApi(api = 29)
open fun prepareInternalAudio(bitrate: Int, sampleRate: Int, isStereo: Boolean): Boolean
@RequiresApi(api = 29)
open fun prepareInternalAudio(bitrate: Int, sampleRate: Int, isStereo: Boolean, echoCanceler: Boolean, noiseSuppressor: Boolean): Boolean

Call this method before use @startStream for streaming internal audio only.

prepareVideo
Link copied to clipboard
open fun prepareVideo(): Boolean

Same to call: rotation = 0; if (Portrait) rotation = 90; prepareVideo(640, 480, 30, 1200 * 1024, true, 0);

open fun prepareVideo(width: Int, height: Int, bitrate: Int): Boolean
open fun prepareVideo(width: Int, height: Int, fps: Int, bitrate: Int, rotation: Int, dpi: Int): Boolean
open fun prepareVideo(width: Int, height: Int, fps: Int, bitrate: Int, rotation: Int, dpi: Int, profile: Int, level: Int, iFrameInterval: Int): Boolean

Call this method before use @startStream. If not you will do a stream without video.

requestKeyFrame
Link copied to clipboard
open fun requestKeyFrame()
resetAudioEncoder
Link copied to clipboard
open fun resetAudioEncoder(): Boolean
resetVideoEncoder
Link copied to clipboard
open fun resetVideoEncoder(): Boolean
resumeRecord
Link copied to clipboard
open fun resumeRecord()
sendIntent
Link copied to clipboard
open fun sendIntent(): Intent?

Create Intent used to init screen capture with startActivityForResult.

setAudioCodec
Link copied to clipboard
open fun setAudioCodec(codec: AudioCodec?)
setCustomAudioEffect
Link copied to clipboard
open fun setCustomAudioEffect(customAudioEffect: CustomAudioEffect?)

Set an audio effect modifying microphone's PCM buffer.

setEncoderErrorCallback
Link copied to clipboard
open fun setEncoderErrorCallback(encoderErrorCallback: CodecErrorCallback?)

Set a callback to know errors related with Video/Audio encoders

setFpsListener
Link copied to clipboard
open fun setFpsListener(callback: FpsListener.Callback?)
setIntentResult
Link copied to clipboard
open fun setIntentResult(resultCode: Int, data: Intent?)
setMediaProjectionCallback
Link copied to clipboard
open fun setMediaProjectionCallback(mediaProjectionCallback: MediaProjection.Callback?)
setRecordController
Link copied to clipboard
open fun setRecordController(recordController: RecordController?)
setTimestampMode
Link copied to clipboard
open fun setTimestampMode(timestampModeVideo: TimestampMode?, timestampModeAudio: TimestampMode?)

Set the mode to calculate timestamp. By default CLOCK. Must be called before startRecord/startStream or it will be ignored.

setVideoBitrateOnFly
Link copied to clipboard
open fun setVideoBitrateOnFly(bitrate: Int)

Set video bitrate of H264 in bits per second while stream.

setVideoCodec
Link copied to clipboard
open fun setVideoCodec(codec: VideoCodec?)
startRecord
Link copied to clipboard
@RequiresApi(api = 26)
open fun startRecord(@NonNull fd: FileDescriptor)
open fun startRecord(@NonNull path: String)
@RequiresApi(api = 26)
open fun startRecord(@NonNull fd: FileDescriptor, @Nullable listener: RecordController.Listener?)
open fun startRecord(@NonNull path: String, @Nullable listener: RecordController.Listener?)

Starts recording a MP4 video.

startStream
Link copied to clipboard
open fun startStream(url: String?)

Need be called after @prepareVideo or/and @prepareAudio.

fun startStream(type: MultiType, index: Int, url: String?)
stopRecord
Link copied to clipboard
open fun stopRecord()

Stop record MP4 video started with @startRecord. If you don't call it file will be unreadable.

stopStream
Link copied to clipboard
open fun stopStream()

Stop stream started with @startStream.

fun stopStream(type: MultiType, index: Int)