From 2fcd3dcee692cbed59bb3c47a7a574a656403cd4 Mon Sep 17 00:00:00 2001 From: Alfonso Gamboa Date: Fri, 30 Sep 2022 17:03:12 -0700 Subject: [PATCH] further enhance imp_helper, check variables first, and only set if changed --- SD_ROOT/wz_mini/usr/bin/app.ver | 2 +- SD_ROOT/wz_mini/usr/bin/imp_helper.sh | 145 ++++++++++++++++++++------ file.chk | 4 +- 3 files changed, 118 insertions(+), 33 deletions(-) diff --git a/SD_ROOT/wz_mini/usr/bin/app.ver b/SD_ROOT/wz_mini/usr/bin/app.ver index 3afc232..dec6390 100644 --- a/SD_ROOT/wz_mini/usr/bin/app.ver +++ b/SD_ROOT/wz_mini/usr/bin/app.ver @@ -1 +1 @@ -Wed Sep 28 05:18:26 PM PDT 2022 +Fri Sep 30 05:01:52 PM PDT 2022 diff --git a/SD_ROOT/wz_mini/usr/bin/imp_helper.sh b/SD_ROOT/wz_mini/usr/bin/imp_helper.sh index 66b65f1..ea7d9df 100755 --- a/SD_ROOT/wz_mini/usr/bin/imp_helper.sh +++ b/SD_ROOT/wz_mini/usr/bin/imp_helper.sh @@ -11,6 +11,22 @@ export WZMINI_CFG=/opt/wz_mini/wz_mini.conf DELAY_BETWEEN=2 RE_RUN_DELAY=60 +rm -f /opt/wz_mini/tmp/impdbg.out + +impdbg --enc_info > /opt/wz_mini/tmp/impdbg.out + +CH0_RC=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep "rcMode =" | sed 's/(.*//' | sed 's,.*\(.\{1\}\)$,\1,') +CH0_TGT_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep TargetBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,') +CH0_MAX_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep MaxBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,') +CH0_FPS=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep frmRateNum | sed 's/(.*//' | sed 's,.*\(.\{2\}\)$,\1,') + +CH1_RC=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep "rcMode =" | sed 's/(.*//' | sed 's,.*\(.\{1\}\)$,\1,') +CH1_TGT_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep TargetBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,') +CH1_MAX_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep MaxBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,') +CH1_FPS=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep frmRateNum | sed 's/(.*//' | sed 's,.*\(.\{2\}\)$,\1,') + +rm -f /opt/wz_mini/tmp/impdbg.out + hi_res_monitor() { if [[ "$RTSP_HI_RES_ENABLED" != "true" ]] ; then return @@ -19,15 +35,25 @@ hi_res_monitor() { if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then - /system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_ENC_PARAMETER != "$CH0_RC" ]] ; then + echo "Setting RTSP_HI_RES_ENC_PARAMETER T20" + /system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_ENC_PARAMETER" + fi else echo "Invalid encoder value $RTSP_HI_RES_ENC_PARAMETER" fi else if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then - /system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_ENC_PARAMETER != "$CH0_RC" ]] ; then + echo "Setting RTSP_HI_RES_ENC_PARAMETER" + /system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_ENC_PARAMETER" + fi else echo "Invalid encoder value $RTSP_HI_RES_ENC_PARAMETER" fi @@ -36,11 +62,21 @@ hi_res_monitor() { if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then - /system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_MAX_BITRATE != "$CH0_MAX_BIT" ]] ; then + echo "Setting RTSP_HI_RES_MAX_BITRATE T20" + /system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_MAX_BITRATE T20" + fi else - /system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_MAX_BITRATE != "$CH0_MAX_BIT" ]] ; then + echo "Setting RTSP_HI_RES_MAX_BITRATE" + /system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_MAX_BITRATE" + fi fi fi @@ -48,18 +84,33 @@ hi_res_monitor() { if [ -f /opt/wz_mini/tmp/.T20 ] ; then echo "not supported on T20" else - /system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_TARGET_BITRATE != "$CH0_TGT_BIT" ]] ; then + echo "Setting RTSP_HI_RES_TARGET_BITRATE" + /system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_TARGET_BITRATE" + fi fi fi if [[ "$RTSP_HI_RES_FPS" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then - /system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_FPS != "$CH0_FPS" ]] ; then + echo "Setting RTSP_HI_RES_FPS T20" + /system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_FPS T20" + fi else - /system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS - sleep $DELAY_BETWEEN + if [[ $RTSP_HI_RES_FPS != "$CH0_FPS" ]] ; then + echo "Setting RTSP_HI_RES_FPS" + /system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_HI_RES_FPS" + fi fi fi } @@ -72,15 +123,25 @@ low_res_monitor () { if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then - /system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_ENC_PARAMETER != "$CH1_RC" ]] ; then + echo "Setting RTSP_LOW_RES_ENC_PARAMETER T20" + /system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_ENC_PARAMETER T20" + fi else echo "Invalid encoder value $RTSP_LOW_RES_ENC_PARAMETER" fi else if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then - /system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_ENC_PARAMETER != "$CH1_RC" ]] ; then + echo "Setting RTSP_LOW_RES_ENC_PARAMETER" + /system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_ENC_PARAMETER" + fi else echo "Invalid encoder value $RTSP_LOW_RES_ENC_PARAMETER" fi @@ -89,30 +150,55 @@ low_res_monitor () { if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then - /system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_MAX_BITRATE != "$CH1_MAX_BIT" ]] ; then + echo "Setting RTSP_LOW_RES_MAX_BITRATE T20" + /system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_MAX_BITRATE T20" + fi else - /system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_MAX_BITRATE != "$CH1_MAX_BIT" ]] ; then + echo "Setting RTSP_LOW_RES_MAX_BITRATE" + /system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_MAX_BITRATE" + fi fi fi if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then - echo "not supported on T20" + echo "Not supported on T20" else - /system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_TARGET_BITRATE != "$CH1_TGT_BIT" ]] ; then + echo "Setting RTSP_LOW_RES_TARGET_BITRATE" + /system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_TARGET_BITRATE" + fi fi fi if [[ "$RTSP_LOW_RES_FPS" != "" ]] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then - /system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_FPS != "$CH1_FPS" ]] ; then + echo "Setting RTSP_LOW_RES_FPS T20" + /system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_FPS T20" + fi else - /system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS - sleep $DELAY_BETWEEN + if [[ $RTSP_LOW_RES_FPS != "$CH1_FPS" ]] ; then + echo "Setting RTSP_LOW_RES_FPS" + /system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS + sleep $DELAY_BETWEEN + else + echo "No change to RTSP_LOW_RES_FPS" + fi fi fi } @@ -138,4 +224,3 @@ while true; do echo "Restart imp_helper.sh, sleep for $RE_RUN_DELAY" sleep $RE_RUN_DELAY done - diff --git a/file.chk b/file.chk index 66d8bcf..a996f44 100644 --- a/file.chk +++ b/file.chk @@ -161,9 +161,9 @@ b339aee882a5d1c943ad08e4282ec3fd SD_ROOT/wz_mini/usr/bin/iCamera-dbg 0de553a920d30d1e9d84c9ab4136df0d SD_ROOT/wz_mini/usr/bin/ucamera 071b974925501c4b83f2dd546d90febd SD_ROOT/wz_mini/usr/bin/netmon.sh b10bdd54c56d8d8de2a27336f17285fe SD_ROOT/wz_mini/usr/bin/patch_icamera.sh -3e15a736b79854c35abb7fd4f7207064 SD_ROOT/wz_mini/usr/bin/imp_helper.sh +dafffcc1bd1e721d508400686338ceb8 SD_ROOT/wz_mini/usr/bin/imp_helper.sh 580b1b6e91e72b4a4fef7b21d8954403 SD_ROOT/wz_mini/usr/bin/getSensorType -eb77636bf7d3371faadcd7aefc6d81bb SD_ROOT/wz_mini/usr/bin/app.ver +62d799364407472f608ebe06398b6d96 SD_ROOT/wz_mini/usr/bin/app.ver 4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar 9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so 4100755cb6cc6e3b76da20c7e3690e16 SD_ROOT/wz_mini/lib/libalog.so