MultiCamera2
Created by pedro on 21/5/21.
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)
MultiCamera2 multiCamera2 = new MultiCamera2(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 MultiCamera2(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):
multiCamera2.startStream(MultiType.RTMP, 1, endpoint); //stream2 is started multiCamera2.stopStream(MultiType.RTSP, 0); //stream3 is stopped multiCamera2.getStreamClient(MultiType.RTMP, 0).retry(delay, reason, backupUrl) //retry stream1
NOTE: If you call this methods nothing is executed:
multiCamera2.startStream(endpoint); multiCamera2.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
Functions
Mute microphone, can be called before, while and after stream.
Enable a muted microphone, can be called before, while and after stream.
Enable OIS video stabilization Warning: Turning both OIS and EIS modes on may produce undesirable interaction, so it is recommended not to enable both at the same time.
Enable EIS video stabilization Warning: Turning both OIS and EIS modes on may produce undesirable interaction, so it is recommended not to enable both at the same time.
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 supported properties of the camera
Get supported resolutions of cameraId in px.
Get supported resolutions of back camera in px.
Get supported resolutions of front camera in px.
Return zoom level range
Get mute state of microphone.
Use getCameraFacing instead
Get record state.
Same to call: prepareAudio(64 * 1024, 32000, true, false, false);
Call this method before use @startStream. If not you will do a stream without audio.
Same to call: isHardwareRotation = true; if (openGlVIew) isHardwareRotation = false; prepareVideo(640, 480, 30, 1200 * 1024, isHardwareRotation, 90);
backward compatibility reason
Call this method before use @startStream. If not you will do a stream without video.
Set an audio effect modifying microphone's PCM buffer.
Set a callback to know errors related with Video/Audio encoders
Set the mode to calculate timestamp. By default CLOCK. Must be called before startRecord/startStream or it will be ignored.
Set video bitrate of H264 in bits per second while stream.
Set zoomIn or zoomOut to camera.
Set zoomIn or zoomOut to camera. Use this method if you use a zoom slider.
Start camera preview. Ignored, if stream or preview is started.
Starts recording a MP4 video.
Need be called after @prepareVideo or/and @prepareAudio. This method override resolution of
Similar to stopPreview but you can do it while streaming or recording.
Stop camera preview. Ignored if streaming or already stopped. You need call it after
Stop record MP4 video started with @startRecord. If you don't call it file will be unreadable.
Stop stream started with @startStream.
Switch camera used. Can be called anytime
Choose a specific camera to use. Can be called anytime.