Skip to content

Commit

Permalink
* Input for webcams has to be set to -1 http://www.lavrsen.dk/foswiki…
Browse files Browse the repository at this point in the history
  • Loading branch information
sackmotion committed Feb 3, 2011
1 parent 6d1ce19 commit e3bb21d
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ Bugfixes
* Avoid segfault when motion cannot create a logfile. (Angel Carpintero)
* No mysql_close
http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x11x22x033859
* No PQfinish() (Angel Carpintero)
* Input for webcams has to be set to -1
http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x01x21x162309

3.2.12 Summary of Changes

Expand Down
2 changes: 1 addition & 1 deletion CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ Angel Carpintero
* Only use post capture when we setup to record videos with external pipe or ffmpeg.
* Fixed FFV1 codec encode with ffmpeg.
http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x13x032553

* No PQfinish().

Jared D
* Change bayer2rgb24() to fix a problem with sn9c102 driver
Expand Down
12 changes: 10 additions & 2 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ config_param config_params[] = {
#endif
{
"input",
"# The video input to be used (default: 8)\n"
"# Should normally be set to 0 or 1 for video/TV cards, and 8 for USB cameras",
"# The video input to be used (default: -1)\n"
"# Should normally be set to 0 or 1 for video/TV cards, and -1 for USB cameras",
0,
CONF_OFFSET(input),
copy_int,
Expand Down Expand Up @@ -1398,6 +1398,14 @@ config_param config_params[] = {
"# Additional special conversion specifiers are\n"
"# %n = the number representing the file_type\n"
"# %f = filename with full path\n"
"# Create tables :\n"
"##\n"
"# Mysql\n"
"# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), event_time_stamp timestamp(14));\n"
"#\n"
"# Postgresql\n"
"# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp without time zone, event_time_stamp timestamp without time zone);\n"
"#\n"
"# Default value:\n"
"# insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')",
0,
Expand Down
31 changes: 27 additions & 4 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED,
cnt->conf.database_host, cnt->conf.database_user,
mysql_error(cnt->database));
} else {
mysql_query(cnt->database, sqlquery);
MOTION_LOG(INF, TYPE_DB, NO_ERRNO, "%s: Re-Connection to Mysql database '%s' Succeed",
cnt->conf.database_dbname);
if (mysql_query(cnt->database, sqlquery) != 0) {
int error_code = mysql_errno(cnt->database);
MOTION_LOG(ERR, TYPE_DB, SHOW_ERRNO, "%s: after re-connection Mysql query failed %s error code %d",
mysql_error(cnt->database), error_code);
}
}
}
}
Expand All @@ -168,10 +174,27 @@ static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED,

res = PQexec(cnt->database_pg, sqlquery);

if (PQresultStatus(res) != PGRES_COMMAND_OK) {
MOTION_LOG(ERR, TYPE_DB, SHOW_ERRNO, "%s: PGSQL query failed");
if (PQstatus(cnt->database_pg) == CONNECTION_BAD) {

MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Connection to PostgreSQL database '%s' failed: %s",
cnt->conf.database_dbname, PQerrorMessage(cnt->database_pg));

// This function will close the connection to the server and attempt to reestablish a new connection to the same server,
// using all the same parameters previously used. This may be useful for error recovery if a working connection is lost
PQreset(cnt->database_pg);

if (PQstatus(cnt->database_pg) == CONNECTION_BAD) {
MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Re-Connection to PostgreSQL database '%s' failed: %s",
cnt->conf.database_dbname, PQerrorMessage(cnt->database_pg));
} else {
MOTION_LOG(INF, TYPE_DB, NO_ERRNO, "%s: Re-Connection to PostgreSQL database '%s' Succeed",
cnt->conf.database_dbname);
}

} else if (PQresultStatus(res) != PGRES_COMMAND_OK) {
MOTION_LOG(ERR, TYPE_DB, SHOW_ERRNO, "%s: PGSQL query [%s] failed", sqlquery);
PQclear(res);
}
}
}
#endif /* HAVE_PGSQL */

Expand Down
14 changes: 11 additions & 3 deletions motion-dist.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ v4l2_palette 17
# This is ONLY used for FreeBSD. Leave it commented out for Linux
; tunerdevice /dev/tuner0

# The video input to be used (default: 8)
# Should normally be set to 0 or 1 for video/TV cards, and 8 for USB cameras
input 8
# The video input to be used (default: -1)
# Should normally be set to 0 or 1 for video/TV cards, and -1 for USB cameras
input -1

# The video norm to use (only for video capture and TV tuner cards)
# Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
Expand Down Expand Up @@ -649,6 +649,14 @@ quiet on
# %n = the number representing the file_type
# %f = filename with full path
# Default value:
# Create tables :
##
# Mysql
# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), event_time_stamp timestamp(14));
#
# Postgresql
# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp without time zone, event_time_stamp timestamp without time zone);
#
# insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
; sql_query insert into security(camera, filename, frame, file_type, time_stamp, event_time_stamp) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')

Expand Down
4 changes: 2 additions & 2 deletions motion.1
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ Values: 0 - 255 / Default: 0 (disabled)
The hue level for the video device.
.TP
.B input integer
Values: 0 - 7, 8 = disabled / Default: 8 (disabled)
Values: -1 - 64, -1 = disabled / Default: -1 (disabled)
.br
Input channel to use expressed as an integer number starting from 0. Should normally be set to 1 for video/TV cards, and 8 for USB cameras.
Input channel to use expressed as an integer number starting from -1. Should normally be set to 1 for video/TV cards, and -1 for USB cameras.
.TP
.B ipv6_enabled boolean
Values: on, off / Default: off
Expand Down
4 changes: 3 additions & 1 deletion motion.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,9 @@ static void motion_cleanup(struct context *cnt)
#endif /* HAVE_MYSQL */

#ifdef HAVE_PGSQL

if ((!strcmp(cnt->conf.database_type, "postgresql")) && (cnt->conf.database_dbname)) {
PQfinish(cnt->database_pg);
}
#endif /* HAVE_PGSQL */

#ifdef HAVE_SQLITE3
Expand Down
6 changes: 3 additions & 3 deletions thread1.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# for FreeBSD default is /dev/bktr0
videodevice /dev/video0

# The video input to be used (default: 8)
# Should normally be set to 1 for video/TV cards, and 8 for USB cameras
input 8
# The video input to be used (default: -1)
# Should normally be set to 1 for video/TV cards, and -1 for USB cameras
input -1

# Draw a user defined text on the images using same options as C function strftime(3)
# Default: Not defined = no text
Expand Down
4 changes: 2 additions & 2 deletions thread2.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# for FreeBSD default is /dev/bktr0
videodevice /dev/video1

# The video input to be used (default: 8)
# Should normally be set to 1 for video/TV cards, and 8 for USB cameras
# The video input to be used (default: -1)
# Should normally be set to 1 for video/TV cards, and -1 for USB cameras
input 1

# Draw a user defined text on the images using same options as C function strftime(3)
Expand Down
6 changes: 3 additions & 3 deletions thread3.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# for FreeBSD default is /dev/bktr0
videodevice /dev/video2

# The video input to be used (default: 8)
# Should normally be set to 1 for video/TV cards, and 8 for USB cameras
input 8
# The video input to be used (default: -1)
# Should normally be set to 1 for video/TV cards, and -1 for USB cameras
input -1

# Draw a user defined text on the images using same options as C function strftime(3)
# Default: Not defined = no text
Expand Down
4 changes: 0 additions & 4 deletions video2.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev,
struct v4l2_standard standard;
v4l2_std_id std_id;

/*if (in == IN_DEFAULT)
in = IN_TV;
*/

/* Set the input. */
memset(&input, 0, sizeof (input));
if (in == IN_DEFAULT)
Expand Down

0 comments on commit e3bb21d

Please sign in to comment.