# MultiOnlyAudio

class MultiOnlyAudio(connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?) : OnlyAudioBase

Created by pedro on 30/5/21.

Support multiple streams in 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)

MultiOnlyAudio multiOnlyAudio = new MultiOnlyAudio(new ConnectChecker[]{ stream1, stream2 }, new ConnectChecker[]{ stream3 });

You can set an empty array or null if you don't want use a protocol new MultiOnlyAudio(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):

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

NOTE: If you call this methods nothing is executed:

multiOnlyAudio.startStream(endpoint); multiOnlyAudio.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

MultiOnlyAudio
Link copied to clipboard
constructor(connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?)

## Properties

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?
streamClient
Link copied to clipboard
open override val streamClient: StreamBaseClient

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

forceCodecType
Link copied to clipboard
open fun forceCodecType(codecTypeAudio: CodecUtil.CodecType?)
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.

resetAudioEncoder
Link copied to clipboard
open fun resetAudioEncoder(): Boolean
resumeRecord
Link copied to clipboard
open fun resumeRecord()
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

setRecordController
Link copied to clipboard
open fun setRecordController(recordController: RecordController?)
setTimestampMode
Link copied to clipboard
open fun setTimestampMode(timestampModeAudio: TimestampMode?)

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

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

Starts recording an AAC audio.

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
@RequiresApi(api = 18)
open fun stopRecord()

Stop record AAC audio 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)