Skip to content

Commit

Permalink
Only use post capture when we setup to record videos with external pi…
Browse files Browse the repository at this point in the history
…pe or ffmpeg.

Little fix in some log level.
  • Loading branch information
AngelCarpintero authored and AngelCarpintero committed Jan 22, 2010
1 parent 019b306 commit 4d4740b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 42 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Bugfixes
* Exit when image dimension are not modulo 16. (Angel Carpintero)
* Avoid logs flooding using some options of netcam_keepalive and try to discard images with
weird header Content-Lenght 0. (Angel Carpintero)
* Only use post capture when we setup to record videos with external pipe or ffmpeg. (Angel Carpintero)


3.2.12 Summary of Changes
Expand Down
5 changes: 4 additions & 1 deletion CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ Angel Carpintero
* Fix fd leaks in external pipe.
* Fix segfault for new libjpeg v7.
* Allow to change Standard method ( PAL / NECAM / SECAM ).

* Exit when image dimension are not modulo 16.
* Avoid logs flooding using some options of netcam_keepalive and try to discard images with
weird header Content-Lenght 0.
* Only use post capture when we setup to record videos with external pipe or ffmpeg.

Jared D
* Change bayer2rgb24() to fix a problem with sn9c102 driver
Expand Down
4 changes: 2 additions & 2 deletions alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ static int alg_labeling(struct context *cnt)

if (labelsize > 0) {
if (debug_level >= CAMERA_VERBOSE)
motion_log(LOG_DEBUG, 0,"%s: Label: %i (%i) Size: %i (%i,%i)\n",
motion_log(LOG_DEBUG, 0,"%s: Label: %i (%i) Size: %i (%i,%i)",
__FUNCTION__, current_label, cnt->current_image->total_labels,
labelsize, ix, iy);

Expand All @@ -553,7 +553,7 @@ static int alg_labeling(struct context *cnt)

if (debug_level >= CAMERA_VERBOSE)
motion_log(LOG_DEBUG, 0,"%s: %i Labels found. Largest connected Area: %i Pixel(s). "
"Largest Label: %i\n", __FUNCTION__, imgs->largest_label, imgs->labelsize_max,
"Largest Label: %i", __FUNCTION__, imgs->largest_label, imgs->labelsize_max,
cnt->current_image->total_labels);

/* return group of significant labels */
Expand Down
4 changes: 0 additions & 4 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
#include "motion.h"


#if (defined(BSD) && !defined(PWCBSD))
#include "video_freebsd.h"
#else
Expand All @@ -41,10 +40,8 @@ char *get_current_dir_name(void)
}
#endif


#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0; }


struct config conf_template = {
width: DEF_WIDTH,
height: DEF_HEIGHT,
Expand Down Expand Up @@ -159,7 +156,6 @@ struct config conf_template = {
};



static struct context **copy_bool(struct context **, const char *, int);
static struct context **copy_int(struct context **, const char *, int);
static struct context **config_thread(struct context **cnt, const char *str, int val);
Expand Down
18 changes: 9 additions & 9 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.64 for motion trunk-r476.
# Generated by GNU Autoconf 2.64 for motion trunk-r479.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
Expand Down Expand Up @@ -546,8 +546,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='motion'
PACKAGE_TARNAME='motion'
PACKAGE_VERSION='trunk-r476'
PACKAGE_STRING='motion trunk-r476'
PACKAGE_VERSION='trunk-r479'
PACKAGE_STRING='motion trunk-r479'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''

Expand Down Expand Up @@ -1210,7 +1210,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 trunk-r476 to adapt to many kinds of systems.
\`configure' configures motion trunk-r479 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1271,7 +1271,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of motion trunk-r476:";;
short | recursive ) echo "Configuration of motion trunk-r479:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1412,7 +1412,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
motion configure trunk-r476
motion configure trunk-r479
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2009,7 +2009,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 trunk-r476, which was
It was created by motion $as_me trunk-r479, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -5790,7 +5790,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 trunk-r476, which was
This file was extended by motion $as_me trunk-r479, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -5850,7 +5850,7 @@ Report bugs to the package provider."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
motion config.status trunk-r476
motion config.status trunk-r479
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
Expand Down
47 changes: 32 additions & 15 deletions motion.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,10 @@ static void process_image_ring(struct context *cnt, unsigned int max_images)
cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL,
&cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm);

//#ifdef HAVE_FFMPEG
/* Check if we must add any "filler" frames into movie to keep up fps */
if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot == 0) {
/* Check if we must add any "filler" frames into movie to keep up fps
Only if we are recording videos ( ffmpeg or extenal pipe ) */
if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot == 0) &&
(cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) {
/* movie_last_shoot is -1 when file is created,
* we don't know how many frames there is in first sec */
if (cnt->movie_last_shot >= 0) {
Expand All @@ -573,15 +574,14 @@ static void process_image_ring(struct context *cnt, unsigned int max_images)
}
cnt->movie_last_shot = 0;
} else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot != (cnt->movie_last_shot + 1)) {
/* We are out of sync! Properbly we got motion - no motion - motion */
/* We are out of sync! Propably we got motion - no motion - motion */
cnt->movie_last_shot = -1;
}

/* Save last shot added to movie
* only when we not are within first sec */
if (cnt->movie_last_shot >= 0)
cnt->movie_last_shot = cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot;
//#endif
}

/* Mark the image as saved */
Expand Down Expand Up @@ -1670,8 +1670,16 @@ static void *motion_loop(void *arg)
*/
if (cnt->conf.emulate_motion && (cnt->startup_frames == 0)) {
cnt->detecting_motion = 1;
/* Setup the postcap counter */
cnt->postcap = cnt->conf.post_capture;
if (debug_level >= CAMERA_DEBUG)
motion_log(0, 0, "%s: Emulating motion %d", __FUNCTION__);

if (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe)) {
/* Setup the postcap counter */
cnt->postcap = cnt->conf.post_capture;
if (debug_level >= CAMERA_DEBUG)
motion_log(0, 0, "%s: (Em) Init post capture %d", __FUNCTION__, cnt->postcap);
}

cnt->current_image->flags |= (IMAGE_TRIGGER | IMAGE_SAVE);
motion_detected(cnt, cnt->video_dev, cnt->current_image);
} else if ((cnt->current_image->flags & IMAGE_MOTION) && (cnt->startup_frames == 0)) {
Expand All @@ -1697,23 +1705,32 @@ 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;
/* Setup the postcap counter */
cnt->postcap = cnt->conf.post_capture;

if (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe)) {
/* Setup the postcap counter */
cnt->postcap = cnt->conf.post_capture;
if (debug_level >= CAMERA_DEBUG)
motion_log(0, 0, "%s: Setup post capture %d", __FUNCTION__, 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;

} else if (cnt->postcap) { /* we have motion in this frame,
but not enought frames for trigger. Check postcap */
} else if ((cnt->postcap) &&
(cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) {
/* we have motion in this frame, but not enought frames for trigger. Check postcap */
cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE);
cnt->postcap--;
if (debug_level >= CAMERA_DEBUG)
motion_log(0, 0, "%s: post capture %d", __FUNCTION__, cnt->postcap);
} else {
cnt->current_image->flags |= IMAGE_PRECAP;
}

/* Always call motion_detected when we have a motion image */
motion_detected(cnt, cnt->video_dev, cnt->current_image);
} else if (cnt->postcap) {
} else if ((cnt->postcap) &&
(cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) {
/* No motion, doing postcap */
cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE);
cnt->postcap--;
Expand Down Expand Up @@ -1748,7 +1765,7 @@ static void *motion_loop(void *arg)
area_once = cnt->event_nr; /* Fire script only once per event */

if (debug_level >= CAMERA_DEBUG)
motion_log(0, 0, "Motion in area %d detected.\n", z+1);
motion_log(0, 0, "Motion in area %d detected.", z+1);
break;
}
}
Expand Down Expand Up @@ -2561,7 +2578,7 @@ int main (int argc, char **argv)

if (((motion_threads_running == 0) && finish) ||
((motion_threads_running == 0) && (threads_running == 0))) {
if (debug_level >= CAMERA_VERBOSE)
if (debug_level >= CAMERA_ALL)
motion_log(LOG_INFO, 0, "%s: DEBUG-1 threads_running %d motion_threads_running %d "
", finish %d", __FUNCTION__, threads_running, motion_threads_running, finish);
break;
Expand Down Expand Up @@ -2598,7 +2615,7 @@ int main (int argc, char **argv)
}
}

if (debug_level >= CAMERA_VERBOSE)
if (debug_level >= CAMERA_ALL)
motion_log(LOG_INFO, 0, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d",
__FUNCTION__, threads_running, motion_threads_running, finish);
}
Expand Down
8 changes: 4 additions & 4 deletions netcam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam)
{
int loop_counter = 0;

if (debug_level > CAMERA_VERBOSE) {
if (debug_level >= CAMERA_ALL) {
motion_log(0, 0, "%s: Begin", __FUNCTION__);
}

Expand All @@ -1791,7 +1791,7 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam)
return -1;
}

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_ALL)
motion_log(0, 0, "%s: statbuf.st_mtime[%d] != last_st_mtime[%d]",
__FUNCTION__, statbuf.st_mtime, netcam->file->last_st_mtime);

Expand All @@ -1802,7 +1802,7 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam)
return -1;
}

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_ALL)
motion_log(0, 0, "%s: delay waiting new file image ", __FUNCTION__);

//its waits 5seconds - READ_TIMEOUT
Expand Down Expand Up @@ -1885,7 +1885,7 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam)

pthread_mutex_unlock(&netcam->mutex);

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_ALL)
motion_log(0, 0, "%s: End", __FUNCTION__);

return 0;
Expand Down
14 changes: 7 additions & 7 deletions netcam_jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static boolean netcam_fill_input_buffer(j_decompress_ptr cinfo)
src->buffer = (JOCTET *) src->data;
} else {
/* Insert a fake EOI marker - as per jpeglib recommendation */
if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_VERBOSE)
motion_log(LOG_INFO, 0, "%s: **fake EOI inserted**", __FUNCTION__);
src->buffer[0] = (JOCTET) 0xFF;
src->buffer[1] = (JOCTET) JPEG_EOI; /* 0xD9 */
Expand Down Expand Up @@ -178,7 +178,7 @@ static void netcam_error_exit(j_common_ptr cinfo)
/* need to "cleanup" the aborted decompression */
jpeg_destroy (cinfo);

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_VERBOSE)
motion_log(LOG_ERR, 0, "%s: netcam->jpeg_error %d", __FUNCTION__,
netcam->jpeg_error);

Expand Down Expand Up @@ -228,7 +228,7 @@ static void netcam_output_message(j_common_ptr cinfo)
* wrong, and that indicates a network problem rather
* than a problem with the content.
*/
if (debug_level > CAMERA_VERBOSE) {
if (debug_level >= CAMERA_VERBOSE) {
/*
* Format the message according to library standards.
* Write it out to the motion log.
Expand Down Expand Up @@ -299,7 +299,7 @@ static int netcam_init_jpeg(netcam_context_ptr netcam, j_decompress_ptr cinfo)
return NETCAM_GENERAL_ERROR | NETCAM_NOTHING_NEW_ERROR;
}

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_VERBOSE)
motion_log(0, 0, "%s: ***new pic delay successful***", __FUNCTION__);
}

Expand Down Expand Up @@ -337,7 +337,7 @@ static int netcam_init_jpeg(netcam_context_ptr netcam, j_decompress_ptr cinfo)
/* Start the decompressor */
jpeg_start_decompress(cinfo);

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_VERBOSE)
motion_log(LOG_INFO, 0, "%s: jpeg_error %d", __FUNCTION__, netcam->jpeg_error);

return netcam->jpeg_error;
Expand Down Expand Up @@ -408,7 +408,7 @@ static int netcam_image_conv(netcam_context_ptr netcam,
/* rotate as specified */
rotate_map(netcam->cnt, image);

if (debug_level > CAMERA_VERBOSE)
if (debug_level >= CAMERA_VERBOSE)
motion_log(LOG_INFO, 0, "%s: jpeg_error %d", __FUNCTION__,
netcam->jpeg_error);

Expand Down Expand Up @@ -469,7 +469,7 @@ int netcam_proc_jpeg(netcam_context_ptr netcam, unsigned char *image)
"with JPEG image - expected %dx%d, JPEG %dx%d",
" retval %d", __FUNCTION__, netcam->width, netcam->height,
cinfo.output_width, cinfo.output_height, retval);
return retval;
return retval;
}
}

Expand Down

0 comments on commit 4d4740b

Please sign in to comment.