Package 

Class CameraCapturer

  • All Implemented Interfaces:
    com.twilio.video.VideoCapturer , tvi.webrtc.VideoCapturer

    
    public class CameraCapturer
     implements VideoCapturer
                        

    The CameraCapturer class is used to provide video frames for a LocalVideoTrack from a given cameraId. The frames are provided via the preview API of .

    This class represents an implementation of a VideoCapturer interface. Although public, these methods are not meant to be invoked directly.

    Note: This capturer can be reused, but cannot be shared across multiple s simultaneously.

    • Constructor Detail

      • CameraCapturer

        CameraCapturer(Context context, String cameraId)
        Constructs a CameraCapturer instance.
        Parameters:
        context - application context
        cameraId - unique identifier of the camera device to open that must be specified ingetDeviceNames
      • CameraCapturer

        CameraCapturer(Context context, String cameraId, CameraCapturer.Listener listener)
        Constructs a CameraCapturer instance.
        Parameters:
        context - application context
        cameraId - unique identifier of the camera device to open that must be specified ingetDeviceNames
        listener - an optional listener of camera capturer events
    • Method Detail

      • isScreencast

         boolean isScreencast()

        Indicates that the camera capturer is not a screen cast.

      • startCapture

         void startCapture(int width, int height, int framerate)
      • stopCapture

         void stopCapture()

        Stops all frames being captured. The android.hardware.Camera interface should beavailable for use upon completion.

        Note: This method is not meant to be invoked directly.

      • dispose

         void dispose()

        This method provides an optional step to perform a final cleanup.

      • switchCamera

         synchronized void switchCamera(@NonNull() String newCameraId)

        Switches the current cameraId. This method can be invoked while capturing frames ornot.

        Parameters:
        newCameraId - the new camera id.
      • updateCameraParameters

         synchronized boolean updateCameraParameters(@NonNull() CameraParameterUpdater cameraParameterUpdater)

        Schedules a camera parameter update. The current camera's will be provided for modification via . Any changes to the parameters will beapplied after the invocation of this callback. This method can be invoked while capturingframes or not.

        The following snippet demonstrates how to turn on the flash of a camera while capturing.

         // Create camera capturer CameraCapturer cameraCapturer = new CameraCapturer(context, cameraId, null); // Start camera capturer LocalVideoTrack cameraVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer); // Schedule camera parameter update cameraCapturer.updateCameraParameters(new CameraParameterUpdater() { {@literal @}Override public void apply(Camera.Parameters cameraParameters) { // Ensure camera supports flash and turn on if (cameraParameters.getFlashMode() != null) { cameraParameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); } } }); 
        Parameters:
        cameraParameterUpdater - camera parameter updater that receives current cameraparameters for modification.