Skip to content

Commit

Permalink
- Added a new starting option -m to disable motion detection
Browse files Browse the repository at this point in the history
- Fixed configure for SDL
- Little fix in logging because was broken
- Replaced malloc by calloc in mymalloc()
  • Loading branch information
sackmotion committed Jan 1, 2012
1 parent 2efcf1b commit 05b8157
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct config conf_template = {
log_file: NULL,
log_level: LEVEL_DEFAULT+10,
log_type_str: NULL,
// motion_detection_pause: 1,
};


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
21 changes: 10 additions & 11 deletions configure
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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=''

Expand Down Expand Up @@ -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]...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 $@
Expand Down Expand Up @@ -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 :
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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\\"
Expand Down
3 changes: 1 addition & 2 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
],
Expand All @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
7 changes: 5 additions & 2 deletions motion.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions motion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(".");
Expand Down Expand Up @@ -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!",
Expand Down
2 changes: 1 addition & 1 deletion webhttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 05b8157

Please sign in to comment.