From 2efcf1bb6170c04862519af700be5f23e77128ec Mon Sep 17 00:00:00 2001 From: Angel Carpintero Date: Sun, 27 Nov 2011 20:24:09 +0100 Subject: [PATCH] * Added new log type COR , to filter messages from CORE. * Fixed a bug in post_capture. It was missed under certain conditions. --- CHANGELOG | 2 ++ conf.c | 2 +- configure | 18 +++++++++--------- logger.c | 2 +- logger.h | 3 ++- motion-dist.conf.in | 4 ++-- motion.1 | 14 +++++++++++--- motion.c | 26 +++++++++++++------------- 8 files changed, 41 insertions(+), 30 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c3f8f3e..3f73f56 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ Features * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). * Added support for libjpeg-turbo http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2010x04x14x082244 (Angel Carpintero) + * Added new log type COR , to filter messages from CORE. (Angel Carpintero) Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) @@ -69,6 +70,7 @@ Bugfixes * Made micro-lightswitch optional (see lightwitch option in motion.conf) * Fixed help text for options event_gap and area_detect * Fixed motion.conf-dist , adding text according with config options. + * Fixed a bug in post_capture. It was missed under certain conditions. 3.2.12 Summary of Changes diff --git a/conf.c b/conf.c index a30792d..84549c8 100644 --- a/conf.c +++ b/conf.c @@ -228,7 +228,7 @@ config_param config_params[] = { }, { "log_type", - "# Filter to log messages by type (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)", + "# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)", 1, CONF_OFFSET(log_type_str), copy_string, diff --git a/configure b/configure index ccb7f2c..7b3362f 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for motion Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6. +# Generated by GNU Autoconf 2.67 for motion Git-48b9b3f938847204fc01553ecfffc7719af70b3d. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -549,8 +549,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6' -PACKAGE_STRING='motion Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6' +PACKAGE_VERSION='Git-48b9b3f938847204fc01553ecfffc7719af70b3d' +PACKAGE_STRING='motion Git-48b9b3f938847204fc01553ecfffc7719af70b3d' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1217,7 +1217,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures motion Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6 to adapt to many kinds of systems. +\`configure' configures motion Git-48b9b3f938847204fc01553ecfffc7719af70b3d to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1278,7 +1278,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6:";; + short | recursive ) echo "Configuration of motion Git-48b9b3f938847204fc01553ecfffc7719af70b3d:";; esac cat <<\_ACEOF @@ -1424,7 +1424,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6 +motion configure Git-48b9b3f938847204fc01553ecfffc7719af70b3d generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2021,7 +2021,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by motion $as_me Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6, which was +It was created by motion $as_me Git-48b9b3f938847204fc01553ecfffc7719af70b3d, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -6532,7 +6532,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by motion $as_me Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6, which was +This file was extended by motion $as_me Git-48b9b3f938847204fc01553ecfffc7719af70b3d, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6594,7 +6594,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -motion config.status Git-944d1ee5adebe1c9cc99da64975e599ebee5aeb6 +motion config.status Git-48b9b3f938847204fc01553ecfffc7719af70b3d configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/logger.c b/logger.c index 6eb8b14..8633677 100644 --- a/logger.c +++ b/logger.c @@ -18,7 +18,7 @@ static FILE *logfile; static unsigned int log_level = LEVEL_DEFAULT; static unsigned int log_type = TYPE_DEFAULT; -static const char *log_type_str[] = {NULL, "STR", "ENC", "NET", "DBL", "EVT", "TRK", "VID", "ALL"}; +static const char *log_type_str[] = {NULL, "COR", "STR", "ENC", "NET", "DBL", "EVT", "TRK", "VID", "ALL"}; static const char *log_level_str[] = {"EMG", "ALR", "CRT", "ERR", "WRN", "NTC", "INF", "DBG", "ALL", NULL}; diff --git a/logger.h b/logger.h index 9910147..9616028 100644 --- a/logger.h +++ b/logger.h @@ -32,11 +32,12 @@ #define NTC LOG_NOTICE /* syslog 5 motion 6 */ #define INF LOG_INFO /* syslog 6 motion 7 */ #define DBG LOG_DEBUG /* syslog 7 motion 8 */ -#define ALL LOG_ALL /* syslog 7 motion 9 */ +#define ALL LOG_ALL /* syslog 8 motion 9 */ #define LEVEL_DEFAULT NTC /* syslog 5 motion 6 default */ #define SHOW_LEVEL_VALUE(x) (x+1) /* Log types */ +#define TYPE_CORE 0 /* Core logs */ #define TYPE_STREAM 1 /* Stream logs */ #define TYPE_ENCODER 2 /* Encoder logs */ #define TYPE_NETCAM 3 /* Netcam logs */ diff --git a/motion-dist.conf.in b/motion-dist.conf.in index f1542ea..afe44f1 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -24,10 +24,10 @@ setup_mode off # Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) ;logfile /tmp/motion.log -# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC) +# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) log_level 6 -# Filter to log messages by type (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) +# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) log_type all ########################################################### diff --git a/motion.1 b/motion.1 index 1fe6fc9..7260f1f 100644 --- a/motion.1 +++ b/motion.1 @@ -24,10 +24,10 @@ Run in non-daemon mode. Run in setup mode. Also forces non-daemon mode .TP .B \-d log level -Set log level [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC) +Set log level [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) .TP .B \-k log type -Set type of log (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) +Set type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) .TP .B \-p Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. @@ -44,7 +44,13 @@ Boolean options can be on or off (values "1", "yes" and "on" all means true and .B area_detect integer Values: 0 - 999999999 / Default: Not defined .br -Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. +Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 +.br +A script (on_area_detected) is started immediately when motion is 4 5 6 +.br +detected in one of the given areas, but only once during an event. 7 8 9 +.br +One or more areas can be specified with this option. Take care: This option does NOT restrict detection to these areas! (Default: not defined) .TP .B auto_brightness boolean Values: on, off / Default: off @@ -274,6 +280,8 @@ URL to use for a netcam proxy server, if required. The syntax is http://myproxy: Values: Max 4095 characters / Default: Not defined .br Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. +.br +http:// ftp:// mjpg:// or file:/// ( mjpg:// is for network cameras with codec mjpeg ). .TP .B netcam_userpass string Values: Max 4095 characters / Default: Not defined diff --git a/motion.c b/motion.c index 09a19b4..f6efc93 100644 --- a/motion.c +++ b/motion.c @@ -1796,18 +1796,15 @@ static void *motion_loop(void *arg) } if (frame_count >= cnt->conf.minimum_motion_frames) { + cnt->current_image->flags |= (IMAGE_TRIGGER | IMAGE_SAVE); cnt->detecting_motion = 1; -#ifdef HAVE_FFMPEG - if (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe)) { -#else - if (cnt->conf.useextpipe && cnt->extpipe) { -#endif - /* Setup the postcap counter */ - cnt->postcap = cnt->conf.post_capture; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Setup post capture %d", - cnt->postcap); - } + + /* Setup the postcap counter */ + cnt->postcap = cnt->conf.post_capture; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Setup post capture %d", + cnt->postcap); + /* Mark all images in image_ring to be saved */ for (i = 0; i < cnt->imgs.image_ring_size; i++) cnt->imgs.image_ring[i].flags |= IMAGE_SAVE; @@ -1838,6 +1835,8 @@ static void *motion_loop(void *arg) /* No motion, doing postcap */ cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); cnt->postcap--; + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", + cnt->postcap); } else { /* Done with postcap, so just have the image in the precap buffer */ cnt->current_image->flags |= IMAGE_PRECAP; @@ -2462,7 +2461,7 @@ static void motion_startup(int daemonize, int argc, char *argv[]) cnt_list[0]->log_level = cnt_list[0]->conf.log_level - 1; // Let's make syslog compatible } - set_log_level(cnt_list[0]->log_level); + //set_log_level(cnt_list[0]->log_level); #ifdef HAVE_SDL MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion "VERSION" Started with SDL support"); @@ -2499,6 +2498,7 @@ static void motion_startup(int daemonize, int argc, char *argv[]) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using log type (%s) log level (%s)", get_log_type_str(cnt_list[0]->log_type), get_log_level_str(cnt_list[0]->log_level)); + set_log_level(cnt_list[0]->log_level); set_log_type(cnt_list[0]->log_type); initialize_chars(); @@ -2764,7 +2764,7 @@ int main (int argc, char **argv) if (((motion_threads_running == 0) && finish) || ((motion_threads_running == 0) && (threads_running == 0))) { - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: DEBUG-1 threads_running %d motion_threads_running %d " + MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-1 threads_running %d motion_threads_running %d " ", finish %d", threads_running, motion_threads_running, finish); break; } @@ -2800,7 +2800,7 @@ int main (int argc, char **argv) } } - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d", + MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d", threads_running, motion_threads_running, finish); } /* Reset end main loop flag */