Banuba SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
platform
desktop
player_api
bnb
player_api
interfaces
player.hpp
1
#pragma once
2
3
#include <bnb/player_api/interfaces/input.hpp>
4
#include <bnb/player_api/interfaces/output.hpp>
5
#include <bnb/player_api/interfaces/render_delegate.hpp>
6
#include <
bnb/effect_player/interfaces/effect_player.hpp
>
7
#include <
bnb/effect_player/interfaces/effect.hpp
>
8
#include <bnb/utils/defs.hpp>
9
10
#include <memory>
11
12
namespace
bnb::player_api::interfaces
13
{
14
class
player
;
15
}
// namespace bnb::player_api::interfaces
16
17
namespace
bnb::player_api
18
{
19
using
player_sptr = std::shared_ptr<bnb::player_api::interfaces::player>;
20
using
effect_sptr = std::shared_ptr<bnb::interfaces::effect>;
21
using
js_callback_sptr = std::shared_ptr<bnb::interfaces::js_callback>;
22
using
effect_player_sptr = std::shared_ptr<bnb::interfaces::effect_player>;
23
}
// namespace bnb::player_api
24
25
namespace
bnb::player_api::interfaces
26
{
27
28
/**
29
* Class manages the lifecycle of the EffectPlayer and is responsible for drawing FrameData
30
* that comes from Input, then processing frame and sending it to Output (or Outputs).
31
* Owns and manages the render thread.
32
*/
33
class
BNB_EXPORT
player
34
{
35
public
:
36
enum class
render_mode
: int32_t
37
{
38
/**
39
*Render in display linked loop with defined `fps`
40
*/
41
loop,
42
/**
43
* Render manually by `render` call
44
*/
45
manual
46
};
47
48
public
:
49
virtual
~player
() =
default
;
50
51
/**
52
* Set rendering mode to another. By default, the render mode is set to LOOP.
53
* @param new_render_mode new rendering mode
54
*/
55
virtual
void
set_render_mode
(
render_mode
new_render_mode) = 0;
56
57
/**
58
* Resume the playback of the effect.
59
*/
60
virtual
void
play
() = 0;
61
62
/**
63
* Pause the playback of the effect.
64
*/
65
virtual
void
pause
() = 0;
66
67
/**
68
* Get an instance of the EffectPlayer
69
*/
70
virtual
effect_player_sptr
get_effect_player
() = 0;
71
72
/**
73
* Use the new input to replace the old one
74
* @param input frames will be receive from it
75
*/
76
virtual
player
&
use
(
const
input_sptr&
input
) = 0;
77
78
/**
79
* Add a new one output to output list
80
* @param output processed frames will be push to it
81
*/
82
virtual
player
&
use
(
const
output_sptr&
output
) = 0;
83
84
/**
85
* Remove one output. If the output `nullptr` is passed as an output, then all outputs are removed.
86
* @param output delete this output from outputs
87
*/
88
virtual
player
&
unuse
(
const
output_sptr&
output
=
nullptr
) = 0;
89
90
/**
91
* Synchronous loading of an effect by name
92
* @param url path to the effect or effect name
93
*/
94
virtual
effect_sptr
load
(
const
std::string& url) = 0;
95
96
/**
97
* Load effect asynchronously by name
98
* @param url path to the effect or effect name
99
*/
100
virtual
effect_sptr
load_async
(
const
std::string& url) = 0;
101
102
/**
103
* Evaluate the `script` in effect
104
* @param script JS string to execute
105
* @param resultCallback Callback for result, will be called in render thread.
106
*/
107
virtual
void
eval_js
(
const
std::string& script, js_callback_sptr callback) = 0;
108
109
/**
110
* Draw and present rendered result synchronously, can be used only in `manual` rendering mode.
111
* @return returns the number of the drawn frame, or -1 if nothing could be drawn.
112
*/
113
virtual
int64_t
render
() = 0;
114
};
// class player
115
116
}
// namespace bnb::player_api::interfaces
bnb::player_api::interfaces::input
The interface is inherited by all classes that must work with the player, responsible for providing f...
Definition
input.hpp:29
bnb::player_api::interfaces::output
The interface is inherited by all classes that must work with player, and responsible for passing the...
Definition
output.hpp:26
bnb::player_api::interfaces::player
Class manages the lifecycle of the EffectPlayer and is responsible for drawing FrameData that comes f...
Definition
player.hpp:34
bnb::player_api::interfaces::player::use
virtual player & use(const output_sptr &output)=0
Add a new one output to output list.
bnb::player_api::interfaces::player::use
virtual player & use(const input_sptr &input)=0
Use the new input to replace the old one.
bnb::player_api::interfaces::player::render_mode
render_mode
Definition
player.hpp:37
bnb::player_api::interfaces::player::eval_js
virtual void eval_js(const std::string &script, js_callback_sptr callback)=0
Evaluate the script in effect.
bnb::player_api::interfaces::player::render
virtual int64_t render()=0
Draw and present rendered result synchronously, can be used only in manual rendering mode.
bnb::player_api::interfaces::player::load_async
virtual effect_sptr load_async(const std::string &url)=0
Load effect asynchronously by name.
bnb::player_api::interfaces::player::play
virtual void play()=0
Resume the playback of the effect.
bnb::player_api::interfaces::player::load
virtual effect_sptr load(const std::string &url)=0
Synchronous loading of an effect by name.
bnb::player_api::interfaces::player::pause
virtual void pause()=0
Pause the playback of the effect.
bnb::player_api::interfaces::player::unuse
virtual player & unuse(const output_sptr &output=nullptr)=0
Remove one output.
bnb::player_api::interfaces::player::get_effect_player
virtual effect_player_sptr get_effect_player()=0
Get an instance of the EffectPlayer.
bnb::player_api::interfaces::player::set_render_mode
virtual void set_render_mode(render_mode new_render_mode)=0
Set rendering mode to another.
effect.hpp
effect_player.hpp
Generated by
1.17.0