diff --git a/obs-studio-client/source/nodeobs_autoconfig.cpp b/obs-studio-client/source/nodeobs_autoconfig.cpp index 7652c5b57..6499e4969 100644 --- a/obs-studio-client/source/nodeobs_autoconfig.cpp +++ b/obs-studio-client/source/nodeobs_autoconfig.cpp @@ -25,6 +25,7 @@ uint32_t autoConfig::sleepIntervalMS = 33; Napi::ThreadSafeFunction autoConfig::js_thread; std::thread *autoConfig::worker_thread = nullptr; std::vector autoConfig::ac_queue_task_workers; +std::string bind_ip = "default"; #ifdef WIN32 const char *ac_sem_name = nullptr; // Not used on Windows @@ -106,6 +107,7 @@ Napi::Value autoConfig::InitializeAutoConfig(const Napi::CallbackInfo &info) Napi::Object serverInfo = info[1].ToObject(); std::string continent = serverInfo.Get("continent").ToString().Utf8Value(); std::string service = serverInfo.Get("service_name").ToString().Utf8Value(); + bind_ip = serverInfo.Get("bind_ip").ToString().Utf8Value(); auto conn = GetConnection(info); if (!conn) @@ -130,7 +132,7 @@ Napi::Value autoConfig::StartBandwidthTest(const Napi::CallbackInfo &info) if (!conn) return info.Env().Undefined(); - std::vector response = conn->call_synchronous_helper("AutoConfig", "StartBandwidthTest", {}); + std::vector response = conn->call_synchronous_helper("AutoConfig", "StartBandwidthTest", {ipc::value(bind_ip)}); if (!ValidateResponse(info, response)) return info.Env().Undefined(); @@ -225,43 +227,74 @@ Napi::Value autoConfig::StartCheckSettings(const Napi::CallbackInfo &info) return info.Env().Undefined(); } -Napi::Value autoConfig::StartSetDefaultSettings(const Napi::CallbackInfo &info) +Napi::Value autoConfig::UseAutoConfigDefaultSettings(const Napi::CallbackInfo &info) { auto conn = GetConnection(info); if (!conn) return info.Env().Undefined(); - std::vector response = conn->call_synchronous_helper("AutoConfig", "StartSetDefaultSettings", {}); + std::vector response = conn->call_synchronous_helper("AutoConfig", "UseAutoConfigDefaultSettings", {}); if (!ValidateResponse(info, response)) return info.Env().Undefined(); return info.Env().Undefined(); } -Napi::Value autoConfig::StartSaveStreamSettings(const Napi::CallbackInfo &info) -{ - auto conn = GetConnection(info); - if (!conn) - return info.Env().Undefined(); +namespace { - std::vector response = conn->call_synchronous_helper("AutoConfig", "StartSaveStreamSettings", {}); - if (!ValidateResponse(info, response)) - return info.Env().Undefined(); - - return info.Env().Undefined(); +Napi::Value napiValueFromIpcValue(const Napi::Env &env, const ipc::value &v) +{ + switch (v.type) { + case ipc::type::Null: + return env.Null(); + case ipc::type::Float: + return Napi::Number::New(env, v.value_union.fp32); + case ipc::type::Double: + return Napi::Number::New(env, v.value_union.fp64); + case ipc::type::Int32: + return Napi::Number::New(env, v.value_union.i32); + case ipc::type::Int64: + return Napi::Number::New(env, v.value_union.i64); + case ipc::type::UInt32: + return Napi::Number::New(env, v.value_union.ui32); + case ipc::type::UInt64: + return Napi::Number::New(env, v.value_union.ui64); + case ipc::type::String: + return Napi::String::New(env, v.value_str); + case ipc::type::Binary: { + auto res = Napi::ArrayBuffer::New(env, v.value_bin.size()); + for (std::size_t i = 0; i < v.value_bin.size(); ++i) { + res.Set(i, v.value_bin[i]); + } + return res; + } + } } -Napi::Value autoConfig::StartSaveSettings(const Napi::CallbackInfo &info) +} // namespace + +Napi::Value autoConfig::GetNewSettings(const Napi::CallbackInfo &info) { auto conn = GetConnection(info); if (!conn) return info.Env().Undefined(); - std::vector response = conn->call_synchronous_helper("AutoConfig", "StartSaveSettings", {}); + std::vector response = conn->call_synchronous_helper("AutoConfig", "GetNewSettings", {}); if (!ValidateResponse(info, response)) return info.Env().Undefined(); - return info.Env().Undefined(); + std::size_t counter = 0; + auto result = Napi::Array::New(info.Env()); + for (std::size_t i = 1; i < response.size(); i += 3, counter++) { + auto settingsTuple = Napi::Array::New(info.Env()); + settingsTuple.Set(uint32_t(0), Napi::String::New(info.Env(), response[i].value_str)); + settingsTuple.Set(uint32_t(1), Napi::String::New(info.Env(), response[i + 1].value_str)); + settingsTuple.Set(uint32_t(2), napiValueFromIpcValue(info.Env(), response[i + 2])); + + result.Set(counter, settingsTuple); + } + + return result; } Napi::Value autoConfig::TerminateAutoConfig(const Napi::CallbackInfo &info) @@ -288,8 +321,7 @@ void autoConfig::Init(Napi::Env env, Napi::Object exports) exports.Set(Napi::String::New(env, "StartStreamEncoderTest"), Napi::Function::New(env, autoConfig::StartStreamEncoderTest)); exports.Set(Napi::String::New(env, "StartRecordingEncoderTest"), Napi::Function::New(env, autoConfig::StartRecordingEncoderTest)); exports.Set(Napi::String::New(env, "StartCheckSettings"), Napi::Function::New(env, autoConfig::StartCheckSettings)); - exports.Set(Napi::String::New(env, "StartSetDefaultSettings"), Napi::Function::New(env, autoConfig::StartSetDefaultSettings)); - exports.Set(Napi::String::New(env, "StartSaveStreamSettings"), Napi::Function::New(env, autoConfig::StartSaveStreamSettings)); - exports.Set(Napi::String::New(env, "StartSaveSettings"), Napi::Function::New(env, autoConfig::StartSaveSettings)); + exports.Set(Napi::String::New(env, "UseAutoConfigDefaultSettings"), Napi::Function::New(env, autoConfig::UseAutoConfigDefaultSettings)); + exports.Set(Napi::String::New(env, "GetNewSettings"), Napi::Function::New(env, autoConfig::GetNewSettings)); exports.Set(Napi::String::New(env, "TerminateAutoConfig"), Napi::Function::New(env, autoConfig::TerminateAutoConfig)); } diff --git a/obs-studio-client/source/nodeobs_autoconfig.hpp b/obs-studio-client/source/nodeobs_autoconfig.hpp index c15083c87..78cc7abf5 100644 --- a/obs-studio-client/source/nodeobs_autoconfig.hpp +++ b/obs-studio-client/source/nodeobs_autoconfig.hpp @@ -57,8 +57,7 @@ Napi::Value StartBandwidthTest(const Napi::CallbackInfo &info); Napi::Value StartStreamEncoderTest(const Napi::CallbackInfo &info); Napi::Value StartRecordingEncoderTest(const Napi::CallbackInfo &info); Napi::Value StartCheckSettings(const Napi::CallbackInfo &info); -Napi::Value StartSetDefaultSettings(const Napi::CallbackInfo &info); -Napi::Value StartSaveStreamSettings(const Napi::CallbackInfo &info); -Napi::Value StartSaveSettings(const Napi::CallbackInfo &info); +Napi::Value UseAutoConfigDefaultSettings(const Napi::CallbackInfo &info); +Napi::Value GetNewSettings(const Napi::CallbackInfo &info); Napi::Value TerminateAutoConfig(const Napi::CallbackInfo &info); } diff --git a/obs-studio-server/source/nodeobs_autoconfig.cpp b/obs-studio-server/source/nodeobs_autoconfig.cpp index 128204360..ad23cd2ce 100644 --- a/obs-studio-server/source/nodeobs_autoconfig.cpp +++ b/obs-studio-server/source/nodeobs_autoconfig.cpp @@ -111,6 +111,25 @@ struct ServerInfo { inline ServerInfo(const char *name_, const char *address_) : name(name_), address(address_) {} }; + +inline const char *GetEncoderDisplayName(Encoder enc) +{ + switch (enc) { + case Encoder::NVENC: + return SIMPLE_ENCODER_NVENC; + case Encoder::QSV: + return SIMPLE_ENCODER_QSV; + case Encoder::AMD: + return SIMPLE_ENCODER_AMD; + case Encoder::appleHW: + return APPLE_HARDWARE_VIDEO_ENCODER; + case Encoder::appleHWM1: + return APPLE_HARDWARE_VIDEO_ENCODER_M1; + default: + return SIMPLE_ENCODER_X264; + } +}; + void autoConfig::Register(ipc::server &srv) { std::shared_ptr cls = std::make_shared("AutoConfig"); @@ -121,9 +140,9 @@ void autoConfig::Register(ipc::server &srv) cls->register_function(std::make_shared("StartStreamEncoderTest", std::vector{}, autoConfig::StartStreamEncoderTest)); cls->register_function(std::make_shared("StartRecordingEncoderTest", std::vector{}, autoConfig::StartRecordingEncoderTest)); cls->register_function(std::make_shared("StartCheckSettings", std::vector{}, autoConfig::StartCheckSettings)); - cls->register_function(std::make_shared("StartSetDefaultSettings", std::vector{}, autoConfig::StartSetDefaultSettings)); - cls->register_function(std::make_shared("StartSaveStreamSettings", std::vector{}, autoConfig::StartSaveStreamSettings)); - cls->register_function(std::make_shared("StartSaveSettings", std::vector{}, autoConfig::StartSaveSettings)); + cls->register_function( + std::make_shared("UseAutoConfigDefaultSettings", std::vector{}, autoConfig::UseAutoConfigDefaultSettings)); + cls->register_function(std::make_shared("GetNewSettings", std::vector{}, autoConfig::GetNewSettings)); cls->register_function(std::make_shared("TerminateAutoConfig", std::vector{}, autoConfig::TerminateAutoConfig)); cls->register_function(std::make_shared("Query", std::vector{}, autoConfig::Query)); @@ -269,13 +288,59 @@ void GetServers(std::vector &servers) obs_properties_destroy(ppts); } -void start_next_step(void (*task)(), std::string event, std::string description, int percentage) +void autoConfig::GetNewSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval) { - /*eventCallbackQueue.work_queue.push_back({cb, event, description, percentage}); - eventCallbackQueue.Signal(); + rval.push_back(ipc::value((uint64_t)ErrorCode::Ok)); + + rval.push_back(ipc::value("Output")); + rval.push_back(ipc::value("Mode")); + rval.push_back(ipc::value("Simple")); + + rval.push_back(ipc::value("Output")); + rval.push_back(ipc::value("VBitrate")); + rval.push_back(ipc::value(idealBitrate)); + + rval.push_back(ipc::value("Output")); + rval.push_back(ipc::value("StreamEncoder")); + rval.push_back(ipc::value(GetEncoderDisplayName(streamingEncoder))); + + if (recordingEncoder != Encoder::Stream) { + rval.push_back(ipc::value("Output")); + rval.push_back(ipc::value("RecEncoder")); + rval.push_back(ipc::value(GetEncoderDisplayName(recordingEncoder))); + } - if(task) - std::thread(*task).detach();*/ + rval.push_back(ipc::value("Output")); + rval.push_back(ipc::value("RecQuality")); + rval.push_back(ipc::value(recordingQuality == Quality::High ? "Small" : "Stream")); + + rval.push_back(ipc::value("Video")); + rval.push_back(ipc::value("outputWidth")); + rval.push_back(ipc::value(idealResolutionCX)); + + rval.push_back(ipc::value("Video")); + rval.push_back(ipc::value("outputHeight")); + rval.push_back(ipc::value(idealResolutionCY)); + + rval.push_back(ipc::value("Advanced")); + rval.push_back(ipc::value("DynamicBitrate")); + rval.push_back(ipc::value(false)); + + if (fpsType != FPSType::UseCurrent) { + rval.push_back(ipc::value("Video")); + rval.push_back(ipc::value("fpsType")); + rval.push_back(ipc::value(0)); + + rval.push_back(ipc::value("Video")); + rval.push_back(ipc::value("fpsNum")); + rval.push_back(ipc::value(idealFPSNum)); + + rval.push_back(ipc::value("Video")); + rval.push_back(ipc::value("fpsDen")); + rval.push_back(ipc::value(1)); + } + + AUTO_DEBUG; } void autoConfig::TerminateAutoConfig(void *data, const int64_t id, const std::vector &args, std::vector &rval) @@ -329,7 +394,8 @@ void autoConfig::InitializeAutoConfig(void *data, const int64_t id, const std::v void autoConfig::StartBandwidthTest(void *data, const int64_t id, const std::vector &args, std::vector &rval) { - asyncTests[ThreadedTests::BandwidthTest] = std::async(std::launch::async, TestBandwidthThread); + const std::string bindIp = args[0].value_str; + asyncTests[ThreadedTests::BandwidthTest] = std::async(std::launch::async, TestBandwidthThread, bindIp); rval.push_back(ipc::value((uint64_t)ErrorCode::Ok)); AUTO_DEBUG; @@ -351,24 +417,6 @@ void autoConfig::StartRecordingEncoderTest(void *data, const int64_t id, const s AUTO_DEBUG; } -void autoConfig::StartSaveStreamSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval) -{ - asyncTests[ThreadedTests::SaveStreamSettings] = std::async(std::launch::async, SaveStreamSettings); - - rval.push_back(ipc::value((uint64_t)ErrorCode::Ok)); - AUTO_DEBUG; -} - -void autoConfig::StartSaveSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval) -{ - asyncTests[ThreadedTests::SaveSettings] = std::async(std::launch::async, SaveSettings); - - cancel = false; - - rval.push_back(ipc::value((uint64_t)ErrorCode::Ok)); - AUTO_DEBUG; -} - void autoConfig::StartCheckSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval) { bool sucess = CheckSettings(); @@ -378,9 +426,15 @@ void autoConfig::StartCheckSettings(void *data, const int64_t id, const std::vec AUTO_DEBUG; } -void autoConfig::StartSetDefaultSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval) +void autoConfig::UseAutoConfigDefaultSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval) { - asyncTests[ThreadedTests::SetDefaultSettings] = std::async(std::launch::async, SetDefaultSettings); + idealResolutionCX = 1280; + idealResolutionCY = 720; + idealFPSNum = 30; + recordingQuality = Quality::High; + idealBitrate = 2500; + streamingEncoder = Encoder::x264; + recordingEncoder = Encoder::Stream; rval.push_back(ipc::value((uint64_t)ErrorCode::Ok)); AUTO_DEBUG; @@ -474,7 +528,7 @@ void sendErrorMessage(const std::string &message) eventsMutex.unlock(); } -void autoConfig::TestBandwidthThread(void) +void autoConfig::TestBandwidthThread(std::string bindIp) { eventsMutex.lock(); events.push(AutoConfigInfo("starting_step", "bandwidth_test", 0)); @@ -619,11 +673,8 @@ void autoConfig::TestBandwidthThread(void) obs_data_set_string(vencoder_settings, "rate_control", "CBR"); obs_data_set_string(vencoder_settings, "preset", "veryfast"); obs_data_set_int(vencoder_settings, "keyint_sec", 2); - obs_data_set_int(aencoder_settings, "bitrate", 32); - - const char *bind_ip = config_get_string(ConfigManager::getInstance().getBasic(), "Output", "BindIP"); - obs_data_set_string(output_settings, "bind_ip", bind_ip); + obs_data_set_string(output_settings, "bind_ip", bindIp.c_str()); /* -----------------------------------*/ /* determine which servers to test */ @@ -1267,24 +1318,6 @@ inline const char *GetEncoderId(Encoder enc) } }; -inline const char *GetEncoderDisplayName(Encoder enc) -{ - switch (enc) { - case Encoder::NVENC: - return SIMPLE_ENCODER_NVENC; - case Encoder::QSV: - return SIMPLE_ENCODER_QSV; - case Encoder::AMD: - return SIMPLE_ENCODER_AMD; - case Encoder::appleHW: - return APPLE_HARDWARE_VIDEO_ENCODER; - case Encoder::appleHWM1: - return APPLE_HARDWARE_VIDEO_ENCODER_M1; - default: - return SIMPLE_ENCODER_X264; - } -}; - bool autoConfig::CheckSettings(void) { OBSData settings = obs_data_create(); @@ -1444,99 +1477,10 @@ bool autoConfig::CheckSettings(void) if (ret != OBS_VIDEO_SUCCESS) { blog(LOG_ERROR, "[VIDEO_CANVAS] Failed to remove video info after CheckSettings, %08X", ovi); } - return success; -} - -void autoConfig::SetDefaultSettings(void) -{ - eventsMutex.lock(); - events.push(AutoConfigInfo("starting_step", "setting_default_settings", 0)); - eventsMutex.unlock(); - - idealResolutionCX = 1280; - idealResolutionCY = 720; - idealFPSNum = 30; - recordingQuality = Quality::High; - idealBitrate = 2500; - streamingEncoder = Encoder::x264; - recordingEncoder = Encoder::Stream; - - eventsMutex.lock(); - events.push(AutoConfigInfo("stopping_step", "setting_default_settings", 100)); - eventsMutex.unlock(); -} - -void autoConfig::SaveStreamSettings() -{ - /* ---------------------------------- */ - /* save service */ - - eventsMutex.lock(); - events.push(AutoConfigInfo("starting_step", "saving_service", 0)); - eventsMutex.unlock(); - - const char *service_id = "rtmp_common"; - - obs_service_t *oldService = OBS_service::getService(StreamServiceId::Main); - OBSData hotkeyData = obs_hotkeys_save_service(oldService); - obs_data_release(hotkeyData); - - OBSData settings = obs_data_create(); - - if (!customServer) - obs_data_set_string(settings, "service", serviceName.c_str()); - obs_data_set_string(settings, "server", server.c_str()); - obs_data_set_string(settings, "key", key.c_str()); - - OBSService newService = obs_service_create(service_id, "default_service", settings, hotkeyData); - - if (!newService) - return; - - OBS_service::setService(newService, StreamServiceId::Main); - OBS_service::saveService(); - - /* ---------------------------------- */ - /* save stream settings */ - config_set_int(ConfigManager::getInstance().getBasic(), "SimpleOutput", "VBitrate", idealBitrate); - config_set_string(ConfigManager::getInstance().getBasic(), "SimpleOutput", "StreamEncoder", GetEncoderDisplayName(streamingEncoder)); - config_remove_value(ConfigManager::getInstance().getBasic(), "SimpleOutput", "UseAdvanced"); - - config_save_safe(ConfigManager::getInstance().getBasic(), "tmp", nullptr); - - eventsMutex.lock(); - events.push(AutoConfigInfo("stopping_step", "saving_service", 100)); - eventsMutex.unlock(); -} - -void autoConfig::SaveSettings() -{ - eventsMutex.lock(); - events.push(AutoConfigInfo("starting_step", "saving_settings", 0)); - eventsMutex.unlock(); - - if (recordingEncoder != Encoder::Stream) - config_set_string(ConfigManager::getInstance().getBasic(), "SimpleOutput", "RecEncoder", GetEncoderDisplayName(recordingEncoder)); - - const char *quality = recordingQuality == Quality::High ? "Small" : "Stream"; - - config_set_string(ConfigManager::getInstance().getBasic(), "Output", "Mode", "Simple"); - config_set_string(ConfigManager::getInstance().getBasic(), "SimpleOutput", "RecQuality", quality); - config_set_int(ConfigManager::getInstance().getBasic(), "Video", "OutputCX", idealResolutionCX); - config_set_int(ConfigManager::getInstance().getBasic(), "Video", "OutputCY", idealResolutionCY); - config_set_int(ConfigManager::getInstance().getBasic(), "Video", "Canvases", 1); - - config_set_bool(ConfigManager::getInstance().getBasic(), "Output", "DynamicBitrate", false); - - if (fpsType != FPSType::UseCurrent) { - config_set_uint(ConfigManager::getInstance().getBasic(), "Video", "FPSType", 0); - config_set_string(ConfigManager::getInstance().getBasic(), "Video", "FPSCommon", std::to_string(idealFPSNum).c_str()); - } - - config_save_safe(ConfigManager::getInstance().getBasic(), "tmp", nullptr); eventsMutex.lock(); - events.push(AutoConfigInfo("stopping_step", "saving_settings", 100)); events.push(AutoConfigInfo("done", "", 0)); eventsMutex.unlock(); + + return success; } diff --git a/obs-studio-server/source/nodeobs_autoconfig.h b/obs-studio-server/source/nodeobs_autoconfig.h index c42a7ce93..b5010954a 100644 --- a/obs-studio-server/source/nodeobs_autoconfig.h +++ b/obs-studio-server/source/nodeobs_autoconfig.h @@ -35,22 +35,18 @@ void StartBandwidthTest(void *data, const int64_t id, const std::vector &args, std::vector &rval); void StartRecordingEncoderTest(void *data, const int64_t id, const std::vector &args, std::vector &rval); void StartCheckSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval); -void StartSetDefaultSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval); -void StartSaveStreamSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval); -void StartSaveSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval); +void GetNewSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval); +void UseAutoConfigDefaultSettings(void *data, const int64_t id, const std::vector &args, std::vector &rval); void TerminateAutoConfig(void *data, const int64_t id, const std::vector &args, std::vector &rval); void Query(void *data, const int64_t id, const std::vector &args, std::vector &rval); void StopThread(); void FindIdealHardwareResolution(); bool TestSoftwareEncoding(); -void TestBandwidthThread(); +void TestBandwidthThread(std::string bindIp); void TestStreamEncoderThread(); void TestRecordingEncoderThread(); -void SaveStreamSettings(); -void SaveSettings(); bool CheckSettings(); -void SetDefaultSettings(); void TestHardwareEncoding(); bool CanTestServer(const char *server); void WaitPendingTests(double timeout = 10); diff --git a/tests/osn-tests/src/test_nodeobs_autoconfig.ts b/tests/osn-tests/src/test_nodeobs_autoconfig.ts index 093b18687..73dd4ab48 100644 --- a/tests/osn-tests/src/test_nodeobs_autoconfig.ts +++ b/tests/osn-tests/src/test_nodeobs_autoconfig.ts @@ -85,75 +85,64 @@ describe(testName, function() { expect(progressInfo.event).to.equal('stopping_step', GetErrorMessage(ETestErrorMsg.CheckSettings)); expect(progressInfo.description).to.equal('checking_settings', GetErrorMessage(ETestErrorMsg.CheckSettings)); expect(progressInfo.percentage).to.equal(100, GetErrorMessage(ETestErrorMsg.CheckSettings)); -/* - osn.NodeObs.StartSaveStreamSettings(); - - progressInfo = await obs.getNextProgressInfo('Save Stream Settings'); - expect(progressInfo.event).to.equal('stopping_step', GetErrorMessage(ETestErrorMsg.SaveStreamSettings)); - expect(progressInfo.description).to.equal('saving_service', GetErrorMessage(ETestErrorMsg.SaveStreamSettings)); - expect(progressInfo.percentage).to.equal(100, GetErrorMessage(ETestErrorMsg.SaveStreamSettings)); - - osn.NodeObs.StartSaveSettings(); - - progressInfo = await obs.getNextProgressInfo('Save Settings'); - expect(progressInfo.event).to.equal('stopping_step', GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - expect(progressInfo.description).to.equal('saving_settings', GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - expect(progressInfo.percentage).to.equal(100, GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - - progressInfo = await obs.getNextProgressInfo('Autoconfig done'); - expect(progressInfo.event).to.equal('done', GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - */ } else { logWarning(testName, 'Bandwidth test failed with ' + progressInfo.description + '. Setting default settings'); - osn.NodeObs.StartSetDefaultSettings(); - - progressInfo = await obs.getNextProgressInfo('Set Default Settings'); - expect(progressInfo.event).to.equal('stopping_step', GetErrorMessage(ETestErrorMsg.SetDefaultSettings)); - expect(progressInfo.description).to.equal('setting_default_settings', GetErrorMessage(ETestErrorMsg.SetDefaultSettings)); - expect(progressInfo.percentage).to.equal(100, GetErrorMessage(ETestErrorMsg.SetDefaultSettings)); - - osn.NodeObs.StartSaveStreamSettings(); - - progressInfo = await obs.getNextProgressInfo('Save Stream Settings'); - expect(progressInfo.event).to.equal('stopping_step', GetErrorMessage(ETestErrorMsg.SaveStreamSettings)); - expect(progressInfo.description).to.equal('saving_service', GetErrorMessage(ETestErrorMsg.SaveStreamSettings)); - expect(progressInfo.percentage).to.equal(100, GetErrorMessage(ETestErrorMsg.SaveStreamSettings)); - - osn.NodeObs.StartSaveSettings(); + osn.NodeObs.UseAutoConfigDefaultSettings(); - progressInfo = await obs.getNextProgressInfo('Save Settings'); - expect(progressInfo.event).to.equal('stopping_step', GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - expect(progressInfo.description).to.equal('saving_settings', GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - expect(progressInfo.percentage).to.equal(100, GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); - - progressInfo = await obs.getNextProgressInfo('Autoconfig done'); - expect(progressInfo.event).to.equal('done', GetErrorMessage(ETestErrorMsg.SaveSettingsStep)); + const settings = osn.NodeObs.GetNewSettings() as Array<[string, string, any]>; + console.log("settings", JSON.stringify(settings)); // Checking default settings - settingValue = obs.getSetting('Output', 'Mode'); - expect(settingValue).to.equal('Simple', GetErrorMessage(ETestErrorMsg.DefaultOutputMode)); - - settingValue = obs.getSetting('Output', 'VBitrate'); - expect(settingValue).to.equal(2500, GetErrorMessage(ETestErrorMsg.DefaultVBitrate)); - - settingValue = obs.getSetting('Output', 'StreamEncoder'); - expect(settingValue).to.equal('x264', GetErrorMessage(ETestErrorMsg.DefaultStreamEncoder)); - - settingValue = obs.getSetting('Output', 'RecQuality'); - expect(settingValue).to.equal('Small', GetErrorMessage(ETestErrorMsg.DefaultRecQuality)); - - settingValue = obs.getSetting('Advanced', 'DynamicBitrate'); - expect(settingValue).to.equal(false, GetErrorMessage(ETestErrorMsg.DefaultDinamicBitrate)); - - settingValue = obs.getSetting('Video', 'Output'); - expect(settingValue).to.equal('1280x720', GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); - - settingValue = obs.getSetting('Video', 'FPSType'); - expect(settingValue).to.equal('Common FPS Values', GetErrorMessage(ETestErrorMsg.DefaultFPSType)); - - settingValue = obs.getSetting('Video', 'FPSCommon'); - expect(settingValue).to.equal('30', GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); + settingValue = settings[0]; + expect(settingValue[0]).to.equal('Output', GetErrorMessage(ETestErrorMsg.DefaultOutputMode)); + expect(settingValue[1]).to.equal('Mode', GetErrorMessage(ETestErrorMsg.DefaultOutputMode)); + expect(settingValue[2]).to.equal('Simple', GetErrorMessage(ETestErrorMsg.DefaultOutputMode)); + + settingValue = settings[1]; + expect(settingValue[0]).to.equal('Output', GetErrorMessage(ETestErrorMsg.DefaultVBitrate)); + expect(settingValue[1]).to.equal('VBitrate', GetErrorMessage(ETestErrorMsg.DefaultVBitrate)); + expect(settingValue[2]).to.equal(2500, GetErrorMessage(ETestErrorMsg.DefaultVBitrate)); + + settingValue = settings[2]; + expect(settingValue[0]).to.equal('Output', GetErrorMessage(ETestErrorMsg.DefaultStreamEncoder)); + expect(settingValue[1]).to.equal('StreamEncoder', GetErrorMessage(ETestErrorMsg.DefaultStreamEncoder)); + expect(settingValue[2]).to.equal('x264', GetErrorMessage(ETestErrorMsg.DefaultStreamEncoder)); + + settingValue = settings[3]; + expect(settingValue[0]).to.equal('Output', GetErrorMessage(ETestErrorMsg.DefaultRecQuality)); + expect(settingValue[1]).to.equal('RecQuality', GetErrorMessage(ETestErrorMsg.DefaultRecQuality)); + expect(settingValue[2]).to.equal('Small', GetErrorMessage(ETestErrorMsg.DefaultRecQuality)); + + settingValue = settings[4]; + expect(settingValue[0]).to.equal('Video', GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); + expect(settingValue[1]).to.equal('outputWidth', GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); + expect(settingValue[2]).to.equal(1280, GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); + + settingValue = settings[5];; + expect(settingValue[0]).to.equal('Video', GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); + expect(settingValue[1]).to.equal('outputHeight', GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); + expect(settingValue[2]).to.equal(720, GetErrorMessage(ETestErrorMsg.DefaultVideoOutput)); + + settingValue = settings[6]; + expect(settingValue[0]).to.equal('Advanced', GetErrorMessage(ETestErrorMsg.DefaultDinamicBitrate)); + expect(settingValue[1]).to.equal('DynamicBitrate', GetErrorMessage(ETestErrorMsg.DefaultDinamicBitrate)); + expect(settingValue[2]).to.equal(0, GetErrorMessage(ETestErrorMsg.DefaultDinamicBitrate)); + + settingValue = settings[7];; + expect(settingValue[0]).to.equal('Video', GetErrorMessage(ETestErrorMsg.DefaultFPSType)); + expect(settingValue[1]).to.equal('fpsType', GetErrorMessage(ETestErrorMsg.DefaultFPSType)); + expect(settingValue[2]).to.equal(0, GetErrorMessage(ETestErrorMsg.DefaultFPSType)); + + settingValue = settings[8];; + expect(settingValue[0]).to.equal('Video', GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); + expect(settingValue[1]).to.equal('fpsNum', GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); + expect(settingValue[2]).to.equal(30, GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); + + settingValue = settings[9]; + expect(settingValue[0]).to.equal('Video', GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); + expect(settingValue[1]).to.equal('fpsDen', GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); + expect(settingValue[2]).to.equal(1, GetErrorMessage(ETestErrorMsg.DefaultFPSCommon)); } osn.NodeObs.TerminateAutoConfig(); diff --git a/tests/osn-tests/util/obs_handler.ts b/tests/osn-tests/util/obs_handler.ts index 9c0d4f2d3..1f1cf56fe 100644 --- a/tests/osn-tests/util/obs_handler.ts +++ b/tests/osn-tests/util/obs_handler.ts @@ -267,7 +267,7 @@ export class OBSHandler { } }, { - service_name: 'Twitch', + service_name: 'Twitch', bind_ip: 'default', }); }