Skip to content

Expose obs_output_force_stop on the NodeObs API #1533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 12 additions & 2 deletions obs-studio-client/source/nodeobs_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ Napi::Value service::OBS_service_stopRecording(const Napi::CallbackInfo &info)
return info.Env().Undefined();
}

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

conn->call("NodeOBS_Service", "OBS_service_stopRecordingForce", {});
return info.Env().Undefined();
}

Napi::Value service::OBS_service_stopReplayBuffer(const Napi::CallbackInfo &info)
{
bool forceStop = info[0].ToBoolean().Value();
Expand Down Expand Up @@ -510,6 +520,7 @@ void service::Init(Napi::Env env, Napi::Object exports)
exports.Set(Napi::String::New(env, "OBS_service_startRecording"), Napi::Function::New(env, service::OBS_service_startRecording));
exports.Set(Napi::String::New(env, "OBS_service_startReplayBuffer"), Napi::Function::New(env, service::OBS_service_startReplayBuffer));
exports.Set(Napi::String::New(env, "OBS_service_stopRecording"), Napi::Function::New(env, service::OBS_service_stopRecording));
exports.Set(Napi::String::New(env, "OBS_service_stopRecordingForce"), Napi::Function::New(env, service::OBS_service_stopRecordingForce));
exports.Set(Napi::String::New(env, "OBS_service_stopStreaming"), Napi::Function::New(env, service::OBS_service_stopStreaming));
exports.Set(Napi::String::New(env, "OBS_service_stopReplayBuffer"), Napi::Function::New(env, service::OBS_service_stopReplayBuffer));
exports.Set(Napi::String::New(env, "OBS_service_connectOutputSignals"), Napi::Function::New(env, service::OBS_service_connectOutputSignals));
Expand All @@ -523,6 +534,5 @@ void service::Init(Napi::Env env, Napi::Object exports)
exports.Set(Napi::String::New(env, "OBS_service_updateVirtualCam"), Napi::Function::New(env, service::OBS_service_updateVirtualCam));
exports.Set(Napi::String::New(env, "OBS_service_installVirtualCamPlugin"), Napi::Function::New(env, service::OBS_service_installVirtualCamPlugin));
exports.Set(Napi::String::New(env, "OBS_service_uninstallVirtualCamPlugin"), Napi::Function::New(env, service::OBS_service_uninstallVirtualCamPlugin));
exports.Set(Napi::String::New(env, "OBS_service_isVirtualCamPluginInstalled"),
Napi::Function::New(env, service::OBS_service_isVirtualCamPluginInstalled));
exports.Set(Napi::String::New(env, "OBS_service_isVirtualCamPluginInstalled"), Napi::Function::New(env, service::OBS_service_isVirtualCamPluginInstalled));
}
1 change: 1 addition & 0 deletions obs-studio-client/source/nodeobs_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Napi::Value OBS_service_startRecording(const Napi::CallbackInfo &info);
Napi::Value OBS_service_startReplayBuffer(const Napi::CallbackInfo &info);
Napi::Value OBS_service_stopStreaming(const Napi::CallbackInfo &info);
Napi::Value OBS_service_stopRecording(const Napi::CallbackInfo &info);
Napi::Value OBS_service_stopRecordingForce(const Napi::CallbackInfo &info);
Napi::Value OBS_service_stopReplayBuffer(const Napi::CallbackInfo &info);

Napi::Value OBS_service_connectOutputSignals(const Napi::CallbackInfo &info);
Expand Down
35 changes: 27 additions & 8 deletions obs-studio-server/source/nodeobs_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,20 @@ void OBS_service::Register(ipc::server &srv)
cls->register_function(std::make_shared<ipc::function>("OBS_service_startStreaming", std::vector<ipc::type>{}, OBS_service_startStreaming));
cls->register_function(std::make_shared<ipc::function>("OBS_service_startRecording", std::vector<ipc::type>{}, OBS_service_startRecording));
cls->register_function(std::make_shared<ipc::function>("OBS_service_startReplayBuffer", std::vector<ipc::type>{}, OBS_service_startReplayBuffer));
cls->register_function(
std::make_shared<ipc::function>("OBS_service_stopStreaming", std::vector<ipc::type>{ipc::type::Int32}, OBS_service_stopStreaming));
cls->register_function(std::make_shared<ipc::function>("OBS_service_stopStreaming", std::vector<ipc::type>{ipc::type::Int32}, OBS_service_stopStreaming));
cls->register_function(std::make_shared<ipc::function>("OBS_service_stopRecording", std::vector<ipc::type>{}, OBS_service_stopRecording));
cls->register_function(
std::make_shared<ipc::function>("OBS_service_stopReplayBuffer", std::vector<ipc::type>{ipc::type::Int32}, OBS_service_stopReplayBuffer));
cls->register_function(std::make_shared<ipc::function>("OBS_service_stopRecordingForce", std::vector<ipc::type>{}, OBS_service_stopRecordingForce));
cls->register_function(std::make_shared<ipc::function>("OBS_service_stopReplayBuffer", std::vector<ipc::type>{ipc::type::Int32}, OBS_service_stopReplayBuffer));
cls->register_function(std::make_shared<ipc::function>("OBS_service_connectOutputSignals", std::vector<ipc::type>{}, OBS_service_connectOutputSignals));
cls->register_function(std::make_shared<ipc::function>("Query", std::vector<ipc::type>{}, Query));
cls->register_function(
std::make_shared<ipc::function>("OBS_service_processReplayBufferHotkey", std::vector<ipc::type>{}, OBS_service_processReplayBufferHotkey));
cls->register_function(std::make_shared<ipc::function>("OBS_service_processReplayBufferHotkey", std::vector<ipc::type>{}, OBS_service_processReplayBufferHotkey));
cls->register_function(std::make_shared<ipc::function>("OBS_service_splitFile", std::vector<ipc::type>{}, OBS_service_splitFile));
cls->register_function(std::make_shared<ipc::function>("OBS_service_getLastReplay", std::vector<ipc::type>{}, OBS_service_getLastReplay));
cls->register_function(std::make_shared<ipc::function>("OBS_service_getLastRecording", std::vector<ipc::type>{}, OBS_service_getLastRecording));

cls->register_function(std::make_shared<ipc::function>("OBS_service_startVirtualCam", std::vector<ipc::type>{}, OBS_service_startVirtualCam));
cls->register_function(std::make_shared<ipc::function>("OBS_service_stopVirtualCam", std::vector<ipc::type>{}, OBS_service_stopVirtualCam));
cls->register_function(std::make_shared<ipc::function>("OBS_service_updateVirtualCam", std::vector<ipc::type>{ipc::type::Int32, ipc::type::String},
OBS_service_updateVirtualCam));
cls->register_function(std::make_shared<ipc::function>("OBS_service_updateVirtualCam", std::vector<ipc::type>{ipc::type::Int32, ipc::type::String}, OBS_service_updateVirtualCam));

srv.register_collection(cls);
}
Expand Down Expand Up @@ -278,6 +275,18 @@ void OBS_service::OBS_service_stopRecording(void *data, const int64_t id, const
AUTO_DEBUG;
}

void OBS_service::OBS_service_stopRecordingForce(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval)
{
stopRecordingForce();
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));

#if !defined(_WIN32)
util::CrashManager::UpdateBriefCrashInfoAppState();
#endif

AUTO_DEBUG;
}

void OBS_service::OBS_service_stopReplayBuffer(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval)
{
stopReplayBuffer((bool)args[0].value_union.i32);
Expand Down Expand Up @@ -1762,6 +1771,16 @@ void OBS_service::stopRecording(void)
isRecording = false;
}

void OBS_service::stopRecordingForce(void)
{
blog(LOG_WARNING, "stopRecordingForce called");

if (recordingOutput && obs_output_active(recordingOutput))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor codestyle issue. wrong indentation.

obs_output_force_stop(recordingOutput);

isRecording = false;
}

void OBS_service::updateReplayBufferOutput(bool isSimpleMode, bool useStreamEncoder)
{
blog(LOG_INFO, "updateReplayBufferOutput - isSimpleMode: %d, useStreamEncoder: %d", (int)isSimpleMode, (int)useStreamEncoder);
Expand Down
2 changes: 2 additions & 0 deletions obs-studio-server/source/nodeobs_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class OBS_service {
static void OBS_service_startReplayBuffer(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_service_stopStreaming(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_service_stopRecording(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_service_stopRecordingForce(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_service_stopReplayBuffer(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_service_connectOutputSignals(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
static void OBS_service_processReplayBufferHotkey(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval);
Expand All @@ -158,6 +159,7 @@ class OBS_service {
static bool startReplayBuffer(void);
static void stopReplayBuffer(bool forceStop);
static void stopRecording(void);
static void stopRecordingForce(void);

static void releaseStreamingOutput(StreamServiceId serviceId);

Expand Down