mirror of
https://github.com/novatiq/packages.git
synced 2026-04-29 23:18:42 +01:00
v4l2rtspserver: add package
Signed-off-by: Roger Dammit <rogerdammit@gmail.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
COMPILE_OPTS = $(INCLUDES) -I. -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOCALE_NOT_USED -DNO_SSTREAM=1 -DALLOW_RTSP_SERVER_PORT_REUSE=1
|
||||
C = c
|
||||
C_COMPILER = $(GCC)
|
||||
CFLAGS += $(COMPILE_OPTS)
|
||||
C_FLAGS = $(CFLAGS)
|
||||
CPP = cpp
|
||||
CPLUSPLUS_COMPILER = $(AS) # optimizations are only in AR apparently, so use instead of CXX
|
||||
CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1
|
||||
CPLUSPLUS_FLAGS += $(CPPFLAGS) -fexceptions
|
||||
OBJ = o
|
||||
LINK = $(CXX) -o
|
||||
LINK_OPTS = -L. $(LDFLAGS)
|
||||
CONSOLE_LINK_OPTS = $(LINK_OPTS)
|
||||
LIBRARY_LINK = $(AR) cr
|
||||
LIBRARY_LINK_OPTS =
|
||||
LIB_SUFFIX = a
|
||||
LIBS_FOR_CONSOLE_APPLICATION = $(CXXLIBS)
|
||||
LIBS_FOR_GUI_APPLICATION = $(LIBS_FOR_CONSOLE_APPLICATION)
|
||||
EXE =
|
||||
@@ -0,0 +1,10 @@
|
||||
config v4l2rtspserver 'core'
|
||||
option enabled '0'
|
||||
option device '/dev/video0'
|
||||
option port '554'
|
||||
option resolution '640x480'
|
||||
option fps '15'
|
||||
option path 'stream'
|
||||
option username 'openwrt'
|
||||
option password 'openwrt'
|
||||
option format 'h264'
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2017 OpenWrt.org
|
||||
|
||||
# TODO:
|
||||
# * support start multiple streams with one server
|
||||
# * support multiple usernames
|
||||
# * support HLS, etc.
|
||||
|
||||
START=90
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
SERVICE=v4l2rtspserver
|
||||
PROG=/usr/bin/$SERVICE
|
||||
|
||||
error() {
|
||||
logger -t "$SERVICE" "$@"
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local s="$1"
|
||||
|
||||
config_get_bool enabled "$1" 'enabled' 0
|
||||
[ $enabled -eq 0 ] && return
|
||||
|
||||
# validate device
|
||||
config_get device "$s" 'device'
|
||||
if [ ! -c "$device" ]; then
|
||||
error "device '$device' does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# get options
|
||||
config_get port "$s" 'port'
|
||||
config_get resolution "$s" 'resolution'
|
||||
config_get fps "$s" 'fps'
|
||||
config_get username "$s" 'username'
|
||||
config_get password "$s" 'password'
|
||||
config_get path "$s" 'path'
|
||||
config_get format "$s" 'format'
|
||||
|
||||
# pull out resolution width and height from string
|
||||
local w="$(echo $resolution | cut -d'x' -f1)"
|
||||
local h="$(echo $resolution | cut -d'x' -f2)"
|
||||
|
||||
# make sure format is uppercase
|
||||
format="$(echo $format | tr a-z A-Z)"
|
||||
|
||||
# build args
|
||||
local args="-s"
|
||||
args="$args -P $port"
|
||||
args="$args -u ${path}"
|
||||
args="$args -F $fps"
|
||||
args="$args -W $w"
|
||||
args="$args -H $h"
|
||||
args="$args -f$format"
|
||||
args="$args -c" # fixes issue with corrupt frames with H264
|
||||
|
||||
if [ -n "$username" ]; then
|
||||
args="$args -U ${username}:${password}"
|
||||
fi
|
||||
|
||||
cmd="$PROG $args $device"
|
||||
|
||||
# procd stuff
|
||||
procd_open_instance
|
||||
procd_set_param file /etc/config/$SERVICE
|
||||
procd_set_param command $cmd
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_add_mdns "rtsp" "tcp" "$port" "daemon=$SERVICE" "path=/$path"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "$SERVICE"
|
||||
config_foreach start_instance "$SERVICE"
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$SERVICE"
|
||||
}
|
||||
Reference in New Issue
Block a user