From 43a1ee3bc017f465d4ec24ce5a37d93a4f7a8f5c Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Tue, 28 Nov 2023 22:21:05 +0100 Subject: [PATCH 1/7] fix(build.sh): fix wrong cs branch for cloning (#215) Signed-off-by: Patrick Gehrsitz --- bin/build.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/build.sh b/bin/build.sh index b4ee2cc4..b386d894 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -73,6 +73,12 @@ is_raspberry_pi() { fi } +is_bookworm() { + if [[ -f /etc/os-release ]]; then + grep -cq "bookworm" /etc/os-release &> /dev/null && echo "1" || echo "0" + fi +} + ### Get avail mem get_avail_mem() { grep "MemTotal" /proc/meminfo | awk '{print $2}' @@ -116,6 +122,11 @@ clone_cstreamer() { printf "%s already exist ... [SKIPPED]\n" "${CSTREAMER_PATH}" return fi + if [[ "$(is_bookworm)" = "1" ]]; then + printf "\nBookworm detected!\n" + printf "Using main branch of camera-streamer for Bookworm ...\n\n" + CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="main" + fi git clone "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" \ -b "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" \ "${BASE_CN_BIN_PATH}"/"${CSTREAMER_PATH}" \ From 61421f514821f948924883fd894726c1a495ff0f Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Thu, 14 Dec 2023 23:54:46 +0100 Subject: [PATCH 2/7] fix: fixes error in detect_legacy (#217) This will fix issue on Raspberry Pi5, which doesnt generate cam list, because 'vcgencmd get_camera' exits with an error. If all conditions fail it will always return '0' Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 63b6710d..7ee45d1a 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -86,13 +86,16 @@ get_libcamera_path() { # Determine connected "legacy" device function detect_legacy { local avail - if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry" /proc/device-tree/model; then - avail="$(vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)" - else - avail="0" + 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 \ + )" + fi fi - echo "${avail}" + echo "${avail:-0}" } function dev_is_legacy { From 4feaab72497519d6ffdf2f31005787e124bd74d4 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Sun, 7 Jan 2024 17:27:53 +0100 Subject: [PATCH 3/7] fix: skip do_memory_split on bookworm (#223) `do_memory_split` got removed on bookworm. Fixes #219 --- tools/libs/set_gpumem.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/libs/set_gpumem.sh b/tools/libs/set_gpumem.sh index ab183e0f..bf20311f 100755 --- a/tools/libs/set_gpumem.sh +++ b/tools/libs/set_gpumem.sh @@ -34,7 +34,9 @@ set_gpu_mem() { else mem_split=256 fi - if [[ "$(is_raspbian)" = "1" ]] && [[ -n "$(command -v raspi-config)" ]]; then + if [[ "$(is_raspbian)" = "1" ]] && + [[ "$(is_bookworm)" = "0" ]] && + [[ -n "$(command -v raspi-config)" ]]; then if sudo raspi-config nonint do_memory_split "${mem_split}" ;then status_msg "Trying to set minimum GPU Memory to ${mem_split} MB ..." "0" else From fd22d11d9b920c90203be70e983543663fd8a2d3 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Sun, 7 Jan 2024 17:29:33 +0100 Subject: [PATCH 4/7] fix: fix crash with brokenfocus and camera-streamer (#224) If one cam with `ustreamer` is defined it will run `brokenfocus` for every cam defined. This will lead to a crash with `brokenfocus` devices with mode `camera-streamer`. This PR fixes this issue and will only run `brokenfocus` for devices with mode `ustreamer`. --- libs/ustreamer.sh | 2 +- libs/v4l2_control.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/ustreamer.sh b/libs/ustreamer.sh index 3f588eec..e4c7c451 100755 --- a/libs/ustreamer.sh +++ b/libs/ustreamer.sh @@ -24,7 +24,7 @@ run_mjpg() { run_ustreamer "${instance}" & done blockyfix - brokenfocus + brokenfocus "${cams}" return } diff --git a/libs/v4l2_control.sh b/libs/v4l2_control.sh index d7630219..167fc3a4 100755 --- a/libs/v4l2_control.sh +++ b/libs/v4l2_control.sh @@ -116,7 +116,7 @@ function brokenfocus { function main { local cur_val conf_val device - for cam in $(configured_cams); do + for cam in ${1}; do device="$(get_param "cam ${cam}" device)" cur_val="$(get_current_value "${device}")" conf_val="$(get_conf_value "${cam}")" @@ -133,7 +133,7 @@ function brokenfocus { } ### MAIN -main +main "${1}" } From 0b4cf6f0a141c655af8dc08fff796ba5b31d6046 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Sun, 7 Jan 2024 17:30:12 +0100 Subject: [PATCH 5/7] chore: shallow clone camera-streamer submodules (#226) This reduces the download size and disk usage for `camera-streamer`. --- bin/build.sh | 2 +- tools/libs/build_apps.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index b386d894..4093d454 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -130,7 +130,7 @@ clone_cstreamer() { git clone "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" \ -b "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" \ "${BASE_CN_BIN_PATH}"/"${CSTREAMER_PATH}" \ - "${CLONE_FLAGS[@]}" --recursive + "${CLONE_FLAGS[@]}" --recurse-submodules --shallow-submodules } ### Clone Apps diff --git a/tools/libs/build_apps.sh b/tools/libs/build_apps.sh index 6575b4b8..2ed84f24 100755 --- a/tools/libs/build_apps.sh +++ b/tools/libs/build_apps.sh @@ -36,7 +36,8 @@ clone_cstreamer() { rm -rf bin/camera-streamer fi sudo -u "${BASE_USER}" \ - git clone "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" --recursive \ + git clone "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" \ + --recurse-submodules --shallow-submodules \ -b "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" \ --depth=1 --single-branch bin/camera-streamer } From aa97f12a5d84f6808695cad00f749bef5773a9a4 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Sun, 7 Jan 2024 17:57:56 +0100 Subject: [PATCH 6/7] fix: add pi5 support (#225) Signed-off-by: Patrick Gehrsitz --- README.md | 1 + bin/build.sh | 23 ++++++++++++++++++++++- libs/core.sh | 4 +++- libs/hwhandler.sh | 9 +++++++++ libs/init_stream.sh | 4 +++- libs/versioncontrol.sh | 4 +++- tools/libs/core.sh | 17 +++++++++++++++++ 7 files changed, 58 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 18d3af21..a280f44f 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ See the [README.md](https://github.com/mainsail-crew/crowsnest/tree/legacy/v3) o #### Hint Bookworm Raspberry Pi OS images that are based on Debian 12 (codename 'bookworm') currently use a different branch of [camera-streamer](https://github.com/ayufan/camera-streamer)! +The Raspberry Pi 5 has only [ustreamer](https://github.com/pikvm/ustreamer) support! This is due to the missing JPEG and H264 Hardware encoders. --- diff --git a/bin/build.sh b/bin/build.sh index 4093d454..6c03f292 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -79,6 +79,24 @@ is_bookworm() { fi } +is_pi5() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry Pi 5" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + +is_ubuntu_arm() { + if [[ "$(is_raspberry_pi)" = "1" ]] && + grep -q "ubuntu" /etc/os-release; then + echo "1" + else + echo "0" + fi +} + ### Get avail mem get_avail_mem() { grep "MemTotal" /proc/meminfo | awk '{print $2}' @@ -114,7 +132,10 @@ clone_ustreamer() { clone_cstreamer() { ## Special handling because only supported on Raspberry Pi [[ -n "${CROWSNEST_UNATTENDED}" ]] || CROWSNEST_UNATTENDED="0" - if [[ "$(is_raspberry_pi)" = "0" ]] && [[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then + if { [[ "$(is_raspberry_pi)" = "0" ]] || + [[ "$(is_pi5)" = "1" ]] || + [[ "$(is_ubuntu_arm)" = "1" ]]; } && + [[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then printf "WARN: Cloning camera-streamer skipped! Device is not supported!" return fi diff --git a/libs/core.sh b/libs/core.sh index 0f1a904c..aab784df 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -93,7 +93,9 @@ function check_apps { fi ## Avoid dependency check if non rpi sbc - if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then + if [[ "$(is_raspberry_pi)" = "1" ]] && + [[ "$(is_ubuntu_arm)" = "0" ]] && + [[ "$(is_pi5)" = "0" ]]; then if [[ -x "${BASE_CN_PATH}/${cstreamer}" ]]; then log_msg "Dependency: '${cstreamer##*/}' found in ${cstreamer}." else diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 7ee45d1a..2e1fd075 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -131,6 +131,15 @@ is_raspberry_pi() { fi } +is_pi5() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry Pi 5" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && grep -q "ubuntu" /etc/os-release; then diff --git a/libs/init_stream.sh b/libs/init_stream.sh index 4b6dce64..2884c698 100755 --- a/libs/init_stream.sh +++ b/libs/init_stream.sh @@ -27,7 +27,9 @@ function construct_streamer { check_section "${cams}" case ${mode} in [mM]ulti | camera-streamer) - if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then + if [[ "$(is_raspberry_pi)" = "1" ]] && + [[ "$(is_ubuntu_arm)" = "0" ]] && + [[ "$(is_pi5)" = "0" ]]; then MULTI_INSTANCES+=( "${cams}" ) else log_msg "WARN: Mode 'camera-streamer' is not supported on your device!" diff --git a/libs/versioncontrol.sh b/libs/versioncontrol.sh index 806bf120..2c7b1850 100644 --- a/libs/versioncontrol.sh +++ b/libs/versioncontrol.sh @@ -42,7 +42,9 @@ versioncontrol() { # Camera Streamer has no version Output yet get_ayucamstream_version() { local cur_ver avail_ver - if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then + if [[ "$(is_raspberry_pi)" = "1" ]] && + [[ "$(is_ubuntu_arm)" = "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 " ")" diff --git a/tools/libs/core.sh b/tools/libs/core.sh index a72bb4a4..3fe80165 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -67,6 +67,15 @@ is_raspberry_pi() { fi } +is_pi5() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry Pi 5" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && grep -q "ubuntu" /etc/os-release; then @@ -104,6 +113,14 @@ shallow_cs_dependencies_check() { fi status_msg "Checking if device is a Raspberry Pi ..." "0" + msg "Checking if device is not a Raspberry Pi 5 ...\n" + if [[ "$(is_pi5)" = "1" ]]; then + status_msg "Checking if device is not a Raspberry Pi 5 ..." "3" + msg "This device is a Raspberry Pi 5 therefore camera-streeamer cannot be installed ..." + return 1 + fi + status_msg "Checking if device is not a Raspberry Pi 5 ..." "0" + msg "Checking if device is not running Ubuntu ...\n" if [[ "$(is_ubuntu_arm)" = "1" ]]; then status_msg "Checking if device is not running Ubuntu ..." "3" From fcd12d323c8c2b669248cf3ad53ea8f615fc1fbf Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Mon, 8 Jan 2024 22:10:49 +0100 Subject: [PATCH 7/7] chore: add note about proxies to crowsnest.conf (#227) Signed-off-by: Patrick Gehrsitz --- resources/crowsnest.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/crowsnest.conf b/resources/crowsnest.conf index 4a1f2446..ecb841d8 100644 --- a/resources/crowsnest.conf +++ b/resources/crowsnest.conf @@ -17,6 +17,11 @@ #### Port 8082 equals /webcam3/?action=[stream/snapshot] ##### #### Port 8083 equals /webcam4/?action=[stream/snapshot] ##### #### ##### +#### Note: These ports are default for most Mainsail ##### +#### installations. To use any other port would involve ##### +#### changing the proxy configuration or using directly ##### +#### http://:/?action=[stream/snapshot] ##### +#### ##### ##################################################################### #### RTSP Stream URL: ( if enabled and supported ) ##### #### rtsp://:/stream.h264 #####