noobs 0.0.157 → 0.0.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/noobs.node +0 -0
- package/package.json +1 -1
- package/src/obs_interface.cpp +11 -5
- package/src/utils.cpp +41 -41
package/dist/noobs.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/obs_interface.cpp
CHANGED
|
@@ -66,10 +66,10 @@ void ObsInterface::load_module(const char* module, const char* data, bool allowF
|
|
|
66
66
|
blog(LOG_INFO, "Allow fail: %d", allowFail);
|
|
67
67
|
|
|
68
68
|
obs_module_t *ptr = NULL;
|
|
69
|
-
int
|
|
69
|
+
int openmod = obs_open_module(&ptr, module, data);
|
|
70
70
|
|
|
71
|
-
if (
|
|
72
|
-
blog(LOG_ERROR, "Failed to open module: %s", module);
|
|
71
|
+
if (openmod != MODULE_SUCCESS) {
|
|
72
|
+
blog(LOG_ERROR, "Failed to open module: %s, %d", module, openmod);
|
|
73
73
|
throw std::runtime_error("Failed to open module!");
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -119,7 +119,6 @@ void ObsInterface::setVideoContext(int fps, int width, int height) {
|
|
|
119
119
|
create_video_encoders();
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
123
122
|
int ObsInterface::reset_video(int fps, int width, int height) {
|
|
124
123
|
blog(LOG_INFO, "Reset video");
|
|
125
124
|
obs_video_info ovi = {};
|
|
@@ -139,7 +138,14 @@ int ObsInterface::reset_video(int fps, int width, int height) {
|
|
|
139
138
|
ovi.gpu_conversion = true;
|
|
140
139
|
ovi.graphics_module = "libobs-d3d11.dll";
|
|
141
140
|
|
|
142
|
-
|
|
141
|
+
int rc = obs_reset_video(&ovi);
|
|
142
|
+
|
|
143
|
+
if (rc == OBS_VIDEO_SUCCESS) {
|
|
144
|
+
// Without this HDR doesn't work.
|
|
145
|
+
obs_set_video_levels(300.0f, 1000.0f);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return rc;
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
bool ObsInterface::reset_audio() {
|
package/src/utils.cpp
CHANGED
|
@@ -8,56 +8,56 @@
|
|
|
8
8
|
#include <windows.h>
|
|
9
9
|
|
|
10
10
|
void log_handler(int lvl, const char *msg, va_list args, void *p) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
std::stringstream filename;
|
|
19
|
-
filename << "OBS-" << std::put_time(std::localtime(&t), "%Y-%m-%d") << ".log";
|
|
11
|
+
static std::stringstream logFileName;
|
|
12
|
+
static bool logInitialized = false;
|
|
13
|
+
|
|
14
|
+
if (!logInitialized) {
|
|
15
|
+
// Build the log filename.
|
|
16
|
+
auto now = std::chrono::system_clock::now();
|
|
17
|
+
auto t = std::chrono::system_clock::to_time_t(now);
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
if (!log_dir.empty() && log_dir.back() != '\\' && log_dir.back() != '/')
|
|
23
|
-
log_dir += '\\';
|
|
19
|
+
std::string logDir = static_cast<const char*>(p);
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
if (!logDir.empty() && logDir.back() != '\\' && logDir.back() != '/') {
|
|
22
|
+
logDir += '\\';
|
|
27
23
|
}
|
|
24
|
+
|
|
25
|
+
logFileName << logDir << "OBS-" << std::put_time(std::localtime(&t), "%Y-%m-%d") << ".log";
|
|
26
|
+
logInitialized = true;
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
// Timestamp
|
|
30
|
+
auto now = std::chrono::system_clock::now();
|
|
31
|
+
auto t = std::chrono::system_clock::to_time_t(now);
|
|
32
|
+
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
33
|
+
now.time_since_epoch()) % 1000;
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
35
|
-
now.time_since_epoch()) % 1000;
|
|
35
|
+
std::stringstream timestamp;
|
|
36
|
+
timestamp << "[" << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S")
|
|
37
|
+
<< "." << std::setfill('0') << std::setw(3) << ms.count() << "] ";
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
// Log level
|
|
40
|
+
const char* level_str = "UNKNOWN";
|
|
41
|
+
switch (lvl) {
|
|
42
|
+
case LOG_ERROR: level_str = "ERROR"; break;
|
|
43
|
+
case LOG_WARNING: level_str = "WARN"; break;
|
|
44
|
+
case LOG_INFO: level_str = "INFO"; break;
|
|
45
|
+
case LOG_DEBUG: level_str = "DEBUG"; break;
|
|
46
|
+
}
|
|
47
|
+
timestamp << "[" << level_str << "] ";
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
case LOG_ERROR: level_str = "ERROR"; break;
|
|
45
|
-
case LOG_WARNING: level_str = "WARN"; break;
|
|
46
|
-
case LOG_INFO: level_str = "INFO"; break;
|
|
47
|
-
case LOG_DEBUG: level_str = "DEBUG"; break;
|
|
48
|
-
}
|
|
49
|
-
timestamp << "[" << level_str << "] ";
|
|
49
|
+
// Format message
|
|
50
|
+
char buffer[4096];
|
|
51
|
+
vsnprintf(buffer, sizeof(buffer), msg, args);
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
// Prepend timestamp and flush per line
|
|
54
|
+
std::istringstream iss(buffer);
|
|
55
|
+
std::string line;
|
|
56
|
+
std::ofstream logFile(logFileName.str(), std::ios::app);
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
while (std::getline(iss, line)) {
|
|
59
|
-
logFile << timestamp.str() << line << std::endl; // std::endl flushes
|
|
60
|
-
}
|
|
58
|
+
while (logFile.is_open() && std::getline(iss, line)) {
|
|
59
|
+
logFile << timestamp.str() << line << std::endl; // std::endl flushes
|
|
60
|
+
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
Napi::Object data_to_napi(Napi::Env env, obs_data_t* data) {
|