-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathnodeobs_api.h
More file actions
171 lines (141 loc) · 8.11 KB
/
Copy pathnodeobs_api.h
File metadata and controls
171 lines (141 loc) · 8.11 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/******************************************************************************
Copyright (C) 2016-2019 by Streamlabs (General Workings Inc)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#ifdef WIN32
#include <io.h>
#endif
#include <iostream>
#include <ipc-server.hpp>
#include <math.h>
#include <obs.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include "nodeobs_configManager.hpp"
//#include "nodeobs_service.h"
#include "util-osx.hpp"
extern std::string g_moduleDirectory;
namespace util {
class CrashManager;
}
class OBS_API {
friend util::CrashManager;
public:
struct LogReport {
static const int MaximumMessages = 150;
void push(std::string message)
{
general.push_back(message);
if (general.size() > MaximumMessages) {
general.pop_front();
}
}
std::deque<std::string> general;
};
struct OutputStats {
double kbitsPerSec = 0;
double dataOutput = 0;
uint64_t lastBytesSent = 0;
uint64_t lastBytesSentTime = 0;
};
public:
OBS_API();
~OBS_API();
static void Register(ipc::server &);
static void OBS_API_initAPI(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_API_destroyOBS_API(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_API_getPerformanceStatistics(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetWorkingDirectory(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void StopCrashHandler(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void InformCrashHandler(const int crash_id);
static void CrashModuleInfo(const std::string &moduleName, const std::string &binaryPath);
static void QueryHotkeys(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void ProcessHotkeyStatus(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetUsername(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_API_forceCrash(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetBrowserAcceleration(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetBrowserAcceleration(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetBrowserAccelerationLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetMediaFileCaching(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetMediaFileCaching(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetMediaFileCachingLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetProcessPriority(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetProcessPriority(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetProcessPriorityLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetSdrWhiteLevel(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetSdrWhiteLevel(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetSdrWhiteLevelLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetHdrNominalPeakLevel(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetHdrNominalPeakLevel(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetHdrNominalPeakLevelLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetLowLatencyAudioBuffering(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetLowLatencyAudioBuffering(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetLowLatencyAudioBufferingLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetForceGPURendering(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void SetForceGPURendering(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void GetForceGPURenderingLegacy(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static bool getBrowserAcceleration();
static bool getMediaFileCaching();
public:
static void initAPI(void);
static bool openAllModules(int &video_err);
static double getCPU_Percentage(void);
static int getNumberOfDroppedFrames(void);
static double getDroppedFramesPercentage(void);
static double getCurrentFrameRate(void);
static double getAverageTimeToRenderFrame();
static std::string getDiskSpaceAvailable();
static double getMemoryUsage();
static void getCurrentOutputStats(obs_output_t *output, OBS_API::OutputStats &outputStats);
// Snapshot (and clear) the general log tail under logMutex. Uses try_lock — the crash
// handler calls this and must never block on the logging thread. Returns oldest-first,
// empty if the lock can't be acquired.
static std::deque<std::string> snapshotOBSLogGeneral();
static std::string getCurrentVersion();
static std::string getUsername();
static std::vector<std::string> exploreDirectory(std::string directory, std::string typeToReturn);
public:
static std::string getPathConfigDirectory(void);
static void setPathConfigDirectory(std::string newPathConfigDirectory);
static std::string getOBS_currentProfile(void);
static void setOBS_currentProfile(std::string profileName);
static std::string getOBS_currentSceneCollection(void);
static void setOBS_currentSceneCollection(std::string sceneCollectionName);
static bool isOBS_configFilesUsed(void);
static std::string getModuleDirectory(void);
static std::vector<std::pair<uint32_t, uint32_t>> availableResolutions(void);
static std::string getGlobalConfigPath(void);
static std::string getBasicConfigPath(void);
static std::string getServiceConfigPath(void);
static std::string getContentConfigPath(void);
static void setAudioDeviceMonitoring(void);
static void SetProcessPriorityOld(const char *priority);
static void destroyOBS_API(void);
static void SetCrashHandlerPipe(const std::wstring &);
static void CreateCrashHandlerExitPipe();
static void WaitCrashHandlerClose(bool waitBeforeClosing);
};
class outdated_driver_error {
static outdated_driver_error *inst;
std::string line_1 = "";
std::string line_2 = "";
int lookup_enabled = 0;
public:
static outdated_driver_error *instance();
void set_active(bool state);
std::string get_error();
void catch_error(const char *msg);
};