Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ __pycache__/

# Benchmark results
tools/benchmark_results_*.txt

# iKuai package outputs
ikuai-support/.staging/
ikuai-support/dist/
7 changes: 7 additions & 0 deletions ikuai-support/rtp2httpd/app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
HOST_IP=0.0.0.0
APP_PORT_WEB=5140
RTP2HTTPD_CONFIG=app/config/rtp2httpd.conf
RTP2HTTPD_MAXCLIENTS=20
RTP2HTTPD_WORKERS=1
RTP2HTTPD_VERBOSITY=2
RTP2HTTPD_EXTRA_ARGS=
Empty file.
50 changes: 50 additions & 0 deletions ikuai-support/rtp2httpd/app/config/rtp2httpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# rtp2httpd configuration for native iKuai package.
#
# scripts/start.sh passes listen address, port, max clients, worker count,
# and verbosity from app/.env as command-line arguments. Values below are
# kept as safe defaults and examples for advanced settings.

[global]
verbosity = 2
maxclients = 20
workers = 1

# Keep UDPxy-compatible URLs enabled. Example:
# http://192.168.1.1:5140/rtp/239.253.64.120:5140
udpxy = yes

# Set an upstream interface only if the iKuai host routing table cannot
# reach the IPTV multicast network correctly.
;upstream-interface = eth0
;upstream-interface-multicast = eth0
;upstream-interface-fcc = eth0
;upstream-interface-rtsp = eth0
;upstream-interface-http = eth0

# Optional external playlist. HTTP/HTTPS fetching requires curl on the host.
;external-m3u = https://example.com/playlist.m3u
external-m3u-update-interval = 7200

# Enable only if your network drops multicast membership periodically.
;mcast-rejoin-interval = 60

# Restrict FCC UDP ports when upstream NAT or firewall rules require it.
;fcc-listen-port-range = 40000-40100

# Enable only on kernels that support MSG_ZEROCOPY and when locked memory
# limits are configured properly.
zerocopy-on-send = no

# Enable only if ffmpeg is installed and reachable from iKuai's shell.
video-snapshot = no
;ffmpeg-path = /usr/bin/ffmpeg
;ffmpeg-args = -hwaccel none

[bind]
* 5140

[services]
# You can paste an M3U playlist here as an alternative to external-m3u.
;#EXTM3U
;#EXTINF:-1 group-title="IPTV",CCTV-1
;rtp://239.253.64.120:5140
2 changes: 2 additions & 0 deletions ikuai-support/rtp2httpd/app/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Runtime environment variables loaded by scripts/start.sh after app/.env.
# TZ=Asia/Shanghai
80 changes: 80 additions & 0 deletions ikuai-support/rtp2httpd/app/option.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[
{
"default": "0.0.0.0",
"attrname": "HOST_IP",
"label": {
"en": "Listen address",
"zh": "监听地址"
},
"required": true,
"scope": "config",
"type": "text",
"min": 1,
"max": 64
},
{
"default": 5140,
"attrname": "APP_PORT_WEB",
"label": {
"en": "Web and stream port",
"zh": "Web 与流服务端口"
},
"required": true,
"scope": "config",
"type": "integer",
"min": 1,
"max": 65535
},
{
"default": 20,
"attrname": "RTP2HTTPD_MAXCLIENTS",
"label": {
"en": "Maximum clients",
"zh": "最大客户端数"
},
"required": true,
"scope": "config",
"type": "integer",
"min": 1,
"max": 4096
},
{
"default": 1,
"attrname": "RTP2HTTPD_WORKERS",
"label": {
"en": "Worker processes",
"zh": "工作进程数"
},
"required": true,
"scope": "config",
"type": "integer",
"min": 1,
"max": 64
},
{
"default": 2,
"attrname": "RTP2HTTPD_VERBOSITY",
"label": {
"en": "Log verbosity",
"zh": "日志级别"
},
"required": true,
"scope": "config",
"type": "integer",
"min": 0,
"max": 4
},
{
"default": "",
"attrname": "RTP2HTTPD_EXTRA_ARGS",
"label": {
"en": "Extra command arguments",
"zh": "额外启动参数"
},
"required": false,
"scope": "config",
"type": "text",
"min": 0,
"max": 1024
}
]
3 changes: 3 additions & 0 deletions ikuai-support/rtp2httpd/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
v3.12.2

首次上架爱快应用市场。
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions ikuai-support/rtp2httpd/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "rtp2httpd",
"version": "v3.12.2",
"display_name": "rtp2httpd",
"image": "rtp2httpd-3.12.2-x86_64-static",
"description": "面向 IPTV 场景的组播、RTSP、HTTP 流媒体转发服务,内置状态页面和 Web 播放器。可替代 udpxy 和 msd_lite。",
"type": "0",
"maintainer": "stackia",
"maintainer_url": "https://github.com/stackia/rtp2httpd",
"distributor": "stackia",
"distributor_url": "https://github.com/stackia/rtp2httpd",
"requirements": {
"memory": "64MB",
"storage": "16MB",
"os_min_version": "4.0.0"
}
}
7 changes: 7 additions & 0 deletions ikuai-support/rtp2httpd/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rtp2httpd 通过 scripts/start.sh 和 scripts/stop.sh 在爱快系统中以原生方式运行,不依赖 Docker Compose。

此软件包需要在 app/bin/rtp2httpd 放置静态 Linux 二进制文件。可以使用 scripts/build-rtp2httpd-ipkg.sh 从官方 Release 二进制构建完整 .ipkg,也可以通过 BINARY_PATH 指定本地二进制文件。

服务监听 APP_PORT_WEB,默认端口为 5140,同时提供状态页面、Web 播放器和 IPTV 流媒体代理入口。默认状态页面为 /status,Web 播放器为 /player。

组播接收依赖爱快主机网络环境。如果无法播放,请先确认爱快主机能够访问 IPTV 组播网络,并检查 IGMP、组播转发和路由配置。若系统路由不能正确选择 IPTV 接口,可在 app/config/rtp2httpd.conf 中配置 upstream-interface 相关参数。
13 changes: 13 additions & 0 deletions ikuai-support/rtp2httpd/scripts/POST_INST.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd "$(dirname "$0")" && pwd)
PKG_DIR=$(dirname "$SCRIPT_DIR")
INSTALL_LOG="$PKG_DIR/log/install.log"

if [ ! -x "$PKG_DIR/app/bin/rtp2httpd" ]; then
printf '%s POST_INST warning: app/bin/rtp2httpd is missing or not executable\n' "$(date '+%Y-%m-%d %H:%M:%S')" >> "$INSTALL_LOG"
exit 0
fi

printf '%s POST_INST completed\n' "$(date '+%Y-%m-%d %H:%M:%S')" >> "$INSTALL_LOG"
9 changes: 9 additions & 0 deletions ikuai-support/rtp2httpd/scripts/POST_UNINST.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd "$(dirname "$0")" && pwd)
PKG_DIR=$(dirname "$SCRIPT_DIR")
INSTALL_LOG="$PKG_DIR/log/install.log"

rm -f "$PKG_DIR/app/cache/rtp2httpd.pid"
printf '%s POST_UNINST completed\n' "$(date '+%Y-%m-%d %H:%M:%S')" >> "$INSTALL_LOG"
14 changes: 14 additions & 0 deletions ikuai-support/rtp2httpd/scripts/PRE_INST.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd "$(dirname "$0")" && pwd)
PKG_DIR=$(dirname "$SCRIPT_DIR")
INSTALL_LOG="$PKG_DIR/log/install.log"

mkdir -p "$PKG_DIR/app/bin" "$PKG_DIR/app/cache" "$PKG_DIR/app/config" "$PKG_DIR/app/data" "$PKG_DIR/log"

if [ -f "$PKG_DIR/app/bin/rtp2httpd" ]; then
chmod 755 "$PKG_DIR/app/bin/rtp2httpd"
fi

printf '%s PRE_INST completed\n' "$(date '+%Y-%m-%d %H:%M:%S')" >> "$INSTALL_LOG"
12 changes: 12 additions & 0 deletions ikuai-support/rtp2httpd/scripts/PRE_UNINST.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd "$(dirname "$0")" && pwd)
PKG_DIR=$(dirname "$SCRIPT_DIR")
INSTALL_LOG="$PKG_DIR/log/install.log"

if [ -x "$SCRIPT_DIR/stop.sh" ]; then
"$SCRIPT_DIR/stop.sh" || true
fi

printf '%s PRE_UNINST completed\n' "$(date '+%Y-%m-%d %H:%M:%S')" >> "$INSTALL_LOG"
93 changes: 93 additions & 0 deletions ikuai-support/rtp2httpd/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd "$(dirname "$0")" && pwd)
PKG_DIR=$(dirname "$SCRIPT_DIR")
CONFIG_ENV="$PKG_DIR/app/.env"
RUNTIME_ENV="$PKG_DIR/app/environment"
BIN="$PKG_DIR/app/bin/rtp2httpd"
PIDFILE="$PKG_DIR/app/cache/rtp2httpd.pid"
RUN_LOG="$PKG_DIR/log/run.log"

log() {
printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*" >> "$RUN_LOG"
}

load_env_file() {
if [ -f "$1" ]; then
set -a
. "$1"
set +a
fi
}

mkdir -p "$PKG_DIR/app/cache" "$PKG_DIR/app/data" "$PKG_DIR/log"
load_env_file "$CONFIG_ENV"
load_env_file "$RUNTIME_ENV"

: "${HOST_IP:=0.0.0.0}"
: "${APP_PORT_WEB:=5140}"
: "${RTP2HTTPD_CONFIG:=app/config/rtp2httpd.conf}"
: "${RTP2HTTPD_MAXCLIENTS:=20}"
: "${RTP2HTTPD_WORKERS:=1}"
: "${RTP2HTTPD_VERBOSITY:=2}"
: "${RTP2HTTPD_EXTRA_ARGS:=}"

case "$RTP2HTTPD_CONFIG" in
/*) CONFIG_FILE="$RTP2HTTPD_CONFIG" ;;
*) CONFIG_FILE="$PKG_DIR/$RTP2HTTPD_CONFIG" ;;
esac

if [ ! -x "$BIN" ]; then
log "Binary is missing or not executable: $BIN"
exit 1
fi

if [ ! -f "$CONFIG_FILE" ]; then
log "Config file is missing: $CONFIG_FILE"
exit 1
fi

if [ -f "$PIDFILE" ]; then
OLD_PID=$(cat "$PIDFILE" 2>/dev/null || true)
if [ -n "$OLD_PID" ] && kill -0 "$OLD_PID" 2>/dev/null; then
log "rtp2httpd is already running, pid=$OLD_PID"
exit 0
fi
rm -f "$PIDFILE"
fi

if [ "$HOST_IP" = "*" ] || [ "$HOST_IP" = "0.0.0.0" ]; then
LISTEN="$APP_PORT_WEB"
else
LISTEN="$HOST_IP:$APP_PORT_WEB"
fi

export HOME="$PKG_DIR/app/data"

set -- "$BIN" \
--config "$CONFIG_FILE" \
--listen "$LISTEN" \
--maxclients "$RTP2HTTPD_MAXCLIENTS" \
--workers "$RTP2HTTPD_WORKERS" \
--verbose "$RTP2HTTPD_VERBOSITY"

if [ -n "$RTP2HTTPD_EXTRA_ARGS" ]; then
# Intentionally split extra arguments so advanced users can pass native CLI flags.
set -- "$@" $RTP2HTTPD_EXTRA_ARGS
fi

log "Starting rtp2httpd: $*"
nohup "$@" >> "$RUN_LOG" 2>&1 &
PID=$!
printf '%s\n' "$PID" > "$PIDFILE"

sleep 1
if kill -0 "$PID" 2>/dev/null; then
log "rtp2httpd started, pid=$PID"
exit 0
fi

rm -f "$PIDFILE"
log "rtp2httpd failed to start"
exit 1
41 changes: 41 additions & 0 deletions ikuai-support/rtp2httpd/scripts/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd "$(dirname "$0")" && pwd)
PKG_DIR=$(dirname "$SCRIPT_DIR")
PIDFILE="$PKG_DIR/app/cache/rtp2httpd.pid"
RUN_LOG="$PKG_DIR/log/run.log"

log() {
mkdir -p "$PKG_DIR/log"
printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*" >> "$RUN_LOG"
}

if [ ! -f "$PIDFILE" ]; then
log "rtp2httpd is not running: pid file missing"
exit 0
fi

PID=$(cat "$PIDFILE" 2>/dev/null || true)
if [ -z "$PID" ] || ! kill -0 "$PID" 2>/dev/null; then
rm -f "$PIDFILE"
log "rtp2httpd is not running: stale pid file removed"
exit 0
fi

log "Stopping rtp2httpd, pid=$PID"
kill "$PID" 2>/dev/null || true

COUNT=0
while kill -0 "$PID" 2>/dev/null; do
COUNT=$((COUNT + 1))
if [ "$COUNT" -ge 10 ]; then
log "rtp2httpd did not stop after TERM, sending KILL"
kill -9 "$PID" 2>/dev/null || true
break
fi
sleep 1
done

rm -f "$PIDFILE"
log "rtp2httpd stopped"
1 change: 1 addition & 0 deletions ikuai-support/rtp2httpd/ui/ico/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added ikuai-support/rtp2httpd/ui/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ikuai-support/rtp2httpd/ui/images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading