public interface VideoCapturer extends VideoCapturer
VideoCapturer
.
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 a
VideoSource
.
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 by surfaceTextureHelper
, register
itself as a listener, and forward the frames to the capturer observer. This method will be
called exactly once before VideoCapturer.startCapture(int, int, int)
.
The local video track retains ownership of the surfaceTextureHelper
.
VideoCapturer.startCapture(int, int, int)
- The video capturer should
start capturing in a format as close as possible to width x height
at framerate
. 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
when VideoCapturer.startCapture(int, int, int)
is called.
Capturers should then stop capturing and join the capturer thread when VideoCapturer.stopCapture()
} is called.
LocalVideoTrack
Modifier and Type | Method and 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() |
initialize, isScreencast, startCapture, stopCapture
default VideoFormat getCaptureFormat()
default void changeCaptureFormat(int width, int height, int framerate)
changeCaptureFormat
in interface VideoCapturer
default void dispose()
dispose
in interface VideoCapturer
6.0.0