Interface VideoCapturer

All Superinterfaces:
All Known Implementing Classes:
Camera2Capturer, CameraCapturer, ScreenCapturer

public interface VideoCapturer extends VideoCapturer
Generic video capturing interface that extends 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.

  1. VideoCapturer.isScreencast() - The return value is used to create a VideoSource.
  2. 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.
  3. 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.

  1. VideoCapturer.stopCapture() - The video capturer should stop capturing frames. The SDK expects this method to block until frames have stopped being captured.
  2. 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.

See Also:
  • Method Details

    • getCaptureFormat

      default VideoFormat getCaptureFormat()
    • changeCaptureFormat

      default void changeCaptureFormat(int width, int height, int framerate)
      Specified by:
      changeCaptureFormat in interface VideoCapturer
    • dispose

      default void dispose()
      This method provides an optional step to perform a final cleanup.
      Specified by:
      dispose in interface VideoCapturer