Compare commits

...

15 commits
1.0 ... main

Author SHA1 Message Date
Stephen Seo 741111fe8c Add forgejo action to make releases for tags
All checks were successful
Create releases with ArchLinux pkg / check-and-build-and-release (push) Successful in 5s
2024-01-29 13:38:58 +09:00
Stephen Seo 287e3d98d8 Update LICENSE year 2024-01-27 22:09:49 +09:00
Stephen Seo b40f3daff7 Refactor archLinuxPackaging/PKGBUILD 2024-01-27 21:57:32 +09:00
Stephen Seo 2d7ddc1c2f Update archlinux packaging 2024-01-26 17:54:26 +09:00
Stephen Seo 4c708a2b9a Version 1.3.0
Allow toggling streaming and replay-buffer.
2024-01-26 17:37:03 +09:00
Stephen Seo 0376d6cf4b Update archLinux packaging 2024-01-26 17:11:40 +09:00
Stephen Seo d4becec995 Version 1.2.1
Fix client error on toggle recording.
Fix extra newline in output when toggling recording from client.
2024-01-26 17:08:43 +09:00
Stephen Seo 5700e720af Update archlinux packaging 2024-01-26 16:54:59 +09:00
Stephen Seo 3a9ac9e58c Version 1.2
Fix CMakeLists.txt.

Add new feature to "--toggle-recording" from client.

Set debug optimization flag to "-Og".
2024-01-26 16:50:25 +09:00
Stephen Seo 190b013e2d Update archLinuxPackaging/PKGBUILD 2023-08-14 11:50:12 +09:00
Stephen Seo 640ae65d07 Add support for controlling the replay buffer 2023-08-14 11:35:36 +09:00
Stephen Seo a18c507472 Update README.md 2023-08-13 16:03:51 +09:00
Stephen Seo 056139a718 Update README.md 2023-08-13 16:03:03 +09:00
Stephen Seo 43ab2cc04c Add README.md 2023-08-13 16:01:19 +09:00
Stephen Seo 8911bdab50 Add PKGBUILD 2023-08-13 15:45:01 +09:00
8 changed files with 239 additions and 7 deletions

View file

@ -0,0 +1,71 @@
name: Create releases with ArchLinux pkg
on:
push:
branches:
- '*'
jobs:
check-and-build-and-release:
runs-on: any_archLinux
steps:
- name: Get tags
run: |
curl --fail-with-body -X 'GET' \
'https://git.seodisparate.com/api/v1/repos/stephenseo/obs-studio-plugin-unix-socket-control/tags' \
-H 'accept: application/json' -o tags.json -w '%output{header_count}%header{x-total-count}' 2>/dev/null \
- name: Fetch repo
run: git clone https://git.seodisparate.com/stephenseo/obs-studio-plugin-unix-socket-control.git obs_usc
- name: Fetch PKGBUILD
run: pushd obs_usc >&/dev/null && git checkout main && popd >&/dev/null && cp obs_usc/archLinuxPackaging/PKGBUILD ./
- name: Check tags and build per release
run: |
SAVED_DIR="$(pwd)"
TAG_COUNT="$(cat ./header_count)"
for ((i=0; i<$TAG_COUNT; ++i)); do
echo "$(jq ".[$i].name" < ./tags.json | tr -d '"')" >> tempList
done
sort -V < tempList > versionList
for ((i=0; i<$TAG_COUNT; ++i)); do
cd "$SAVED_DIR"
TAG_NAME="$(sed -n "$((i+1))p" ./versionList)"
curl -X 'GET' "https://git.seodisparate.com/api/v1/repos/stephenseo/obs-studio-plugin-unix-socket-control/releases/tags/${TAG_NAME}" -H 'accept: application/json' -w '%output{http_code}%{http_code}' >&/dev/null
if [[ $(cat ./http_code) != "404" ]]; then
continue
fi
echo "Trying to build and release \"$TAG_NAME\"..."
mkdir -p "build_${TAG_NAME}" || continue
cp ./PKGBUILD "build_${TAG_NAME}/" || continue
sed -i "s/^pkgver=.*\$/pkgver=${TAG_NAME}/" "build_${TAG_NAME}/PKGBUILD" || continue
sed -i 's/^pkgrel=.*$/pkgrel=1/' "build_${TAG_NAME}/PKGBUILD" || continue
sed -i 's/^sha256sums=.*$/sha256sums=("SKIP")/' "build_${TAG_NAME}/PKGBUILD" || continue
cd "build_${TAG_NAME}" || continue
makepkg || continue
curl --fail-with-body -X 'POST' \
"https://git.seodisparate.com/api/v1/repos/stephenseo/obs-studio-plugin-unix-socket-control/releases" \
-H 'accept: application/json' \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H 'Content-Type: application/json' \
-d "{
\"name\": \"OBS Plugin Unix Socket Control version ${TAG_NAME}\",
\"body\": \"\",
\"tag_name\": \"${TAG_NAME}\"
}" > release_response.json || continue
curl --fail-with-body -X 'POST' \
"https://git.seodisparate.com/api/v1/repos/stephenseo/obs-studio-plugin-unix-socket-control/releases/$(jq .id < release_response.json)/assets" \
-H 'accept: application/json' \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H 'Content-Type: multipart/form-data' \
-F "attachment=@obs-studio-plugin-unix-socket-control-${TAG_NAME}-1-x86_64.pkg.tar.zst;type=application/zstd" > release_asset.json || continue
done

View file

@ -1,9 +1,16 @@
cmake_minimum_required(VERSION 3.25)
project(obs-studio-plugin-unix-socket-control)
set(obs_usc_VERSION_MAJOR 1)
set(obs_usc_VERSION_MINOR 3)
set(obs_usc_VERSION_PATCH 0)
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}")
add_compile_options(
-Wall -Wextra -Wpedantic
$<$<CONFIG:DEBUG>:-O0>
$<$<CONFIG:DEBUG>:-Og>
)
if(NOT DEFINED CMAKE_BUILD_TYPE OR NOT CMAKE_BUILD_TYPE)

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Stephen Seo
Copyright (c) 2023-2024 Stephen Seo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

11
README.md Normal file
View file

@ -0,0 +1,11 @@
# obs-studio-plugin-unix-socket-control
An obs-studio plugin that accepts commands over a unix socket to start/stop
recording/streaming or shows recording/streaming active status.
When building the plugin, an obs-studio plugin and a client program is built.
This exists because obs-studio keyboard shortcuts don't work on Wayland, and I
wanted a workaround to tell obs-studio to start/stop recording (via the use of
invoking a toggle script that uses this plugin's client with a configured Sway
keyboard shortcut).

View file

@ -0,0 +1,22 @@
pkgname=obs-studio-plugin-unix-socket-control
pkgver=1.3.0
pkgrel=1
pkgdesc="An obs studio plugin to command obs to start/stop recording/streaming via unix socket"
arch=(x86_64)
url="https://git.seodisparate.com/stephenseo/obs-studio-plugin-unix-socket-control"
license=('MIT')
depends=(obs-studio)
makedepends=(cmake)
source=("${pkgname}_${pkgver}.tar.gz::$url/archive/$pkgver.tar.gz")
sha256sums=(259ea3e490da13dd98b5593571310b7f0abab926be8436b00a272ca768b08eac)
build() {
cd "$pkgname"
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
make -C buildRelease
}
package() {
install -D -m555 "$srcdir/$pkgname/buildRelease/libunix-socket-control.so" "$pkgdir/usr/lib/obs-plugins/lib$pkgname.so"
install -D -m555 "$srcdir/$pkgname/buildRelease/unix-socket-control-client" "$pkgdir/usr/bin/$pkgname-client"
}

View file

@ -16,8 +16,14 @@ void print_usage(char *name) {
printf(" %s\n", name);
printf(" [--start-recording \n");
printf(" | --stop-recording\n");
printf(" | --toggle-recording\n");
printf(" | --start-streaming\n");
printf(" | --stop-streaming\n");
printf(" | --toggle-streaming\n");
printf(" | --start-replay-buffer\n");
printf(" | --stop-replay-buffer\n");
printf(" | --toggle-replay-buffer\n");
printf(" | --save-replay-buffer\n");
printf(" | --get-status]\n");
}
@ -37,8 +43,20 @@ int main(int argc, char **argv) {
type = UNIX_SOCKET_EVENT_STOP_RECORDING;
} else if (strncmp(argv[1], "--start-streaming", 17) == 0) {
type = UNIX_SOCKET_EVENT_START_STREAMING;
} else if (strncmp(argv[1], "--toggle-recording", 18) == 0) {
type = UNIX_SOCKET_EVENT_TOGGLE_RECORDING;
} else if (strncmp(argv[1], "--stop-streaming", 16) == 0) {
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) {
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], "--toggle-replay-buffer", 22) == 0) {
type = UNIX_SOCKET_EVENT_TOGGLE_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,10 +112,14 @@ 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");
} else if (buffer[0] != UNIX_SOCKET_EVENT_NOP) {
(buffer[1] & 2) != 0 ? "true" : "false",
(buffer[1] & 4) != 0 ? "true" : "false");
} 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.
return 7;
} else {
@ -108,12 +130,60 @@ int main(int argc, char **argv) {
case UNIX_SOCKET_EVENT_STOP_RECORDING:
puts("Sent event \"stop recording\"!");
break;
case UNIX_SOCKET_EVENT_TOGGLE_RECORDING:
switch(buffer[1]) {
case UNIX_SOCKET_EVENT_START_RECORDING:
puts("Sent event \"toggle recording\", recording STARTED!");
break;
case UNIX_SOCKET_EVENT_STOP_RECORDING:
puts("Sent event \"toggle recording\", recording STOPPED!");
break;
default:
puts("Sent event \"toggle recording\", recording status UNKNOWN!");
break;
}
break;
case UNIX_SOCKET_EVENT_START_STREAMING:
puts("Sent event \"start streaming\"!");
break;
case UNIX_SOCKET_EVENT_STOP_STREAMING:
puts("Sent event \"stop streaming\"!");
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:
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_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:
puts("Sent event \"save replay-buffer\"!");
break;
default:
// Error. TODO handle this
return 8;

View file

@ -9,7 +9,13 @@ 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,
UNIX_SOCKET_EVENT_TOGGLE_RECORDING,
UNIX_SOCKET_EVENT_TOGGLE_STREAMING,
UNIX_SOCKET_EVENT_TOGGLE_REPLAY_BUFFER
} UnixSocketEventType;
#endif

View file

@ -1,4 +1,5 @@
#include "socket.h"
#include "common_constants.h"
// standard library includes
#include <stdlib.h>
@ -77,12 +78,30 @@ int unix_socket_handler_thread_function(void *ud) {
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_RECORDING) {
obs_frontend_recording_stop();
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
} else if (buffer[0] == UNIX_SOCKET_EVENT_TOGGLE_RECORDING) {
ret_buffer[0] = UNIX_SOCKET_EVENT_TOGGLE_RECORDING;
if (obs_frontend_recording_active()) {
obs_frontend_recording_stop();
ret_buffer[1] = UNIX_SOCKET_EVENT_STOP_RECORDING;
} else {
obs_frontend_recording_start();
ret_buffer[1] = UNIX_SOCKET_EVENT_START_RECORDING;
}
} else if (buffer[0] == UNIX_SOCKET_EVENT_START_STREAMING) {
obs_frontend_streaming_start();
ret_buffer[0] = UNIX_SOCKET_EVENT_NOP;
} else if (buffer[0] == UNIX_SOCKET_EVENT_STOP_STREAMING) {
obs_frontend_streaming_stop();
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) {
ret_buffer[0] = UNIX_SOCKET_EVENT_GET_STATUS;
if (obs_frontend_recording_active()) {
@ -91,6 +110,32 @@ 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_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) {
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;