Interface VideoCapturer
-
- All Superinterfaces:
VideoCapturer
- All Known Implementing Classes:
Camera2Capturer
,CameraCapturer
,ScreenCapturer
public interface VideoCapturer extends VideoCapturer
Generic video capturing interface that extendsVideoCapturer
.This interface provides an extension of the WebRTC video capturing interface. Implementations of this interface or
VideoCapturer
can be used when creating local video tracks. As a result, callers can leverage capturers provided by the SDK, capturers provided by WebRTC, or custom capturers.The
LocalVideoTrack
API directly relates to the video capturer programming model. When a caller creates a local video track, the following methods are called in the order listed.VideoCapturer.isScreencast()
- The return value is used to create aVideoSource
.VideoCapturer.initialize(SurfaceTextureHelper, Context, CapturerObserver)
- This method is called so the video capturer can setup to capture frames. The video capturer should retain a reference to the capturer observer and prepare to forward frames. If the video capturer wants to deliver texture frames, it should do this by rendering on the SurfaceTexture provided bysurfaceTextureHelper
, register itself as a listener, and forward the frames to the capturer observer. This method will be called exactly once beforeVideoCapturer.startCapture(int, int, int)
. The local video track retains ownership of thesurfaceTextureHelper
.VideoCapturer.startCapture(int, int, int)
- The video capturer should start capturing in a format as close as possible towidth x height
atframerate
. The video capturer should capture and deliver frames to the capturer observer provided in initialize on a dedicated thread.
When a caller releases a local video track, the following methods are called in the order listed.
VideoCapturer.stopCapture()
- The video capturer should stop capturing frames. The SDK expects this method to block until frames have stopped being captured.VideoCapturer.dispose()
- Perform final cleanup.
Threading Recommendations
Each of these methods are called on the same thread that creates and releases a local video track which for most cases will be the main thread. As a result, video capturers should minimize the amount of work done in each callback and delegate operations on a dedicated thread. A recommended approach would be to create a capturing thread when
VideoCapturer.initialize(SurfaceTextureHelper, Context, CapturerObserver)
is called and then begin capturing and delivering frames to the capturer observer on the capturing thread whenVideoCapturer.startCapture(int, int, int)
is called.Capturers should then stop capturing and join the capturer thread when
VideoCapturer.stopCapture()
} is called.- See Also:
LocalVideoTrack
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default void
changeCaptureFormat(int width, int height, int framerate)
default void
dispose()
This method provides an optional step to perform a final cleanup.default VideoFormat
getCaptureFormat()
-
Methods inherited from interface tvi.webrtc.VideoCapturer
initialize, isScreencast, startCapture, stopCapture
-
-
-
-
Method Detail
-
getCaptureFormat
default VideoFormat getCaptureFormat()
-
changeCaptureFormat
default void changeCaptureFormat(int width, int height, int framerate)
- Specified by:
changeCaptureFormat
in interfaceVideoCapturer
-
dispose
default void dispose()
This method provides an optional step to perform a final cleanup.- Specified by:
dispose
in interfaceVideoCapturer
-
-