This commit is contained in:
2026-04-09 18:19:03 -03:00
parent 5921cd6562
commit 5b467ffba8
18 changed files with 1793 additions and 43 deletions

36
media/ctrl/build.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
# Build media transport targets
# Usage: ./build.sh [client|server|all] [--release]
# client build cht-client (default)
# server build cht-server
# all build both
set -euo pipefail
MEDIA_DIR="$(cd "$(dirname "$0")/.." && pwd)"
CARGO="${CARGO:-$HOME/.cargo/bin/cargo}"
TARGET="${1:-client}"
shift || true
CARGO_FLAGS=()
for arg in "$@"; do
CARGO_FLAGS+=("$arg")
done
LOG_DIR="$MEDIA_DIR/logs"
mkdir -p "$LOG_DIR"
build() {
local pkg="$1"
local log="$LOG_DIR/build-$pkg.log"
echo "==> building $pkg ${CARGO_FLAGS[*]+"${CARGO_FLAGS[@]}"}"
"$CARGO" build -p "cht-$pkg" "${CARGO_FLAGS[@]}" --manifest-path "$MEDIA_DIR/Cargo.toml" 2>&1 | tee "$log"
return "${PIPESTATUS[0]}"
}
case "$TARGET" in
client) build client ;;
server) build server ;;
all) build client || true; build server ;;
*) echo "Usage: $0 [client|server|all] [--release]" >&2; exit 1 ;;
esac

21
media/ctrl/client.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Build and run the media client (sender)
# Requires DRM master access — runs under sudo unless already root.
# Usage: ./client.sh [server_addr] e.g. ./client.sh mcrndeb:4444
set -euo pipefail
MEDIA_DIR="$(cd "$(dirname "$0")/.." && pwd)"
CARGO="${CARGO:-$HOME/.cargo/bin/cargo}"
LOG_DIR="$MEDIA_DIR/logs"
mkdir -p "$LOG_DIR"
"$CARGO" build -p cht-client --manifest-path "$MEDIA_DIR/Cargo.toml" 2>&1 | tee "$LOG_DIR/build-client.log"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then exit 1; fi
BIN="$MEDIA_DIR/target/debug/cht-client"
if [ "$(id -u)" -ne 0 ]; then
exec sudo "$BIN" "$@"
else
exec "$BIN" "$@"
fi

21
media/ctrl/docs.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Re-render all Graphviz diagrams to SVG.
# Run this after each phase when .dot files are updated.
# Usage: ./docs.sh
set -euo pipefail
DOCS_DIR="$(cd "$(dirname "$0")/../docs" && pwd)"
if ! command -v dot &>/dev/null; then
echo "graphviz not found — install with: sudo apt install graphviz" >&2
exit 1
fi
for f in "$DOCS_DIR"/*.dot; do
svg="${f%.dot}.svg"
echo "==> $(basename "$f")$(basename "$svg")"
dot -Tsvg "$f" -o "$svg"
done
echo "==> done. Serving at http://localhost:9099 (ctrl-c to stop)"
cd "$DOCS_DIR" && python3 -m http.server 9099

15
media/ctrl/server.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Build and run the media server (receiver).
# Run this on mcrndeb directly.
# Usage: ./server.sh [port]
set -euo pipefail
MEDIA_DIR="$(cd "$(dirname "$0")/.." && pwd)"
CARGO="${CARGO:-$HOME/.cargo/bin/cargo}"
LOG_DIR="$MEDIA_DIR/logs"
mkdir -p "$LOG_DIR"
"$CARGO" build -p cht-server --manifest-path "$MEDIA_DIR/Cargo.toml" 2>&1 | tee "$LOG_DIR/build-server.log"
if [ "${PIPESTATUS[0]}" -ne 0 ]; then exit 1; fi
exec "$MEDIA_DIR/target/debug/cht-server" "$@"