Skip to content

Commit

Permalink
Revert accidental changes by the autoformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
attilabody committed Jan 30, 2025
1 parent b901484 commit ead17ea
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 135 deletions.
67 changes: 34 additions & 33 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ if [[ -z "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" ]]; then
CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="master"
fi


# Paths of repos
ALL_PATHS=(
"${BASE_CN_BIN_PATH}"/"${USTREAMER_PATH}"
Expand All @@ -67,7 +68,7 @@ show_help() {
### Check if device is Raspberry Pi
is_raspberry_pi() {
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry" /proc/device-tree/model; then
grep -q "Raspberry" /proc/device-tree/model; then
echo "1"
else
echo "0"
Expand All @@ -76,13 +77,13 @@ is_raspberry_pi() {

is_bookworm() {
if [[ -f /etc/os-release ]]; then
grep -cq "bookworm" /etc/os-release &>/dev/null && echo "1" || echo "0"
grep -cq "bookworm" /etc/os-release &> /dev/null && echo "1" || echo "0"
fi
}

is_pi5() {
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry Pi 5" /proc/device-tree/model; then
grep -q "Raspberry Pi 5" /proc/device-tree/model; then
echo "1"
else
echo "0"
Expand All @@ -91,7 +92,7 @@ is_pi5() {

is_ubuntu_arm() {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
grep -q "ubuntu" /etc/os-release; then
grep -q "ubuntu" /etc/os-release; then
echo "1"
else
echo "0"
Expand Down Expand Up @@ -142,10 +143,10 @@ clone_cstreamer() {
## Special handling because only supported on Raspberry Pi
[[ -n "${CROWSNEST_UNATTENDED}" ]] || CROWSNEST_UNATTENDED="0"
if { [[ "$(is_raspberry_pi)" = "0" ]] ||
[[ "$(is_pi5)" = "1" ]] ||
[[ "$(is_ubuntu_arm)" = "1" ]] ||
[[ "$(is_armbian)" = "1" ]]; } &&
[[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then
[[ "$(is_pi5)" = "1" ]] ||
[[ "$(is_ubuntu_arm)" = "1" ]] ||
[[ "$(is_armbian)" = "1" ]]; } &&
[[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then
printf "Device is not supported! Cloning camera-streamer ... [SKIPPED]\n"
return
fi
Expand Down Expand Up @@ -178,11 +179,11 @@ clean_apps() {
for app in "${ALL_PATHS[@]}"; do
if [[ ! -d "${app}" ]]; then
printf "'%s' does not exist! Clean ... [SKIPPED]\n" "${app}"
else
else
printf "\nRunning 'make clean' in %s ... \n" "${app}"
pushd "${app}" &>/dev/null || exit 1
pushd "${app}" &> /dev/null || exit 1
make clean
popd &>/dev/null || exit 1
popd &> /dev/null || exit 1
fi
done
printf "\nRunning 'make clean' ... [DONE]\n"
Expand All @@ -204,9 +205,9 @@ build_apps() {
fi
if [[ -d "${path}" ]]; then
printf "Build '%s' using ${USE_PROCS##-j} Cores ... \n" "${path##*/}"
pushd "${path}" &>/dev/null || exit 1
pushd "${path}" &> /dev/null || exit 1
make "${USE_PROCS}"
popd &>/dev/null || exit 1
popd &> /dev/null || exit 1
printf "Build '%s' ... [SUCCESS]\n" "${path##*/}"
fi
done
Expand All @@ -229,31 +230,31 @@ main() {
## Get opts
while true; do
case "${1}" in
-b | --build)
build_apps
break
-b|--build)
build_apps
break
;;
-c | --clean)
clean_apps
break
-c|--clean)
clean_apps
break
;;
-d | --delete)
delete_apps
break
-d|--delete)
delete_apps
break
;;
-h | --help)
show_help
break
-h|--help)
show_help
break
;;
-r | --reclone)
delete_apps
clone_apps
break
-r|--reclone)
delete_apps
clone_apps
break
;;
*)
printf "Unknown option: %s" "${1}"
show_help
break
*)
printf "Unknown option: %s" "${1}"
show_help
break
;;
esac
done
Expand Down
10 changes: 5 additions & 5 deletions libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ set -Ee

## Version of crowsnest
function self_version {
pushd "${BASE_CN_PATH}" &>/dev/null
pushd "${BASE_CN_PATH}" &> /dev/null
git describe --always --tags
popd &>/dev/null
popd &> /dev/null
}

# Init Traps
Expand Down Expand Up @@ -96,9 +96,9 @@ function check_apps {

## Avoid dependency check if non rpi sbc
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ "$(is_ubuntu_arm)" = "0" ]] &&
[[ "$(is_armbian)" = "0" ]] &&
[[ "$(is_pi5)" = "0" ]]; then
[[ "$(is_ubuntu_arm)" = "0" ]] &&
[[ "$(is_armbian)" = "0" ]] &&
[[ "$(is_pi5)" = "0" ]]; then
if [[ -x "${BASE_CN_PATH}/${cstreamer}" ]]; then
log_msg "Dependency: '${cstreamer##*/}' found in ${cstreamer}."
else
Expand Down
48 changes: 24 additions & 24 deletions libs/hwhandler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -Ee
### Detect Hardware
detect_avail_cams() {
local avail realpath
avail="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null)"
avail="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null)"
count="$(echo "${avail}" | wc -l)"
if [[ -d "/dev/v4l/by-id/" ]] && [[ -n "${avail}" ]]; then
log_msg "INFO: Found ${count} available v4l2 (UVC) camera(s)"
Expand All @@ -43,7 +43,7 @@ list_cam_formats() {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "Supported Formats:"
while read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(v4l2-ctl -d "${device}" --list-formats-ext | sed '1,3d')
}

Expand All @@ -53,15 +53,15 @@ list_cam_v4l2ctrls() {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "Supported Controls:"
while read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(v4l2-ctl -d "${device}" --list-ctrls-menus)
}

## Determine connected libcamera (CSI) device
detect_libcamera() {
local avail
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
[[ -x "$(command -v libcamera-hello)" ]]; then
avail="$(libcamera-hello --list-cameras | grep -c "Available" || echo "0")"
if [[ "${avail}" = "1" ]]; then
get_libcamera_path | wc -l
Expand All @@ -76,9 +76,9 @@ detect_libcamera() {
## Spit /base/soc path for libcamera device
get_libcamera_path() {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ -x "$(command -v libcamera-hello)" ]]; then
libcamera-hello --list-cameras | sed '1,2d' |
grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)'
[[ -x "$(command -v libcamera-hello)" ]]; then
libcamera-hello --list-cameras | sed '1,2d' \
| grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)'
fi
}

Expand All @@ -88,22 +88,22 @@ list_picam_resolution() {
prefix="$(date +'[%D %T]') crowsnest:"
log_msg "'libcamera' device(s) resolution(s) :"
while IFS= read -r i; do
printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}"
printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}"
done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/')
}

get_libcamera_controls() {
local ust_bin flags
flags=(--camera-type=libcamera --camera-list_options)
flags=( --camera-type=libcamera --camera-list_options )
ust_bin="${BASE_CN_PATH}/bin/camera-streamer/camera-streamer"
if [[ -x "${ust_bin}" ]]; then
"${ust_bin}" "${flags[@]}" --camera-path="$(get_libcamera_path)" 2>/dev/null |
sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' |
sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' |
sed 's/- available option: //g' | sed '/^$/d;' |
sed 's/([0-9]*[a-z,0-9]\, /(/g' | sed '/type=7/d;/type=4/d;/type=Rectangle/d' |
sed 's/type=1/bool/g;s/type=3/int/g;s/type=5/float/g' | sed 's/type=//g;' |
sed 's/\[/min=/g;s/\.\./ max=/g;s/\]$//g'
"${ust_bin}" "${flags[@]}" --camera-path="$(get_libcamera_path)" 2> /dev/null | \
sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \
sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' | \
sed 's/- available option: //g' | sed '/^$/d;' | \
sed 's/([0-9]*[a-z,0-9]\, /(/g' | sed '/type=7/d;/type=4/d;/type=Rectangle/d' | \
sed 's/type=1/bool/g;s/type=3/int/g;s/type=5/float/g' | sed 's/type=//g;' | \
sed 's/\[/min=/g;s/\.\./ max=/g;s/\]$//g'
else
log_msg "WARN: 'libcamera' device option can not be displayed, because"
log_msg "WARN: camera-streamer is not installed"
Expand All @@ -127,17 +127,17 @@ list_picam_controls() {
function detect_legacy {
local avail
if [[ "$(is_raspberry_pi)" = "1" ]] &&
command -v vcgencmd &>/dev/null; then
if vcgencmd get_camera &>/dev/null; then
avail="$(vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)"
command -v vcgencmd &> /dev/null; then
if vcgencmd get_camera &> /dev/null; then
avail="$( vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)"
fi
fi
echo "${avail:-0}"
}

function dev_is_legacy {
v4l2-ctl --list-devices | grep -A1 -e 'mmal' |
awk 'NR==2 {print $1}'
v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
awk 'NR==2 {print $1}'
}

## Determine if cam has H.264 Hardware encoder
Expand All @@ -161,7 +161,7 @@ detect_mjpeg() {
## Check if device is raspberry sbc
is_raspberry_pi() {
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry" /proc/device-tree/model; then
grep -q "Raspberry" /proc/device-tree/model; then
echo "1"
else
echo "0"
Expand All @@ -170,7 +170,7 @@ is_raspberry_pi() {

is_pi5() {
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry Pi 5" /proc/device-tree/model; then
grep -q "Raspberry Pi 5" /proc/device-tree/model; then
echo "1"
else
echo "0"
Expand All @@ -179,7 +179,7 @@ is_pi5() {

is_ubuntu_arm() {
if [[ "$(is_raspberry_pi)" = "1" ]] &&
grep -q "ubuntu" /etc/os-release; then
grep -q "ubuntu" /etc/os-release; then
echo "1"
else
echo "0"
Expand Down
30 changes: 14 additions & 16 deletions libs/init_stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ function construct_streamer {
mode="$(get_param "cam ${cams}" mode)"
check_section "${cams}"
case ${mode} in
[mM]ulti | camera-streamer)
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[mM]ulti | camera-streamer)
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ "$(is_ubuntu_arm)" = "0" ]] &&
[[ "$(is_armbian)" = "0" ]] &&
[[ "$(is_pi5)" = "0" ]]; then
MULTI_INSTANCES+=("${cams}")
else
log_msg "WARN: Mode 'camera-streamer' is not supported on your device!"
log_msg "WARN: Falling back to Mode 'ustreamer'"
MJPG_INSTANCES+=("${cams}")
fi
MULTI_INSTANCES+=( "${cams}" )
else
log_msg "WARN: Mode 'camera-streamer' is not supported on your device!"
log_msg "WARN: Falling back to Mode 'ustreamer'"
MJPG_INSTANCES+=( "${cams}" )
fi
;;
mjpg | mjpeg | ustreamer)
MJPG_INSTANCES+=("${cams}")
mjpg | mjpeg | ustreamer)
MJPG_INSTANCES+=( "${cams}" )
;;
? | *)
unknown_mode_msg
MJPG_INSTANCES+=("${cams}")
?|*)
unknown_mode_msg
MJPG_INSTANCES+=( "${cams}" )

;;
esac
Expand All @@ -54,8 +54,6 @@ function construct_streamer {
if [ "${#MJPG_INSTANCES[@]}" != "0" ]; then
run_mjpg "${MJPG_INSTANCES[*]}"
fi
sleep 2 &
sleep_pid="$!"
wait "${sleep_pid}"
sleep 2 & sleep_pid="$!" ; wait "${sleep_pid}"
log_msg " ... Done!"
}
47 changes: 24 additions & 23 deletions libs/versioncontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,36 @@ versioncontrol() {

get_ustreamer_version() {
local cur_ver avail_ver
pushd "${BASE_CN_PATH}"/bin/ustreamer &>/dev/null || exit 1
avail_ver="$(git describe --tags --always)"
cur_ver="v$(${UST_BIN} -v)"
if [[ "${cur_ver}" == "${avail_ver}" ]]; then
vc_log_msg "ustreamer is up to date. (${cur_ver})"
fi
if [[ "${cur_ver}" != "${avail_ver}" ]]; then
vc_log_msg "ustreamer new version available: ${avail_ver} (${cur_ver})."
fi
popd &>/dev/null || exit 1
pushd "${BASE_CN_PATH}"/bin/ustreamer &> /dev/null || exit 1
avail_ver="$(git describe --tags --always)"
cur_ver="v$(${UST_BIN} -v)"
if [[ "${cur_ver}" == "${avail_ver}" ]]; then
vc_log_msg "ustreamer is up to date. (${cur_ver})"
fi
if [[ "${cur_ver}" != "${avail_ver}" ]]; then
vc_log_msg "ustreamer new version available: ${avail_ver} (${cur_ver})."
fi
popd &> /dev/null || exit 1
}


# Camera Streamer has no version Output yet
get_ayucamstream_version() {
local cur_ver avail_ver
if [[ "$(is_raspberry_pi)" = "1" ]] &&
[[ "$(is_ubuntu_arm)" = "0" ]] &&
[[ "$(is_armbian)" = "0" ]] &&
[[ "$(is_pi5)" = "0" ]]; then
pushd "${BASE_CN_PATH}"/bin/camera-streamer &>/dev/null || exit 1
avail_ver="($(git describe --tags --always))"
cur_ver="$("${PWD}"/camera-streamer --version | tr -d " ")"
if [ "${cur_ver}" == "${avail_ver}" ]; then
vc_log_msg "camera-streamer is up to date. (${cur_ver})"
fi
if [ "${cur_ver}" != "${avail_ver}" ]; then
vc_log_msg "camera-streamer new version available: ${avail_ver} (${cur_ver})."
fi
popd &>/dev/null || exit 1
[[ "$(is_ubuntu_arm)" = "0" ]] &&
[[ "$(is_armbian)" = "0" ]] &&
[[ "$(is_pi5)" = "0" ]]; then
pushd "${BASE_CN_PATH}"/bin/camera-streamer &> /dev/null || exit 1
avail_ver="($(git describe --tags --always))"
cur_ver="$("${PWD}"/camera-streamer --version | tr -d " ")"
if [ "${cur_ver}" == "${avail_ver}" ]; then
vc_log_msg "camera-streamer is up to date. (${cur_ver})"
fi
if [ "${cur_ver}" != "${avail_ver}" ]; then
vc_log_msg "camera-streamer new version available: ${avail_ver} (${cur_ver})."
fi
popd &> /dev/null || exit 1
fi
}

Expand Down
Loading

0 comments on commit ead17ea

Please sign in to comment.