Banuba SDK Android
Banuba SDK delivery includes the following parts: banuba_sdk.aar
and banuba_effect_player.aar
.
banuba_effect_player.aar
provides a relatively low-level cross-platform API described in the API reference.
banuba_sdk.aar
is built on top of banuba_effect_player.aar
. This library provides the Android-specific functionality.
banuba_effect_player.aar
provided in a compiled form and banuba_sdk.aar
in sources are available for your reference and fine-tuning.
The entry point to banuba_sdk.aar
library is BanubaSdkManager class. This class provides the following functionality:
- Configure rendering mode —
setDrawSize
,setAutoFaceOrientation
,setFaceOrientation
. - Set up the watermark —
setWatermarkInfo
. - Manage camera —
openCamera
,closeCamera
,setCameraFacing
,setCameraZoom
,notifyGotCameraPermissions
. - Open GL context management —
releaseSurface
,attachSurface
,onSurfaceCreated
,onSurfaceChanged
,onSurfaceChanged
,onSurfaceDestroyed
. - Take a screenshot or image with the effect using the camera —
takePhoto
,processCameraPhoto
. - Apply the effect to an external image (e.g. from disk) —
processImage
. - Record a video with the effect —
startVideoRecording
,stopVideoRecording
. - Continuous photo rendering (i.e. the dynamic effect applied to the frozen image) —
startEditingImage
,stopEditingImage
,takeEditedImage
- Send frames to other destinations (e.g. via WebRTC) —
startForwardingFrames
,stopForwardingFrames
.
banuba_sdk
contains the following packages:
internal.camera
— the functionality related to the camera capture. SeeCamera2
andCameraThread
.internal.encoding
— audio and video capture and recording.internal.gl
— various Open GL ES utils.internal.photo
— screenshot capture.internal.renderer
— rendering thread. SeeRenderThread
.
The Effect component makes up an essential part of the SDK usage. It's represented as a folder with scripts and resources. Please, refer to Android demo app section for more details about effects.
Configuring watermark
If you want to apply watermark to your photos, you should use mSdkManager.takePhoto(...)
method.
Drawable watermarkDrawable = ContextCompat.getDrawable(this, R.drawable.my_watermark_resource);
int watermarkWidth = 101;
int watermarkHeight = 24;
float aspectRatio = watermarkWidth / watermarkHeight;
SizeProvider provider = viewportSize -> {
int targetWidth = (int)(viewportSize.getWidth() * 0.5f);
int targetHeight = (int)(targetWidth / aspectRatio);
return new Size(targetWidth, targetHeight);
};
PositionProvider positionProvider = new GravityPositionProviderAdapter(provider, Gravity.TOP | Gravity.LEFT);
WatermarkInfo watermarkInfo = new WatermarkInfo(watermarkDrawable, provider, positionProvider, watermarkWidth, watermarkHeight, true);
mSdkManager.setWatermarkInfo(watermarkInfo);
mSdkManager.takePhoto(null);
Binaries size
We include native debug symbols in our .aar archives, so you may find that banuba_effect_player.aar
is too big (about 100 MB). These symbols will help us to get clear crash logs. Nevertheless, Android Studio
will silently strip them from release apps, and no extra actions are required.
Visit our FAQ or contact our support.