MultiStream
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)
MultiStream multiStream = new MultiStream(openGlView, new ConnectChecker[]{ stream1, stream2 }, new ConnectChecker[]{ stream3 });
You can set an empty array or null if you don't want use a protocol new MultiStream(openGlView, 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):
multiStream.startStream(MultiType.RTMP, 1, endpoint); //stream2 is started multiStream.stopStream(MultiType.RTSP, 0); //stream3 is stopped multiStream.getStreamClient(MultiType.RTMP, 0).retry(delay, reason, backupUrl) //retry stream1
NOTE: If you call this methods nothing is executed:
multiStream.startStream(endpoint); multiStream.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
Properties
Functions
Change audio source. Must be called after prepareAudio.
Change video source to Camera1 or Camera2. Must be called after prepareVideo.
Force stream to work with fps selected in prepareVideo method. Must be called before prepareVideo. This is not recommend because could produce fps problems.
Get glInterface used to render video. This is useful to send filters to stream. Must be called after prepareVideo.
return surface texture that can be used to render and encode custom data. Return null if video not prepared. start and stop rendering must be managed by the user.
Pause record. Ignored if you are not recording.
Force VideoEncoder to produce a keyframe. Ignored if not recording or streaming. This could be ignored depend of the Codec implementation in each device.
Reset AudioEncoder. Only recommended if an AudioEncoder class error is received in the EncoderErrorCallback
Reset VideoEncoder. Only recommended if a VideoEncoder class error is received in the EncoderErrorCallback
Resume record. Ignored if you are not recording and in pause mode.
Change AudioCodec used. This could fail depend of the Codec supported in each Protocol. For example G711 is not supported in SRT
Set a callback to know errors related with Video/Audio encoders
Change stream orientation depend of activity orientation. This method affect to preview and stream. Must be called after prepareVideo.
Replace the current BaseRecordController. This method allow record in other format or even create your custom implementation and record in a new format.
Set the mode to calculate timestamp. By default CLOCK. Must be called before startRecord/startStream or it will be ignored.
Set video bitrate in bits per second while streaming.
Change VideoCodec used. This could fail depend of the Codec supported in each Protocol. For example AV1 is not supported in SRT
Start preview in the selected SurfaceView. Must be called after prepareVideo.
Start preview in the selected TextureView. Must be called after prepareVideo.
Start preview in the selected SurfaceTexture. Must be called after prepareVideo.
Start preview in the selected Surface. Must be called after prepareVideo.
Start record.
Start stream.
Stop preview. Must be called after prepareVideo.