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 Object
implements android.view.Choreographer.FrameCallback
Entry point to Banuba SDK.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionBanubaSdkManager
(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
Modifier and TypeMethodDescriptionvoid
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
Clear surface to black colorvoid
Stop camera.static void
Free shared resourcesvoid
doFrame
(long frameTimeNanos) Choreographer callback, called near vsync.void
void
static void
enableDiagnostics
(String outputFolder) Enables performance diagnostics.protected void
finalize()
Get camera direction (facing).com.banuba.sdk.effect_player.EffectManager
com.banuba.sdk.effect_player.EffectPlayer
static String
static void
initialize
(android.content.Context context, String clientTokenString, String... pathsList) Call this once to initialize BanubaSdk.com.banuba.sdk.effect_player.Effect
loadEffect
(String url, boolean synchronous) Load effectstatic List<EffectInfo>
Load all info about effects bundled with the app.void
onSurfaceChanged
(int ignored, int width, int height) void
void
void
Open camera and start frame capturing.void
pause video capture.void
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
Tell manager to release surface (remove callbacks, destroy surface etc.)void
runOnRenderThread
(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
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
void
startEditingImage
(com.banuba.sdk.types.FullImageData image) Start editing image with applying current effect.void
Request to continuously forward rendered frames to `IEventCallback.onFrameRendered`.void
Request to continuously forward rendered frames to `IEventCallback.onTextureRendered` as a OpenGL textures.void
startVideoRecording
(String fileName, boolean captureMic, ContentRatioParams contentRatioParams, float speed) Start video capture with applying current effect.void
void
Stop editing image with applying current effect.void
Stop frame forwarding requested by `startForwardingFrames`.void
Stop frame forwarding requested by `startForwardingTextures`.void
Stop video capture.void
Take edited image with applying current effect.void
takePhoto
(ContentRatioParams contentRatioParams) Take screenshot.void
unloadEffect
(com.banuba.sdk.effect_player.Effect effect) Unload effectvoid
pause video capture.void
-
Field Details
-
EFFECTS_RESOURCES_PATH
- See Also:
-
-
Constructor Details
-
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 Details
-
initialize
public static void initialize(@NonNull android.content.Context context, @NonNull String clientTokenString, @Nullable 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
public static void deinitialize()Free shared resources -
enableDiagnostics
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
Set callback to receive events from SDK -
setCameraFacing
Change camera direction (facing).- Returns:
- `true` if command was passed to command queue
-
setCameraFacing
Change camera direction (facing) and set is mirroring required for that camera.- Returns:
- `true` if command was passed to command queue
-
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
Set camera FPS mode.- Parameters:
mode
-CameraFpsMode
value.
-
setWatermarkInfo
-
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
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
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
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 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:
-
startDebugVideoRecording
-
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
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
-
recycle
public void recycle()Force release of owned native objects -
runOnRenderThread
-
waitOnRenderThread
public void waitOnRenderThread() -
finalize
-