java.lang.Object | |
↳ | org.opencdnunion.media.streamer.capture.CameraCapture |
The CameraCapture class is used to capture video frames from camera.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | CameraCapture.OnCameraCaptureListener | Notify the event occurred while camera capturing. | |||||||||
class | CameraCapture.Size |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | CAMERA_ERROR_EVICTED | ||||||||||
int | CAMERA_ERROR_SERVER_DIED | ||||||||||
int | CAMERA_ERROR_START_FAILED | ||||||||||
int | CAMERA_ERROR_UNKNOWN | ||||||||||
int | CAMERA_STATE_IDLE | ||||||||||
int | CAMERA_STATE_INITIALIZING | ||||||||||
int | CAMERA_STATE_PREVIEWING | ||||||||||
int | CAMERA_STATE_STOPPING | ||||||||||
int | DEFAULT_PREVIEW_FPS |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static final int | FACING_BACK | ||||||||||
public static final int | FACING_FRONT | ||||||||||
public final SrcPin<ImgBufFrame> | mImgBufSrcPin | Source pin transfer ImgBufFrame, used for fallback cpu path | |||||||||
public final SrcPin<ImgTexFrame> | mImgTexSrcPin | Source pin transfer ImgTexFrame, used for gpu path and preview |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CameraCapture(Context context, GLRender glRender) |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
synchronized void |
autoFocus(Camera.AutoFocusCallback cb)
Starts camera auto-focus and registers a callback function to run
when the camera is focused.
| ||||||||||
synchronized void |
cancelAutoFocus()
Cancels any auto-focus function in progress.Whether or not auto-focus is currently
in progress,this function will return the focus position to the default.
| ||||||||||
int |
getCameraDisplayOrientation()
Get camera display orientation.
| ||||||||||
int | getCameraFacing() | ||||||||||
synchronized Camera.Parameters |
getCameraParameters()
Get parameters of current camera.
| ||||||||||
float |
getCurrentPreviewFps()
Get actual preview fps in the last second.
| ||||||||||
int |
getState()
Get current mState.
| ||||||||||
float |
getTargetPreviewFps()
Get actual preview fps set to camera.
| ||||||||||
CameraCapture.Size |
getTargetPreviewSize()
Get actual preview size currently used
| ||||||||||
boolean |
isRecording()
Is recording.
| ||||||||||
synchronized boolean |
isTorchSupported()
Check if flash torch mode supported of current camera.
| ||||||||||
void | onFrameAvailable(SurfaceTexture surfaceTexture) | ||||||||||
synchronized void |
release()
Clean resources.
| ||||||||||
synchronized boolean |
setCameraParameters(Camera.Parameters parameters)
Set new parameters to current camera.
| ||||||||||
synchronized void |
setCameraParametersAsync(Camera.Parameters parameters)
Set new parameters to current camera asynchronous.
| ||||||||||
void |
setEnableExposureWorkaround(boolean enableExposureWorkaround)
Fix dark preview in some device(such as Pixel) with 24/30fps.
| ||||||||||
void |
setEnableFrameDrop(boolean enableFrameDrop)
Drop frame if the real preview fps greater than the set value.
| ||||||||||
void |
setOnCameraCaptureListener(CameraCapture.OnCameraCaptureListener listener)
Set CameraCapture Listener.
| ||||||||||
void | setOnPreviewFrameListener(OnPreviewFrameListener listener) | ||||||||||
void |
setOrientation(int degrees)
Set preview orientation.
| ||||||||||
void |
setPreviewFps(float fps)
Set preset preview fps.
| ||||||||||
void |
setPreviewSize(int width, int height)
Set preset preview size of camera preview.
| ||||||||||
void | setSpeed(float speed) | ||||||||||
synchronized void |
start(int facing)
Start camera preview.
| ||||||||||
void |
startRecord()
start recording
| ||||||||||
synchronized void |
stop()
Stop camera preview.
| ||||||||||
void |
stopRecord()
stop recording
| ||||||||||
synchronized boolean |
switchCamera()
Switch front/back camera if supported.
| ||||||||||
synchronized boolean |
toggleTorch(boolean open)
Toggle torch of current camera.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Source pin transfer ImgBufFrame, used for fallback cpu path
Source pin transfer ImgTexFrame, used for gpu path and preview
Starts camera auto-focus and registers a callback function to run
when the camera is focused.
Should be called on state CAMERA_STATE_PREVIEWING
.
cb | the callback to run |
---|
Cancels any auto-focus function in progress.Whether or not auto-focus is currently
in progress,this function will return the focus position to the default.
If the camera does not support auto-focus, this is a no-op.
Should be called on state CAMERA_STATE_PREVIEWING
.
Get camera display orientation.
Should be called after start(int)
Get parameters of current camera.
Should be called on state CAMERA_STATE_PREVIEWING
.
Get actual preview fps in the last second.
Get current mState.
Get actual preview size currently used
Is recording.
Check if flash torch mode supported of current camera.
Should be called after onStarted()
called.
Clean resources.
After this call, this object should not be accessed any more.
Set new parameters to current camera.
Should be called on state CAMERA_STATE_PREVIEWING
.
parameters | Camera parameters to be set. |
---|
Set new parameters to current camera asynchronous.
Should be called on state CAMERA_STATE_PREVIEWING
.
parameters | Camera parameters to be set. |
---|
Fix dark preview in some device(such as Pixel) with 24/30fps.
enableExposureWorkaround | true to enable, false to disable, default: true |
---|
Drop frame if the real preview fps greater than the set value.
enableFrameDrop | true to enable, false to disable, default: true |
---|
Set CameraCapture Listener.
Should be set before call start(int)
listener | listener implemented by user |
---|
Set preview orientation.
Should be set before call start(int)
degrees | the rotate degrees of current Activity. Acceptable value: 0, 90, 180, 270, other values will be ignored. Default value is 0. |
---|
Set preset preview fps.
Should be set before call start(int)
The preset fps may be different with the value finally used for preview.
The actual preview fps can be get by getTargetPreviewFps()
after
onStarted()
called.
fps | preset fps, default value is 15.0f |
---|
Set preset preview size of camera preview.
Should be set before call start(int)
The preset value may be different with the value finally used for preview.
The actual preview size can be get by getTargetPreviewSize()
after
onStarted()
called.
width | preset width, default value is 1280 |
---|---|
height | preset height, default value is 720 |
Start camera preview.
Can only be called on mState IDLE.
facing | camera facing, acceptable value FACING_BACK , FACING_FRONT
|
---|
start recording
Stop camera preview.
Can be called on mState CAMERA_STATE_INITIALIZING
,
CAMERA_STATE_PREVIEWING
.
stop recording
Switch front/back camera if supported.
Toggle torch of current camera.
open | true to turn on, false to turn off. |
---|