diff --git a/VERSION b/VERSION index de31062..1d0ba9e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.0d +0.4.0 diff --git a/src/h264grabber/h264grabber/h264grabber.c b/src/h264grabber/h264grabber/h264grabber.c index c8815bc..55c4ec8 100644 --- a/src/h264grabber/h264grabber/h264grabber.c +++ b/src/h264grabber/h264grabber/h264grabber.c @@ -214,7 +214,7 @@ int main(int argc, char **argv) { FILE *fFid = NULL; FILE *fOut = NULL; - int current_frame, frame_counter, frame_counter_tmp, next_frame_counter; + int current_frame, frame_counter, frame_counter_tmp, next_frame_counter, frame_start, next_frame_start; int table_offset, stream_offset; unsigned int frame_ts = 0; unsigned int frame_ts_tmp, next_frame_ts, frame_ts_diff; @@ -573,17 +573,24 @@ int main(int argc, char **argv) { for (i = 0; i < table_record_num; i++) { // Get pointer to the record record_ptr = addr + table_offset + (i * table_record_size); + // Get the frame start and check if '01' + frame_start = (int) *(record_ptr); + if (frame_start != 1) continue; // Get the frame counter frame_counter_tmp = (((int) *(record_ptr + frame_counter_offset + 1)) << 8) + ((int) *(record_ptr + frame_counter_offset)); // Check if it is the largest frame_counter if (frame_counter_tmp > frame_counter) { frame_counter = frame_counter_tmp; - } else { current_frame = i; + } else { break; } } + if (current_frame == -1) { + usleep(MILLIS_10); + continue; + } if (debug) fprintf(stderr, "%lld - found latest frame: id %d, frame_counter %d\n", current_timestamp(), current_frame, frame_counter); // Wait 10 milliseconds @@ -601,6 +608,12 @@ int main(int argc, char **argv) { } else { next_record_ptr = record_ptr + table_record_size; } + // Get the frame start and check if '01' + next_frame_start = (int) *(next_record_ptr); + if (next_frame_start != 1) { + usleep(MILLIS_10); + continue; + } // Get the frame counter of the next record next_frame_counter = ((int) *(next_record_ptr + frame_counter_offset + 1)) * 256 + ((int) *(next_record_ptr + frame_counter_offset)); if (debug) fprintf(stderr, "%lld - current frame counter is %d, next frame counter is %d\n", current_timestamp(), frame_counter, next_frame_counter); @@ -635,7 +648,7 @@ int main(int argc, char **argv) { } else { frame_counter_invalid++; if (frame_counter_invalid < 10) { - if (debug) fprintf(stderr, "%lld - frame counter invalid %d\n", current_timestamp(), frame_counter_invalid); + if (debug) fprintf(stderr, "%lld - frame counter invalid %d, wait for the next frame\n", current_timestamp(), frame_counter_invalid); } else { if (debug) fprintf(stderr, "%lld - frame counter invalid %d, sync lost\n", current_timestamp(), frame_counter_invalid); break; @@ -650,10 +663,13 @@ int main(int argc, char **argv) { for(;;) { // Find the record with the largest timestamp current_frame = -1; - frame_counter = -1; + frame_ts = 0; for (i = 0; i < table_record_num; i++) { // Get pointer to the record record_ptr = addr + table_offset + (i * table_record_size); + // Get the frame start and check if '01' + frame_start = (int) *(record_ptr); + if (frame_start != 1) continue; // Get the frame timestamp frame_ts_tmp = (((int) *(record_ptr + frame_ts_offset + 3)) << 24) + (((int) *(record_ptr + frame_ts_offset + 2)) << 16) + @@ -662,11 +678,15 @@ int main(int argc, char **argv) { // Check if it is the largest timestamp if (frame_ts_tmp > frame_ts) { frame_ts = frame_ts_tmp; - } else { current_frame = i; + } else { break; } } + if (current_frame == -1) { + usleep(MILLIS_10); + continue; + } if (debug) fprintf(stderr, "%lld - found latest frame: id %d, frame_ts %u\n", current_timestamp(), current_frame, frame_ts); // Wait 10 milliseconds @@ -684,18 +704,24 @@ int main(int argc, char **argv) { } else { next_record_ptr = record_ptr + table_record_size; } + // Get the frame start and check if '01' + next_frame_start = (int) *(next_record_ptr); + if (next_frame_start != 1) { + usleep(MILLIS_10); + continue; + } // Get the frame timestamp of the next record next_frame_ts = (((int) *(next_record_ptr + frame_ts_offset + 3)) << 24) + (((int) *(next_record_ptr + frame_ts_offset + 2)) << 16) + (((int) *(next_record_ptr + frame_ts_offset + 1)) << 8) + ((int) *(next_record_ptr + frame_ts_offset)); - if (debug) fprintf(stderr, "%lld - current frame timestamp is %u, next frame timestamp is %u\n", current_timestamp(), frame_ts, next_frame_ts); + if (debug) fprintf(stderr, "%lld - current frame timestamp is %u, next frame timestamp is %u, duration is %u\n", current_timestamp(), frame_ts, next_frame_ts, next_frame_ts - frame_ts); // Check if the frame timestamp is valid if (next_frame_ts >= frame_ts) frame_ts_diff = next_frame_ts - frame_ts; else frame_ts_diff = next_frame_ts + (0xffffffff - frame_ts + 1); - if ((frame_ts_diff >= 0) && (frame_ts_diff <= 10 * 64)) { // 1 packet with 1024 samples every 64 ms + if ((frame_ts_diff >= 0) && (frame_ts_diff <= 2 * 128)) { // 1 packet with 1024 samples every 128 ms // Get the offset of the stream frame_offset = (((int) *(record_ptr + frame_offset_offset + 3)) << 24) + (((int) *(record_ptr + frame_offset_offset + 2)) << 16) + @@ -724,9 +750,9 @@ int main(int argc, char **argv) { } else { frame_counter_invalid++; if (frame_counter_invalid < 10) { - if (debug) fprintf(stderr, "%lld - frame counter invalid %d\n", current_timestamp(), frame_counter_invalid); + if (debug) fprintf(stderr, "%lld - frame timestamp invalid %d, wait for the next frame\n", current_timestamp(), frame_counter_invalid); } else { - if (debug) fprintf(stderr, "%lld - frame counter invalid %d, sync lost\n", current_timestamp(), frame_counter_invalid); + if (debug) fprintf(stderr, "%lld - frame timestamp invalid %d, sync lost\n", current_timestamp(), frame_counter_invalid); break; } } diff --git a/src/mqtt-config/mqtt-config/config.c b/src/mqtt-config/mqtt-config/config.c index 1e02ee1..66eeb06 100644 --- a/src/mqtt-config/mqtt-config/config.c +++ b/src/mqtt-config/mqtt-config/config.c @@ -2,6 +2,24 @@ void (*fconf_handler)(const char* key, const char* value); +void ucase(char *string) { + // Convert to upper case + char *s = string; + while (*s) { + *s = toupper((unsigned char) *s); + s++; + } +} + +void lcase(char *string) { + // Convert to lower case + char *s = string; + while (*s) { + *s = tolower((unsigned char) *s); + s++; + } +} + void config_set_handler(void (*f)(const char* key, const char* value)) { if (f != NULL) @@ -30,6 +48,72 @@ void config_parse(FILE *fp) } } +void config_replace(char *filename, char *key, char *value) +{ + char buf[MAX_LINE_LENGTH]; + char oldkey[128]; + char oldvalue[128]; + char *line; + int parsed; + FILE *fps, *fpt; + char tmpFile[L_tmpnam + 1]; // Add +1 for the null character. + + lcase(filename); + ucase(key); + + fps = fopen(filename, "r"); + if (fps == NULL) { + printf("Can't open file \"%s\": %s\n", filename, strerror(errno)); + return; + } + + tmpnam(tmpFile); + fpt = fopen(tmpFile, "w"); + if (fpt == NULL) { + printf("Can't open file \"%s\": %s\n", filename, strerror(errno)); + return; + } + + while (!feof(fps)) { + line = fgets(buf, MAX_LINE_LENGTH, fps); + if (line == NULL) break; + if (buf[0] != '#') { + parsed = sscanf(buf, "%[^=] = %s", oldkey, oldvalue); + if((parsed == 2) && (strcasecmp(key, oldkey) == 0)) { + sprintf(buf, "%s=%s\n", key, value); + } + } + fputs(buf, fpt); + } + + fclose(fpt); + fclose(fps); + + // Rename file (rename function is a cross-device link) + fps = fopen(filename, "w"); + if (fps == NULL) { + printf("Can't open file \"%s\": %s\n", filename, strerror(errno)); + return; + } + + fpt = fopen(tmpFile, "r"); + if (fpt == NULL) { + printf("Can't open file \"%s\": %s\n", filename, strerror(errno)); + return; + } + + while (!feof(fpt)) { + line = fgets(buf, MAX_LINE_LENGTH, fpt); + if (line == NULL) break; + fputs(buf, fps); + } + + fclose(fpt); + fclose(fps); + + remove(tmpFile); +} + FILE *open_conf_file(const char* filename) { FILE *fp; diff --git a/src/mqtt-config/mqtt-config/config.h b/src/mqtt-config/mqtt-config/config.h index cc0a9e5..cb070a4 100644 --- a/src/mqtt-config/mqtt-config/config.h +++ b/src/mqtt-config/mqtt-config/config.h @@ -11,5 +11,6 @@ void config_set_handler(void (*f)(const char* key, const char* value)); void config_parse(FILE *fp); +void config_replace(char *filename, char *key, char *value); FILE *open_conf_file(const char* filename); void close_conf_file(FILE *fp); diff --git a/src/mqtt-config/mqtt-config/mqtt-config.c b/src/mqtt-config/mqtt-config/mqtt-config.c index 04e511c..50ebec3 100644 --- a/src/mqtt-config/mqtt-config/mqtt-config.c +++ b/src/mqtt-config/mqtt-config/mqtt-config.c @@ -60,6 +60,7 @@ void disconnect_callback(struct mosquitto *mosq, void *obj, int result) void message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message) { char topic_prefix[MAX_LINE_LENGTH], topic[MAX_LINE_LENGTH], file[MAX_KEY_LENGTH], param[MAX_KEY_LENGTH]; + char conf_file[256]; char *slash; bool match = 0; int len; @@ -148,6 +149,10 @@ void message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_ sprintf(cmd_line, "ipc_cmd %s %s", ipc_cmd_param, (char *) message->payload); if (debug) printf("Running system command \"%s\"\n", cmd_line); system(cmd_line); + } else { + sprintf(conf_file, "%s/%s.conf", CONF_FILE_PATH, file); + if (debug) fprintf(stderr, "Updating file \"%s\", parameter \"%s\" with value \"%s\"\n", file, param, (char *) message->payload); + config_replace(conf_file, param, message->payload); } } } else { diff --git a/src/rRTSPServer/Makefile.rRTSPServer b/src/rRTSPServer/Makefile.rRTSPServer index d45bcf4..9cecfac 100755 --- a/src/rRTSPServer/Makefile.rRTSPServer +++ b/src/rRTSPServer/Makefile.rRTSPServer @@ -8,7 +8,7 @@ CPLUSPLUS_COMPILER = $(CXX) CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1 $(CPPFLAGS) $(CXXFLAGS) OBJ = o LINK = $(CXX) -o -LINK_OPTS = -L. $(LDFLAGS) +LINK_OPTS = -Wl,--gc-sections -L. $(LDFLAGS) CONSOLE_LINK_OPTS = $(LINK_OPTS) LIBRARY_LINK = $(AR) cr LIBRARY_LINK_OPTS = diff --git a/src/rRTSPServer/init.rRTSPServer b/src/rRTSPServer/init.rRTSPServer index 1567571..4751ee1 100755 --- a/src/rRTSPServer/init.rRTSPServer +++ b/src/rRTSPServer/init.rRTSPServer @@ -30,7 +30,6 @@ fi tar zxvf $ARCHIVE patch -p0 < rRTSPServer.patch -patch -p0 < rRTSPServer2.patch cd live || exit 1 diff --git a/src/rRTSPServer/rRTSPServer.patch b/src/rRTSPServer/rRTSPServer.patch index 71ba3bb..0ec3ef1 100755 --- a/src/rRTSPServer/rRTSPServer.patch +++ b/src/rRTSPServer/rRTSPServer.patch @@ -2,7 +2,7 @@ diff -Naur live.ori/config.linux-cross live/config.linux-cross --- live.ori/config.linux-cross 1970-01-01 01:00:00.000000000 +0100 +++ live/config.linux-cross 2021-02-18 10:39:28.103846011 +0100 @@ -0,0 +1,17 @@ -+COMPILE_OPTS = $(INCLUDES) -I. -O1 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DNO_OPENSSL=1 -DNEWLOCALE_NOT_USED ++COMPILE_OPTS = $(INCLUDES) -I. -O1 -ffunction-sections -fdata-sections -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DNO_OPENSSL=1 -DRTP_PAYLOAD_MAX_SIZE=1352 -DNEWLOCALE_NOT_USED +C = c +C_COMPILER = $(CC) +C_FLAGS = $(COMPILE_OPTS) $(CPPFLAGS) $(CFLAGS) @@ -11,7 +11,7 @@ diff -Naur live.ori/config.linux-cross live/config.linux-cross +CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -DBSD=1 $(CPPFLAGS) $(CXXFLAGS) +OBJ = o +LINK = $(CXX) -o -+LINK_OPTS = -L. $(LDFLAGS) ++LINK_OPTS = -Wl,--gc-sections -L. $(LDFLAGS) +CONSOLE_LINK_OPTS = $(LINK_OPTS) +LIBRARY_LINK = $(AR) cr +LIBRARY_LINK_OPTS = diff --git a/src/rRTSPServer/rRTSPServer2.patch b/src/rRTSPServer/rRTSPServer2.patch deleted file mode 100755 index beb531d..0000000 --- a/src/rRTSPServer/rRTSPServer2.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff -Naur include.ori/ADTSAudioFifoServerMediaSubsession.hh include/ADTSAudioFifoServerMediaSubsession.hh ---- include.ori/ADTSAudioFifoServerMediaSubsession.hh 2023-04-15 23:22:04.964120526 +0200 -+++ include/ADTSAudioFifoServerMediaSubsession.hh 2023-04-20 19:18:14.115207781 +0200 -@@ -54,6 +54,8 @@ - private: - char* fAuxSDPLine; - char fDoneFlag; // used when setting up "fAuxSDPLine" -+ unsigned fSamplingFrequency; -+ unsigned fNumChannels; - char fConfigStr[5]; - RTPSink* fDummyRTPSink; // ditto - StreamReplicator *fReplicator; -diff -Naur src.ori/ADTSAudioFifoServerMediaSubsession.cpp src/ADTSAudioFifoServerMediaSubsession.cpp ---- src.ori/ADTSAudioFifoServerMediaSubsession.cpp 2023-04-15 23:22:04.964120526 +0200 -+++ src/ADTSAudioFifoServerMediaSubsession.cpp 2023-04-20 21:46:20.842280500 +0200 -@@ -128,6 +128,8 @@ - Medium::close(resultSource); - return NULL; - } else { -+ fSamplingFrequency = originalSource->samplingFrequency(); -+ fNumChannels = originalSource->numChannels(); - sprintf(fConfigStr, originalSource->configStr()); - if (debug & 4) fprintf(stderr, "createStreamReplica completed successfully\n"); - -@@ -139,10 +141,9 @@ - ::createNewRTPSink(Groupsock* rtpGroupsock, - unsigned char rtpPayloadTypeIfDynamic, - FramedSource* inputSource) { -- ADTSAudioFifoSource* adtsSource = (ADTSAudioFifoSource*)inputSource; - return MPEG4GenericRTPSink::createNew(envir(), rtpGroupsock, - rtpPayloadTypeIfDynamic, -- adtsSource->samplingFrequency(), -+ fSamplingFrequency, - "audio", "AAC-hbr", fConfigStr, -- adtsSource->numChannels()); -+ fNumChannels); - } diff --git a/src/rRTSPServer/src/ADTSAudioFifoSource.cpp b/src/rRTSPServer/src/ADTSAudioFifoSource.cpp index 528d730..d706cd5 100755 --- a/src/rRTSPServer/src/ADTSAudioFifoSource.cpp +++ b/src/rRTSPServer/src/ADTSAudioFifoSource.cpp @@ -56,19 +56,33 @@ ADTSAudioFifoSource::createNew(UsageEnvironment& env, char const* fileName) { }; // Clean fifo content +#ifdef READ_FROM_FILES_SYNCHRONOUSLY + if (debug & 4) fprintf(stderr, "Read synchronously\n"); while (fread(null, 1, sizeof(null), fid) > 0) {} +#else + if (debug & 4) fprintf(stderr, "Read asynchronously\n"); + while (read(fileno(fid), null, sizeof(null)) > 0) {} +#endif // Restore old blocking if (fcntl(fileno(fid), F_SETFL, flags) != 0) { fclose(fid); break; - }; + } unsigned char fixedHeader[7]; while (1) { +#ifdef READ_FROM_FILES_SYNCHRONOUSLY fread(fixedHeader, 1, 1, fid); +#else + read(fileno(fid), fixedHeader, 1); +#endif if (fixedHeader[0] == 0xFF) { +#ifdef READ_FROM_FILES_SYNCHRONOUSLY fread(&fixedHeader[1], 1, 1, fid); +#else + read(fileno(fid), &fixedHeader[1], 1); +#endif // Check the 'syncword': if ((fixedHeader[1]&0xF0) == 0xF0) { break; @@ -76,7 +90,11 @@ ADTSAudioFifoSource::createNew(UsageEnvironment& env, char const* fileName) { } usleep(10000); } +#ifdef READ_FROM_FILES_SYNCHRONOUSLY fread(&fixedHeader[2], 1, 5, fid); +#else + read(fileno(fid), &fixedHeader[2], 5); +#endif u_int16_t frame_length = ((fixedHeader[3]&0x03)<<11) | (fixedHeader[4]<<3) | ((fixedHeader[5]&0xE0)>>5); // Get and check the 'profile': diff --git a/src/snapshot/.gitignore b/src/snapshot/.gitignore index 9cd7c97..9ca2b40 100644 --- a/src/snapshot/.gitignore +++ b/src/snapshot/.gitignore @@ -1,8 +1,8 @@ # Ignore the install dir _install/ snapshot/SDK -snapshot/jpeg-9c -snapshot/ffmpeg-4.0.4 +snapshot/jpeg-9e +snapshot/ffmpeg-6.0 snapshot/add_water.o snapshot/convert2jpg.o snapshot/imggrabber diff --git a/src/snapshot/snapshot/imggrabber.c b/src/snapshot/snapshot/imggrabber.c index 67f3b95..9f8f380 100644 --- a/src/snapshot/snapshot/imggrabber.c +++ b/src/snapshot/snapshot/imggrabber.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 roleo. + * Copyright (c) 2023 roleo. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -314,6 +315,49 @@ int add_watermark(char *buffer, int width, int height) return 0; } +pid_t proc_find(const char* process_name, pid_t process_pid) +{ + DIR* dir; + struct dirent* ent; + char* endptr; + char buf[512]; + + if (!(dir = opendir("/proc"))) { + perror("can't open /proc"); + return -1; + } + + while((ent = readdir(dir)) != NULL) { + /* if endptr is not a null character, the directory is not + * entirely numeric, so ignore it */ + long lpid = strtol(ent->d_name, &endptr, 10); + if (*endptr != '\0') { + continue; + } + + /* try to open the cmdline file */ + snprintf(buf, sizeof(buf), "/proc/%ld/cmdline", lpid); + FILE* fp = fopen(buf, "r"); + + if (fp) { + if (fgets(buf, sizeof(buf), fp) != NULL) { + /* check the first token in the file, the program name */ + char* first = strtok(buf, " "); + if ((strcmp(first, process_name) == 0) && ((pid_t) lpid != process_pid)) { + fclose(fp); + closedir(dir); + return (pid_t) lpid; + } + } + fclose(fp); + } + + } + + closedir(dir); + return -1; +} + void print_usage(char *prog_name) { fprintf(stderr, "Usage: %s [options]\n", prog_name); @@ -614,6 +658,25 @@ int main(int argc, char **argv) { if (debug) fprintf(stderr, "Starting program\n"); + // Check if snapshot is disabled + if (access("/tmp/snapshot.disabled", F_OK ) == 0 ) { + fprintf(stderr, "Snapshot is disabled\n"); + return 0; + } + + // Check if snapshot is low res + if (access("/tmp/snapshot.low", F_OK ) == 0 ) { + fprintf(stderr, "Snapshot is low res\n"); + resolution = RESOLUTION_LOW; + } + + // Check if the process is already running + pid_t my_pid = getpid(); + if (proc_find(basename(argv[0]), my_pid) != -1) { + fprintf(stderr, "Process is already running\n"); + return 0; + } + if (resolution == RESOLUTION_LOW) { table_offset = table_low_offset; stream_offset = stream_low_offset; diff --git a/src/static/static/home/yi-hack-v5/etc/camera.conf b/src/static/static/home/yi-hack-v5/etc/camera.conf index cffe2f8..cff8fd3 100644 --- a/src/static/static/home/yi-hack-v5/etc/camera.conf +++ b/src/static/static/home/yi-hack-v5/etc/camera.conf @@ -1,9 +1,9 @@ SWITCH_ON=yes SAVE_VIDEO_ON_MOTION=yes -SENSITIVITY=high -AI_HUMAN_DETECTION=yes -SOUND_DETECTION=yes +SENSITIVITY=low +SOUND_DETECTION=no SOUND_SENSITIVITY=80 +BABY_CRYING_DETECT=no LED=yes ROTATE=no IR=yes diff --git a/src/static/static/home/yi-hack-v5/etc/mqttv4.conf b/src/static/static/home/yi-hack-v5/etc/mqttv4.conf index e601173..4dcbf24 100644 --- a/src/static/static/home/yi-hack-v5/etc/mqttv4.conf +++ b/src/static/static/home/yi-hack-v5/etc/mqttv4.conf @@ -24,9 +24,8 @@ MQTT_PREFIX=yicam TOPIC_BIRTH_WILL=status TOPIC_MOTION=motion_detection TOPIC_MOTION_IMAGE=motion_detection_image +MOTION_IMAGE_DELAY=0.5 TOPIC_MOTION_FILES=motion_files -TOPIC_AI_HUMAN_DETECTION=ai_human_detection -TOPIC_BABY_CRYING=baby_crying TOPIC_SOUND_DETECTION=sound_detection # ----------------------------------------------------------------------------- @@ -37,9 +36,8 @@ BIRTH_MSG=online WILL_MSG=offline MOTION_START_MSG=motion_start MOTION_STOP_MSG=motion_stop -AI_HUMAN_DETECTION_MSG=human BABY_CRYING_MSG=crying -SOUND_DETECTION_MSG=sound +SOUND_DETECTION_MSG=sound_detected # ----------------------------------------------------------------------------- # Other settings @@ -51,6 +49,4 @@ MQTT_RETAIN_BIRTH_WILL=1 MQTT_RETAIN_MOTION=0 MQTT_RETAIN_MOTION_IMAGE=0 MQTT_RETAIN_MOTION_FILES=0 -MQTT_RETAIN_AI_HUMAN_DETECTION=0 -MQTT_RETAIN_BABY_CRYING=0 MQTT_RETAIN_SOUND_DETECTION=0 diff --git a/src/static/static/home/yi-hack-v5/etc/system.conf b/src/static/static/home/yi-hack-v5/etc/system.conf index 40aeece..b7fd96b 100644 --- a/src/static/static/home/yi-hack-v5/etc/system.conf +++ b/src/static/static/home/yi-hack-v5/etc/system.conf @@ -14,6 +14,8 @@ ONVIF_WSDD=no ONVIF_PROFILE=high ONVIF_NETIF=wlan0 ONVIF_WM_SNAPSHOT=no +SNAPSHOT=yes +SNAPSHOT_LOW=no NTPD=no NTP_SERVER=pool.ntp.org PROXYCHAINSNG=no diff --git a/src/static/static/home/yi-hack-v5/script/check_conf.sh b/src/static/static/home/yi-hack-v5/script/check_conf.sh index 834e56a..4adf9ea 100755 --- a/src/static/static/home/yi-hack-v5/script/check_conf.sh +++ b/src/static/static/home/yi-hack-v5/script/check_conf.sh @@ -14,23 +14,15 @@ DISABLE_CLOUD=no REC_WITHOUT_CLOUD=no MQTT=no RTSP=no -RTSP_ALT=no RTSP_STREAM=high RTSP_AUDIO=no -SPEAKER_AUDIO=yes -SNAPSHOT=yes -SNAPSHOT_VIDEO=no -SNAPSHOT_LOW=no -TIMELAPSE=no -TIMELAPSE_FTP=no -TIMELAPSE_DT=60 -TIMELAPSE_VDT= ONVIF=no ONVIF_WSDD=yes ONVIF_PROFILE=high ONVIF_NETIF=wlan0 ONVIF_WM_SNAPSHOT=yes -TIME_OSD=no +SNAPSHOT=yes +SNAPSHOT_LOW=no NTPD=yes NTP_SERVER=pool.ntp.org PROXYCHAINSNG=no @@ -56,19 +48,13 @@ DEBUG_LOG=no" PARMS2=" SWITCH_ON=yes SAVE_VIDEO_ON_MOTION=yes -MOTION_DETECTION=yes SENSITIVITY=low -AI_HUMAN_DETECTION=no -AI_VEHICLE_DETECTION=no -AI_ANIMAL_DETECTION=no -FACE_DETECTION=no -MOTION_TRACKING=no SOUND_DETECTION=no SOUND_SENSITIVITY=80 +BABY_CRYING_DETECT=no LED=yes ROTATE=no -IR=yes -CRUISE=no" +IR=yes" PARMS3=" MQTT_IP=0.0.0.0 @@ -82,15 +68,11 @@ TOPIC_MOTION=motion_detection TOPIC_MOTION_IMAGE=motion_detection_image MOTION_IMAGE_DELAY=0.5 TOPIC_MOTION_FILES=motion_files -TOPIC_AI_HUMAN_DETECTION=ai_human_detection TOPIC_SOUND_DETECTION=sound_detection BIRTH_MSG=online WILL_MSG=offline MOTION_START_MSG=motion_start MOTION_STOP_MSG=motion_stop -AI_HUMAN_DETECTION_MSG=human -AI_VEHICLE_DETECTION_MSG=vehicle -AI_ANIMAL_DETECTION_MSG=animal BABY_CRYING_MSG=crying SOUND_DETECTION_MSG=sound_detected MQTT_KEEPALIVE=120 @@ -99,7 +81,6 @@ MQTT_RETAIN_BIRTH_WILL=1 MQTT_RETAIN_MOTION=0 MQTT_RETAIN_MOTION_IMAGE=0 MQTT_RETAIN_MOTION_FILES=0 -MQTT_RETAIN_AI_HUMAN_DETECTION=0 MQTT_RETAIN_SOUND_DETECTION=0" if [ ! -f $SYSTEM_CONF_FILE ]; then diff --git a/src/static/static/home/yi-hack-v5/script/system.sh b/src/static/static/home/yi-hack-v5/script/system.sh index 42a49ff..ee5e2c9 100755 --- a/src/static/static/home/yi-hack-v5/script/system.sh +++ b/src/static/static/home/yi-hack-v5/script/system.sh @@ -254,6 +254,14 @@ if [[ $(get_config ONVIF_WM_SNAPSHOT) == "yes" ]] ; then WATERMARK="&watermark=yes" fi +if [[ $(get_config SNAPSHOT) == "no" ]] ; then + touch /tmp/snapshot.disabled +fi + +if [[ $(get_config SNAPSHOT_LOW) == "yes" ]] ; then + touch /tmp/snapshot.low +fi + RRTSP_MODEL=$MODEL_SUFFIX RRTSP_RES=$(get_config RTSP_STREAM) RRTSP_AUDIO=$(get_config RTSP_AUDIO) diff --git a/src/www/httpd/cgi-bin/camera_settings.sh b/src/www/httpd/cgi-bin/camera_settings.sh index be506fe..ad2888c 100755 --- a/src/www/httpd/cgi-bin/camera_settings.sh +++ b/src/www/httpd/cgi-bin/camera_settings.sh @@ -31,12 +31,6 @@ do fi elif [ "$CONF" == "sensitivity" ] ; then ipc_cmd -s $VAL - elif [ "$CONF" == "ai_human_detection" ] ; then - if [ "$VAL" == "no" ] ; then - ipc_cmd -a off - else - ipc_cmd -a on - fi elif [ "$CONF" == "sound_detection" ] ; then if [ "$VAL" == "no" ] ; then ipc_cmd -b off @@ -47,6 +41,12 @@ do if [ "$VAL" == "50" ] || [ "$VAL" == "60" ] || [ "$VAL" == "70" ] || [ "$VAL" == "80" ] || [ "$VAL" == "90" ] ; then ipc_cmd -n $VAL fi + elif [ "$CONF" == "baby_crying_detect" ] ; then + if [ "$VAL" == "no" ] ; then + ipc_cmd -B off + else + ipc_cmd -B on + fi elif [ "$CONF" == "led" ] ; then if [ "$VAL" == "no" ] ; then ipc_cmd -l off diff --git a/src/www/httpd/htdocs/js/modules/camera_settings.js b/src/www/httpd/htdocs/js/modules/camera_settings.js index b7e815e..57cdfd0 100644 --- a/src/www/httpd/htdocs/js/modules/camera_settings.js +++ b/src/www/httpd/htdocs/js/modules/camera_settings.js @@ -57,9 +57,9 @@ APP.camera_settings = (function ($) { url: 'cgi-bin/camera_settings.sh?' + 'save_video_on_motion=' + configs["SAVE_VIDEO_ON_MOTION"] + '&sensitivity=' + configs["SENSITIVITY"] + - '&ai_human_detection=' + configs["AI_HUMAN_DETECTION"] + '&sound_detection=' + configs["SOUND_DETECTION"] + '&sound_sensitivity=' + configs["SOUND_SENSITIVITY"] + + '&baby_crying_detect=' + configs["BABY_CRYING_DETECT"] + '&led=' + configs["LED"] + '&ir=' + configs["IR"] + '&rotate=' + configs["ROTATE"] + diff --git a/src/www/httpd/htdocs/pages/camera_settings.html b/src/www/httpd/htdocs/pages/camera_settings.html index 55bc522..8d94fb8 100644 --- a/src/www/httpd/htdocs/pages/camera_settings.html +++ b/src/www/httpd/htdocs/pages/camera_settings.html @@ -76,7 +76,7 @@

General

Enable/disable AI Human Detection. - + --> Sound Detection @@ -103,7 +103,20 @@

General

- --> + + + Baby crying detect + + + + Enable/disable baby crying detect. + + + Status led diff --git a/src/www/httpd/htdocs/pages/configurations.html b/src/www/httpd/htdocs/pages/configurations.html index 1249f0a..989e240 100644 --- a/src/www/httpd/htdocs/pages/configurations.html +++ b/src/www/httpd/htdocs/pages/configurations.html @@ -172,6 +172,34 @@

General

+ + Snapshot + + + + Enable snapshot feature. +
+ If you want to use this feature, enable swap file to avoid memory problems. +
+ + + + Force low resolution snapshot + + + + Take low resolution snapshots only (useful for avoiding memory problems). + + + diff --git a/src/www/httpd/htdocs/pages/mqtt.html b/src/www/httpd/htdocs/pages/mqtt.html index 3dc3326..5aace03 100644 --- a/src/www/httpd/htdocs/pages/mqtt.html +++ b/src/www/httpd/htdocs/pages/mqtt.html @@ -130,16 +130,20 @@

Topics

+ + A raw jpeg image is sent to this topic when a motion is detected. + + - + Sound Detection @@ -157,7 +161,7 @@

Topics

- + @@ -242,7 +246,7 @@

Advanced

- + Retain for Sound Detection messages