diff --git a/bin/build.sh b/bin/build.sh index 5e8ed519..992d2f21 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -32,10 +32,10 @@ CLONE_FLAGS=(--depth=1 --single-branch) # Ustreamer repo USTREAMER_PATH="ustreamer" if [[ -z "${CROWSNEST_USTREAMER_REPO_SHIP}" ]]; then - CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/mryel00/ustreamer.git" + CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git" fi if [[ -z "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]]; then - CROWSNEST_USTREAMER_REPO_BRANCH="master" + CROWSNEST_USTREAMER_REPO_BRANCH="v6.10" fi # Camera-streamer repo diff --git a/libs/core.sh b/libs/core.sh index d37e2b73..59581de7 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -82,18 +82,15 @@ function check_dep { function check_apps { local cstreamer ustreamer - ustreamer_base="bin/ustreamer" - ustreamer="$(find "${BASE_CN_PATH}"/"${ustreamer_base}" \ - -iname 'ustreamer.bin' 2> /dev/null | sed '1q')" + ustreamer="bin/ustreamer/src/ustreamer.bin" cstreamer="bin/camera-streamer/camera-streamer" - - if [[ -x "${ustreamer}" ]]; then - log_msg "Dependency: '${ustreamer##*/}' found in ${ustreamer_base}/${ustreamer##*/}." - UST_BIN="${ustreamer}" + if [[ -x "${BASE_CN_PATH}/${ustreamer}" ]]; then + log_msg "Dependency: 'ustreamer' found in ${ustreamer}." + UST_BIN="${BASE_CN_PATH}/${ustreamer}" # shellcheck disable=SC2034 declare -r UST_BIN else - log_msg "Dependency: '${ustreamer##*/}' not found. Exiting!" + log_msg "Dependency: 'ustreamer' not found. Exiting!" exit 1 fi diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index ceb5bd72..515b2b6b 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -21,8 +21,7 @@ detect_avail_cams() { local avail realpath 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 + if [[ -d "/dev/v4l/by-id/" ]] && [[ -n "${avail}" ]]; then log_msg "INFO: Found ${count} available v4l2 (UVC) camera(s)" echo "${avail}" | while read -r v4l; do realpath=$(readlink -e "${v4l}") @@ -63,8 +62,8 @@ detect_libcamera() { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && [[ -x "$(command -v libcamera-hello)" ]]; then - avail="$(libcamera-hello --list-cameras | sed '/^\[.*\].*/d' | awk 'NR==1 {print $1}')" - if [[ "${avail}" = "Available" ]]; then + avail="$(libcamera-hello --list-cameras | grep -c "Available")" + if [[ "${avail}" = "1" ]]; then get_libcamera_path | wc -l else echo "0" @@ -83,23 +82,61 @@ get_libcamera_path() { fi } +# print libcamera resolutions +list_picam_resolution() { + local prefix + prefix="$(date +'[%D %T]') crowsnest:" + log_msg "'libcamera' device(s) resolution(s) :" + while read -r i; do + 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 ) + 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' | \ + sed 's/type=1/ (bool/g;s/type=3/ (int/g;s/type=5/ (float/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" + fi +} + +list_picam_controls() { + local prefix + prefix="$(date +'[%D %T]') crowsnest:" + log_msg "'libcamera' device controls :" + while read -r i; do + if [[ ! "${i}" =~ "INFO" ]]; then + printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + fi + done < <(get_libcamera_controls) + # blank line workaround + log_msg "" +} + # Determine connected "legacy" device 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 \ - )" + 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' | \ + v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ awk 'NR==2 {print $1}' } diff --git a/libs/logging.sh b/libs/logging.sh index aef72e09..bb40a8e8 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -108,9 +108,13 @@ function print_cams { for device in $(get_libcamera_path); do log_msg "Detected 'libcamera' device -> ${device}" done + if [[ "$(is_pi5)" = "0" ]]; then + list_picam_resolution + list_picam_controls + fi fi if [[ "${legacy}" -ne 0 ]]; then - raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ + raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ awk 'NR==2 {print $1}')" log_msg "Detected 'Raspicam' Device -> ${raspicam}" if [[ ! "${CROWSNEST_LOG_LEVEL}" = "quiet" ]]; then diff --git a/tools/configure.sh b/tools/configure.sh index 8c3d9579..11c82467 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -26,8 +26,8 @@ CN_CONFIG_CONFIGPATH="${CN_CONFIG_ROOTPATH}/config" CN_CONFIG_LOGPATH="${CN_CONFIG_ROOTPATH}/logs" CN_CONFIG_ENVPATH="${CN_CONFIG_ROOTPATH}/systemd" CN_MOONRAKER_CONFIG_PATH="${CN_CONFIG_CONFIGPATH}/moonraker.conf" -CN_USTREAMER_REPO="https://github.com/mryel00/ustreamer.git" -CN_USTREAMER_BRANCH="master" +CN_USTREAMER_REPO="https://github.com/pikvm/ustreamer.git" +CN_USTREAMER_BRANCH="v6.10" CN_CAMERA_STREAMER_REPO="https://github.com/ayufan/camera-streamer.git" CN_CAMERA_STREAMER_BRANCH="master" diff --git a/tools/libs/config.sh b/tools/libs/config.sh index ba0b10b3..6f9419bc 100755 --- a/tools/libs/config.sh +++ b/tools/libs/config.sh @@ -35,8 +35,8 @@ import_config() { [[ -n "${CROWSNEST_CONFIG_PATH}" ]] || CROWSNEST_CONFIG_PATH="/home/${BASE_USER}/printer_data/config" [[ -n "${CROWSNEST_LOG_PATH}" ]] || CROWSNEST_LOG_PATH="/home/${BASE_USER}/printer_data/logs" [[ -n "${CROWSNEST_ENV_PATH}" ]] || CROWSNEST_ENV_PATH="/home/${BASE_USER}/printer_data/systemd" - [[ -n "${CROWSNEST_USTREAMER_REPO_SHIP}" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/mryel00/ustreamer.git" - [[ -n "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="master" + [[ -n "${CROWSNEST_USTREAMER_REPO_SHIP}" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git" + [[ -n "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="v6.10" [[ -n "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" ]] || CROWSNEST_CAMERA_STREAMER_REPO_SHIP="https://github.com/ayufan/camera-streamer.git" [[ -n "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" ]] || CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="master" status_msg "Using default configuration ..." "0"