From 05b815771a359a3a66c1c06a597cb6b947fefe89 Mon Sep 17 00:00:00 2001 From: Angel Carpintero Date: Sun, 1 Jan 2012 20:07:17 +0100 Subject: [PATCH] - Added a new starting option -m to disable motion detection - Fixed configure for SDL - Little fix in logging because was broken - Replaced malloc by calloc in mymalloc() --- CHANGELOG | 2 ++ CREDITS | 1 + conf.c | 9 +++++++-- conf.h | 1 + configure | 21 ++++++++++----------- configure.in | 3 +-- logger.c | 5 +++++ logger.h | 18 +++++++++--------- motion.1 | 7 +++++-- motion.c | 6 +++--- webhttpd.c | 2 +- 11 files changed, 45 insertions(+), 30 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3f73f56..8c00a44 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -43,6 +43,7 @@ Features * 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) + * Added a new starting option -m to disable motion detection. (Angel Carpintero) Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) @@ -71,6 +72,7 @@ Bugfixes * 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. + * Fixed configure for SDL. 3.2.12 Summary of Changes diff --git a/CREDITS b/CREDITS index e4663e2..96f4c0e 100644 --- a/CREDITS +++ b/CREDITS @@ -432,6 +432,7 @@ Angel Carpintero * No PQfinish(). * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 + * Added a new starting option -m to disable motion detection. Jared D * Change bayer2rgb24() to fix a problem with sn9c102 driver diff --git a/conf.c b/conf.c index 84549c8..901bc93 100644 --- a/conf.c +++ b/conf.c @@ -159,6 +159,7 @@ struct config conf_template = { log_file: NULL, log_level: LEVEL_DEFAULT+10, log_type_str: NULL, +// motion_detection_pause: 1, }; @@ -1550,7 +1551,7 @@ static void conf_cmdline(struct context *cnt, int thread) * if necessary. This is accomplished by calling mystrcpy(); * see this function for more information. */ - while ((c = getopt(conf->argc, conf->argv, "c:d:hns?p:k:l:")) != EOF) + while ((c = getopt(conf->argc, conf->argv, "c:d:hmns?p:k:l:")) != EOF) switch (c) { case 'c': if (thread == -1) @@ -1579,6 +1580,9 @@ static void conf_cmdline(struct context *cnt, int thread) if (thread == -1) strcpy(cnt->log_file, optarg); break; + case 'm': + cnt->pause = 1; + break; case 'h': case '?': default: @@ -2358,9 +2362,10 @@ static void usage() printf("-s\t\t\tRun in setup mode.\n"); printf("-c config\t\tFull path and filename of config file.\n"); printf("-d level\t\tLog level (1-9) (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). default: 6 / NTC.\n"); - printf("-k type\t\t\tType of log (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). default: ALL.\n"); + printf("-k type\t\t\tType of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). default: ALL.\n"); printf("-p process_id_file\tFull path and filename of process id file (pid file).\n"); printf("-l log file \t\tFull path and filename of log file.\n"); + printf("-m\t\t\tDisable motion detection at startup.\n"); printf("-h\t\t\tShow this screen.\n"); printf("\n"); printf("Motion is configured using a config file only. If none is supplied,\n"); diff --git a/conf.h b/conf.h index b03397e..cad2eef 100644 --- a/conf.h +++ b/conf.h @@ -133,6 +133,7 @@ struct config { int minimum_motion_frames; const char *exif_text; char *pid_file; +// unsigned int motion_detection_pause; int argc; char **argv; }; diff --git a/configure b/configure index 7b3362f..7dd38f5 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-48b9b3f938847204fc01553ecfffc7719af70b3d. +# Generated by GNU Autoconf 2.67 for motion Git-2efcf1bb6170c04862519af700be5f23e77128ec. # # # 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-48b9b3f938847204fc01553ecfffc7719af70b3d' -PACKAGE_STRING='motion Git-48b9b3f938847204fc01553ecfffc7719af70b3d' +PACKAGE_VERSION='Git-2efcf1bb6170c04862519af700be5f23e77128ec' +PACKAGE_STRING='motion Git-2efcf1bb6170c04862519af700be5f23e77128ec' 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-48b9b3f938847204fc01553ecfffc7719af70b3d to adapt to many kinds of systems. +\`configure' configures motion Git-2efcf1bb6170c04862519af700be5f23e77128ec 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-48b9b3f938847204fc01553ecfffc7719af70b3d:";; + short | recursive ) echo "Configuration of motion Git-2efcf1bb6170c04862519af700be5f23e77128ec:";; 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-48b9b3f938847204fc01553ecfffc7719af70b3d +motion configure Git-2efcf1bb6170c04862519af700be5f23e77128ec 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-48b9b3f938847204fc01553ecfffc7719af70b3d, which was +It was created by motion $as_me Git-2efcf1bb6170c04862519af700be5f23e77128ec, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -3942,7 +3942,7 @@ fi # # Check for sdl library # -SDL_SUPPORT="yes" +SDL_SUPPORT="no" # Check whether --with-sdl was given. if test "${with_sdl+set}" = set; then : @@ -3954,7 +3954,6 @@ $as_echo_n "checking for sdl... " >&6; } if test "x$withval" = "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 $as_echo "skipped" >&6; } - SDL_SUPPORT="no" else if test "${FreeBSD}" != ""; then CONFIG_SDL='sdl11-config' @@ -6532,7 +6531,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-48b9b3f938847204fc01553ecfffc7719af70b3d, which was +This file was extended by motion $as_me Git-2efcf1bb6170c04862519af700be5f23e77128ec, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6594,7 +6593,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-48b9b3f938847204fc01553ecfffc7719af70b3d +motion config.status Git-2efcf1bb6170c04862519af700be5f23e77128ec configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/configure.in b/configure.in index b230d34..48a081e 100644 --- a/configure.in +++ b/configure.in @@ -211,7 +211,7 @@ fi # # Check for sdl library # -SDL_SUPPORT="yes" +SDL_SUPPORT="no" AC_ARG_WITH(sdl, [ --without-sdl Compile without sdl support to get stream in SDL window. ], @@ -220,7 +220,6 @@ AC_ARG_WITH(sdl, AC_MSG_CHECKING(for sdl) if test "x$withval" = "xno"; then AC_MSG_RESULT(skipped) - SDL_SUPPORT="no" else if test "${FreeBSD}" != ""; then CONFIG_SDL='sdl11-config' diff --git a/logger.c b/logger.c index 8633677..f76d2a3 100644 --- a/logger.c +++ b/logger.c @@ -63,6 +63,7 @@ const char* get_log_type_str(unsigned int type) void set_log_type(unsigned int type) { log_type = type; + //printf("set log type %d\n", type); } /** @@ -85,6 +86,7 @@ const char* get_log_level_str(unsigned int level) void set_log_level(unsigned int level) { log_level = level; + //printf("set log level %d\n", level); } /** @@ -96,6 +98,7 @@ void set_log_level(unsigned int level) void set_log_mode(int mode) { log_mode = mode; + //printf("set log mode %d\n", mode); } /** @@ -173,6 +176,8 @@ void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, . if ((log_type != TYPE_ALL) && (type != log_type)) return; + //printf("log_type %d, type %d level %d\n", log_type, type, level); + /* * If pthread_getspecific fails (e.g., because the thread's TLS doesn't * contain anything for thread number, it returns NULL which casts to zero, diff --git a/logger.h b/logger.h index 9616028..1361c6c 100644 --- a/logger.h +++ b/logger.h @@ -37,15 +37,15 @@ #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 */ -#define TYPE_DB 4 /* Database logs */ -#define TYPE_EVENTS 5 /* Events logs */ -#define TYPE_TRACK 6 /* Track logs */ -#define TYPE_VIDEO 7 /* V4L1/2 Bktr logs */ -#define TYPE_ALL 8 /* All type logs */ +#define TYPE_CORE 1 /* Core logs */ +#define TYPE_STREAM 2 /* Stream logs */ +#define TYPE_ENCODER 3 /* Encoder logs */ +#define TYPE_NETCAM 4 /* Netcam logs */ +#define TYPE_DB 5 /* Database logs */ +#define TYPE_EVENTS 6 /* Events logs */ +#define TYPE_TRACK 7 /* Track logs */ +#define TYPE_VIDEO 8 /* V4L1/2 Bktr logs */ +#define TYPE_ALL 9 /* All type logs */ #define TYPE_DEFAULT TYPE_ALL /* Default type */ #define TYPE_DEFAULT_STR "ALL" /* Default name logs */ diff --git a/motion.1 b/motion.1 index 7260f1f..a77fb31 100644 --- a/motion.1 +++ b/motion.1 @@ -1,9 +1,9 @@ -.TH MOTION 1 2008-05-05 "Motion" "Motion Options and Config Files" +.TH MOTION 1 2011-12-12 "Motion" "Motion Options and Config Files" .SH NAME motion \- Detect motion using a video4linux device .SH SYNOPSIS .B motion -[ -hns ] [ -c config file path ] [ -d log level ] [ -k log type ] [ -p process_id_file ] [ -l logfile ] +[ -hmns ] [ -c config file path ] [ -d log level ] [ -k log type ] [ -p process_id_file ] [ -l logfile ] .SH DESCRIPTION .I Motion uses a video4linux device to detect motion. If motion is detected both normal @@ -17,6 +17,9 @@ Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is / .B \-h Show help screen. .TP +.B \-m +Disable motion detection at startup. +.TP .B \-n Run in non-daemon mode. .TP diff --git a/motion.c b/motion.c index f6efc93..64426d5 100644 --- a/motion.c +++ b/motion.c @@ -688,8 +688,8 @@ static int motion_init(struct context *cnt) cnt->detecting_motion = 0; cnt->makemovie = 0; - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d started", - (unsigned long)pthread_getspecific(tls_key_threadnr)); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d started , motion detection %s", + (unsigned long)pthread_getspecific(tls_key_threadnr), cnt->pause ? "Disabled":"Enabled"); if (!cnt->conf.filepath) cnt->conf.filepath = mystrdup("."); @@ -2854,7 +2854,7 @@ int main (int argc, char **argv) */ void * mymalloc(size_t nbytes) { - void *dummy = malloc(nbytes); + void *dummy = calloc(nbytes, 1); if (!dummy) { MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Could not allocate %llu bytes of memory!", diff --git a/webhttpd.c b/webhttpd.c index af6a387..20fe4e8 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2389,7 +2389,7 @@ void httpd_run(struct context **cnt) { int sd = -1, client_socket_fd, val; unsigned int client_sent_quit_message = 1, closehttpd = 0; - struct addrinfo hints, *res, *ressave; + struct addrinfo hints, *res = NULL, *ressave = NULL; struct sigaction act; char *authentication = NULL; char portnumber[10], hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];