-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoffscreen_effect_player.hpp
121 lines (105 loc) · 4.45 KB
/
offscreen_effect_player.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#pragma once
#include <optional>
#include <interfaces/effect_player.hpp>
#include <interfaces/offscreen_render_target.hpp>
#include <interfaces/image_processing_result.hpp>
namespace bnb::oep::interfaces
{
class offscreen_effect_player;
}
using offscreen_effect_player_sptr = std::shared_ptr<bnb::oep::interfaces::offscreen_effect_player>;
using oep_image_process_cb = std::function<void(image_processing_result_sptr)>;
namespace bnb::oep::interfaces
{
class offscreen_effect_player
{
public:
/**
* Create the offscreen effect player
*
* @param ep - shared pointer to the effect player
* @param ort - shared pointer to the offscreen render target
* @param width - initial width for offscreen render target
* @param height - initial height for offscreen render target
*
* @return - shared pointer to the offscreen effect player
*
* @example bnb::oep::interfaces::offscreen_effect_player::create(my_ep, my_ort, width, height)
*/
static offscreen_effect_player_sptr create(effect_player_sptr ep, offscreen_render_target_sptr ort, int32_t width, int32_t height);
virtual ~offscreen_effect_player() = default;
/**
* An asynchronous method for passing a frame to effect player,
* and calling callback as a frame will be processed
*
* @param image the passed instance of the pixel_buffer class provides the access to the image byte data
* @param input_rotation image orientation for effect player
* @param require_mirroring require mirroring for effect player
* @param callback calling when frame will be processed, containing pointer of pixel_buffer for get bytes
* @param target_orientation image orientation for postprocessing
*
* @example process_image_async(my_input_image, rotation::deg0, true, [](image_processing_result_sptr sptr){}, rotation::deg180)
* @return false if the frame is rejected because of too many items in the internal queue of frames, otherwise true
*/
virtual bool process_image_async(pixel_buffer_sptr image, rotation input_rotation, bool require_mirroring, oep_image_process_cb callback, std::optional<rotation> target_orientation) = 0;
/**
* Notify about rendering surface being resized.
* Must be called from the render thread.
*
* @param width New width for the rendering surface
* @param height New height for the rendering surface
*
* @example surface_changed(1280, 720)
*/
virtual void surface_changed(int32_t width, int32_t height) = 0;
/**
* Load and activate effect async. May be called from any thread
*
* @param effect_path Path to directory of effect
*
* @example load_effect("effects/Afro")
*/
virtual void load_effect(const std::string& effect_path) = 0;
/**
* Unload effect from cache.
*
* @example unload_effect()
*/
virtual void unload_effect() = 0;
/**
* Pause in effect player
*
* @example pause();
*/
virtual void pause() = 0;
/**
* Resume in effect player
*
* @example resume()
*/
virtual void resume() = 0;
/**
* Stop in effect player
*
* @example stop()
*/
virtual void stop() = 0;
/**
* Call js method defined in config.js file of active effect
*
* @param method JS function name. Member functions are not supported.
* @param param function arguments as JSON string.
*
* @example call_js_method("just_bg", "{ \"recordDuration\": 15, \"rotation_vector\": true }")
*/
virtual void call_js_method(const std::string& method, const std::string& param) = 0;
/**
* * Evaluate the `script` in effect. This method is thread safe.
* @param script JS string to execute
* @param result_callback Callback for result. Must be called from the render thread
*
* @example eval_js("Skin.softening(1)", [](const std::string&){ DO SOMETHING })
*/
virtual void eval_js(const std::string& script, oep_eval_js_result_cb result_callback) = 0;
}; /* class offscreen_effect_player INTERFACE */
} /* namespace bnb::oep::interfaces */