JCVideoCapture

public class JCVideoCapture implements JCVideoCaptureInterface, Camera.PreviewCallback

The JCVideoCapture class implements JCVideoCaptureInterface to access the default Android camera video capture.

Constructors

JCVideoCapture

public JCVideoCapture()

Creates a new JCVideoCapture object to access a particular hardware camera and provide frames for streaming.

Methods

enableHD

public boolean enableHD(boolean enable)

Enable HD or SD when capturing the video

Parameters:
  • enable – boolean to determine HD(ex. 1280x720) or SD(ex. 640x480) quality.
Returns:

true if successfully enabled HD, false otherwise

onPreviewFrame

public void onPreviewFrame(byte[] data, Camera camera)

Called as preview frames are displayed. This callback is invoked on the event thread android.hardware.Camera.open(int) was called from.

If using the android.graphics.ImageFormat.YV12 format, refer to the equations in Camera.Parameters.setPreviewFormat for the arrangement of the pixel data in the preview callback buffers.

Parameters:

resumeCapture

public boolean resumeCapture()

Resume video capture. Generally restart the capture thread if stopped.

Returns:true if success, false otherwise

selectCamera

public boolean selectCamera(int cameraId)

Select the camera id. For example front or back camera. This can be an empty method in a custom stream.

Parameters:
Returns:

true if camera selection was successful, false otherwise

startCapture

public boolean startCapture(int width, int height, int framerate, Context applicationContext, JCVideoCaptureCallback cb)

Start a thread to provide video frames to the system. Parameters are suggestions and can be safely ignored when implementing the method.

Parameters:
  • width – Video frame width
  • height – Video frame height
  • framerate – Frames per second
  • applicationContext – Application context provided in JCClient
  • cb – Callback object used to provide video frame to the system
Returns:

true if successful, false otherwise

stopCapture

public synchronized boolean stopCapture()

Stop the capture thread. Called when app goes into the background.

Returns:true if successful, false otherwise

switchCamera

public boolean switchCamera()

Switch the camera. Used to toggle between front and back camera.

Returns:true if successful, false otherwise