Package com.banuba.sdk.effect_player
Class EffectPlayer.CppProxy
- java.lang.Object
-
- com.banuba.sdk.effect_player.EffectPlayer.CppProxy
-
- All Implemented Interfaces:
EffectPlayer
- Enclosing interface:
- EffectPlayer
public static final class EffectPlayer.CppProxy extends java.lang.Object implements EffectPlayer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.banuba.sdk.effect_player.EffectPlayer
EffectPlayer.CppProxy
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
_djinni_private_destroy()
void
addCameraPoiListener(CameraPoiListener cameraPoiListener)
Add callback to receive center of the face in frame relative to top-left corner in [0, 1] space.void
addEffectActivationCompletionListener(EffectActivationCompletionListener effectActivationCompletionListener)
Add callback to receive current effect activation notification from Effect Player.void
addEffectInfoListener(EffectInfoListener effectInfoListener)
Add callback to receive current effect info from Effect Player.void
addFaceNumberListener(FaceNumberListener faceNumberListener)
Add callback to receive faces count in frame.void
addFrameDataListener(FrameDataListener frameDataListener)
Add callback to receive frame data right after processing in recognizer.void
addFrameDurationListener(FrameDurationListener frameDurationListener)
Add callback to receive FPS information.void
captureBlit(int captureWidth, int captureHeight)
Record last rendering ("draw_()") result into current OpenGL framebuffer.static EffectPlayer
create(EffectPlayerConfiguration configuration)
long
draw()
Draw the current effect into the current OpenGL framebuffer.Data
drawVideoFrame(FrameData inputFrameData, long timeNs, PixelFormat outputPixelFormat)
Draw processed frame to image buffer.Data
drawVideoFrameAllocated(FrameData inputFrameData, long timeNs, PixelFormat outputPixelFormat, Data allocatedBuffer)
The same as *draw_video_frame* but accepts preallocated buffer to avoid recreation for every frame.long
drawWithExternalFrameData(FrameData frameData)
Draw the current effect into the current OpenGL framebuffer.EffectManager
effectManager()
Get effect manager object Thread-safe.protected void
finalize()
FrameProcessor
frameProcessor()
Get current frame processor Thread-safe.static RenderBackendType
getCurrentRenderBackendType()
InputManager
getInputManager()
Get interface to control user iterations.EffectPlayerPlaybackState
getPlaybackState()
Thread-safe.void
onVideoRecordEnd()
Triggers record stop events in EP and Effect.void
onVideoRecordStart(boolean playAudioWhileRecording)
Trigger record start events in EP and Effect.void
playbackPause()
void
playbackPlay()
MUST be called from the main(render) threadvoid
playbackStop()
Data
processImage(FullImageData inputImage, PixelFormat outputPixelFormat)
Process an image with current effect.byte[]
processImageData(byte[] inputImage, int width, int height, CameraOrientation orientation, boolean isMirrored, PixelFormat inputPixelFormat, PixelFormat outputPixelFormat)
Process image with current effect.Data
processImageFrameData(FrameData inputFrameData, PixelFormat outputPixelFormat)
Process an image with current effect.FrameData
processVideoFrame(FullImageData inputImage, java.lang.Integer recognizerIterations)
Provide frame to evaluate video processing.FrameData
processVideoFrameData(FrameData inputFrameData, java.lang.Integer recognizerIterations)
Provide frame data to evaluate video processing.void
pushFrame(FullImageData fullImage)
Provides image to process and to play effect.void
pushFrameData(FrameData frameData)
Provides FrameData to process and to play effect.void
pushFrameDataWithNumber(FrameData frameData, long frameNumber)
Provides FrameData with frame number to process and to play effect.void
pushFrameWithNumber(FullImageData fullImage, long frameNumber)
Provides image to process and to play effect.PixelBuffer
readPixels()
Receive the last rendered frame in binary form.void
removeCameraPoiListener(CameraPoiListener cameraPoiListener)
Remove callback to receive center of the face in frame relative to top-left Thread-safe.void
removeEffectActivationCompletionListener(EffectActivationCompletionListener effectActivationCompletionListener)
Remove callback to receive current effect activation notification from Effect Player.void
removeEffectInfoListener(EffectInfoListener effectInfoListener)
Remove callback to receive current effect info from Effect Player.void
removeFaceNumberListener(FaceNumberListener faceNumberListener)
Remove callback to receive faces count in frame.void
removeFrameDataListener(FrameDataListener frameDataListener)
Remove callback to receive frame data right after processing in recognizer.void
removeFrameDurationListener(FrameDurationListener frameDurationListener)
Remove callback to receive FPS information.void
setExternalCameraTexture(int name, int width, int height)
Set OpenGL name of input external texture.void
setFrameProcessor(FrameProcessor processor)
Set frame processor as current Thread-safe.void
setMaxFaces(int maxFaces)
Sets maximum allowed face results, if face tracking feature is present.void
setRecognizerOfflineMode(boolean on)
Force recognizer offline mode Thread-safe.void
setRecognizerUseFutureFilter(boolean on)
Set future frame filtrarion mode.void
setRecognizerUseFutureInterpolate(boolean on)
Set future frame interpolation mode.static void
setRenderBackend(RenderBackendType backendType)
void
setRenderConsistencyMode(ConsistencyMode value)
Thread-safe.void
setUseExtCamTex(boolean value)
Use external texture as input source.void
startVideoProcessing(long screenWidth, long screenHeight, CameraOrientation orientation, boolean resetEffect, boolean offlineMode)
Initialize video processing.void
stopVideoProcessing(boolean resetEffect)
Finish processing and return renderer to normal state.void
surfaceChanged(int width, int height)
Notify about rendering surface being resized.void
surfaceCreated(int width, int height)
Use to notify the EffectPlayer that the surface exists and effect can be played.void
surfaceDestroyed()
This method should be called right before an active context will become invalid.void
writeRecordedAudio(java.lang.String filename, long lengthMs)
Save recorded audio.
-
-
-
Method Detail
-
_djinni_private_destroy
public void _djinni_private_destroy()
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
addFrameDurationListener
public void addFrameDurationListener(FrameDurationListener frameDurationListener)
Description copied from interface:EffectPlayer
Add callback to receive FPS information. Thread-safe. May be called from any thread- Specified by:
addFrameDurationListener
in interfaceEffectPlayer
-
removeFrameDurationListener
public void removeFrameDurationListener(FrameDurationListener frameDurationListener)
Description copied from interface:EffectPlayer
Remove callback to receive FPS information. Thread-safe. May be called from any thread- Specified by:
removeFrameDurationListener
in interfaceEffectPlayer
-
addFaceNumberListener
public void addFaceNumberListener(FaceNumberListener faceNumberListener)
Description copied from interface:EffectPlayer
Add callback to receive faces count in frame. Thread-safe. May be called from any thread- Specified by:
addFaceNumberListener
in interfaceEffectPlayer
-
removeFaceNumberListener
public void removeFaceNumberListener(FaceNumberListener faceNumberListener)
Description copied from interface:EffectPlayer
Remove callback to receive faces count in frame. Thread-safe. May be called from any thread- Specified by:
removeFaceNumberListener
in interfaceEffectPlayer
-
addFrameDataListener
public void addFrameDataListener(FrameDataListener frameDataListener)
Description copied from interface:EffectPlayer
Add callback to receive frame data right after processing in recognizer. Thread-safe. May be called from any thread- Specified by:
addFrameDataListener
in interfaceEffectPlayer
-
removeFrameDataListener
public void removeFrameDataListener(FrameDataListener frameDataListener)
Description copied from interface:EffectPlayer
Remove callback to receive frame data right after processing in recognizer. Thread-safe. May be called from any thread- Specified by:
removeFrameDataListener
in interfaceEffectPlayer
-
addCameraPoiListener
public void addCameraPoiListener(CameraPoiListener cameraPoiListener)
Description copied from interface:EffectPlayer
Add callback to receive center of the face in frame relative to top-left corner in [0, 1] space. Thread-safe. May be called from any thread- Specified by:
addCameraPoiListener
in interfaceEffectPlayer
-
removeCameraPoiListener
public void removeCameraPoiListener(CameraPoiListener cameraPoiListener)
Description copied from interface:EffectPlayer
Remove callback to receive center of the face in frame relative to top-left Thread-safe. May be called from any thread- Specified by:
removeCameraPoiListener
in interfaceEffectPlayer
-
addEffectInfoListener
public void addEffectInfoListener(EffectInfoListener effectInfoListener)
Description copied from interface:EffectPlayer
Add callback to receive current effect info from Effect Player. Thread-safe. May be called from any thread- Specified by:
addEffectInfoListener
in interfaceEffectPlayer
-
removeEffectInfoListener
public void removeEffectInfoListener(EffectInfoListener effectInfoListener)
Description copied from interface:EffectPlayer
Remove callback to receive current effect info from Effect Player. Thread-safe. May be called from any thread- Specified by:
removeEffectInfoListener
in interfaceEffectPlayer
-
addEffectActivationCompletionListener
public void addEffectActivationCompletionListener(EffectActivationCompletionListener effectActivationCompletionListener)
Description copied from interface:EffectPlayer
Add callback to receive current effect activation notification from Effect Player. Thread-safe. May be called from any thread- Specified by:
addEffectActivationCompletionListener
in interfaceEffectPlayer
-
removeEffectActivationCompletionListener
public void removeEffectActivationCompletionListener(EffectActivationCompletionListener effectActivationCompletionListener)
Description copied from interface:EffectPlayer
Remove callback to receive current effect activation notification from Effect Player. Thread-safe. May be called from any thread- Specified by:
removeEffectActivationCompletionListener
in interfaceEffectPlayer
-
setMaxFaces
public void setMaxFaces(int maxFaces)
Description copied from interface:EffectPlayer
Sets maximum allowed face results, if face tracking feature is present. Thread-safe. May be called from any thread This option is relevant only for GLFX effects.- Specified by:
setMaxFaces
in interfaceEffectPlayer
-
setExternalCameraTexture
public void setExternalCameraTexture(int name, int width, int height)
Description copied from interface:EffectPlayer
Set OpenGL name of input external texture. https://developer.android.com/reference/android/graphics/SurfaceTexture . MUST be called from the render thread- Specified by:
setExternalCameraTexture
in interfaceEffectPlayer
- Parameters:
name
- Texture namewidth
- Textute widthheight
- Texture height- See Also:
Note: This function is Android only. Note: We use texture size to calculate aspect ratio only.
-
setUseExtCamTex
public void setUseExtCamTex(boolean value)
Description copied from interface:EffectPlayer
Use external texture as input source. MUST be called from the render thread- Specified by:
setUseExtCamTex
in interfaceEffectPlayer
- See Also:
EffectPlayer.setExternalCameraTexture(int,int,int)
-
surfaceCreated
public void surfaceCreated(int width, int height)
Description copied from interface:EffectPlayer
Use to notify the EffectPlayer that the surface exists and effect can be played. 0, 0 for width and height are valid values. MUST be called from the render thread- Specified by:
surfaceCreated
in interfaceEffectPlayer
-
surfaceChanged
public void surfaceChanged(int width, int height)
Description copied from interface:EffectPlayer
Notify about rendering surface being resized. MUST be called from the render thread- Specified by:
surfaceChanged
in interfaceEffectPlayer
-
surfaceDestroyed
public void surfaceDestroyed()
Description copied from interface:EffectPlayer
This method should be called right before an active context will become invalid. Switches playback state to inactive state. If it's not done an application will be crashed on next draw iteration. After losing the surface effect playback can't be resumed from last position. MUST be called from the render thread- Specified by:
surfaceDestroyed
in interfaceEffectPlayer
-
draw
public long draw()
Description copied from interface:EffectPlayer
Draw the current effect into the current OpenGL framebuffer. Uses internal frame_data object obtained from latest push_frame recognition result. Return current frame number if drawing was performed and caller should swap buffers otherwise `DRAW_SKIPPED`(-1) MUST be called from the render thread- Specified by:
draw
in interfaceEffectPlayer
-
drawWithExternalFrameData
public long drawWithExternalFrameData(FrameData frameData)
Description copied from interface:EffectPlayer
Draw the current effect into the current OpenGL framebuffer. Uses externally provided frameData object instead of internal one obtained from latest push_frame recognition result. Return frame number from provided frameData if drawing was performed and caller should swap buffers otherwise `DRAW_SKIPPED`(-1) MUST be called from the render thread- Specified by:
drawWithExternalFrameData
in interfaceEffectPlayer
-
captureBlit
public void captureBlit(int captureWidth, int captureHeight)
Description copied from interface:EffectPlayer
Record last rendering ("draw_()") result into current OpenGL framebuffer. Content is cropped to maintain effect_size() aspect ratio MUST be called from the render thread- Specified by:
captureBlit
in interfaceEffectPlayer
-
readPixels
public PixelBuffer readPixels()
Description copied from interface:EffectPlayer
Receive the last rendered frame in binary form.- Specified by:
readPixels
in interfaceEffectPlayer
- Returns:
- 4-byte per pixel data, size is `fx_width * fx_height * 4` MUST be called from the render thread
-
setRenderConsistencyMode
public void setRenderConsistencyMode(ConsistencyMode value)
Description copied from interface:EffectPlayer
Thread-safe. May be called from any thread- Specified by:
setRenderConsistencyMode
in interfaceEffectPlayer
-
processImage
public Data processImage(FullImageData inputImage, PixelFormat outputPixelFormat)
Description copied from interface:EffectPlayer
Process an image with current effect. Must be called from the render thread.- Specified by:
processImage
in interfaceEffectPlayer
- Parameters:
inputImage
- to avoid conversion recommended to use YUV imageoutputPixelFormat
- to avoid conversion recommended to use RGBA
-
processImageFrameData
public Data processImageFrameData(FrameData inputFrameData, PixelFormat outputPixelFormat)
Description copied from interface:EffectPlayer
Process an image with current effect. Prefer this method over `processImage` when you have extra input data besides just an input image. Must be called from render thread.- Specified by:
processImageFrameData
in interfaceEffectPlayer
- Parameters:
inputFrameData
- `FrameData` with an imageoutputPixelFormat
- to avoid conversion recommended to use RGBA
-
processImageData
public byte[] processImageData(byte[] inputImage, int width, int height, CameraOrientation orientation, boolean isMirrored, PixelFormat inputPixelFormat, PixelFormat outputPixelFormat)
Description copied from interface:EffectPlayer
Process image with current effect. Must be called from render thread. NOTE: inputImage have copy overhead, preferable to use process_image method MUST be called from the render thread- Specified by:
processImageData
in interfaceEffectPlayer
- Parameters:
inputImage
- input image with `width * height * 4` sizeoutputPixelFormat
- to avoid conversion recommended to use RGBA
-
pushFrame
public void pushFrame(FullImageData fullImage)
Description copied from interface:EffectPlayer
Provides image to process and to play effect. Thread-safe. May be called from any thread- Specified by:
pushFrame
in interfaceEffectPlayer
-
pushFrameWithNumber
public void pushFrameWithNumber(FullImageData fullImage, long frameNumber)
Description copied from interface:EffectPlayer
Provides image to process and to play effect. Thread-safe. May be called from any thread- Specified by:
pushFrameWithNumber
in interfaceEffectPlayer
-
pushFrameData
public void pushFrameData(FrameData frameData)
Description copied from interface:EffectPlayer
Provides FrameData to process and to play effect. Must contain full image. Thread-safe. May be called from any thread- Specified by:
pushFrameData
in interfaceEffectPlayer
-
pushFrameDataWithNumber
public void pushFrameDataWithNumber(FrameData frameData, long frameNumber)
Description copied from interface:EffectPlayer
Provides FrameData with frame number to process and to play effect. Must contain full image. Thread-safe. May be called from any thread- Specified by:
pushFrameDataWithNumber
in interfaceEffectPlayer
-
playbackPlay
public void playbackPlay()
Description copied from interface:EffectPlayer
MUST be called from the main(render) thread- Specified by:
playbackPlay
in interfaceEffectPlayer
-
playbackPause
public void playbackPause()
- Specified by:
playbackPause
in interfaceEffectPlayer
-
playbackStop
public void playbackStop()
- Specified by:
playbackStop
in interfaceEffectPlayer
-
getPlaybackState
public EffectPlayerPlaybackState getPlaybackState()
Description copied from interface:EffectPlayer
Thread-safe. May be called from any thread- Specified by:
getPlaybackState
in interfaceEffectPlayer
-
getInputManager
public InputManager getInputManager()
Description copied from interface:EffectPlayer
Get interface to control user iterations. This events will be passed to effect. Thread-safe. May be called from any thread- Specified by:
getInputManager
in interfaceEffectPlayer
-
startVideoProcessing
public void startVideoProcessing(long screenWidth, long screenHeight, CameraOrientation orientation, boolean resetEffect, boolean offlineMode)
Description copied from interface:EffectPlayer
Initialize video processing. To provide frames use *process_video_frame* methods. Effect audio is recorded as well and can be accessed using *process_recorded_audio* and *write_recorded_audio*. *push_frame* should not be called during processing. MUST be called from the render thread- Specified by:
startVideoProcessing
in interfaceEffectPlayer
-
stopVideoProcessing
public void stopVideoProcessing(boolean resetEffect)
Description copied from interface:EffectPlayer
Finish processing and return renderer to normal state. MUST be called from the render thread- Specified by:
stopVideoProcessing
in interfaceEffectPlayer
-
processVideoFrameData
public FrameData processVideoFrameData(FrameData inputFrameData, java.lang.Integer recognizerIterations)
Description copied from interface:EffectPlayer
Provide frame data to evaluate video processing. MUST be called from the render thread- Specified by:
processVideoFrameData
in interfaceEffectPlayer
- Parameters:
inputFrameData
- Frame Data to process.recognizerIterations
- Number of processing iterations. Higher number means higher processing quality, but lower speed. Must be greater than 1. Pass null value for default number.- Returns:
- Frame data with frame processing results.
-
processVideoFrame
public FrameData processVideoFrame(FullImageData inputImage, java.lang.Integer recognizerIterations)
Description copied from interface:EffectPlayer
Provide frame to evaluate video processing. MUST be called from the render thread- Specified by:
processVideoFrame
in interfaceEffectPlayer
- Parameters:
inputImage
- Image to process.recognizerIterations
- Number of processing iterations. Higher number means higher processing quality, but lower speed. Must be greater than 1. Pass null value for default number.- Returns:
- Frame data with frame processing results.
-
drawVideoFrame
public Data drawVideoFrame(FrameData inputFrameData, long timeNs, PixelFormat outputPixelFormat)
Description copied from interface:EffectPlayer
Draw processed frame to image buffer. MUST be called from the render thread- Specified by:
drawVideoFrame
in interfaceEffectPlayer
- Parameters:
inputFrameData
- FrameData to draw.timeNs
- Frame position on timeline.outputPixelFormat
- Output image format.- Returns:
- Buffer with processed image in selected format.
-
drawVideoFrameAllocated
public Data drawVideoFrameAllocated(FrameData inputFrameData, long timeNs, PixelFormat outputPixelFormat, Data allocatedBuffer)
Description copied from interface:EffectPlayer
The same as *draw_video_frame* but accepts preallocated buffer to avoid recreation for every frame. MUST be called from the render thread- Specified by:
drawVideoFrameAllocated
in interfaceEffectPlayer
-
writeRecordedAudio
public void writeRecordedAudio(java.lang.String filename, long lengthMs)
Description copied from interface:EffectPlayer
Save recorded audio. Not thread-safe but can be called from any thread.- Specified by:
writeRecordedAudio
in interfaceEffectPlayer
- Parameters:
filename
- ".wav" extension must be used.lengthMs
- Track length. Set to '0' to use full duration.
-
onVideoRecordStart
public void onVideoRecordStart(boolean playAudioWhileRecording)
Description copied from interface:EffectPlayer
Trigger record start events in EP and Effect. Records all sounds during recording to be replayed by `processRecordedAudio`. If @param playAudioWhileRecording is true, the audio will continue to play. Otherwise, the audio will be muted. Thread-safe. May be called from any thread- Specified by:
onVideoRecordStart
in interfaceEffectPlayer
-
onVideoRecordEnd
public void onVideoRecordEnd()
Description copied from interface:EffectPlayer
Triggers record stop events in EP and Effect. Thread-safe. May be called from any thread- Specified by:
onVideoRecordEnd
in interfaceEffectPlayer
-
effectManager
public EffectManager effectManager()
Description copied from interface:EffectPlayer
Get effect manager object Thread-safe. May be called from any thread- Specified by:
effectManager
in interfaceEffectPlayer
-
setRecognizerOfflineMode
public void setRecognizerOfflineMode(boolean on)
Description copied from interface:EffectPlayer
Force recognizer offline mode Thread-safe. May be called from any thread- Specified by:
setRecognizerOfflineMode
in interfaceEffectPlayer
-
setRecognizerUseFutureFilter
public void setRecognizerUseFutureFilter(boolean on)
Description copied from interface:EffectPlayer
Set future frame filtrarion mode. Produce smoother recognition result (anti jitter), however adds inconsistency in push'ed/draw'ed frames (one frame lag) Example: push frame 1 - draw frame 1, push frame 2 - draw frame 1, push frame 3 - draw frame 2, ...- Specified by:
setRecognizerUseFutureFilter
in interfaceEffectPlayer
-
setRecognizerUseFutureInterpolate
public void setRecognizerUseFutureInterpolate(boolean on)
Description copied from interface:EffectPlayer
Set future frame interpolation mode. Produce faster recognition result (skip even frames), however adds inconsistency in push'ed/pop'ed frames (one frame lag) Example: push frame 1 - pop frame 1, push frame 2 - pop frame 1, push frame 3 - pop frame 2, ...- Specified by:
setRecognizerUseFutureInterpolate
in interfaceEffectPlayer
-
setFrameProcessor
public void setFrameProcessor(FrameProcessor processor)
Description copied from interface:EffectPlayer
Set frame processor as current Thread-safe. May be called from any thread- Specified by:
setFrameProcessor
in interfaceEffectPlayer
-
frameProcessor
public FrameProcessor frameProcessor()
Description copied from interface:EffectPlayer
Get current frame processor Thread-safe. May be called from any thread- Specified by:
frameProcessor
in interfaceEffectPlayer
-
create
@Nullable public static EffectPlayer create(@Nullable EffectPlayerConfiguration configuration)
-
setRenderBackend
public static void setRenderBackend(@NonNull RenderBackendType backendType)
-
getCurrentRenderBackendType
@NonNull public static RenderBackendType getCurrentRenderBackendType()
-
-