Skip to content

Commit

Permalink
Add go2rtc binary autodetect
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Sep 21, 2024
1 parent ea8a7f5 commit 76da55d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/www/httpd/cgi-bin/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if [ "$MODEL_SUFFIX" == "r30gb" ] || [ "$MODEL_SUFFIX" == "r35gb" ] || [ "$MODEL
else
PTZ="no"
fi
if [ -f /tmp/sd/yi-hack/bin/go2rtc ]; then
GO2RTC="yes"
else
GO2RTC="no"
fi
MFG_PART=$(grep -oE ".{0,0}mfg@.{0,9}" /sys/firmware/devicetree/base/chosen/bootargs | cut -c 5-14)
SERIAL_NUMBER=$(dd bs=1 count=20 skip=36 if=/dev/$MFG_PART 2>/dev/null | tr '\0' '0' | cut -c1-20)
LOCAL_TIME=$(date)
Expand Down Expand Up @@ -47,6 +52,7 @@ printf "\"%s\":\"%s\",\n" "fw_version" "$FW_VERSION"
printf "\"%s\":\"%s\",\n" "home_version" "$HOME_VERSION"
printf "\"%s\":\"%s\",\n" "model_suffix" "$MODEL_SUFFIX"
printf "\"%s\":\"%s\",\n" "ptz" "$PTZ"
printf "\"%s\":\"%s\",\n" "go2rtc" "$GO2RTC"
printf "\"%s\":\"%s\",\n" "serial_number" "$SERIAL_NUMBER"
printf "\"%s\":\"%s\",\n" "local_time" "$LOCAL_TIME"
printf "\"%s\":\"%s\",\n" "uptime" "$UPTIME"
Expand Down
19 changes: 19 additions & 0 deletions src/www/httpd/htdocs/js/modules/configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ APP.configurations = (function($) {
function init() {
registerEventHandler();
fetchConfigs();
fetchStatus();
}

function registerEventHandler() {
Expand Down Expand Up @@ -98,6 +99,24 @@ APP.configurations = (function($) {
});
}

function fetchStatus() {
$.ajax({
type: "GET",
url: 'cgi-bin/status.json',
dataType: "json",
success: function(response) {
$.each(response, function(key, state) {
if (key == "go2rtc" && state == "no") {
$("#RTSP_ALT option[value='go2rtc']").remove();
}
});
},
error: function(response) {
console.log('error', response);
}
});
}

function validateHostname(hostname) {
return /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/.test(hostname);
}
Expand Down

0 comments on commit 76da55d

Please sign in to comment.