Package com.banuba.sdk.input
Class CameraDevice
- java.lang.Object
-
- com.banuba.sdk.player.VerifyCloseable
-
- com.banuba.sdk.input.CameraDevice
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class CameraDevice extends VerifyCloseable
TheCameraDevice
class used to capture video stream, and photos. It uses the standard CameraX as a camera.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CameraDevice.FrameProvider
static interface
CameraDevice.ICapturedFrameInput
Interface for getting frames from video capture or photo capturestatic interface
CameraDevice.IErrorOccurred
Interface for getting errors
-
Field Summary
-
Fields inherited from class com.banuba.sdk.player.VerifyCloseable
mIsClosed, mTag
-
-
Constructor Summary
Constructors Constructor Description CameraDevice(android.content.Context context, androidx.lifecycle.LifecycleOwner lifecycleOwner)
Creates a camera object but does not start it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addVideoCaptureListener(CameraDevice.ICapturedFrameInput listener)
Add the new video capture listenervoid
close()
CameraDeviceConfigurator
getConfigurator()
Returns the CameraDeviceConfigurator.void
removeVideoCaptureListener(CameraDevice.ICapturedFrameInput listener)
Removes the previously added video capture listenervoid
start()
Starts the camera if it has not been startedvoid
stop()
Stops the camera if it has not been stoppedvoid
takePhoto(CameraDevice.ICapturedFrameInput photoInputCallback, CameraDevice.IErrorOccurred errorCallback)
Takes a photo from the current camera and calls a callback when the photo is available for reading.-
Methods inherited from class com.banuba.sdk.player.VerifyCloseable
finalize
-
-
-
-
Constructor Detail
-
CameraDevice
public CameraDevice(@NonNull android.content.Context context, @NonNull androidx.lifecycle.LifecycleOwner lifecycleOwner)
Creates a camera object but does not start it.- Parameters:
context
- an application context. For the activity can be passed like this: 'this'lifecycleOwner
- activity or application life cycle. For the activity can be passed like this: 'MainActivity.this'
-
-
Method Detail
-
getConfigurator
public CameraDeviceConfigurator getConfigurator()
Returns the CameraDeviceConfigurator. You need to manage the camera settings through it.- Returns:
- CameraDeviceConfigurator
- See Also:
CameraDeviceConfigurator
-
addVideoCaptureListener
public void addVideoCaptureListener(@NonNull CameraDevice.ICapturedFrameInput listener)
Add the new video capture listener- Parameters:
listener
- new video capture listener- See Also:
removeVideoCaptureListener(com.banuba.sdk.input.CameraDevice.ICapturedFrameInput)
-
removeVideoCaptureListener
public void removeVideoCaptureListener(@NonNull CameraDevice.ICapturedFrameInput listener)
Removes the previously added video capture listener- Parameters:
listener
- previously added video capture listener- See Also:
addVideoCaptureListener(com.banuba.sdk.input.CameraDevice.ICapturedFrameInput)
-
takePhoto
public void takePhoto(@NonNull CameraDevice.ICapturedFrameInput photoInputCallback, @Nullable CameraDevice.IErrorOccurred errorCallback)
Takes a photo from the current camera and calls a callback when the photo is available for reading.- Parameters:
photoInputCallback
- callback for processing the photo
-
start
public void start()
Starts the camera if it has not been started
-
stop
public void stop()
Stops the camera if it has not been stopped
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classVerifyCloseable
-
-