Skip to content

Commit

Permalink
[Automated] Merged develop into target master
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Jan 8, 2024
2 parents f7ac6aa + fcd12d3 commit 6659f30
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
36 changes: 34 additions & 2 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@ 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
}

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}'
Expand Down Expand Up @@ -108,18 +132,26 @@ 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
if [[ -d "${BASE_CN_BIN_PATH}"/"${CSTREAMER_PATH}" ]]; then
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}" \
"${CLONE_FLAGS[@]}" --recursive
"${CLONE_FLAGS[@]}" --recurse-submodules --shallow-submodules
}

### Clone Apps
Expand Down
4 changes: 3 additions & 1 deletion libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 18 additions & 6 deletions libs/hwhandler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -128,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
Expand Down
4 changes: 3 additions & 1 deletion libs/init_stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
2 changes: 1 addition & 1 deletion libs/ustreamer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ run_mjpg() {
run_ustreamer "${instance}" &
done
blockyfix
brokenfocus
brokenfocus "${cams}"
return
}

Expand Down
4 changes: 2 additions & 2 deletions libs/v4l2_control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}")"
Expand All @@ -133,7 +133,7 @@ function brokenfocus {
}

### MAIN
main
main "${1}"

}

Expand Down
4 changes: 3 additions & 1 deletion libs/versioncontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 " ")"
Expand Down
5 changes: 5 additions & 0 deletions resources/crowsnest.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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://<ip>:<port>/?action=[stream/snapshot] #####
#### #####
#####################################################################
#### RTSP Stream URL: ( if enabled and supported ) #####
#### rtsp://<ip>:<rtsp_port>/stream.h264 #####
Expand Down
3 changes: 2 additions & 1 deletion tools/libs/build_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
17 changes: 17 additions & 0 deletions tools/libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion tools/libs/set_gpumem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6659f30

Please sign in to comment.