From b7c39347711fa34c2650c96ac4e03577c2a91e85 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sat, 21 Sep 2024 16:43:20 -0400 Subject: [PATCH] First sort of working copy of the .ps1 prototype. --- .vimrc_proj | 1 + main.cpp | 29 +++++++++++++++++++++++++++++ meson.build | 10 +++++++++- scripts/reset_build.ps1 | 1 + scripts/reset_build.sh | 1 + 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .vimrc_proj create mode 100644 main.cpp diff --git a/.vimrc_proj b/.vimrc_proj new file mode 100644 index 0000000..d58d328 --- /dev/null +++ b/.vimrc_proj @@ -0,0 +1 @@ +set makeprg=meson\ compile\ -j\ 4\ -C\ . diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..eae743f --- /dev/null +++ b/main.cpp @@ -0,0 +1,29 @@ +#include +#include "dbc.hpp" + +#define BUF_MAX 1024 * 10 +using namespace fmt; + +const string TWITCH_BR="7M"; + +FILE *run_ffmpeg() { + string ffmpeg_cmd = format("ffmpeg -listen 1 -i rtmp://192.168.254.146/ -bufsize 3000k -maxrate $twitch_br -flags +global_header -c:v libx264 -preset veryfast -tune zerolatency -g:v 60 -vb $twitch_br -c:a copy -f flv $twitch"); + + FILE *handle = popen(ffmpeg_cmd.c_str(), "r"); + dbc::check(handle != nullptr, "failed to start ffmpeg"); + return handle; +} + +int main() { + FILE *handle = run_ffmpeg(); + char buffer[BUF_MAX]; + char *res = nullptr; + + do { + res = fgets(buffer, BUF_MAX, handle); + print("OUT: {}", res); + } while(res != nullptr); + + int rc = pclose(handle); + dbc::check(rc == 0, "error closing ffmpeg"); +} diff --git a/meson.build b/meson.build index 8e409b7..9d1e365 100644 --- a/meson.build +++ b/meson.build @@ -3,12 +3,20 @@ project('distributary', 'cpp', catch2 = dependency('catch2-with-main') fmt = dependency('fmt') +json = dependency('nlohmann_json') +depends = [catch2, fmt, json] runtests = executable('runtests', [ 'dbc.cpp', 'tests/fsm.cpp', 'tests/dbc.cpp', ], - dependencies: [catch2, fmt]) + dependencies: depends) + +distributary = executable('distributary', [ + 'main.cpp', + 'dbc.cpp', + ], + dependencies: depends) test('tests', runtests) diff --git a/scripts/reset_build.ps1 b/scripts/reset_build.ps1 index 03ccae4..f49e981 100644 --- a/scripts/reset_build.ps1 +++ b/scripts/reset_build.ps1 @@ -6,6 +6,7 @@ cp *.wrap subprojects mkdir builddir meson wrap install fmt meson wrap install catch2 +meson wrap install nlohmann_json # $env:CC="clang" # $env:CXX="clang++" meson setup --default-library=static --prefer-static builddir diff --git a/scripts/reset_build.sh b/scripts/reset_build.sh index a419b6c..a2b40f3 100644 --- a/scripts/reset_build.sh +++ b/scripts/reset_build.sh @@ -9,4 +9,5 @@ mkdir builddir cp *.wrap subprojects meson wrap install fmt meson wrap install catch2 +meson wrap install nlohmann_json meson setup builddir