From 9b84b52ef5224a65e8cc9b2fd2fe2c5f136b4e42 Mon Sep 17 00:00:00 2001 From: snokvist Date: Sun, 5 Jul 2026 14:44:52 +0200 Subject: [PATCH] package: add waybeam encoder for Infinity6E and Infinity6C Buildroot package building the OpenIPC/waybeam_venc H.265 video encoder and streamer for SigmaStar Infinity6E (SSC338Q/SSC30KQ) and Infinity6C (SSC378QE). The SoC backend is selected from OPENIPC_SOC_FAMILY. The source is MIT-licensed. Installs /usr/bin/waybeam, /usr/bin/json_cli, /etc/waybeam.json and /etc/init.d/S95waybeam. On Infinity6C it also installs the encoder's own imx335/imx415 sensor modules as sensor_imx*_mipi.ko and the matching imx335.bin/imx415.bin, since there are no in-tree modules for these sensors; the package is ordered after sigmastar-osdrv-sensors and sigmastar-osdrv-infinity6c so those modules install over the stock ones. waybeam and Majestic cannot be built together (depends on !BR2_PACKAGE_MAJESTIC): both drive the same sensor and encoder, and the SigmaStar OSDRV MI libraries are installed only when Majestic is not selected. The package ships no libraries; OSDRV provides them. Co-Authored-By: Claude Opus 4.8 (1M context) --- package/waybeam/Config.in | 22 ++++++ package/waybeam/files/S95waybeam | 60 +++++++++++++++++ package/waybeam/files/waybeam.json | 105 +++++++++++++++++++++++++++++ package/waybeam/waybeam.mk | 69 +++++++++++++++++++ 4 files changed, 256 insertions(+) create mode 100644 package/waybeam/Config.in create mode 100644 package/waybeam/files/S95waybeam create mode 100644 package/waybeam/files/waybeam.json create mode 100644 package/waybeam/waybeam.mk diff --git a/package/waybeam/Config.in b/package/waybeam/Config.in new file mode 100644 index 000000000..351f3e53b --- /dev/null +++ b/package/waybeam/Config.in @@ -0,0 +1,22 @@ +config BR2_PACKAGE_WAYBEAM + bool "waybeam" + depends on BR2_TOOLCHAIN_HAS_THREADS + depends on BR2_PACKAGE_SIGMASTAR_OSDRV_INFINITY6E || \ + BR2_PACKAGE_SIGMASTAR_OSDRV_INFINITY6C + depends on !BR2_PACKAGE_MAJESTIC + help + Standalone H.265 video encoder and streamer for SigmaStar + Infinity6E (SSC338Q/SSC30KQ) and Infinity6C (SSC378QE). The + SoC backend is selected automatically from the target SoC + family. Provides a dual encoder backend, sensor unlock and an + HTTP configuration API. + + It is an alternative to the Majestic streamer and cannot be + built alongside it: both drive the same sensor and encoder + hardware, and both rely on the SigmaStar OSDRV MI libraries, + which OSDRV installs only when Majestic is not selected. + + Installs: + - /usr/bin/waybeam + - /etc/waybeam.json + - /etc/init.d/S95waybeam diff --git a/package/waybeam/files/S95waybeam b/package/waybeam/files/S95waybeam new file mode 100644 index 000000000..c249d7ad5 --- /dev/null +++ b/package/waybeam/files/S95waybeam @@ -0,0 +1,60 @@ +#!/bin/sh + +DAEMON="waybeam" +RESPAWN="waybeam-resp" +WATCHDOG="waybeam-wd" +DAEMON_PATH="/usr/bin/waybeam" +LOG_PATH="/tmp/waybeam.log" + +# waybeam forks a respawn child (comm "waybeam-resp") on an API restart and a +# watchdog ("waybeam-wd"). pidof and killall match by comm, so every restart +# path must cover all three names, otherwise stop() returns while a helper is +# still alive and the next start() trips the duplicate-instance check. +still_running() { + pidof "$DAEMON" "$RESPAWN" "$WATCHDOG" >/dev/null 2>&1 +} + +wait_exit() { + i=0 + while [ $i -lt 30 ]; do + still_running || return 0 + sleep 0.5 + i=$((i + 1)) + done + echo "Warning: $DAEMON did not exit in time" +} + +start() { + if still_running; then + echo "$DAEMON already running" + return 0 + fi + echo -n "Starting $DAEMON: " + # waybeam reads /etc/waybeam.json from a fixed path; it has no -c flag. + "$DAEMON_PATH" > "$LOG_PATH" 2>&1 & + i=0 + while [ $i -lt 10 ]; do + sleep 0.3 + still_running && { echo "OK"; return 0; } + i=$((i + 1)) + done + echo "FAILED (crashed at init or lost the duplicate-instance check, see $LOG_PATH)" + return 1 +} + +stop() { + echo -n "Stopping $DAEMON: " + killall "$DAEMON" "$RESPAWN" "$WATCHDOG" 2>/dev/null + wait_exit + echo "OK" +} + +case "$1" in + start) start ;; + stop) stop ;; + restart) stop; start ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/package/waybeam/files/waybeam.json b/package/waybeam/files/waybeam.json new file mode 100644 index 000000000..e79497e60 --- /dev/null +++ b/package/waybeam/files/waybeam.json @@ -0,0 +1,105 @@ +{ + "system": { + "webPort": 80, + "overclockLevel": 1, + "verbose": false + }, + "sensor": { + "index": -1, + "mode": -1 + }, + "isp": { + "sensorBin": "", + "aeEngine": "sdk", + "aeFps": 15, + "gainMax": 0, + "awbMode": "auto", + "awbCt": 5500, + "keepAspect": true + }, + "image": { + "mirror": false, + "flip": false, + "rotate": 0 + }, + "video0": { + "rcMode": "cbr", + "fps": 90, + "size": "auto", + "bitrate": 2580, + "gopSize": 5.0, + "qpDelta": -12, + "frameLost": true, + "sceneThreshold": 0, + "sceneHoldoff": 2, + "resilience": "off", + "zoomX": 0.5, + "zoomY": 0.5, + "framing": "off", + "stabCropPct": 0, + "stabRecenterSpeed": 0, + "stabKalmanQ": 0.0, + "stabKalmanR": 0.0 + }, + "outgoing": { + "enabled": true, + "server": "udp://192.168.1.10:5600", + "streamMode": "rtp", + "maxPayloadSize": 1400, + "connectedUdp": true, + "audioPort": 5601, + "sidecarPort": 5602 + }, + "discovery": { + "enabled": true, + "serviceType": "_waybeam-venc._tcp", + "name": "", + "bareAlias": true + }, + "fpv": { + "roiEnabled": false, + "roiQp": 0, + "roiSteps": 2, + "roiCenter": 0.4, + "noiseLevel": 0 + }, + "audio": { + "enabled": false, + "sampleRate": 48000, + "channels": 1, + "codec": "opus", + "volume": 80, + "mute": false + }, + "imu": { + "enabled": false, + "i2cDevice": "/dev/i2c-1", + "i2cAddr": "0x68", + "sampleRateHz": 200, + "gyroRangeDps": 1000, + "calFile": "/etc/imu.cal", + "calSamples": 400 + }, + "record": { + "enabled": false, + "dir": "/mnt/mmcblk0p1", + "format": "ts", + "mode": "mirror", + "maxSeconds": 300, + "maxMB": 500, + "bitrate": 0, + "fps": 0, + "gopSize": 0.0, + "server": "" + }, + "snapshot": { + "enabled": true, + "quality": 80, + "channel": 7, + "width": 0, + "height": 0 + }, + "debug": { + "showOsd": false + } +} diff --git a/package/waybeam/waybeam.mk b/package/waybeam/waybeam.mk new file mode 100644 index 000000000..d114df70f --- /dev/null +++ b/package/waybeam/waybeam.mk @@ -0,0 +1,69 @@ +################################################################################ +# +# waybeam +# +################################################################################ + +WAYBEAM_VERSION = HEAD +WAYBEAM_SITE = https://github.com/OpenIPC/waybeam_venc.git +WAYBEAM_SITE_METHOD = git +WAYBEAM_LICENSE = MIT +WAYBEAM_LICENSE_FILES = LICENSE + +# The encoder ships a single source tree with two SoC backends selected by +# SOC_BUILD. Derive it from the target SoC family and build with Buildroot's +# toolchain; CC_BIN / CC_MARUKO_BIN point the tree's toolchain check at the +# same compiler so it does not fetch its own. The `stage` target also lays out +# the Maruko sensor modules and ISP bins under out/maruko/. +ifeq ($(OPENIPC_SOC_FAMILY),infinity6c) +WAYBEAM_SOC = maruko +WAYBEAM_MAKE_OPTS = SOC_BUILD=maruko MARUKO_CC="$(TARGET_CC)" CC_MARUKO_BIN="$(TARGET_CC)" +# Built after the stock sensor and MI-library packages so the modified Maruko +# sensor modules install over the stock sensor_imx*_mipi.ko names. +WAYBEAM_DEPENDENCIES += sigmastar-osdrv-sensors sigmastar-osdrv-infinity6c +else +WAYBEAM_SOC = star6e +WAYBEAM_MAKE_OPTS = SOC_BUILD=star6e STAR6E_CC="$(TARGET_CC)" CC_BIN="$(TARGET_CC)" +endif + +define WAYBEAM_BUILD_CMDS + $(MAKE) -C $(@D) stage json_cli $(WAYBEAM_MAKE_OPTS) +endef + +define WAYBEAM_INSTALL_TARGET_CMDS + $(INSTALL) -m 0755 -D $(@D)/out/$(WAYBEAM_SOC)/waybeam \ + $(TARGET_DIR)/usr/bin/waybeam + $(INSTALL) -m 0755 -D $(@D)/out/$(WAYBEAM_SOC)/json_cli \ + $(TARGET_DIR)/usr/bin/json_cli + $(INSTALL) -m 0644 -D $(WAYBEAM_PKGDIR)/files/waybeam.json \ + $(TARGET_DIR)/etc/waybeam.json +endef + +# The encoder dlopens the SigmaStar MI libraries at runtime. They are +# installed to /usr/lib by sigmastar-osdrv-infinity6{e,c}, which does so +# only when Majestic is not selected; waybeam depends on !MAJESTIC, so +# that path always applies and the package ships no libraries itself. + +# Infinity6C (Maruko) has no in-tree modules for these sensors and Waybeam +# uses its own modified imx335/imx415 drivers. Install them under the stock +# _mipi.ko names, plus the matching ISP tuning bins. +ifeq ($(WAYBEAM_SOC),maruko) +define WAYBEAM_INSTALL_MARUKO_SENSORS + $(INSTALL) -m 0644 -D $(@D)/out/maruko/drivers/sensor_imx335_mipi.ko \ + $(TARGET_DIR)/lib/modules/5.10.61/sigmastar/sensor_imx335_mipi.ko + $(INSTALL) -m 0644 -D $(@D)/out/maruko/drivers/sensor_imx415_mipi.ko \ + $(TARGET_DIR)/lib/modules/5.10.61/sigmastar/sensor_imx415_mipi.ko + $(INSTALL) -m 0644 -D $(@D)/out/maruko/isp-bins/imx335.bin \ + $(TARGET_DIR)/etc/sensors/imx335.bin + $(INSTALL) -m 0644 -D $(@D)/out/maruko/isp-bins/imx415.bin \ + $(TARGET_DIR)/etc/sensors/imx415.bin +endef +WAYBEAM_POST_INSTALL_TARGET_HOOKS += WAYBEAM_INSTALL_MARUKO_SENSORS +endif + +define WAYBEAM_INSTALL_INIT_SYSV + $(INSTALL) -m 0755 -D $(WAYBEAM_PKGDIR)/files/S95waybeam \ + $(TARGET_DIR)/etc/init.d/S95waybeam +endef + +$(eval $(generic-package))