Repository navigation
Expand file tree
/
Copy pathavplumber.hpp
More file actions
88 lines (81 loc) · 2.52 KB
/
Copy pathavplumber.hpp
File metadata and controls
88 lines (81 loc) · 2.52 KB
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
#pragma once
#include <cstdint>
#include <string>
#include <thread>
#include <atomic>
#include <functional>
#include <memory>
class ControlImpl;
class NodeManager;
#ifdef EMBED_IN_OBS
struct obs_source;
typedef struct obs_source obs_source_t;
#endif
/*
* Usage #1: (as in standalone application)
* mainLoop()
* will return after any node with restart=panic or restart=exit finishes or you call
* stopMainLoop()
* from a different thread or from interrupt
*
* Usage #2: (as in obs-avplumber-source)
* setReady()
* will make avplumber usable, working in background threads. When you want it to stop working, call:
* shutdown()
* you may want to call
* heartbeat()
* periodically to make avplumber print some status information to the log
*/
class AVPlumber {
private:
ControlImpl* impl_;
uint16_t control_port_;
std::string webui_api_url_;
std::string instance_name_;
std::string log_file_;
std::thread webui_heartbeat_thread_;
std::atomic<bool> webui_heartbeat_stop_;
void webuiHeartbeatThread();
#ifdef EMBED_IN_OBS
std::string PAUSE_TEAM_;
std::string REALTIME_TEAM_;
void get_pause_team_name();
void get_realtime_team_name();
#endif
public:
AVPlumber();
~AVPlumber();
void enableControlServer(const uint16_t tcp_port);
void registerWithWebUI(const std::string& webui_api_url, const std::string& instance_name = "", const std::string& log_file = "");
ControlImpl* controlImpl() { return impl_; }
std::shared_ptr<NodeManager> manager();
#ifdef EMBED_IN_OBS
void setObsSource(obs_source_t* obssrc);
void unsetObsSourceAndWait();
void obsTick();
bool obs_is_paused();
void obs_play();
void obs_pause();
void obs_stop();
void obs_restart();
int64_t obs_get_time();
void obs_set_time(int64_t ms);
int64_t obs_get_duration();
double obs_get_speed();
bool obs_is_eof();
#endif
void executeCommandsFromFile(const std::string path);
void executeCommandsFromString(const std::string script);
void registerControlCommand(
const std::string& command,
std::function<std::string(const std::string&)> handler,
bool no_lock = false, bool quiet = false);
void setLogFile(const std::string path);
void setLogCallback(std::function<void(const std::string &)> callback);
void setExceptionCallback(std::function<void(const std::string&, const std::string&, const std::string&)> callback);
void setReady();
void shutdown();
void mainLoop();
void stopMainLoop();
void heartbeat();
};