|
|
@ -14,99 +14,119 @@ error() { |
|
|
|
start_instance() { |
|
|
|
local s="$1" |
|
|
|
|
|
|
|
local enabled |
|
|
|
config_get_bool enabled "$1" 'enabled' 0 |
|
|
|
[ $enabled -eq 0 ] && return |
|
|
|
[ "$enabled" ] || return |
|
|
|
|
|
|
|
local input |
|
|
|
config_get input "$s" 'input' |
|
|
|
if [ -z "$input" ]; then |
|
|
|
[ -z "$input" ] && { |
|
|
|
error "in section '$s' option input is missing" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
local output |
|
|
|
config_get output "$s" 'output' |
|
|
|
if [ -z "$output" ]; then |
|
|
|
[ -z "$output" ] && { |
|
|
|
error "in section '$s' option output is missing" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
local input_arg |
|
|
|
if [ "x$input" = 'xuvc' ]; then |
|
|
|
[ "x$input" = 'xuvc' ] && { |
|
|
|
input_arg="input_uvc.so" |
|
|
|
|
|
|
|
local device |
|
|
|
config_get device "$s" 'device' |
|
|
|
if [ ! -c "$device" ]; then |
|
|
|
[ -c "$device" ] || { |
|
|
|
error "device '$device' does not exist" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
input_arg="${input_arg} --device $device" |
|
|
|
|
|
|
|
local fps |
|
|
|
config_get fps "$s" 'fps' |
|
|
|
[ -n "$fps" ] && input_arg="${input_arg} --fps $fps" |
|
|
|
|
|
|
|
local yuv |
|
|
|
config_get_bool yuv "$s" 'yuv' 0 |
|
|
|
if [ $yuv -ne 0 ]; then |
|
|
|
[ "$yuv" -ne 0 ] && { |
|
|
|
input_arg="${input_arg} --yuv" |
|
|
|
local quality |
|
|
|
config_get quality "$s" 'quality' |
|
|
|
[ -n "$quality" ] && input_arg="${input_arg} --quality $quality" |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
local resolution |
|
|
|
config_get resolution "$s" 'resolution' |
|
|
|
[ -n "$resolution" ] && input_arg="${input_arg} --resolution $resolution" |
|
|
|
|
|
|
|
local led |
|
|
|
config_get led "$s" 'led' |
|
|
|
[ -n "$led" ] && input_arg="${input_arg} --led $led" |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
if [ -z "$input_arg" ]; then |
|
|
|
[ -z "$input_arg" ] && { |
|
|
|
error "unsuported input option '$input' in section '$s'" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
local output_arg |
|
|
|
if [ "x$output" = 'xhttp' ]; then |
|
|
|
[ "x$output" = 'xhttp' ] && { |
|
|
|
output_arg="output_http.so" |
|
|
|
|
|
|
|
local port |
|
|
|
config_get port "$s" 'port' |
|
|
|
[ -n "$port" ] && output_arg="${output_arg} --port $port" |
|
|
|
|
|
|
|
local listen_ip |
|
|
|
config_get listen_ip "$s" 'listen_ip' |
|
|
|
[ -n "$listen_ip" ] && output_arg="${output_arg} --listen $listen_ip" |
|
|
|
|
|
|
|
local www |
|
|
|
config_get www "$s" 'www' |
|
|
|
[ -n "$www" ] && output_arg="${output_arg} --www $www" |
|
|
|
|
|
|
|
local username |
|
|
|
config_get username "$s" 'username' |
|
|
|
local password |
|
|
|
config_get password "$s" 'password' |
|
|
|
[ -n "$username" ] && [ -n "$password" ] && output_arg="${output_arg} --credentials $username:$password" |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
if [ "x$output" = 'xfile' ]; then |
|
|
|
[ "x$output" = 'xfile' ] && { |
|
|
|
output_arg="output_file.so" |
|
|
|
|
|
|
|
local folder |
|
|
|
config_get folder "$s" 'folder' |
|
|
|
[ -n "$folder" ] && output_arg="${output_arg} --folder $folder" |
|
|
|
|
|
|
|
local delay |
|
|
|
config_get delay "$s" 'delay' |
|
|
|
[ -n "$delay" ] && output_arg="${output_arg} --delay $delay" |
|
|
|
|
|
|
|
local link |
|
|
|
config_get link "$s" 'link' |
|
|
|
[ -n "$link" ] && output_arg="${output_arg} --link $link" |
|
|
|
|
|
|
|
local ringbuffer |
|
|
|
config_get ringbuffer "$s" 'ringbuffer' |
|
|
|
[ -n "$ringbuffer" ] && output_arg="${output_arg} --size $ringbuffer" |
|
|
|
|
|
|
|
local exceed |
|
|
|
config_get exceed "$s" 'exceed' |
|
|
|
[ -n "$exceed" ] && output_arg="${output_arg} --exceed $exceed" |
|
|
|
|
|
|
|
local command |
|
|
|
config_get command "$s" 'command' |
|
|
|
[ -n "$command" ] && output_arg="${output_arg} --command $command" |
|
|
|
|
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
if [ -z "$output_arg" ]; then |
|
|
|
[ -z "$output_arg" ] && { |
|
|
|
error "unsuported output option '$output' in section '$s'" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
procd_open_instance |
|
|
|
procd_set_param command "$PROG" --input "$input_arg" --output "$output_arg" |
|
|
|