Version 1.3.0
Allow toggling streaming and replay-buffer.
This commit is contained in:
parent
0376d6cf4b
commit
4c708a2b9a
4 changed files with 62 additions and 7 deletions
|
@ -1,8 +1,8 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
|
|
||||||
set(obs_usc_VERSION_MAJOR 1)
|
set(obs_usc_VERSION_MAJOR 1)
|
||||||
set(obs_usc_VERSION_MINOR 2)
|
set(obs_usc_VERSION_MINOR 3)
|
||||||
set(obs_usc_VERSION_PATCH 1)
|
set(obs_usc_VERSION_PATCH 0)
|
||||||
set(obs_usc_VERSION_STR "${obs_usc_VERSION_MAJOR}.${obs_usc_VERSION_MINOR}.${obs_usc_VERSION_PATCH}")
|
set(obs_usc_VERSION_STR "${obs_usc_VERSION_MAJOR}.${obs_usc_VERSION_MINOR}.${obs_usc_VERSION_PATCH}")
|
||||||
|
|
||||||
project(obs-studio-plugin-unix-socket-control VERSION "${obs_usc_VERSION_STR}")
|
project(obs-studio-plugin-unix-socket-control VERSION "${obs_usc_VERSION_STR}")
|
||||||
|
|
43
src/client.c
43
src/client.c
|
@ -19,8 +19,10 @@ void print_usage(char *name) {
|
||||||
printf(" | --toggle-recording\n");
|
printf(" | --toggle-recording\n");
|
||||||
printf(" | --start-streaming\n");
|
printf(" | --start-streaming\n");
|
||||||
printf(" | --stop-streaming\n");
|
printf(" | --stop-streaming\n");
|
||||||
|
printf(" | --toggle-streaming\n");
|
||||||
printf(" | --start-replay-buffer\n");
|
printf(" | --start-replay-buffer\n");
|
||||||
printf(" | --stop-replay-buffer\n");
|
printf(" | --stop-replay-buffer\n");
|
||||||
|
printf(" | --toggle-replay-buffer\n");
|
||||||
printf(" | --save-replay-buffer\n");
|
printf(" | --save-replay-buffer\n");
|
||||||
printf(" | --get-status]\n");
|
printf(" | --get-status]\n");
|
||||||
}
|
}
|
||||||
|
@ -45,10 +47,14 @@ int main(int argc, char **argv) {
|
||||||
type = UNIX_SOCKET_EVENT_TOGGLE_RECORDING;
|
type = UNIX_SOCKET_EVENT_TOGGLE_RECORDING;
|
||||||
} else if (strncmp(argv[1], "--stop-streaming", 16) == 0) {
|
} else if (strncmp(argv[1], "--stop-streaming", 16) == 0) {
|
||||||
type = UNIX_SOCKET_EVENT_STOP_STREAMING;
|
type = UNIX_SOCKET_EVENT_STOP_STREAMING;
|
||||||
|
} else if (strncmp(argv[1], "--toggle-streaming", 18) == 0) {
|
||||||
|
type = UNIX_SOCKET_EVENT_TOGGLE_STREAMING;
|
||||||
} else if (strncmp(argv[1], "--start-replay-buffer", 21) == 0) {
|
} else if (strncmp(argv[1], "--start-replay-buffer", 21) == 0) {
|
||||||
type = UNIX_SOCKET_EVENT_START_REPLAY_BUFFER;
|
type = UNIX_SOCKET_EVENT_START_REPLAY_BUFFER;
|
||||||
} else if (strncmp(argv[1], "--stop-replay-buffer", 20) == 0) {
|
} else if (strncmp(argv[1], "--stop-replay-buffer", 20) == 0) {
|
||||||
type = UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER;
|
type = UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER;
|
||||||
|
} else if (strncmp(argv[1], "--toggle-replay-buffer", 22) == 0) {
|
||||||
|
type = UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER;
|
||||||
} else if (strncmp(argv[1], "--save-replay-buffer", 20) == 0) {
|
} else if (strncmp(argv[1], "--save-replay-buffer", 20) == 0) {
|
||||||
type = UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER;
|
type = UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER;
|
||||||
} else if (strncmp(argv[1], "--get-status", 12) == 0) {
|
} else if (strncmp(argv[1], "--get-status", 12) == 0) {
|
||||||
|
@ -110,7 +116,10 @@ int main(int argc, char **argv) {
|
||||||
(buffer[1] & 1) != 0 ? "true" : "false",
|
(buffer[1] & 1) != 0 ? "true" : "false",
|
||||||
(buffer[1] & 2) != 0 ? "true" : "false",
|
(buffer[1] & 2) != 0 ? "true" : "false",
|
||||||
(buffer[1] & 4) != 0 ? "true" : "false");
|
(buffer[1] & 4) != 0 ? "true" : "false");
|
||||||
} else if (buffer[0] != UNIX_SOCKET_EVENT_NOP && buffer[0] != UNIX_SOCKET_EVENT_TOGGLE_RECORDING) {
|
} else if (buffer[0] != UNIX_SOCKET_EVENT_NOP
|
||||||
|
&& buffer[0] != UNIX_SOCKET_EVENT_TOGGLE_RECORDING
|
||||||
|
&& buffer[0] != UNIX_SOCKET_EVENT_TOGGLE_STREAMING
|
||||||
|
&& buffer[0] != UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER) {
|
||||||
// Error. TODO handle this.
|
// Error. TODO handle this.
|
||||||
return 7;
|
return 7;
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,13 +133,13 @@ int main(int argc, char **argv) {
|
||||||
case UNIX_SOCKET_EVENT_TOGGLE_RECORDING:
|
case UNIX_SOCKET_EVENT_TOGGLE_RECORDING:
|
||||||
switch(buffer[1]) {
|
switch(buffer[1]) {
|
||||||
case UNIX_SOCKET_EVENT_START_RECORDING:
|
case UNIX_SOCKET_EVENT_START_RECORDING:
|
||||||
puts("Sent event \"toggle recording\", stream STARTED!");
|
puts("Sent event \"toggle recording\", recording STARTED!");
|
||||||
break;
|
break;
|
||||||
case UNIX_SOCKET_EVENT_STOP_RECORDING:
|
case UNIX_SOCKET_EVENT_STOP_RECORDING:
|
||||||
puts("Sent event \"toggle recording\", stream STOPPED!");
|
puts("Sent event \"toggle recording\", recording STOPPED!");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
puts("Sent event \"toggle recording\", stream status UNKNOWN!");
|
puts("Sent event \"toggle recording\", recording status UNKNOWN!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -140,12 +149,38 @@ int main(int argc, char **argv) {
|
||||||
case UNIX_SOCKET_EVENT_STOP_STREAMING:
|
case UNIX_SOCKET_EVENT_STOP_STREAMING:
|
||||||
puts("Sent event \"stop streaming\"!");
|
puts("Sent event \"stop streaming\"!");
|
||||||
break;
|
break;
|
||||||
|
case UNIX_SOCKET_EVENT_TOGGLE_STREAMING:
|
||||||
|
switch(buffer[1]) {
|
||||||
|
case UNIX_SOCKET_EVENT_START_STREAMING:
|
||||||
|
puts("Sent event \"toggle streaming\", stream STARTED!");
|
||||||
|
break;
|
||||||
|
case UNIX_SOCKET_EVENT_STOP_STREAMING:
|
||||||
|
puts("Sent event \"toggle streaming\", stream STOPPED!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
puts("Sent event \"toggle streaming\", stream status UNKNOWN!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case UNIX_SOCKET_EVENT_START_REPLAY_BUFFER:
|
case UNIX_SOCKET_EVENT_START_REPLAY_BUFFER:
|
||||||
puts("Sent event \"start replay-buffer\"!");
|
puts("Sent event \"start replay-buffer\"!");
|
||||||
break;
|
break;
|
||||||
case UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER:
|
case UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER:
|
||||||
puts("Sent event \"stop replay-buffer\"!");
|
puts("Sent event \"stop replay-buffer\"!");
|
||||||
break;
|
break;
|
||||||
|
case UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER:
|
||||||
|
switch(buffer[1]) {
|
||||||
|
case UNIX_SOCKET_EVENT_START_REPLAY_BUFFER:
|
||||||
|
puts("Sent event \"toggle replay-buffer\", replay-buffer STARTED!");
|
||||||
|
break;
|
||||||
|
case UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER:
|
||||||
|
puts("Sent event \"toggle replay-buffer\", replay-buffer STOPPED!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
puts("Sent event \"toggle replay-buffer\", replay-buffer status UNKNOWN!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER:
|
case UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER:
|
||||||
puts("Sent event \"save replay-buffer\"!");
|
puts("Sent event \"save replay-buffer\"!");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,7 +13,9 @@ typedef enum UnixSocketEventType {
|
||||||
UNIX_SOCKET_EVENT_START_REPLAY_BUFFER,
|
UNIX_SOCKET_EVENT_START_REPLAY_BUFFER,
|
||||||
UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER,
|
UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER,
|
||||||
UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER,
|
UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER,
|
||||||
UNIX_SOCKET_EVENT_TOGGLE_RECORDING
|
UNIX_SOCKET_EVENT_TOGGLE_RECORDING,
|
||||||
|
UNIX_SOCKET_EVENT_TOGGLE_STREAMING,
|
||||||
|
UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER
|
||||||
} UnixSocketEventType;
|
} UnixSocketEventType;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
18
src/socket.c
18
src/socket.c
|
@ -93,6 +93,15 @@ int unix_socket_handler_thread_function(void *ud) {
|
||||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_STREAMING) {
|
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_STREAMING) {
|
||||||
obs_frontend_streaming_stop();
|
obs_frontend_streaming_stop();
|
||||||
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
||||||
|
} else if (buffer[0] == UNIX_SOCKET_EVENT_TOGGLE_STREAMING) {
|
||||||
|
ret_buffer[0] = UNIX_SOCKET_EVENT_TOGGLE_STREAMING;
|
||||||
|
if (obs_frontend_streaming_active()) {
|
||||||
|
obs_frontend_streaming_stop();
|
||||||
|
ret_buffer[1] = UNIX_SOCKET_EVENT_STOP_STREAMING;
|
||||||
|
} else {
|
||||||
|
obs_frontend_streaming_start();
|
||||||
|
ret_buffer[1] = UNIX_SOCKET_EVENT_START_STREAMING;
|
||||||
|
}
|
||||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_GET_STATUS) {
|
} else if (buffer[0] == UNIX_SOCKET_EVENT_GET_STATUS) {
|
||||||
ret_buffer[0] = UNIX_SOCKET_EVENT_GET_STATUS;
|
ret_buffer[0] = UNIX_SOCKET_EVENT_GET_STATUS;
|
||||||
if (obs_frontend_recording_active()) {
|
if (obs_frontend_recording_active()) {
|
||||||
|
@ -110,6 +119,15 @@ int unix_socket_handler_thread_function(void *ud) {
|
||||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER) {
|
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER) {
|
||||||
obs_frontend_replay_buffer_stop();
|
obs_frontend_replay_buffer_stop();
|
||||||
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
||||||
|
} else if (buffer[0] == UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER) {
|
||||||
|
ret_buffer[0] = UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER;
|
||||||
|
if (obs_frontend_replay_buffer_active()) {
|
||||||
|
obs_frontend_replay_buffer_stop();
|
||||||
|
ret_buffer[1] = UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER;
|
||||||
|
} else {
|
||||||
|
obs_frontend_replay_buffer_start();
|
||||||
|
ret_buffer[1] = UNIX_SOCKET_EVENT_START_REPLAY_BUFFER;
|
||||||
|
}
|
||||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER) {
|
} else if (buffer[0] == UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER) {
|
||||||
if (obs_frontend_replay_buffer_active()) {
|
if (obs_frontend_replay_buffer_active()) {
|
||||||
obs_frontend_replay_buffer_save();
|
obs_frontend_replay_buffer_save();
|
||||||
|
|
Loading…
Reference in a new issue