Add support for controlling the replay buffer
This commit is contained in:
parent
a18c507472
commit
640ae65d07
3 changed files with 43 additions and 3 deletions
23
src/client.c
23
src/client.c
|
@ -18,6 +18,9 @@ void print_usage(char *name) {
|
|||
printf(" | --stop-recording\n");
|
||||
printf(" | --start-streaming\n");
|
||||
printf(" | --stop-streaming\n");
|
||||
printf(" | --start-replay-buffer\n");
|
||||
printf(" | --stop-replay-buffer\n");
|
||||
printf(" | --save-replay-buffer\n");
|
||||
printf(" | --get-status]\n");
|
||||
}
|
||||
|
||||
|
@ -39,6 +42,12 @@ int main(int argc, char **argv) {
|
|||
type = UNIX_SOCKET_EVENT_START_STREAMING;
|
||||
} else if (strncmp(argv[1], "--stop-streaming", 16) == 0) {
|
||||
type = UNIX_SOCKET_EVENT_STOP_STREAMING;
|
||||
} else if (strncmp(argv[1], "--start-replay-buffer", 21) == 0) {
|
||||
type = UNIX_SOCKET_EVENT_START_REPLAY_BUFFER;
|
||||
} else if (strncmp(argv[1], "--stop-replay-buffer", 20) == 0) {
|
||||
type = UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER;
|
||||
} else if (strncmp(argv[1], "--save-replay-buffer", 20) == 0) {
|
||||
type = UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER;
|
||||
} else if (strncmp(argv[1], "--get-status", 12) == 0) {
|
||||
type = UNIX_SOCKET_EVENT_GET_STATUS;
|
||||
} else {
|
||||
|
@ -94,9 +103,10 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (type == UNIX_SOCKET_EVENT_GET_STATUS && buffer[0] == UNIX_SOCKET_EVENT_GET_STATUS) {
|
||||
printf("Is recording: %s\nIs streaming: %s\n",
|
||||
printf("Is recording: %s\nIs streaming: %s\nReplay buffer active: %s\n",
|
||||
(buffer[1] & 1) != 0 ? "true" : "false",
|
||||
(buffer[1] & 2) != 0 ? "true" : "false");
|
||||
(buffer[1] & 2) != 0 ? "true" : "false",
|
||||
(buffer[1] & 4) != 0 ? "true" : "false");
|
||||
} else if (buffer[0] != UNIX_SOCKET_EVENT_NOP) {
|
||||
// Error. TODO handle this.
|
||||
return 7;
|
||||
|
@ -114,6 +124,15 @@ int main(int argc, char **argv) {
|
|||
case UNIX_SOCKET_EVENT_STOP_STREAMING:
|
||||
puts("Sent event \"stop streaming\"!");
|
||||
break;
|
||||
case UNIX_SOCKET_EVENT_START_REPLAY_BUFFER:
|
||||
puts("Sent event \"start replay-buffer\"!");
|
||||
break;
|
||||
case UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER:
|
||||
puts("Sent event \"stop replay-buffer\"!");
|
||||
break;
|
||||
case UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER:
|
||||
puts("Sent event \"save replay-buffer\"!");
|
||||
break;
|
||||
default:
|
||||
// Error. TODO handle this
|
||||
return 8;
|
||||
|
|
|
@ -9,7 +9,10 @@ typedef enum UnixSocketEventType {
|
|||
UNIX_SOCKET_EVENT_STOP_RECORDING,
|
||||
UNIX_SOCKET_EVENT_START_STREAMING,
|
||||
UNIX_SOCKET_EVENT_STOP_STREAMING,
|
||||
UNIX_SOCKET_EVENT_GET_STATUS
|
||||
UNIX_SOCKET_EVENT_GET_STATUS,
|
||||
UNIX_SOCKET_EVENT_START_REPLAY_BUFFER,
|
||||
UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER,
|
||||
UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER
|
||||
} UnixSocketEventType;
|
||||
|
||||
#endif
|
||||
|
|
18
src/socket.c
18
src/socket.c
|
@ -1,4 +1,5 @@
|
|||
#include "socket.h"
|
||||
#include "common_constants.h"
|
||||
|
||||
// standard library includes
|
||||
#include <stdlib.h>
|
||||
|
@ -91,6 +92,23 @@ int unix_socket_handler_thread_function(void *ud) {
|
|||
if (obs_frontend_streaming_active()) {
|
||||
ret_buffer[1] |= 2;
|
||||
}
|
||||
if (obs_frontend_replay_buffer_active()) {
|
||||
ret_buffer[1] |= 4;
|
||||
}
|
||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_START_REPLAY_BUFFER) {
|
||||
obs_frontend_replay_buffer_start();
|
||||
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_REPLAY_BUFFER) {
|
||||
obs_frontend_replay_buffer_stop();
|
||||
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
||||
} else if (buffer[0] == UNIX_SOCKET_EVENT_SAVE_REPLAY_BUFFER) {
|
||||
if (obs_frontend_replay_buffer_active()) {
|
||||
obs_frontend_replay_buffer_save();
|
||||
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
|
||||
} else {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue