Banuba SDK
effect_manager.hpp
Go to the documentation of this file.
1 /// \file
2 /// \addtogroup EffectPlayer
3 /// @{
4 ///
5 // AUTOGENERATED FILE - DO NOT MODIFY!
6 // This file was generated by Djinni from effect_player.djinni
7 
8 #pragma once
9 
11 #include <bnb/utils/defs.hpp>
12 #include <cstdint>
13 #include <memory>
14 #include <string>
15 
16 namespace bnb { namespace interfaces {
17 
18 class effect;
19 class effect_activated_listener;
20 class effect_event_listener;
21 class error_listener;
22 class hint_listener;
23 class reload_result;
24 struct effect_info;
25 struct surface_data;
26 
27 class BNB_EXPORT effect_manager {
28 public:
29  virtual ~effect_manager() {}
30 
31  /**
32  * Add callback to receive errors messages from Effect Player.
33  * Thread-safe. May be called from any thread
34  */
35  virtual void add_error_listener(const std::shared_ptr<error_listener> & error_listener) = 0;
36 
37  /**
38  * Remove callback to receive errors messages from Effect Player.
39  * Thread-safe. May be called from any thread
40  */
41  virtual void remove_error_listener(const std::shared_ptr<error_listener> & error_listener) = 0;
42 
43  /**
44  * Add callback to receive user-visible messages from effects.
45  * You should display them on UI.
46  * Thread-safe. May be called from any thread
47  */
48  virtual void add_hint_listener(const std::shared_ptr<hint_listener> & hint_listener) = 0;
49 
50  /**
51  * Remove callback to receive user-visible messages from effects.
52  * Thread-safe. May be called from any thread
53  */
54  virtual void remove_hint_listener(const std::shared_ptr<hint_listener> & hint_listener) = 0;
55 
56  /**
57  * Add callback to receive events from effect.
58  * Thread-safe. May be called from any thread
59  */
60  virtual void add_effect_event_listener(const std::shared_ptr<effect_event_listener> & effect_event_listener) = 0;
61 
62  /**
63  * Remove callback to receive events from effect.
64  * Thread-safe. May be called from any thread
65  */
66  virtual void remove_effect_event_listener(const std::shared_ptr<effect_event_listener> & effect_event_listener) = 0;
67 
68  /**
69  * Add callback to receive notifications on effect change.
70  * Thread-safe. May be called from any thread
71  */
72  virtual void add_effect_activated_listener(const std::shared_ptr<effect_activated_listener> & effect_activated_listener) = 0;
73 
74  /**
75  * Remove callback to receive notifications on effect change.
76  * Thread-safe. May be called from any thread
77  */
78  virtual void remove_effect_activated_listener(const std::shared_ptr<effect_activated_listener> & effect_activated_listener) = 0;
79 
80  /** Create empty effect. If working directory path is empty string then effect assumed as an in-memory effect. */
81  virtual std::shared_ptr<effect> create_effect(const std::string & work_dir) const = 0;
82 
83  /**
84  * Set current effect.
85  * Thread-safe. May be called from any thread
86  */
87  virtual void set_current_effect(const std::shared_ptr<effect> & effect) = 0;
88 
89  /**
90  * Load and activate effect sync.
91  * MUST be called from the render thread.
92  */
93  virtual std::shared_ptr<effect> load(const std::string & url) = 0;
94 
95  /**
96  * Load effect async, activate in the draw() call when it will be ready.
97  * Thread-safe. May be called from any thread.
98  */
99  virtual std::shared_ptr<effect> load_async(const std::string & url) = 0;
100 
101  /**
102  * Reload current effect config from the string provided. If this reload
103  * is possible without effect recreation, this method will return `hot_reload == true`,
104  * otherwise `current` effect will be replaced and the method will return
105  * `hot_reload == false`.
106  *
107  * Thread-safe. May be called from any thread.
108  */
109  virtual std::shared_ptr<reload_result> reload_config(const std::string & config) = 0;
110 
111  /**
112  * Get effect info. May be called before loading effect
113  * "render type" and "recognizer features" fields won't be filled
114  * Thread-safe. May be called from any thread
115  */
116  static effect_info get_effect_info(const std::string & url);
117 
118  /**
119  * Unload effect from cache. if no currently loading effect -
120  * works the same way as load(""); launches empty effect loading.
121  * MUST be called from the render thread
122  */
123  virtual void unload(const std::shared_ptr<effect> & effect) = 0;
124 
125  /**
126  * Get active effect
127  * Thread-safe. May be called from any thread
128  */
129  virtual std::shared_ptr<effect> current() const = 0;
130 
131  /**
132  * Update effect loading state
133  * @param sync syncronize effect manager, block until effect loaded
134  * MUST be called from the render thread
135  */
136  virtual void update(bool sync) = 0;
137 
138  /**
139  * Get current effect size
140  * Thread-safe. May be called from any thread
141  */
142  virtual ::bnb::interfaces::size effect_size() const = 0;
143 
144  /**
145  * Get current surface size
146  * Thread-safe. May be called from any thread
147  */
148  virtual ::bnb::interfaces::size surface_size() const = 0;
149 
150  /**
151  * Get effect audio volume.
152  * Thread-safe. May be called from any thread
153  * @return A volume in range `[0, 1]`, where `1` means maximum volume.
154  */
155  virtual float effect_volume() const = 0;
156 
157  /**
158  * Set effect audio volume.
159  * Thread-safe. May be called from any thread
160  * @param volume A value in range `[0, 1]`, where `1` means maximum volume.
161  */
162  virtual void set_effect_volume(float volume) = 0;
163 
164  /**
165  * Changes effect player render size, should be called on render thread.
166  * MUST be called from the render thread
167  */
168  virtual void set_effect_size(int32_t fx_width, int32_t fx_height) = 0;
169 
170  /** set different render surfaces. Can be treated as void* */
171  virtual void set_render_surface(const surface_data & data) = 0;
172 
173  /** disable surface presentation. Needed for offscreen rendering */
174  virtual void disable_surface_presentation() = 0;
175 };
176 
177 } } // namespace bnb::interfaces
178 /// @}
179 
bnb::interfaces::effect_manager
Definition: effect_manager.hpp:27
bnb::interfaces::error_listener
Interface to receive errors from EffectPlayer.
Definition: error_listener.hpp:19
bnb::interfaces::effect_activated_listener
Interface to receive notifications on effect change.
Definition: effect_activated_listener.hpp:16
bnb::interfaces::surface_data
Data for creating surface.
Definition: surface_data.hpp:16
size.hpp
bnb::interfaces::effect_event_listener
Callback interface for effect events.
Definition: effect_event_listener.hpp:17
bnb::interfaces::hint_listener
Callback to receive "hints" (e.g.
Definition: hint_listener.hpp:19
bnb::interfaces::effect
Definition: effect.hpp:21
bnb::interfaces::effect_info
Definition: effect_info.hpp:17