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.
  • Field Details

  • 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 context
      sdkManagerConfiguration - 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 context
      resolutionController - 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 context
      clientTokenString - client token string
      pathsList - list of paths to prepend before resource
      See Also:
    • deinitialize

      public static void deinitialize()
      Free shared resources
    • enableDiagnostics

      public static void enableDiagnostics(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 interface android.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 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(String url, boolean synchronous)
      Load effect
      Parameters:
      url - path to effect
      synchronous - 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 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

      public void startDebugVideoRecording(@NonNull DebugVideoCallbackListener listener)
    • stopDebugVideoRecording

      public void stopDebugVideoRecording()
    • stopVideoRecording

      public void stopVideoRecording()
      Stop video capture. You will gent result in `IEventCallback.onVideoRecordingFinished`.
      See Also:
    • pauseVideoRecording

      public void pauseVideoRecording()
      pause video capture.
      See Also:
    • unpauseVideoRecording

      public void unpauseVideoRecording()
      pause video capture.
      See Also:
    • 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.
      See Also:
    • 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 String getResourcesBase()
    • recycle

      public void recycle()
      Force release of owned native objects
    • runOnRenderThread

      public void runOnRenderThread(Runnable runnable)
    • waitOnRenderThread

      public void waitOnRenderThread()
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable