Moved construct_streamer function

* Moved function to init_streams.sh

* Prepared v4l2-ctl device control feature

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2021-12-09 19:55:30 +01:00
parent 490f3f2842
commit 2a2bff5b31
No known key found for this signature in database
GPG Key ID: F465B83ACBA45639
3 changed files with 56 additions and 23 deletions

38
libs/init_stream.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
#### Init Stream library
#### webcamd - A webcam Service for multiple Cams and Stream Services.
####
#### written by Stephan Wendel aka KwadFan
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# Exit upon Errors
set -e
## Start Stream Service
# sleep to prevent cpu cycle spikes
function construct_streamer {
local stream_server cams
cams=($(configured_cams))
log_msg "Try to start configured Cams / Services..."
for (( i=0; i<"${#cams[@]}"; i++ )); do
stream_server="$(get_param "cam ${cams[$i]}" streamer 2> /dev/null)"
if [ "${stream_server}" == "ustreamer" ]; then
run_ustreamer "${cams[$i]}" &
sleep 8 & sleep_pid="$!"
wait "${sleep_pid}"
elif [ "${stream_server}" == "rtsp" ]; then
run_rtsp "${cams[$i]}" &
sleep 8 & sleep_pid="$!"
wait "${sleep_pid}"
else
log_msg "ERROR: Missing 'streamer' parameter in [cam ${cams[$i]}]. Skipping."
fi
done
log_msg "... Done!"
}

16
libs/v4l2_control.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#### Init Stream library
#### webcamd - A webcam Service for multiple Cams and Stream Services.
####
#### written by Stephan Wendel aka KwadFan
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# Exit upon Errors
set -e

25
webcamd
View File

@ -28,29 +28,8 @@ source "${BASE_CN_PATH}/libs/hwhandler.sh"
source "${BASE_CN_PATH}/libs/logging.sh"
source "${BASE_CN_PATH}/libs/messages.sh"
source "${BASE_CN_PATH}/libs/watchdog.sh"
## Start Stream Service
# sleep to prevent cpu cycle spikes
function construct_streamer {
local stream_server cams
cams=($(configured_cams))
log_msg "Try to start configured Cams / Services..."
for (( i=0; i<"${#cams[@]}"; i++ )); do
stream_server="$(get_param "cam ${cams[$i]}" streamer 2> /dev/null)"
if [ "${stream_server}" == "ustreamer" ]; then
run_ustreamer "${cams[$i]}" &
sleep 8 & sleep_pid="$!"
wait "${sleep_pid}"
elif [ "${stream_server}" == "rtsp" ]; then
run_rtsp "${cams[$i]}" &
sleep 8 & sleep_pid="$!"
wait "${sleep_pid}"
else
log_msg "ERROR: Missing 'streamer' parameter in [cam ${cams[$i]}]. Skipping."
fi
done
log_msg "... Done!"
}
source "${BASE_CN_PATH}/libs/init_stream.sh"
# source "${BASE_CN_PATH}/libs/v4l2_control.sh"
function run_ustreamer {
local cam_section ustreamer_bin device port resolution fps custom