Skip to content

Commit

Permalink
Quick fix to allow use picture_filename preview and fix %f for ext_pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelCarpintero authored and AngelCarpintero committed Sep 24, 2008
1 parent e201628 commit 1b80e57
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
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.61 for motion trunk-r412.
# Generated by GNU Autoconf 2.61 for motion trunk-r426.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Expand Down Expand Up @@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='motion'
PACKAGE_TARNAME='motion'
PACKAGE_VERSION='trunk-r412'
PACKAGE_STRING='motion trunk-r412'
PACKAGE_VERSION='trunk-r426'
PACKAGE_STRING='motion trunk-r426'
PACKAGE_BUGREPORT=''

ac_unique_file="motion.c"
Expand Down Expand Up @@ -1177,7 +1177,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-r412 to adapt to many kinds of systems.
\`configure' configures motion trunk-r426 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1238,7 +1238,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of motion trunk-r412:";;
short | recursive ) echo "Configuration of motion trunk-r426:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1374,7 +1374,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
motion configure trunk-r412
motion configure trunk-r426
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
Expand All @@ -1388,7 +1388,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-r412, which was
It was created by motion $as_me trunk-r426, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -8122,7 +8122,7 @@ exec 6>&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-r412, which was
This file was extended by motion $as_me trunk-r426, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -8171,7 +8171,7 @@ Report bugs to <[email protected]>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
motion config.status trunk-r412
motion config.status trunk-r426
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
Expand Down
25 changes: 12 additions & 13 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static void event_extpipe_end(struct context *cnt, int type ATTRIBUTE_UNUSED,
motion_log(LOG_INFO, 0, "%s: CLOSING: extpipe file desc %d, error state %d",
__FUNCTION__, fileno(cnt->extpipe), ferror(cnt->extpipe));
motion_log(LOG_INFO, 0, "%s: pclose return: %d", __FUNCTION__, pclose(cnt->extpipe));
event(cnt, EVENT_FILECLOSE, NULL, cnt->newfilename, (void *)FTYPE_MPEG, NULL);
event(cnt, EVENT_FILECLOSE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL);
}
}

Expand All @@ -369,7 +369,6 @@ static void event_create_extpipe(struct context *cnt, int type ATTRIBUTE_UNUSED,
{
if ((cnt->conf.useextpipe) && (cnt->conf.extpipe)) {
char stamp[PATH_MAX] = "";
char extpipefilename[PATH_MAX] = "";
const char *moviepath;
/* conf.mpegpath would normally be defined but if someone deleted it by control interface
it is better to revert to the default than fail */
Expand All @@ -382,46 +381,46 @@ static void event_create_extpipe(struct context *cnt, int type ATTRIBUTE_UNUSED,
}

mystrftime(cnt, stamp, sizeof(stamp), moviepath, currenttime_tm, NULL, 0);
snprintf(extpipefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp);
snprintf(cnt->extpipefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp);

/* Open a dummy file to check if path is correct */
if (myfopen(extpipefilename, "w") == NULL) {
if (myfopen(cnt->extpipefilename, "w") == NULL) {
if (errno == ENOENT) {
/* create path for file ... */
if (create_path(extpipefilename) == -1) {
if (create_path(cnt->extpipefilename) == -1) {
motion_log(LOG_ERR, 1, "%s: error opening file %s",
__FUNCTION__, extpipefilename);
__FUNCTION__, cnt->extpipefilename);
return ;
}

/* and retry opening the file (use file_proto) */
if (myfopen(extpipefilename, "w") == NULL) {
if (myfopen(cnt->extpipefilename, "w") == NULL) {
motion_log(LOG_ERR, 1, "%s: error opening file %s",
__FUNCTION__, extpipefilename);
__FUNCTION__, cnt->extpipefilename);
return ;
}

/* Permission denied */
} else if (errno == EACCES) {
motion_log(LOG_ERR, 1, "%s: error opening file %s ... check access "
"rights to target directory", __FUNCTION__, extpipefilename);
"rights to target directory", __FUNCTION__, cnt->extpipefilename);
return ;
} else {
motion_log(LOG_ERR, 1, "%s: error opening file %s", __FUNCTION__, extpipefilename);
motion_log(LOG_ERR, 1, "%s: error opening file %s", __FUNCTION__, cnt->extpipefilename);
}

}

unlink(extpipefilename);
unlink(cnt->extpipefilename);

mystrftime(cnt, stamp, sizeof(stamp), cnt->conf.extpipe, currenttime_tm, extpipefilename, 0);
mystrftime(cnt, stamp, sizeof(stamp), cnt->conf.extpipe, currenttime_tm, cnt->extpipefilename, 0);

if (debug_level >= CAMERA_INFO) {
motion_log(LOG_INFO, 0, "%s: pipe: %s", __FUNCTION__, stamp);
motion_log(LOG_INFO, 0, "%s: cnt->moviefps: %d", __FUNCTION__, cnt->movie_fps);
}

event(cnt, EVENT_FILECREATE, NULL, extpipefilename, (void *)FTYPE_MPEG, NULL);
event(cnt, EVENT_FILECREATE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL);
cnt->extpipe = popen(stamp, "w");

if (cnt->extpipe == NULL) {
Expand Down
1 change: 1 addition & 0 deletions motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ struct context {

short int movie_fps;
char newfilename[PATH_MAX];
char extpipefilename[PATH_MAX];
short int movie_last_shot;

#ifdef HAVE_FFMPEG
Expand Down
26 changes: 15 additions & 11 deletions picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,8 @@ void put_fixed_mask(struct context *cnt, const char *file)
/* save preview_shot */
void preview_save(struct context *cnt)
{
#ifdef HAVE_FFMPEG
int use_imagepath;
int basename_len;
#endif /* HAVE_FFMPEG */
const char *imagepath;
char previewname[PATH_MAX];
char filename[PATH_MAX];
Expand All @@ -667,20 +665,26 @@ void preview_save(struct context *cnt)
/* Set global context to the image we are processing */
cnt->current_image = &cnt->imgs.preview_image;

#ifdef HAVE_FFMPEG
/* Use filename of movie i.o. jpeg_filename when set to 'preview' */
use_imagepath = strcmp(cnt->conf.imagepath, "preview");

if (cnt->ffmpeg_output && !use_imagepath) {
/* Replace avi/mpg with jpg/ppm and keep the rest of the filename */
basename_len = strlen(cnt->newfilename) - 3;
strncpy(previewname, cnt->newfilename, basename_len);

if ( (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))
&& !use_imagepath) {

if (cnt->conf.useextpipe && cnt->extpipe) {
basename_len = strlen(cnt->extpipefilename) + 1;
strncpy(previewname, cnt->extpipefilename, basename_len);
previewname[basename_len - 1] = '.';
} else {
/* Replace avi/mpg with jpg/ppm and keep the rest of the filename */
basename_len = strlen(cnt->newfilename) - 3;
strncpy(previewname, cnt->newfilename, basename_len);
}

previewname[basename_len] = '\0';
strcat(previewname, imageext(cnt));
put_picture(cnt, previewname, cnt->imgs.preview_image.image , FTYPE_IMAGE);
} else
#endif /* HAVE_FFMPEG */
{
} else {
/* Save best preview-shot also when no movies are recorded or imagepath
* is used. Filename has to be generated - nothing available to reuse! */
//printf("preview_shot: different filename or picture only!\n");
Expand Down

0 comments on commit 1b80e57

Please sign in to comment.