Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
SLGenerator: Visual Studio 17 2022
SLDistributeDirectory: distribute
SLFullDistributePath: "streamlabs-build.app/distribute" # The .app extension is required to run macOS tests correctly.
LibOBSVersion: 31.1.2sl21
LibOBSVersion: 31.1.2ndi1
PACKAGE_NAME: osn

jobs:
Expand Down
7 changes: 7 additions & 0 deletions js/module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ export interface IModule {
readonly binaryPath: string;
readonly dataPath: string;
}
export declare const NDI_RUNTIME_VERSION_MISMATCH = "NDI_RUNTIME_VERSION_MISMATCH";
export declare const NDI_RUNTIME_NOT_FOUND = "NDI_RUNTIME_NOT_FOUND";
export interface IObsModuleLoadFailure {
module: string;
code: string;
message: string;
}
export declare function addItems(scene: IScene, sceneItems: ISceneItemInfo[]): ISceneItem[];
export interface FilterInfo {
name: string;
Expand Down
4 changes: 3 additions & 1 deletion js/module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeObs = exports.AdvancedReplayBufferFactory = exports.SimpleReplayBufferFactory = exports.AudioEncoderFactory = exports.AdvancedRecordingFactory = exports.SimpleRecordingFactory = exports.AudioTrackFactory = exports.NetworkFactory = exports.ReconnectFactory = exports.DelayFactory = exports.EnhancedBroadcastingSimpleStreamingFactory = exports.EnhancedBroadcastingAdvancedStreamingFactory = exports.AdvancedStreamingFactory = exports.SimpleStreamingFactory = exports.ServiceFactory = exports.VideoEncoderFactory = exports.IPC = exports.ModuleFactory = exports.AudioFactory = exports.Audio = exports.FaderFactory = exports.VolmeterFactory = exports.TransitionFactory = exports.FilterFactory = exports.SceneFactory = exports.InputFactory = exports.VideoFactory = exports.Video = exports.Global = exports.DefaultPluginPathMac = exports.DefaultPluginDataPath = exports.DefaultPluginPath = exports.DefaultDataPath = exports.DefaultBinPath = exports.DefaultDrawPluginPath = exports.DefaultOpenGLPath = exports.DefaultD3D11Path = void 0;
exports.NodeObs = exports.NDI_RUNTIME_NOT_FOUND = exports.NDI_RUNTIME_VERSION_MISMATCH = exports.AdvancedReplayBufferFactory = exports.SimpleReplayBufferFactory = exports.AudioEncoderFactory = exports.AdvancedRecordingFactory = exports.SimpleRecordingFactory = exports.AudioTrackFactory = exports.NetworkFactory = exports.ReconnectFactory = exports.DelayFactory = exports.EnhancedBroadcastingSimpleStreamingFactory = exports.EnhancedBroadcastingAdvancedStreamingFactory = exports.AdvancedStreamingFactory = exports.SimpleStreamingFactory = exports.ServiceFactory = exports.VideoEncoderFactory = exports.IPC = exports.ModuleFactory = exports.AudioFactory = exports.Audio = exports.FaderFactory = exports.VolmeterFactory = exports.TransitionFactory = exports.FilterFactory = exports.SceneFactory = exports.InputFactory = exports.VideoFactory = exports.Video = exports.Global = exports.DefaultPluginPathMac = exports.DefaultPluginDataPath = exports.DefaultPluginPath = exports.DefaultDataPath = exports.DefaultBinPath = exports.DefaultDrawPluginPath = exports.DefaultOpenGLPath = exports.DefaultD3D11Path = void 0;
exports.addItems = addItems;
exports.createSources = createSources;
exports.getSourcesSize = getSourcesSize;
Expand Down Expand Up @@ -50,6 +50,8 @@ exports.AdvancedReplayBufferFactory = obs.AdvancedReplayBuffer;
;
;
;
exports.NDI_RUNTIME_VERSION_MISMATCH = 'NDI_RUNTIME_VERSION_MISMATCH';
exports.NDI_RUNTIME_NOT_FOUND = 'NDI_RUNTIME_NOT_FOUND';
function addItems(scene, sceneItems) {
const items = [];
if (Array.isArray(sceneItems)) {
Expand Down
9 changes: 9 additions & 0 deletions js/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,15 @@ export interface IModule {
readonly dataPath: string;
}

export const NDI_RUNTIME_VERSION_MISMATCH = 'NDI_RUNTIME_VERSION_MISMATCH';
export const NDI_RUNTIME_NOT_FOUND = 'NDI_RUNTIME_NOT_FOUND';

export interface IObsModuleLoadFailure {
module: string;
code: string;
message: string;
}

export function addItems(scene: IScene, sceneItems: ISceneItemInfo[]): ISceneItem[] {
const items: ISceneItem[] = [];
if (Array.isArray(sceneItems)) {
Expand Down
38 changes: 38 additions & 0 deletions obs-studio-client/source/nodeobs_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,43 @@ Napi::Value api::OBS_API_destroyOBS_API(const Napi::CallbackInfo &info)
return info.Env().Undefined();
}

Napi::Value api::OBS_API_getModuleLoadFailures(const Napi::CallbackInfo &info)
{
auto conn = GetConnection(info);
if (!conn)
return info.Env().Undefined();

std::vector<ipc::value> response = conn->call_synchronous_helper("API", "OBS_API_getModuleLoadFailures", {});

if (!ValidateResponse(info, response))
return info.Env().Undefined();

if (response.size() < 2) {
Napi::Error::New(info.Env(), "Malformed module load failure response.").ThrowAsJavaScriptException();
return info.Env().Undefined();
}

const uint32_t count = response[1].value_union.ui32;
const size_t expectedSize = 2 + static_cast<size_t>(count) * 3;
if (response.size() < expectedSize) {
Napi::Error::New(info.Env(), "Malformed module load failure response.").ThrowAsJavaScriptException();
return info.Env().Undefined();
}

Napi::Array failures = Napi::Array::New(info.Env(), count);
size_t responseIndex = 2;

for (uint32_t i = 0; i < count; i++) {
Napi::Object failure = Napi::Object::New(info.Env());
failure.Set("module", Napi::String::New(info.Env(), response[responseIndex++].value_str));
failure.Set("code", Napi::String::New(info.Env(), response[responseIndex++].value_str));
failure.Set("message", Napi::String::New(info.Env(), response[responseIndex++].value_str));
failures.Set(i, failure);
}

return failures;
}

Napi::Value api::OBS_API_getPerformanceStatistics(const Napi::CallbackInfo &info)
{
auto conn = GetConnection(info);
Expand Down Expand Up @@ -560,6 +597,7 @@ void api::Init(Napi::Env env, Napi::Object exports)
exports.Set(Napi::String::New(env, "OBS_API_initAPI"), Napi::Function::New(env, api::OBS_API_initAPI));
exports.Set(Napi::String::New(env, "OBS_API_destroyOBS_API"), Napi::Function::New(env, api::OBS_API_destroyOBS_API));
exports.Set(Napi::String::New(env, "OBS_API_getPerformanceStatistics"), Napi::Function::New(env, api::OBS_API_getPerformanceStatistics));
exports.Set(Napi::String::New(env, "OBS_API_getModuleLoadFailures"), Napi::Function::New(env, api::OBS_API_getModuleLoadFailures));
exports.Set(Napi::String::New(env, "SetWorkingDirectory"), Napi::Function::New(env, api::SetWorkingDirectory));
exports.Set(Napi::String::New(env, "InitShutdownSequence"), Napi::Function::New(env, api::InitShutdownSequence));
exports.Set(Napi::String::New(env, "OBS_API_QueryHotkeys"), Napi::Function::New(env, api::OBS_API_QueryHotkeys));
Expand Down
1 change: 1 addition & 0 deletions obs-studio-client/source/nodeobs_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void Init(Napi::Env env, Napi::Object exports);
Napi::Value OBS_API_initAPI(const Napi::CallbackInfo &info);
Napi::Value OBS_API_destroyOBS_API(const Napi::CallbackInfo &info);
Napi::Value OBS_API_getPerformanceStatistics(const Napi::CallbackInfo &info);
Napi::Value OBS_API_getModuleLoadFailures(const Napi::CallbackInfo &info);
Napi::Value SetWorkingDirectory(const Napi::CallbackInfo &info);
Napi::Value InitShutdownSequence(const Napi::CallbackInfo &info);
Napi::Value OBS_API_QueryHotkeys(const Napi::CallbackInfo &info);
Expand Down
52 changes: 46 additions & 6 deletions obs-studio-server/source/nodeobs_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ std::chrono::high_resolution_clock::time_point start_wait_acknowledge;

ipc::server *g_server = nullptr;

struct ModuleLoadFailure {
std::string module;
std::string code;
std::string message;
};

static std::vector<ModuleLoadFailure> moduleLoadFailures;

static bool browserAccel = true;
static bool mediaFileCaching = true;
static uint32_t sdrWhiteLevel = 300;
Expand All @@ -142,6 +150,19 @@ static bool lowLatencyAudioBuffering = false;
static bool forceGPURendering = true;
static std::string processPriority = "Normal";

static void copyModuleLoadFailures(const obs_module_failure_info &mfi)
{
moduleLoadFailures.clear();

if (mfi.failures) {
for (size_t i = 0; i < mfi.count; i++) {
const obs_module_load_failure &failure = mfi.failures[i];
moduleLoadFailures.push_back(
{failure.module ? failure.module : "", failure.code ? failure.code : "", failure.message ? failure.message : ""});
}
}
}

void OBS_API::Register(ipc::server &srv)
{
std::shared_ptr<ipc::collection> cls = std::make_shared<ipc::collection>("API");
Expand All @@ -150,6 +171,7 @@ void OBS_API::Register(ipc::server &srv)
"OBS_API_initAPI", std::vector<ipc::type>{ipc::type::String, ipc::type::String, ipc::type::String, ipc::type::String}, OBS_API_initAPI));
cls->register_function(std::make_shared<ipc::function>("OBS_API_destroyOBS_API", std::vector<ipc::type>{}, OBS_API_destroyOBS_API));
cls->register_function(std::make_shared<ipc::function>("OBS_API_getPerformanceStatistics", std::vector<ipc::type>{}, OBS_API_getPerformanceStatistics));
cls->register_function(std::make_shared<ipc::function>("OBS_API_getModuleLoadFailures", std::vector<ipc::type>{}, OBS_API_getModuleLoadFailures));
cls->register_function(std::make_shared<ipc::function>("SetWorkingDirectory", std::vector<ipc::type>{ipc::type::String}, SetWorkingDirectory));
cls->register_function(std::make_shared<ipc::function>("StopCrashHandler", std::vector<ipc::type>{}, StopCrashHandler));
cls->register_function(std::make_shared<ipc::function>("OBS_API_QueryHotkeys", std::vector<ipc::type>{}, QueryHotkeys));
Expand Down Expand Up @@ -994,18 +1016,22 @@ void OBS_API::OBS_API_initAPI(void *data, const int64_t id, const std::vector<ip
obs_data_release(private_settings);

addModulePaths();
struct obs_module_failure_info mfi;
struct obs_module_failure_info mfi = {};
obs_load_all_modules2(&mfi);
copyModuleLoadFailures(mfi);
obs_log_loaded_modules();
obs_post_load_modules();

if (mfi.count) {
char **plugin = mfi.failed_modules;
while (*plugin) {
blog(LOG_ERROR, "Failed to load plugin: %s", *plugin);
plugin++;
if (!moduleLoadFailures.empty()) {
for (const ModuleLoadFailure &failure : moduleLoadFailures) {
if (!failure.code.empty() || !failure.message.empty()) {
blog(LOG_ERROR, "Failed to load plugin: %s (%s): %s", failure.module.c_str(), failure.code.c_str(), failure.message.c_str());
} else {
blog(LOG_ERROR, "Failed to load plugin: %s", failure.module.c_str());
}
}
}
obs_module_failure_info_free(&mfi);

OBS_service::createService(StreamServiceId::Main);
OBS_service::createService(StreamServiceId::Second);
Expand Down Expand Up @@ -1069,6 +1095,20 @@ void OBS_API::OBS_API_destroyOBS_API(void *data, const int64_t id, const std::ve
AUTO_DEBUG;
}

void OBS_API::OBS_API_getModuleLoadFailures(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval)
{
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
rval.push_back(ipc::value((uint32_t)moduleLoadFailures.size()));

for (const ModuleLoadFailure &failure : moduleLoadFailures) {
rval.push_back(ipc::value(failure.module));
rval.push_back(ipc::value(failure.code));
rval.push_back(ipc::value(failure.message));
}

AUTO_DEBUG;
}

void OBS_API::OBS_API_getPerformanceStatistics(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval)
{
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
Expand Down
1 change: 1 addition & 0 deletions obs-studio-server/source/nodeobs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class OBS_API {
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 OBS_API_getModuleLoadFailures(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);
Expand Down
Loading