Skip to content

Commit

Permalink
Implement getStatus and clean up the rest of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jan 6, 2025
1 parent ae774e3 commit d2605f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
30 changes: 5 additions & 25 deletions httpstatic/obs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,17 @@ const {} = choc; //autoimport

export function render(data) {}

export function sockmsg_get_status(msg) {
obsstudio.getStatus(status => ws_sync.send({cmd: "response", key: msg.key, ...status}));
}
export function sockmsg_get_scene(msg) {
obsstudio.getCurrentScene(scene => ws_sync.send({cmd: "response", key: msg.key, scenename: scene.name}));
}
export function sockmsg_set_scene(msg) {
obsstudio.setCurrentScene(msg.scenename);
sockmsg_get_scene(msg);
}
//TODO maybe: saveReplayBuffer?

//ws_sync.send({cmd: "logme", keys: Object.keys(obsstudio).sort()});
//obsstudio.getCurrentScene(sc => ws_sync.send({cmd: "logme", sc}));
//obsstudio.setCurrentScene("Big Head Mode");

/*
"getControlLevel",
"getCurrentScene",
"getCurrentTransition",
"getScenes",
"getStatus",
"getTransitions",
"pauseRecording",
"pluginVersion",
"saveReplayBuffer",
"setCurrentScene",
"setCurrentTransition",
"startRecording",
"startReplayBuffer",
"startStreaming",
"startVirtualcam",
"stopRecording",
"stopReplayBuffer",
"stopStreaming",
"stopVirtualcam",
"unpauseRecording"
*/
//obsstudio.getControlLevel(sc => ws_sync.send({cmd: "logme", sc}));
15 changes: 12 additions & 3 deletions modules/http/chan_obs.pike
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Need to reset the key? [Reset key](:#resetkey) will disable any previous link an

constant builtin_name = "OBS Studio";
constant builtin_description = "Manage OBS Studio";
constant builtin_param = ({"/Action/Get scene/Switch scene", "Parameter"});
constant builtin_param = ({"/Action/Status/Get scene/Switch scene", "Parameter"});
constant vars_provided = ([
"{scenename}": "Current scene name",
"{scenename}": "Current scene name (get/switch scene)",
"{streaming}": "1 if streaming, 0 if not (status)",
"{recording}": "1 if recording, 0 if not (status)",
]);

@retain: mapping obsstudio_inflight_messages = ([]);
Expand All @@ -42,8 +44,15 @@ __async__ mapping send_obs_signal(object channel, mapping msg) {
}

__async__ mapping message_params(object channel, mapping person, array param, mapping cfg) {
//TODO: If no client connected, immediate error
switch (param[0]) {
case "Status": {
mapping info = await(send_obs_signal(channel, (["cmd": "get_status"])));
//Also available, if of interest: recordingPaused, replaybuffer, virtualcam
return ([
"{streaming}": (string)(int)info->streaming,
"{recording}": (string)(int)info->recording,
]);
}
case "Get scene": {
mapping info = await(send_obs_signal(channel, (["cmd": "get_scene"])));
return (["{scenename}": (string)info->scenename]);
Expand Down

0 comments on commit d2605f1

Please sign in to comment.