MultiFromFile

Created by pedro on 17/7/24.

Experiment class.

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)

MultiFromFile multiFromFile = new MultiFromFile(context, new ConnectChecker[]{ stream1, stream2 }, new ConnectChecker[]{ stream3 });

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

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

NOTE: If you call this methods nothing is executed:

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

Link copied to clipboard
constructor(openGlView: OpenGlView, videoDecoderInterface: VideoDecoderInterface, audioDecoderInterface: AudioDecoderInterface, connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?)
constructor(context: Context, videoDecoderInterface: VideoDecoderInterface, audioDecoderInterface: AudioDecoderInterface, connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?)
constructor(videoDecoderInterface: VideoDecoderInterface, audioDecoderInterface: AudioDecoderInterface, connectCheckerRtmpList: Array<ConnectChecker>?, connectCheckerRtspList: Array<ConnectChecker>?, connectCheckerSrtList: Array<ConnectChecker>?, connectCheckerUdpList: Array<ConnectChecker>?)

Properties

Link copied to clipboard
Link copied to clipboard

Functions

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

Link copied to clipboard
Link copied to clipboard
open fun getAudioTime(): Double
Link copied to clipboard
open fun getBitrate(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getStreamHeight(): Int
Link copied to clipboard
open fun getStreamWidth(): Int
Link copied to clipboard
Link copied to clipboard
open fun getVideoTime(): Double
Link copied to clipboard
Link copied to clipboard
open fun isRecording(): Boolean

Get record state.

Link copied to clipboard
open fun moveTo(time: Double)

Working but it is too slow. You need wait few seconds after call it to continue :(

Link copied to clipboard
open fun pauseRecord()
Link copied to clipboard
open fun playAudioDevice()
Link copied to clipboard
open fun prepareAudio(filePath: String): Boolean
open fun prepareAudio(context: Context, uri: Uri): Boolean
open fun prepareAudio(fileDescriptor: FileDescriptor, bitRate: Int): Boolean
open fun prepareAudio(filePath: String, bitRate: Int): Boolean
open fun prepareAudio(context: Context, uri: Uri, bitRate: Int): Boolean
Link copied to clipboard
open fun prepareVideo(fileDescriptor: FileDescriptor): Boolean
open fun prepareVideo(filePath: String): Boolean
open fun prepareVideo(context: Context, uri: Uri): Boolean
open fun prepareVideo(fileDescriptor: FileDescriptor, bitRate: Int, rotation: Int): Boolean
open fun prepareVideo(filePath: String, bitRate: Int, rotation: Int): Boolean
open fun prepareVideo(context: Context, uri: Uri, bitRate: Int, rotation: Int): Boolean
open fun prepareVideo(fileDescriptor: FileDescriptor, bitRate: Int, rotation: Int, profile: Int, level: Int): Boolean
open fun prepareVideo(filePath: String, bitRate: Int, rotation: Int, profile: Int, level: Int): Boolean
open fun prepareVideo(context: Context, uri: Uri, bitRate: Int, rotation: Int, profile: Int, level: Int): Boolean
Link copied to clipboard
open fun replaceAudioFile(fileDescriptor: FileDescriptor)
open fun replaceAudioFile(filePath: String)
open fun replaceAudioFile(context: Context, uri: Uri)
Link copied to clipboard
open fun replaceVideoFile(fileDescriptor: FileDescriptor)
open fun replaceVideoFile(filePath: String)
open fun replaceVideoFile(context: Context, uri: Uri)
Link copied to clipboard
open fun replaceView(context: Context)
open fun replaceView(openGlView: OpenGlView)
Link copied to clipboard
open fun requestKeyFrame()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun resumeRecord()
Link copied to clipboard
open fun reSyncFile()
Link copied to clipboard
open fun setAudioCodec(codec: AudioCodec)
Link copied to clipboard
open fun setEncoderErrorCallback(encoderErrorCallback: EncoderErrorCallback)

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

Link copied to clipboard
Link copied to clipboard
open fun setLoopMode(loopMode: Boolean)

If you want reproduce video in loop. This mode clear all effects or stream object when video is restarted. TODO: No clear it.

Link copied to clipboard
open fun setRecordController(recordController: BaseRecordController)
Link copied to clipboard
@RequiresApi(api = 19)
open fun setVideoBitrateOnFly(bitrate: Int)

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

Link copied to clipboard
open fun setVideoCodec(codec: VideoCodec)
Link copied to clipboard
@RequiresApi(api = 26)
open fun startRecord(@NonNull fd: FileDescriptor)
open fun startRecord(@NonNull path: String)

Starts recording a MP4 video.

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

Need be called after @prepareVideo.

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

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

Link copied to clipboard
open fun stopStream()

Stop stream started with @startStream.

fun stopStream(type: MultiType, index: Int)