noobs 0.0.158 → 0.0.177
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 -3
- package/src/obs_interface.h +2 -0
- 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
|
|
|
@@ -612,6 +612,8 @@ void ObsInterface::connect_signal_handlers(obs_output_t *output) {
|
|
|
612
612
|
signal_handler_connect(sh, "starting", output_signal_handler, starting_ctx);
|
|
613
613
|
signal_handler_connect(sh, "stopping", output_signal_handler, stopping_ctx);
|
|
614
614
|
signal_handler_connect(sh, "stop", output_signal_handler, stop_ctx);
|
|
615
|
+
signal_handler_connect(sh, "activate", output_signal_handler, activate_ctx);
|
|
616
|
+
signal_handler_connect(sh, "deactivate", output_signal_handler, deactivate_ctx);
|
|
615
617
|
}
|
|
616
618
|
|
|
617
619
|
void ObsInterface::disconnect_signal_handlers(obs_output_t *output) {
|
|
@@ -620,6 +622,8 @@ void ObsInterface::disconnect_signal_handlers(obs_output_t *output) {
|
|
|
620
622
|
signal_handler_disconnect(sh, "start", output_signal_handler, start_ctx);
|
|
621
623
|
signal_handler_disconnect(sh, "stopping", output_signal_handler, stopping_ctx);
|
|
622
624
|
signal_handler_disconnect(sh, "stop", output_signal_handler, stop_ctx);
|
|
625
|
+
signal_handler_disconnect(sh, "activate", output_signal_handler, activate_ctx);
|
|
626
|
+
signal_handler_disconnect(sh, "deactivate ", output_signal_handler, deactivate_ctx);
|
|
623
627
|
}
|
|
624
628
|
|
|
625
629
|
bool draw_source_outline(obs_scene_t *scene, obs_sceneitem_t *item, void *p) {
|
|
@@ -935,6 +939,8 @@ ObsInterface::ObsInterface(
|
|
|
935
939
|
start_ctx = new SignalContext{ this, "start" };
|
|
936
940
|
stopping_ctx = new SignalContext{ this, "stopping" };
|
|
937
941
|
stop_ctx = new SignalContext{ this, "stop" };
|
|
942
|
+
activate_ctx = new SignalContext{this, "activate"};
|
|
943
|
+
deactivate_ctx = new SignalContext{this, "deactivate"};
|
|
938
944
|
|
|
939
945
|
// Create the resources we rely on.
|
|
940
946
|
create_scene();
|
|
@@ -965,6 +971,8 @@ ObsInterface::~ObsInterface() {
|
|
|
965
971
|
delete start_ctx;
|
|
966
972
|
delete stopping_ctx;
|
|
967
973
|
delete stop_ctx;
|
|
974
|
+
delete activate_ctx;
|
|
975
|
+
delete deactivate_ctx;
|
|
968
976
|
|
|
969
977
|
for (auto& kv : sources) {
|
|
970
978
|
std::string name = kv.first;
|
package/src/obs_interface.h
CHANGED
|
@@ -119,6 +119,8 @@ class ObsInterface {
|
|
|
119
119
|
SignalContext* start_ctx;
|
|
120
120
|
SignalContext* stopping_ctx;
|
|
121
121
|
SignalContext* stop_ctx;
|
|
122
|
+
SignalContext* activate_ctx;
|
|
123
|
+
SignalContext* deactivate_ctx;
|
|
122
124
|
static void output_signal_handler(void *data, calldata_t *cd);
|
|
123
125
|
|
|
124
126
|
void list_encoders(obs_encoder_type type = OBS_ENCODER_VIDEO);
|
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) {
|