Banuba SDK
effect.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 
10 #include "bnb/scene/interfaces/scene.hpp"
11 #include <bnb/utils/defs.hpp>
12 #include <cstdint>
13 #include <memory>
14 #include <string>
15 
16 namespace bnb { namespace interfaces {
17 
18 class js_callback;
19 enum class effect_status;
20 
21 class BNB_EXPORT effect {
22 public:
23  virtual ~effect() {}
24 
25  /** Thread-safe. May be called from any thread */
26  virtual std::string url() = 0;
27 
28  /**
29  * Call js method in effect.
30  * @param method_name JS global function name. Member functions are not supported.
31  * @param params Function arguments.
32  * @depreacted Use `evalJs` instead.
33  */
34  virtual void call_js_method(const std::string & method_name, const std::string & params) = 0;
35 
36  /**
37  * Evaluate the `script` in effect. This method is thread safe.
38  * @param sctipt JS string to execute
39  * @param js_callback Callback for result, will be called in render thread.
40  */
41  virtual void eval_js(const std::string & script, const std::shared_ptr<js_callback> & result_callback) = 0;
42 
43  /**
44  * Evaluate the `script` in effect.
45  * MUST be called from the render thread
46  * @param sctipt JS string to execute
47  * @return JS evaluation result
48  */
49  virtual std::string eval_js_sync(const std::string & script) = 0;
50 
51  /**
52  * Reset effect state
53  * MUST be called from the render thread
54  */
55  virtual void reset() = 0;
56 
57  /**
58  * Update effect state (evaluate scheduled JS calls)
59  * MUST be called from the render thread
60  */
61  virtual void update() = 0;
62 
63  /**
64  * If effect is based on Scene engine and it is activated completly - returns Scene object from the effect.
65  * Otherwise returns null.
66  * MUST be called from the render thread
67  * Returned Scene object MUST be used only from the render thread and only while the effect is in the activated state.
68  */
69  virtual std::shared_ptr<::bnb::interfaces::scene> scene() = 0;
70 
71  /**
72  * Deserialize effect from the provided `resoved_url`. If `config_override` is an
73  * empty string, will use `config.json` under provided `resolved_url`, otherwise
74  * content of `config_override` will be used.
75  *
76  * Can be called from any thread.
77  */
78  virtual void deserialize(const std::string & resolved_url, const std::string & config_override) = 0;
79 
80  /**
81  * activate current effect
82  * MUST be called from the render thread for OpenGL backends.
83  */
84  virtual void activate(int32_t fx_width, int32_t fx_height, int32_t surface_width, int32_t surface_height) = 0;
85 
86  virtual void dump_fs(const std::string & out_dir) = 0;
87 
88  virtual void dump() = 0;
89 
90  virtual std::string dump_json() = 0;
91 
92  virtual effect_status status() = 0;
93 };
94 
95 } } // namespace bnb::interfaces
96 /// @}
97 
bnb::interfaces::effect
Definition: effect.hpp:21