Skip to content
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

Virtual camera custom sources #1491

Open
wants to merge 5 commits into
base: obs_merge_30.2.3
Choose a base branch
from
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 @@ -22,7 +22,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: 30.2.3sl3
LibOBSVersion: vcam-custom-sources-1
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 @@ -941,4 +941,11 @@ export interface IAudioTrackFactory {
importLegacySettings(): void;
saveLegacySettings(): void;
}
export declare const enum VCamOutputType {
Invalid,
SceneOutput,
SourceOutput,
ProgramView,
PreviewOutput,
};
export declare const NodeObs: any;
8 changes: 8 additions & 0 deletions js/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,14 @@ export interface IAudioTrackFactory {
saveLegacySettings(): void;
}

export const enum VCamOutputType {
Invalid,
SceneOutput,
SourceOutput,
ProgramView,
PreviewOutput,
};

// Initialization and other stuff which needs local data.
const __dirnameApple = __dirname + '/bin';
if (fs.existsSync(path.resolve(__dirnameApple).replace('app.asar', 'app.asar.unpacked'))) {
Expand Down
33 changes: 13 additions & 20 deletions obs-studio-client/source/nodeobs_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,45 +359,39 @@ Napi::Value service::OBS_service_removeCallback(const Napi::CallbackInfo &info)
return info.Env().Undefined();
}

Napi::Value service::OBS_service_createVirtualWebcam(const Napi::CallbackInfo &info)
Napi::Value service::OBS_service_startVirtualCam(const Napi::CallbackInfo &info)
{
std::string name = info[0].ToString().Utf8Value();

auto conn = GetConnection(info);
if (!conn)
return info.Env().Undefined();

conn->call("NodeOBS_Service", "OBS_service_createVirtualWebcam", {ipc::value(name)});
conn->call("NodeOBS_Service", "OBS_service_startVirtualCam", {});
return info.Env().Undefined();
}

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

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

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

conn->call("NodeOBS_Service", "OBS_service_startVirtualWebcam", {});
return info.Env().Undefined();
}
const int sourceType = info[0].ToNumber().Int32Value();
std::string sourceName;

Napi::Value service::OBS_service_stopVirtualWebcam(const Napi::CallbackInfo &info)
{
auto conn = GetConnection(info);
if (!conn)
return info.Env().Undefined();
if (info.Length() == 2)
sourceName = info[1].ToString().Utf8Value();

conn->call("NodeOBS_Service", "OBS_service_stopVirtualWebcam", {});
conn->call("NodeOBS_Service", "OBS_service_updateVirtualCam", {ipc::value(sourceType), ipc::value(sourceName)});
return info.Env().Undefined();
}

Expand Down Expand Up @@ -522,10 +516,9 @@ void service::Init(Napi::Env env, Napi::Object exports)
exports.Set(Napi::String::New(env, "OBS_service_getLastReplay"), Napi::Function::New(env, service::OBS_service_getLastReplay));
exports.Set(Napi::String::New(env, "OBS_service_getLastRecording"), Napi::Function::New(env, service::OBS_service_getLastRecording));
exports.Set(Napi::String::New(env, "OBS_service_splitFile"), Napi::Function::New(env, service::OBS_service_splitFile));
exports.Set(Napi::String::New(env, "OBS_service_createVirtualWebcam"), Napi::Function::New(env, service::OBS_service_createVirtualWebcam));
exports.Set(Napi::String::New(env, "OBS_service_removeVirtualWebcam"), Napi::Function::New(env, service::OBS_service_removeVirtualWebcam));
exports.Set(Napi::String::New(env, "OBS_service_startVirtualWebcam"), Napi::Function::New(env, service::OBS_service_startVirtualWebcam));
exports.Set(Napi::String::New(env, "OBS_service_stopVirtualWebcam"), Napi::Function::New(env, service::OBS_service_stopVirtualWebcam));
exports.Set(Napi::String::New(env, "OBS_service_startVirtualCam"), Napi::Function::New(env, service::OBS_service_startVirtualCam));
exports.Set(Napi::String::New(env, "OBS_service_stopVirtualCam"), Napi::Function::New(env, service::OBS_service_stopVirtualCam));
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"),
Expand Down
8 changes: 4 additions & 4 deletions obs-studio-client/source/nodeobs_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void OBS_service_splitFile(const Napi::CallbackInfo &info);
int getServiceIdByName(std::string serviceName);
std::string getServiceNameById(int serviceId);

Napi::Value OBS_service_createVirtualWebcam(const Napi::CallbackInfo &info);
Napi::Value OBS_service_removeVirtualWebcam(const Napi::CallbackInfo &info);
Napi::Value OBS_service_startVirtualWebcam(const Napi::CallbackInfo &info);
Napi::Value OBS_service_stopVirtualWebcam(const Napi::CallbackInfo &info);
Napi::Value OBS_service_startVirtualCam(const Napi::CallbackInfo &info);
Napi::Value OBS_service_stopVirtualCam(const Napi::CallbackInfo &info);
Napi::Value OBS_service_updateVirtualCam(const Napi::CallbackInfo &info);

Napi::Value OBS_service_installVirtualCamPlugin(const Napi::CallbackInfo &info);
Napi::Value OBS_service_uninstallVirtualCamPlugin(const Napi::CallbackInfo &info);
Napi::Value OBS_service_isVirtualCamPluginInstalled(const Napi::CallbackInfo &info);
Expand Down
1 change: 1 addition & 0 deletions obs-studio-client/source/nodeobs_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ std::vector<std::string> settings::getListCategories(void)
categories.push_back("Video");
categories.push_back("Hotkeys");
categories.push_back("Advanced");
categories.push_back("Virtual Webcam");

return categories;
}
Expand Down
Loading
Loading