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
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBanubaSdkManager(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 TypeMethodDescriptionvoidattachSurface(android.view.Surface surface) You must manually call `onSurfaceDestroyed`, `onSurfaceCreated`, `onSurfaceChanged`.voidattachSurface(android.view.SurfaceView surfaceView) This method will add callback to `surfaceView.getHolder().addCallback`.voidClear surface to black colorvoidStop camera.static voidFree shared resourcesvoiddoFrame(long frameTimeNanos) Choreographer callback, called near vsync.voidvoidstatic voidenableDiagnostics(String outputFolder) Enables performance diagnostics.protected voidfinalize()Get camera direction (facing).com.banuba.sdk.effect_player.EffectManagercom.banuba.sdk.effect_player.EffectPlayerstatic Stringstatic voidinitialize(android.content.Context context, String clientTokenString, String... pathsList) Call this once to initialize BanubaSdk.com.banuba.sdk.effect_player.EffectloadEffect(String url, boolean synchronous) Load effectstatic List<EffectInfo>Load all info about effects bundled with the app.voidonSurfaceChanged(int ignored, int width, int height) voidvoidvoidOpen camera and start frame capturing.voidpause video capture.voidTake high resolution photo from camera and apply effect on it.voidprocessImage(com.banuba.sdk.types.FullImageData image) Process image and apply current selected effect on it.voidrecycle()Force release of owned native objectsvoidTell manager to release surface (remove callbacks, destroy surface etc.)voidrunOnRenderThread(Runnable runnable) voidsetAutoFaceOrientation(boolean on) Enables or disables automatic update of expected face orientation based on device orientationvoidsetCallback(IEventCallback callback) Set callback to receive events from SDKbooleansetCameraFacing(Facing facing) Change camera direction (facing).booleansetCameraFacing(Facing facing, boolean requireMirroring) Change camera direction (facing) and set is mirroring required for that camera.voidSet camera FPS mode.voidsetCameraZoom(float cameraZoom) Change camera zoom factor.voidsetFlashlightEnabled(boolean enabled) voidsetRequireMirroring(boolean requireMirroring) Set is mirroring required.voidsetWatermarkInfo(WatermarkInfo watermarkInfo) voidvoidstartEditingImage(com.banuba.sdk.types.FullImageData image) Start editing image with applying current effect.voidRequest to continuously forward rendered frames to `IEventCallback.onFrameRendered`.voidRequest to continuously forward rendered frames to `IEventCallback.onTextureRendered` as a OpenGL textures.voidstartVideoRecording(String fileName, boolean captureMic, ContentRatioParams contentRatioParams, float speed) Start video capture with applying current effect.voidvoidStop editing image with applying current effect.voidStop frame forwarding requested by `startForwardingFrames`.voidStop frame forwarding requested by `startForwardingTextures`.voidStop video capture.voidTake edited image with applying current effect.voidtakePhoto(ContentRatioParams contentRatioParams) Take screenshot.voidunloadEffect(com.banuba.sdk.effect_player.Effect effect) Unload effectvoidpause 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:
doFramein 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-CameraFpsModevalue.
-
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
-