Package com.banuba.sdk.manager
Class BanubaSdkManager
- java.lang.Object
-
- com.banuba.sdk.manager.BanubaSdkManager
-
- All Implemented Interfaces:
android.view.Choreographer.FrameCallback
public final class BanubaSdkManager extends java.lang.Object implements android.view.Choreographer.FrameCallback
Entry point to Banuba SDK.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BanubaSdkManager.Consumer<T>
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EFFECTS_RESOURCES_PATH
-
Constructor Summary
Constructors Constructor Description BanubaSdkManager(android.content.Context context)
Constructs BanubaSdk instance.BanubaSdkManager(android.content.Context context, BanubaSdkManagerConfiguration sdkManagerConfiguration)
Constructs BanubaSdk instance.BanubaSdkManager(android.content.Context context, IResolutionController resolutionController)
Constructs BanubaSdk instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attachSurface(android.view.Surface surface)
You must manually call `onSurfaceDestroyed`, `onSurfaceCreated`, `onSurfaceChanged`.void
attachSurface(android.view.SurfaceView surfaceView)
This method will add callback to `surfaceView.getHolder().addCallback`.void
clearSurface()
Clear surface to black colorvoid
closeCamera()
Stop camera.static void
deinitialize()
Free shared resourcesvoid
doFrame(long frameTimeNanos)
Choreographer callback, called near vsync.void
effectPlayerPause()
void
effectPlayerPlay()
static void
enableDiagnostics(java.lang.String outputFolder)
Enables performance diagnostics.protected void
finalize()
Facing
getCameraFacing()
Get camera direction (facing).com.banuba.sdk.effect_player.EffectManager
getEffectManager()
com.banuba.sdk.effect_player.EffectPlayer
getEffectPlayer()
static java.lang.String
getResourcesBase()
static void
initialize(android.content.Context context, java.lang.String clientTokenString, java.lang.String... pathsList)
Call this once to initialize BanubaSdk.com.banuba.sdk.effect_player.Effect
loadEffect(java.lang.String url, boolean synchronous)
Load effectstatic java.util.List<EffectInfo>
loadEffects()
Load all info about effects bundled with the app.void
onSurfaceChanged(int ignored, int width, int height)
void
onSurfaceCreated()
void
onSurfaceDestroyed()
void
openCamera()
Open camera and start frame capturing.void
pauseVideoRecording()
pause video capture.void
processCameraPhoto()
Take high resolution photo from camera and apply effect on it.void
processImage(com.banuba.sdk.types.FullImageData image)
Process image and apply current selected effect on it.void
recycle()
Force release of owned native objectsvoid
releaseSurface()
Tell manager to release surface (remove callbacks, destroy surface etc.)void
runOnRenderThread(java.lang.Runnable runnable)
void
setAutoFaceOrientation(boolean on)
Enables or disables automatic update of expected face orientation based on device orientationvoid
setCallback(IEventCallback callback)
Set callback to receive events from SDKboolean
setCameraFacing(Facing facing)
Change camera direction (facing).boolean
setCameraFacing(Facing facing, boolean requireMirroring)
Change camera direction (facing) and set is mirroring required for that camera.void
setCameraFpsMode(CameraFpsMode mode)
Set camera FPS mode.void
setCameraZoom(float cameraZoom)
Change camera zoom factor.void
setFlashlightEnabled(boolean enabled)
void
setRequireMirroring(boolean requireMirroring)
Set is mirroring required.void
setWatermarkInfo(WatermarkInfo watermarkInfo)
void
startDebugVideoRecording(DebugVideoCallbackListener listener)
void
startEditingImage(com.banuba.sdk.types.FullImageData image)
Start editing image with applying current effect.void
startForwardingFrames()
Request to continuously forward rendered frames to `IEventCallback.onFrameRendered`.void
startForwardingTextures()
Request to continuously forward rendered frames to `IEventCallback.onTextureRendered` as a OpenGL textures.void
startVideoRecording(java.lang.String fileName, boolean captureMic, ContentRatioParams contentRatioParams, float speed)
Start video capture with applying current effect.void
stopDebugVideoRecording()
void
stopEditingImage()
Stop editing image with applying current effect.void
stopForwardingFrames()
Stop frame forwarding requested by `startForwardingFrames`.void
stopForwardingTextures()
Stop frame forwarding requested by `startForwardingTextures`.void
stopVideoRecording()
Stop video capture.void
takeEditedImage()
Take edited image with applying current effect.void
takePhoto(ContentRatioParams contentRatioParams)
Take screenshot.void
unloadEffect(com.banuba.sdk.effect_player.Effect effect)
Unload effectvoid
unpauseVideoRecording()
pause video capture.void
waitOnRenderThread()
-
-
-
Field Detail
-
EFFECTS_RESOURCES_PATH
public static final java.lang.String EFFECTS_RESOURCES_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BanubaSdkManager
public BanubaSdkManager(@NonNull android.content.Context context)
Constructs BanubaSdk instance. Enables auto face orientation feature.- Parameters:
context
- Android context
-
BanubaSdkManager
public BanubaSdkManager(@NonNull android.content.Context context, @NonNull BanubaSdkManagerConfiguration sdkManagerConfiguration)
Constructs BanubaSdk instance. Enables auto face orientation feature.- Parameters:
context
- Android contextsdkManagerConfiguration
- can change sdk manager configuration
-
BanubaSdkManager
public BanubaSdkManager(@NonNull android.content.Context context, @Nullable IResolutionController resolutionController)
Constructs BanubaSdk instance. Enables auto face orientation feature.- Parameters:
context
- Android contextresolutionController
- can change default resolution
-
-
Method Detail
-
initialize
public static void initialize(@NonNull android.content.Context context, @NonNull java.lang.String clientTokenString, @Nullable java.lang.String... pathsList)
Call this once to initialize BanubaSdk.- Parameters:
context
- Android contextclientTokenString
- client token stringpathsList
- list of paths to prepend before resource- See Also:
deinitialize()
-
deinitialize
public static void deinitialize()
Free shared resources
-
enableDiagnostics
public static void enableDiagnostics(java.lang.String outputFolder)
Enables performance diagnostics. Don't call before initialize.- Parameters:
outputFolder
- path for performance diagrams
-
doFrame
public void doFrame(long frameTimeNanos)
Choreographer callback, called near vsync.- Specified by:
doFrame
in interfaceandroid.view.Choreographer.FrameCallback
- See Also:
Choreographer.FrameCallback.doFrame(long)
-
setCallback
public void setCallback(IEventCallback callback)
Set callback to receive events from SDK
-
setCameraFacing
public boolean setCameraFacing(@NonNull Facing facing)
Change camera direction (facing).- Returns:
- `true` if command was passed to command queue
-
setCameraFacing
public boolean setCameraFacing(@NonNull Facing facing, boolean requireMirroring)
Change camera direction (facing) and set is mirroring required for that camera.- Returns:
- `true` if command was passed to command queue
-
getCameraFacing
public Facing getCameraFacing()
Get camera direction (facing).- Returns:
- camera direction (facing): FRONT or BACK
-
setCameraZoom
public void setCameraZoom(float cameraZoom)
Change camera zoom factor.
-
setAutoFaceOrientation
public void setAutoFaceOrientation(boolean on)
Enables or disables automatic update of expected face orientation based on device orientation
-
setRequireMirroring
public void setRequireMirroring(boolean requireMirroring)
Set is mirroring required.- Parameters:
requireMirroring
- Is mirroring required value.
-
setCameraFpsMode
public void setCameraFpsMode(@NonNull CameraFpsMode mode)
Set camera FPS mode.- Parameters:
mode
-CameraFpsMode
value.
-
setWatermarkInfo
public void setWatermarkInfo(WatermarkInfo watermarkInfo)
-
effectPlayerPlay
public void effectPlayerPlay()
-
effectPlayerPause
public void effectPlayerPause()
-
setFlashlightEnabled
public void setFlashlightEnabled(boolean enabled)
-
openCamera
public void openCamera()
Open camera and start frame capturing. It is safe to call this method if camera is already opened.
-
closeCamera
public void closeCamera()
Stop camera. Call this method when you don't need input from camera (e.g. in background).
-
releaseSurface
public void releaseSurface()
Tell manager to release surface (remove callbacks, destroy surface etc.)
-
attachSurface
public void attachSurface(android.view.Surface surface)
You must manually call `onSurfaceDestroyed`, `onSurfaceCreated`, `onSurfaceChanged`. Consider `attachSurface(SurfaceView surfaceView)` which will do this for you.- Parameters:
surface
- pass `Surface` to draw effect on.
-
attachSurface
public void attachSurface(android.view.SurfaceView surfaceView)
This method will add callback to `surfaceView.getHolder().addCallback`. If you will handle lifecycle changes yourself (or you don't have `SurfaceView`) just use `attachSurface(Surface surface)`.- Parameters:
surfaceView
-
-
clearSurface
public void clearSurface()
Clear surface to black color
-
loadEffects
public static java.util.List<EffectInfo> loadEffects()
Load all info about effects bundled with the app. This method will search for effects here: `assets/effects` and `assets/bnb-resources/effects`.- Returns:
- list of available effects
-
loadEffect
@Nullable public com.banuba.sdk.effect_player.Effect loadEffect(java.lang.String url, boolean synchronous)
Load effect- Parameters:
url
- path to effectsynchronous
- block the call until effect is loaded- Returns:
- effect instance
-
unloadEffect
public void unloadEffect(com.banuba.sdk.effect_player.Effect effect)
Unload effect- Parameters:
effect
- which should be unloaded
-
onSurfaceCreated
public void onSurfaceCreated()
-
onSurfaceChanged
public void onSurfaceChanged(int ignored, int width, int height)
-
onSurfaceDestroyed
public void onSurfaceDestroyed()
-
takePhoto
public void takePhoto(@Nullable ContentRatioParams contentRatioParams)
Take screenshot. Will push the result in `IEventCallback`- Parameters:
contentRatioParams
- if not specified, default params applied
-
processCameraPhoto
public void processCameraPhoto()
Take high resolution photo from camera and apply effect on it. You will get result in `IEventCallback`.This call will stop camera session. In most cases this what you need as the next step is to display processed ph0to to user in other screen.
-
processImage
public void processImage(@NonNull com.banuba.sdk.types.FullImageData image)
Process image and apply current selected effect on it. You will get result in `IEventCallback`.- Parameters:
image
-
-
startVideoRecording
public void startVideoRecording(@Nullable java.lang.String fileName, boolean captureMic, @Nullable ContentRatioParams contentRatioParams, float speed)
Start video capture with applying current effect.Note, that one of parameters (
fileName
,videoWithWatermarkFileName
) should be non-null.- Parameters:
captureMic
-speed
- increase or decrease video and sound speed (ex. 0.5, 1.5, 3.0 etc)contentRatioParams
- if not specified, default params applied- See Also:
stopVideoRecording()
-
startDebugVideoRecording
public void startDebugVideoRecording(@NonNull DebugVideoCallbackListener listener)
-
stopDebugVideoRecording
public void stopDebugVideoRecording()
-
stopVideoRecording
public void stopVideoRecording()
Stop video capture. You will gent result in `IEventCallback.onVideoRecordingFinished`.
-
pauseVideoRecording
public void pauseVideoRecording()
pause video capture.
-
unpauseVideoRecording
public void unpauseVideoRecording()
pause video capture.
-
startForwardingFrames
public void startForwardingFrames()
Request to continuously forward rendered frames to `IEventCallback.onFrameRendered`.
-
stopForwardingFrames
public void stopForwardingFrames()
Stop frame forwarding requested by `startForwardingFrames`.
-
startForwardingTextures
public void startForwardingTextures()
Request to continuously forward rendered frames to `IEventCallback.onTextureRendered` as a OpenGL textures.
-
stopForwardingTextures
public void stopForwardingTextures()
Stop frame forwarding requested by `startForwardingTextures`.
-
startEditingImage
public void startEditingImage(@NonNull com.banuba.sdk.types.FullImageData image)
Start editing image with applying current effect.- Parameters:
image
-- See Also:
stopEditingImage()
-
stopEditingImage
public void stopEditingImage()
Stop editing image with applying current effect.
-
takeEditedImage
public void takeEditedImage()
Take edited image with applying current effect. You will get result in `IEventCallback`.
-
getEffectPlayer
public com.banuba.sdk.effect_player.EffectPlayer getEffectPlayer()
-
getEffectManager
@NonNull public com.banuba.sdk.effect_player.EffectManager getEffectManager()
-
getResourcesBase
public static java.lang.String getResourcesBase()
-
recycle
public void recycle()
Force release of owned native objects
-
runOnRenderThread
public void runOnRenderThread(java.lang.Runnable runnable)
-
waitOnRenderThread
public void waitOnRenderThread()
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-