Banuba SDK
Public Member Functions | Static Public Member Functions | List of all members
bnb::interfaces::effect_player Class Referenceabstract

The EffectPlayer class provides ability to play AR effects on set of images or video. More...

#include <effect_player.hpp>

Public Member Functions

virtual void add_frame_duration_listener (const std::shared_ptr< frame_duration_listener > &frame_duration_listener)=0
 Add callback to receive FPS information. More...
 
virtual void remove_frame_duration_listener (const std::shared_ptr< frame_duration_listener > &frame_duration_listener)=0
 Remove callback to receive FPS information. More...
 
virtual void add_face_number_listener (const std::shared_ptr< face_number_listener > &face_number_listener)=0
 Add callback to receive faces count in frame. More...
 
virtual void remove_face_number_listener (const std::shared_ptr< face_number_listener > &face_number_listener)=0
 Remove callback to receive faces count in frame. More...
 
virtual void add_frame_data_listener (const std::shared_ptr< frame_data_listener > &frame_data_listener)=0
 Add callback to receive frame data right after processing in recognizer. More...
 
virtual void remove_frame_data_listener (const std::shared_ptr< frame_data_listener > &frame_data_listener)=0
 Remove callback to receive frame data right after processing in recognizer. More...
 
virtual void add_low_light_listener (const std::shared_ptr< low_light_listener > &low_light_listener)=0
 Add callback to receive low light info Thread-safe. More...
 
virtual void remove_low_light_listener (const std::shared_ptr< low_light_listener > &low_light_listener)=0
 Remove callback to receive low light info Thread-safe. More...
 
virtual void add_camera_poi_listener (const std::shared_ptr< camera_poi_listener > &camera_poi_listener)=0
 Add callback to receive center of the face in frame relative to top-left corner in [0, 1] space. More...
 
virtual void remove_camera_poi_listener (const std::shared_ptr< camera_poi_listener > &camera_poi_listener)=0
 Remove callback to receive center of the face in frame relative to top-left Thread-safe. More...
 
virtual void add_effect_info_listener (const std::shared_ptr< effect_info_listener > &effect_info_listener)=0
 Add callback to receive current effect info from Effect Player. More...
 
virtual void remove_effect_info_listener (const std::shared_ptr< effect_info_listener > &effect_info_listener)=0
 Remove callback to receive current effect info from Effect Player. More...
 
virtual void add_effect_activation_completion_listener (const std::shared_ptr< effect_activation_completion_listener > &effect_activation_completion_listener)=0
 Add callback to receive current effect activation notification from Effect Player. More...
 
virtual void remove_effect_activation_completion_listener (const std::shared_ptr< effect_activation_completion_listener > &effect_activation_completion_listener)=0
 Remove callback to receive current effect activation notification from Effect Player. More...
 
virtual void set_max_faces (int32_t max_faces)=0
 Sets maximum allowed face results, if face tracking feature is present. More...
 
virtual void set_external_camera_texture (int32_t name, int32_t width, int32_t height)=0
 Set OpenGL name of input external texture. More...
 
virtual void set_use_ext_cam_tex (bool value)=0
 Use external texture as input source. More...
 
virtual void surface_created (int32_t width, int32_t height)=0
 Use to notify the EffectPlayer that the surface exists and effect can be played. More...
 
virtual void surface_changed (int32_t width, int32_t height)=0
 Notify about rendering surface being resized. More...
 
virtual void surface_destroyed ()=0
 This method should be called right before an active context will become invalid. More...
 
virtual int64_t draw ()=0
 Draw the current effect into the current OpenGL framebuffer. More...
 
virtual int64_t draw_with_external_frame_data (const std::shared_ptr<::bnb::interfaces::frame_data > &frame_data)=0
 Draw the current effect into the current OpenGL framebuffer. More...
 
virtual void capture_blit (int32_t capture_width, int32_t capture_height)=0
 Record last rendering ("draw_()") result into current OpenGL framebuffer. More...
 
virtual ::bnb::interfaces::pixel_buffer read_pixels ()=0
 Receive the last rendered frame in binary form. More...
 
virtual void set_render_consistency_mode (consistency_mode value)=0
 Thread-safe. More...
 
virtual void set_render_transform (const ::bnb::interfaces::pixel_rect &image_rect, const ::bnb::interfaces::pixel_rect &viewport_rect, bool x_flip, bool y_flip)=0
 Request display of sub-area of the input image into sub-area of the output surface, with optional x,y flips image_rect is fitted inside viewport_rect Resets transform to default if either rect has 0 dimensions. More...
 
virtual ::bnb::data_t process_image (::bnb::full_image_t input_image, ::bnb::interfaces::pixel_format output_pixel_format, const process_image_params &params)=0
 Process an image with current effect. More...
 
virtual ::bnb::data_t process_image_frame_data (const std::shared_ptr<::bnb::interfaces::frame_data > &input_frame_data, ::bnb::interfaces::pixel_format output_pixel_format, const process_image_params &params)=0
 Process an image with current effect. More...
 
virtual std::vector< uint8_t > process_image_data (const std::vector< uint8_t > &input_image, int32_t width, int32_t height, camera_orientation orientation, bool is_mirrored, ::bnb::interfaces::pixel_format input_pixel_format, ::bnb::interfaces::pixel_format output_pixel_format, const process_image_params &params)=0
 Process image with current effect. More...
 
virtual void push_frame (::bnb::full_image_t full_image)=0
 Provides image to process and to play effect. More...
 
virtual void push_frame_with_number (::bnb::full_image_t full_image, int64_t frame_number)=0
 Provides image to process and to play effect. More...
 
virtual void push_frame_data (const std::shared_ptr<::bnb::interfaces::frame_data > &frame_data)=0
 Provides FrameData to process and to play effect. More...
 
virtual void push_frame_data_with_number (const std::shared_ptr<::bnb::interfaces::frame_data > &frame_data, int32_t frame_number)=0
 Provides FrameData with frame number to process and to play effect. More...
 
virtual void playback_play ()=0
 MUST be called from the main(render) thread.
 
virtual void playback_pause ()=0
 
virtual void playback_stop ()=0
 
virtual effect_player_playback_state get_playback_state ()=0
 Thread-safe. More...
 
virtual void enable_audio (bool enable)=0
 Set audio enabled.
 
virtual std::shared_ptr< input_managerget_input_manager ()=0
 Get interface to control user iterations. More...
 
virtual void start_video_processing (int64_t screen_width, int64_t screen_height, camera_orientation orientation, bool reset_effect, bool offline_mode)=0
 Initialize video processing. More...
 
virtual void stop_video_processing (bool reset_effect)=0
 Finish processing and return renderer to normal state. More...
 
virtual std::shared_ptr<::bnb::interfaces::frame_dataprocess_video_frame_data (const std::shared_ptr<::bnb::interfaces::frame_data > &input_frame_data, const process_image_params &params, std::optional< int32_t > recognizer_iterations)=0
 Provide frame data to evaluate video processing. More...
 
virtual std::shared_ptr<::bnb::interfaces::frame_dataprocess_video_frame (::bnb::full_image_t input_image, const process_image_params &params, std::optional< int32_t > recognizer_iterations)=0
 Provide frame to evaluate video processing. More...
 
virtual ::bnb::data_t draw_video_frame (const std::shared_ptr<::bnb::interfaces::frame_data > &input_frame_data, int64_t time_ns, ::bnb::interfaces::pixel_format output_pixel_format)=0
 Draw processed frame to image buffer. More...
 
virtual ::bnb::data_t draw_video_frame_allocated (const std::shared_ptr<::bnb::interfaces::frame_data > &input_frame_data, int64_t time_ns, ::bnb::interfaces::pixel_format output_pixel_format, ::bnb::data_t allocated_buffer)=0
 The same as draw_video_frame but accepts preallocated buffer to avoid recreation for every frame. More...
 
virtual bool is_voice_changer_configured ()=0
 Thread-safe. More...
 
virtual void process_recorded_audio (const std::string &in_filename, const std::string &out_filename, float mix_volume)=0
 Process recorded voice with voice changer effects mixing with recorded sounds. More...
 
virtual void write_recorded_audio (const std::string &filename, int64_t length_ms)=0
 Save recorded audio. More...
 
virtual void on_video_record_start ()=0
 Trigger record start events in EP and Effect. More...
 
virtual void on_video_record_end ()=0
 Triggers record stop events in EP and Effect. More...
 
virtual bool is_device_nn_compatible ()=0
 Check is device compatible with Neural Networks player Thread-safe. More...
 
virtual void start_framedata_capture (const std::string &folder, const std::optional< std::string > &filename)=0
 Request to start framedata capture process. More...
 
virtual void stop_framedata_capture ()=0
 
virtual void start_analytics_capture (const std::unordered_map< std::string, std::string > &device_info, const analytics_config &config, const std::shared_ptr< analytics_listener > &listener)=0
 Request to start analytics capture process. More...
 
virtual void stop_analytics_capture ()=0
 
virtual std::shared_ptr<::bnb::interfaces::effect_managereffect_manager ()=0
 Get effect manager object Thread-safe. More...
 
virtual std::shared_ptr<::bnb::interfaces::debug_interfacedebug_interface ()=0
 For internal usage only.
 
virtual void set_recognizer_offline_mode (bool on)=0
 Force recognizer offline mode Thread-safe. More...
 

Static Public Member Functions

static std::shared_ptr< effect_playercreate (const effect_player_configuration &configuration)
 
static int32_t version_major ()
 Get major version of EffectPlayer. More...
 
static int32_t version_minor ()
 Get minor version of EffectPlayer. More...
 
static void set_render_backend (::bnb::interfaces::render_backend_type backend_type)
 
::bnb::interfaces::render_backend_type get_current_render_backend_type ()
 

Detailed Description

The EffectPlayer class provides ability to play AR effects on set of images or video.

Lifecycle

In order to support an application lifecycle EffectPlayer provides special methods to control it during application states like pause or losing focus.

Effect playback

Initial playback state of newly created Effect Player instance is active. With playback control methods described below, the player can be launched/resumed or paused. State of effect player becomes stopped/inactive at the moment of surface loss or by calling the EffectPlayer::playback_stop method. One can use next three methods to control effect playback:
- EffectPlayer.playback_play. Switching to active state attempt. Possible from paused or stopped state and has no effect if effect playback is already active. Playback resumes from the position saved before EffectPlayer.playbackPause call.
- EffectPlayer.playback_pause. Suspend current playback attempt. The recognizer thread is stopped and all the video textures and audio units playback is stopped as well. Effect player doesn't react on EffectPlayer::pushFrame calls in suspended state except asynchronous-inconsistent mode.
- EffectPlayer.playbackStop. Switch to inactive state. In addition to pause clears recognizer's buffer. The next switch to active state will result in total rerun of active effect which means that it will be started from the very beginning.

Android usage example

If you want an application to be active on windowed mode and if the focus is on another application you can switch EffectPlayer into active state when onStart activity callback occurs and switch to paused when onStop occurs. Otherwise you can suspend EffectPlayer on onPause and resume on onResume callback to make an instance of the EffectPlayer inactive while activity losing focus.

Context/surface control

There are two methods that have to be used to ensure correct operating of the EffectPlayer. Losing context without notifying the EffectPlayer leads to application crash. Methods for context changes notification:
- EffectPlayer.surfaceCreated
- EffectPlayer.surfaceDestroyed

Multi-Threading performance and safety. Listeners.

EffectPlayer allows to call some of its methods from several threads (simultaneously) for convenience and increased performance. This is allowed only during normal operation, all invocations from other threads MUST finish before you start destroying the EffectPlayer instance. Most methods belong to one of the two groups:
- MUST be called from the "Main" (also "Render") thread ("Not Reentrant, Not Thread-safe")
- MAY be called from "Any" thread. Most are "Thread-safe" Listener callbacks can be called back from any thread. Generally for best performance and responsiveness you'll have 3 threads:
- Main(render) thread for drawing-related operations
- "Camera" thread for handling and push()-ing frames into EffectPlayer
- UI Thread for handling user interactions and other tasks

Definition at line 91 of file effect_player.hpp.

Member Function Documentation

◆ add_camera_poi_listener()

virtual void bnb::interfaces::effect_player::add_camera_poi_listener ( const std::shared_ptr< camera_poi_listener > &  camera_poi_listener)
pure virtual

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

◆ add_effect_activation_completion_listener()

virtual void bnb::interfaces::effect_player::add_effect_activation_completion_listener ( const std::shared_ptr< effect_activation_completion_listener > &  effect_activation_completion_listener)
pure virtual

Add callback to receive current effect activation notification from Effect Player.

Thread-safe. May be called from any thread

◆ add_effect_info_listener()

virtual void bnb::interfaces::effect_player::add_effect_info_listener ( const std::shared_ptr< effect_info_listener > &  effect_info_listener)
pure virtual

Add callback to receive current effect info from Effect Player.

Thread-safe. May be called from any thread

◆ add_face_number_listener()

virtual void bnb::interfaces::effect_player::add_face_number_listener ( const std::shared_ptr< face_number_listener > &  face_number_listener)
pure virtual

Add callback to receive faces count in frame.

Thread-safe. May be called from any thread

◆ add_frame_data_listener()

virtual void bnb::interfaces::effect_player::add_frame_data_listener ( const std::shared_ptr< frame_data_listener > &  frame_data_listener)
pure virtual

Add callback to receive frame data right after processing in recognizer.

Thread-safe. May be called from any thread

◆ add_frame_duration_listener()

virtual void bnb::interfaces::effect_player::add_frame_duration_listener ( const std::shared_ptr< frame_duration_listener > &  frame_duration_listener)
pure virtual

Add callback to receive FPS information.

Thread-safe. May be called from any thread

◆ add_low_light_listener()

virtual void bnb::interfaces::effect_player::add_low_light_listener ( const std::shared_ptr< low_light_listener > &  low_light_listener)
pure virtual

Add callback to receive low light info Thread-safe.

May be called from any thread

◆ capture_blit()

virtual void bnb::interfaces::effect_player::capture_blit ( int32_t  capture_width,
int32_t  capture_height 
)
pure virtual

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

◆ draw()

virtual int64_t bnb::interfaces::effect_player::draw ( )
pure virtual

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

◆ draw_video_frame()

virtual ::bnb::data_t bnb::interfaces::effect_player::draw_video_frame ( const std::shared_ptr<::bnb::interfaces::frame_data > &  input_frame_data,
int64_t  time_ns,
::bnb::interfaces::pixel_format  output_pixel_format 
)
pure virtual

Draw processed frame to image buffer.

MUST be called from the render thread

Parameters
input_frame_dataFrameData to draw.
time_nsFrame position on timeline.
output_pixel_formatOutput image format.
Returns
Buffer with processed image in selected format.

◆ draw_video_frame_allocated()

virtual ::bnb::data_t bnb::interfaces::effect_player::draw_video_frame_allocated ( const std::shared_ptr<::bnb::interfaces::frame_data > &  input_frame_data,
int64_t  time_ns,
::bnb::interfaces::pixel_format  output_pixel_format,
::bnb::data_t  allocated_buffer 
)
pure virtual

The same as draw_video_frame but accepts preallocated buffer to avoid recreation for every frame.

MUST be called from the render thread

◆ draw_with_external_frame_data()

virtual int64_t bnb::interfaces::effect_player::draw_with_external_frame_data ( const std::shared_ptr<::bnb::interfaces::frame_data > &  frame_data)
pure virtual

Draw the current effect into the current OpenGL framebuffer.

Uses externally provided frame_data object instead of internal one obtained from latest push_frame recognition result.

Return frame number from provided frame_data if drawing was performed and caller should swap buffers otherwise DRAW_SKIPPED(-1) MUST be called from the render thread

◆ effect_manager()

virtual std::shared_ptr<::bnb::interfaces::effect_manager> bnb::interfaces::effect_player::effect_manager ( )
pure virtual

Get effect manager object Thread-safe.

May be called from any thread

◆ get_input_manager()

virtual std::shared_ptr<input_manager> bnb::interfaces::effect_player::get_input_manager ( )
pure virtual

Get interface to control user iterations.

This events will be passed to effect. Thread-safe. May be called from any thread

◆ get_playback_state()

virtual effect_player_playback_state bnb::interfaces::effect_player::get_playback_state ( )
pure virtual

Thread-safe.

May be called from any thread

◆ is_device_nn_compatible()

virtual bool bnb::interfaces::effect_player::is_device_nn_compatible ( )
pure virtual

Check is device compatible with Neural Networks player Thread-safe.

May be called from any thread On some platforms (e.g. Android) may require the first invocation to be on the render thread

◆ is_voice_changer_configured()

virtual bool bnb::interfaces::effect_player::is_voice_changer_configured ( )
pure virtual

Thread-safe.

May be called from any thread

◆ on_video_record_end()

virtual void bnb::interfaces::effect_player::on_video_record_end ( )
pure virtual

Triggers record stop events in EP and Effect.

Thread-safe. May be called from any thread

◆ on_video_record_start()

virtual void bnb::interfaces::effect_player::on_video_record_start ( )
pure virtual

Trigger record start events in EP and Effect.

If voice changer is active in the effect, pauses and records all sounds during recording to be replayed by processRecordedAudio. Thread-safe. May be called from any thread

◆ process_image()

virtual ::bnb::data_t bnb::interfaces::effect_player::process_image ( ::bnb::full_image_t  input_image,
::bnb::interfaces::pixel_format  output_pixel_format,
const process_image_params params 
)
pure virtual

Process an image with current effect.

Must be called from the render thread.

Parameters
input_imageto avoid conversion recommended to use YUV image
output_pixel_formatto avoid conversion recommended to use RGBA
paramsextra image processing arguments

◆ process_image_data()

virtual std::vector<uint8_t> bnb::interfaces::effect_player::process_image_data ( const std::vector< uint8_t > &  input_image,
int32_t  width,
int32_t  height,
camera_orientation  orientation,
bool  is_mirrored,
::bnb::interfaces::pixel_format  input_pixel_format,
::bnb::interfaces::pixel_format  output_pixel_format,
const process_image_params params 
)
pure virtual

Process image with current effect.

Must be called from render thread. NOTE: input_image have copy overhead, preferable to use process_image method MUST be called from the render thread

Parameters
input_imageinput image with width * height * 4 size
output_pixel_formatto avoid conversion recommended to use RGBA

◆ process_image_frame_data()

virtual ::bnb::data_t bnb::interfaces::effect_player::process_image_frame_data ( const std::shared_ptr<::bnb::interfaces::frame_data > &  input_frame_data,
::bnb::interfaces::pixel_format  output_pixel_format,
const process_image_params params 
)
pure virtual

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.

Parameters
input_frame_dataFrameData with an image
output_pixel_formatto avoid conversion recommended to use RGBA
paramsextra image processing arguments

◆ process_recorded_audio()

virtual void bnb::interfaces::effect_player::process_recorded_audio ( const std::string &  in_filename,
const std::string &  out_filename,
float  mix_volume 
)
pure virtual

Process recorded voice with voice changer effects mixing with recorded sounds.

Copies in->out if no voice changer or effect is active. Not thread-safe but can be called from any thread. Recorded sounds have the same lifetime as the effect(e.g reset after load_effect, etc.).

Parameters
in_filenameInput filename.
out_filenameMust have ".wav" extension.
mix_volumeRelative volume for mixing in sounds, [0..1].

◆ process_video_frame()

virtual std::shared_ptr<::bnb::interfaces::frame_data> bnb::interfaces::effect_player::process_video_frame ( ::bnb::full_image_t  input_image,
const process_image_params params,
std::optional< int32_t >  recognizer_iterations 
)
pure virtual

Provide frame to evaluate video processing.

MUST be called from the render thread

Parameters
input_imageImage to process.
paramsProcessing params.
recognizer_iterationsNumber 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.

◆ process_video_frame_data()

virtual std::shared_ptr<::bnb::interfaces::frame_data> bnb::interfaces::effect_player::process_video_frame_data ( const std::shared_ptr<::bnb::interfaces::frame_data > &  input_frame_data,
const process_image_params params,
std::optional< int32_t >  recognizer_iterations 
)
pure virtual

Provide frame data to evaluate video processing.

MUST be called from the render thread

Parameters
input_frame_dataFrame Data to process.
paramsProcessing params.
recognizer_iterationsNumber 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.

◆ push_frame()

virtual void bnb::interfaces::effect_player::push_frame ( ::bnb::full_image_t  full_image)
pure virtual

Provides image to process and to play effect.

Thread-safe. May be called from any thread

◆ push_frame_data()

virtual void bnb::interfaces::effect_player::push_frame_data ( const std::shared_ptr<::bnb::interfaces::frame_data > &  frame_data)
pure virtual

Provides FrameData to process and to play effect.

Must contain full image. Thread-safe. May be called from any thread

◆ push_frame_data_with_number()

virtual void bnb::interfaces::effect_player::push_frame_data_with_number ( const std::shared_ptr<::bnb::interfaces::frame_data > &  frame_data,
int32_t  frame_number 
)
pure virtual

Provides FrameData with frame number to process and to play effect.

Must contain full image. Thread-safe. May be called from any thread

◆ push_frame_with_number()

virtual void bnb::interfaces::effect_player::push_frame_with_number ( ::bnb::full_image_t  full_image,
int64_t  frame_number 
)
pure virtual

Provides image to process and to play effect.

Thread-safe. May be called from any thread

◆ read_pixels()

virtual ::bnb::interfaces::pixel_buffer bnb::interfaces::effect_player::read_pixels ( )
pure virtual

Receive the last rendered frame in binary form.

Returns
4-byte per pixel data, size is fx_width * fx_height * 4 MUST be called from the render thread

◆ remove_camera_poi_listener()

virtual void bnb::interfaces::effect_player::remove_camera_poi_listener ( const std::shared_ptr< camera_poi_listener > &  camera_poi_listener)
pure virtual

Remove callback to receive center of the face in frame relative to top-left Thread-safe.

May be called from any thread

◆ remove_effect_activation_completion_listener()

virtual void bnb::interfaces::effect_player::remove_effect_activation_completion_listener ( const std::shared_ptr< effect_activation_completion_listener > &  effect_activation_completion_listener)
pure virtual

Remove callback to receive current effect activation notification from Effect Player.

Thread-safe. May be called from any thread

◆ remove_effect_info_listener()

virtual void bnb::interfaces::effect_player::remove_effect_info_listener ( const std::shared_ptr< effect_info_listener > &  effect_info_listener)
pure virtual

Remove callback to receive current effect info from Effect Player.

Thread-safe. May be called from any thread

◆ remove_face_number_listener()

virtual void bnb::interfaces::effect_player::remove_face_number_listener ( const std::shared_ptr< face_number_listener > &  face_number_listener)
pure virtual

Remove callback to receive faces count in frame.

Thread-safe. May be called from any thread

◆ remove_frame_data_listener()

virtual void bnb::interfaces::effect_player::remove_frame_data_listener ( const std::shared_ptr< frame_data_listener > &  frame_data_listener)
pure virtual

Remove callback to receive frame data right after processing in recognizer.

Thread-safe. May be called from any thread

◆ remove_frame_duration_listener()

virtual void bnb::interfaces::effect_player::remove_frame_duration_listener ( const std::shared_ptr< frame_duration_listener > &  frame_duration_listener)
pure virtual

Remove callback to receive FPS information.

Thread-safe. May be called from any thread

◆ remove_low_light_listener()

virtual void bnb::interfaces::effect_player::remove_low_light_listener ( const std::shared_ptr< low_light_listener > &  low_light_listener)
pure virtual

Remove callback to receive low light info Thread-safe.

May be called from any thread

◆ set_external_camera_texture()

virtual void bnb::interfaces::effect_player::set_external_camera_texture ( int32_t  name,
int32_t  width,
int32_t  height 
)
pure virtual

Set OpenGL name of input external texture.

https://developer.android.com/reference/android/graphics/SurfaceTexture . MUST be called from the render thread

Parameters
nameTexture name
widthTextute width
heightTexture height
See also
setUseExtCamTex


Note: This function is Android only.
Note: We use texture size to calculate aspect ratio only.

◆ set_max_faces()

virtual void bnb::interfaces::effect_player::set_max_faces ( int32_t  max_faces)
pure virtual

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.

◆ set_recognizer_offline_mode()

virtual void bnb::interfaces::effect_player::set_recognizer_offline_mode ( bool  on)
pure virtual

Force recognizer offline mode Thread-safe.

May be called from any thread

◆ set_render_consistency_mode()

virtual void bnb::interfaces::effect_player::set_render_consistency_mode ( consistency_mode  value)
pure virtual

Thread-safe.

May be called from any thread

◆ set_render_transform()

virtual void bnb::interfaces::effect_player::set_render_transform ( const ::bnb::interfaces::pixel_rect image_rect,
const ::bnb::interfaces::pixel_rect viewport_rect,
bool  x_flip,
bool  y_flip 
)
pure virtual

Request display of sub-area of the input image into sub-area of the output surface, with optional x,y flips image_rect is fitted inside viewport_rect Resets transform to default if either rect has 0 dimensions.

Parameters
image_rectrectangle in input image coordinates(pixels) after applying input rotations and flips
viewport_rectrectangle in output surface coordinates(pixels) MUST be called from the render thread

◆ set_use_ext_cam_tex()

virtual void bnb::interfaces::effect_player::set_use_ext_cam_tex ( bool  value)
pure virtual

Use external texture as input source.

MUST be called from the render thread

See also
setExternalCameraTexture
Note
This function is Android only

◆ start_analytics_capture()

virtual void bnb::interfaces::effect_player::start_analytics_capture ( const std::unordered_map< std::string, std::string > &  device_info,
const analytics_config config,
const std::shared_ptr< analytics_listener > &  listener 
)
pure virtual

Request to start analytics capture process.

Analytics supports two business cases:

  1. Capture high resolution photo with face (bigger than 720p).
  2. Capture N frames with face (N is configurable, if N=0 capturer will skip this case). Result is a path to CBOR file with images and face recognition results, compressed with zlib. Thread-safe. May be called from any thread
    Parameters
    device_infoAny user specific information to attach in analytics report.
    configSetup configurable properties (like frames counter and delay before capture).
    listenerCallback which is fired in one of two above mentioned cases.

◆ start_framedata_capture()

virtual void bnb::interfaces::effect_player::start_framedata_capture ( const std::string &  folder,
const std::optional< std::string > &  filename 
)
pure virtual

Request to start framedata capture process.

Output file is in CBOR format. Thread-safe. May be called from any thread

Parameters
folderOutput folder.
filenameOutput filename. If the value is an empty string, filename is generated based on date and time.

◆ start_video_processing()

virtual void bnb::interfaces::effect_player::start_video_processing ( int64_t  screen_width,
int64_t  screen_height,
camera_orientation  orientation,
bool  reset_effect,
bool  offline_mode 
)
pure virtual

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

Exceptions
ExceptionMust be aborted with stop_video_processing()

◆ stop_framedata_capture()

virtual void bnb::interfaces::effect_player::stop_framedata_capture ( )
pure virtual
See also
startFramedataCapture

◆ stop_video_processing()

virtual void bnb::interfaces::effect_player::stop_video_processing ( bool  reset_effect)
pure virtual

Finish processing and return renderer to normal state.

MUST be called from the render thread

◆ surface_changed()

virtual void bnb::interfaces::effect_player::surface_changed ( int32_t  width,
int32_t  height 
)
pure virtual

Notify about rendering surface being resized.

MUST be called from the render thread

◆ surface_created()

virtual void bnb::interfaces::effect_player::surface_created ( int32_t  width,
int32_t  height 
)
pure virtual

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

◆ surface_destroyed()

virtual void bnb::interfaces::effect_player::surface_destroyed ( )
pure virtual

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

◆ version_major()

static int32_t bnb::interfaces::effect_player::version_major ( )
static

Get major version of EffectPlayer.

Use this method to filter out breaking changes in implementation of this class.

Note
this is not version of SDK.
See also
EffectPlayer.versionMinor

◆ version_minor()

static int32_t bnb::interfaces::effect_player::version_minor ( )
static

Get minor version of EffectPlayer.

See also
EffectPlayer.versionMajor

◆ write_recorded_audio()

virtual void bnb::interfaces::effect_player::write_recorded_audio ( const std::string &  filename,
int64_t  length_ms 
)
pure virtual

Save recorded audio.

Not thread-safe but can be called from any thread.

Parameters
filename".wav" extension must be used.
length_msTrack length. Set to '0' to use full duration.

The documentation for this class was generated from the following file: