Offscreen Effect Player (OEP) allows processing an image using Banuba SDK, no matter where it comes from: the camera, file system or somewhere else. OEP is the camera independent solution that returns a processed image in the same form as received. It means that an input image orientation stays unchanged after Banuba SDK processing. Additionally, OEP can draw the processed image on an external texture.
The entry point to Offscreen Effect Player is
OffscreenEffectPlayer class. This class provides the following functionality:
- Manage image processing —
setImageProcessListener./*** Send Image to process* Image will be closed inside OffscreenEffectPlayer** @param image Android image to process* @param orientation describes current image orientation*/public void processImage(@NonNull Image image, @NonNull ImageOrientation orientation);
Working with external texture =
setSurfaceTexture./*** Sets SurfaceTexture* Can be used together with ImageProcessListener.* In this case OffscreenEffectPlayer will render to SurfaceTexture and send image to listener** Passing NULL will disable render to SurfaceTexture** @param surfaceTexture The surfaceTexture to use, or null to remove.*/public void setSurfaceTexture(@Nullable SurfaceTexture surfaceTexture);
Apply the effect to an processed image (e.g. camera frame image of image from disk) —
unloadEffect./*** Load effect to the effect player.** @param effectName the name of an effect (folder) in the app resource storage*/public void loadEffect(@NonNull String effectName);/*** Unload active effect. The effect stays in the cache so another loading of the same effect is faster.*/public void unloadEffect();
Calling any effect methods -
callJsMethod./*** Let call methods defined in the script of the active effect, to configure effect or manage its state.** @param method - the name of js method* @param parameter - the parameter to pass to the method**/public void callJsMethod(@NonNull String method, @NonNull String parameter);
The main advantage of
OffscreenEffectPlayer compared to
BanubaSdkManager is that the OEP does not depend on the camera module.
Note, the best performance is achieved if OEP uses the
SurfaceTexture) as an output. In this case, the output image is returned in ARGB format. It lets you bypass GPU-CPU synchronization.
ExternalTexture is not used, the output image is returned as the byte buffer in YUV I420 reduced range video format (BT.601 420v). See the
ImageProcessResult.java classes from delivery bundle for more details.
The OEP simply expects an input image buffer to process it by Banuba SDK. In this case, the camera image acquiring should be implemented externally if necessary.
The camera image acquiring implementation can be considered as the main disadvantage of OEP solution.
The Banuba SDK delivery bundle contains the OEP sources in the
offscreen directory from the
offscreen directory contains the following main classes:
OffscreenEffectPlayer- the main class of the Offscreen Effect Player (OEP) module.
OffscreenEffectPlayerConfig- the Offscreen Effect Player configuration class.
BufferAllocator- the interface for buffer allocation. May be used in the application for retaining buffers.
ImageDebugUtils- the utility class that allow saving an image for debuggin.
ImageOrientation- the class that helps to make a proper image orientation based on the camera or image parameters.
ImageProcessResult- the class of a processed image.
You can use Offscreen Effect Player with or without surface texture.
Surface texture is set by the
setSurfaceTexture method of the
Please, refer to OEP Android demo app section for more details about Offscreen Effect Player usage with a Demo application.