From 048791e449a49c632021d993260b0d08d5a2a3ee Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 13 Jun 2014 19:52:34 -0600 Subject: [PATCH 001/233] Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) --- alg.c | 4 +- conf.c | 40 ++- event.c | 4 +- jpegutils.c | 2 +- logger.c | 13 +- motion.c | 24 +- motion.mk808.conf | 738 ++++++++++++++++++++++++++++++++++++++++++++++ netcam.c | 4 +- netcam_rtsp.c | 2 +- stream.c | 2 +- webhttpd.c | 5 +- 11 files changed, 803 insertions(+), 35 deletions(-) create mode 100644 motion.mk808.conf diff --git a/alg.c b/alg.c index 93c260f..343ff47 100644 --- a/alg.c +++ b/alg.c @@ -534,7 +534,7 @@ static int alg_labeling(struct context *cnt) imgs->labels_above = 0; /* Init: 0 means no label set / not checked. */ - memset(labels, 0, width * height * sizeof(labels)); + memset(labels, 0, width * height * sizeof(*labels)); pixelpos = 0; for (iy = 0; iy < height - 1; iy++) { @@ -1363,6 +1363,6 @@ void alg_update_reference_frame(struct context *cnt, int action) /* Copy fresh image */ memcpy(cnt->imgs.ref, cnt->imgs.image_virgin, cnt->imgs.size); /* Reset static objects */ - memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); + memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); } } diff --git a/conf.c b/conf.c index 2da0da6..26585ee 100644 --- a/conf.c +++ b/conf.c @@ -1569,17 +1569,23 @@ static void conf_cmdline(struct context *cnt, int thread) cnt->log_level = (unsigned int)atoi(optarg); break; case 'k': - if (thread == -1) - strcpy(cnt->log_type_str, optarg); - break; + if (thread == -1) { + strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); + cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; + } + break; case 'p': - if (thread == -1) - strcpy(cnt->pid_file, optarg); - break; + if (thread == -1) { + strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); + cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; + } + break; case 'l': - if (thread == -1) - strcpy(cnt->log_file, optarg); - break; + if (thread == -1) { + strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); + cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; + } + break; case 'm': cnt->pause = 1; break; @@ -1868,8 +1874,9 @@ struct context **conf_load(struct context **cnt) conf_cmdline(cnt[0], -1); if (cnt[0]->conf_filename[0]) { /* User has supplied filename on Command-line. */ - strcpy(filename, cnt[0]->conf_filename); - fp = fopen (filename, "r"); + strncpy(filename, cnt[0]->conf_filename, PATH_MAX-1); + filename[PATH_MAX-1] = '\0'; + fp = fopen (filename, "r"); } if (!fp) { /* Command-line didn't work, try current dir. */ @@ -1905,11 +1912,12 @@ struct context **conf_load(struct context **cnt) /* Now we process the motion.conf config file and close it. */ if (fp) { - strcpy(cnt[0]->conf_filename, filename); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing thread 0 - config file %s", - filename); - cnt = conf_process(cnt, fp); - myfclose(fp); + strncpy(cnt[0]->conf_filename, filename, sizeof(cnt[0]->conf_filename) - 1); + cnt[0]->conf_filename[sizeof(cnt[0]->conf_filename) - 1] = '\0'; + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing thread 0 - config file %s", + filename); + cnt = conf_process(cnt, fp); + myfclose(fp); } else { MOTION_LOG(CRT, TYPE_ALL, NO_ERRNO, "%s: Not config file to process using default values"); } diff --git a/event.c b/event.c index e93c8d5..f8a7d28 100644 --- a/event.c +++ b/event.c @@ -416,9 +416,9 @@ static void event_extpipe_end(struct context *cnt, int type ATTRIBUTE_UNUSED, if (cnt->extpipe_open) { cnt->extpipe_open = 0; fflush(cnt->extpipe); - MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO, "%s: CLOSING: extpipe file desc %d, error state %d", + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: CLOSING: extpipe file desc %d, error state %d", fileno(cnt->extpipe), ferror(cnt->extpipe)); - MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO, "%s: pclose return: %d", + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: pclose return: %d", pclose(cnt->extpipe)); event(cnt, EVENT_FILECLOSE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL); } diff --git a/jpegutils.c b/jpegutils.c index 9c9bc44..84caea4 100644 --- a/jpegutils.c +++ b/jpegutils.c @@ -478,7 +478,7 @@ int decode_jpeg_raw (unsigned char *jpeg_data, int len, if (setjmp (jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. */ jpeg_destroy_decompress (&dinfo); - return -1; + return 1; } jpeg_create_decompress (&dinfo); diff --git a/logger.c b/logger.c index f76d2a3..b2e4231 100644 --- a/logger.c +++ b/logger.c @@ -212,11 +212,20 @@ void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, . /* Next add the user's message. */ va_start(ap, fmt); n += vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); + buf[1023] = '\0'; /* If errno_flag is set, add on the library error message. */ if (errno_flag) { - strncat(buf, ": ", 1024 - strlen(buf)); - n += 2; + size_t buf_len = strlen(buf); + + // just knock off 10 characters if we're that close... + if (buf_len + 10 > 1024) { + buf[1024 - 10] = '\0'; + buf_len = 1024 - 10; + } + + strncat(buf, ": ", 1024 - buf_len); + n += 2; /* * This is bad - apparently gcc/libc wants to use the non-standard GNU * version of strerror_r, which doesn't actually put the message into diff --git a/motion.c b/motion.c index 5666770..fc48e64 100644 --- a/motion.c +++ b/motion.c @@ -723,13 +723,13 @@ static int motion_init(struct context *cnt) memset(cnt->imgs.out, 0, cnt->imgs.size); /* contains the moving objects of ref. frame */ - cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); + cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); cnt->imgs.image_virgin = mymalloc(cnt->imgs.size); cnt->imgs.smartmask = mymalloc(cnt->imgs.motionsize); cnt->imgs.smartmask_final = mymalloc(cnt->imgs.motionsize); - cnt->imgs.smartmask_buffer = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.smartmask_buffer)); - cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.labels)); - cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(cnt->imgs.labelsize)); + cnt->imgs.smartmask_buffer = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.smartmask_buffer)); + cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.labels)); + cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(*cnt->imgs.labelsize)); /* Set output picture type */ if (!strcmp(cnt->conf.picture_type, "ppm")) @@ -917,7 +917,7 @@ static int motion_init(struct context *cnt) /* Always initialize smart_mask - someone could turn it on later... */ memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); memset(cnt->imgs.smartmask_final, 255, cnt->imgs.motionsize); - memset(cnt->imgs.smartmask_buffer, 0, cnt->imgs.motionsize*sizeof(cnt->imgs.smartmask_buffer)); + memset(cnt->imgs.smartmask_buffer, 0, cnt->imgs.motionsize * sizeof(*cnt->imgs.smartmask_buffer)); /* Set noise level */ cnt->noise = cnt->conf.noise; @@ -1294,7 +1294,7 @@ static void *motion_loop(void *arg) cnt->current_image->timestamp_tm = old_image->timestamp_tm; cnt->current_image->shot = old_image->shot; cnt->current_image->cent_dist = old_image->cent_dist; - cnt->current_image->flags = old_image->flags; + cnt->current_image->flags = old_image->flags & (~IMAGE_SAVED); cnt->current_image->location = old_image->location; cnt->current_image->total_labels = old_image->total_labels; } @@ -2714,8 +2714,12 @@ int main (int argc, char **argv) cnt_list[i]->threadnr = i ? i : 1; if (strcmp(cnt_list[i]->conf_filename, "")) + { + cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", cnt_list[i]->threadnr, cnt_list[i]->conf_filename); + } MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? @@ -3200,6 +3204,14 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us ++pos_userformat; break; + case 'w': // picture width + sprintf(tempstr, "%d", cnt->imgs.width); + break; + + case 'h': // picture height + sprintf(tempstr, "%d", cnt->imgs.height); + break; + case 'f': // filename -- or %fps if ((*(pos_userformat+1) == 'p') && (*(pos_userformat+2) == 's')) { sprintf(tempstr, "%d", cnt->movie_fps); diff --git a/motion.mk808.conf b/motion.mk808.conf new file mode 100644 index 0000000..ab1289d --- /dev/null +++ b/motion.mk808.conf @@ -0,0 +1,738 @@ +# Rename this distribution example file to motion.conf +# +# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ + + +############################################################ +# Daemon +############################################################ + +# Start in daemon (background) mode and release terminal (default: off) +daemon on + +# File to store the process ID, also called pid file. (default: not defined) +process_id_file /var/run/motion/motion.pid + +############################################################ +# Basic Setup Mode +############################################################ + +# Start in Setup-Mode, daemon disabled. (default: off) +setup_mode off + + +# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) +;logfile /tmp/motion.log + +# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) +log_level 6 + +# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) +log_type all + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video0 + +# v4l2_palette allows to choose preferable palette to be use by motion +# to capture from those supported by your videodevice. (default: 17) +# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and +# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. +# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 +# instead. +# +# Values : +# V4L2_PIX_FMT_SN9C10X : 0 'S910' +# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' +# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' +# V4L2_PIX_FMT_SPCA561 : 3 'S561' +# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' +# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' +# V4L2_PIX_FMT_PAC207 : 6 'P207' +# V4L2_PIX_FMT_PJPG : 7 'PJPG' +# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' +# V4L2_PIX_FMT_JPEG : 9 'JPEG' +# V4L2_PIX_FMT_RGB24 : 10 'RGB3' +# V4L2_PIX_FMT_SPCA501 : 11 'S501' +# V4L2_PIX_FMT_SPCA505 : 12 'S505' +# V4L2_PIX_FMT_SPCA508 : 13 'S508' +# V4L2_PIX_FMT_UYVY : 14 'UYVY' +# V4L2_PIX_FMT_YUYV : 15 'YUYV' +# V4L2_PIX_FMT_YUV422P : 16 '422P' +# V4L2_PIX_FMT_YUV420 : 17 'YU12' +# +v4l2_palette 8 + +# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) +# This is ONLY used for FreeBSD. Leave it commented out for Linux +; tunerdevice /dev/tuner0 + +# 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) +norm 0 + +# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) +frequency 0 + +# Rotate image this number of degrees. The rotation affects all saved images as +# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. +rotate 0 + +# Image width (pixels). Valid range: Camera dependent, default: 352 +#width 640 + +# Image height (pixels). Valid range: Camera dependent, default: 288 +#height 480 + +# Maximum number of frames to be captured per second. +# Valid range: 2-100. Default: 100 (almost no limit). +#framerate 10 + +# Minimum time in seconds between capturing picture frames from the camera. +# Default: 0 = disabled - the capture rate is given by the camera framerate. +# This option is used when you want to capture images at a rate lower than 2 per second. +minimum_frame_time 0 + +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// or file:///) +# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined +; netcam_url value + +# Username and password for network camera (only if required). Default: not defined +# Syntax is user:password +; netcam_userpass value + +# The setting for keep-alive of network socket, should improve performance on compatible net cameras. +# off: The historical implementation using HTTP/1.0, closing the socket after each http request. +# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +# on: Use HTTP/1.1 requests that support keep alive as default. +# Default: off +netcam_keepalive off + +# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". +# If a port number other than 80 is needed, use "http://myproxy:1234". +# Default: not defined +; netcam_proxy value + +# Set less strict jpeg checks for network cameras with a poor/buggy firmware. +# Default: off +netcam_tolerant_check off + +# Let motion regulate the brightness of a video device (default: off). +# The auto_brightness feature uses the brightness option as its target value. +# If brightness is zero auto_brightness will adjust to average brightness value 128. +# Only recommended for cameras without auto brightness +auto_brightness off + +# Set the initial brightness of a video device. +# If auto_brightness is enabled, this value defines the average brightness level +# which Motion will try and adjust to. +# Valid range 0-255, default 0 = disabled +brightness 0 + +# Set the contrast of a video device. +# Valid range 0-255, default 0 = disabled +contrast 0 + +# Set the saturation of a video device. +# Valid range 0-255, default 0 = disabled +saturation 0 + +# Set the hue of a video device (NTSC feature). +# Valid range 0-255, default 0 = disabled +hue 0 + + +############################################################ +# Round Robin (multiple inputs on same video device name) +############################################################ + +# Number of frames to capture in each roundrobin step (default: 1) +roundrobin_frames 1 + +# Number of frames to skip before each roundrobin step (default: 1) +roundrobin_skip 1 + +# Try to filter out noise generated by roundrobin (default: off) +switchfilter off + + +############################################################ +# Motion Detection Settings: +############################################################ + +# Threshold for number of changed pixels in an image that +# triggers motion detection (default: 1500) +threshold 1500 + +# Automatically tune the threshold down if possible (default: off) +threshold_tune off + +# Noise threshold for the motion detection (default: 32) +noise_level 32 + +# Automatically tune the noise threshold (default: on) +noise_tune off + +# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) +# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. +# (l)abeling must only be used once and the 'l' must be the last letter. +# Comment out to disable +#despeckle_filter EedDl + +# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 +# A script (on_area_detected) is started immediately when motion is 4 5 6 +# detected in one of the given areas, but only once during an event. 7 8 9 +# One or more areas can be specified with this option. Take care: This option +# does NOT restrict detection to these areas! (Default: not defined) +; area_detect value + +# PGM file to use as a sensitivity mask. +# Full path name to. (Default: not defined) +; mask_file value + +# Dynamically create a mask file during operation (default: 0) +# Adjust speed of mask changes from 0 (off) to 10 (fast) +smart_mask_speed 0 + +# Ignore sudden massive light intensity changes given as a percentage of the picture +# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled +lightswitch 0 + +# Picture frames must contain motion at least the specified number of frames +# in a row before they are detected as true motion. At the default of 1, all +# motion is detected. Valid range: 1 to thousands, recommended 1-5 +minimum_motion_frames 1 + +# Specifies the number of pre-captured (buffered) pictures from before motion +# was detected that will be output at motion detection. +# Recommended range: 0 to 5 (default: 0) +# Do not use large values! Large values will cause Motion to skip video frames and +# cause unsmooth movies. To smooth movies use larger values of post_capture instead. +pre_capture 0 + +# Number of frames to capture after motion is no longer detected (default: 0) +post_capture 5 + +# Event Gap is the seconds of no motion detection that triggers the end of an event. +# An event is defined as a series of motion images taken within a short timeframe. +# Recommended value is 60 seconds (Default). The value -1 is allowed and disables +# events causing all Motion to be written to one single movie file and no pre_capture. +# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An +# event ends right after no more motion is detected and post_capture is over. +event_gap 60 + +# Maximum length in seconds of a movie +# When value is exceeded a new movie file is created. (Default: 0 = infinite) +max_movie_time 600 + +# Always save images even if there was no motion (default: off) +emulate_motion off + + +############################################################ +# Image File Output +############################################################ + +# Output 'normal' pictures when motion is detected (default: on) +# Valid values: on, off, first, best, center +# When set to 'first', only the first picture of an event is saved. +# Picture with most motion of an event is saved when set to 'best'. +# Picture with motion nearest center of picture is saved when set to 'center'. +# Can be used as preview shot for the corresponding movie. +output_pictures best + +# Output pictures with only the pixels moving object (ghost images) (default: off) +output_debug_pictures off + +# The quality (in percent) to be used by the jpeg compression (default: 75) +quality 75 + +# Type of output images +# Valid values: jpeg, ppm (default: jpeg) +picture_type jpeg + +############################################################ +# FFMPEG related options +# Film (movies) file output, and deinterlacing of the video input +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################ + +# Use ffmpeg to encode movies in realtime (default: off) +ffmpeg_output_movies off + +# Use ffmpeg to make movies with only the pixels moving +# object (ghost images) (default: off) +ffmpeg_output_debug_movies off + +# Use ffmpeg to encode a timelapse movie +# Default value 0 = off - else save frame every Nth second +ffmpeg_timelapse 0 + +# The file rollover mode of the timelapse video +# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual +ffmpeg_timelapse_mode daily + +# Bitrate to be used by the ffmpeg encoder (default: 400000) +# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) +ffmpeg_bps 2000000 + +# Enables and defines variable bitrate for the ffmpeg encoder. +# ffmpeg_bps is ignored if variable bitrate is enabled. +# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, +# or the range 2 - 31 where 2 means best quality and 31 is worst. +ffmpeg_variable_bitrate 0 + +# Codec to used by ffmpeg for the video compression. +# Timelapse mpegs are always made in mpeg1 format independent from this option. +# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. +# mpeg1 - gives you files with extension .mpg +# mpeg4 or msmpeg4 - gives you files with extension .avi +# msmpeg4 is recommended for use with Windows Media Player because +# it requires no installation of codec on the Windows client. +# swf - gives you a flash film with extension .swf +# flv - gives you a flash video with extension .flv +# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) +# mov - QuickTime ( testing ) +# ogg - Ogg/Theora ( testing ) +ffmpeg_video_codec mpeg4 + +# Use ffmpeg to deinterlace video. Necessary if you use an analog camera +# and see horizontal combing on moving objects in video or pictures. +# (default: off) +ffmpeg_deinterlace off + +############################################################ +# SDL Window +############################################################ + +# Number of motion thread to show in SDL Window (default: 0 = disabled) +sdl_threadnr 0 + +############################################################ +# External pipe to video encoder +# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################# + +# Bool to enable or disable extpipe (default: off) +use_extpipe on + +# External program (full path and opts) to pipe raw video to +# Generally, use '-' for STDIN... + +#extpipe x264 - --input-res 640x480 --fps %fps --bitrate 500 --preset ultrafast --quiet -o %f.mp4 + + +############################################################ +# Snapshots (Traditional Periodic Webcam File Output) +############################################################ + +# Make automated snapshot every N seconds (default: 0 = disabled) +snapshot_interval 0 + + +############################################################ +# Text Display +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, \n = new line, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event - do not use with text_event! +# You can put quotation marks around the text to allow +# leading spaces +############################################################ + +# Locate and draw a box around the moving object. +# Valid values: on, off, preview (default: off) +# Set to 'preview' will only draw a box in preview_shot pictures. +locate_motion_mode on + +# Set the look and style of the locate box if enabled. +# Valid values: box, redbox, cross, redcross (default: box) +# Set to 'box' will draw the traditional box. +# Set to 'redbox' will draw a red box. +# Set to 'cross' will draw a little cross to mark center. +# Set to 'redcross' will draw a little red cross to mark center. +locate_motion_style box + +# Draws the timestamp using same options as C function strftime(3) +# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +# Text is placed in lower right corner +text_right %Y-%m-%d\n%T-%q + +# Draw a user defined text on the images using same options as C function strftime(3) +# Default: Not defined = no text +# Text is placed in lower left corner +; text_left CAMERA %t + +# Draw the number of changed pixed on the images (default: off) +# Will normally be set to off except when you setup and adjust the motion settings +# Text is placed in upper right corner +text_changes off + +# This option defines the value of the special event conversion specifier %C +# You can use any conversion specifier in this option except %C. Date and time +# values are from the timestamp of the first image in the current event. +# Default: %Y%m%d%H%M%S +# The idea is that %C can be used filenames and text_left/right for creating +# a unique identifier for each event. +text_event %Y%m%d%H%M%S + +# Draw characters at twice normal size on images. (default: off) +text_double off + + +# Text to include in a JPEG EXIF comment +# May be any text, including conversion specifiers. +# The EXIF timestamp is included independent of this text. +;exif_text %i%J/%K%L + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, movie_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute path. (Default: current working directory) +#target_dir /home/ubuntu/cam0 + +# File path for snapshots (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-snapshot +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot +# File extension .jpg or .ppm is automatically added so do not include this. +# Note: A symbolic link called lastsnap.jpg created in the target_dir will always +# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +snapshot_filename lastsnap + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename %v-%Y%m%d_%H-%M + +# File path for motion triggered ffmpeg films (movies) relative to target_dir +# Default: %v-%Y%m%d%H%M%S +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S +# File extension .mpg or .avi is automatically added so do not include this +# This option was previously called ffmpeg_filename +movie_filename %v-%Y%m%d_%H-%M + +# File path for timelapse movies relative to target_dir +# Default: %Y%m%d-timelapse +# Default value is near equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse +# File extension .mpg is automatically added so do not include this +timelapse_filename %Y%m%d-timelapse + +############################################################ +# Global Network Options +############################################################ +# Enable or disable IPV6 for http control and stream (default: off ) +ipv6_enabled off + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8081 + +# Quality of the jpeg (in percent) images produced (default: 50) +stream_quality 50 + +# Output frames at 1 fps when no motion is detected and increase to the +# rate given by stream_maxrate when motion is detected (default: off) +stream_motion off + +# Maximum framerate for stream streams (default: 1) +stream_maxrate 1 + +# Restrict stream connections to localhost only (default: on) +stream_localhost off + +# Limits the number of images per connection (default: 0 = unlimited) +# Number can be defined by multiplying actual stream rate by desired number of seconds +# Actual stream rate is the smallest of the numbers framerate and stream_maxrate +stream_limit 0 + +# Set the authentication method (default: 0) +# 0 = disabled +# 1 = Basic authentication +# 2 = MD5 digest (the safer authentication) +stream_auth_method 0 + +# Authentication for the stream. Syntax username:password +# Default: not defined (Disabled) +; stream_authentication username:password + + +############################################################ +# HTTP Based Control +############################################################ + +# TCP/IP port for the http server to listen on (default: 0 = disabled) +webcontrol_port 8080 + +# Restrict control connections to localhost only (default: on) +webcontrol_localhost on + +# Output for http server, select off to choose raw text plain (default: on) +webcontrol_html_output on + +# Authentication for the http based control. Syntax username:password +# Default: not defined (Disabled) +; webcontrol_authentication username:password + + +############################################################ +# Tracking (Pan/Tilt) +############################################################# + +# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) +# The generic type enables the definition of motion center and motion size to +# be used with the conversion specifiers for options like on_motion_detected +track_type 0 + +# Enable auto tracking (default: off) +track_auto off + +# Serial port of motor (default: none) +;track_port /dev/ttyS0 + +# Motor number for x-axis (default: 0) +;track_motorx 0 + +# Set motorx reverse (default: 0) +;track_motorx_reverse 0 + +# Motor number for y-axis (default: 0) +;track_motory 1 + +# Set motory reverse (default: 0) +;track_motory_reverse 0 + +# Maximum value on x-axis (default: 0) +;track_maxx 200 + +# Minimum value on x-axis (default: 0) +;track_minx 50 + +# Maximum value on y-axis (default: 0) +;track_maxy 200 + +# Minimum value on y-axis (default: 0) +;track_miny 50 + +# Center value on x-axis (default: 0) +;track_homex 128 + +# Center value on y-axis (default: 0) +;track_homey 128 + +# ID of an iomojo camera if used (default: 0) +track_iomojo_id 0 + +# Angle in degrees the camera moves per step on the X-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_x 10 + +# Angle in degrees the camera moves per step on the Y-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_y 10 + +# Delay to wait for after tracking movement as number +# of picture frames (default: 10) +track_move_wait 10 + +# Speed to set the motor to (stepper motor option) (default: 255) +track_speed 255 + +# Number of steps to make (stepper motor option) (default: 40) +track_stepsize 40 + + +############################################################ +# External Commands, Warnings and Logging: +# You can use conversion specifiers for the on_xxxx commands +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# %f = filename with full path +# %n = number indicating filetype +# Both %f and %n are only defined for on_picture_save, +# on_movie_start and on_movie_end +# Quotation marks round string are allowed. +############################################################ + +# Do not sound beeps when detecting motion (default: on) +# Note: Motion never beeps when running in daemon mode. +quiet on + +# Command to be executed when an event starts. (default: none) +# An event starts at first motion detected after a period of no motion defined by event_gap +; on_event_start value + +# Command to be executed when an event ends after a period of no motion +# (default: none). The period of no motion is defined by option event_gap. +; on_event_end value + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# To give the filename as an argument to a command append it with %f +; on_picture_save value + +# Command to be executed when a motion frame is detected (default: none) +; on_motion_detected value + +# Command to be executed when motion in a predefined area is detected +# Check option 'area_detect'. (default: none) +; on_area_detected value + +# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_start value + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_end value + +# Command to be executed when a camera can't be opened or if it is lost +# NOTE: There is situations when motion don't detect a lost camera! +# It depends on the driver, some drivers dosn't detect a lost camera at all +# Some hangs the motion thread. Some even hangs the PC! (default: none) +; on_camera_lost value + +##################################################################### +# Common Options for database features. +# Options require database options to be active also. +##################################################################### + +# Log to the database when creating motion triggered picture file (default: on) +; sql_log_picture on + +# Log to the database when creating a snapshot image file (default: on) +; sql_log_snapshot on + +# Log to the database when creating motion triggered movie file (default: off) +; sql_log_movie off + +# Log to the database when creating timelapse movies file (default: off) +; sql_log_timelapse off + +# SQL query string that is sent to the database +# Use same conversion specifiers has for text features +# Additional special conversion specifiers are +# %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') + + +############################################################ +# Database Options +############################################################ + +# database type : mysql, postgresql, sqlite3 (default : not defined) +; database_type value + +# database to log to (default: not defined) +; database_dbname value + +# The host on which the database is located (default: localhost) +; database_host value + +# User account name for database (default: not defined) +; database_user value + +# User password for database (default: not defined) +; database_password value + +# Port on which the database is located +# mysql 3306 , postgresql 5432 (default: not defined) +; database_port value + +############################################################ +# Database Options For SQLite3 +############################################################ + +# SQLite3 database (file path) (default: not defined) +; sqlite3_db value + + + +############################################################ +# Video Loopback Device (vloopback project) +############################################################ + +# Output images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; video_pipe value + +# Output motion images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; motion_video_pipe value + + +############################################################## +# Thread config files - One for each camera. +# Except if only one camera - You only need this config file. +# If you have more than one camera you MUST define one thread +# config file for each camera in addition to this config file. +############################################################## + +# Remember: If you have more than one camera you must have one +# thread file for each camera. E.g. 2 cameras requires 3 files: +# This motion.conf file AND thread1.conf and thread2.conf. +# Only put the options that are unique to each camera in the +# thread config files. +; thread /usr/local/etc/thread1.conf +; thread /usr/local/etc/thread2.conf +; thread /usr/local/etc/thread3.conf +; thread /usr/local/etc/thread4.conf + +width 640 +height 480 +framerate 10 +extpipe x264 - --input-res %wx%h --fps %fps --bitrate 500 --preset ultrafast --quiet -o %f.mp4 +target_dir /home/ubuntu/cam0 + diff --git a/netcam.c b/netcam.c index e327a2f..6faa08c 100644 --- a/netcam.c +++ b/netcam.c @@ -2418,6 +2418,7 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; const char *ptr; + int ret = -1; netcam->caps.streaming = NCS_RTSP; netcam->rtsp = rtsp_new_context(); @@ -2470,7 +2471,8 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) * The RTSP context should be all ready to attempt a connection with * the server, so we try .... */ - rtsp_connect(netcam); + ret = rtsp_connect(netcam); + if (ret < 0) return ret; netcam->get_image = netcam_read_rtsp_image; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 1fe1357..87c4fd0 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -189,7 +189,7 @@ int rtsp_connect(netcam_context_ptr netcam) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %d - %s", netcam->rtsp->path, ret, av_err2str(ret)); rtsp_free_context(netcam->rtsp); netcam->rtsp = NULL; - return -1; + return ret; } // fill out stream information diff --git a/stream.c b/stream.c index 1ed082a..624b92b 100644 --- a/stream.c +++ b/stream.c @@ -955,7 +955,7 @@ static void stream_add_client(struct stream *list, int sc) "Cache-Control: no-cache, private\r\n" "Pragma: no-cache\r\n" "Content-Type: multipart/x-mixed-replace; " - "boundary=--BoundaryString\r\n\r\n"; + "boundary=BoundaryString\r\n\r\n"; memset(new, 0, sizeof(struct stream)); new->socket = sc; diff --git a/webhttpd.c b/webhttpd.c index 20fe4e8..0bd0914 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -370,9 +370,8 @@ static void url_decode(char *urlencoded, size_t length) *urldecoded++ = c[1]; } - } else if (*data == '+') { - *urldecoded++ = ' '; - + } else if (*data == '<' || *data == '+' || data == '>') { + *urldecoded++ = ' '; } else { *urldecoded++ = *data; } From 976fe425a52c811acf0805e1fc0b966b2c32a412 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 13 Jun 2014 20:47:13 -0600 Subject: [PATCH 002/233] Removed compiler warnings and small bug fix for webhttpd.c --- CHANGELOG | 8 +- config.h | 128 +++++++++ configure | 252 ++++++++-------- ffmpeg.c | 67 ++--- jpegutils.c | 15 +- logger.c | 8 +- motion-dist.conf | 732 +++++++++++++++++++++++++++++++++++++++++++++++ netcam_ftp.c | 4 +- picture.c | 17 +- stream.c | 12 +- thread1.conf | 57 ++++ thread2.conf | 58 ++++ thread3.conf | 60 ++++ thread4.conf | 62 ++++ track.c | 5 +- webhttpd.c | 10 +- 16 files changed, 1289 insertions(+), 206 deletions(-) create mode 100644 config.h create mode 100644 motion-dist.conf create mode 100644 thread1.conf create mode 100644 thread2.conf create mode 100644 thread3.conf create mode 100644 thread4.conf diff --git a/CHANGELOG b/CHANGELOG index 10ca2c2..6cdff27 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -49,7 +49,13 @@ Features http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) * Added support for ffmpeg 0.11 new API. * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) - + * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) + * Removed compiler warnings: (Mr-Dave) + logger.c,jpegutils.c,netcam_ftp.c,track.c, + picture.c,webhttpd.c,stream.c,ffmpeg.c + * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) + * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) + Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) diff --git a/config.h b/config.h new file mode 100644 index 0000000..c479b73 --- /dev/null +++ b/config.h @@ -0,0 +1,128 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `get_current_dir_name' function. */ +#define HAVE_GET_CURRENT_DIR_NAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_VIDEODEV2_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_VIDEODEV_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have MySQL support */ +/* #undef HAVE_MYSQL */ + +/* Define to 1 if you have PostgreSQL support */ +/* #undef HAVE_PGSQL */ + +/* Define to 1 if you have SDL support */ +#define HAVE_SDL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have SQLITE3 support */ +/* #undef HAVE_SQLITE3 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "motion" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "motion trunkREVUNKNOWN" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "motion" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "trunkREVUNKNOWN" + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `int *', as computed by sizeof. */ +#define SIZEOF_INT_P 4 + +/* The size of `long int', as computed by sizeof. */ +#define SIZEOF_LONG_INT 4 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to 1 if you have av_avformat_alloc_context support */ +/* #undef have_av_avformat_alloc_context */ + +/* Define to 1 if you have av_get_media_type_string support */ +#define have_av_get_media_type_string 1 + +/* Define to 1 if you have av_register_protocol support */ +/* #undef have_av_register_protocol */ + +/* Define to 1 if you have av_register_protocol2 support */ +/* #undef have_av_register_protocol2 */ + +/* Define to 1 if you have avformat_alloc_context support */ +/* #undef have_avformat_alloc_context */ diff --git a/configure b/configure index 57b6bde..b9b0a24 100755 --- a/configure +++ b/configure @@ -1,9 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for motion Git-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0. +# Generated by GNU Autoconf 2.68 for motion trunkREVUNKNOWN. # # -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -132,31 +134,6 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -190,8 +167,7 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" +test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -236,25 +212,21 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -356,14 +328,6 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -485,10 +449,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -523,16 +483,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -544,8 +504,28 @@ else as_mkdir_p=false fi -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -577,8 +557,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Git-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0' -PACKAGE_STRING='motion Git-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0' +PACKAGE_VERSION='trunkREVUNKNOWN' +PACKAGE_STRING='motion trunkREVUNKNOWN' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1160,6 +1140,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1245,7 +1227,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-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0 to adapt to many kinds of systems. +\`configure' configures motion trunkREVUNKNOWN to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1306,7 +1288,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Git-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0:";; + short | recursive ) echo "Configuration of motion trunkREVUNKNOWN:";; esac cat <<\_ACEOF @@ -1454,10 +1436,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Git-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0 -generated by GNU Autoconf 2.69 +motion configure trunkREVUNKNOWN +generated by GNU Autoconf 2.68 -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1533,7 +1515,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - test -x conftest$ac_exeext + $as_test_x conftest$ac_exeext }; then : ac_retval=0 else @@ -1887,8 +1869,7 @@ int main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1904,8 +1885,7 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1931,8 +1911,7 @@ int main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1948,8 +1927,7 @@ int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1983,8 +1961,7 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2056,8 +2033,8 @@ 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-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0, which was -generated by GNU Autoconf 2.69. Invocation command line was +It was created by motion $as_me trunkREVUNKNOWN, which was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2429,7 +2406,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2469,7 +2446,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2522,7 +2499,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2563,7 +2540,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2621,7 +2598,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2665,7 +2642,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3111,7 +3088,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3303,7 +3281,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3343,7 +3321,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3396,7 +3374,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3437,7 +3415,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3495,7 +3473,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3539,7 +3517,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3735,7 +3713,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -5129,7 +5108,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -5195,7 +5174,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -5704,11 +5683,11 @@ else int main () { - +/* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ + /* Ultrix mips cc rejects this. */ typedef int charset[2]; - const charset cs = { 0, 0 }; + const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -5725,9 +5704,8 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this sort of thing. */ - char tx; - char *t = &tx; + { /* SCO 3.2v4 cc rejects this. */ + char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -5743,10 +5721,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; b->j = 5; + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -6506,16 +6484,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -6575,16 +6553,28 @@ else as_mkdir_p=false fi - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -6605,8 +6595,8 @@ 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-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0, which was -generated by GNU Autoconf 2.69. Invocation command line was +This file was extended by motion $as_me trunkREVUNKNOWN, which was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -6667,11 +6657,11 @@ _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-28b7cb2a4297c78b9c08c9ce29a648aeb22120d0 -configured by $0, generated by GNU Autoconf 2.69, +motion config.status trunkREVUNKNOWN +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -6759,7 +6749,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/ffmpeg.c b/ffmpeg.c index 57eeda4..dbcd7ca 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -22,24 +22,11 @@ * that padded with B frames to obtain the correct framerate. */ # define FFMPEG_NO_NONSTD_MPEG1 -# ifdef __GNUC__ -/* #warning is a non-standard gcc extension */ -# warning ************************************************** -# warning Your version of FFmpeg is newer than version 0.4.8 -# warning Newer versions of ffmpeg do not support MPEG1 with -# warning non-standard framerate. MPEG1 will be disabled for -# warning normal video output. You can still use mpeg4 and -# warning and mpeg4ms which are both better in terms of size -# warning and quality. MPEG1 is always used for timelapse. -# warning Please read the Motion Guide for more information. -# warning Note that this is not an error message! -# warning ************************************************** -# endif /* __GNUC__ */ #endif /* LIBAVCODEC_BUILD > 4680 */ -#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR +#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR # if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 -# define GUESS_NO_DEPRECATED +# define GUESS_NO_DEPRECATED # endif #endif @@ -63,7 +50,7 @@ # define AVSTREAM_CODEC_PTR(avs_ptr) (&avs_ptr->codec) #endif /* LIBAVFORMAT_BUILD >= 4629 */ -// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) +// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) // (54*2^16 | 6*2^8 | 100) #if LIBAVFORMAT_BUILD >= 3540580 #define FF_API_NEW_AVIO @@ -92,9 +79,9 @@ static unsigned char mpeg1_trailer[] = {0x00, 0x00, 0x01, 0xb7}; // FFMPEG API changed in 0.8 #if defined FF_API_NEW_AVIO -// TODO +// TODO + - #else /** @@ -281,7 +268,7 @@ static int mpeg1_write_trailer(AVFormatContext *s) void ffmpeg_init() { MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d" - " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, + " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD); av_register_all(); @@ -304,7 +291,7 @@ void ffmpeg_init() /* Register the append file protocol. */ #ifdef have_av_register_protocol2 av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); -#elif defined have_av_register_protocol +#elif defined have_av_register_protocol av_register_protocol(&mpeg1_file_protocol); #else # warning av_register_protocolXXX missing @@ -344,10 +331,10 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) * result in a muxed output file, which isn't appropriate here. */ #ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); + of = guess_format("mpeg1video", NULL, NULL); #else of = av_guess_format("mpeg1video", NULL, NULL); -#endif +#endif /* But we want the trailer to be correctly written. */ if (of) of->write_trailer = mpeg1_write_trailer; @@ -362,14 +349,14 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) ext = ".avi"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("avi", NULL, NULL); -#endif +#endif } else if (strcmp(codec, "msmpeg4") == 0) { ext = ".avi"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("avi", NULL, NULL); #endif /* Manually override the codec id. */ @@ -380,16 +367,16 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) ext = ".swf"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("swf", NULL, NULL); -#endif +#endif } else if (strcmp(codec, "flv") == 0) { ext = ".flv"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("flv", NULL, NULL); -#endif +#endif of->video_codec = CODEC_ID_FLV1; } else if (strcmp(codec, "ffv1") == 0) { ext = ".avi"; @@ -409,7 +396,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) ext = ".mov"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("mov", NULL, NULL); #endif } @@ -500,7 +487,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, /* Create a new video stream and initialize the codecs. */ ffmpeg->video_st = NULL; if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { -#if defined FF_API_NEW_AVIO +#if defined FF_API_NEW_AVIO ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); #else ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); @@ -521,11 +508,11 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); c->codec_id = ffmpeg->oc->oformat->video_codec; -#if LIBAVCODEC_VERSION_MAJOR < 53 +#if LIBAVCODEC_VERSION_MAJOR < 53 c->codec_type = CODEC_TYPE_VIDEO; #else c->codec_type = AVMEDIA_TYPE_VIDEO; -#endif +#endif is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; if (strcmp(ffmpeg_video_codec, "ffv1") == 0) @@ -865,11 +852,11 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { /* Raw video case. The API will change slightly in the near future for that. */ #ifdef FFMPEG_AVWRITEFRAME_NEWAPI -# if LIBAVCODEC_VERSION_MAJOR < 53 +# if LIBAVCODEC_VERSION_MAJOR < 53 pkt.flags |= PKT_FLAG_KEY; # else - pkt.flags |= AV_PKT_FLAG_KEY; -# endif + pkt.flags |= AV_PKT_FLAG_KEY; +# endif pkt.data = (uint8_t *)pic; pkt.size = sizeof(AVPicture); ret = av_write_frame(ffmpeg->oc, &pkt); @@ -883,10 +870,10 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) pkt.data = ffmpeg->video_outbuf; pkt.size = ffmpeg->video_outbuf_size; - out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), + out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), &pkt, pic, &got_packet_ptr); if (out_size < 0) - // Error encondig + // Error encondig out_size = 0; else out_size = pkt.size; @@ -905,11 +892,11 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) -# if LIBAVCODEC_VERSION_MAJOR < 53 +# if LIBAVCODEC_VERSION_MAJOR < 53 pkt.flags |= PKT_FLAG_KEY; # else pkt.flags |= AV_PKT_FLAG_KEY; -# endif +# endif pkt.data = ffmpeg->video_outbuf; pkt.size = out_size; diff --git a/jpegutils.c b/jpegutils.c index 84caea4..8998034 100644 --- a/jpegutils.c +++ b/jpegutils.c @@ -491,9 +491,9 @@ int decode_jpeg_raw (unsigned char *jpeg_data, int len, */ jpeg_read_header (&dinfo, TRUE); dinfo.raw_data_out = TRUE; -#if JPEG_LIB_VERSION >= 70 +#if JPEG_LIB_VERSION >= 70 dinfo.do_fancy_upsampling = FALSE; -#endif +#endif dinfo.out_color_space = JCS_YCbCr; dinfo.dct_method = JDCT_IFAST; guarantee_huff_tables(&dinfo); @@ -584,9 +584,9 @@ int decode_jpeg_raw (unsigned char *jpeg_data, int len, if (field > 0) { jpeg_read_header (&dinfo, TRUE); dinfo.raw_data_out = TRUE; -#if JPEG_LIB_VERSION >= 70 +#if JPEG_LIB_VERSION >= 70 dinfo.do_fancy_upsampling = FALSE; -#endif +#endif dinfo.out_color_space = JCS_YCbCr; dinfo.dct_method = JDCT_IFAST; jpeg_start_decompress (&dinfo); @@ -770,7 +770,7 @@ int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, unsigned int height, unsigned char *raw0, unsigned char *raw1, unsigned char *raw2) { - int numfields, hsf[3], field, yl, yc, xsl, xsc, xs, xd, hdown; + int numfields, field, yl, yc, xsl, xsc, xs, xd, hdown; unsigned int x, y, vsf[3]; JSAMPROW row0[16] = { buf0[0], buf0[1], buf0[2], buf0[3], @@ -805,7 +805,7 @@ int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, dinfo.raw_data_out = TRUE; #if JPEG_LIB_VERSION >= 70 dinfo.do_fancy_upsampling = FALSE; -#endif +#endif dinfo.out_color_space = JCS_GRAYSCALE; dinfo.dct_method = JDCT_IFAST; @@ -818,7 +818,6 @@ int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, guarantee_huff_tables(&dinfo); jpeg_start_decompress (&dinfo); - hsf[0] = 1; hsf[1] = 1; hsf[2] = 1; vsf[0]= 1; vsf[1] = 1; vsf[2] = 1; /* Height match image height or be exact twice the image height. */ @@ -874,7 +873,7 @@ int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, dinfo.raw_data_out = TRUE; #if JPEG_LIB_VERSION >= 70 dinfo.do_fancy_upsampling = FALSE; -#endif +#endif dinfo.out_color_space = JCS_GRAYSCALE; dinfo.dct_method = JDCT_IFAST; jpeg_start_decompress (&dinfo); diff --git a/logger.c b/logger.c index b2e4231..aa47753 100644 --- a/logger.c +++ b/logger.c @@ -217,7 +217,7 @@ void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, . /* If errno_flag is set, add on the library error message. */ if (errno_flag) { size_t buf_len = strlen(buf); - + // just knock off 10 characters if we're that close... if (buf_len + 10 > 1024) { buf[1024 - 10] = '\0'; @@ -232,15 +232,9 @@ void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, . * my buffer :-(. I have put in a 'hack' to get around this. */ #if defined(XSI_STRERROR_R) -#warning "************************************" -#warning "* Using XSI-COMPLIANT strerror_r() *" -#warning "************************************" /* XSI-compliant strerror_r() */ strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */ #else -#warning "************************************" -#warning "* Using GNU-COMPLIANT strerror_r() *" -#warning "************************************" /* GNU-specific strerror_r() */ strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf)); #endif diff --git a/motion-dist.conf b/motion-dist.conf new file mode 100644 index 0000000..30b094f --- /dev/null +++ b/motion-dist.conf @@ -0,0 +1,732 @@ +# Rename this distribution example file to motion.conf +# +# This config file was generated by motion trunkREVUNKNOWN + + +############################################################ +# Daemon +############################################################ + +# Start in daemon (background) mode and release terminal (default: off) +daemon on + +# File to store the process ID, also called pid file. (default: not defined) +process_id_file /var/run/motion/motion.pid + +############################################################ +# Basic Setup Mode +############################################################ + +# Start in Setup-Mode, daemon disabled. (default: off) +setup_mode off + + +# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) +;logfile /tmp/motion.log + +# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) +log_level 6 + +# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) +log_type all + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video0 + +# v4l2_palette allows to choose preferable palette to be use by motion +# to capture from those supported by your videodevice. (default: 17) +# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and +# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. +# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 +# instead. +# +# Values : +# V4L2_PIX_FMT_SN9C10X : 0 'S910' +# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' +# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' +# V4L2_PIX_FMT_SPCA561 : 3 'S561' +# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' +# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' +# V4L2_PIX_FMT_PAC207 : 6 'P207' +# V4L2_PIX_FMT_PJPG : 7 'PJPG' +# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' +# V4L2_PIX_FMT_JPEG : 9 'JPEG' +# V4L2_PIX_FMT_RGB24 : 10 'RGB3' +# V4L2_PIX_FMT_SPCA501 : 11 'S501' +# V4L2_PIX_FMT_SPCA505 : 12 'S505' +# V4L2_PIX_FMT_SPCA508 : 13 'S508' +# V4L2_PIX_FMT_UYVY : 14 'UYVY' +# V4L2_PIX_FMT_YUYV : 15 'YUYV' +# V4L2_PIX_FMT_YUV422P : 16 '422P' +# V4L2_PIX_FMT_YUV420 : 17 'YU12' +# +v4l2_palette 17 + +# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) +# This is ONLY used for FreeBSD. Leave it commented out for Linux +; tunerdevice /dev/tuner0 + +# 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) +norm 0 + +# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) +frequency 0 + +# Rotate image this number of degrees. The rotation affects all saved images as +# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. +rotate 0 + +# Image width (pixels). Valid range: Camera dependent, default: 352 +width 320 + +# Image height (pixels). Valid range: Camera dependent, default: 288 +height 240 + +# Maximum number of frames to be captured per second. +# Valid range: 2-100. Default: 100 (almost no limit). +framerate 2 + +# Minimum time in seconds between capturing picture frames from the camera. +# Default: 0 = disabled - the capture rate is given by the camera framerate. +# This option is used when you want to capture images at a rate lower than 2 per second. +minimum_frame_time 0 + +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///) +# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined +; netcam_url value + +# Username and password for network camera (only if required). Default: not defined +# Syntax is user:password +; netcam_userpass value + +# The setting for keep-alive of network socket, should improve performance on compatible net cameras. +# off: The historical implementation using HTTP/1.0, closing the socket after each http request. +# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +# on: Use HTTP/1.1 requests that support keep alive as default. +# Default: off +netcam_keepalive off + +# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". +# If a port number other than 80 is needed, use "http://myproxy:1234". +# Default: not defined +; netcam_proxy value + +# Set less strict jpeg checks for network cameras with a poor/buggy firmware. +# Default: off +netcam_tolerant_check off + +# Let motion regulate the brightness of a video device (default: off). +# The auto_brightness feature uses the brightness option as its target value. +# If brightness is zero auto_brightness will adjust to average brightness value 128. +# Only recommended for cameras without auto brightness +auto_brightness off + +# Set the initial brightness of a video device. +# If auto_brightness is enabled, this value defines the average brightness level +# which Motion will try and adjust to. +# Valid range 0-255, default 0 = disabled +brightness 0 + +# Set the contrast of a video device. +# Valid range 0-255, default 0 = disabled +contrast 0 + +# Set the saturation of a video device. +# Valid range 0-255, default 0 = disabled +saturation 0 + +# Set the hue of a video device (NTSC feature). +# Valid range 0-255, default 0 = disabled +hue 0 + + +############################################################ +# Round Robin (multiple inputs on same video device name) +############################################################ + +# Number of frames to capture in each roundrobin step (default: 1) +roundrobin_frames 1 + +# Number of frames to skip before each roundrobin step (default: 1) +roundrobin_skip 1 + +# Try to filter out noise generated by roundrobin (default: off) +switchfilter off + + +############################################################ +# Motion Detection Settings: +############################################################ + +# Threshold for number of changed pixels in an image that +# triggers motion detection (default: 1500) +threshold 1500 + +# Automatically tune the threshold down if possible (default: off) +threshold_tune off + +# Noise threshold for the motion detection (default: 32) +noise_level 32 + +# Automatically tune the noise threshold (default: on) +noise_tune on + +# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) +# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. +# (l)abeling must only be used once and the 'l' must be the last letter. +# Comment out to disable +despeckle_filter EedDl + +# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 +# A script (on_area_detected) is started immediately when motion is 4 5 6 +# detected in one of the given areas, but only once during an event. 7 8 9 +# One or more areas can be specified with this option. Take care: This option +# does NOT restrict detection to these areas! (Default: not defined) +; area_detect value + +# PGM file to use as a sensitivity mask. +# Full path name to. (Default: not defined) +; mask_file value + +# Dynamically create a mask file during operation (default: 0) +# Adjust speed of mask changes from 0 (off) to 10 (fast) +smart_mask_speed 0 + +# Ignore sudden massive light intensity changes given as a percentage of the picture +# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled +lightswitch 0 + +# Picture frames must contain motion at least the specified number of frames +# in a row before they are detected as true motion. At the default of 1, all +# motion is detected. Valid range: 1 to thousands, recommended 1-5 +minimum_motion_frames 1 + +# Specifies the number of pre-captured (buffered) pictures from before motion +# was detected that will be output at motion detection. +# Recommended range: 0 to 5 (default: 0) +# Do not use large values! Large values will cause Motion to skip video frames and +# cause unsmooth movies. To smooth movies use larger values of post_capture instead. +pre_capture 0 + +# Number of frames to capture after motion is no longer detected (default: 0) +post_capture 0 + +# Event Gap is the seconds of no motion detection that triggers the end of an event. +# An event is defined as a series of motion images taken within a short timeframe. +# Recommended value is 60 seconds (Default). The value -1 is allowed and disables +# events causing all Motion to be written to one single movie file and no pre_capture. +# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An +# event ends right after no more motion is detected and post_capture is over. +event_gap 60 + +# Maximum length in seconds of a movie +# When value is exceeded a new movie file is created. (Default: 0 = infinite) +max_movie_time 0 + +# Always save images even if there was no motion (default: off) +emulate_motion off + + +############################################################ +# Image File Output +############################################################ + +# Output 'normal' pictures when motion is detected (default: on) +# Valid values: on, off, first, best, center +# When set to 'first', only the first picture of an event is saved. +# Picture with most motion of an event is saved when set to 'best'. +# Picture with motion nearest center of picture is saved when set to 'center'. +# Can be used as preview shot for the corresponding movie. +output_pictures on + +# Output pictures with only the pixels moving object (ghost images) (default: off) +output_debug_pictures off + +# The quality (in percent) to be used by the jpeg compression (default: 75) +quality 75 + +# Type of output images +# Valid values: jpeg, ppm (default: jpeg) +picture_type jpeg + +############################################################ +# FFMPEG related options +# Film (movies) file output, and deinterlacing of the video input +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################ + +# Use ffmpeg to encode movies in realtime (default: off) +ffmpeg_output_movies on + +# Use ffmpeg to make movies with only the pixels moving +# object (ghost images) (default: off) +ffmpeg_output_debug_movies off + +# Use ffmpeg to encode a timelapse movie +# Default value 0 = off - else save frame every Nth second +ffmpeg_timelapse 0 + +# The file rollover mode of the timelapse video +# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual +ffmpeg_timelapse_mode daily + +# Bitrate to be used by the ffmpeg encoder (default: 400000) +# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) +ffmpeg_bps 500000 + +# Enables and defines variable bitrate for the ffmpeg encoder. +# ffmpeg_bps is ignored if variable bitrate is enabled. +# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, +# or the range 2 - 31 where 2 means best quality and 31 is worst. +ffmpeg_variable_bitrate 0 + +# Codec to used by ffmpeg for the video compression. +# Timelapse mpegs are always made in mpeg1 format independent from this option. +# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. +# mpeg1 - gives you files with extension .mpg +# mpeg4 or msmpeg4 - gives you files with extension .avi +# msmpeg4 is recommended for use with Windows Media Player because +# it requires no installation of codec on the Windows client. +# swf - gives you a flash film with extension .swf +# flv - gives you a flash video with extension .flv +# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) +# mov - QuickTime ( testing ) +# ogg - Ogg/Theora ( testing ) +ffmpeg_video_codec mpeg4 + +# Use ffmpeg to deinterlace video. Necessary if you use an analog camera +# and see horizontal combing on moving objects in video or pictures. +# (default: off) +ffmpeg_deinterlace off + +############################################################ +# SDL Window +############################################################ + +# Number of motion thread to show in SDL Window (default: 0 = disabled) +sdl_threadnr 0 + +############################################################ +# External pipe to video encoder +# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################# + +# Bool to enable or disable extpipe (default: off) +use_extpipe off + +# External program (full path and opts) to pipe raw video to +# Generally, use '-' for STDIN... +;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps + + + +############################################################ +# Snapshots (Traditional Periodic Webcam File Output) +############################################################ + +# Make automated snapshot every N seconds (default: 0 = disabled) +snapshot_interval 0 + + +############################################################ +# Text Display +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, \n = new line, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event - do not use with text_event! +# You can put quotation marks around the text to allow +# leading spaces +############################################################ + +# Locate and draw a box around the moving object. +# Valid values: on, off, preview (default: off) +# Set to 'preview' will only draw a box in preview_shot pictures. +locate_motion_mode off + +# Set the look and style of the locate box if enabled. +# Valid values: box, redbox, cross, redcross (default: box) +# Set to 'box' will draw the traditional box. +# Set to 'redbox' will draw a red box. +# Set to 'cross' will draw a little cross to mark center. +# Set to 'redcross' will draw a little red cross to mark center. +locate_motion_style box + +# Draws the timestamp using same options as C function strftime(3) +# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +# Text is placed in lower right corner +text_right %Y-%m-%d\n%T-%q + +# Draw a user defined text on the images using same options as C function strftime(3) +# Default: Not defined = no text +# Text is placed in lower left corner +; text_left CAMERA %t + +# Draw the number of changed pixed on the images (default: off) +# Will normally be set to off except when you setup and adjust the motion settings +# Text is placed in upper right corner +text_changes off + +# This option defines the value of the special event conversion specifier %C +# You can use any conversion specifier in this option except %C. Date and time +# values are from the timestamp of the first image in the current event. +# Default: %Y%m%d%H%M%S +# The idea is that %C can be used filenames and text_left/right for creating +# a unique identifier for each event. +text_event %Y%m%d%H%M%S + +# Draw characters at twice normal size on images. (default: off) +text_double off + + +# Text to include in a JPEG EXIF comment +# May be any text, including conversion specifiers. +# The EXIF timestamp is included independent of this text. +;exif_text %i%J/%K%L + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, movie_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute path. (Default: current working directory) +target_dir /usr/local/apache2/htdocs/cam1 + +# File path for snapshots (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-snapshot +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot +# File extension .jpg or .ppm is automatically added so do not include this. +# Note: A symbolic link called lastsnap.jpg created in the target_dir will always +# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +snapshot_filename %v-%Y%m%d%H%M%S-snapshot + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename %v-%Y%m%d%H%M%S-%q + +# File path for motion triggered ffmpeg films (movies) relative to target_dir +# Default: %v-%Y%m%d%H%M%S +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S +# File extension .mpg or .avi is automatically added so do not include this +# This option was previously called ffmpeg_filename +movie_filename %v-%Y%m%d%H%M%S + +# File path for timelapse movies relative to target_dir +# Default: %Y%m%d-timelapse +# Default value is near equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse +# File extension .mpg is automatically added so do not include this +timelapse_filename %Y%m%d-timelapse + +############################################################ +# Global Network Options +############################################################ +# Enable or disable IPV6 for http control and stream (default: off ) +ipv6_enabled off + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8081 + +# Quality of the jpeg (in percent) images produced (default: 50) +stream_quality 50 + +# Output frames at 1 fps when no motion is detected and increase to the +# rate given by stream_maxrate when motion is detected (default: off) +stream_motion off + +# Maximum framerate for stream streams (default: 1) +stream_maxrate 1 + +# Restrict stream connections to localhost only (default: on) +stream_localhost on + +# Limits the number of images per connection (default: 0 = unlimited) +# Number can be defined by multiplying actual stream rate by desired number of seconds +# Actual stream rate is the smallest of the numbers framerate and stream_maxrate +stream_limit 0 + +# Set the authentication method (default: 0) +# 0 = disabled +# 1 = Basic authentication +# 2 = MD5 digest (the safer authentication) +stream_auth_method 0 + +# Authentication for the stream. Syntax username:password +# Default: not defined (Disabled) +; stream_authentication username:password + + +############################################################ +# HTTP Based Control +############################################################ + +# TCP/IP port for the http server to listen on (default: 0 = disabled) +webcontrol_port 8080 + +# Restrict control connections to localhost only (default: on) +webcontrol_localhost on + +# Output for http server, select off to choose raw text plain (default: on) +webcontrol_html_output on + +# Authentication for the http based control. Syntax username:password +# Default: not defined (Disabled) +; webcontrol_authentication username:password + + +############################################################ +# Tracking (Pan/Tilt) +############################################################# + +# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) +# The generic type enables the definition of motion center and motion size to +# be used with the conversion specifiers for options like on_motion_detected +track_type 0 + +# Enable auto tracking (default: off) +track_auto off + +# Serial port of motor (default: none) +;track_port /dev/ttyS0 + +# Motor number for x-axis (default: 0) +;track_motorx 0 + +# Set motorx reverse (default: 0) +;track_motorx_reverse 0 + +# Motor number for y-axis (default: 0) +;track_motory 1 + +# Set motory reverse (default: 0) +;track_motory_reverse 0 + +# Maximum value on x-axis (default: 0) +;track_maxx 200 + +# Minimum value on x-axis (default: 0) +;track_minx 50 + +# Maximum value on y-axis (default: 0) +;track_maxy 200 + +# Minimum value on y-axis (default: 0) +;track_miny 50 + +# Center value on x-axis (default: 0) +;track_homex 128 + +# Center value on y-axis (default: 0) +;track_homey 128 + +# ID of an iomojo camera if used (default: 0) +track_iomojo_id 0 + +# Angle in degrees the camera moves per step on the X-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_x 10 + +# Angle in degrees the camera moves per step on the Y-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_y 10 + +# Delay to wait for after tracking movement as number +# of picture frames (default: 10) +track_move_wait 10 + +# Speed to set the motor to (stepper motor option) (default: 255) +track_speed 255 + +# Number of steps to make (stepper motor option) (default: 40) +track_stepsize 40 + + +############################################################ +# External Commands, Warnings and Logging: +# You can use conversion specifiers for the on_xxxx commands +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# %f = filename with full path +# %n = number indicating filetype +# Both %f and %n are only defined for on_picture_save, +# on_movie_start and on_movie_end +# Quotation marks round string are allowed. +############################################################ + +# Do not sound beeps when detecting motion (default: on) +# Note: Motion never beeps when running in daemon mode. +quiet on + +# Command to be executed when an event starts. (default: none) +# An event starts at first motion detected after a period of no motion defined by event_gap +; on_event_start value + +# Command to be executed when an event ends after a period of no motion +# (default: none). The period of no motion is defined by option event_gap. +; on_event_end value + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# To give the filename as an argument to a command append it with %f +; on_picture_save value + +# Command to be executed when a motion frame is detected (default: none) +; on_motion_detected value + +# Command to be executed when motion in a predefined area is detected +# Check option 'area_detect'. (default: none) +; on_area_detected value + +# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_start value + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_end value + +# Command to be executed when a camera can't be opened or if it is lost +# NOTE: There is situations when motion don't detect a lost camera! +# It depends on the driver, some drivers dosn't detect a lost camera at all +# Some hangs the motion thread. Some even hangs the PC! (default: none) +; on_camera_lost value + +##################################################################### +# Common Options for database features. +# Options require database options to be active also. +##################################################################### + +# Log to the database when creating motion triggered picture file (default: on) +; sql_log_picture on + +# Log to the database when creating a snapshot image file (default: on) +; sql_log_snapshot on + +# Log to the database when creating motion triggered movie file (default: off) +; sql_log_movie off + +# Log to the database when creating timelapse movies file (default: off) +; sql_log_timelapse off + +# SQL query string that is sent to the database +# Use same conversion specifiers has for text features +# Additional special conversion specifiers are +# %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') + + +############################################################ +# Database Options +############################################################ + +# database type : mysql, postgresql, sqlite3 (default : not defined) +; database_type value + +# database to log to (default: not defined) +; database_dbname value + +# The host on which the database is located (default: localhost) +; database_host value + +# User account name for database (default: not defined) +; database_user value + +# User password for database (default: not defined) +; database_password value + +# Port on which the database is located +# mysql 3306 , postgresql 5432 (default: not defined) +; database_port value + +############################################################ +# Database Options For SQLite3 +############################################################ + +# SQLite3 database (file path) (default: not defined) +; sqlite3_db value + + + +############################################################ +# Video Loopback Device (vloopback project) +############################################################ + +# Output images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; video_pipe value + +# Output motion images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; motion_video_pipe value + + +############################################################## +# Thread config files - One for each camera. +# Except if only one camera - You only need this config file. +# If you have more than one camera you MUST define one thread +# config file for each camera in addition to this config file. +############################################################## + +# Remember: If you have more than one camera you must have one +# thread file for each camera. E.g. 2 cameras requires 3 files: +# This motion.conf file AND thread1.conf and thread2.conf. +# Only put the options that are unique to each camera in the +# thread config files. +; thread /usr/local/etc/thread1.conf +; thread /usr/local/etc/thread2.conf +; thread /usr/local/etc/thread3.conf +; thread /usr/local/etc/thread4.conf + diff --git a/netcam_ftp.c b/netcam_ftp.c index 0a129b2..7a0451f 100644 --- a/netcam_ftp.c +++ b/netcam_ftp.c @@ -790,10 +790,10 @@ int ftp_get_socket(ftp_context_pointer ctxt) */ int ftp_send_type(ftp_context_pointer ctxt, char type) { - char buf[100], utype; + char buf[100]; int len, res; - utype = toupper(type); + toupper(type); /* Assure transfer will be in "image" mode. */ snprintf(buf, sizeof(buf), "TYPE I\r\n"); len = strlen(buf); diff --git a/picture.c b/picture.c index 196f220..9284280 100644 --- a/picture.c +++ b/picture.c @@ -177,7 +177,7 @@ static void put_direntry(struct tiff_writing *into, const char *data, unsigned l } else { /* Longer entries are stored out-of-line */ unsigned offset = into->data_offset; - + while ((offset & 0x03) != 0) { /* Alignment */ into->base[offset] = 0; offset ++; @@ -324,7 +324,7 @@ static void put_jpeg_exif(j_compress_ptr cinfo, JOCTET *marker = malloc(buffer_size); memcpy(marker, exif_marker_start, 14); /* EXIF and TIFF headers */ - + struct tiff_writing writing = (struct tiff_writing) { .base = marker + 6, /* base address for intra-TIFF offsets */ .buf = marker + 14, /* current write position */ @@ -338,10 +338,10 @@ static void put_jpeg_exif(j_compress_ptr cinfo, if (description) put_stringentry(&writing, TIFF_TAG_IMAGE_DESCRIPTION, description, 0); - + if (datetime) put_stringentry(&writing, TIFF_TAG_DATETIME, datetime, 1); - + if (ifd1_tagcount > 0) { /* Offset of IFD1 - TIFF header + IFD0 size. */ unsigned ifd1_offset = 8 + 6 + ( 12 * ifd0_tagcount ); @@ -369,10 +369,10 @@ static void put_jpeg_exif(j_compress_ptr cinfo, if (datetime) put_stringentry(&writing, EXIF_TAG_ORIGINAL_DATETIME, datetime, 1); - + if (box) put_subjectarea(&writing, box); - + if (subtime) put_stringentry(&writing, EXIF_TAG_ORIGINAL_DATETIME_SS, subtime, 0); @@ -394,7 +394,7 @@ static void put_jpeg_exif(j_compress_ptr cinfo, if (description) free(description); - + free(marker); } @@ -679,7 +679,6 @@ static void put_ppm_bgr24_file(FILE *picture, unsigned char *image, int width, i unsigned char *u = image + width * height; unsigned char *v = u + (width * height) / 4; int r, g, b; - int warningkiller; unsigned char rgb[3]; /* @@ -722,7 +721,7 @@ static void put_ppm_bgr24_file(FILE *picture, unsigned char *image, int width, i v++; } /* ppm is rgb not bgr */ - warningkiller = fwrite(rgb, 1, 3, picture); + fwrite(rgb, 1, 3, picture); } if (y & 1) { u -= width / 2; diff --git a/stream.c b/stream.c index 624b92b..a073617 100644 --- a/stream.c +++ b/stream.c @@ -242,7 +242,8 @@ static void* handle_basic_auth(void* param) pthread_exit(NULL); Error: - write(p->sock, request_auth_response_template, strlen (request_auth_response_template)); + if (write(p->sock, request_auth_response_template, strlen (request_auth_response_template)) < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 1:handle_basic_auth"); Invalid_Request: close(p->sock); @@ -569,8 +570,10 @@ static void* handle_md5_digest(void* param) "Content-Length: %Zu\r\n\r\n", request_auth_response_template, server_nonce, KEEP_ALIVE_TIMEOUT, strlen(auth_failed_html_template)); - write(p->sock, buffer, strlen(buffer)); - write(p->sock, auth_failed_html_template, strlen(auth_failed_html_template)); + if (write(p->sock, buffer, strlen(buffer)) < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 1:handle_md5_digest"); + if (write(p->sock, auth_failed_html_template, strlen(auth_failed_html_template)) < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 2:handle_md5_digest"); } // OK - Access @@ -607,7 +610,8 @@ static void* handle_md5_digest(void* param) if(server_pass) free(server_pass); - write(p->sock, internal_error_template, strlen(internal_error_template)); + if (write(p->sock, internal_error_template, strlen(internal_error_template)) < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 3:handle_md5_digest"); Invalid_Request: close(p->sock); diff --git a/thread1.conf b/thread1.conf new file mode 100644 index 0000000..fd702b1 --- /dev/null +++ b/thread1.conf @@ -0,0 +1,57 @@ +# /usr/local/etc/thread1.conf +# +# This config file was generated by motion trunkREVUNKNOWN + + + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video0 + +# 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 +# Text is placed in lower left corner +text_left CAMERA 1 + + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, mpeg_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute patch. (Default: current working directory) +target_dir /usr/local/apache2/htdocs/cam1 + + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8081 + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# The filename of the picture is appended as an argument for the command. +on_picture_save /usr/local/motion-extras/camparse1.pl + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# Filename of movie is appended as an argument for the command. +on_movie_end /usr/local/motion-extras/mpegparse1.pl diff --git a/thread2.conf b/thread2.conf new file mode 100644 index 0000000..30f3423 --- /dev/null +++ b/thread2.conf @@ -0,0 +1,58 @@ +# /usr/local/etc/thread2.conf +# +# This config file was generated by motion trunkREVUNKNOWN + + + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video1 + +# 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 +# Text is placed in lower left corner +text_left CAMERA 2 + + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, mpeg_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute patch. (Default: current working directory) +target_dir /usr/local/apache2/htdocs/cam2 + + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8082 + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# The filename of the picture is appended as an argument for the command. +on_picture_save /usr/local/motion-extras/camparse2.pl + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# Filename of movie is appended as an argument for the command. +on_movie_end /usr/local/motion-extras/mpegparse2.pl + diff --git a/thread3.conf b/thread3.conf new file mode 100644 index 0000000..f66adaa --- /dev/null +++ b/thread3.conf @@ -0,0 +1,60 @@ +# /usr/local/etc/thread3.conf +# +# This config file was generated by motion trunkREVUNKNOWN + + + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video2 + +# 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 +# Text is placed in lower left corner +text_left CAMERA 3 + + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, mpeg_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute patch. (Default: current working directory) +target_dir /usr/local/apache2/htdocs/cam3 + + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8083 + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# The filename of the picture is appended as an argument for the command. +on_picture_save /usr/local/motion-extras/camparse3.pl + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# Filename of movie is appended as an argument for the command. +on_movie_end /usr/local/motion-extras/mpegparse3.pl + + + diff --git a/thread4.conf b/thread4.conf new file mode 100644 index 0000000..2462161 --- /dev/null +++ b/thread4.conf @@ -0,0 +1,62 @@ +# /usr/local/etc/thread4.conf +# +# This config file was generated by motion trunkREVUNKNOWN + +########################################################### +# Capture device options +############################################################ + +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) +# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined +netcam_url http://192.168.1.6:8093/ + +# The setting for keep-alive of network socket, should improve performance on compatible net cameras. +# off: The historical implementation using HTTP/1.0, closing the socket after each http request. +# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +# on: Use HTTP/1.1 requests that support keep alive as default. +# Default: off +netcam_keepalive force + +# Set less strict jpeg checks for network cameras with a poor/buggy firmware. +# Default: off +netcam_tolerant_check on + +# Draw a user defined text on the images using same options as C function strftime(3) +# Default: Not defined = no text +# Text is placed in lower left corner +text_left CAMERA 4 + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, mpeg_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute patch. (Default: current working directory) +target_dir /usr/local/apache2/htdocs/cam4 + + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8084 + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# The filename of the picture is appended as an argument for the command. +on_picture_save /usr/local/motion-extras/camparse4.pl + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# Filename of movie is appended as an argument for the command. +on_movie_end /usr/local/motion-extras/mpegparse4.pl + diff --git a/track.c b/track.c index 91e89d7..0d7e3b3 100644 --- a/track.c +++ b/track.c @@ -563,7 +563,6 @@ static unsigned int servo_status(struct context *cnt, unsigned int motor) static unsigned int servo_center(struct context *cnt, int x_offset, int y_offset) { - unsigned int ret = 0; int x_offset_abs; int y_offset_abs; @@ -591,7 +590,7 @@ static unsigned int servo_center(struct context *cnt, int x_offset, int y_offset if (x_offset_abs <= cnt->track.maxx && x_offset_abs >= cnt->track.minx) { /* Set Speed , TODO : it should be done only when speed changes */ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); - ret = servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_ABSOLUTE, x_offset_abs); + servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_ABSOLUTE, x_offset_abs); } /* y-axis */ @@ -603,7 +602,7 @@ static unsigned int servo_center(struct context *cnt, int x_offset, int y_offset if (y_offset_abs <= cnt->track.maxy && y_offset_abs >= cnt->track.minx) { /* Set Speed , TODO : it should be done only when speed changes */ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); - ret = servo_command(cnt, cnt->track.motory, SERVO_COMMAND_ABSOLUTE, y_offset_abs); + servo_command(cnt, cnt->track.motory, SERVO_COMMAND_ABSOLUTE, y_offset_abs); } return cnt->track.move_wait; diff --git a/webhttpd.c b/webhttpd.c index 0bd0914..f7449df 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -281,6 +281,8 @@ static void send_template_raw(int client_socket, char *res) { ssize_t nwrite = 0; nwrite = write_nonblock(client_socket, res, strlen(res)); + if (nwrite < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); } /** @@ -290,6 +292,9 @@ static void send_template_end_client(int client_socket) { ssize_t nwrite = 0; nwrite = write_nonblock(client_socket, end_template, strlen(end_template)); + if (nwrite < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); + } /** @@ -303,6 +308,9 @@ static void response_client(int client_socket, const char *template, char *back) send_template(client_socket, back); send_template_end_client(client_socket); } + if (nwrite < 0) + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); + } /** @@ -370,7 +378,7 @@ static void url_decode(char *urlencoded, size_t length) *urldecoded++ = c[1]; } - } else if (*data == '<' || *data == '+' || data == '>') { + } else if (*data == '<' || *data == '+' || *data == '>') { *urldecoded++ = ' '; } else { *urldecoded++ = *data; From b6f8c443f39d573db5ea18f4deb82aeee39c3610 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 13 Jun 2014 22:46:41 -0600 Subject: [PATCH 003/233] RTSP and Configure revisions --- CHANGELOG | 4 + INSTALL | 38 ++- configure | 209 +++++++++------- configure.in => configure.ac | 97 +++++--- netcam.c | 454 +++++++++++++++++++---------------- netcam_rtsp.c | 379 +++++++++++++++-------------- netcam_rtsp.h | 15 +- 7 files changed, 660 insertions(+), 536 deletions(-) rename configure.in => configure.ac (94%) diff --git a/CHANGELOG b/CHANGELOG index 6cdff27..055c375 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -55,6 +55,10 @@ Features picture.c,webhttpd.c,stream.c,ffmpeg.c * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) + * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) + * Resolve additional compiler warnings in ffmpeg (Mr-Dave) + * Revised INSTALL with samples(Mr-Dave) + * Revisions for RTSP and code standard.(Mr-Dave) Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/INSTALL b/INSTALL index 5063740..8f49abd 100644 --- a/INSTALL +++ b/INSTALL @@ -1,16 +1,36 @@ -Very simple: +Required Packages: + sudo apt-get install autoconf automake build-essential libjpeg-turbo8-dev libzip-dev -type: +Obtain source code (via git) + sudo apt-get install git + cd ~ + git clone {https://github.com/your favorite fork} - ./configure +To rebuild the motion configure file use + autoreconf -followed by: +Optional: With FFMPEG support: + Build FFMPEG via their instructions - make + Change to location of the motion source code + cd ~/motion -And + Configure with manually built ffmpeg which installs to ~/bin and ~/ffmpeg_build + Basic + ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include - make install + With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG + ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + + With extra libraries for ffmpeg and install to ~/motion_build + ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + +With APT versions of ffmpeg libraries + sudo apt-get install libavformat-dev libavcodec-dev - -Next read the README +Without any FFMPEG support or just any installed version of FFMPEG + ./configure + +Once configured type: + make + make install diff --git a/configure b/configure index b9b0a24..a997f79 100755 --- a/configure +++ b/configure @@ -666,6 +666,7 @@ with_jpeg_turbo with_jpeg_mmx with_ffmpeg with_ffmpeg_headers +with_ffmpeg_libs with_sqlite3 with_mysql with_mysql_lib @@ -1326,6 +1327,8 @@ Optional Packages: --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. + --with-ffmpeg-libs=libs Specify the extra libs for ffmpeg + --without-sqlite3 Disable sqlite3 support in motion. --without-mysql Disable mysql support in motion. @@ -1534,43 +1537,6 @@ fi } # ac_fn_c_try_link -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes @@ -1613,6 +1579,43 @@ fi } # ac_fn_c_try_run +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using @@ -4279,6 +4282,18 @@ if test "${with_ffmpeg_headers+set}" = set; then : fi +# +# ffmpeg custom extra libraries +# +FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz " + +# Check whether --with-ffmpeg-libs was given. +if test "${with_ffmpeg_libs+set}" = set; then : + withval=$with_ffmpeg_libs; FFMPEG_EXTRALIBS="$withval" + +fi + + # # --without-ffmpeg or with-ffmpeg=no # @@ -4364,51 +4379,63 @@ $as_echo "not found" >&6; } fi fi + # # Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found # +AVFORMAT_DIR="" + if test "${FFMPEG_OK}" = "found"; then if test "${FFMPEG_HEADERS_DIR}" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 $as_echo_n "checking for ffmpeg headers in ${FFMPEG_DIR}... " >&6; } - else + AVFORMAT_DIR="${FFMPEG_DIR}" + else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}" >&5 $as_echo_n "checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}... " >&6; } FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" + AVFORMAT_DIR="${FFMPEG_DIR}" fi if test -f ${FFMPEG_DIR}/include/avformat.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 $as_echo "found ${FFMPEG_DIR}/include/avformat.h" >&6; } FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" + AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" elif test -f ${FFMPEG_DIR}/avformat.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 $as_echo "found ${FFMPEG_DIR}/avformat.h" >&6; } FFMPEG_CFLAGS="-I${FFMPEG_DIR}" + AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; } FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" + AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 $as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; } FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5 $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; } FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/libavformat/avformat.h" >&5 $as_echo "found ${FFMPEG_DIR}/libavformat/avformat.h" >&6; } FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" AVFORMAT="-I{FFMPEG_DIR}/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } FFMPEG_OK="no_found" + AVFORMAT_DIR="avformat.h" echo "**********************************************" echo "* avformat.h not found: *" echo "* ALL FFMPEG FEATURES DISABLED *" @@ -4423,15 +4450,49 @@ $as_echo "not found" >&6; } # If ffmpeg libs and headers have been found # - if test "${FFMPEG_OK}" = "found"; then - TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavformat -lavcodec -lavutil -lm -lz" + if test "${FFMPEG_OK}" = "found"; then + TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" FFMPEG_OBJ="ffmpeg.o" - RTPS_OBJ="netcam_rtsp.o" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking avformat" >&5 +$as_echo_n "checking avformat... " >&6; } + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + #include <${AVFORMAT_DIR}> + int main(void){ + if (LIBAVFORMAT_VERSION_MAJOR >= 55) return -1; + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: version previous to 55" >&5 +$as_echo "version previous to 55" >&6; } +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: version 55 or higher" >&5 +$as_echo "version 55 or higher" >&6; } + TEMP_CFLAGS="${TEMP_CFLAGS} -DFFMPEG_V55" + RTPS_OBJ="netcam_rtsp.o" + + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 @@ -4439,20 +4500,19 @@ $as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS + CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" + LIBS="$TEMP_LIBS" - CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - URLProtocol test_file_protocol; - int main(void){ - test_file_protocol.url_read = file_protocol.url_read; - return 0; - } + #include <${AVFORMAT_DIR}> + URLProtocol test_file_protocol; + int main(void){ + test_file_protocol.url_read = file_protocol.url_read; + return 0; + } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -4460,16 +4520,16 @@ if ac_fn_c_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi fi fi @@ -6017,43 +6077,6 @@ LIBS="${TEMP_LIBS}" LDFLAGS="${TEMP_LDFLAGS}" -ac_fn_c_check_func "$LINENO" "avformat_alloc_context" "ac_cv_func_avformat_alloc_context" -if test "x$ac_cv_func_avformat_alloc_context" = xyes; then : - -$as_echo "#define have_avformat_alloc_context 1" >>confdefs.h - -fi - -ac_fn_c_check_func "$LINENO" "av_avformat_alloc_context" "ac_cv_func_av_avformat_alloc_context" -if test "x$ac_cv_func_av_avformat_alloc_context" = xyes; then : - -$as_echo "#define have_av_avformat_alloc_context 1" >>confdefs.h - -fi - -ac_fn_c_check_func "$LINENO" "av_register_protocol2" "ac_cv_func_av_register_protocol2" -if test "x$ac_cv_func_av_register_protocol2" = xyes; then : - -$as_echo "#define have_av_register_protocol2 1" >>confdefs.h - -fi - -ac_fn_c_check_func "$LINENO" "av_register_protocol" "ac_cv_func_av_register_protocol" -if test "x$ac_cv_func_av_register_protocol" = xyes; then : - -$as_echo "#define have_av_register_protocol 1" >>confdefs.h - -fi - -ac_fn_c_check_func "$LINENO" "av_get_media_type_string" "ac_cv_func_av_get_media_type_string" -if test "x$ac_cv_func_av_get_media_type_string" = xyes; then : - -$as_echo "#define have_av_get_media_type_string 1" >>confdefs.h - -fi - - - # # Add the right exec path for rc scripts # diff --git a/configure.in b/configure.ac similarity index 94% rename from configure.in rename to configure.ac index f551e9a..ad54e6b 100644 --- a/configure.in +++ b/configure.ac @@ -398,6 +398,16 @@ AC_ARG_WITH(ffmpeg_headers, FFMPEG_HEADERS_DIR="$withval" ) +# +# ffmpeg custom extra libraries +# +FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz " +AC_ARG_WITH(ffmpeg-libs, +[ --with-ffmpeg-libs[=libs] Specify the extra libs for ffmpeg + ], +FFMPEG_EXTRALIBS="$withval" +) + # # --without-ffmpeg or with-ffmpeg=no # @@ -471,42 +481,54 @@ else fi fi + # # Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found # +AVFORMAT_DIR="" + if test "${FFMPEG_OK}" = "found"; then if test "${FFMPEG_HEADERS_DIR}" = "yes"; then AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_DIR}) - else + AVFORMAT_DIR="${FFMPEG_DIR}" + else AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_HEADERS_DIR}) FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" + AVFORMAT_DIR="${FFMPEG_DIR}" fi if test -f ${FFMPEG_DIR}/include/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/include/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" + AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" elif test -f ${FFMPEG_DIR}/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}" + AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" + AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/libavformat/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" AVFORMAT="-I{FFMPEG_DIR}/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" else AC_MSG_RESULT(not found) FFMPEG_OK="no_found" + AVFORMAT_DIR="avformat.h" echo "**********************************************" echo "* avformat.h not found: *" echo "* ALL FFMPEG FEATURES DISABLED *" @@ -521,43 +543,57 @@ if test "${FFMPEG_OK}" = "found"; then # If ffmpeg libs and headers have been found # - if test "${FFMPEG_OK}" = "found"; then - TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavformat -lavcodec -lavutil -lm -lz" + if test "${FFMPEG_OK}" = "found"; then + TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" FFMPEG_OBJ="ffmpeg.o" AC_SUBST(FFMPEG_OBJ) - RTPS_OBJ="netcam_rtsp.o" - AC_SUBST(RTPS_OBJ) + AC_MSG_CHECKING(avformat) + AC_RUN_IFELSE([AC_LANG_SOURCE([ + [ + #include <${AVFORMAT_DIR}> + int main(void){ + if (LIBAVFORMAT_VERSION_MAJOR >= 55) return -1; + return 0; + } + ]])], + [AC_MSG_RESULT(version previous to 55)], + [ + AC_MSG_RESULT(version 55 or higher) + TEMP_CFLAGS="${TEMP_CFLAGS} -DFFMPEG_V55" + RTPS_OBJ="netcam_rtsp.o" + AC_SUBST(RTPS_OBJ) + ] + ) AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS - - CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" + CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" + LIBS="$TEMP_LIBS" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - [ - #include - URLProtocol test_file_protocol; - int main(void){ - test_file_protocol.url_read = file_protocol.url_read; - return 0; - } - ]])], - [AC_MSG_RESULT(yes)], - [ - AC_MSG_RESULT(no) - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" - ] - ) - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + [ + #include <${AVFORMAT_DIR}> + URLProtocol test_file_protocol; + int main(void){ + test_file_protocol.url_read = file_protocol.url_read; + return 0; + } + ]])], + [AC_MSG_RESULT(yes)], + [ + AC_MSG_RESULT(no) + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" + ] + ) + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi fi fi @@ -752,7 +788,7 @@ PGSQL_SUPPORT="no" PGSQL_HEADERS="yes" PGSQL_LIBS="yes" -AC_DEFUN(PGSQL_INC_CHK,[if test -r $i$1/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i$1]) +AC_DEFUN([PGSQL_INC_CHK],[if test -r $i$1/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i$1]) AC_ARG_WITH(pgsql, [ --without-pgsql Disable PostgreSQL support in motion. @@ -1217,13 +1253,6 @@ LIBS="${TEMP_LIBS}" LDFLAGS="${TEMP_LDFLAGS}" -AC_CHECK_FUNC(avformat_alloc_context, AC_DEFINE([have_avformat_alloc_context],1,[Define to 1 if you have avformat_alloc_context support])) -AC_CHECK_FUNC(av_avformat_alloc_context, AC_DEFINE([have_av_avformat_alloc_context],1,[Define to 1 if you have av_avformat_alloc_context support])) -AC_CHECK_FUNC(av_register_protocol2, AC_DEFINE([have_av_register_protocol2],1,[Define to 1 if you have av_register_protocol2 support])) -AC_CHECK_FUNC(av_register_protocol, AC_DEFINE([have_av_register_protocol],1,[Define to 1 if you have av_register_protocol support])) -AC_CHECK_FUNC(av_get_media_type_string, AC_DEFINE([have_av_get_media_type_string],1,[Define to 1 if you have av_get_media_type_string support])) - - # # Add the right exec path for rc scripts # diff --git a/netcam.c b/netcam.c index 6faa08c..554da65 100644 --- a/netcam.c +++ b/netcam.c @@ -45,7 +45,7 @@ #include #include "netcam_ftp.h" -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 #include "netcam_rtsp.h" #endif @@ -149,21 +149,21 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) { char *s; int i; -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 const char *re = "(http|ftp|mjpg|rtsp)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; #else const char *re = "(http|ftp|mjpg)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; -#endif +#endif regex_t pattbuf; regmatch_t matches[10]; - if (!strncmp(text_url, "file", 4)) + if (!strncmp(text_url, "file", 4)) re = "(file)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]*)(:([0-9]*))?($|(/[^:][/-_.a-z0-9]+))"; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Entry netcam_url_parse data %s", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Entry netcam_url_parse data %s", text_url); memset(parse_url, 0, sizeof(struct url_t)); @@ -211,10 +211,10 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) parse_url->port = 80; else if (!strcmp(parse_url->service, "ftp")) parse_url->port = 21; -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 else if (!strcmp(parse_url->service, "rtsp") && parse_url->port == 0) parse_url->port = 554; -#endif +#endif } regfree(&pattbuf); @@ -313,7 +313,7 @@ static long netcam_check_content_length(char *header) " Content-Length but value %ld", length); } - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length %ld", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length %ld", length); return length; @@ -341,7 +341,7 @@ static int netcam_check_keepalive(char *header) return -1; /* We do not detect the second field or other case mixes at present. */ - if (content_type) + if (content_type) free(content_type); return 1; @@ -368,11 +368,11 @@ static int netcam_check_close(char *header) if (!header_process(header, "Connection", http_process_type, &type)) return -1; - + if (!strcmp(type, "close")) /* strcmp returns 0 for match. */ ret = 1; - - if (type) + + if (type) free(type); return ret; @@ -403,7 +403,7 @@ static int netcam_check_content_type(char *header) if (!header_process(header, "Content-type", http_process_type, &content_type)) return -1; - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-type %s", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-type %s", content_type); if (!strcmp(content_type, "image/jpeg")) { @@ -442,7 +442,7 @@ static int netcam_read_next_header(netcam_context_ptr netcam) char *header; /* Return if not connected */ - if (netcam->sock == -1) + if (netcam->sock == -1) return -1; /* * We are expecting a header which *must* contain a mime-type of @@ -465,12 +465,12 @@ static int netcam_read_next_header(netcam_context_ptr netcam) if (retval != HG_OK) { /* Header reported as not-OK, check to see if it's null. */ if (strlen(header) == 0) { - MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " + MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " "streaming mode (1). Null header."); } else { /* Header is not null. Output it in case it's a new camera with unknown headers. */ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " - "streaming mode (1). Unknown header '%s'", + "streaming mode (1). Unknown header '%s'", header); } @@ -490,7 +490,7 @@ static int netcam_read_next_header(netcam_context_ptr netcam) retval = header_get(netcam, &header, HG_NONE); if (retval != HG_OK) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header (2)"); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header (2)"); free(header); return -1; } @@ -512,16 +512,16 @@ static int netcam_read_next_header(netcam_context_ptr netcam) netcam->receiving->content_length = retval; } else { netcam->receiving->content_length = 0; - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length 0"); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length 0"); free(header); return -1; - } - } + } + } free(header); } - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Found image header record"); + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Found image header record"); free(header); return 0; @@ -592,11 +592,11 @@ static int netcam_read_first_header(netcam_context_ptr netcam) while (1) { /* 'Do forever' */ ret = header_get(netcam, &header, HG_NONE); - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received first header ('%s')", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received first header ('%s')", header); if (ret != HG_OK) { - MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header (%s)", + MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header (%s)", header); free(header); return -1; @@ -609,15 +609,15 @@ static int netcam_read_first_header(netcam_context_ptr netcam) free(header); if (netcam->connect_keepalive) { - /* - * Cannot unset netcam->cnt->conf.netcam_keepalive as it is assigned const - * But we do unset the netcam keepalive flag which was set in netcam_start + /* + * Cannot unset netcam->cnt->conf.netcam_keepalive as it is assigned const + * But we do unset the netcam keepalive flag which was set in netcam_start * This message is logged as Information as it would be useful to know - * if your netcam often returns bad HTTP result codes. + * if your netcam often returns bad HTTP result codes. */ netcam->connect_keepalive = FALSE; free((void *)netcam->cnt->conf.netcam_keepalive); - netcam->cnt->conf.netcam_keepalive = strdup("off"); + netcam->cnt->conf.netcam_keepalive = strdup("off"); MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag" "due to apparent closed HTTP connection."); } @@ -643,18 +643,18 @@ static int netcam_read_first_header(netcam_context_ptr netcam) */ switch (ret) { case 1: /* Not streaming */ - if (netcam->connect_keepalive) - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " + if (netcam->connect_keepalive) + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " "(keep-alive set)"); else - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " "(keep-alive not set)"); netcam->caps.streaming = NCS_UNSUPPORTED; break; case 2: /* Streaming */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera"); + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera"); netcam->caps.streaming = NCS_MULTIPART; @@ -687,7 +687,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized content type"); free(header); return -1; - + } } else if ((ret = (int) netcam_check_content_length(header)) >= 0) { MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Content-length present"); @@ -695,7 +695,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) if (ret > 0) { netcam->caps.content_length = 1; /* Set flag */ netcam->receiving->content_length = ret; - } else { + } else { netcam->receiving->content_length = 0; MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-length 0"); retval = -2; @@ -704,18 +704,18 @@ static int netcam_read_first_header(netcam_context_ptr netcam) /* Note that we have received a Keep-Alive header, and thus the socket can be left open. */ aliveflag = TRUE; netcam->keepalive_thisconn = TRUE; - /* - * This flag will not be set when a Streaming cam is in use, but that - * does not matter as the test below looks at Streaming state also. + /* + * This flag will not be set when a Streaming cam is in use, but that + * does not matter as the test below looks at Streaming state also. */ } else if (netcam_check_close(header) == TRUE) { /* Note that we have received a Connection: close header. */ closeflag = TRUE; - /* - * This flag is acted upon below. - * Changed criterion and moved up from below to catch headers that cause returns. + /* + * This flag is acted upon below. + * Changed criterion and moved up from below to catch headers that cause returns. */ - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Found Conn: close header ('%s')", + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Found Conn: close header ('%s')", header); } free(header); @@ -723,7 +723,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) free(header); if (netcam->caps.streaming == NCS_UNSUPPORTED && netcam->connect_keepalive) { - + /* If we are a non-streaming (ie. Jpeg) netcam and keepalive is configured. */ if (aliveflag) { @@ -738,22 +738,22 @@ static int netcam_read_first_header(netcam_context_ptr netcam) netcam->cnt->conf.netcam_keepalive = strdup("off"); } else { /* - * If not a streaming cam, and keepalive is set, and the flag shows we + * If not a streaming cam, and keepalive is set, and the flag shows we * did not see a Keep-Alive field returned from netcam and a Close field. * Not quite sure what the correct course of action is here. In for testing. - */ + */ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Both 'Connection: Keep-Alive' and " "'Connection: close' header received. Motion continues unchanged."); } } else { - /* - * aliveflag && !closeflag + /* + * aliveflag && !closeflag * - * If not a streaming cam, and keepalive is set, and the flag shows we + * If not a streaming cam, and keepalive is set, and the flag shows we * just got a Keep-Alive field returned from netcam and no Close field. * No action, as this is the normal case. In debug we print a notification. */ - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received a Keep-Alive field in this" "set of headers."); } @@ -770,17 +770,17 @@ static int netcam_read_first_header(netcam_context_ptr netcam) netcam->cnt->conf.netcam_keepalive = strdup("off"); } else { /* - * If not a streaming cam, and keepalive is set, and the flag shows we + * If not a streaming cam, and keepalive is set, and the flag shows we * did not see a Keep-Alive field returned from netcam nor a Close field. * Not quite sure what the correct course of action is here. In for testing. - */ + */ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: No 'Connection: Keep-Alive' nor 'Connection: close'" " header received.\n Motion continues unchanged."); } - } else { - /* - * !aliveflag & closeflag - * If not a streaming cam, and keepalive is set, and the flag shows we + } else { + /* + * !aliveflag & closeflag + * If not a streaming cam, and keepalive is set, and the flag shows we * received a 'Connection: close' field returned from netcam. It is not likely * we will get a Keep-Alive and Close header together - this is picked up by * the test code above. @@ -805,11 +805,11 @@ static int netcam_read_first_header(netcam_context_ptr netcam) free((void *)netcam->cnt->conf.netcam_keepalive); netcam->cnt->conf.netcam_keepalive = strdup("off"); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag because" - " 'Connection: close' header received.\n Netcam does not support " + " 'Connection: close' header received.\n Netcam does not support " "Keep-Alive. Motion continues in non-Keep-Alive."); } else { netcam->keepalive_timeup = TRUE; /* We will close and re-open keep-alive */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "Keep-Alive has reached end of valid period.\n" + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "Keep-Alive has reached end of valid period.\n" "Motion will close netcam, then resume Keep-Alive with a new socket."); } } @@ -873,7 +873,7 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) /* Assure any previous connection has been closed - IF we are not in keepalive. */ if (!netcam->connect_keepalive) { - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam " + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam " "since keep-alive not set."); netcam_disconnect(netcam); @@ -891,13 +891,13 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) } else if (netcam->sock == -1) { /* We are in keepalive mode, check for invalid socket. */ /* Must be first time, or closed, create a new socket. */ if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with keepalive set, invalid socket." + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with keepalive set, invalid socket." "This could be the first time. Creating a new one failed."); return -1; } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: with keepalive set, invalid socket." - "This could be first time, created a new one with fd %d", + "This could be first time, created a new one with fd %d", netcam->sock); /* Record that this connection has not yet received a Keep-Alive header. */ @@ -909,7 +909,7 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) return -1; } - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE is %s", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE is %s", optval ? "ON":"OFF"); /* Set the option active. */ @@ -922,9 +922,9 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE set on socket."); - } - - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: re-using socket %d since keepalive is set.", + } + + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: re-using socket %d since keepalive is set.", netcam->sock); /* Lookup the hostname given in the netcam URL. */ @@ -976,7 +976,7 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) /* If the connect failed with anything except EINPROGRESS, error. */ if ((ret < 0) && (back_err != EINPROGRESS)) { if (!err_flag) - MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect() failed (%d)", + MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect() failed (%d)", back_err); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (4)"); @@ -995,9 +995,9 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) if (ret == 0) { /* 0 means timeout. */ if (!err_flag) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: timeout on connect()"); - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (2)"); - + netcam_disconnect(netcam); return -1; } @@ -1062,7 +1062,7 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) real_alloc += NETCAM_BUFFSIZE; new_size = buff->size + real_alloc; - + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", (int) buff->used, (int) buff->size, (int) buff->used, new_size); @@ -1321,9 +1321,9 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) * as 'latest', and make the buffer previously in 'latest' become * the new 'receiving'. */ - if (gettimeofday(&curtime, NULL) < 0) + if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* @@ -1336,7 +1336,7 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } netcam->last_image = curtime; @@ -1362,7 +1362,7 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) "netcam since keep-alive not set."); netcam_disconnect(netcam); - } + } MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: leaving netcam connected."); } @@ -1403,9 +1403,9 @@ static int netcam_http_request(netcam_context_ptr netcam) * safe to include it as part of this loop * (Not always true now Keep-Alive is implemented). */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: about to try to connect, time #%d", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: about to try to connect, time #%d", ix); - + if (netcam_connect(netcam, 0) != 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "Failed to open camera - check your config " "and that netcamera is online"); @@ -1468,9 +1468,9 @@ static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) netcam->response->buffer_left = retval; netcam->response->buffer_pos = netcam->response->buffer; - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Refilled buffer with [%d]" - " bytes from the network.", retval); + " bytes from the network.", retval); return retval; } @@ -1478,7 +1478,7 @@ static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) /** * netcam_read_mjpg_jpeg * - * This routine reads from a netcam using a MJPG-chunk based + * This routine reads from a netcam using a MJPG-chunk based * protocol, used by Linksys WVC200 for example. * This implementation has been made by reverse-engineering * the protocol, so it may contain bugs and should be considered as @@ -1488,7 +1488,7 @@ static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) * * The stream consists of JPG pictures, spanned across multiple * MJPG chunks (in general 3 chunks, altough that's not guaranteed). - * + * * Each data chunk can range from 1 to 65535 bytes + a header, altough * i have not seen anything bigger than 20000 bytes + a header. * @@ -1538,7 +1538,7 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) read_bytes += retval; - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] header bytes.", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] header bytes.", read_bytes, sizeof(mh)); /* If we don't have received a full header, refill our buffer. */ @@ -1572,26 +1572,26 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) mh.mh_chunksize - read_bytes); read_bytes += retval; MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] chunk bytes," - " [%d/%d] total", read_bytes, mh.mh_chunksize, + " [%d/%d] total", read_bytes, mh.mh_chunksize, buffer->used + read_bytes, mh.mh_framesize); if (retval < (int) (mh.mh_chunksize - read_bytes)) { /* MOTION_LOG(EMG, TYPE_NETCAM, NO_ERRNO, "Chunk incomplete, going to refill."); */ if (netcam_mjpg_buffer_refill(netcam) < 0) return -1; - + } } buffer->used += read_bytes; MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Chunk complete," - " buffer used [%d] bytes.", buffer->used); + " buffer used [%d] bytes.", buffer->used); /* Is our JPG image complete ? */ if (mh.mh_framesize == buffer->used) { MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Image complete," " buffer used [%d] bytes.", buffer->used); - break; + break; } /* MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Rlen now at [%d] bytes", rlen); */ } @@ -1601,9 +1601,9 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) * as 'latest', and make the buffer previously in 'latest' become * the new 'receiving'. */ - if (gettimeofday(&curtime, NULL) < 0) + if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* @@ -1616,7 +1616,7 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } netcam->last_image = curtime; @@ -1676,9 +1676,9 @@ static int netcam_read_ftp_jpeg(netcam_context_ptr netcam) buffer->used += len; } while (len > 0); - if (gettimeofday(&curtime, NULL) < 0) + if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* * Calculate our "running average" time for this netcam's @@ -1690,7 +1690,7 @@ static int netcam_read_ftp_jpeg(netcam_context_ptr netcam) (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } @@ -1748,17 +1748,17 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) /*int fstat(int filedes, struct stat *buf);*/ do { if (stat(netcam->file->path, &statbuf)) { - MOTION_LOG(CRT, TYPE_NETCAM, SHOW_ERRNO, "%s: stat(%s) error", + MOTION_LOG(CRT, TYPE_NETCAM, SHOW_ERRNO, "%s: stat(%s) error", netcam->file->path); return -1; } - + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: statbuf.st_mtime[%d]" - " != last_st_mtime[%d]", statbuf.st_mtime, + " != last_st_mtime[%d]", statbuf.st_mtime, netcam->file->last_st_mtime); /* its waits POLLING_TIMEOUT */ - if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { + if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: waiting new file image" " timeout"); return -1; @@ -1766,9 +1766,9 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: delay waiting new" " file image "); - + //its waits 5seconds - READ_TIMEOUT - //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000); + //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000); SLEEP(0, POLLING_TIME); // its waits 500ms /*return -1;*/ loop_counter++; @@ -1776,26 +1776,26 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) } while (statbuf.st_mtime == netcam->file->last_st_mtime); netcam->file->last_st_mtime = statbuf.st_mtime; - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: processing new file image -" " st_mtime %d", netcam->file->last_st_mtime); - + /* Assure there's enough room in the buffer. */ while (buffer->size < (size_t)statbuf.st_size) - netcam_check_buffsize(buffer, statbuf.st_size); - + netcam_check_buffsize(buffer, statbuf.st_size); + /* Do the read */ netcam->file->control_file_desc = open(netcam->file->path, O_RDONLY); if (netcam->file->control_file_desc < 0) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: open(%s) error: %d", + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: open(%s) error: %d", netcam->file->path, netcam->file->control_file_desc); return -1; } - if ((len = read(netcam->file->control_file_desc, + if ((len = read(netcam->file->control_file_desc, buffer->ptr + buffer->used, statbuf.st_size)) < 0) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: read(%s) error: %d", + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: read(%s) error: %d", netcam->file->control_file_desc, len); return -1; } @@ -1805,7 +1805,7 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* * Calculate our "running average" time for this netcam's @@ -1816,8 +1816,8 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } @@ -1844,12 +1844,12 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) pthread_mutex_unlock(&netcam->mutex); MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: End"); - + return 0; } -tfile_context *file_new_context(void) +tfile_context *file_new_context(void) { tfile_context *ret; @@ -1862,7 +1862,7 @@ tfile_context *file_new_context(void) return ret; } -void file_free_context(tfile_context* ctxt) +void file_free_context(tfile_context* ctxt) { if (ctxt == NULL) return; @@ -1873,7 +1873,7 @@ void file_free_context(tfile_context* ctxt) free(ctxt); } -static int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url) +static int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url) { if ((netcam->file = file_new_context()) == NULL) @@ -1888,7 +1888,7 @@ static int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url) netcam->file->path = url->path; url->path = NULL; - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->file->path %s", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->file->path %s", netcam->file->path); netcam_url_free(url); @@ -1939,7 +1939,7 @@ static void *netcam_handler_loop(void *arg) if (netcam->response) { /* If html input */ if (netcam->caps.streaming == NCS_UNSUPPORTED) { /* Non-streaming ie. jpeg */ - if (!netcam->connect_keepalive || + if (!netcam->connect_keepalive || (netcam->connect_keepalive && netcam->keepalive_timeup)) { /* If keepalive flag set but time up, time to close this socket. */ if (netcam->connect_keepalive && netcam->keepalive_timeup) { @@ -1974,7 +1974,7 @@ static void *netcam_handler_loop(void *arg) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized image" " header (%d)", retval); } else if (retval != -1) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error in header (%d)", + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error in header (%d)", retval); } /* Need to have a dynamic delay here. */ @@ -1995,7 +1995,7 @@ static void *netcam_handler_loop(void *arg) if ((retval = netcam_read_first_header(netcam) != 2)) { if (retval > 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, - "%s: Unrecognized image header (%d)", + "%s: Unrecognized image header (%d)", retval); } else if (retval != -1) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, @@ -2017,16 +2017,36 @@ static void *netcam_handler_loop(void *arg) */ } } + + +#ifdef FFMPEG_V55 + if (netcam->caps.streaming == NCS_RTSP) { + if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Attempting to reconnect"); + rtsp_connect(netcam); + continue; + } else { + // We think we are connected... + if (netcam->get_image(netcam) < 0) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image attempting to reconnect"); + //Nope. We are not or got bad image. Reconnect + rtsp_connect(netcam); + continue; + } + } + } +#endif if (netcam->get_image(netcam) < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error getting jpeg image"); - /* If FTP connection, attempt to re-connect to server. */ - if (netcam->ftp) { - close(netcam->ftp->control_file_desc); - if (ftp_connect(netcam) < 0) - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Trying to re-connect"); - + if (netcam->caps.streaming != NCS_RTSP) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error getting jpeg image"); + /* If FTP connection, attempt to re-connect to server. */ + if (netcam->ftp) { + close(netcam->ftp->control_file_desc); + if (ftp_connect(netcam) < 0) + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Trying to re-connect"); + } + continue; } - continue; } /* * FIXME @@ -2065,6 +2085,11 @@ static void *netcam_handler_loop(void *arg) /* The loop continues forever, or until motion shutdown. */ } +#ifdef FFMPEG_V55 + if (netcam->caps.streaming == NCS_RTSP) + netcam_shutdown_rtsp(netcam); +#endif + /* Our thread is finished - decrement motion's thread count. */ pthread_mutex_lock(&global_lock); threads_running--; @@ -2101,7 +2126,7 @@ static void *netcam_handler_loop(void *arg) * Returns: 0 on success, * or -1 if an fatal error occurs. */ -static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) +static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; const char *ptr; /* Working var */ @@ -2115,8 +2140,8 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) memset(netcam->response, 0, sizeof(struct rbuf)); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam has flags:" - " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", - netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", + " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", + netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", netcam->connect_keepalive ? "ON":"OFF"); /* @@ -2136,7 +2161,7 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) if (ptr) { userpass = mymalloc(strlen(ptr) + 3); strcpy(userpass, ptr); - } else { + } else { userpass = NULL; } @@ -2189,13 +2214,13 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) ptr = mymalloc(strlen(url->service) + strlen(url->host) + strlen(url->path) + 4); sprintf((char *)ptr, "http://%s%s", url->host, url->path); - + netcam->connect_keepalive = FALSE; /* Disable Keepalive if proxy */ free((void *)netcam->cnt->conf.netcam_keepalive); netcam->cnt->conf.netcam_keepalive = strdup("off"); MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: " - "Removed netcam_keepalive flag due to proxy set." + "Removed netcam_keepalive flag due to proxy set." "Proxy is incompatible with Keep-Alive."); } else { /* If no proxy, set as netcam_url path. */ @@ -2210,22 +2235,22 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) ix += strlen(ptr); - /* + /* * Now add the required number of characters for the close header * or Keep-Alive header. We test the flag which can be unset if * there is a problem (rather than the flag in the conf structure * which is read-only. */ - - if (netcam->connect_keepalive) + + if (netcam->connect_keepalive) ix += strlen(connect_req_keepalive); - else + else ix += strlen(connect_req_close); - + /* - * Point to either the HTTP 1.0 or 1.1 request header set - * If the configuration is anything other than 1.1, use 1.0 + * Point to either the HTTP 1.0 or 1.1 request header set + * If the configuration is anything other than 1.1, use 1.0 * as a default. This avoids a chance of being left with none. */ if (netcam->connect_http_11 == TRUE) @@ -2242,13 +2267,13 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) /* Now create the request string with an sprintf. */ sprintf(netcam->connect_request, connect_req, ptr, - netcam->connect_host); + netcam->connect_host); - if (netcam->connect_keepalive) + if (netcam->connect_keepalive) strcat(netcam->connect_request, connect_req_keepalive); - else + else strcat(netcam->connect_request, connect_req_close); - + if (userpass) { strcat(netcam->connect_request, request_pass); @@ -2282,7 +2307,7 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) * Returns: 0 on success (camera link ok) or -1 if an error occurred. * */ -static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) +static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) { /* * This netcam is http-based, so build the required URL and @@ -2358,7 +2383,7 @@ static int netcam_setup_mjpg(netcam_context_ptr netcam, struct url_t *url) return 0; } -static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) +static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; const char *ptr; @@ -2413,13 +2438,13 @@ static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) return 0; } -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; const char *ptr; int ret = -1; - + netcam->caps.streaming = NCS_RTSP; netcam->rtsp = rtsp_new_context(); @@ -2427,12 +2452,12 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); return -1; } - + /* * Allocate space for a working string to contain the path. * The extra 5 is for "://", ":" and string terminator. */ - + // force port to a sane value if (netcam->connect_port > 65536) { netcam->connect_port = 65536; @@ -2440,41 +2465,64 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) netcam->connect_port = 0; } - ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) - + 5 + strlen(url->path) + 5); - sprintf((char *)ptr, "%s://%s:%d%s", url->service, - netcam->connect_host, netcam->connect_port, url->path); - - netcam->rtsp->path = (char *)ptr; - - if (cnt->conf.netcam_userpass != NULL) { - ptr = cnt->conf.netcam_userpass; - } else { - ptr = url->userpass; /* Don't set this one NULL, gets freed. */ - } - - if (ptr != NULL) { - char *cptr; - - if ((cptr = strchr(ptr, ':')) == NULL) { - netcam->rtsp->user = mystrdup(ptr); + if (cnt->conf.netcam_userpass != NULL) { + ptr = cnt->conf.netcam_userpass; } else { - netcam->rtsp->user = mymalloc((cptr - ptr)); - memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); - netcam->rtsp->pass = mystrdup(cptr + 1); + ptr = url->userpass; /* Don't set this one NULL, gets freed. */ + } + + if (ptr != NULL) { + char *cptr; + if ((cptr = strchr(ptr, ':')) == NULL) { + netcam->rtsp->user = mystrdup(ptr); + } else { + netcam->rtsp->user = mymalloc((cptr - ptr)); + memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); + netcam->rtsp->pass = mystrdup(cptr + 1); + } } - } - netcam_url_free(url); + /* + Need a method to query the path and + determine the authentication type if needed. + avformat_open_input returns file not found when + it wants authentication and it is not provided. + right now, if user specified a password, we will + prepend it onto the path to make it happier so we + can at least try basic authentication. + */ + + if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { + ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + + 5 + strlen(url->path) + 5 + + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 5 ); + sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", + url->service,netcam->rtsp->user,netcam->rtsp->pass, + netcam->connect_host, netcam->connect_port, url->path); + } + else { + ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + + 5 + strlen(url->path) + 5); + sprintf((char *)ptr, "%s://%s:%d%s", url->service, + netcam->connect_host, netcam->connect_port, url->path); + } + netcam->rtsp->path = (char *)ptr; - /* - * The RTSP context should be all ready to attempt a connection with - * the server, so we try .... - */ - ret = rtsp_connect(netcam); - if (ret < 0) return ret; + netcam_url_free(url); + + /* + * Now we need to set some flags for the callback function. + */ + netcam->rtsp->readingframe = 0; + + /* + * The RTSP context should be all ready to attempt a connection with + * the server, so we try .... + */ + ret = rtsp_connect(netcam); + if (ret < 0) return ret; - netcam->get_image = netcam_read_rtsp_image; + netcam->get_image = netcam_read_rtsp_image; return 0; } @@ -2498,7 +2546,7 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) * error reply from the system call. * */ -ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) +ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) { ssize_t retval; fd_set fd_r; @@ -2527,7 +2575,7 @@ ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) * handled. * This function is also called from motion_init if first time connection * fails and we start retrying until we get a valid first frame from the - * camera. + * camera. * * Parameters: * @@ -2579,7 +2627,7 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) if (netcam->caps.streaming == NCS_UNSUPPORTED) pthread_cond_signal(&netcam->cap_cond); - + /* * Once the camera-handler gets to the end of it's loop (probably as @@ -2619,45 +2667,45 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) pthread_mutex_unlock(&netcam->mutex); /* and cleanup the rest of the netcam_context structure. */ - if (netcam->connect_host != NULL) + if (netcam->connect_host != NULL) free(netcam->connect_host); - if (netcam->connect_request != NULL) + if (netcam->connect_request != NULL) free(netcam->connect_request); - - if (netcam->boundary != NULL) + + if (netcam->boundary != NULL) free(netcam->boundary); - + if (netcam->latest != NULL) { - if (netcam->latest->ptr != NULL) + if (netcam->latest->ptr != NULL) free(netcam->latest->ptr); - + free(netcam->latest); } if (netcam->receiving != NULL) { - if (netcam->receiving->ptr != NULL) + if (netcam->receiving->ptr != NULL) free(netcam->receiving->ptr); - + free(netcam->receiving); } if (netcam->jpegbuf != NULL) { - if (netcam->jpegbuf->ptr != NULL) + if (netcam->jpegbuf->ptr != NULL) free(netcam->jpegbuf->ptr); - + free(netcam->jpegbuf); } - if (netcam->ftp != NULL) + if (netcam->ftp != NULL) ftp_free_context(netcam->ftp); - else + else netcam_disconnect(netcam); - - if (netcam->response != NULL) + + if (netcam->response != NULL) free(netcam->response); pthread_mutex_destroy(&netcam->mutex); @@ -2721,9 +2769,9 @@ int netcam_next(struct context *cnt, unsigned char *image) * approach is to just return a NULL (failed) to the caller (an * error message has already been produced by the libjpeg routines). */ - if (setjmp(netcam->setjmp_buffer)) + if (setjmp(netcam->setjmp_buffer)) return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; - + /* If there was no error, process the latest image buffer. */ return netcam_proc_jpeg(netcam, image); } @@ -2791,7 +2839,7 @@ int netcam_start(struct context *cnt) pthread_cond_init(&netcam->cap_cond, NULL); pthread_cond_init(&netcam->pic_ready, NULL); pthread_cond_init(&netcam->exiting, NULL); - + /* Initialise the average frame time to the user's value. */ netcam->av_frame_time = 1000000.0 / cnt->conf.frame_limit; @@ -2828,7 +2876,7 @@ int netcam_start(struct context *cnt) netcam_url_parse(&url, cnt->conf.netcam_url); if (!url.host) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", cnt->conf.netcam_url); netcam_url_free(&url); return -1; @@ -2842,7 +2890,7 @@ int netcam_start(struct context *cnt) /* Get HTTP Mode (1.0 default, 1.0 Keep-Alive, 1.1) flag from config * and report its stata for debug reasons. - * The flags in the conf structure is read only and cannot be + * The flags in the conf structure is read only and cannot be * unset if the Keep-Alive needs to be switched off (ie. netcam does * not turn out to support it. That is handled by unsetting the flags * in the context structures (cnt->...) only. @@ -2863,9 +2911,9 @@ int netcam_start(struct context *cnt) } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam_http parameter '%s'" - " converts to flags: HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", - cnt->conf.netcam_keepalive, - netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", + " converts to flags: HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", + cnt->conf.netcam_keepalive, + netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", netcam->connect_keepalive ? "ON":"OFF"); /* Initialise the netcam socket to -1 to trigger a connection by the keep-alive logic. */ @@ -2892,13 +2940,13 @@ int netcam_start(struct context *cnt) strcpy(url.service, "http"); /* Put back a real URL service. */ retval = netcam_setup_mjpg(netcam, &url); -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" " netcam_setup_rtsp()"); retval = netcam_setup_rtsp(netcam, &url); -#endif +#endif } else { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam service '%s' - " "must be http, ftp, mjpg or file.", url.service); @@ -2922,7 +2970,7 @@ int netcam_start(struct context *cnt) return -1; } -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 if (netcam->caps.streaming != NCS_RTSP) { #endif /* @@ -2955,7 +3003,7 @@ int netcam_start(struct context *cnt) " is not modulo 8", netcam->height); return -3; } -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 } else { // not jpeg, get the dimensions netcam->width = netcam->rtsp->codec_context->width; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 87c4fd0..d266b75 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -2,7 +2,7 @@ #include "netcam_rtsp.h" #include "motion.h" -#ifdef have_av_get_media_type_string +#ifdef FFMPEG_V55 /**************************************************** * Duplicated static functions - FIXME @@ -37,7 +37,7 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) real_alloc += NETCAM_BUFFSIZE; new_size = buff->size + real_alloc; - + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", (int) buff->used, (int) buff->size, (int) buff->used, new_size); @@ -53,31 +53,31 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc) { - int check = 0; - int ret = avcodec_decode_video2(cc, frame, &check, packet); - - if (ret < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); - return 0; - } - - if (check == 0) { - // no frame could be decoded...keep trying - return 0; - } + int check = 0; + int ret = avcodec_decode_video2(cc, frame, &check, packet); - int frame_size = av_image_get_buffer_size(cc->pix_fmt, cc->width, cc->height, 1); + if (ret < 0) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); + return 0; + } - /* Assure there's enough room in the buffer. */ - netcam_check_buffsize(buffer, frame_size); + if (check == 0) { + // no frame could be decoded...keep trying + return 0; + } - av_image_copy_to_buffer((uint8_t *)buffer->ptr, frame_size, + int frame_size = av_image_get_buffer_size(cc->pix_fmt, cc->width, cc->height, 1); + + /* Assure there's enough room in the buffer. */ + netcam_check_buffsize(buffer, frame_size); + + av_image_copy_to_buffer((uint8_t *)buffer->ptr, frame_size, (const uint8_t **)(frame->data), frame->linesize, cc->pix_fmt, cc->width, cc->height, 1); - buffer->used = frame_size; - - return frame_size; + buffer->used = frame_size; + + return frame_size; } static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type) @@ -88,7 +88,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV AVCodec *dec = NULL; ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); if (ret < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", av_get_media_type_string(type)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", av_get_media_type_string(type)); return ret; } else { *stream_idx = ret; @@ -122,211 +122,208 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV */ struct rtsp_context *rtsp_new_context(void) { - struct rtsp_context *ret; - - /* Note that mymalloc will exit on any problem. */ - ret = mymalloc(sizeof(struct rtsp_context)); - - memset(ret, 0, sizeof(struct rtsp_context)); - - return ret; + struct rtsp_context *ret; + + /* Note that mymalloc will exit on any problem. */ + ret = mymalloc(sizeof(struct rtsp_context)); + + memset(ret, 0, sizeof(struct rtsp_context)); + + return ret; } -/** -* rtsp_free_context -* -* Free the resources allocated for this context. -* -* Parameters -* -* ctxt Pointer to the rtsp_context structure. -* -* Returns: Nothing -* -*/ -static void rtsp_free_context(struct rtsp_context *ctxt) +static int decode_interrupt_cb(void *ctx) { - if (ctxt == NULL) - return; - - if (ctxt->path != NULL) - free(ctxt->path); - - if (ctxt->user) - free(ctxt->user); - - if (ctxt->pass) - free(ctxt->pass); - - if (ctxt->format_context != NULL) { - avformat_close_input(&ctxt->format_context); - } - - if (ctxt->codec_context != NULL) { - avcodec_close(ctxt->codec_context); - } - - free(ctxt); + struct rtsp_context *rtsp = (struct rtsp_context *)ctx; + + if (rtsp->readingframe != 1) { + return 0; + } else { + struct timeval interrupttime; + if (gettimeofday(&interrupttime, NULL) < 0) { + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: Failed to get interrupt time"); + } + if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){ + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Timeout getting frame %d",interrupttime.tv_sec - rtsp->startreadtime.tv_sec); + return 1; + } else{ + return 0; + } + } + + //should not be possible to get here + return 0; } int rtsp_connect(netcam_context_ptr netcam) { - if (netcam->rtsp == NULL) { - netcam->rtsp = rtsp_new_context(); + int ret; - if (netcam->rtsp == NULL) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create context(%s)", netcam->rtsp->path); - return -1; + if (netcam->rtsp->path == NULL) { + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); + return -1; } - } - // open the network connection - AVDictionary *opts = 0; - av_dict_set(&opts, "rtsp_transport", "tcp", 0); - int ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); - if (ret < 0) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %d - %s", netcam->rtsp->path, ret, av_err2str(ret)); - rtsp_free_context(netcam->rtsp); - netcam->rtsp = NULL; - return ret; - } + // open the network connection + AVDictionary *opts = 0; + av_dict_set(&opts, "rtsp_transport", "tcp", 0); - // fill out stream information - ret = avformat_find_stream_info(netcam->rtsp->format_context, NULL); - if (ret < 0) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %d", ret); - rtsp_free_context(netcam->rtsp); - netcam->rtsp = NULL; - return -1; - } + netcam->rtsp->format_context = avformat_alloc_context(); + netcam->rtsp->format_context->interrupt_callback.callback = decode_interrupt_cb; + netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; - ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); - if (ret < 0) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %d", ret); - rtsp_free_context(netcam->rtsp); - netcam->rtsp = NULL; - return -1; - } - - netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; - - // start up the feed - av_read_play(netcam->rtsp->format_context); - - return 0; + ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); + if (ret < 0) { + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %d - %s", netcam->rtsp->path,av_err2str(ret)); + if (ret == -1094995529) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Authentication?"); + avformat_close_input(&netcam->rtsp->format_context); + return ret; + } + + // fill out stream information + ret = avformat_find_stream_info(netcam->rtsp->format_context, NULL); + if (ret < 0) { + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %d", ret); + avformat_close_input(&netcam->rtsp->format_context); + return -1; + } + + ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); + if (ret < 0) { + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %d", ret); + avformat_close_input(&netcam->rtsp->format_context); + avcodec_close(netcam->rtsp->codec_context); + return -1; + } + + netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; + + netcam->rtsp->frame = av_frame_alloc(); + + // start up the feed + av_read_play(netcam->rtsp->format_context); + + return 0; } int netcam_read_rtsp_image(netcam_context_ptr netcam) { - if (netcam->rtsp == NULL) { - if (rtsp_connect(netcam) < 0) { - return -1; - } - } + /* This code is called many times so optimize and do + * little as possible in here. + */ - AVCodecContext *cc = netcam->rtsp->codec_context; - AVFormatContext *fc = netcam->rtsp->format_context; - netcam_buff_ptr buffer; + struct timeval curtime; + netcam_buff_ptr buffer; + AVPacket packet; + int size_decoded; + static int usual_size_decoded; - /* Point to our working buffer. */ - buffer = netcam->receiving; - buffer->used = 0; + /* Point to our working buffer. */ + buffer = netcam->receiving; + buffer->used = 0; - AVFrame *frame = avcodec_alloc_frame(); + av_init_packet(&packet); - AVPacket packet; - - av_init_packet(&packet); + packet.data = NULL; + packet.size = 0; - packet.data = NULL; - packet.size = 0; + size_decoded = 0; + usual_size_decoded = 0; - int size_decoded = 0; - static int usual_size_decoded = 0; + if (gettimeofday(&curtime, NULL) < 0) { + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); + } + netcam->rtsp->startreadtime = curtime; + + netcam->rtsp->readingframe = 1; + while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { + if(packet.stream_index != netcam->rtsp->video_stream_index) { + // not our packet, skip + continue; + } + size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); + } + netcam->rtsp->readingframe = 0; - while (size_decoded == 0 && av_read_frame(fc, &packet) >= 0) { + // at this point, we are finished with the packet and frame, so free them. + av_free_packet(&packet); - if(packet.stream_index != netcam->rtsp->video_stream_index) { - // not our packet, skip - continue; + if (size_decoded == 0) { + // something went wrong, end of stream? Interupted? + MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: invalid frame! %d", size_decoded); + return -1; } - size_decoded = decode_packet(&packet, buffer, frame, cc); - } - - if (size_decoded == 0) { - // something went wrong, end of stream? - MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: invalid frame!"); - return -1; - } - - if (size_decoded != usual_size_decoded) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: unusual frame size of %d!", size_decoded); - usual_size_decoded = size_decoded; - } - - // at this point, we are finished with the packet and frame, so free them. - av_free_packet(&packet); - av_free(frame); - - struct timeval curtime; - - if (gettimeofday(&curtime, NULL) < 0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - } - - netcam->receiving->image_time = curtime; - - /* - * Calculate our "running average" time for this netcam's - * frame transmissions (except for the first time). - * Note that the average frame time is held in microseconds. - */ - if (netcam->last_image.tv_sec) { - netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * + if (size_decoded != usual_size_decoded) { + if (usual_size_decoded !=0) { + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: unusual frame size of %d!", size_decoded); + } + usual_size_decoded = size_decoded; + } + // Time may be slightly off due to it being when we initiated the reading of the frame + // rather than when we finally got a good frame. But we are averaging frame times anyway.. + netcam->receiving->image_time = curtime; + + /* + * Calculate our "running average" time for this netcam's + * frame transmissions (except for the first time). + * Note that the average frame time is held in microseconds. + */ + if (netcam->last_image.tv_sec) { + netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); - } - - netcam->last_image = curtime; - - netcam_buff *xchg; - - /* - * read is complete - set the current 'receiving' buffer atomically - * as 'latest', and make the buffer previously in 'latest' become - * the new 'receiving'. - */ - pthread_mutex_lock(&netcam->mutex); - - xchg = netcam->latest; - netcam->latest = netcam->receiving; - netcam->receiving = xchg; - netcam->imgcnt++; - - /* - * We have a new frame ready. We send a signal so that - * any thread (e.g. the motion main loop) waiting for the - * next frame to become available may proceed. - */ - pthread_cond_signal(&netcam->pic_ready); - - pthread_mutex_unlock(&netcam->mutex); - - return 0; + } + + netcam->last_image = curtime; + + netcam_buff *xchg; + + /* + * read is complete - set the current 'receiving' buffer atomically + * as 'latest', and make the buffer previously in 'latest' become + * the new 'receiving'. + */ + pthread_mutex_lock(&netcam->mutex); + + xchg = netcam->latest; + netcam->latest = netcam->receiving; + netcam->receiving = xchg; + netcam->imgcnt++; + + /* + * We have a new frame ready. We send a signal so that + * any thread (e.g. the motion main loop) waiting for the + * next frame to become available may proceed. + */ + pthread_cond_signal(&netcam->pic_ready); + + pthread_mutex_unlock(&netcam->mutex); + + return 0; } void netcam_shutdown_rtsp(netcam_context_ptr netcam) { - if (netcam->rtsp != NULL) { - rtsp_free_context(netcam->rtsp); + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); + + av_free(netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + + if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); + if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); + if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); + + free(netcam->rtsp); + netcam->rtsp = NULL; - } + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); } #endif diff --git a/netcam_rtsp.h b/netcam_rtsp.h index 38ef565..35ad6a1 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -7,12 +7,15 @@ struct rtsp_context { - AVFormatContext* format_context; - AVCodecContext* codec_context; - int video_stream_index; - char* path; - char* user; - char* pass; + AVFormatContext* format_context; + AVCodecContext* codec_context; + AVFrame *frame; + int video_stream_index; + char* path; + char* user; + char* pass; + int readingframe; + struct timeval startreadtime; }; //int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); From fe8c8016870d055f1f894bfd3806e9a8b736cc7c Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 14 Jun 2014 15:38:45 -0600 Subject: [PATCH 004/233] Plug memory leaks in RTSP --- CHANGELOG | 1 + netcam.c | 11 ++++-- netcam_rtsp.c | 93 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 63 insertions(+), 42 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 055c375..abdf86e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -59,6 +59,7 @@ Features * Resolve additional compiler warnings in ffmpeg (Mr-Dave) * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) + * Plugged most(?) memory leaks in RTSP. (Mr-Dave) Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/netcam.c b/netcam.c index 554da65..fa9d0fa 100644 --- a/netcam.c +++ b/netcam.c @@ -2446,10 +2446,12 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) int ret = -1; netcam->caps.streaming = NCS_RTSP; + netcam->rtsp = rtsp_new_context(); if (netcam->rtsp == NULL) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); + netcam_shutdown_rtsp(netcam); return -1; } @@ -2476,7 +2478,7 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) if ((cptr = strchr(ptr, ':')) == NULL) { netcam->rtsp->user = mystrdup(ptr); } else { - netcam->rtsp->user = mymalloc((cptr - ptr)); + netcam->rtsp->user = mymalloc((cptr - ptr)+2); //+2 for string terminator memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); netcam->rtsp->pass = mystrdup(cptr + 1); } @@ -2495,7 +2497,7 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + 5 + strlen(url->path) + 5 - + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 5 ); + + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 3 ); sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", url->service,netcam->rtsp->user,netcam->rtsp->pass, netcam->connect_host, netcam->connect_port, url->path); @@ -2520,7 +2522,10 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) * the server, so we try .... */ ret = rtsp_connect(netcam); - if (ret < 0) return ret; + if (ret < 0){ + netcam_shutdown_rtsp(netcam); + return ret; + } netcam->get_image = netcam_read_rtsp_image; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index d266b75..36d677d 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -51,6 +51,18 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) * End Duplicated static functions - FIXME ****************************************************/ +void netcam_free_context(netcam_context_ptr netcam) +{ + av_frame_free(&netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + + free(netcam->rtsp->frame); + free(netcam->rtsp->codec_context); + free(netcam->rtsp->format_context); + +} + static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc) { int check = 0; @@ -80,31 +92,38 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram return frame_size; } -static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type) +static int open_codec_context(netcam_context_ptr netcam, enum AVMediaType type) { int ret; - AVStream *st; - AVCodecContext *dec_ctx = NULL; AVCodec *dec = NULL; - ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); + + ret = av_find_best_stream(netcam->rtsp->format_context, type, -1, -1, NULL, 0); if (ret < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", av_get_media_type_string(type)); return ret; - } else { - *stream_idx = ret; - st = fmt_ctx->streams[*stream_idx]; - /* find decoder for the stream */ - dec_ctx = st->codec; - dec = avcodec_find_decoder(dec_ctx->codec_id); - if (!dec) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", av_get_media_type_string(type)); - return ret; - } - if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", av_get_media_type_string(type)); - return ret; - } } + + netcam->rtsp->video_stream_index = ret; + netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; + + dec = avcodec_find_decoder(netcam->rtsp->codec_context->codec_id); + if (dec == NULL) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", av_get_media_type_string(type)); + return -1; + } + + netcam->rtsp->codec_context = avcodec_alloc_context3(dec); + if (netcam->rtsp->codec_context == NULL) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec context for %s codec!", av_get_media_type_string(type)); + return -1; + } + + ret = avcodec_open2(netcam->rtsp->codec_context, dec, NULL); + if (ret < 0) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", av_get_media_type_string(type)); + return ret; + } + return 0; } @@ -164,6 +183,7 @@ int rtsp_connect(netcam_context_ptr netcam) return -1; } + netcam_free_context(netcam); // open the network connection AVDictionary *opts = 0; @@ -189,16 +209,14 @@ int rtsp_connect(netcam_context_ptr netcam) return -1; } - ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); + ret = open_codec_context(netcam, AVMEDIA_TYPE_VIDEO); if (ret < 0) { MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %d", ret); - avformat_close_input(&netcam->rtsp->format_context); avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); return -1; } - netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; - netcam->rtsp->frame = av_frame_alloc(); // start up the feed @@ -223,10 +241,6 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) buffer = netcam->receiving; buffer->used = 0; - av_init_packet(&packet); - - packet.data = NULL; - packet.size = 0; size_decoded = 0; usual_size_decoded = 0; @@ -239,10 +253,19 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) netcam->rtsp->readingframe = 1; while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { if(packet.stream_index != netcam->rtsp->video_stream_index) { - // not our packet, skip + // not our packet, Free it/reinitialize and try again. + av_free_packet(&packet); + av_init_packet(&packet); + packet.data = NULL; + packet.size = 0; continue; } size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); + + av_free_packet(&packet); + av_init_packet(&packet); + packet.data = NULL; + packet.size = 0; } netcam->rtsp->readingframe = 0; @@ -307,23 +330,15 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) return 0; } - void netcam_shutdown_rtsp(netcam_context_ptr netcam) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); + netcam_free_context(netcam); - av_free(netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); - - if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); - if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); - if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); + free(netcam->rtsp->path); + free(netcam->rtsp->user); + free(netcam->rtsp->pass); free(netcam->rtsp); - - netcam->rtsp = NULL; - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); } #endif From 0ba3f6caf9838fd606338bfe7b79da17434deaa9 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 14 Jun 2014 20:02:38 -0600 Subject: [PATCH 005/233] Undo changes from code editor and other unnecessary changes --- CHANGELOG | 2 + ffmpeg.c | 77 +++++++------ netcam.c | 328 +++++++++++++++++++++++++++--------------------------- 3 files changed, 209 insertions(+), 198 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index abdf86e..586d7da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,6 +60,8 @@ Features * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) * Plugged most(?) memory leaks in RTSP. (Mr-Dave) + * Undo changes caused by code editor and other unnecessary changes + Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/ffmpeg.c b/ffmpeg.c index dbcd7ca..611e11e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -24,9 +24,9 @@ # define FFMPEG_NO_NONSTD_MPEG1 #endif /* LIBAVCODEC_BUILD > 4680 */ -#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR +#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR # if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 -# define GUESS_NO_DEPRECATED +# define GUESS_NO_DEPRECATED # endif #endif @@ -50,7 +50,7 @@ # define AVSTREAM_CODEC_PTR(avs_ptr) (&avs_ptr->codec) #endif /* LIBAVFORMAT_BUILD >= 4629 */ -// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) +// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) // (54*2^16 | 6*2^8 | 100) #if LIBAVFORMAT_BUILD >= 3540580 #define FF_API_NEW_AVIO @@ -79,9 +79,9 @@ static unsigned char mpeg1_trailer[] = {0x00, 0x00, 0x01, 0xb7}; // FFMPEG API changed in 0.8 #if defined FF_API_NEW_AVIO -// TODO - +// TODO + #else /** @@ -268,7 +268,7 @@ static int mpeg1_write_trailer(AVFormatContext *s) void ffmpeg_init() { MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d" - " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, + " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD); av_register_all(); @@ -289,12 +289,10 @@ void ffmpeg_init() mpeg1_file_protocol.url_close = file_protocol.url_close; /* Register the append file protocol. */ -#ifdef have_av_register_protocol2 +#ifdef FFMPEG_V55 av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); -#elif defined have_av_register_protocol - av_register_protocol(&mpeg1_file_protocol); #else -# warning av_register_protocolXXX missing + av_register_protocol(&mpeg1_file_protocol); #endif #endif // FF_API_NEW_AVIO @@ -331,10 +329,10 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) * result in a muxed output file, which isn't appropriate here. */ #ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); + of = guess_format("mpeg1video", NULL, NULL); #else of = av_guess_format("mpeg1video", NULL, NULL); -#endif +#endif /* But we want the trailer to be correctly written. */ if (of) of->write_trailer = mpeg1_write_trailer; @@ -349,14 +347,14 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) ext = ".avi"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("avi", NULL, NULL); -#endif +#endif } else if (strcmp(codec, "msmpeg4") == 0) { ext = ".avi"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("avi", NULL, NULL); #endif /* Manually override the codec id. */ @@ -367,16 +365,16 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) ext = ".swf"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("swf", NULL, NULL); -#endif +#endif } else if (strcmp(codec, "flv") == 0) { ext = ".flv"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("flv", NULL, NULL); -#endif +#endif of->video_codec = CODEC_ID_FLV1; } else if (strcmp(codec, "ffv1") == 0) { ext = ".avi"; @@ -396,7 +394,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) ext = ".mov"; #ifdef GUESS_NO_DEPRECATED of = guess_format("mpeg1video", NULL, NULL); -#else +#else of = av_guess_format("mov", NULL, NULL); #endif } @@ -460,12 +458,10 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); /* Allocation the output media context. */ -#ifdef have_avformat_alloc_context +#ifdef FFMPEG_V55 ffmpeg->oc = avformat_alloc_context(); -#elif defined have_av_avformat_alloc_context - ffmpeg->oc = av_alloc_format_context(); #else - ffmpeg->oc = av_mallocz(sizeof(AVFormatContext)); + ffmpeg->oc = av_alloc_format_context(); #endif if (!ffmpeg->oc) { @@ -487,7 +483,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, /* Create a new video stream and initialize the codecs. */ ffmpeg->video_st = NULL; if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { -#if defined FF_API_NEW_AVIO +#if defined FF_API_NEW_AVIO ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); #else ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); @@ -508,11 +504,11 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); c->codec_id = ffmpeg->oc->oformat->video_codec; -#if LIBAVCODEC_VERSION_MAJOR < 53 +#if LIBAVCODEC_VERSION_MAJOR < 53 c->codec_type = CODEC_TYPE_VIDEO; #else c->codec_type = AVMEDIA_TYPE_VIDEO; -#endif +#endif is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; if (strcmp(ffmpeg_video_codec, "ffv1") == 0) @@ -619,7 +615,11 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, } /* Allocate the encoded raw picture. */ +#ifdef FFMPEG_V55 + ffmpeg->picture = av_frame_alloc(); +#else ffmpeg->picture = avcodec_alloc_frame(); +#endif if (!ffmpeg->picture) { MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -" @@ -852,11 +852,11 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { /* Raw video case. The API will change slightly in the near future for that. */ #ifdef FFMPEG_AVWRITEFRAME_NEWAPI -# if LIBAVCODEC_VERSION_MAJOR < 53 +# if LIBAVCODEC_VERSION_MAJOR < 53 pkt.flags |= PKT_FLAG_KEY; # else - pkt.flags |= AV_PKT_FLAG_KEY; -# endif + pkt.flags |= AV_PKT_FLAG_KEY; +# endif pkt.data = (uint8_t *)pic; pkt.size = sizeof(AVPicture); ret = av_write_frame(ffmpeg->oc, &pkt); @@ -870,10 +870,10 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) pkt.data = ffmpeg->video_outbuf; pkt.size = ffmpeg->video_outbuf_size; - out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), + out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), &pkt, pic, &got_packet_ptr); if (out_size < 0) - // Error encondig + // Error encondig out_size = 0; else out_size = pkt.size; @@ -892,11 +892,11 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) -# if LIBAVCODEC_VERSION_MAJOR < 53 +# if LIBAVCODEC_VERSION_MAJOR < 53 pkt.flags |= PKT_FLAG_KEY; # else pkt.flags |= AV_PKT_FLAG_KEY; -# endif +# endif pkt.data = ffmpeg->video_outbuf; pkt.size = out_size; @@ -936,7 +936,11 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y, { AVFrame *picture; +#ifdef FFMPEG_V55 + picture = av_frame_alloc(); +#else picture = avcodec_alloc_frame(); +#endif if (!picture) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc frame"); @@ -985,7 +989,12 @@ void ffmpeg_deinterlace(unsigned char *img, int width, int height) picture.linesize[2] = width2; /* We assume using 'PIX_FMT_YUV420P' always */ +#ifdef FFMPEG_V55 + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Deinterlace depreciated for recent versions of FFMPEG."); +#else avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height); +#endif + #if !defined(__SSE_MATH__) && (defined(__i386__) || defined(__x86_64__)) __asm__ __volatile__ ( "emms"); diff --git a/netcam.c b/netcam.c index fa9d0fa..4a9b961 100644 --- a/netcam.c +++ b/netcam.c @@ -149,21 +149,21 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) { char *s; int i; -#ifdef FFMPEG_V55 +#ifdef FFMPEG_V55 const char *re = "(http|ftp|mjpg|rtsp)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; #else const char *re = "(http|ftp|mjpg)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; -#endif +#endif regex_t pattbuf; regmatch_t matches[10]; - if (!strncmp(text_url, "file", 4)) + if (!strncmp(text_url, "file", 4)) re = "(file)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]*)(:([0-9]*))?($|(/[^:][/-_.a-z0-9]+))"; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Entry netcam_url_parse data %s", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Entry netcam_url_parse data %s", text_url); memset(parse_url, 0, sizeof(struct url_t)); @@ -211,10 +211,10 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) parse_url->port = 80; else if (!strcmp(parse_url->service, "ftp")) parse_url->port = 21; -#ifdef FFMPEG_V55 +#ifdef FFMPEG_V55 else if (!strcmp(parse_url->service, "rtsp") && parse_url->port == 0) parse_url->port = 554; -#endif +#endif } regfree(&pattbuf); @@ -313,7 +313,7 @@ static long netcam_check_content_length(char *header) " Content-Length but value %ld", length); } - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length %ld", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length %ld", length); return length; @@ -341,7 +341,7 @@ static int netcam_check_keepalive(char *header) return -1; /* We do not detect the second field or other case mixes at present. */ - if (content_type) + if (content_type) free(content_type); return 1; @@ -368,11 +368,11 @@ static int netcam_check_close(char *header) if (!header_process(header, "Connection", http_process_type, &type)) return -1; - + if (!strcmp(type, "close")) /* strcmp returns 0 for match. */ ret = 1; - - if (type) + + if (type) free(type); return ret; @@ -403,7 +403,7 @@ static int netcam_check_content_type(char *header) if (!header_process(header, "Content-type", http_process_type, &content_type)) return -1; - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-type %s", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-type %s", content_type); if (!strcmp(content_type, "image/jpeg")) { @@ -442,7 +442,7 @@ static int netcam_read_next_header(netcam_context_ptr netcam) char *header; /* Return if not connected */ - if (netcam->sock == -1) + if (netcam->sock == -1) return -1; /* * We are expecting a header which *must* contain a mime-type of @@ -465,12 +465,12 @@ static int netcam_read_next_header(netcam_context_ptr netcam) if (retval != HG_OK) { /* Header reported as not-OK, check to see if it's null. */ if (strlen(header) == 0) { - MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " + MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " "streaming mode (1). Null header."); } else { /* Header is not null. Output it in case it's a new camera with unknown headers. */ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " - "streaming mode (1). Unknown header '%s'", + "streaming mode (1). Unknown header '%s'", header); } @@ -490,7 +490,7 @@ static int netcam_read_next_header(netcam_context_ptr netcam) retval = header_get(netcam, &header, HG_NONE); if (retval != HG_OK) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header (2)"); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header (2)"); free(header); return -1; } @@ -512,16 +512,16 @@ static int netcam_read_next_header(netcam_context_ptr netcam) netcam->receiving->content_length = retval; } else { netcam->receiving->content_length = 0; - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length 0"); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length 0"); free(header); return -1; - } - } + } + } free(header); } - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Found image header record"); + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Found image header record"); free(header); return 0; @@ -592,11 +592,11 @@ static int netcam_read_first_header(netcam_context_ptr netcam) while (1) { /* 'Do forever' */ ret = header_get(netcam, &header, HG_NONE); - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received first header ('%s')", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received first header ('%s')", header); if (ret != HG_OK) { - MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header (%s)", + MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header (%s)", header); free(header); return -1; @@ -609,15 +609,15 @@ static int netcam_read_first_header(netcam_context_ptr netcam) free(header); if (netcam->connect_keepalive) { - /* - * Cannot unset netcam->cnt->conf.netcam_keepalive as it is assigned const - * But we do unset the netcam keepalive flag which was set in netcam_start + /* + * Cannot unset netcam->cnt->conf.netcam_keepalive as it is assigned const + * But we do unset the netcam keepalive flag which was set in netcam_start * This message is logged as Information as it would be useful to know - * if your netcam often returns bad HTTP result codes. + * if your netcam often returns bad HTTP result codes. */ netcam->connect_keepalive = FALSE; free((void *)netcam->cnt->conf.netcam_keepalive); - netcam->cnt->conf.netcam_keepalive = strdup("off"); + netcam->cnt->conf.netcam_keepalive = strdup("off"); MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag" "due to apparent closed HTTP connection."); } @@ -643,18 +643,18 @@ static int netcam_read_first_header(netcam_context_ptr netcam) */ switch (ret) { case 1: /* Not streaming */ - if (netcam->connect_keepalive) - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " + if (netcam->connect_keepalive) + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " "(keep-alive set)"); else - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " "(keep-alive not set)"); netcam->caps.streaming = NCS_UNSUPPORTED; break; case 2: /* Streaming */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera"); + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera"); netcam->caps.streaming = NCS_MULTIPART; @@ -687,7 +687,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized content type"); free(header); return -1; - + } } else if ((ret = (int) netcam_check_content_length(header)) >= 0) { MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Content-length present"); @@ -695,7 +695,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) if (ret > 0) { netcam->caps.content_length = 1; /* Set flag */ netcam->receiving->content_length = ret; - } else { + } else { netcam->receiving->content_length = 0; MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-length 0"); retval = -2; @@ -704,18 +704,18 @@ static int netcam_read_first_header(netcam_context_ptr netcam) /* Note that we have received a Keep-Alive header, and thus the socket can be left open. */ aliveflag = TRUE; netcam->keepalive_thisconn = TRUE; - /* - * This flag will not be set when a Streaming cam is in use, but that - * does not matter as the test below looks at Streaming state also. + /* + * This flag will not be set when a Streaming cam is in use, but that + * does not matter as the test below looks at Streaming state also. */ } else if (netcam_check_close(header) == TRUE) { /* Note that we have received a Connection: close header. */ closeflag = TRUE; - /* - * This flag is acted upon below. - * Changed criterion and moved up from below to catch headers that cause returns. + /* + * This flag is acted upon below. + * Changed criterion and moved up from below to catch headers that cause returns. */ - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Found Conn: close header ('%s')", + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Found Conn: close header ('%s')", header); } free(header); @@ -723,7 +723,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) free(header); if (netcam->caps.streaming == NCS_UNSUPPORTED && netcam->connect_keepalive) { - + /* If we are a non-streaming (ie. Jpeg) netcam and keepalive is configured. */ if (aliveflag) { @@ -738,22 +738,22 @@ static int netcam_read_first_header(netcam_context_ptr netcam) netcam->cnt->conf.netcam_keepalive = strdup("off"); } else { /* - * If not a streaming cam, and keepalive is set, and the flag shows we + * If not a streaming cam, and keepalive is set, and the flag shows we * did not see a Keep-Alive field returned from netcam and a Close field. * Not quite sure what the correct course of action is here. In for testing. - */ + */ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Both 'Connection: Keep-Alive' and " "'Connection: close' header received. Motion continues unchanged."); } } else { - /* - * aliveflag && !closeflag + /* + * aliveflag && !closeflag * - * If not a streaming cam, and keepalive is set, and the flag shows we + * If not a streaming cam, and keepalive is set, and the flag shows we * just got a Keep-Alive field returned from netcam and no Close field. * No action, as this is the normal case. In debug we print a notification. */ - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received a Keep-Alive field in this" "set of headers."); } @@ -770,17 +770,17 @@ static int netcam_read_first_header(netcam_context_ptr netcam) netcam->cnt->conf.netcam_keepalive = strdup("off"); } else { /* - * If not a streaming cam, and keepalive is set, and the flag shows we + * If not a streaming cam, and keepalive is set, and the flag shows we * did not see a Keep-Alive field returned from netcam nor a Close field. * Not quite sure what the correct course of action is here. In for testing. - */ + */ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: No 'Connection: Keep-Alive' nor 'Connection: close'" " header received.\n Motion continues unchanged."); } - } else { - /* - * !aliveflag & closeflag - * If not a streaming cam, and keepalive is set, and the flag shows we + } else { + /* + * !aliveflag & closeflag + * If not a streaming cam, and keepalive is set, and the flag shows we * received a 'Connection: close' field returned from netcam. It is not likely * we will get a Keep-Alive and Close header together - this is picked up by * the test code above. @@ -805,11 +805,11 @@ static int netcam_read_first_header(netcam_context_ptr netcam) free((void *)netcam->cnt->conf.netcam_keepalive); netcam->cnt->conf.netcam_keepalive = strdup("off"); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag because" - " 'Connection: close' header received.\n Netcam does not support " + " 'Connection: close' header received.\n Netcam does not support " "Keep-Alive. Motion continues in non-Keep-Alive."); } else { netcam->keepalive_timeup = TRUE; /* We will close and re-open keep-alive */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "Keep-Alive has reached end of valid period.\n" + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "Keep-Alive has reached end of valid period.\n" "Motion will close netcam, then resume Keep-Alive with a new socket."); } } @@ -873,7 +873,7 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) /* Assure any previous connection has been closed - IF we are not in keepalive. */ if (!netcam->connect_keepalive) { - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam " + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam " "since keep-alive not set."); netcam_disconnect(netcam); @@ -891,13 +891,13 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) } else if (netcam->sock == -1) { /* We are in keepalive mode, check for invalid socket. */ /* Must be first time, or closed, create a new socket. */ if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with keepalive set, invalid socket." + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with keepalive set, invalid socket." "This could be the first time. Creating a new one failed."); return -1; } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: with keepalive set, invalid socket." - "This could be first time, created a new one with fd %d", + "This could be first time, created a new one with fd %d", netcam->sock); /* Record that this connection has not yet received a Keep-Alive header. */ @@ -909,7 +909,7 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) return -1; } - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE is %s", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE is %s", optval ? "ON":"OFF"); /* Set the option active. */ @@ -922,9 +922,9 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE set on socket."); - } - - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: re-using socket %d since keepalive is set.", + } + + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: re-using socket %d since keepalive is set.", netcam->sock); /* Lookup the hostname given in the netcam URL. */ @@ -976,7 +976,7 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) /* If the connect failed with anything except EINPROGRESS, error. */ if ((ret < 0) && (back_err != EINPROGRESS)) { if (!err_flag) - MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect() failed (%d)", + MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect() failed (%d)", back_err); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (4)"); @@ -995,9 +995,9 @@ static int netcam_connect(netcam_context_ptr netcam, int err_flag) if (ret == 0) { /* 0 means timeout. */ if (!err_flag) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: timeout on connect()"); - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (2)"); - + netcam_disconnect(netcam); return -1; } @@ -1062,7 +1062,7 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) real_alloc += NETCAM_BUFFSIZE; new_size = buff->size + real_alloc; - + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", (int) buff->used, (int) buff->size, (int) buff->used, new_size); @@ -1321,9 +1321,9 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) * as 'latest', and make the buffer previously in 'latest' become * the new 'receiving'. */ - if (gettimeofday(&curtime, NULL) < 0) + if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* @@ -1336,7 +1336,7 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } netcam->last_image = curtime; @@ -1362,7 +1362,7 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) "netcam since keep-alive not set."); netcam_disconnect(netcam); - } + } MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: leaving netcam connected."); } @@ -1403,9 +1403,9 @@ static int netcam_http_request(netcam_context_ptr netcam) * safe to include it as part of this loop * (Not always true now Keep-Alive is implemented). */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: about to try to connect, time #%d", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: about to try to connect, time #%d", ix); - + if (netcam_connect(netcam, 0) != 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "Failed to open camera - check your config " "and that netcamera is online"); @@ -1468,9 +1468,9 @@ static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) netcam->response->buffer_left = retval; netcam->response->buffer_pos = netcam->response->buffer; - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Refilled buffer with [%d]" - " bytes from the network.", retval); + " bytes from the network.", retval); return retval; } @@ -1478,7 +1478,7 @@ static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) /** * netcam_read_mjpg_jpeg * - * This routine reads from a netcam using a MJPG-chunk based + * This routine reads from a netcam using a MJPG-chunk based * protocol, used by Linksys WVC200 for example. * This implementation has been made by reverse-engineering * the protocol, so it may contain bugs and should be considered as @@ -1488,7 +1488,7 @@ static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) * * The stream consists of JPG pictures, spanned across multiple * MJPG chunks (in general 3 chunks, altough that's not guaranteed). - * + * * Each data chunk can range from 1 to 65535 bytes + a header, altough * i have not seen anything bigger than 20000 bytes + a header. * @@ -1538,7 +1538,7 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) read_bytes += retval; - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] header bytes.", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] header bytes.", read_bytes, sizeof(mh)); /* If we don't have received a full header, refill our buffer. */ @@ -1572,26 +1572,26 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) mh.mh_chunksize - read_bytes); read_bytes += retval; MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] chunk bytes," - " [%d/%d] total", read_bytes, mh.mh_chunksize, + " [%d/%d] total", read_bytes, mh.mh_chunksize, buffer->used + read_bytes, mh.mh_framesize); if (retval < (int) (mh.mh_chunksize - read_bytes)) { /* MOTION_LOG(EMG, TYPE_NETCAM, NO_ERRNO, "Chunk incomplete, going to refill."); */ if (netcam_mjpg_buffer_refill(netcam) < 0) return -1; - + } } buffer->used += read_bytes; MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Chunk complete," - " buffer used [%d] bytes.", buffer->used); + " buffer used [%d] bytes.", buffer->used); /* Is our JPG image complete ? */ if (mh.mh_framesize == buffer->used) { MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Image complete," " buffer used [%d] bytes.", buffer->used); - break; + break; } /* MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Rlen now at [%d] bytes", rlen); */ } @@ -1601,9 +1601,9 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) * as 'latest', and make the buffer previously in 'latest' become * the new 'receiving'. */ - if (gettimeofday(&curtime, NULL) < 0) + if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* @@ -1616,7 +1616,7 @@ static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } netcam->last_image = curtime; @@ -1676,9 +1676,9 @@ static int netcam_read_ftp_jpeg(netcam_context_ptr netcam) buffer->used += len; } while (len > 0); - if (gettimeofday(&curtime, NULL) < 0) + if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* * Calculate our "running average" time for this netcam's @@ -1690,7 +1690,7 @@ static int netcam_read_ftp_jpeg(netcam_context_ptr netcam) (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } @@ -1748,17 +1748,17 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) /*int fstat(int filedes, struct stat *buf);*/ do { if (stat(netcam->file->path, &statbuf)) { - MOTION_LOG(CRT, TYPE_NETCAM, SHOW_ERRNO, "%s: stat(%s) error", + MOTION_LOG(CRT, TYPE_NETCAM, SHOW_ERRNO, "%s: stat(%s) error", netcam->file->path); return -1; } - + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: statbuf.st_mtime[%d]" - " != last_st_mtime[%d]", statbuf.st_mtime, + " != last_st_mtime[%d]", statbuf.st_mtime, netcam->file->last_st_mtime); /* its waits POLLING_TIMEOUT */ - if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { + if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: waiting new file image" " timeout"); return -1; @@ -1766,9 +1766,9 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: delay waiting new" " file image "); - + //its waits 5seconds - READ_TIMEOUT - //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000); + //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000); SLEEP(0, POLLING_TIME); // its waits 500ms /*return -1;*/ loop_counter++; @@ -1776,26 +1776,26 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) } while (statbuf.st_mtime == netcam->file->last_st_mtime); netcam->file->last_st_mtime = statbuf.st_mtime; - + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: processing new file image -" " st_mtime %d", netcam->file->last_st_mtime); - + /* Assure there's enough room in the buffer. */ while (buffer->size < (size_t)statbuf.st_size) - netcam_check_buffsize(buffer, statbuf.st_size); - + netcam_check_buffsize(buffer, statbuf.st_size); + /* Do the read */ netcam->file->control_file_desc = open(netcam->file->path, O_RDONLY); if (netcam->file->control_file_desc < 0) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: open(%s) error: %d", + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: open(%s) error: %d", netcam->file->path, netcam->file->control_file_desc); return -1; } - if ((len = read(netcam->file->control_file_desc, + if ((len = read(netcam->file->control_file_desc, buffer->ptr + buffer->used, statbuf.st_size)) < 0) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: read(%s) error: %d", + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: read(%s) error: %d", netcam->file->control_file_desc, len); return -1; } @@ -1805,7 +1805,7 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) if (gettimeofday(&curtime, NULL) < 0) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - + netcam->receiving->image_time = curtime; /* * Calculate our "running average" time for this netcam's @@ -1816,8 +1816,8 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", + + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", netcam->av_frame_time); } @@ -1844,12 +1844,12 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) pthread_mutex_unlock(&netcam->mutex); MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: End"); - + return 0; } -tfile_context *file_new_context(void) +tfile_context *file_new_context(void) { tfile_context *ret; @@ -1862,7 +1862,7 @@ tfile_context *file_new_context(void) return ret; } -void file_free_context(tfile_context* ctxt) +void file_free_context(tfile_context* ctxt) { if (ctxt == NULL) return; @@ -1873,7 +1873,7 @@ void file_free_context(tfile_context* ctxt) free(ctxt); } -static int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url) +static int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url) { if ((netcam->file = file_new_context()) == NULL) @@ -1888,7 +1888,7 @@ static int netcam_setup_file(netcam_context_ptr netcam, struct url_t *url) netcam->file->path = url->path; url->path = NULL; - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->file->path %s", + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->file->path %s", netcam->file->path); netcam_url_free(url); @@ -1939,7 +1939,7 @@ static void *netcam_handler_loop(void *arg) if (netcam->response) { /* If html input */ if (netcam->caps.streaming == NCS_UNSUPPORTED) { /* Non-streaming ie. jpeg */ - if (!netcam->connect_keepalive || + if (!netcam->connect_keepalive || (netcam->connect_keepalive && netcam->keepalive_timeup)) { /* If keepalive flag set but time up, time to close this socket. */ if (netcam->connect_keepalive && netcam->keepalive_timeup) { @@ -1974,7 +1974,7 @@ static void *netcam_handler_loop(void *arg) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized image" " header (%d)", retval); } else if (retval != -1) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error in header (%d)", + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error in header (%d)", retval); } /* Need to have a dynamic delay here. */ @@ -1995,7 +1995,7 @@ static void *netcam_handler_loop(void *arg) if ((retval = netcam_read_first_header(netcam) != 2)) { if (retval > 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, - "%s: Unrecognized image header (%d)", + "%s: Unrecognized image header (%d)", retval); } else if (retval != -1) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, @@ -2017,8 +2017,7 @@ static void *netcam_handler_loop(void *arg) */ } } - - + #ifdef FFMPEG_V55 if (netcam->caps.streaming == NCS_RTSP) { if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect @@ -2036,8 +2035,8 @@ static void *netcam_handler_loop(void *arg) } } #endif - if (netcam->get_image(netcam) < 0) { - if (netcam->caps.streaming != NCS_RTSP) { + if (netcam->caps.streaming != NCS_RTSP) { + if (netcam->get_image(netcam) < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error getting jpeg image"); /* If FTP connection, attempt to re-connect to server. */ if (netcam->ftp) { @@ -2048,6 +2047,7 @@ static void *netcam_handler_loop(void *arg) continue; } } + /* * FIXME * Need to check whether the image was received / decoded @@ -2126,7 +2126,7 @@ static void *netcam_handler_loop(void *arg) * Returns: 0 on success, * or -1 if an fatal error occurs. */ -static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) +static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; const char *ptr; /* Working var */ @@ -2140,8 +2140,8 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) memset(netcam->response, 0, sizeof(struct rbuf)); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam has flags:" - " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", - netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", + " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", + netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", netcam->connect_keepalive ? "ON":"OFF"); /* @@ -2161,7 +2161,7 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) if (ptr) { userpass = mymalloc(strlen(ptr) + 3); strcpy(userpass, ptr); - } else { + } else { userpass = NULL; } @@ -2214,13 +2214,13 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) ptr = mymalloc(strlen(url->service) + strlen(url->host) + strlen(url->path) + 4); sprintf((char *)ptr, "http://%s%s", url->host, url->path); - + netcam->connect_keepalive = FALSE; /* Disable Keepalive if proxy */ free((void *)netcam->cnt->conf.netcam_keepalive); netcam->cnt->conf.netcam_keepalive = strdup("off"); MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: " - "Removed netcam_keepalive flag due to proxy set." + "Removed netcam_keepalive flag due to proxy set." "Proxy is incompatible with Keep-Alive."); } else { /* If no proxy, set as netcam_url path. */ @@ -2235,22 +2235,22 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) ix += strlen(ptr); - /* + /* * Now add the required number of characters for the close header * or Keep-Alive header. We test the flag which can be unset if * there is a problem (rather than the flag in the conf structure * which is read-only. */ - - if (netcam->connect_keepalive) + + if (netcam->connect_keepalive) ix += strlen(connect_req_keepalive); - else + else ix += strlen(connect_req_close); - + /* - * Point to either the HTTP 1.0 or 1.1 request header set - * If the configuration is anything other than 1.1, use 1.0 + * Point to either the HTTP 1.0 or 1.1 request header set + * If the configuration is anything other than 1.1, use 1.0 * as a default. This avoids a chance of being left with none. */ if (netcam->connect_http_11 == TRUE) @@ -2267,13 +2267,13 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) /* Now create the request string with an sprintf. */ sprintf(netcam->connect_request, connect_req, ptr, - netcam->connect_host); + netcam->connect_host); - if (netcam->connect_keepalive) + if (netcam->connect_keepalive) strcat(netcam->connect_request, connect_req_keepalive); - else + else strcat(netcam->connect_request, connect_req_close); - + if (userpass) { strcat(netcam->connect_request, request_pass); @@ -2307,7 +2307,7 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) * Returns: 0 on success (camera link ok) or -1 if an error occurred. * */ -static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) +static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) { /* * This netcam is http-based, so build the required URL and @@ -2383,7 +2383,7 @@ static int netcam_setup_mjpg(netcam_context_ptr netcam, struct url_t *url) return 0; } -static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) +static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; const char *ptr; @@ -2497,7 +2497,7 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + 5 + strlen(url->path) + 5 - + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 3 ); + + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 4 ); sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", url->service,netcam->rtsp->user,netcam->rtsp->pass, netcam->connect_host, netcam->connect_port, url->path); @@ -2551,7 +2551,7 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) * error reply from the system call. * */ -ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) +ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) { ssize_t retval; fd_set fd_r; @@ -2580,7 +2580,7 @@ ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) * handled. * This function is also called from motion_init if first time connection * fails and we start retrying until we get a valid first frame from the - * camera. + * camera. * * Parameters: * @@ -2632,7 +2632,7 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) if (netcam->caps.streaming == NCS_UNSUPPORTED) pthread_cond_signal(&netcam->cap_cond); - + /* * Once the camera-handler gets to the end of it's loop (probably as @@ -2672,45 +2672,45 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) pthread_mutex_unlock(&netcam->mutex); /* and cleanup the rest of the netcam_context structure. */ - if (netcam->connect_host != NULL) + if (netcam->connect_host != NULL) free(netcam->connect_host); - if (netcam->connect_request != NULL) + if (netcam->connect_request != NULL) free(netcam->connect_request); + - - if (netcam->boundary != NULL) + if (netcam->boundary != NULL) free(netcam->boundary); - + if (netcam->latest != NULL) { - if (netcam->latest->ptr != NULL) + if (netcam->latest->ptr != NULL) free(netcam->latest->ptr); - + free(netcam->latest); } if (netcam->receiving != NULL) { - if (netcam->receiving->ptr != NULL) + if (netcam->receiving->ptr != NULL) free(netcam->receiving->ptr); - + free(netcam->receiving); } if (netcam->jpegbuf != NULL) { - if (netcam->jpegbuf->ptr != NULL) + if (netcam->jpegbuf->ptr != NULL) free(netcam->jpegbuf->ptr); - + free(netcam->jpegbuf); } - if (netcam->ftp != NULL) + if (netcam->ftp != NULL) ftp_free_context(netcam->ftp); - else + else netcam_disconnect(netcam); + - - if (netcam->response != NULL) + if (netcam->response != NULL) free(netcam->response); pthread_mutex_destroy(&netcam->mutex); @@ -2774,9 +2774,9 @@ int netcam_next(struct context *cnt, unsigned char *image) * approach is to just return a NULL (failed) to the caller (an * error message has already been produced by the libjpeg routines). */ - if (setjmp(netcam->setjmp_buffer)) + if (setjmp(netcam->setjmp_buffer)) return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; - + /* If there was no error, process the latest image buffer. */ return netcam_proc_jpeg(netcam, image); } @@ -2844,7 +2844,7 @@ int netcam_start(struct context *cnt) pthread_cond_init(&netcam->cap_cond, NULL); pthread_cond_init(&netcam->pic_ready, NULL); pthread_cond_init(&netcam->exiting, NULL); - + /* Initialise the average frame time to the user's value. */ netcam->av_frame_time = 1000000.0 / cnt->conf.frame_limit; @@ -2881,7 +2881,7 @@ int netcam_start(struct context *cnt) netcam_url_parse(&url, cnt->conf.netcam_url); if (!url.host) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", cnt->conf.netcam_url); netcam_url_free(&url); return -1; @@ -2895,7 +2895,7 @@ int netcam_start(struct context *cnt) /* Get HTTP Mode (1.0 default, 1.0 Keep-Alive, 1.1) flag from config * and report its stata for debug reasons. - * The flags in the conf structure is read only and cannot be + * The flags in the conf structure is read only and cannot be * unset if the Keep-Alive needs to be switched off (ie. netcam does * not turn out to support it. That is handled by unsetting the flags * in the context structures (cnt->...) only. @@ -2916,9 +2916,9 @@ int netcam_start(struct context *cnt) } MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam_http parameter '%s'" - " converts to flags: HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", - cnt->conf.netcam_keepalive, - netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", + " converts to flags: HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", + cnt->conf.netcam_keepalive, + netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", netcam->connect_keepalive ? "ON":"OFF"); /* Initialise the netcam socket to -1 to trigger a connection by the keep-alive logic. */ @@ -2945,13 +2945,13 @@ int netcam_start(struct context *cnt) strcpy(url.service, "http"); /* Put back a real URL service. */ retval = netcam_setup_mjpg(netcam, &url); -#ifdef FFMPEG_V55 +#ifdef FFMPEG_V55 } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" " netcam_setup_rtsp()"); retval = netcam_setup_rtsp(netcam, &url); -#endif +#endif } else { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam service '%s' - " "must be http, ftp, mjpg or file.", url.service); @@ -3008,7 +3008,7 @@ int netcam_start(struct context *cnt) " is not modulo 8", netcam->height); return -3; } -#ifdef FFMPEG_V55 +#ifdef FFMPEG_V55 } else { // not jpeg, get the dimensions netcam->width = netcam->rtsp->codec_context->width; From 8060fd2778b76b626f6d73ba8c15bdaef2a38fcb Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 14 Jun 2014 20:15:08 -0600 Subject: [PATCH 006/233] Remove conf files --- motion-dist.conf | 732 ----------------------------------------------- thread1.conf | 57 ---- thread2.conf | 58 ---- thread3.conf | 60 ---- thread4.conf | 62 ---- 5 files changed, 969 deletions(-) delete mode 100644 motion-dist.conf delete mode 100644 thread1.conf delete mode 100644 thread2.conf delete mode 100644 thread3.conf delete mode 100644 thread4.conf diff --git a/motion-dist.conf b/motion-dist.conf deleted file mode 100644 index 30b094f..0000000 --- a/motion-dist.conf +++ /dev/null @@ -1,732 +0,0 @@ -# Rename this distribution example file to motion.conf -# -# This config file was generated by motion trunkREVUNKNOWN - - -############################################################ -# Daemon -############################################################ - -# Start in daemon (background) mode and release terminal (default: off) -daemon on - -# File to store the process ID, also called pid file. (default: not defined) -process_id_file /var/run/motion/motion.pid - -############################################################ -# Basic Setup Mode -############################################################ - -# Start in Setup-Mode, daemon disabled. (default: off) -setup_mode off - - -# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) -;logfile /tmp/motion.log - -# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -log_level 6 - -# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -log_type all - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video0 - -# v4l2_palette allows to choose preferable palette to be use by motion -# to capture from those supported by your videodevice. (default: 17) -# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and -# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. -# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 -# instead. -# -# Values : -# V4L2_PIX_FMT_SN9C10X : 0 'S910' -# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -# V4L2_PIX_FMT_SPCA561 : 3 'S561' -# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -# V4L2_PIX_FMT_PAC207 : 6 'P207' -# V4L2_PIX_FMT_PJPG : 7 'PJPG' -# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -# V4L2_PIX_FMT_JPEG : 9 'JPEG' -# V4L2_PIX_FMT_RGB24 : 10 'RGB3' -# V4L2_PIX_FMT_SPCA501 : 11 'S501' -# V4L2_PIX_FMT_SPCA505 : 12 'S505' -# V4L2_PIX_FMT_SPCA508 : 13 'S508' -# V4L2_PIX_FMT_UYVY : 14 'UYVY' -# V4L2_PIX_FMT_YUYV : 15 'YUYV' -# V4L2_PIX_FMT_YUV422P : 16 '422P' -# V4L2_PIX_FMT_YUV420 : 17 'YU12' -# -v4l2_palette 17 - -# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) -# This is ONLY used for FreeBSD. Leave it commented out for Linux -; tunerdevice /dev/tuner0 - -# 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) -norm 0 - -# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) -frequency 0 - -# Rotate image this number of degrees. The rotation affects all saved images as -# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. -rotate 0 - -# Image width (pixels). Valid range: Camera dependent, default: 352 -width 320 - -# Image height (pixels). Valid range: Camera dependent, default: 288 -height 240 - -# Maximum number of frames to be captured per second. -# Valid range: 2-100. Default: 100 (almost no limit). -framerate 2 - -# Minimum time in seconds between capturing picture frames from the camera. -# Default: 0 = disabled - the capture rate is given by the camera framerate. -# This option is used when you want to capture images at a rate lower than 2 per second. -minimum_frame_time 0 - -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -; netcam_url value - -# Username and password for network camera (only if required). Default: not defined -# Syntax is user:password -; netcam_userpass value - -# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -# on: Use HTTP/1.1 requests that support keep alive as default. -# Default: off -netcam_keepalive off - -# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". -# If a port number other than 80 is needed, use "http://myproxy:1234". -# Default: not defined -; netcam_proxy value - -# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -# Default: off -netcam_tolerant_check off - -# Let motion regulate the brightness of a video device (default: off). -# The auto_brightness feature uses the brightness option as its target value. -# If brightness is zero auto_brightness will adjust to average brightness value 128. -# Only recommended for cameras without auto brightness -auto_brightness off - -# Set the initial brightness of a video device. -# If auto_brightness is enabled, this value defines the average brightness level -# which Motion will try and adjust to. -# Valid range 0-255, default 0 = disabled -brightness 0 - -# Set the contrast of a video device. -# Valid range 0-255, default 0 = disabled -contrast 0 - -# Set the saturation of a video device. -# Valid range 0-255, default 0 = disabled -saturation 0 - -# Set the hue of a video device (NTSC feature). -# Valid range 0-255, default 0 = disabled -hue 0 - - -############################################################ -# Round Robin (multiple inputs on same video device name) -############################################################ - -# Number of frames to capture in each roundrobin step (default: 1) -roundrobin_frames 1 - -# Number of frames to skip before each roundrobin step (default: 1) -roundrobin_skip 1 - -# Try to filter out noise generated by roundrobin (default: off) -switchfilter off - - -############################################################ -# Motion Detection Settings: -############################################################ - -# Threshold for number of changed pixels in an image that -# triggers motion detection (default: 1500) -threshold 1500 - -# Automatically tune the threshold down if possible (default: off) -threshold_tune off - -# Noise threshold for the motion detection (default: 32) -noise_level 32 - -# Automatically tune the noise threshold (default: on) -noise_tune on - -# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) -# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. -# (l)abeling must only be used once and the 'l' must be the last letter. -# Comment out to disable -despeckle_filter EedDl - -# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -# A script (on_area_detected) is started immediately when motion is 4 5 6 -# detected in one of the given areas, but only once during an event. 7 8 9 -# One or more areas can be specified with this option. Take care: This option -# does NOT restrict detection to these areas! (Default: not defined) -; area_detect value - -# PGM file to use as a sensitivity mask. -# Full path name to. (Default: not defined) -; mask_file value - -# Dynamically create a mask file during operation (default: 0) -# Adjust speed of mask changes from 0 (off) to 10 (fast) -smart_mask_speed 0 - -# Ignore sudden massive light intensity changes given as a percentage of the picture -# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled -lightswitch 0 - -# Picture frames must contain motion at least the specified number of frames -# in a row before they are detected as true motion. At the default of 1, all -# motion is detected. Valid range: 1 to thousands, recommended 1-5 -minimum_motion_frames 1 - -# Specifies the number of pre-captured (buffered) pictures from before motion -# was detected that will be output at motion detection. -# Recommended range: 0 to 5 (default: 0) -# Do not use large values! Large values will cause Motion to skip video frames and -# cause unsmooth movies. To smooth movies use larger values of post_capture instead. -pre_capture 0 - -# Number of frames to capture after motion is no longer detected (default: 0) -post_capture 0 - -# Event Gap is the seconds of no motion detection that triggers the end of an event. -# An event is defined as a series of motion images taken within a short timeframe. -# Recommended value is 60 seconds (Default). The value -1 is allowed and disables -# events causing all Motion to be written to one single movie file and no pre_capture. -# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An -# event ends right after no more motion is detected and post_capture is over. -event_gap 60 - -# Maximum length in seconds of a movie -# When value is exceeded a new movie file is created. (Default: 0 = infinite) -max_movie_time 0 - -# Always save images even if there was no motion (default: off) -emulate_motion off - - -############################################################ -# Image File Output -############################################################ - -# Output 'normal' pictures when motion is detected (default: on) -# Valid values: on, off, first, best, center -# When set to 'first', only the first picture of an event is saved. -# Picture with most motion of an event is saved when set to 'best'. -# Picture with motion nearest center of picture is saved when set to 'center'. -# Can be used as preview shot for the corresponding movie. -output_pictures on - -# Output pictures with only the pixels moving object (ghost images) (default: off) -output_debug_pictures off - -# The quality (in percent) to be used by the jpeg compression (default: 75) -quality 75 - -# Type of output images -# Valid values: jpeg, ppm (default: jpeg) -picture_type jpeg - -############################################################ -# FFMPEG related options -# Film (movies) file output, and deinterlacing of the video input -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################ - -# Use ffmpeg to encode movies in realtime (default: off) -ffmpeg_output_movies on - -# Use ffmpeg to make movies with only the pixels moving -# object (ghost images) (default: off) -ffmpeg_output_debug_movies off - -# Use ffmpeg to encode a timelapse movie -# Default value 0 = off - else save frame every Nth second -ffmpeg_timelapse 0 - -# The file rollover mode of the timelapse video -# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual -ffmpeg_timelapse_mode daily - -# Bitrate to be used by the ffmpeg encoder (default: 400000) -# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) -ffmpeg_bps 500000 - -# Enables and defines variable bitrate for the ffmpeg encoder. -# ffmpeg_bps is ignored if variable bitrate is enabled. -# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, -# or the range 2 - 31 where 2 means best quality and 31 is worst. -ffmpeg_variable_bitrate 0 - -# Codec to used by ffmpeg for the video compression. -# Timelapse mpegs are always made in mpeg1 format independent from this option. -# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. -# mpeg1 - gives you files with extension .mpg -# mpeg4 or msmpeg4 - gives you files with extension .avi -# msmpeg4 is recommended for use with Windows Media Player because -# it requires no installation of codec on the Windows client. -# swf - gives you a flash film with extension .swf -# flv - gives you a flash video with extension .flv -# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -# mov - QuickTime ( testing ) -# ogg - Ogg/Theora ( testing ) -ffmpeg_video_codec mpeg4 - -# Use ffmpeg to deinterlace video. Necessary if you use an analog camera -# and see horizontal combing on moving objects in video or pictures. -# (default: off) -ffmpeg_deinterlace off - -############################################################ -# SDL Window -############################################################ - -# Number of motion thread to show in SDL Window (default: 0 = disabled) -sdl_threadnr 0 - -############################################################ -# External pipe to video encoder -# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################# - -# Bool to enable or disable extpipe (default: off) -use_extpipe off - -# External program (full path and opts) to pipe raw video to -# Generally, use '-' for STDIN... -;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps - - - -############################################################ -# Snapshots (Traditional Periodic Webcam File Output) -############################################################ - -# Make automated snapshot every N seconds (default: 0 = disabled) -snapshot_interval 0 - - -############################################################ -# Text Display -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, \n = new line, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event - do not use with text_event! -# You can put quotation marks around the text to allow -# leading spaces -############################################################ - -# Locate and draw a box around the moving object. -# Valid values: on, off, preview (default: off) -# Set to 'preview' will only draw a box in preview_shot pictures. -locate_motion_mode off - -# Set the look and style of the locate box if enabled. -# Valid values: box, redbox, cross, redcross (default: box) -# Set to 'box' will draw the traditional box. -# Set to 'redbox' will draw a red box. -# Set to 'cross' will draw a little cross to mark center. -# Set to 'redcross' will draw a little red cross to mark center. -locate_motion_style box - -# Draws the timestamp using same options as C function strftime(3) -# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -# Text is placed in lower right corner -text_right %Y-%m-%d\n%T-%q - -# Draw a user defined text on the images using same options as C function strftime(3) -# Default: Not defined = no text -# Text is placed in lower left corner -; text_left CAMERA %t - -# Draw the number of changed pixed on the images (default: off) -# Will normally be set to off except when you setup and adjust the motion settings -# Text is placed in upper right corner -text_changes off - -# This option defines the value of the special event conversion specifier %C -# You can use any conversion specifier in this option except %C. Date and time -# values are from the timestamp of the first image in the current event. -# Default: %Y%m%d%H%M%S -# The idea is that %C can be used filenames and text_left/right for creating -# a unique identifier for each event. -text_event %Y%m%d%H%M%S - -# Draw characters at twice normal size on images. (default: off) -text_double off - - -# Text to include in a JPEG EXIF comment -# May be any text, including conversion specifiers. -# The EXIF timestamp is included independent of this text. -;exif_text %i%J/%K%L - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, movie_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute path. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam1 - -# File path for snapshots (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-snapshot -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot -# File extension .jpg or .ppm is automatically added so do not include this. -# Note: A symbolic link called lastsnap.jpg created in the target_dir will always -# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -snapshot_filename %v-%Y%m%d%H%M%S-snapshot - -# File path for motion triggered images (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-%q -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this -# Set to 'preview' together with best-preview feature enables special naming -# convention for preview shots. See motion guide for details -picture_filename %v-%Y%m%d%H%M%S-%q - -# File path for motion triggered ffmpeg films (movies) relative to target_dir -# Default: %v-%Y%m%d%H%M%S -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -# File extension .mpg or .avi is automatically added so do not include this -# This option was previously called ffmpeg_filename -movie_filename %v-%Y%m%d%H%M%S - -# File path for timelapse movies relative to target_dir -# Default: %Y%m%d-timelapse -# Default value is near equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse -# File extension .mpg is automatically added so do not include this -timelapse_filename %Y%m%d-timelapse - -############################################################ -# Global Network Options -############################################################ -# Enable or disable IPV6 for http control and stream (default: off ) -ipv6_enabled off - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8081 - -# Quality of the jpeg (in percent) images produced (default: 50) -stream_quality 50 - -# Output frames at 1 fps when no motion is detected and increase to the -# rate given by stream_maxrate when motion is detected (default: off) -stream_motion off - -# Maximum framerate for stream streams (default: 1) -stream_maxrate 1 - -# Restrict stream connections to localhost only (default: on) -stream_localhost on - -# Limits the number of images per connection (default: 0 = unlimited) -# Number can be defined by multiplying actual stream rate by desired number of seconds -# Actual stream rate is the smallest of the numbers framerate and stream_maxrate -stream_limit 0 - -# Set the authentication method (default: 0) -# 0 = disabled -# 1 = Basic authentication -# 2 = MD5 digest (the safer authentication) -stream_auth_method 0 - -# Authentication for the stream. Syntax username:password -# Default: not defined (Disabled) -; stream_authentication username:password - - -############################################################ -# HTTP Based Control -############################################################ - -# TCP/IP port for the http server to listen on (default: 0 = disabled) -webcontrol_port 8080 - -# Restrict control connections to localhost only (default: on) -webcontrol_localhost on - -# Output for http server, select off to choose raw text plain (default: on) -webcontrol_html_output on - -# Authentication for the http based control. Syntax username:password -# Default: not defined (Disabled) -; webcontrol_authentication username:password - - -############################################################ -# Tracking (Pan/Tilt) -############################################################# - -# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) -# The generic type enables the definition of motion center and motion size to -# be used with the conversion specifiers for options like on_motion_detected -track_type 0 - -# Enable auto tracking (default: off) -track_auto off - -# Serial port of motor (default: none) -;track_port /dev/ttyS0 - -# Motor number for x-axis (default: 0) -;track_motorx 0 - -# Set motorx reverse (default: 0) -;track_motorx_reverse 0 - -# Motor number for y-axis (default: 0) -;track_motory 1 - -# Set motory reverse (default: 0) -;track_motory_reverse 0 - -# Maximum value on x-axis (default: 0) -;track_maxx 200 - -# Minimum value on x-axis (default: 0) -;track_minx 50 - -# Maximum value on y-axis (default: 0) -;track_maxy 200 - -# Minimum value on y-axis (default: 0) -;track_miny 50 - -# Center value on x-axis (default: 0) -;track_homex 128 - -# Center value on y-axis (default: 0) -;track_homey 128 - -# ID of an iomojo camera if used (default: 0) -track_iomojo_id 0 - -# Angle in degrees the camera moves per step on the X-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_x 10 - -# Angle in degrees the camera moves per step on the Y-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_y 10 - -# Delay to wait for after tracking movement as number -# of picture frames (default: 10) -track_move_wait 10 - -# Speed to set the motor to (stepper motor option) (default: 255) -track_speed 255 - -# Number of steps to make (stepper motor option) (default: 40) -track_stepsize 40 - - -############################################################ -# External Commands, Warnings and Logging: -# You can use conversion specifiers for the on_xxxx commands -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# %f = filename with full path -# %n = number indicating filetype -# Both %f and %n are only defined for on_picture_save, -# on_movie_start and on_movie_end -# Quotation marks round string are allowed. -############################################################ - -# Do not sound beeps when detecting motion (default: on) -# Note: Motion never beeps when running in daemon mode. -quiet on - -# Command to be executed when an event starts. (default: none) -# An event starts at first motion detected after a period of no motion defined by event_gap -; on_event_start value - -# Command to be executed when an event ends after a period of no motion -# (default: none). The period of no motion is defined by option event_gap. -; on_event_end value - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# To give the filename as an argument to a command append it with %f -; on_picture_save value - -# Command to be executed when a motion frame is detected (default: none) -; on_motion_detected value - -# Command to be executed when motion in a predefined area is detected -# Check option 'area_detect'. (default: none) -; on_area_detected value - -# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_start value - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_end value - -# Command to be executed when a camera can't be opened or if it is lost -# NOTE: There is situations when motion don't detect a lost camera! -# It depends on the driver, some drivers dosn't detect a lost camera at all -# Some hangs the motion thread. Some even hangs the PC! (default: none) -; on_camera_lost value - -##################################################################### -# Common Options for database features. -# Options require database options to be active also. -##################################################################### - -# Log to the database when creating motion triggered picture file (default: on) -; sql_log_picture on - -# Log to the database when creating a snapshot image file (default: on) -; sql_log_snapshot on - -# Log to the database when creating motion triggered movie file (default: off) -; sql_log_movie off - -# Log to the database when creating timelapse movies file (default: off) -; sql_log_timelapse off - -# SQL query string that is sent to the database -# Use same conversion specifiers has for text features -# Additional special conversion specifiers are -# %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') - - -############################################################ -# Database Options -############################################################ - -# database type : mysql, postgresql, sqlite3 (default : not defined) -; database_type value - -# database to log to (default: not defined) -; database_dbname value - -# The host on which the database is located (default: localhost) -; database_host value - -# User account name for database (default: not defined) -; database_user value - -# User password for database (default: not defined) -; database_password value - -# Port on which the database is located -# mysql 3306 , postgresql 5432 (default: not defined) -; database_port value - -############################################################ -# Database Options For SQLite3 -############################################################ - -# SQLite3 database (file path) (default: not defined) -; sqlite3_db value - - - -############################################################ -# Video Loopback Device (vloopback project) -############################################################ - -# Output images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; video_pipe value - -# Output motion images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; motion_video_pipe value - - -############################################################## -# Thread config files - One for each camera. -# Except if only one camera - You only need this config file. -# If you have more than one camera you MUST define one thread -# config file for each camera in addition to this config file. -############################################################## - -# Remember: If you have more than one camera you must have one -# thread file for each camera. E.g. 2 cameras requires 3 files: -# This motion.conf file AND thread1.conf and thread2.conf. -# Only put the options that are unique to each camera in the -# thread config files. -; thread /usr/local/etc/thread1.conf -; thread /usr/local/etc/thread2.conf -; thread /usr/local/etc/thread3.conf -; thread /usr/local/etc/thread4.conf - diff --git a/thread1.conf b/thread1.conf deleted file mode 100644 index fd702b1..0000000 --- a/thread1.conf +++ /dev/null @@ -1,57 +0,0 @@ -# /usr/local/etc/thread1.conf -# -# This config file was generated by motion trunkREVUNKNOWN - - - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video0 - -# 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 -# Text is placed in lower left corner -text_left CAMERA 1 - - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, mpeg_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam1 - - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8081 - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse1.pl - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse1.pl diff --git a/thread2.conf b/thread2.conf deleted file mode 100644 index 30f3423..0000000 --- a/thread2.conf +++ /dev/null @@ -1,58 +0,0 @@ -# /usr/local/etc/thread2.conf -# -# This config file was generated by motion trunkREVUNKNOWN - - - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video1 - -# 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 -# Text is placed in lower left corner -text_left CAMERA 2 - - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, mpeg_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam2 - - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8082 - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse2.pl - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse2.pl - diff --git a/thread3.conf b/thread3.conf deleted file mode 100644 index f66adaa..0000000 --- a/thread3.conf +++ /dev/null @@ -1,60 +0,0 @@ -# /usr/local/etc/thread3.conf -# -# This config file was generated by motion trunkREVUNKNOWN - - - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video2 - -# 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 -# Text is placed in lower left corner -text_left CAMERA 3 - - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, mpeg_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam3 - - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8083 - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse3.pl - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse3.pl - - - diff --git a/thread4.conf b/thread4.conf deleted file mode 100644 index 2462161..0000000 --- a/thread4.conf +++ /dev/null @@ -1,62 +0,0 @@ -# /usr/local/etc/thread4.conf -# -# This config file was generated by motion trunkREVUNKNOWN - -########################################################### -# Capture device options -############################################################ - -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -netcam_url http://192.168.1.6:8093/ - -# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -# on: Use HTTP/1.1 requests that support keep alive as default. -# Default: off -netcam_keepalive force - -# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -# Default: off -netcam_tolerant_check on - -# Draw a user defined text on the images using same options as C function strftime(3) -# Default: Not defined = no text -# Text is placed in lower left corner -text_left CAMERA 4 - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, mpeg_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam4 - - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8084 - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse4.pl - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse4.pl - From d11348bb8759ac921672c6e617766b3429e2da3d Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 16 Jun 2014 17:28:36 -0600 Subject: [PATCH 007/233] Call to netcam_shutdown_rtsp moved. --- CHANGELOG | 1 + netcam.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 586d7da..c411c2d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -61,6 +61,7 @@ Features * Revisions for RTSP and code standard.(Mr-Dave) * Plugged most(?) memory leaks in RTSP. (Mr-Dave) * Undo changes caused by code editor and other unnecessary changes + * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. Bugfixes diff --git a/netcam.c b/netcam.c index 4a9b961..8c269ec 100644 --- a/netcam.c +++ b/netcam.c @@ -2085,11 +2085,6 @@ static void *netcam_handler_loop(void *arg) /* The loop continues forever, or until motion shutdown. */ } -#ifdef FFMPEG_V55 - if (netcam->caps.streaming == NCS_RTSP) - netcam_shutdown_rtsp(netcam); -#endif - /* Our thread is finished - decrement motion's thread count. */ pthread_mutex_lock(&global_lock); threads_running--; @@ -2713,6 +2708,11 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) if (netcam->response != NULL) free(netcam->response); +#ifdef FFMPEG_V55 + if (netcam->caps.streaming == NCS_RTSP) + netcam_shutdown_rtsp(netcam); +#endif + pthread_mutex_destroy(&netcam->mutex); pthread_cond_destroy(&netcam->cap_cond); pthread_cond_destroy(&netcam->pic_ready); From 87d271e91420cd4f837d01a597ce772d0c883444 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 17 Jun 2014 19:47:26 -0600 Subject: [PATCH 008/233] Regession fix for memory leaks and reconnection. --- CHANGELOG | 1 + netcam_rtsp.c | 117 ++++++++++++++++++++++++++------------------------ 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c411c2d..ed34bf2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -62,6 +62,7 @@ Features * Plugged most(?) memory leaks in RTSP. (Mr-Dave) * Undo changes caused by code editor and other unnecessary changes * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. + * Regession fix for memory leaks and reconnection Bugfixes diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 36d677d..a209cad 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -4,6 +4,10 @@ #ifdef FFMPEG_V55 +/* Only recent versions of FFMPEG are supported since + * no documentation on how to code the old versions exist + */ + /**************************************************** * Duplicated static functions - FIXME ****************************************************/ @@ -51,18 +55,6 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) * End Duplicated static functions - FIXME ****************************************************/ -void netcam_free_context(netcam_context_ptr netcam) -{ - av_frame_free(&netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); - - free(netcam->rtsp->frame); - free(netcam->rtsp->codec_context); - free(netcam->rtsp->format_context); - -} - static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc) { int check = 0; @@ -71,7 +63,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram if (ret < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); return 0; - } + } if (check == 0) { // no frame could be decoded...keep trying @@ -92,38 +84,31 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram return frame_size; } -static int open_codec_context(netcam_context_ptr netcam, enum AVMediaType type) +static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type) { int ret; + AVStream *st; + AVCodecContext *dec_ctx = NULL; AVCodec *dec = NULL; - - ret = av_find_best_stream(netcam->rtsp->format_context, type, -1, -1, NULL, 0); - if (ret < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", av_get_media_type_string(type)); - return ret; - } - - netcam->rtsp->video_stream_index = ret; - netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; - - dec = avcodec_find_decoder(netcam->rtsp->codec_context->codec_id); - if (dec == NULL) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", av_get_media_type_string(type)); - return -1; - } - - netcam->rtsp->codec_context = avcodec_alloc_context3(dec); - if (netcam->rtsp->codec_context == NULL) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec context for %s codec!", av_get_media_type_string(type)); - return -1; - } - - ret = avcodec_open2(netcam->rtsp->codec_context, dec, NULL); + ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); if (ret < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", av_get_media_type_string(type)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", av_get_media_type_string(type)); return ret; + } else { + *stream_idx = ret; + st = fmt_ctx->streams[*stream_idx]; + /* find decoder for the stream */ + dec_ctx = st->codec; + dec = avcodec_find_decoder(dec_ctx->codec_id); + if (!dec) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", av_get_media_type_string(type)); + return ret; + } + if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", av_get_media_type_string(type)); + return ret; + } } - return 0; } @@ -160,7 +145,7 @@ static int decode_interrupt_cb(void *ctx) } else { struct timeval interrupttime; if (gettimeofday(&interrupttime, NULL) < 0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: Failed to get interrupt time"); + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time"); } if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Timeout getting frame %d",interrupttime.tv_sec - rtsp->startreadtime.tv_sec); @@ -174,8 +159,10 @@ static int decode_interrupt_cb(void *ctx) return 0; } + int rtsp_connect(netcam_context_ptr netcam) { + int ret; if (netcam->rtsp->path == NULL) { @@ -183,7 +170,6 @@ int rtsp_connect(netcam_context_ptr netcam) return -1; } - netcam_free_context(netcam); // open the network connection AVDictionary *opts = 0; @@ -197,10 +183,12 @@ int rtsp_connect(netcam_context_ptr netcam) if (ret < 0) { MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %d - %s", netcam->rtsp->path,av_err2str(ret)); if (ret == -1094995529) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Authentication?"); + av_dict_free(&opts); avformat_close_input(&netcam->rtsp->format_context); return ret; - } - + } + av_dict_free(&opts); + // fill out stream information ret = avformat_find_stream_info(netcam->rtsp->format_context, NULL); if (ret < 0) { @@ -209,14 +197,16 @@ int rtsp_connect(netcam_context_ptr netcam) return -1; } - ret = open_codec_context(netcam, AVMEDIA_TYPE_VIDEO); + ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); if (ret < 0) { MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %d", ret); - avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); + avcodec_close(netcam->rtsp->codec_context); return -1; } + netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; + netcam->rtsp->frame = av_frame_alloc(); // start up the feed @@ -227,6 +217,7 @@ int rtsp_connect(netcam_context_ptr netcam) int netcam_read_rtsp_image(netcam_context_ptr netcam) { + /* This code is called many times so optimize and do * little as possible in here. */ @@ -241,6 +232,10 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) buffer = netcam->receiving; buffer->used = 0; + av_init_packet(&packet); + + packet.data = NULL; + packet.size = 0; size_decoded = 0; usual_size_decoded = 0; @@ -253,11 +248,11 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) netcam->rtsp->readingframe = 1; while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { if(packet.stream_index != netcam->rtsp->video_stream_index) { - // not our packet, Free it/reinitialize and try again. av_free_packet(&packet); av_init_packet(&packet); packet.data = NULL; packet.size = 0; + // not our packet, skip continue; } size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); @@ -275,6 +270,9 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) if (size_decoded == 0) { // something went wrong, end of stream? Interupted? MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: invalid frame! %d", size_decoded); + av_free(netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); return -1; } @@ -284,8 +282,8 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) } usual_size_decoded = size_decoded; } - // Time may be slightly off due to it being when we initiated the reading of the frame - // rather than when we finally got a good frame. But we are averaging frame times anyway.. + + netcam->receiving->image_time = curtime; /* @@ -295,11 +293,11 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) */ if (netcam->last_image.tv_sec) { netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * - (curtime.tv_sec - netcam->last_image.tv_sec) + - (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; + (curtime.tv_sec - netcam->last_image.tv_sec) + + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", - netcam->av_frame_time); + netcam->av_frame_time); } netcam->last_image = curtime; @@ -330,15 +328,24 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) return 0; } + void netcam_shutdown_rtsp(netcam_context_ptr netcam) { - netcam_free_context(netcam); - free(netcam->rtsp->path); - free(netcam->rtsp->user); - free(netcam->rtsp->pass); + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); + + av_free(netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + + if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); + if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); + if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); free(netcam->rtsp); + + netcam->rtsp = NULL; + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); } #endif From ca413db53cdd3a97ce7a409822f8b401fadb968b Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 19 Jun 2014 20:17:20 -0600 Subject: [PATCH 009/233] Added support for libav V53 --- CHANGELOG | 12 +++- INSTALL | 72 +++++++++---------- configure.ac | 34 ++++++++- ffmpeg.c | 193 +++++++++----------------------------------------- ffmpeg.h | 3 + netcam.c | 21 +++--- netcam_rtsp.c | 110 +++++++++++----------------- 7 files changed, 163 insertions(+), 282 deletions(-) mode change 100644 => 100755 CHANGELOG mode change 100644 => 100755 INSTALL mode change 100644 => 100755 configure.ac mode change 100644 => 100755 ffmpeg.c mode change 100644 => 100755 ffmpeg.h mode change 100644 => 100755 netcam.c mode change 100644 => 100755 netcam_rtsp.c diff --git a/CHANGELOG b/CHANGELOG old mode 100644 new mode 100755 index ed34bf2..448557a --- a/CHANGELOG +++ b/CHANGELOG @@ -60,9 +60,15 @@ Features * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) * Plugged most(?) memory leaks in RTSP. (Mr-Dave) - * Undo changes caused by code editor and other unnecessary changes - * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. - * Regession fix for memory leaks and reconnection + * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) + * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) + * Regession fix for memory leaks and reconnection (Mr-Dave) + * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) + * Revised RTSP to support version 53 of libavformat (Mr-Dave) + * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) + * Revised INSTALL to have sample PI configure option.(Mr-Dave) + * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) + * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) Bugfixes diff --git a/INSTALL b/INSTALL old mode 100644 new mode 100755 index 8f49abd..fba3f71 --- a/INSTALL +++ b/INSTALL @@ -1,36 +1,36 @@ -Required Packages: - sudo apt-get install autoconf automake build-essential libjpeg-turbo8-dev libzip-dev - -Obtain source code (via git) - sudo apt-get install git - cd ~ - git clone {https://github.com/your favorite fork} - -To rebuild the motion configure file use - autoreconf - -Optional: With FFMPEG support: - Build FFMPEG via their instructions - - Change to location of the motion source code - cd ~/motion - - Configure with manually built ffmpeg which installs to ~/bin and ~/ffmpeg_build - Basic - ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include - - With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG - ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " - - With extra libraries for ffmpeg and install to ~/motion_build - ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " - -With APT versions of ffmpeg libraries - sudo apt-get install libavformat-dev libavcodec-dev - -Without any FFMPEG support or just any installed version of FFMPEG - ./configure - -Once configured type: - make - make install +Required Packages: + sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev + +Obtain source code (via git) + sudo apt-get install git + cd ~ + git clone {https://github.com/your favorite fork} + +To rebuild the motion configure file use + autoreconf + +Optional: With FFMPEG support: + Build FFMPEG via their instructions + Configure with manually built ffmpeg which currently installs to ~/bin and ~/ffmpeg_build + Basic + ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include + + With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG + ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + + With extra libraries for ffmpeg and install to ~/motion_build + ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + +With LIBAV APT versions of libraries + sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools + +Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat + ./configure + +Sample PI configuration with LIBAV + ./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf --with-ffmpeg-headers=/usr/include + + +Once configured type: + make + make install diff --git a/configure.ac b/configure.ac old mode 100644 new mode 100755 index ad54e6b..f25b40d --- a/configure.ac +++ b/configure.ac @@ -441,6 +441,11 @@ else if test "${FFMPEG_DIR}" = "yes"; then FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" FFMPEG_DIR="/usr" + elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib/i386-linux-gnu" + FFMPEG_DIR="/usr" else AC_MSG_RESULT(not found) echo "" @@ -551,7 +556,7 @@ if test "${FFMPEG_OK}" = "found"; then FFMPEG_OBJ="ffmpeg.o" AC_SUBST(FFMPEG_OBJ) - AC_MSG_CHECKING(avformat) + AC_MSG_CHECKING(avformat version 55) AC_RUN_IFELSE([AC_LANG_SOURCE([ [ #include <${AVFORMAT_DIR}> @@ -560,15 +565,38 @@ if test "${FFMPEG_OK}" = "found"; then return 0; } ]])], - [AC_MSG_RESULT(version previous to 55)], + [ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(avformat version 53) + AC_RUN_IFELSE([AC_LANG_SOURCE([ + [ + #include <${AVFORMAT_DIR}> + int main(void){ + if (LIBAVFORMAT_VERSION_MAJOR = 53) return -1; + return 0; + } + ]])], + [AC_MSG_RESULT(no)], [ - AC_MSG_RESULT(version 55 or higher) + AC_MSG_RESULT(yes) + TEMP_CFLAGS="${TEMP_CFLAGS} -DAVFMT_V53" + RTPS_OBJ="netcam_rtsp.o" + AC_SUBST(RTPS_OBJ) + ] + ) + ], + [ + AC_MSG_RESULT( yes version 55 or higher) TEMP_CFLAGS="${TEMP_CFLAGS} -DFFMPEG_V55" RTPS_OBJ="netcam_rtsp.o" AC_SUBST(RTPS_OBJ) ] ) + + + + AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS diff --git a/ffmpeg.c b/ffmpeg.c old mode 100644 new mode 100755 index 611e11e..492fe8e --- a/ffmpeg.c +++ b/ffmpeg.c @@ -14,7 +14,7 @@ #include "ffmpeg.h" #include "motion.h" - + #if LIBAVCODEC_BUILD > 4680 /* * FFmpeg after build 4680 doesn't have support for mpeg1 videos with @@ -150,89 +150,37 @@ URLProtocol mpeg1_file_protocol = { #include "avstring.h" #endif -/** - * file_open - * - */ -static int file_open(URLContext *h, const char *filename, int flags) -{ - const char *mode; - FILE *fh; - size_t bufsize = 0; - - av_strstart(filename, "file:", &filename); - - if (flags & URL_RDWR) { - mode = "wb+"; - bufsize = BUFSIZE_1MEG; - } else if (flags & URL_WRONLY) { - mode = "wb"; - bufsize = BUFSIZE_1MEG; - } else { - mode = "rb"; - } - fh = myfopen(filename, mode, bufsize); - if (fh == NULL) - return AVERROR(ENOENT); - h->priv_data = (void *)fh; - return 0; -} - -/** - * file_read - */ -static int file_read(URLContext *h, unsigned char *buf, int size) -{ - FILE *fh = (FILE *)h->priv_data; - return fread(buf, 1, size, fh); -} - -/** - * file_write - */ -static int file_write(URLContext *h, unsigned char *buf, int size) -{ - FILE *fh = (FILE *)h->priv_data; - return fwrite(buf, 1, size, fh); -} - -/** - * file_seek - */ -static int64_t file_seek(URLContext *h, int64_t pos, int whence) -{ - FILE *fh = (FILE *)h->priv_data; - if (fseek(fh, pos, whence)) - return -1; - return ftell(fh); -} +#endif // HAVE_FFMPEG_NEW -/** - * file_close - */ -static int file_close(URLContext *h) -{ - FILE *fh = (FILE *)h->priv_data; - return myfclose(fh); +#endif // FF_API_NEW_AVIO +/**************************************************************************** + * The section below is the "my" section of functions. + * These are designed to be extremely simple version specific + * variants of the libav functions. + ****************************************************************************/ +AVFrame *my_frame_alloc(void){ + AVFrame *pic; +#ifdef FFMPEG_V55 + pic = av_frame_alloc(); +#else + pic = avcodec_alloc_frame(); +#endif + return pic; } -URLProtocol file_protocol = { - "file", - file_open, - file_read, - file_write, - file_seek, - file_close, -#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) - NULL, - NULL, - NULL, +void my_frame_free(AVFrame *frame){ +#ifdef FFMPEG_V55 + av_frame_free(&frame); +#else + //avcodec_free_frame(&frame); + //av_frame_free(&netcam->rtsp->frame); + av_freep(&frame); #endif -}; - -#endif // HAVE_FFMPEG_NEW +} -#endif // FF_API_NEW_AVIO +/**************************************************************************** + **************************************************************************** + ****************************************************************************/ /** * mpeg1_write_trailer @@ -244,16 +192,8 @@ URLProtocol file_protocol = { */ static int mpeg1_write_trailer(AVFormatContext *s) { -#if defined FF_API_NEW_AVIO avio_write(s->pb, mpeg1_trailer, 4); avio_flush(s->pb); -#elif LIBAVFORMAT_BUILD >= (52<<16) - put_buffer(s->pb, mpeg1_trailer, 4); - put_flush_packet(s->pb); -#else - put_buffer(&s->pb, mpeg1_trailer, 4); - put_flush_packet(&s->pb); -#endif /* FF_API_NEW_AVIO -- LIBAVFORMAT_BUILD >= (52<<16) */ return 0; /* success */ } @@ -277,26 +217,6 @@ void ffmpeg_init() av_log_set_level(AV_LOG_ERROR); #endif -#if defined FF_API_NEW_AVIO -#else - /* - * Copy the functions to use for the append file protocol from the standard - * file protocol. - */ - mpeg1_file_protocol.url_read = file_protocol.url_read; - mpeg1_file_protocol.url_write = file_protocol.url_write; - mpeg1_file_protocol.url_seek = file_protocol.url_seek; - mpeg1_file_protocol.url_close = file_protocol.url_close; - -/* Register the append file protocol. */ -#ifdef FFMPEG_V55 - av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); -#else - av_register_protocol(&mpeg1_file_protocol); -#endif - -#endif // FF_API_NEW_AVIO - } /** @@ -458,7 +378,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); /* Allocation the output media context. */ -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) ffmpeg->oc = avformat_alloc_context(); #else ffmpeg->oc = av_alloc_format_context(); @@ -483,11 +403,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, /* Create a new video stream and initialize the codecs. */ ffmpeg->video_st = NULL; if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { -#if defined FF_API_NEW_AVIO ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); -#else - ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); -#endif if (!ffmpeg->video_st) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: av_new_stream - could" " not alloc stream"); @@ -549,18 +465,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->flags |= CODEC_FLAG_GLOBAL_HEADER; } -#if defined FF_API_NEW_AVIO -// pass the options to avformat_write_header directly -#else - /* Set the output parameters (must be done even if no parameters). */ - if (av_set_parameters(ffmpeg->oc, NULL) < 0) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: av_set_parameters error:" - " Invalid output format parameters"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } -#endif - /* Dump the format settings. This shows how the various streams relate to each other. */ //dump_format(ffmpeg->oc, 0, filename, 1); @@ -584,11 +488,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, pthread_mutex_lock(&global_lock); /* Open the codec */ -#if defined FF_API_NEW_AVIO ret = avcodec_open2(c, codec, NULL /* options */ ); -#else - ret = avcodec_open(c, codec); -#endif if (ret < 0) { /* Release the lock. */ @@ -615,11 +515,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, } /* Allocate the encoded raw picture. */ -#ifdef FFMPEG_V55 - ffmpeg->picture = av_frame_alloc(); -#else - ffmpeg->picture = avcodec_alloc_frame(); -#endif + ffmpeg->picture = my_frame_alloc(); if (!ffmpeg->picture) { MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -" @@ -659,11 +555,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(file_proto, sizeof(file_proto), "%s", filename); -#if defined FF_API_NEW_AVIO if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -#else - if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -#endif /* Path did not exist? */ if (errno == ENOENT) { /* Create path for file (don't use file_proto)... */ @@ -672,12 +564,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, return NULL; } -#if defined FF_API_NEW_AVIO if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -#else - /* And retry opening the file (use file_proto). */ - if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -#endif MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: url_fopen -" " error opening file %s", filename); ffmpeg_cleanups(ffmpeg); @@ -701,11 +588,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, } /* Write the stream header, if any. */ -#if defined FF_API_NEW_AVIO avformat_write_header(ffmpeg->oc, NULL); -#else - av_write_header(ffmpeg->oc); -#endif // FF_API_NEW_AVIO return ffmpeg; } @@ -773,13 +656,7 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { /* Close the output file. */ -#if defined FF_API_NEW_AVIO avio_close(ffmpeg->oc->pb); -#elif LIBAVFORMAT_BUILD >= (52<<16) - url_fclose(ffmpeg->oc->pb); -#else - url_fclose(&ffmpeg->oc->pb); -#endif /* FF_API_NEW_AVIO -- LIBAVFORMAT_BUILD >= (52<<16) */ } @@ -840,7 +717,7 @@ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, */ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) { - int out_size, ret, got_packet_ptr; + int out_size, ret; #ifdef FFMPEG_AVWRITEFRAME_NEWAPI AVPacket pkt; @@ -867,6 +744,8 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) } else { /* Encodes the image. */ #if defined FF_API_NEW_AVIO + + int got_packet_ptr; pkt.data = ffmpeg->video_outbuf; pkt.size = ffmpeg->video_outbuf_size; @@ -936,11 +815,7 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y, { AVFrame *picture; -#ifdef FFMPEG_V55 - picture = av_frame_alloc(); -#else - picture = avcodec_alloc_frame(); -#endif + picture = my_frame_alloc(); if (!picture) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc frame"); @@ -989,7 +864,7 @@ void ffmpeg_deinterlace(unsigned char *img, int width, int height) picture.linesize[2] = width2; /* We assume using 'PIX_FMT_YUV420P' always */ -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Deinterlace depreciated for recent versions of FFMPEG."); #else avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height); diff --git a/ffmpeg.h b/ffmpeg.h old mode 100644 new mode 100755 index a1e2e9d..86f4ec9 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -95,4 +95,7 @@ void ffmpeg_deinterlace(unsigned char *, int, int); /* Setup an avcodec log handler. */ void ffmpeg_avcodec_log(void *, int, const char *, va_list); +AVFrame *my_frame_alloc(void); +void my_frame_free(AVFrame *frame); + #endif /* _INCLUDE_FFMPEG_H_ */ diff --git a/netcam.c b/netcam.c old mode 100644 new mode 100755 index 8c269ec..843bc8f --- a/netcam.c +++ b/netcam.c @@ -45,7 +45,7 @@ #include #include "netcam_ftp.h" -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) #include "netcam_rtsp.h" #endif @@ -149,7 +149,7 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) { char *s; int i; -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) const char *re = "(http|ftp|mjpg|rtsp)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; #else @@ -211,7 +211,7 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) parse_url->port = 80; else if (!strcmp(parse_url->service, "ftp")) parse_url->port = 21; -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) else if (!strcmp(parse_url->service, "rtsp") && parse_url->port == 0) parse_url->port = 554; #endif @@ -2018,7 +2018,7 @@ static void *netcam_handler_loop(void *arg) } } -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) if (netcam->caps.streaming == NCS_RTSP) { if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Attempting to reconnect"); @@ -2433,7 +2433,7 @@ static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) return 0; } -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) { struct context *cnt = netcam->cnt; @@ -2518,7 +2518,6 @@ static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) */ ret = rtsp_connect(netcam); if (ret < 0){ - netcam_shutdown_rtsp(netcam); return ret; } @@ -2708,8 +2707,8 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) if (netcam->response != NULL) free(netcam->response); -#ifdef FFMPEG_V55 - if (netcam->caps.streaming == NCS_RTSP) +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) + if ((netcam->caps.streaming == NCS_RTSP) && (netcam->rtsp->connected == 1)) netcam_shutdown_rtsp(netcam); #endif @@ -2945,7 +2944,7 @@ int netcam_start(struct context *cnt) strcpy(url.service, "http"); /* Put back a real URL service. */ retval = netcam_setup_mjpg(netcam, &url); -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" " netcam_setup_rtsp()"); @@ -2975,7 +2974,7 @@ int netcam_start(struct context *cnt) return -1; } -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) if (netcam->caps.streaming != NCS_RTSP) { #endif /* @@ -3008,7 +3007,7 @@ int netcam_start(struct context *cnt) " is not modulo 8", netcam->height); return -3; } -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) } else { // not jpeg, get the dimensions netcam->width = netcam->rtsp->codec_context->width; diff --git a/netcam_rtsp.c b/netcam_rtsp.c old mode 100644 new mode 100755 index a209cad..6748a4f --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -2,11 +2,9 @@ #include "netcam_rtsp.h" #include "motion.h" -#ifdef FFMPEG_V55 +#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) -/* Only recent versions of FFMPEG are supported since - * no documentation on how to code the old versions exist - */ +#include "ffmpeg.h" /**************************************************** * Duplicated static functions - FIXME @@ -58,8 +56,10 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc) { int check = 0; - int ret = avcodec_decode_video2(cc, frame, &check, packet); - + int frame_size = 0; + int ret = 0; + + ret = avcodec_decode_video2(cc, frame, &check, packet); if (ret < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); return 0; @@ -70,14 +70,12 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram return 0; } - int frame_size = av_image_get_buffer_size(cc->pix_fmt, cc->width, cc->height, 1); - - /* Assure there's enough room in the buffer. */ + frame_size = avpicture_get_size(cc->pix_fmt, cc->width, cc->height); + netcam_check_buffsize(buffer, frame_size); - - av_image_copy_to_buffer((uint8_t *)buffer->ptr, frame_size, - (const uint8_t **)(frame->data), frame->linesize, - cc->pix_fmt, cc->width, cc->height, 1); + + avpicture_layout((const AVPicture*)frame,cc->pix_fmt,cc->width,cc->height + ,(unsigned char *)buffer->ptr,frame_size ); buffer->used = frame_size; @@ -92,7 +90,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV AVCodec *dec = NULL; ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); if (ret < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", av_get_media_type_string(type)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", type); return ret; } else { *stream_idx = ret; @@ -101,11 +99,11 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV dec_ctx = st->codec; dec = avcodec_find_decoder(dec_ctx->codec_id); if (!dec) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", av_get_media_type_string(type)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", type); return ret; } if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", av_get_media_type_string(type)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", type); return ret; } } @@ -136,7 +134,7 @@ struct rtsp_context *rtsp_new_context(void) return ret; } -static int decode_interrupt_cb(void *ctx) +static int interrupt_cb(void *ctx) { struct rtsp_context *rtsp = (struct rtsp_context *)ctx; @@ -158,33 +156,34 @@ static int decode_interrupt_cb(void *ctx) //should not be possible to get here return 0; } - - int rtsp_connect(netcam_context_ptr netcam) { - int ret; - + int ret; + char errstr[128]; + + netcam->rtsp->connected = 0; + if (netcam->rtsp->path == NULL) { MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); return -1; } - // open the network connection AVDictionary *opts = 0; av_dict_set(&opts, "rtsp_transport", "tcp", 0); netcam->rtsp->format_context = avformat_alloc_context(); - netcam->rtsp->format_context->interrupt_callback.callback = decode_interrupt_cb; + netcam->rtsp->format_context->interrupt_callback.callback = interrupt_cb; netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); if (ret < 0) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %d - %s", netcam->rtsp->path,av_err2str(ret)); + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); if (ret == -1094995529) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Authentication?"); av_dict_free(&opts); - avformat_close_input(&netcam->rtsp->format_context); + //The format context gets freed upon any error from open_input. return ret; } av_dict_free(&opts); @@ -207,10 +206,12 @@ int rtsp_connect(netcam_context_ptr netcam) netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; - netcam->rtsp->frame = av_frame_alloc(); - + netcam->rtsp->frame = my_frame_alloc(); + // start up the feed av_read_play(netcam->rtsp->format_context); + + netcam->rtsp->connected = 1; return 0; } @@ -218,10 +219,6 @@ int rtsp_connect(netcam_context_ptr netcam) int netcam_read_rtsp_image(netcam_context_ptr netcam) { - /* This code is called many times so optimize and do - * little as possible in here. - */ - struct timeval curtime; netcam_buff_ptr buffer; AVPacket packet; @@ -233,7 +230,6 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) buffer->used = 0; av_init_packet(&packet); - packet.data = NULL; packet.size = 0; @@ -264,12 +260,12 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) } netcam->rtsp->readingframe = 0; - // at this point, we are finished with the packet and frame, so free them. + // at this point, we are finished with the packet av_free_packet(&packet); if (size_decoded == 0) { // something went wrong, end of stream? Interupted? - MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: invalid frame! %d", size_decoded); + MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: invalid frame! %d ", size_decoded); av_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); @@ -284,57 +280,31 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) } - netcam->receiving->image_time = curtime; - /* - * Calculate our "running average" time for this netcam's - * frame transmissions (except for the first time). - * Note that the average frame time is held in microseconds. + * read is complete - set the current 'receiving' buffer atomically + * as 'latest', and make the buffer previously in 'latest' become + * the new 'receiving' and signal pic_ready. */ - if (netcam->last_image.tv_sec) { - netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * - (curtime.tv_sec - netcam->last_image.tv_sec) + - (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - - MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", - netcam->av_frame_time); - } - + netcam->receiving->image_time = curtime; netcam->last_image = curtime; - netcam_buff *xchg; - /* - * read is complete - set the current 'receiving' buffer atomically - * as 'latest', and make the buffer previously in 'latest' become - * the new 'receiving'. - */ pthread_mutex_lock(&netcam->mutex); - - xchg = netcam->latest; - netcam->latest = netcam->receiving; - netcam->receiving = xchg; - netcam->imgcnt++; - - /* - * We have a new frame ready. We send a signal so that - * any thread (e.g. the motion main loop) waiting for the - * next frame to become available may proceed. - */ - pthread_cond_signal(&netcam->pic_ready); - + xchg = netcam->latest; + netcam->latest = netcam->receiving; + netcam->receiving = xchg; + netcam->imgcnt++; + pthread_cond_signal(&netcam->pic_ready); pthread_mutex_unlock(&netcam->mutex); return 0; } - - void netcam_shutdown_rtsp(netcam_context_ptr netcam) { MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); - av_free(netcam->rtsp->frame); + my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); From 9d07be5478dcc0edd7e757a7cc67a6a38945dbe0 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 19 Jun 2014 20:57:32 -0600 Subject: [PATCH 010/233] Added support for libav V53 --- netcam_rtsp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netcam_rtsp.h b/netcam_rtsp.h index 35ad6a1..a1770ed 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -15,10 +15,10 @@ struct rtsp_context { char* user; char* pass; int readingframe; + int connected; struct timeval startreadtime; }; -//int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); struct rtsp_context *rtsp_new_context(void); void netcam_shutdown_rtsp(netcam_context_ptr netcam); int rtsp_connect(netcam_context_ptr netcam); From 225804cb95f9020693333d1465d9b14467b2a097 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 21 Jun 2014 00:11:46 -0600 Subject: [PATCH 011/233] RTSP fully functional with Libav packages(0.8 and 0.9) in addition to FFMpeg git --- CHANGELOG | 1 + configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 448557a..c3a7133 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -69,6 +69,7 @@ Features * Revised INSTALL to have sample PI configure option.(Mr-Dave) * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) + * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) Bugfixes diff --git a/configure.ac b/configure.ac index f25b40d..44211f8 100755 --- a/configure.ac +++ b/configure.ac @@ -567,12 +567,12 @@ if test "${FFMPEG_OK}" = "found"; then ]])], [ AC_MSG_RESULT(no) - AC_MSG_CHECKING(avformat version 53) + AC_MSG_CHECKING(avformat version 53/54) AC_RUN_IFELSE([AC_LANG_SOURCE([ [ #include <${AVFORMAT_DIR}> int main(void){ - if (LIBAVFORMAT_VERSION_MAJOR = 53) return -1; + if ((LIBAVFORMAT_VERSION_MAJOR = 53) || (LIBAVFORMAT_VERSION_MAJOR = 54)) return -1; return 0; } ]])], From abfd68a1274f1807e890dbdeadff471430da6c42 Mon Sep 17 00:00:00 2001 From: "Xubuntu 12.04" Date: Mon, 23 Jun 2014 20:06:42 -0700 Subject: [PATCH 012/233] Updated configure --- configure | 60 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/configure b/configure index a997f79..198f571 100755 --- a/configure +++ b/configure @@ -4334,6 +4334,12 @@ $as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" FFMPEG_DIR="/usr" + elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 +$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib/i386-linux-gnu" + FFMPEG_DIR="/usr" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } @@ -4458,8 +4464,8 @@ $as_echo "not found" >&6; } FFMPEG_OBJ="ffmpeg.o" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking avformat" >&5 -$as_echo_n "checking avformat... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking avformat version 55" >&5 +$as_echo_n "checking avformat version 55... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} @@ -4478,12 +4484,50 @@ else _ACEOF if ac_fn_c_try_run "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: version previous to 55" >&5 -$as_echo "version previous to 55" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking avformat version 53/54" >&5 +$as_echo_n "checking avformat version 53/54... " >&6; } + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - { $as_echo "$as_me:${as_lineno-$LINENO}: result: version 55 or higher" >&5 -$as_echo "version 55 or higher" >&6; } + + #include <${AVFORMAT_DIR}> + int main(void){ + if ((LIBAVFORMAT_VERSION_MAJOR = 53) || (LIBAVFORMAT_VERSION_MAJOR = 54)) return -1; + return 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + TEMP_CFLAGS="${TEMP_CFLAGS} -DAVFMT_V53" + RTPS_OBJ="netcam_rtsp.o" + + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes version 55 or higher" >&5 +$as_echo "yes version 55 or higher" >&6; } TEMP_CFLAGS="${TEMP_CFLAGS} -DFFMPEG_V55" RTPS_OBJ="netcam_rtsp.o" @@ -4495,6 +4539,10 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 $as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } saved_CFLAGS=$CFLAGS From 4a8f8de20aed932e375b64e784a8ee9555326785 Mon Sep 17 00:00:00 2001 From: tos Date: Tue, 24 Jun 2014 17:52:56 +0300 Subject: [PATCH 013/233] Remove some files that should not be in source tree config.h is auto generated upon configure, motion.mk808.conf was temporary experimental config from test branch - it's not needed in the scope of current fork --- config.h | 128 -------- motion.mk808.conf | 738 ---------------------------------------------- 2 files changed, 866 deletions(-) delete mode 100644 config.h delete mode 100644 motion.mk808.conf diff --git a/config.h b/config.h deleted file mode 100644 index c479b73..0000000 --- a/config.h +++ /dev/null @@ -1,128 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `get_current_dir_name' function. */ -#define HAVE_GET_CURRENT_DIR_NAME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LINUX_VIDEODEV2_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_VIDEODEV_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have MySQL support */ -/* #undef HAVE_MYSQL */ - -/* Define to 1 if you have PostgreSQL support */ -/* #undef HAVE_PGSQL */ - -/* Define to 1 if you have SDL support */ -#define HAVE_SDL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to 1 if you have SQLITE3 support */ -/* #undef HAVE_SQLITE3 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MMAN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "motion" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "motion trunkREVUNKNOWN" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "motion" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "trunkREVUNKNOWN" - -/* The size of `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of `int *', as computed by sizeof. */ -#define SIZEOF_INT_P 4 - -/* The size of `long int', as computed by sizeof. */ -#define SIZEOF_LONG_INT 4 - -/* The size of `long long', as computed by sizeof. */ -#define SIZEOF_LONG_LONG 8 - -/* The size of `short', as computed by sizeof. */ -#define SIZEOF_SHORT 2 - -/* The size of `void *', as computed by sizeof. */ -#define SIZEOF_VOID_P 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to 1 if you have av_avformat_alloc_context support */ -/* #undef have_av_avformat_alloc_context */ - -/* Define to 1 if you have av_get_media_type_string support */ -#define have_av_get_media_type_string 1 - -/* Define to 1 if you have av_register_protocol support */ -/* #undef have_av_register_protocol */ - -/* Define to 1 if you have av_register_protocol2 support */ -/* #undef have_av_register_protocol2 */ - -/* Define to 1 if you have avformat_alloc_context support */ -/* #undef have_avformat_alloc_context */ diff --git a/motion.mk808.conf b/motion.mk808.conf deleted file mode 100644 index ab1289d..0000000 --- a/motion.mk808.conf +++ /dev/null @@ -1,738 +0,0 @@ -# Rename this distribution example file to motion.conf -# -# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ - - -############################################################ -# Daemon -############################################################ - -# Start in daemon (background) mode and release terminal (default: off) -daemon on - -# File to store the process ID, also called pid file. (default: not defined) -process_id_file /var/run/motion/motion.pid - -############################################################ -# Basic Setup Mode -############################################################ - -# Start in Setup-Mode, daemon disabled. (default: off) -setup_mode off - - -# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) -;logfile /tmp/motion.log - -# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -log_level 6 - -# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -log_type all - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video0 - -# v4l2_palette allows to choose preferable palette to be use by motion -# to capture from those supported by your videodevice. (default: 17) -# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and -# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. -# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 -# instead. -# -# Values : -# V4L2_PIX_FMT_SN9C10X : 0 'S910' -# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -# V4L2_PIX_FMT_SPCA561 : 3 'S561' -# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -# V4L2_PIX_FMT_PAC207 : 6 'P207' -# V4L2_PIX_FMT_PJPG : 7 'PJPG' -# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -# V4L2_PIX_FMT_JPEG : 9 'JPEG' -# V4L2_PIX_FMT_RGB24 : 10 'RGB3' -# V4L2_PIX_FMT_SPCA501 : 11 'S501' -# V4L2_PIX_FMT_SPCA505 : 12 'S505' -# V4L2_PIX_FMT_SPCA508 : 13 'S508' -# V4L2_PIX_FMT_UYVY : 14 'UYVY' -# V4L2_PIX_FMT_YUYV : 15 'YUYV' -# V4L2_PIX_FMT_YUV422P : 16 '422P' -# V4L2_PIX_FMT_YUV420 : 17 'YU12' -# -v4l2_palette 8 - -# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) -# This is ONLY used for FreeBSD. Leave it commented out for Linux -; tunerdevice /dev/tuner0 - -# 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) -norm 0 - -# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) -frequency 0 - -# Rotate image this number of degrees. The rotation affects all saved images as -# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. -rotate 0 - -# Image width (pixels). Valid range: Camera dependent, default: 352 -#width 640 - -# Image height (pixels). Valid range: Camera dependent, default: 288 -#height 480 - -# Maximum number of frames to be captured per second. -# Valid range: 2-100. Default: 100 (almost no limit). -#framerate 10 - -# Minimum time in seconds between capturing picture frames from the camera. -# Default: 0 = disabled - the capture rate is given by the camera framerate. -# This option is used when you want to capture images at a rate lower than 2 per second. -minimum_frame_time 0 - -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -; netcam_url value - -# Username and password for network camera (only if required). Default: not defined -# Syntax is user:password -; netcam_userpass value - -# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -# on: Use HTTP/1.1 requests that support keep alive as default. -# Default: off -netcam_keepalive off - -# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". -# If a port number other than 80 is needed, use "http://myproxy:1234". -# Default: not defined -; netcam_proxy value - -# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -# Default: off -netcam_tolerant_check off - -# Let motion regulate the brightness of a video device (default: off). -# The auto_brightness feature uses the brightness option as its target value. -# If brightness is zero auto_brightness will adjust to average brightness value 128. -# Only recommended for cameras without auto brightness -auto_brightness off - -# Set the initial brightness of a video device. -# If auto_brightness is enabled, this value defines the average brightness level -# which Motion will try and adjust to. -# Valid range 0-255, default 0 = disabled -brightness 0 - -# Set the contrast of a video device. -# Valid range 0-255, default 0 = disabled -contrast 0 - -# Set the saturation of a video device. -# Valid range 0-255, default 0 = disabled -saturation 0 - -# Set the hue of a video device (NTSC feature). -# Valid range 0-255, default 0 = disabled -hue 0 - - -############################################################ -# Round Robin (multiple inputs on same video device name) -############################################################ - -# Number of frames to capture in each roundrobin step (default: 1) -roundrobin_frames 1 - -# Number of frames to skip before each roundrobin step (default: 1) -roundrobin_skip 1 - -# Try to filter out noise generated by roundrobin (default: off) -switchfilter off - - -############################################################ -# Motion Detection Settings: -############################################################ - -# Threshold for number of changed pixels in an image that -# triggers motion detection (default: 1500) -threshold 1500 - -# Automatically tune the threshold down if possible (default: off) -threshold_tune off - -# Noise threshold for the motion detection (default: 32) -noise_level 32 - -# Automatically tune the noise threshold (default: on) -noise_tune off - -# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) -# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. -# (l)abeling must only be used once and the 'l' must be the last letter. -# Comment out to disable -#despeckle_filter EedDl - -# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -# A script (on_area_detected) is started immediately when motion is 4 5 6 -# detected in one of the given areas, but only once during an event. 7 8 9 -# One or more areas can be specified with this option. Take care: This option -# does NOT restrict detection to these areas! (Default: not defined) -; area_detect value - -# PGM file to use as a sensitivity mask. -# Full path name to. (Default: not defined) -; mask_file value - -# Dynamically create a mask file during operation (default: 0) -# Adjust speed of mask changes from 0 (off) to 10 (fast) -smart_mask_speed 0 - -# Ignore sudden massive light intensity changes given as a percentage of the picture -# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled -lightswitch 0 - -# Picture frames must contain motion at least the specified number of frames -# in a row before they are detected as true motion. At the default of 1, all -# motion is detected. Valid range: 1 to thousands, recommended 1-5 -minimum_motion_frames 1 - -# Specifies the number of pre-captured (buffered) pictures from before motion -# was detected that will be output at motion detection. -# Recommended range: 0 to 5 (default: 0) -# Do not use large values! Large values will cause Motion to skip video frames and -# cause unsmooth movies. To smooth movies use larger values of post_capture instead. -pre_capture 0 - -# Number of frames to capture after motion is no longer detected (default: 0) -post_capture 5 - -# Event Gap is the seconds of no motion detection that triggers the end of an event. -# An event is defined as a series of motion images taken within a short timeframe. -# Recommended value is 60 seconds (Default). The value -1 is allowed and disables -# events causing all Motion to be written to one single movie file and no pre_capture. -# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An -# event ends right after no more motion is detected and post_capture is over. -event_gap 60 - -# Maximum length in seconds of a movie -# When value is exceeded a new movie file is created. (Default: 0 = infinite) -max_movie_time 600 - -# Always save images even if there was no motion (default: off) -emulate_motion off - - -############################################################ -# Image File Output -############################################################ - -# Output 'normal' pictures when motion is detected (default: on) -# Valid values: on, off, first, best, center -# When set to 'first', only the first picture of an event is saved. -# Picture with most motion of an event is saved when set to 'best'. -# Picture with motion nearest center of picture is saved when set to 'center'. -# Can be used as preview shot for the corresponding movie. -output_pictures best - -# Output pictures with only the pixels moving object (ghost images) (default: off) -output_debug_pictures off - -# The quality (in percent) to be used by the jpeg compression (default: 75) -quality 75 - -# Type of output images -# Valid values: jpeg, ppm (default: jpeg) -picture_type jpeg - -############################################################ -# FFMPEG related options -# Film (movies) file output, and deinterlacing of the video input -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################ - -# Use ffmpeg to encode movies in realtime (default: off) -ffmpeg_output_movies off - -# Use ffmpeg to make movies with only the pixels moving -# object (ghost images) (default: off) -ffmpeg_output_debug_movies off - -# Use ffmpeg to encode a timelapse movie -# Default value 0 = off - else save frame every Nth second -ffmpeg_timelapse 0 - -# The file rollover mode of the timelapse video -# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual -ffmpeg_timelapse_mode daily - -# Bitrate to be used by the ffmpeg encoder (default: 400000) -# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) -ffmpeg_bps 2000000 - -# Enables and defines variable bitrate for the ffmpeg encoder. -# ffmpeg_bps is ignored if variable bitrate is enabled. -# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, -# or the range 2 - 31 where 2 means best quality and 31 is worst. -ffmpeg_variable_bitrate 0 - -# Codec to used by ffmpeg for the video compression. -# Timelapse mpegs are always made in mpeg1 format independent from this option. -# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. -# mpeg1 - gives you files with extension .mpg -# mpeg4 or msmpeg4 - gives you files with extension .avi -# msmpeg4 is recommended for use with Windows Media Player because -# it requires no installation of codec on the Windows client. -# swf - gives you a flash film with extension .swf -# flv - gives you a flash video with extension .flv -# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -# mov - QuickTime ( testing ) -# ogg - Ogg/Theora ( testing ) -ffmpeg_video_codec mpeg4 - -# Use ffmpeg to deinterlace video. Necessary if you use an analog camera -# and see horizontal combing on moving objects in video or pictures. -# (default: off) -ffmpeg_deinterlace off - -############################################################ -# SDL Window -############################################################ - -# Number of motion thread to show in SDL Window (default: 0 = disabled) -sdl_threadnr 0 - -############################################################ -# External pipe to video encoder -# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################# - -# Bool to enable or disable extpipe (default: off) -use_extpipe on - -# External program (full path and opts) to pipe raw video to -# Generally, use '-' for STDIN... - -#extpipe x264 - --input-res 640x480 --fps %fps --bitrate 500 --preset ultrafast --quiet -o %f.mp4 - - -############################################################ -# Snapshots (Traditional Periodic Webcam File Output) -############################################################ - -# Make automated snapshot every N seconds (default: 0 = disabled) -snapshot_interval 0 - - -############################################################ -# Text Display -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, \n = new line, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event - do not use with text_event! -# You can put quotation marks around the text to allow -# leading spaces -############################################################ - -# Locate and draw a box around the moving object. -# Valid values: on, off, preview (default: off) -# Set to 'preview' will only draw a box in preview_shot pictures. -locate_motion_mode on - -# Set the look and style of the locate box if enabled. -# Valid values: box, redbox, cross, redcross (default: box) -# Set to 'box' will draw the traditional box. -# Set to 'redbox' will draw a red box. -# Set to 'cross' will draw a little cross to mark center. -# Set to 'redcross' will draw a little red cross to mark center. -locate_motion_style box - -# Draws the timestamp using same options as C function strftime(3) -# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -# Text is placed in lower right corner -text_right %Y-%m-%d\n%T-%q - -# Draw a user defined text on the images using same options as C function strftime(3) -# Default: Not defined = no text -# Text is placed in lower left corner -; text_left CAMERA %t - -# Draw the number of changed pixed on the images (default: off) -# Will normally be set to off except when you setup and adjust the motion settings -# Text is placed in upper right corner -text_changes off - -# This option defines the value of the special event conversion specifier %C -# You can use any conversion specifier in this option except %C. Date and time -# values are from the timestamp of the first image in the current event. -# Default: %Y%m%d%H%M%S -# The idea is that %C can be used filenames and text_left/right for creating -# a unique identifier for each event. -text_event %Y%m%d%H%M%S - -# Draw characters at twice normal size on images. (default: off) -text_double off - - -# Text to include in a JPEG EXIF comment -# May be any text, including conversion specifiers. -# The EXIF timestamp is included independent of this text. -;exif_text %i%J/%K%L - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, movie_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute path. (Default: current working directory) -#target_dir /home/ubuntu/cam0 - -# File path for snapshots (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-snapshot -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot -# File extension .jpg or .ppm is automatically added so do not include this. -# Note: A symbolic link called lastsnap.jpg created in the target_dir will always -# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -snapshot_filename lastsnap - -# File path for motion triggered images (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-%q -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this -# Set to 'preview' together with best-preview feature enables special naming -# convention for preview shots. See motion guide for details -picture_filename %v-%Y%m%d_%H-%M - -# File path for motion triggered ffmpeg films (movies) relative to target_dir -# Default: %v-%Y%m%d%H%M%S -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -# File extension .mpg or .avi is automatically added so do not include this -# This option was previously called ffmpeg_filename -movie_filename %v-%Y%m%d_%H-%M - -# File path for timelapse movies relative to target_dir -# Default: %Y%m%d-timelapse -# Default value is near equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse -# File extension .mpg is automatically added so do not include this -timelapse_filename %Y%m%d-timelapse - -############################################################ -# Global Network Options -############################################################ -# Enable or disable IPV6 for http control and stream (default: off ) -ipv6_enabled off - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8081 - -# Quality of the jpeg (in percent) images produced (default: 50) -stream_quality 50 - -# Output frames at 1 fps when no motion is detected and increase to the -# rate given by stream_maxrate when motion is detected (default: off) -stream_motion off - -# Maximum framerate for stream streams (default: 1) -stream_maxrate 1 - -# Restrict stream connections to localhost only (default: on) -stream_localhost off - -# Limits the number of images per connection (default: 0 = unlimited) -# Number can be defined by multiplying actual stream rate by desired number of seconds -# Actual stream rate is the smallest of the numbers framerate and stream_maxrate -stream_limit 0 - -# Set the authentication method (default: 0) -# 0 = disabled -# 1 = Basic authentication -# 2 = MD5 digest (the safer authentication) -stream_auth_method 0 - -# Authentication for the stream. Syntax username:password -# Default: not defined (Disabled) -; stream_authentication username:password - - -############################################################ -# HTTP Based Control -############################################################ - -# TCP/IP port for the http server to listen on (default: 0 = disabled) -webcontrol_port 8080 - -# Restrict control connections to localhost only (default: on) -webcontrol_localhost on - -# Output for http server, select off to choose raw text plain (default: on) -webcontrol_html_output on - -# Authentication for the http based control. Syntax username:password -# Default: not defined (Disabled) -; webcontrol_authentication username:password - - -############################################################ -# Tracking (Pan/Tilt) -############################################################# - -# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) -# The generic type enables the definition of motion center and motion size to -# be used with the conversion specifiers for options like on_motion_detected -track_type 0 - -# Enable auto tracking (default: off) -track_auto off - -# Serial port of motor (default: none) -;track_port /dev/ttyS0 - -# Motor number for x-axis (default: 0) -;track_motorx 0 - -# Set motorx reverse (default: 0) -;track_motorx_reverse 0 - -# Motor number for y-axis (default: 0) -;track_motory 1 - -# Set motory reverse (default: 0) -;track_motory_reverse 0 - -# Maximum value on x-axis (default: 0) -;track_maxx 200 - -# Minimum value on x-axis (default: 0) -;track_minx 50 - -# Maximum value on y-axis (default: 0) -;track_maxy 200 - -# Minimum value on y-axis (default: 0) -;track_miny 50 - -# Center value on x-axis (default: 0) -;track_homex 128 - -# Center value on y-axis (default: 0) -;track_homey 128 - -# ID of an iomojo camera if used (default: 0) -track_iomojo_id 0 - -# Angle in degrees the camera moves per step on the X-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_x 10 - -# Angle in degrees the camera moves per step on the Y-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_y 10 - -# Delay to wait for after tracking movement as number -# of picture frames (default: 10) -track_move_wait 10 - -# Speed to set the motor to (stepper motor option) (default: 255) -track_speed 255 - -# Number of steps to make (stepper motor option) (default: 40) -track_stepsize 40 - - -############################################################ -# External Commands, Warnings and Logging: -# You can use conversion specifiers for the on_xxxx commands -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# %f = filename with full path -# %n = number indicating filetype -# Both %f and %n are only defined for on_picture_save, -# on_movie_start and on_movie_end -# Quotation marks round string are allowed. -############################################################ - -# Do not sound beeps when detecting motion (default: on) -# Note: Motion never beeps when running in daemon mode. -quiet on - -# Command to be executed when an event starts. (default: none) -# An event starts at first motion detected after a period of no motion defined by event_gap -; on_event_start value - -# Command to be executed when an event ends after a period of no motion -# (default: none). The period of no motion is defined by option event_gap. -; on_event_end value - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# To give the filename as an argument to a command append it with %f -; on_picture_save value - -# Command to be executed when a motion frame is detected (default: none) -; on_motion_detected value - -# Command to be executed when motion in a predefined area is detected -# Check option 'area_detect'. (default: none) -; on_area_detected value - -# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_start value - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_end value - -# Command to be executed when a camera can't be opened or if it is lost -# NOTE: There is situations when motion don't detect a lost camera! -# It depends on the driver, some drivers dosn't detect a lost camera at all -# Some hangs the motion thread. Some even hangs the PC! (default: none) -; on_camera_lost value - -##################################################################### -# Common Options for database features. -# Options require database options to be active also. -##################################################################### - -# Log to the database when creating motion triggered picture file (default: on) -; sql_log_picture on - -# Log to the database when creating a snapshot image file (default: on) -; sql_log_snapshot on - -# Log to the database when creating motion triggered movie file (default: off) -; sql_log_movie off - -# Log to the database when creating timelapse movies file (default: off) -; sql_log_timelapse off - -# SQL query string that is sent to the database -# Use same conversion specifiers has for text features -# Additional special conversion specifiers are -# %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') - - -############################################################ -# Database Options -############################################################ - -# database type : mysql, postgresql, sqlite3 (default : not defined) -; database_type value - -# database to log to (default: not defined) -; database_dbname value - -# The host on which the database is located (default: localhost) -; database_host value - -# User account name for database (default: not defined) -; database_user value - -# User password for database (default: not defined) -; database_password value - -# Port on which the database is located -# mysql 3306 , postgresql 5432 (default: not defined) -; database_port value - -############################################################ -# Database Options For SQLite3 -############################################################ - -# SQLite3 database (file path) (default: not defined) -; sqlite3_db value - - - -############################################################ -# Video Loopback Device (vloopback project) -############################################################ - -# Output images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; video_pipe value - -# Output motion images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; motion_video_pipe value - - -############################################################## -# Thread config files - One for each camera. -# Except if only one camera - You only need this config file. -# If you have more than one camera you MUST define one thread -# config file for each camera in addition to this config file. -############################################################## - -# Remember: If you have more than one camera you must have one -# thread file for each camera. E.g. 2 cameras requires 3 files: -# This motion.conf file AND thread1.conf and thread2.conf. -# Only put the options that are unique to each camera in the -# thread config files. -; thread /usr/local/etc/thread1.conf -; thread /usr/local/etc/thread2.conf -; thread /usr/local/etc/thread3.conf -; thread /usr/local/etc/thread4.conf - -width 640 -height 480 -framerate 10 -extpipe x264 - --input-res %wx%h --fps %fps --bitrate 500 --preset ultrafast --quiet -o %f.mp4 -target_dir /home/ubuntu/cam0 - From 68cb3fee6d175c5e8d8f65823b719d4cdb5d4c4b Mon Sep 17 00:00:00 2001 From: tos Date: Tue, 24 Jun 2014 21:38:28 +0300 Subject: [PATCH 014/233] Restored 0644 permissions for some files CHANGELOG INSTALL ffmpeg.c ffmpeg.h netcam.c netcam_rtsp.c --- CHANGELOG | 0 INSTALL | 0 ffmpeg.c | 0 ffmpeg.h | 0 netcam.c | 0 netcam_rtsp.c | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CHANGELOG mode change 100755 => 100644 INSTALL mode change 100755 => 100644 ffmpeg.c mode change 100755 => 100644 ffmpeg.h mode change 100755 => 100644 netcam.c mode change 100755 => 100644 netcam_rtsp.c diff --git a/CHANGELOG b/CHANGELOG old mode 100755 new mode 100644 diff --git a/INSTALL b/INSTALL old mode 100755 new mode 100644 diff --git a/ffmpeg.c b/ffmpeg.c old mode 100755 new mode 100644 diff --git a/ffmpeg.h b/ffmpeg.h old mode 100755 new mode 100644 diff --git a/netcam.c b/netcam.c old mode 100755 new mode 100644 diff --git a/netcam_rtsp.c b/netcam_rtsp.c old mode 100755 new mode 100644 From 6c8ab8783530455c1ec888e9ea9bcb419ed69124 Mon Sep 17 00:00:00 2001 From: tos Date: Tue, 24 Jun 2014 21:50:55 +0300 Subject: [PATCH 015/233] Updated CHANGELOG with credits for some previous commits --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c3a7133..c23917b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -50,6 +50,10 @@ Features * Added support for ffmpeg 0.11 new API. * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) + * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) + * Buffer overflow vulnerabilities (hyperbolic2346) + * Redundand -- boundary prefix (torao) + * Proper size for memset and allocation size (Alfred Klomp) * Removed compiler warnings: (Mr-Dave) logger.c,jpegutils.c,netcam_ftp.c,track.c, picture.c,webhttpd.c,stream.c,ffmpeg.c From cdfcdc2a744a94dd5714ba25a5fa8b4da0aea3dc Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 26 Jun 2014 21:56:45 -0600 Subject: [PATCH 016/233] Additional validations for successful connection and clean up messages --- CHANGELOG | 2 ++ netcam.c | 8 ++++++-- netcam_rtsp.c | 49 +++++++++++++++++++++++++++++++++---------------- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c23917b..eb33e1d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -74,6 +74,8 @@ Features * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) + * Clean up the messaging for RTSP. + * Additional validations for RTSP connection and corrected free sequences Bugfixes diff --git a/netcam.c b/netcam.c index 843bc8f..aa4d12e 100644 --- a/netcam.c +++ b/netcam.c @@ -2021,13 +2021,17 @@ static void *netcam_handler_loop(void *arg) #if ((defined FFMPEG_V55) || (defined AVFMT_V53)) if (netcam->caps.streaming == NCS_RTSP) { if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Attempting to reconnect"); + if (netcam->rtsp->connected == 1){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Reconnecting with camera...."); + } rtsp_connect(netcam); continue; } else { // We think we are connected... if (netcam->get_image(netcam) < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image attempting to reconnect"); + if (netcam->rtsp->connected == 1){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image. Reconnecting with camera...."); + } //Nope. We are not or got bad image. Reconnect rtsp_connect(netcam); continue; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 6748a4f..1120090 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -98,7 +98,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV /* find decoder for the stream */ dec_ctx = st->codec; dec = avcodec_find_decoder(dec_ctx->codec_id); - if (!dec) { + if (dec == NULL) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", type); return ret; } @@ -146,7 +146,7 @@ static int interrupt_cb(void *ctx) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time"); } if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){ - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Timeout getting frame %d",interrupttime.tv_sec - rtsp->startreadtime.tv_sec); + MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Reading picture timed out for %s",rtsp->path); return 1; } else{ return 0; @@ -165,7 +165,7 @@ int rtsp_connect(netcam_context_ptr netcam) netcam->rtsp->connected = 0; if (netcam->rtsp->path == NULL) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); return -1; } @@ -180,8 +180,8 @@ int rtsp_connect(netcam_context_ptr netcam) ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); if (ret < 0) { av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); - if (ret == -1094995529) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Authentication?"); + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); + if (ret == -1094995529) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error opening camera. Authentication?"); av_dict_free(&opts); //The format context gets freed upon any error from open_input. return ret; @@ -191,28 +191,46 @@ int rtsp_connect(netcam_context_ptr netcam) // fill out stream information ret = avformat_find_stream_info(netcam->rtsp->format_context, NULL); if (ret < 0) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %d", ret); + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %s", errstr); avformat_close_input(&netcam->rtsp->format_context); return -1; } ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); if (ret < 0) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %d", ret); - avformat_close_input(&netcam->rtsp->format_context); + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); return -1; } netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; netcam->rtsp->frame = my_frame_alloc(); - + if (netcam->rtsp->frame == NULL) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + return -1; + } + // start up the feed - av_read_play(netcam->rtsp->format_context); - + ret = av_read_play(netcam->rtsp->format_context); + if (ret < 0) { + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open the camera: %s", errstr); + my_frame_free(netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + return -1; + } + netcam->rtsp->connected = 1; + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Camera connected"); + return 0; } @@ -237,7 +255,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) usual_size_decoded = 0; if (gettimeofday(&curtime, NULL) < 0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); + MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); } netcam->rtsp->startreadtime = curtime; @@ -265,7 +283,6 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) if (size_decoded == 0) { // something went wrong, end of stream? Interupted? - MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: invalid frame! %d ", size_decoded); av_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); @@ -274,7 +291,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) if (size_decoded != usual_size_decoded) { if (usual_size_decoded !=0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: unusual frame size of %d!", size_decoded); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: unusual frame size of %d!", size_decoded); } usual_size_decoded = size_decoded; } @@ -302,7 +319,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) void netcam_shutdown_rtsp(netcam_context_ptr netcam) { - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); @@ -315,7 +332,7 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam) free(netcam->rtsp); netcam->rtsp = NULL; - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); } #endif From 7c3164c6cb20f6b08e4c66071e6ab76607ac22c3 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 27 Jun 2014 21:54:22 -0600 Subject: [PATCH 017/233] Isolate RTSP and revise configure --- configure | 123 +++++++++++++++---------------------- ffmpeg.c | 14 ++--- netcam.c | 132 ++++------------------------------------ netcam_rtsp.c | 163 +++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 202 insertions(+), 230 deletions(-) diff --git a/configure b/configure index a997f79..720f000 100755 --- a/configure +++ b/configure @@ -1537,6 +1537,43 @@ fi } # ac_fn_c_try_link +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes @@ -1579,43 +1616,6 @@ fi } # ac_fn_c_try_run -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using @@ -4259,6 +4259,7 @@ fi # # Check for libavcodec and libavformat from ffmpeg # + FFMPEG_DIR="yes" FFMPEG_OK="no_found" FFMPEG_OBJ="" @@ -4334,6 +4335,12 @@ $as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" FFMPEG_DIR="/usr" + elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 +$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib/i386-linux-gnu" + FFMPEG_DIR="/usr" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } @@ -4458,43 +4465,6 @@ $as_echo "not found" >&6; } FFMPEG_OBJ="ffmpeg.o" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking avformat" >&5 -$as_echo_n "checking avformat... " >&6; } - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - - #include <${AVFORMAT_DIR}> - int main(void){ - if (LIBAVFORMAT_VERSION_MAJOR >= 55) return -1; - return 0; - } - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: version previous to 55" >&5 -$as_echo "version previous to 55" >&6; } -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: version 55 or higher" >&5 -$as_echo "version 55 or higher" >&6; } - TEMP_CFLAGS="${TEMP_CFLAGS} -DFFMPEG_V55" - RTPS_OBJ="netcam_rtsp.o" - - - -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 $as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } saved_CFLAGS=$CFLAGS @@ -4533,6 +4503,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi +# Revised RTSP module so that it can be included +# whether or not FFMPEG is found. + + RTPS_OBJ="netcam_rtsp.o" + # # Check SQLITE3 diff --git a/ffmpeg.c b/ffmpeg.c index 492fe8e..afde3f4 100755 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -160,7 +160,7 @@ URLProtocol mpeg1_file_protocol = { ****************************************************************************/ AVFrame *my_frame_alloc(void){ AVFrame *pic; -#ifdef FFMPEG_V55 +#if (LIBAVFORMAT_VERSION_MAJOR >= 55) pic = av_frame_alloc(); #else pic = avcodec_alloc_frame(); @@ -169,7 +169,7 @@ AVFrame *my_frame_alloc(void){ } void my_frame_free(AVFrame *frame){ -#ifdef FFMPEG_V55 +#if (LIBAVFORMAT_VERSION_MAJOR >= 55) av_frame_free(&frame); #else //avcodec_free_frame(&frame); @@ -378,7 +378,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); /* Allocation the output media context. */ -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) +#if (LIBAVFORMAT_VERSION_MAJOR >= 53) ffmpeg->oc = avformat_alloc_context(); #else ffmpeg->oc = av_alloc_format_context(); @@ -420,10 +420,10 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); c->codec_id = ffmpeg->oc->oformat->video_codec; -#if LIBAVCODEC_VERSION_MAJOR < 53 - c->codec_type = CODEC_TYPE_VIDEO; -#else +#if (LIBAVFORMAT_VERSION_MAJOR >= 53) c->codec_type = AVMEDIA_TYPE_VIDEO; +#else + c->codec_type = CODEC_TYPE_VIDEO; #endif is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; @@ -864,7 +864,7 @@ void ffmpeg_deinterlace(unsigned char *img, int width, int height) picture.linesize[2] = width2; /* We assume using 'PIX_FMT_YUV420P' always */ -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) +#if (LIBAVFORMAT_VERSION_MAJOR >= 53) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Deinterlace depreciated for recent versions of FFMPEG."); #else avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height); diff --git a/netcam.c b/netcam.c index 843bc8f..f99508d 100755 --- a/netcam.c +++ b/netcam.c @@ -45,9 +45,7 @@ #include #include "netcam_ftp.h" -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) #include "netcam_rtsp.h" -#endif #define CONNECT_TIMEOUT 10 /* Timeout on remote connection attempt */ #define READ_TIMEOUT 5 /* Default timeout on recv requests */ @@ -149,13 +147,9 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) { char *s; int i; -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) + const char *re = "(http|ftp|mjpg|rtsp)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; -#else - const char *re = "(http|ftp|mjpg)://(((.*):(.*))@)?" - "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; -#endif regex_t pattbuf; regmatch_t matches[10]; @@ -211,10 +205,8 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) parse_url->port = 80; else if (!strcmp(parse_url->service, "ftp")) parse_url->port = 21; -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) else if (!strcmp(parse_url->service, "rtsp") && parse_url->port == 0) parse_url->port = 554; -#endif } regfree(&pattbuf); @@ -232,7 +224,7 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) * Returns: Nothing * */ -static void netcam_url_free(struct url_t *parse_url) +void netcam_url_free(struct url_t *parse_url) { if (parse_url->service) { free(parse_url->service); @@ -2018,23 +2010,22 @@ static void *netcam_handler_loop(void *arg) } } -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) if (netcam->caps.streaming == NCS_RTSP) { - if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect + if (netcam->rtsp->connected == 0) { // We must have disconnected. Try to reconnect MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Attempting to reconnect"); - rtsp_connect(netcam); + netcam_connect_rtsp(netcam); continue; } else { // We think we are connected... if (netcam->get_image(netcam) < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image attempting to reconnect"); //Nope. We are not or got bad image. Reconnect - rtsp_connect(netcam); + netcam_connect_rtsp(netcam); continue; } } } -#endif + if (netcam->caps.streaming != NCS_RTSP) { if (netcam->get_image(netcam) < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error getting jpeg image"); @@ -2433,100 +2424,6 @@ static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) return 0; } -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) -static int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url) -{ - struct context *cnt = netcam->cnt; - const char *ptr; - int ret = -1; - - netcam->caps.streaming = NCS_RTSP; - - netcam->rtsp = rtsp_new_context(); - - if (netcam->rtsp == NULL) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); - netcam_shutdown_rtsp(netcam); - return -1; - } - - /* - * Allocate space for a working string to contain the path. - * The extra 5 is for "://", ":" and string terminator. - */ - - // force port to a sane value - if (netcam->connect_port > 65536) { - netcam->connect_port = 65536; - } else if (netcam->connect_port < 0) { - netcam->connect_port = 0; - } - - if (cnt->conf.netcam_userpass != NULL) { - ptr = cnt->conf.netcam_userpass; - } else { - ptr = url->userpass; /* Don't set this one NULL, gets freed. */ - } - - if (ptr != NULL) { - char *cptr; - if ((cptr = strchr(ptr, ':')) == NULL) { - netcam->rtsp->user = mystrdup(ptr); - } else { - netcam->rtsp->user = mymalloc((cptr - ptr)+2); //+2 for string terminator - memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); - netcam->rtsp->pass = mystrdup(cptr + 1); - } - } - - /* - Need a method to query the path and - determine the authentication type if needed. - avformat_open_input returns file not found when - it wants authentication and it is not provided. - right now, if user specified a password, we will - prepend it onto the path to make it happier so we - can at least try basic authentication. - */ - - if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { - ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) - + 5 + strlen(url->path) + 5 - + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 4 ); - sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", - url->service,netcam->rtsp->user,netcam->rtsp->pass, - netcam->connect_host, netcam->connect_port, url->path); - } - else { - ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) - + 5 + strlen(url->path) + 5); - sprintf((char *)ptr, "%s://%s:%d%s", url->service, - netcam->connect_host, netcam->connect_port, url->path); - } - netcam->rtsp->path = (char *)ptr; - - netcam_url_free(url); - - /* - * Now we need to set some flags for the callback function. - */ - netcam->rtsp->readingframe = 0; - - /* - * The RTSP context should be all ready to attempt a connection with - * the server, so we try .... - */ - ret = rtsp_connect(netcam); - if (ret < 0){ - return ret; - } - - netcam->get_image = netcam_read_rtsp_image; - - return 0; -} -#endif - /** * netcam_recv * @@ -2707,10 +2604,9 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) if (netcam->response != NULL) free(netcam->response); -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) + if ((netcam->caps.streaming == NCS_RTSP) && (netcam->rtsp->connected == 1)) netcam_shutdown_rtsp(netcam); -#endif pthread_mutex_destroy(&netcam->mutex); pthread_cond_destroy(&netcam->cap_cond); @@ -2944,13 +2840,11 @@ int netcam_start(struct context *cnt) strcpy(url.service, "http"); /* Put back a real URL service. */ retval = netcam_setup_mjpg(netcam, &url); -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" " netcam_setup_rtsp()"); retval = netcam_setup_rtsp(netcam, &url); -#endif } else { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam service '%s' - " "must be http, ftp, mjpg or file.", url.service); @@ -2974,9 +2868,9 @@ int netcam_start(struct context *cnt) return -1; } -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) + if (netcam->caps.streaming != NCS_RTSP) { -#endif + /* * If an error occurs in the JPEG decompression which follows this, * jpeglib will return to the code within this 'if'. If such an error @@ -3007,13 +2901,7 @@ int netcam_start(struct context *cnt) " is not modulo 8", netcam->height); return -3; } -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) - } else { - // not jpeg, get the dimensions - netcam->width = netcam->rtsp->codec_context->width; - netcam->height = netcam->rtsp->codec_context->height; - } -#endif + } /* Fill in camera details into context structure. */ cnt->imgs.width = netcam->width; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 6748a4f..23e1557 100755 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -2,16 +2,21 @@ #include "netcam_rtsp.h" #include "motion.h" -#if ((defined FFMPEG_V55) || (defined AVFMT_V53)) +#ifdef HAVE_FFMPEG +/*********************************************************** + * This top section is the real code that opens and processes + * the rtsp camera. In the #else section below there are + * basic functions that indicate that if FFmpeg/Libav is + * not installed, rtsp is not available. By blocking the + * #IFs this way, we are able to isolate all the rtsp code + * and avoid numerous #IF blocks in the other components. + ***********************************************************/ #include "ffmpeg.h" -/**************************************************** - * Duplicated static functions - FIXME - ****************************************************/ - +static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ /** - * netcam_check_buffsize + * netcam_buffsize_rtsp * * This routine checks whether there is enough room in a buffer to copy * some additional data. If there is not enough room, it will re-allocate @@ -23,8 +28,7 @@ * * Returns: Nothing */ -static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) -{ + int min_size_to_alloc; int real_alloc; int new_size; @@ -49,12 +53,8 @@ static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) buff->size = new_size; } -/**************************************************** - * End Duplicated static functions - FIXME - ****************************************************/ +static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ -static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc) -{ int check = 0; int frame_size = 0; int ret = 0; @@ -72,7 +72,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram frame_size = avpicture_get_size(cc->pix_fmt, cc->width, cc->height); - netcam_check_buffsize(buffer, frame_size); + netcam_buffsize_rtsp(buffer, frame_size); avpicture_layout((const AVPicture*)frame,cc->pix_fmt,cc->width,cc->height ,(unsigned char *)buffer->ptr,frame_size ); @@ -82,8 +82,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram return frame_size; } -static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type) -{ +static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ int ret; AVStream *st; AVCodecContext *dec_ctx = NULL; @@ -110,6 +109,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV return 0; } +struct rtsp_context *rtsp_new_context(void){ /** * rtsp_new_context * @@ -122,8 +122,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV * Returns: Pointer to the newly-created structure, NULL if error. * */ -struct rtsp_context *rtsp_new_context(void) -{ + struct rtsp_context *ret; /* Note that mymalloc will exit on any problem. */ @@ -134,8 +133,7 @@ struct rtsp_context *rtsp_new_context(void) return ret; } -static int interrupt_cb(void *ctx) -{ +static int netcam_interrupt_rtsp(void *ctx){ struct rtsp_context *rtsp = (struct rtsp_context *)ctx; if (rtsp->readingframe != 1) { @@ -156,8 +154,8 @@ static int interrupt_cb(void *ctx) //should not be possible to get here return 0; } -int rtsp_connect(netcam_context_ptr netcam) -{ + +int netcam_connect_rtsp(netcam_context_ptr netcam){ int ret; char errstr[128]; @@ -174,7 +172,7 @@ int rtsp_connect(netcam_context_ptr netcam) av_dict_set(&opts, "rtsp_transport", "tcp", 0); netcam->rtsp->format_context = avformat_alloc_context(); - netcam->rtsp->format_context->interrupt_callback.callback = interrupt_cb; + netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); @@ -211,13 +209,15 @@ int rtsp_connect(netcam_context_ptr netcam) // start up the feed av_read_play(netcam->rtsp->format_context); + netcam->width = netcam->rtsp->codec_context->width; + netcam->height = netcam->rtsp->codec_context->height; + netcam->rtsp->connected = 1; return 0; } -int netcam_read_rtsp_image(netcam_context_ptr netcam) -{ +int netcam_read_rtsp_image(netcam_context_ptr netcam){ struct timeval curtime; netcam_buff_ptr buffer; @@ -299,8 +299,8 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam) return 0; } -void netcam_shutdown_rtsp(netcam_context_ptr netcam) -{ + +void netcam_shutdown_rtsp(netcam_context_ptr netcam){ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); @@ -318,4 +318,113 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam) MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); } +int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ + struct context *cnt = netcam->cnt; + const char *ptr; + int ret = -1; + + netcam->caps.streaming = NCS_RTSP; + + netcam->rtsp = rtsp_new_context(); + + if (netcam->rtsp == NULL) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); + netcam_shutdown_rtsp(netcam); + return -1; + } + + /* + * Allocate space for a working string to contain the path. + * The extra 5 is for "://", ":" and string terminator. + */ + + // force port to a sane value + if (netcam->connect_port > 65536) { + netcam->connect_port = 65536; + } else if (netcam->connect_port < 0) { + netcam->connect_port = 0; + } + + if (cnt->conf.netcam_userpass != NULL) { + ptr = cnt->conf.netcam_userpass; + } else { + ptr = url->userpass; /* Don't set this one NULL, gets freed. */ + } + + if (ptr != NULL) { + char *cptr; + if ((cptr = strchr(ptr, ':')) == NULL) { + netcam->rtsp->user = mystrdup(ptr); + } else { + netcam->rtsp->user = mymalloc((cptr - ptr)+2); //+2 for string terminator + memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); + netcam->rtsp->pass = mystrdup(cptr + 1); + } + } + + /* + Need a method to query the path and + determine the authentication type if needed. + avformat_open_input returns file not found when + it wants authentication and it is not provided. + right now, if user specified a password, we will + prepend it onto the path to make it happier so we + can at least try basic authentication. + */ + + if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { + ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + + 5 + strlen(url->path) + 5 + + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 4 ); + sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", + url->service,netcam->rtsp->user,netcam->rtsp->pass, + netcam->connect_host, netcam->connect_port, url->path); + } + else { + ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + + 5 + strlen(url->path) + 5); + sprintf((char *)ptr, "%s://%s:%d%s", url->service, + netcam->connect_host, netcam->connect_port, url->path); + } + netcam->rtsp->path = (char *)ptr; + + netcam_url_free(url); + + /* + * Now we need to set some flags for the callback function. + */ + netcam->rtsp->readingframe = 0; + + /* + * The RTSP context should be all ready to attempt a connection with + * the server, so we try .... + */ + ret = netcam_connect_rtsp(netcam); + if (ret < 0){ + return ret; + } + + netcam->get_image = netcam_read_rtsp_image; + + return 0; +} + +#else +/*********************************************************** + * This section is when there is no FFmpeg/Libav. It only + * contains the functions called from netcam and they all + * return fail error codes and user messages. + ***********************************************************/ +int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); + return -1; +} +void netcam_shutdown_rtsp(netcam_context_ptr netcam){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); +}; +int netcam_connect_rtsp(netcam_context_ptr netcam){ + netcam->rtsp->connected = 0; + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); + return -1; +}; #endif From b9b4ef6b4dcf8d9de830ee749f9f8efe5be29ce7 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 27 Jun 2014 22:36:47 -0600 Subject: [PATCH 018/233] New configure and isolation of RTSP --- configure.ac | 47 ++++++----------------------------------------- netcam.h | 1 + netcam_rtsp.h | 19 +++++++++++++++++-- 3 files changed, 24 insertions(+), 43 deletions(-) diff --git a/configure.ac b/configure.ac index 44211f8..d36ef2f 100755 --- a/configure.ac +++ b/configure.ac @@ -375,6 +375,7 @@ fi # # Check for libavcodec and libavformat from ffmpeg # + FFMPEG_DIR="yes" FFMPEG_OK="no_found" FFMPEG_OBJ="" @@ -556,47 +557,6 @@ if test "${FFMPEG_OK}" = "found"; then FFMPEG_OBJ="ffmpeg.o" AC_SUBST(FFMPEG_OBJ) - AC_MSG_CHECKING(avformat version 55) - AC_RUN_IFELSE([AC_LANG_SOURCE([ - [ - #include <${AVFORMAT_DIR}> - int main(void){ - if (LIBAVFORMAT_VERSION_MAJOR >= 55) return -1; - return 0; - } - ]])], - [ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(avformat version 53/54) - AC_RUN_IFELSE([AC_LANG_SOURCE([ - [ - #include <${AVFORMAT_DIR}> - int main(void){ - if ((LIBAVFORMAT_VERSION_MAJOR = 53) || (LIBAVFORMAT_VERSION_MAJOR = 54)) return -1; - return 0; - } - ]])], - [AC_MSG_RESULT(no)], - [ - AC_MSG_RESULT(yes) - TEMP_CFLAGS="${TEMP_CFLAGS} -DAVFMT_V53" - RTPS_OBJ="netcam_rtsp.o" - AC_SUBST(RTPS_OBJ) - ] - ) - ], - [ - AC_MSG_RESULT( yes version 55 or higher) - TEMP_CFLAGS="${TEMP_CFLAGS} -DFFMPEG_V55" - RTPS_OBJ="netcam_rtsp.o" - AC_SUBST(RTPS_OBJ) - ] - ) - - - - - AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS @@ -625,6 +585,11 @@ if test "${FFMPEG_OK}" = "found"; then fi fi +# Revised RTSP module so that it can be included +# whether or not FFMPEG is found. + + RTPS_OBJ="netcam_rtsp.o" + AC_SUBST(RTPS_OBJ) # # Check SQLITE3 diff --git a/netcam.h b/netcam.h index 6062edf..ec19820 100644 --- a/netcam.h +++ b/netcam.h @@ -297,5 +297,6 @@ int netcam_start (struct context *); int netcam_next (struct context *, unsigned char *); void netcam_cleanup (struct netcam_context *, int); ssize_t netcam_recv(netcam_context_ptr, void *, size_t); +void netcam_url_free(struct url_t *parse_url); #endif diff --git a/netcam_rtsp.h b/netcam_rtsp.h index a1770ed..876b21e 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -1,11 +1,13 @@ #include "netcam.h" + +#ifdef HAVE_FFMPEG + #include #include #include #include #include - struct rtsp_context { AVFormatContext* format_context; AVCodecContext* codec_context; @@ -18,8 +20,21 @@ struct rtsp_context { int connected; struct timeval startreadtime; }; +#else +/**************************************** + * Dummy context for when no FFMPEG/Libav + * is on machine. These need to be primitive + * data types + *****************************************/ +struct rtsp_context { + int* format_context; + int readingframe; + int connected; +}; +#endif struct rtsp_context *rtsp_new_context(void); void netcam_shutdown_rtsp(netcam_context_ptr netcam); -int rtsp_connect(netcam_context_ptr netcam); +int netcam_connect_rtsp(netcam_context_ptr netcam); int netcam_read_rtsp_image(netcam_context_ptr netcam); +int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); From 4d8b57ffde51872ac89ee234f928f144fc95c1e2 Mon Sep 17 00:00:00 2001 From: "Xubuntu 12.04" Date: Thu, 3 Jul 2014 20:50:36 -0700 Subject: [PATCH 019/233] Additional validations on rtsp start --- CHANGELOG | 1 + configure | 7473 +++++++++++++++++++++++++++++++++++++++++++++++++ netcam.c | 9 +- netcam.h | 5 + netcam_rtsp.c | 244 +- netcam_rtsp.h | 6 +- 6 files changed, 7684 insertions(+), 54 deletions(-) create mode 100755 configure diff --git a/CHANGELOG b/CHANGELOG index eb33e1d..42729e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -76,6 +76,7 @@ Features * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) * Clean up the messaging for RTSP. * Additional validations for RTSP connection and corrected free sequences + * Removed seg fault on failure to open first image, comments, isolation of RTSP Bugfixes diff --git a/configure b/configure new file mode 100755 index 0000000..b9fbdbe --- /dev/null +++ b/configure @@ -0,0 +1,7473 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.68. +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= + +ac_unique_file="motion" +ac_unique_file="motion.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +BIN_PATH +EGREP +GREP +CPP +RTPS_OBJ +FFMPEG_OBJ +SDL_OBJ +VIDEO +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_linuxthreads +with_pwcbsd +with_bktr +with_v4l +with_sdl +with_jpeg_turbo +with_jpeg_mmx +with_ffmpeg +with_ffmpeg_headers +with_ffmpeg_libs +with_sqlite3 +with_mysql +with_mysql_lib +with_mysql_include +with_pgsql +with_pgsql_lib +with_pgsql_include +with_optimizecpu +with_developer_flags +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +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 this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-linuxthreads Use linuxthreads in BSD instead of native pthreads + + + --with-pwcbsd Use pwcbsd based webcams ( only BSD ) + + + --without-bktr Exclude to use bktr subsystem , that usually useful + for devices as network cameras ( ONLY used in *BSD). + + + --without-v4l Exclude using v4l (video4linux) subsystem. + Makes Motion so it only supports network cameras. + + --without-sdl Compile without sdl support to get stream in SDL window. + + --with-jpeg-turbo=DIR Specify the prefix for the install path for + jpeg-turbo for optimized jpeg handling (optional). + + --with-jpeg-mmx=DIR Specify the prefix for the install path for + jpeg-mmx for optimized jpeg handling (optional). + If this is not specified motion will try to find + the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. + + --with-ffmpeg=DIR Specify the prefix for the install path for + libavcodec/libavformat (part of ffmpeg) be able to + encode mpeg movies realtime. + If this is not specified motion will try to find + the libraries in /usr and /usr/local. + + --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. + + --with-ffmpeg-libs=libs Specify the extra libs for ffmpeg + + --without-sqlite3 Disable sqlite3 support in motion. + + --without-mysql Disable mysql support in motion. + + --with-mysql-lib=DIR Normally, configure will scan all possible default + installation paths for mysql libs. When it fails, use + this command to tell configure where mysql libs + installation root directory is. + + --with-mysql-include=DIR Normally, configure will scan all possible default + installation paths for mysql include. When it fails, use + this command to tell configure where mysql include + installation root directory is. + + --without-pgsql Disable PostgreSQL support in motion. + + --with-pgsql-lib=DIR Normally, configure will scan all possible default + installation paths for pgsql libs. When it fails, use + this command to tell configure where pgsql libs + installation root directory is. + + --with-pgsql-include=DIR Normally, configure will scan all possible default + installation paths for pgsql include. When it fails, use + this command to tell configure where pgsql include + installation root directory is. + + --without-optimizecpu Exclude autodetecting platform and cpu type. + This will disable the compilation of gcc + optimizing code by platform and cpu. + + --with-developer-flags Causes practically all of the possible gcc + warning flags to be set. This may produce + a large amount of warnings. + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.68 + +Copyright (C) 2010 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 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 $as_me, which was +generated by GNU Autoconf 2.68. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers config.h" + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +THREAD_CFLAGS="" +THREAD_CHECK="/usr/include/pthread.h" + +Darwin="" +FreeBSD="" + +LINUXTHREADS="no" + +# Check whether --with-linuxthreads was given. +if test "${with_linuxthreads+set}" = set; then : + withval=$with_linuxthreads; LINUXTHREADS="$withval" + +fi + + +PWCBSD="no" + +# Check whether --with-pwcbsd was given. +if test "${with_pwcbsd+set}" = set; then : + withval=$with_pwcbsd; PWCBSD="$withval" + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 +$as_echo_n "checking for Darwin... " >&6; } +Darwin=`uname -a | grep "Darwin"` + +if test "${Darwin}" = ""; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 +$as_echo_n "checking for *BSD... " >&6; } + + FreeBSD=`uname -a | grep "BSD"` + if test "${FreeBSD}" = ""; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + VIDEO="video.o video2.o video_common.o" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + if test "${LINUXTHREADS}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linuxthreads" >&5 +$as_echo_n "checking Linuxthreads... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +$as_echo "skipping" >&6; } + else + THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" + THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" + fi + + if test "${PWCBSD}" != "no"; then + VIDEO="video.o video2.o video_common.o" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" + else + VIDEO="video_freebsd.o" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" + fi + + TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" + TEMP_LIBS="-L/usr/local/lib" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Build with PWCBSD support $PWCBSD" >&5 +$as_echo "Build with PWCBSD support $PWCBSD" >&6; } + + fi +else + TEMP_CFLAGS="${CFLAGS} -I/sw/include" + TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" + TEMP_LIBS="-L/sw/lib" + VIDEO="video_freebsd.o" + FINK_LIB="-L/sw/lib" + Darwin="yes" + V4L="no" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Darwin" >&5 +$as_echo "$Darwin" >&6; } +fi + + + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +TEMP_LIBS="-lm ${TEMP_LIBS}" +TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" +TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" + +if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking bktr headers in /usr/include/dev/bktr" >&5 +$as_echo_n "checking bktr headers in /usr/include/dev/bktr... " >&6; } + + if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" + fi +# +# Check to Exclude BKTR +# +BKTR="yes" + +# Check whether --with-bktr was given. +if test "${with_bktr+set}" = set; then : + withval=$with_bktr; BKTR="$withval" + +fi + + + if test "${BKTR}" = "no"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + fi + +else + +# +# Check to Exclude V4L +# +V4L="yes" + +# Check whether --with-v4l was given. +if test "${with_v4l+set}" = set; then : + withval=$with_v4l; V4L="$withval" + +fi + + +fi + + +if test "${V4L}" = "no"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" +fi + + +if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linuxthreads" >&5 +$as_echo_n "checking for linuxthreads... " >&6; } + +# +# Check for thread header +# + if test -f "${THREAD_CHECK}"; then + HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" + THREADS="yes" + else + THREADS="no" + fi + +# +# Check for thread lib +# + if test -f "${THREAD_LIB_CHECK}" ; then + THREADS="yes" + LIB_THREAD="-llthread -llgcc_r" + else + THREADS="no" + fi + +# Checks for Library linuxthreads for FreeBSD +# +# linuxthreads on freeBSD, ports collection +# /usr/local/include/pthreads/linuxthreads/pthread.h +# #include +# /usr/local/lib/libpthread.so +# + + if test "${THREADS}" = "yes"; then + TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" + TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" + THREAD_CFLAGS="-D_THREAD_SAFE" + PTHREAD_SUPPORT="yes" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 +$as_echo "$THREADS" >&6; } + else + PTHREAD_SUPPORT="no" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 +$as_echo "$THREADS" >&6; } + echo + echo "You do not have linuxthread installed" + echo + fi + +elif test -f "${THREAD_CHECK}"; then + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking threads" >&5 +$as_echo_n "checking threads... " >&6; } + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + PTHREAD_LIB=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test x$PTHREAD_LIB != xyes; then + + if test "${FreeBSD}" != ""; then + TEMP_LIBS="$TEMP_LIBS -pthread" + TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" + else + TEMP_LIBS="$TEMP_LIBS -lpthread" + TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" + fi + PTHREAD_SUPPORT="yes" +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_SUPPORT" >&5 +$as_echo "$PTHREAD_SUPPORT" >&6; } + +else + echo + echo "You do not have threads support" + echo +fi + + +# +# Check for sdl library +# +SDL_SUPPORT="no" + +# Check whether --with-sdl was given. +if test "${with_sdl+set}" = set; then : + withval=$with_sdl; +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl" >&5 +$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; } +else + if test "${FreeBSD}" != ""; then + CONFIG_SDL='sdl11-config' + else + CONFIG_SDL='sdl-config' + fi + if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "$withval" = "yes"; then + echo "" + echo "****************************************************" + echo "* sdl-config could not be found. Please install it *" + echo "* and remove the --with-sdl configure argument. *" + echo "* libSDL can be found at http://www.libsdl.org *" + echo "****************************************************" + echo "" + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SDL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" + TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" + +$as_echo "#define HAVE_SDL 1" >>confdefs.h + + SDL_OBJ="sdl.o" + + fi +fi + +# +# Check for the libjpeg-turbo library +# +JPEG_TURBO="no" +JPEG_TURBO_OK="not_found" + + +# Check whether --with-jpeg-turbo was given. +if test "${with_jpeg_turbo+set}" = set; then : + withval=$with_jpeg_turbo; JPEG_TURBO="$withval" + +fi + + +if test "${JPEG_TURBO}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo" >&5 +$as_echo_n "checking for libjpeg-turbo... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +$as_echo "skipping" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo in -> ${JPEG_TURBO} <-" >&5 +$as_echo_n "checking for libjpeg-turbo in -> ${JPEG_TURBO} <-... " >&6; } + if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + JPEG_TURBO_OK="found" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + fi +fi + + +if test "${JPEG_TURBO_OK}" = "found"; then + saved_CFLAGS="$CFLAGS" + saved_LIBS="$LIBS" + saved_LDFLAGS="$LDFLAGS" + LDFLAGS="-L${JPEG_TURBO}/lib" + CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" + LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 +$as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } +if ${ac_cv_lib_jpeg_jpeg_start_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ljpeg $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char jpeg_start_compress (); +int +main () +{ +return jpeg_start_compress (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_jpeg_jpeg_start_compress=yes +else + ac_cv_lib_jpeg_jpeg_start_compress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 +$as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } +if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = xyes; then : + TEMP_LIBS="$LIBS" + TEMP_CFLAGS="${CFLAGS}" + TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" + JPEG_SUPPORT="yes" +fi + + LIBS="$saved_LIBS" + CFLAGS="$saved_CFLAGS" + LDFLAGS="$saved_LDFLAGS" + JPEG_SUPPORT_TURBO="yes" +fi + + +# +# Check for the special mmx accelerated jpeg library +# +JPEG_MMX="no" +JPEG_MMX_OK="not_found" + +# Check whether --with-jpeg-mmx was given. +if test "${with_jpeg_mmx+set}" = set; then : + withval=$with_jpeg_mmx; JPEG_MMX="$withval" + +fi + + +# +# --without-jpeg-mmx or with-jpeg-mmx=no +# + +if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx" >&5 +$as_echo_n "checking for libjpeg-mmx... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +$as_echo "skipping" >&6; } +elif test "${JPEG_MMX}" = "yes"; then + # AUTODETECT STATIC LIB + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx autodetecting" >&5 +$as_echo_n "checking for libjpeg-mmx autodetecting... " >&6; } + + if test -f /usr/lib/libjpeg-mmx.a ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + JPEG_MMX_OK="found" + JPEG_MMX="/usr/lib" + elif test -f /usr/local/lib/libjpeg-mmx.a ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + JPEG_MMX_OK="found" + JPEG_MMX="/usr/local/lib" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx in -> ${JPEG_MMX} <-" >&5 +$as_echo_n "checking for libjpeg-mmx in -> ${JPEG_MMX} <-... " >&6; } + if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + JPEG_MMX_OK="found" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + fi +fi + +if test "${JPEG_MMX_OK}" = "found"; then + saved_CFLAGS="$CFLAGS" + saved_LIBS="$LIBS" + CFLAGS="$CFLAGS -I${JPEG_MMX}" + LIBS="$LIBS -L${JPEG_MMX}" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg-mmx" >&5 +$as_echo_n "checking for jpeg_start_compress in -ljpeg-mmx... " >&6; } +if ${ac_cv_lib_jpeg_mmx_jpeg_start_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ljpeg-mmx $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char jpeg_start_compress (); +int +main () +{ +return jpeg_start_compress (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_jpeg_mmx_jpeg_start_compress=yes +else + ac_cv_lib_jpeg_mmx_jpeg_start_compress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&5 +$as_echo "$ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&6; } +if test "x$ac_cv_lib_jpeg_mmx_jpeg_start_compress" = xyes; then : + TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" + TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" + JPEG_SUPPORT="yes" +fi + + LIBS="$saved_LIBS" + CFLAGS="$saved_CFLAGS" + JPEG_SUPPORT_MMX="yes" +fi + +# +# Look for _a_ jpeg lib that will work. +# +if test x$JPEG_SUPPORT != xyes ; then + # Checks for libraries + LDFLAGS=$TEMP_LDFLAGS + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_set_defaults in -ljpeg" >&5 +$as_echo_n "checking for jpeg_set_defaults in -ljpeg... " >&6; } +if ${ac_cv_lib_jpeg_jpeg_set_defaults+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ljpeg $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char jpeg_set_defaults (); +int +main () +{ +return jpeg_set_defaults (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_jpeg_jpeg_set_defaults=yes +else + ac_cv_lib_jpeg_jpeg_set_defaults=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_set_defaults" >&5 +$as_echo "$ac_cv_lib_jpeg_jpeg_set_defaults" >&6; } +if test "x$ac_cv_lib_jpeg_jpeg_set_defaults" = xyes; then : + + TEMP_LIBS="$TEMP_LIBS -ljpeg" + JPEG_SUPPORT="yes" + +else + + echo + echo "You do not have libjpeg installed" + echo + + +fi + +fi + + +# +# Check for libavcodec and libavformat from ffmpeg +# + +FFMPEG_DIR="yes" +FFMPEG_OK="no_found" +FFMPEG_OBJ="" + +# Check whether --with-ffmpeg was given. +if test "${with_ffmpeg+set}" = set; then : + withval=$with_ffmpeg; FFMPEG_DIR="$withval" + +fi + + +# +# ffmpeg headers custom location +# +FFMPEG_HEADERS_DIR="yes" + +# Check whether --with-ffmpeg_headers was given. +if test "${with_ffmpeg_headers+set}" = set; then : + withval=$with_ffmpeg_headers; FFMPEG_HEADERS_DIR="$withval" + +fi + + +# +# ffmpeg custom extra libraries +# +FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz " + +# Check whether --with-ffmpeg-libs was given. +if test "${with_ffmpeg_libs+set}" = set; then : + withval=$with_ffmpeg_libs; FFMPEG_EXTRALIBS="$withval" + +fi + + +# +# --without-ffmpeg or with-ffmpeg=no +# +if test "${FFMPEG_DIR}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg" >&5 +$as_echo_n "checking for ffmpeg... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +$as_echo "skipping" >&6; } +# +# with-ffmpeg= or nothing +# +else if test "${FFMPEG_DIR}" = "yes"; then + # AUTODETECT STATIC/SHARED LIB + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting libraries" >&5 +$as_echo_n "checking for ffmpeg autodetecting libraries... " >&6; } + + if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib64" >&5 +$as_echo "found in /usr/lib64" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib64" + FFMPEG_DIR="/usr" + elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib" >&5 +$as_echo "found in /usr/lib" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib" + FFMPEG_DIR="/usr" + elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/local/lib" >&5 +$as_echo "found in /usr/local/lib" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/local/lib" + FFMPEG_DIR="/usr/local" + elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/x86_64-linux-gnu" >&5 +$as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" + FFMPEG_DIR="/usr" + elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 +$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib/i386-linux-gnu" + FFMPEG_DIR="/usr" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + echo "" + echo "**********************************************" + echo "* libavcodec.a or libavcodec.so or *" + echo "* libavformat.a or libavformat.so not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-" >&5 +$as_echo_n "checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-... " >&6; } + if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + FFMPEG_OK="found" + FFMPEG_LIB="${FFMPEG_DIR}/lib" + elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + FFMPEG_LIB="${FFMPEG_DIR}" + FFMPEG_OK="found" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + if test "${FFMPEG_OK}" != "found"; then + echo "" + echo "**********************************************" + echo "* libavcodec.a or libavcodec.so or *" + echo "* libavformat.a or libavformat.so not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi + fi +fi + + +# +# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found +# + +AVFORMAT_DIR="" + +if test "${FFMPEG_OK}" = "found"; then + if test "${FFMPEG_HEADERS_DIR}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 +$as_echo_n "checking for ffmpeg headers in ${FFMPEG_DIR}... " >&6; } + AVFORMAT_DIR="${FFMPEG_DIR}" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}" >&5 +$as_echo_n "checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}... " >&6; } + FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" + AVFORMAT_DIR="${FFMPEG_DIR}" + fi + + if test -f ${FFMPEG_DIR}/include/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 +$as_echo "found ${FFMPEG_DIR}/include/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" + AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" + elif test -f ${FFMPEG_DIR}/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 +$as_echo "found ${FFMPEG_DIR}/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR}" + AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" + elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 +$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" + AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" + elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 +$as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" + AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" + elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5 +$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" + AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" + elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/libavformat/avformat.h" >&5 +$as_echo "found ${FFMPEG_DIR}/libavformat/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" + AVFORMAT="-I{FFMPEG_DIR}/libavformat" + AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + FFMPEG_OK="no_found" + AVFORMAT_DIR="avformat.h" + echo "**********************************************" + echo "* avformat.h not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi + +# +# If ffmpeg libs and headers have been found +# + + if test "${FFMPEG_OK}" = "found"; then + TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" + TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" + + FFMPEG_OBJ="ffmpeg.o" + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 +$as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + + CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" + LIBS="$TEMP_LIBS" + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + #include <${AVFORMAT_DIR}> + URLProtocol test_file_protocol; + int main(void){ + test_file_protocol.url_read = file_protocol.url_read; + return 0; + } + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi +fi +fi + +# Revised RTSP module so that it can be included +# whether or not FFMPEG is found. + + RTPS_OBJ="netcam_rtsp.o" + + +# +# Check SQLITE3 +# + +SQLITE3_SUPPORT="no" + +# Check whether --with-sqlite3 was given. +if test "${with_sqlite3+set}" = set; then : + withval=$with_sqlite3; SQLITE3="$withval" + # if not given argument, assume standard + +fi + + +if test "${SQLITE3}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3" >&5 +$as_echo_n "checking for sqlite3... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +$as_echo "skipping" >&6; } +else + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_open (); +int +main () +{ +return sqlite3_open (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_open=yes +else + ac_cv_lib_sqlite3_sqlite3_open=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then : + + TEMP_LIBS="$TEMP_LIBS -lsqlite3" + SQLITE3_SUPPORT="yes" + +$as_echo "#define HAVE_SQLITE3 1" >>confdefs.h + + + +fi + + + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS +fi + + +# +# Check Mysql +# + +MYSQL="yes" +MYSQL_SUPPORT="no" +MYSQL_HEADERS="yes" +MYSQL_LIBS="yes" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql support" >&5 +$as_echo_n "checking for mysql support... " >&6; } + + +# Check whether --with-mysql was given. +if test "${with_mysql+set}" = set; then : + withval=$with_mysql; MYSQL="$withval" +# if not given argument, assume standard + +fi + + + +# Check whether --with-mysql-lib was given. +if test "${with_mysql_lib+set}" = set; then : + withval=$with_mysql_lib; MYSQL_LIBS="$withval" +# if not given argument, assume standard + +fi + + + + +# Check whether --with-mysql-include was given. +if test "${with_mysql_include+set}" = set; then : + withval=$with_mysql_include; MYSQL_HEADERS="$withval" +# if not given argument, assume standard + +fi + + + +if test "${MYSQL}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: testing" >&5 +$as_echo "testing" >&6; } + # ******* Search mysql headers ******* + + if test "${MYSQL_HEADERS}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql headers" >&5 +$as_echo_n "checking autodect mysql headers... " >&6; } + # Autodetect + for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do + # check for plain setups + if test -f $w/mysql.h; then + MYSQL_INCDIR=$w + break + fi + # check for "/usr/include/" type setups + if test -f $w/mysql/mysql.h; then + MYSQL_INCDIR=$w/mysql + break + fi + # check for "/usr//include" type setups + if test -f $w/mysql/include/mysql.h; then + MYSQL_INCDIR=$w/mysql/include + break + fi + done + elif test "${MYSQL_HEADERS}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers" >&5 +$as_echo_n "checking for mysql headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers in $MYSQL_HEADERS" >&5 +$as_echo_n "checking for mysql headers in $MYSQL_HEADERS... " >&6; } + # Manual detection for + if test -f $MYSQL_HEADERS/mysql.h; then + MYSQL_INCDIR=$MYSQL_HEADERS + fi + fi + + if test -z "$MYSQL_INCDIR" ; then + MYSQL_HEADERS="no" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + echo "Invalid MySQL directory - unable to find mysql.h." + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_INCDIR yes" >&5 +$as_echo "$MYSQL_INCDIR yes" >&6; } + MYSQL_HEADERS="yes" + fi + + + if test "${MYSQL_HEADERS}" = "yes"; then + + # ******* Search mysql libs ********* + if test "${MYSQL_LIBS}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql libs" >&5 +$as_echo_n "checking autodect mysql libs... " >&6; } + # Autodetect + for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do + # check for plain setups + if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then + MYSQL_LIBDIR=$w + break + fi + # check for "/usr/lib/" type setups + if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then + MYSQL_LIBDIR=$w/mysql + break + fi + # check for "/usr//lib" type setups + if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then + MYSQL_LIBDIR=$w/mysql/lib + break + fi + done + elif test "${MYSQL_LIBS}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 +$as_echo_n "checking for mysql libs... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs in $MYSQL_LIBS" >&5 +$as_echo_n "checking for mysql libs in $MYSQL_LIBS... " >&6; } + # Manual detection for + if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then + MYSQL_LIBDIR=$MYSQL_LIBS + fi + fi + + + if test -z "$MYSQL_LIBDIR" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_LIBDIR" >&5 +$as_echo "$MYSQL_LIBDIR" >&6; } + #LDFLAGS="-L$MYSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$MYSQL_INCDIR" + LIBS="-L$MYSQL_LIBDIR" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 +$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } +if ${ac_cv_lib_mysqlclient_mysql_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmysqlclient $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char mysql_init (); +int +main () +{ +return mysql_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_mysqlclient_mysql_init=yes +else + ac_cv_lib_mysqlclient_mysql_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 +$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } +if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then : + + TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" + TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" + MYSQL_SUPPORT="yes" + +$as_echo "#define HAVE_MYSQL 1" >>confdefs.h + + +else + as_fn_error $? "MySQL support can't build without MySQL libraries" "$LINENO" 5 +fi + + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + # end mysql-include , mysql-libs + fi + +# end Mysql detection +fi + + +# +# Check PostgreSQL +# +PGSQL="yes" +PGSQL_SUPPORT="no" +PGSQL_HEADERS="yes" +PGSQL_LIBS="yes" + + + + +# Check whether --with-pgsql was given. +if test "${with_pgsql+set}" = set; then : + withval=$with_pgsql; PGSQL="$withval" +# if not given argument, assume standard + +fi + + + +# Check whether --with-pgsql-lib was given. +if test "${with_pgsql_lib+set}" = set; then : + withval=$with_pgsql_lib; PGSQL_LIBS="$withval" +# if not given argument, assume standard + +fi + + + +# Check whether --with-pgsql-include was given. +if test "${with_pgsql_include+set}" = set; then : + withval=$with_pgsql_include; PGSQL_HEADERS="$withval" +# if not given argument, assume standard + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PostgreSQL" >&5 +$as_echo_n "checking for PostgreSQL... " >&6; } + +if test "${PGSQL}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: testing" >&5 +$as_echo "testing" >&6; } + + # ******* Search pgsql headers ******* + if test "${PGSQL_HEADERS}" = "yes"; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql headers" >&5 +$as_echo_n "checking autodect pgsql headers... " >&6; } + # Autodetect + for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do + if test -r $i/include/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i/include + elif test -r $i/include/pgsql/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i/include/pgsql + elif test -r $i/include/postgresql/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i/include/postgresql + fi + done + + elif test "${PGSQL_HEADERS}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers" >&5 +$as_echo_n "checking for pgsql headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers in $PGSQL_HEADERS" >&5 +$as_echo_n "checking for pgsql headers in $PGSQL_HEADERS... " >&6; } + # Manual detection for + if test -f $PGSQL_HEADERS/libpq-fe.h; then + PGSQL_INCDIR=$PGSQL_HEADERS + fi + fi + + if test -z "$PGSQL_INCDIR" ; then + PGSQL_HEADERS="no" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes $PGSQL_INCDIR" >&5 +$as_echo "yes $PGSQL_INCDIR" >&6; } + PGSQL_HEADERS="yes" + fi + + + if test "${PGSQL_HEADERS}" = "yes"; then + + # ******* Search pgsql libs ********* + if test "${PGSQL_LIBS}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 +$as_echo_n "checking autodect pgsql libs... " >&6; } + # Autodetect + PGSQL_INCLUDE="-I$PGSQL_INCDIR" + PGSQL_LIBDIR=$PGSQL_DIR/lib + + if test -f /usr/lib64/libpq.so ; then + PGSQL_LIBDIR=/usr/lib64 + elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql + elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql + elif test -f $PGSQL_DIR/lib/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib + else + PGSQL_LIBDIR="" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 +$as_echo "$PGSQL_LIBDIR" >&6; } + + elif test "${PGSQL_LIBS}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 +$as_echo_n "checking for pgsql libs... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 +$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } + # Manual detection for + if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then + PGSQL_LIBDIR=$PGSQL_LIBS + fi + fi + + + if test -z "$PGSQL_LIBDIR" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." + else + #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$PGSQL_INCDIR" + LIBS="-L$PGSQL_LIBDIR" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 +$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } +if ${ac_cv_lib_pq_PQconnectStart+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpq $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char PQconnectStart (); +int +main () +{ +return PQconnectStart (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pq_PQconnectStart=yes +else + ac_cv_lib_pq_PQconnectStart=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 +$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } +if test "x$ac_cv_lib_pq_PQconnectStart" = xyes; then : + + PGSQL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" + TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" + +$as_echo "#define HAVE_PGSQL 1" >>confdefs.h + + +else + as_fn_error $? "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 +fi + + LDFLAGS="" + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + fi # end pgsql-include , pgsql-libs + +# end PostgreSQL detection +fi + + +#Checks for header files. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_func in get_current_dir_name +do : + ac_fn_c_check_func "$LINENO" "get_current_dir_name" "ac_cv_func_get_current_dir_name" +if test "x$ac_cv_func_get_current_dir_name" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GET_CURRENT_DIR_NAME 1 +_ACEOF + +fi +done + + +# Check if v4l2 is available +SUPPORTED_V4L2=false +SUPPORTED_V4L2_old=false + +if test "${V4L}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 +$as_echo_n "checking for V42L support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +$as_echo "skipping" >&6; } +else + ac_fn_c_check_type "$LINENO" "struct v4l2_buffer" "ac_cv_type_struct_v4l2_buffer" "#include + #include +" +if test "x$ac_cv_type_struct_v4l2_buffer" = xyes; then : + SUPPORTED_V4L2=true +else + SUPPORTED_V4L2=false +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 +$as_echo_n "checking for V42L support... " >&6; } + if test x$SUPPORTED_V4L2 = xtrue; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + + # linux/videodev.h doesn't include videodev2.h + if test x$SUPPORTED_V4L2 = xfalse; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L *old* support" >&5 +$as_echo_n "checking for V42L *old* support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: testing" >&5 +$as_echo "testing" >&6; } + for ac_header in linux/videodev2.h +do : + ac_fn_c_check_header_compile "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "#include +" +if test "x$ac_cv_header_linux_videodev2_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_VIDEODEV2_H 1 +_ACEOF + SUPPORTED_V4L2_old=true +fi + +done + + fi + + + if test x$SUPPORTED_V4L2_old = xtrue; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" + SUPPORTED_V4L2=true + fi + +fi + + +# Check sizes of integer types +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 +$as_echo_n "checking size of short... " >&6; } +if ${ac_cv_sizeof_short+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_short" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (short) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_short=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 +$as_echo "$ac_cv_sizeof_short" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_SHORT $ac_cv_sizeof_short +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 +$as_echo_n "checking size of int... " >&6; } +if ${ac_cv_sizeof_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 +$as_echo "$ac_cv_sizeof_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT $ac_cv_sizeof_int +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5 +$as_echo_n "checking size of long int... " >&6; } +if ${ac_cv_sizeof_long_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_long_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (long int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_int" >&5 +$as_echo "$ac_cv_sizeof_long_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG_INT $ac_cv_sizeof_long_int +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 +$as_echo_n "checking size of long long... " >&6; } +if ${ac_cv_sizeof_long_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_long_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (long long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 +$as_echo "$ac_cv_sizeof_long_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 +$as_echo_n "checking size of int *... " >&6; } +if ${ac_cv_sizeof_int_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_int_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (int *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int_p" >&5 +$as_echo "$ac_cv_sizeof_int_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT_P $ac_cv_sizeof_int_p +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 +$as_echo_n "checking size of void *... " >&6; } +if ${ac_cv_sizeof_void_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (void *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_void_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 +$as_echo "$ac_cv_sizeof_void_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +_ACEOF + + + +if test "$ac_cv_sizeof_short" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" +else + if test "$ac_cv_sizeof_int" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" + else + if test "$ac_cv_sizeof_long_int" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" + fi + fi +fi + + +OPTIMIZECPU="yes" + + +# Check whether --with-optimizecpu was given. +if test "${with_optimizecpu+set}" = set; then : + withval=$with_optimizecpu; OPTIMIZECPU="$withval" + +fi + + +DEVELOPER_FLAGS="no" + + +# Check whether --with-developer-flags was given. +if test "${with_developer_flags+set}" = set; then : + withval=$with_developer_flags; DEVELOPER_FLAGS="$withval" + +fi + + +# Checks for typedefs, structures, and compiler characteristics. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + + +if test "${FreeBSD}" != ""; then + OPTIMIZECPU="" +fi + +if test "${OPTIMIZECPU}" = "yes"; then + +# Try to autodetect cpu type +CPU_NAME="unknown" +CPU_TYPE="unknown" +if test -e "/proc/cpuinfo" ; then + intel[30]="-march=i386" + intel[32]="-march=i386" + intel[34]="-march=i386" + intel[40]="-march=i486" + intel[41]="-march=i486" + intel[42]="-march=i486" + intel[43]="-march=i486" + intel[44]="-march=i486" + intel[45]="-march=i486" + intel[47]="-march=i486" + intel[48]="-march=i486" + intel[51]="-march=pentium" + intel[52]="-march=pentium" + intel[54]="-march=pentium-mmx" + intel[56]="-march=pentium-mmx" + intel[61]="-march=pentiumpro" + intel[63]="-march=pentium2" + intel[65]="-march=pentium2" + intel[66]="-march=pentium2" + intel[67]="-march=pentium3" + intel[68]="-march=pentium3" + intel[610]="-march=pentium3" + intel[611]="-march=pentium3" + intel[150]="-march=pentium4" + intel[151]="-march=pentium4" + intel[152]="-march=pentium4" + intel[154]="-march=pentium4" + intel[614]="-march=prescott" + intel[628]="-march=core2" + amd[50]="-march=i586" + amd[51]="-march=i586" + amd[52]="-march=i586" + amd[53]="-march=i586" + amd[56]="-march=k6" + amd[57]="-march=k6" + amd[58]="-march=k6-2" + amd[510]="-march=k6-2" + amd[59]="-march=k6-3" + amd[513]="-march=k6-3" + amd[61]="-march=athlon" + amd[62]="-march=athlon" + amd[63]="-march=athlon" + amd[64]="-march=athlon" + amd[66]="-march=athlon" + amd[67]="-march=athlon" + amd[68]="-march=athlon" + amd[610]="-march=athlon" + amd[158]="-march=athlon-xp" + amd[154]="-march=k8" + amd[155]="-march=athlon64" + amd[1543]="-march=athlon64" + amd[1544]="-march=athlon64" + amd[1565]="-march=opteron" + amd[1572]="-march=k8" + via[67]="-march=c3" + via[68]="-march=c3" + via[69]="-march=i686" + via[610]="-march=i686" + + CPU_TYPE="known" + CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` + CPU_MODEL=`cat /proc/cpuinfo | grep model[^\ ] | head -n1` + CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` + CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` + CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` + CPU_FAMILY=${CPU_FAMILY#*: } + CPU_MODEL=${CPU_MODEL#*: } + CPU_NAME=${CPU_NAME#*: } + CPU_FLAGS=${CPU_FLAGS#*: } + CPU_VENDOR=${CPU_VENDOR#*: } + if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then + CPU_OPTIONS=${intel[$CPU_FAMILY$CPU_MODEL]} + fi + if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then + CPU_OPTIONS=${amd[$CPU_FAMILY$CPU_MODEL]} + fi + if test "x${CPU_VENDOR}" = "xCentaurHauls"; then + CPU_OPTIONS=${via[$CPU_FAMILY$CPU_MODEL]} + fi + if test "x${CPU_OPTIONS}" = "x" ; then + CPU_TYPE="unknown" + fi + CPU_EXT="" + for i in $CPU_FLAGS ; do + case $i in + fpu) + CPU_FPU="-mfpmath=387" + ;; + mmx) + CPU_EXT="$CPU_EXT -mmmx" + ;; + sse) + CPU_FPU="-mfpmath=sse -msse" + ;; + sse2) + CPU_FPU="-mfpmath=sse -msse2" + ;; + sse3) + CPU_FPU="-msse3" + ;; + ssse3) + CPU_FPU="-mfpmath=sse -msse2 -mssse3" + ;; + 3dnow) + CPU_EXT="$CPU_EXT -m3dnow" + ;; + esac + done + CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" +fi +if test "x${CPU_TYPE}" = "xunknown"; then + CPU_TYPE=`( uname -p ) 2>&1` + case $CPU_TYPE in + i386) + CPU_OPTIONS="-march=i386" + ;; + i486) + CPU_OPTIONS="-march=i486" + ;; + Pentium2) + CPU_OPTIONS="-march=pentium2" + ;; + Pentiumpro) + CPU_OPTIONS="-march=pentiumpro" + ;; + Pentium*) + CPU_OPTIONS="-march=pentium" + ;; + k6) + CPU_OPTIONS="-march=k6" + ;; + k6-2) + CPU_OPTIONS="-march=k6-2" + ;; + k6-3) + CPU_OPTIONS="-march=k6-3" + ;; + "VIA C3 Ezra") + CPU_OPTIONS="-march=c3" + CPU_TYPE="known" + ;; + *) + CPU_OPTIONS="" + CPU_TYPE="unknown" + ;; + esac + if test "x${CPU_TYPE}" = "xunknown"; then + CPU_TYPE=`( uname -m ) 2>&1` + case $CPU_TYPE in + i386) + CPU_OPTIONS="-march=i386" + ;; + i486) + CPU_OPTIONS="-march=i486" + ;; + i586) + CPU_OPTIONS="-march=i586" + ;; + i686) + CPU_OPTIONS="-march=i686" + ;; + Pentium2) + CPU_OPTIONS="-march=pentium2" + ;; + Pentiumpro) + CPU_OPTIONS="-march=pentiumpro" + ;; + k6) + CPU_OPTIONS="-march=k6" + ;; + k6-2) + CPU_OPTIONS="-march=k6-2" + ;; + k6-3) + CPU_OPTIONS="-march=k6-3" + ;; + *) + CPU_OPTIONS="-march=native -mtune=native" + ;; + esac + fi +fi +echo "Detected CPU: $CPU_NAME" +# Now we check if the compiler supports the detected cpu +COMPILER=$CC +for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do + test "$I" && break +done +TMPC="$I/cpu_test-$RANDOM-$$.c" +TMPO="$I/cpu_test-$RANDOM-$$.o" +cat > $TMPC << EOF +int main(void) { return 0; } +EOF +( $COMPILER $CPU_OPTIONS -o $TMPO $TMPC ) 2>&1 +TMP="$?" +rm -f $TMPO +rm -f $TMPC + + +if test "x${TMP}" = "x1" ; then + CPU_OPTIONS="" + echo "No CPU optimizations will be added" +else + echo "CPU optimization: $CPU_OPTIONS" +fi + +else + CPU_OPTIONS="" +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bswap instruction" >&5 +$as_echo_n "checking for bswap instruction... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +unsigned int __x=0; + register unsigned int __v; + __asm("bswap %0" : "=r" (__v) : "0" (__x)); + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +if test "${DEVELOPER_FLAGS}" = "yes"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" +fi + +CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" + +LIBS="${TEMP_LIBS}" +LDFLAGS="${TEMP_LDFLAGS}" + + +# +# Add the right exec path for rc scripts +# +if test $prefix = "NONE";then + BIN_PATH="$ac_default_prefix" + if test $exec_prefix = "NONE"; then + BIN_PATH="$BIN_PATH/bin" + else + BIN_PATH="$BIN_PATH/$bindir" + fi +else + if test $exec_prefix = "NONE";then + BIN_PATH="$prefix/bin" + else + BIN_PATH="$prefix/$bindir" + fi +fi + + + + +ac_config_files="$ac_config_files thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian motion.init-Fedora motion.spec Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.68. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.68, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2010 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "thread1.conf") CONFIG_FILES="$CONFIG_FILES thread1.conf" ;; + "thread2.conf") CONFIG_FILES="$CONFIG_FILES thread2.conf" ;; + "thread3.conf") CONFIG_FILES="$CONFIG_FILES thread3.conf" ;; + "thread4.conf") CONFIG_FILES="$CONFIG_FILES thread4.conf" ;; + "motion-dist.conf") CONFIG_FILES="$CONFIG_FILES motion-dist.conf" ;; + "motion.init-FreeBSD.sh") CONFIG_FILES="$CONFIG_FILES motion.init-FreeBSD.sh" ;; + "motion.init-Debian") CONFIG_FILES="$CONFIG_FILES motion.init-Debian" ;; + "motion.init-Fedora") CONFIG_FILES="$CONFIG_FILES motion.init-Fedora" ;; + "motion.spec") CONFIG_FILES="$CONFIG_FILES motion.spec" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + +echo "" +echo " **************************" +echo " Configure status " +echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" +echo " **************************" +echo + + +if test "${Darwin}" != ""; then + echo "OS : Darwin" +elif test "${FreeBSD}" != ""; then + echo "OS : *BSD" +else + echo "OS : Linux" +fi + +if test "${PTHREAD_SUPPORT}" = "yes"; then + echo "pthread support: Yes" +else + echo "pthread support: No" + echo "**********************************************" + echo "** Fatal Error YOU MUST HAVE pthread Support *" + echo "**********************************************" +fi + + +if test "${JPEG_SUPPORT_TURBO}" = "yes"; then + echo "jpeg turbo support: Yes" +elif test "${JPEG_SUPPORT_MMX}" = "yes"; then + echo "jpeg-mmx support: Yes" +elif test "${JPEG_SUPPORT}" = "yes"; then + echo "jpeg support: Yes" +else + echo "jpeg support: No" + echo "**********************************************" + echo "** Fatal Error YOU MUST HAVE jpeg Support ***" + echo "**********************************************" +fi + +if test "${FreeBSD}" != ""; then + if test "${BKTR}" = "yes"; then + echo "BKTR included: Yes" + else + echo "BKTR included: No" + fi + + if test "${PWCBSD}" = "yes"; then + echo "PWCBSD include: Yes" + else + echo "PWCBSD include: No" + fi + +else + if test "${V4L}" = "yes"; then + echo "V4L support: Yes" + else + echo "V4L support: No" + fi + + if test x$SUPPORTED_V4L2 = xtrue; then + echo "V4L2 support: Yes" + else + echo "V4L2 support: No" + fi +fi + +if test "${SDL_SUPPORT}" = "yes"; then + echo "SDL support: Yes" +else + echo "SDL support: No" +fi + +if test "${FFMPEG_OK}" = "found"; then + echo "FFmpeg support: Yes" +else + echo "FFmpeg support: No" +fi + +if test "${SQLITE3_SUPPORT}" = "yes"; then + echo "SQLite3 support: Yes" +else + echo "SQLite3 support: No" +fi + +if test "${MYSQL_SUPPORT}" = "yes"; then + echo "MYSQL support: Yes" +else + echo "MYSQL support: No" +fi + +if test "${PGSQL_SUPPORT}" = "yes"; then + echo "PostgreSQL support: Yes" +else + echo "PostgreSQL support: No" +fi +echo +echo "CFLAGS: $CFLAGS" +echo "LIBS: $LIBS" +echo "LDFLAGS: $LDFLAGS" +echo +echo "Install prefix: $prefix" +echo + diff --git a/netcam.c b/netcam.c index ff521d9..efdc296 100644 --- a/netcam.c +++ b/netcam.c @@ -2012,18 +2012,20 @@ static void *netcam_handler_loop(void *arg) if (netcam->caps.streaming == NCS_RTSP) { if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect - if (netcam->rtsp->connected == 1){ + if (netcam->rtsp->status == RTSP_CONNECTED){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Reconnecting with camera...."); } + netcam->rtsp->status = RTSP_RECONNECTING; netcam_connect_rtsp(netcam); continue; } else { // We think we are connected... if (netcam->get_image(netcam) < 0) { - if (netcam->rtsp->connected == 1){ + if (netcam->rtsp->status == RTSP_CONNECTED){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image. Reconnecting with camera...."); } //Nope. We are not or got bad image. Reconnect + netcam->rtsp->status = RTSP_RECONNECTING; netcam_connect_rtsp(netcam); continue; } @@ -2609,7 +2611,7 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) free(netcam->response); - if ((netcam->caps.streaming == NCS_RTSP) && (netcam->rtsp->connected == 1)) + if (netcam->caps.streaming == NCS_RTSP) netcam_shutdown_rtsp(netcam); pthread_mutex_destroy(&netcam->mutex); @@ -2869,6 +2871,7 @@ int netcam_start(struct context *cnt) if ((retval = netcam->get_image(netcam)) != 0) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Failed trying to " "read first image - retval:%d", retval); + netcam->rtsp->status = RTSP_NOTCONNECTED; return -1; } diff --git a/netcam.h b/netcam.h index ec19820..3612f1a 100644 --- a/netcam.h +++ b/netcam.h @@ -107,6 +107,11 @@ typedef struct file_context { #define NCS_BLOCK 2 /* streaming is done via MJPG-block */ #define NCS_RTSP 3 /* streaming is done via RTSP */ + +#define RTSP_NOTCONNECTED 0 /* The camera has never connected */ +#define RTSP_CONNECTED 1 /* The camera is currently connected */ +#define RTSP_RECONNECTING 2 /* The camera is trying to reconnect*/ + /* * struct netcam_context contains all the structures and other data * for an individual netcam. diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 64a6868..d0c3e01 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -54,6 +54,23 @@ static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ } static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ +/** + * decode_packet + * + * This routine takes in the packet from the read and decodes it into + * the frame. It then takes the frame and copies it into the netcam + * buffer + * + * Parameters: + * packet The packet that was read from av_read + * buffer The buffer that is the final destination + * frame The frame into which we decode the packet + * + * + * Returns: + * Failure 0(zero) + * Success The size of the frame decoded + */ int check = 0; int frame_size = 0; @@ -83,29 +100,54 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram } static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ +/** + * open_codec_context + * + * This routine opens the codec context for the indicated stream + * + * Parameters: + * stream_idx The index of the stream that was found as "best" + * fmt_ctx The format context that was created upon opening the stream + * type The type of media type (This is a constant) + * + * + * Returns: + * Failure Error code from FFmpeg (Negative number) + * Success 0(Zero) + */ + int ret; + char errstr[128]; AVStream *st; AVCodecContext *dec_ctx = NULL; AVCodec *dec = NULL; + ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); if (ret < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream %s in input!", type); + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream in input!: %s",errstr); + return ret; + } + + *stream_idx = ret; + st = fmt_ctx->streams[*stream_idx]; + + /* find decoder for the stream */ + dec_ctx = st->codec; + dec = avcodec_find_decoder(dec_ctx->codec_id); + if (dec == NULL) { + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find codec!"); + return -1; + } + + /* Open the codec */ + ret = avcodec_open2(dec_ctx, dec, NULL); + if (ret < 0) { + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); return ret; - } else { - *stream_idx = ret; - st = fmt_ctx->streams[*stream_idx]; - /* find decoder for the stream */ - dec_ctx = st->codec; - dec = avcodec_find_decoder(dec_ctx->codec_id); - if (dec == NULL) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find %s codec!", type); - return ret; - } - if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open %s codec!", type); - return ret; - } } + return 0; } @@ -134,6 +176,27 @@ struct rtsp_context *rtsp_new_context(void){ } static int netcam_interrupt_rtsp(void *ctx){ +/** +* netcam_interrupt_rtsp +* +* This function is called during the FFmpeg blocking functions. +* These include the opening of the format context as well as the +* reading of the packets from the stream. Since this is called +* during all blocking functions, the process uses the readingframe +* flag to determine whether to timeout the process. +* +* Parameters +* +* ctx We pass in the rtsp context to use it to look for the +* readingframe flag as well as the time that we started +* the read attempt. +* +* Returns: +* Failure -1(which triggers an interupt) +* Success 0(zero which indicates to let process continue) +* +*/ + struct rtsp_context *rtsp = (struct rtsp_context *)ctx; if (rtsp->readingframe != 1) { @@ -141,7 +204,7 @@ static int netcam_interrupt_rtsp(void *ctx){ } else { struct timeval interrupttime; if (gettimeofday(&interrupttime, NULL) < 0) { - MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time"); + MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time failed"); } if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Reading picture timed out for %s",rtsp->path); @@ -156,20 +219,34 @@ static int netcam_interrupt_rtsp(void *ctx){ } int netcam_connect_rtsp(netcam_context_ptr netcam){ +/** +* netcam_connect_rtsp +* +* This function initiates the connection to the rtsp camera. +* +* Parameters +* +* netcam The netcam context to open. +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ int ret; char errstr[128]; - - netcam->rtsp->connected = 0; - + if (netcam->rtsp->path == NULL) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); + } return -1; } // open the network connection AVDictionary *opts = 0; - av_dict_set(&opts, "rtsp_transport", "tcp", 0); + //av_dict_set(&opts, "rtsp_transport", "tcp", 0); netcam->rtsp->format_context = avformat_alloc_context(); netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; @@ -177,29 +254,33 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); if (ret < 0) { - av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); - if (ret == -1094995529) MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error opening camera. Authentication?"); + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); + } av_dict_free(&opts); //The format context gets freed upon any error from open_input. return ret; } av_dict_free(&opts); - + // fill out stream information ret = avformat_find_stream_info(netcam->rtsp->format_context, NULL); if (ret < 0) { - av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %s", errstr); + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %s", errstr); + } avformat_close_input(&netcam->rtsp->format_context); return -1; } ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); if (ret < 0) { - av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); - avcodec_close(netcam->rtsp->codec_context); + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); + } avformat_close_input(&netcam->rtsp->format_context); return -1; } @@ -208,7 +289,9 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ netcam->rtsp->frame = my_frame_alloc(); if (netcam->rtsp->frame == NULL) { - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); + } avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); return -1; @@ -217,18 +300,36 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ // start up the feed ret = av_read_play(netcam->rtsp->format_context); if (ret < 0) { - av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open the camera: %s", errstr); + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open the camera: %s", errstr); + } my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); return -1; } + /* + * Get an image from the feed, this serves + * two purposes. One get the dimensions of the pic + * validate that the previous steps really did open + * something we can use. Some cameras get this far + * without throwing an error + */ + + ret = netcam_read_rtsp_image(netcam); + if (ret < 0) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first image"); + } + return -1; + } + netcam->width = netcam->rtsp->codec_context->width; netcam->height = netcam->rtsp->codec_context->height; - netcam->rtsp->connected = 1; + netcam->rtsp->status = RTSP_CONNECTED; MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Camera connected"); @@ -236,6 +337,22 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ } int netcam_read_rtsp_image(netcam_context_ptr netcam){ +/** +* netcam_read_rtsp_image +* +* This function reads the packet from the camera. +* It is called extensively so only absolutely essential +* functions and allocations are performed. +* +* Parameters +* +* netcam The netcam context to read from +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ struct timeval curtime; netcam_buff_ptr buffer; @@ -283,7 +400,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ if (size_decoded == 0) { // something went wrong, end of stream? Interupted? - av_free(netcam->rtsp->frame); + my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); return -1; @@ -318,24 +435,54 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ } void netcam_shutdown_rtsp(netcam_context_ptr netcam){ - - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: shutting down rtsp"); - - my_frame_free(netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); - +/** +* netcam_shutdown_rtsp +* +* This function closes and frees all the items for rtsp +* +* Parameters +* +* netcam The netcam context to free. +* +* Returns: +* Failure nothing +* Success nothing +* +*/ + if (netcam->rtsp->status == RTSP_CONNECTED) { + my_frame_free(netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); + } + if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); - + free(netcam->rtsp); - netcam->rtsp = NULL; - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); + } int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ +/** +* netcam_setup_rtsp +* +* This function sets up all the necessary items for the +* rtsp camera. +* +* Parameters +* +* netcam The netcam context to free. +* url The URL of the camera +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ struct context *cnt = netcam->cnt; const char *ptr; int ret = -1; @@ -408,10 +555,11 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam_url_free(url); /* - * Now we need to set some flags for the callback function. + * Now we need to set some flags */ netcam->rtsp->readingframe = 0; - + netcam->rtsp->status = RTSP_NOTCONNECTED; + /* * The RTSP context should be all ready to attempt a connection with * the server, so we try .... @@ -440,7 +588,7 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); }; int netcam_connect_rtsp(netcam_context_ptr netcam){ - netcam->rtsp->connected = 0; + netcam->rtsp->status = RTSP_NOTCONNECTED; netcam->rtsp->format_context = NULL; MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); return -1; diff --git a/netcam_rtsp.h b/netcam_rtsp.h index 876b21e..b0bd3d8 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -11,13 +11,13 @@ struct rtsp_context { AVFormatContext* format_context; AVCodecContext* codec_context; - AVFrame *frame; + AVFrame* frame; int video_stream_index; char* path; char* user; char* pass; int readingframe; - int connected; + int status; struct timeval startreadtime; }; #else @@ -29,7 +29,7 @@ struct rtsp_context { struct rtsp_context { int* format_context; int readingframe; - int connected; + int status; }; #endif From 546727ba9012ac215d89917344126ed6364eea3e Mon Sep 17 00:00:00 2001 From: "Xubuntu 12.04" Date: Sat, 5 Jul 2014 15:35:45 -0700 Subject: [PATCH 020/233] Implement init of AV libraries from bcl fork and clean up --- CHANGELOG | 2 + INSTALL | 25 + configure | 1753 ++++++++++++++++++++++++++++++++-------------- configure.ac | 1 + ffmpeg.h | 2 + motion-dist.conf | 732 +++++++++++++++++++ netcam_rtsp.c | 303 ++++---- netcam_rtsp.h | 15 +- 8 files changed, 2161 insertions(+), 672 deletions(-) create mode 100644 motion-dist.conf diff --git a/CHANGELOG b/CHANGELOG index 42729e6..2bb0199 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -77,6 +77,8 @@ Features * Clean up the messaging for RTSP. * Additional validations for RTSP connection and corrected free sequences * Removed seg fault on failure to open first image, comments, isolation of RTSP + * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. + * Implement inits of AV functions from bcl fork Bugfixes diff --git a/INSTALL b/INSTALL index fba3f71..4a2c39a 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,9 @@ +NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point + and may need modification by the time you read this. + +********************************** +*** DEBIAN BASED SYSTEMS *** + Required Packages: sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev @@ -34,3 +40,22 @@ Sample PI configuration with LIBAV Once configured type: make make install + +***************************** +*** OpenSUSE SYSTEM *** + +sudo zypper install autoconf automake libtool git +sudo zypper install --type pattern devel_basis +sudo zypper install libjpeg8-devel +sudo zypper install -t pattern devel_C_C++ + +Optional: FFmpeg files +sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials +sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia +sudo zypper install libffmpeg-devel + +./configure + make + make install + +************************* diff --git a/configure b/configure index b9fbdbe..5cc0faf 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.68. +# Generated by GNU Autoconf 2.68 for motion trunkREVUNKNOWN. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -555,15 +555,13 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= - -ac_unique_file="motion" -ac_unique_file="motion.c" +PACKAGE_NAME='motion' +PACKAGE_TARNAME='motion' +PACKAGE_VERSION='trunkREVUNKNOWN' +PACKAGE_STRING='motion trunkREVUNKNOWN' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + # Factoring default headers for most tests. ac_includes_default="\ #include @@ -600,16 +598,17 @@ ac_includes_default="\ # include #endif" +ac_unique_file="motion.c" ac_subst_vars='LTLIBOBJS LIBOBJS BIN_PATH -EGREP -GREP -CPP RTPS_OBJ FFMPEG_OBJ SDL_OBJ VIDEO +EGREP +GREP +CPP OBJEXT EXEEXT ac_ct_CC @@ -727,7 +726,7 @@ sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' @@ -1229,7 +1228,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 this package to adapt to many kinds of systems. +\`configure' configures motion trunkREVUNKNOWN to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1277,7 +1276,7 @@ Fine tuning of the installation directories: --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --docdir=DIR documentation root [DATAROOTDIR/doc/motion] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1289,7 +1288,9 @@ _ACEOF fi if test -n "$ac_init_help"; then - + case $ac_init_help in + short | recursive ) echo "Configuration of motion trunkREVUNKNOWN:";; + esac cat <<\_ACEOF Optional Packages: @@ -1438,7 +1439,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -configure +motion configure trunkREVUNKNOWN generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1490,52 +1491,6 @@ fi } # ac_fn_c_try_compile -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -1573,48 +1528,6 @@ fi } # ac_fn_c_try_cpp -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using @@ -1702,6 +1615,48 @@ fi } # ac_fn_c_check_header_mongrel +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in @@ -1733,6 +1688,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -2035,7 +2036,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 $as_me, which was +It was created by motion $as_me trunkREVUNKNOWN, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2383,9 +2384,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_config_headers="$ac_config_headers config.h" - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -3177,37 +3175,1040 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu - -THREAD_CFLAGS="" -THREAD_CHECK="/usr/include/pthread.h" - -Darwin="" -FreeBSD="" - -LINUXTHREADS="no" - -# Check whether --with-linuxthreads was given. -if test "${with_linuxthreads+set}" = set; then : - withval=$with_linuxthreads; LINUXTHREADS="$withval" - +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : - -PWCBSD="no" - -# Check whether --with-pwcbsd was given. -if test "${with_pwcbsd+set}" = set; then : - withval=$with_pwcbsd; PWCBSD="$withval" - +else + # Broken: fails on valid input. +continue fi +rm -f conftest.err conftest.i conftest.$ac_ext - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 -$as_echo_n "checking for Darwin... " >&6; } -Darwin=`uname -a | grep "Darwin"` - -if test "${Darwin}" = ""; then + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" +if test "x$ac_cv_header_minix_config_h" = xyes; then : + MINIX=yes +else + MINIX= +fi + + + if test "$MINIX" = yes; then + +$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h + + +$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h + + +$as_echo "#define _MINIX 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if ${ac_cv_safe_to_define___extensions__+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_safe_to_define___extensions__=yes +else + ac_cv_safe_to_define___extensions__=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + test $ac_cv_safe_to_define___extensions__ = yes && + $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h + + $as_echo "#define _ALL_SOURCE 1" >>confdefs.h + + $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h + + + + +ac_config_headers="$ac_config_headers config.h" + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +THREAD_CFLAGS="" +THREAD_CHECK="/usr/include/pthread.h" + +Darwin="" +FreeBSD="" + +LINUXTHREADS="no" + +# Check whether --with-linuxthreads was given. +if test "${with_linuxthreads+set}" = set; then : + withval=$with_linuxthreads; LINUXTHREADS="$withval" + +fi + + +PWCBSD="no" + +# Check whether --with-pwcbsd was given. +if test "${with_pwcbsd+set}" = set; then : + withval=$with_pwcbsd; PWCBSD="$withval" + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 +$as_echo_n "checking for Darwin... " >&6; } +Darwin=`uname -a | grep "Darwin"` + +if test "${Darwin}" = ""; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 @@ -3911,7 +4912,6 @@ elif test -f "${THREAD_CHECK}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking threads" >&5 $as_echo_n "checking threads... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -4873,389 +5873,121 @@ $as_echo "not found" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes $PGSQL_INCDIR" >&5 $as_echo "yes $PGSQL_INCDIR" >&6; } - PGSQL_HEADERS="yes" - fi - - - if test "${PGSQL_HEADERS}" = "yes"; then - - # ******* Search pgsql libs ********* - if test "${PGSQL_LIBS}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 -$as_echo_n "checking autodect pgsql libs... " >&6; } - # Autodetect - PGSQL_INCLUDE="-I$PGSQL_INCDIR" - PGSQL_LIBDIR=$PGSQL_DIR/lib - - if test -f /usr/lib64/libpq.so ; then - PGSQL_LIBDIR=/usr/lib64 - elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql - elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql - elif test -f $PGSQL_DIR/lib/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib - else - PGSQL_LIBDIR="" - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 -$as_echo "$PGSQL_LIBDIR" >&6; } - - elif test "${PGSQL_LIBS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 -$as_echo_n "checking for pgsql libs... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 -$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } - # Manual detection for - if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then - PGSQL_LIBDIR=$PGSQL_LIBS - fi - fi - - - if test -z "$PGSQL_LIBDIR" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." - else - #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$PGSQL_INCDIR" - LIBS="-L$PGSQL_LIBDIR" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 -$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } -if ${ac_cv_lib_pq_PQconnectStart+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpq $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char PQconnectStart (); -int -main () -{ -return PQconnectStart (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_pq_PQconnectStart=yes -else - ac_cv_lib_pq_PQconnectStart=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 -$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } -if test "x$ac_cv_lib_pq_PQconnectStart" = xyes; then : - - PGSQL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" - TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" - -$as_echo "#define HAVE_PGSQL 1" >>confdefs.h - - -else - as_fn_error $? "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 -fi - - LDFLAGS="" - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - fi # end pgsql-include , pgsql-libs - -# end PostgreSQL detection -fi - - -#Checks for header files. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext + PGSQL_HEADERS="yes" + fi - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : + if test "${PGSQL_HEADERS}" = "yes"; then -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi + # ******* Search pgsql libs ********* + if test "${PGSQL_LIBS}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 +$as_echo_n "checking autodect pgsql libs... " >&6; } + # Autodetect + PGSQL_INCLUDE="-I$PGSQL_INCDIR" + PGSQL_LIBDIR=$PGSQL_DIR/lib -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test -f /usr/lib64/libpq.so ; then + PGSQL_LIBDIR=/usr/lib64 + elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql + elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql + elif test -f $PGSQL_DIR/lib/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib + else + PGSQL_LIBDIR="" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 +$as_echo "$PGSQL_LIBDIR" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : + elif test "${PGSQL_LIBS}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 +$as_echo_n "checking for pgsql libs... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +$as_echo "skipped" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 +$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } + # Manual detection for + if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then + PGSQL_LIBDIR=$PGSQL_LIBS + fi + fi + + + if test -z "$PGSQL_LIBDIR" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." + else + #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$PGSQL_INCDIR" + LIBS="-L$PGSQL_LIBDIR" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 +$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } +if ${ac_cv_lib_pq_PQconnectStart+:} false; then : $as_echo_n "(cached) " >&6 else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpq $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char PQconnectStart (); +int +main () +{ +return PQconnectStart (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pq_PQconnectStart=yes else - ac_cv_path_GREP=$GREP + ac_cv_lib_pq_PQconnectStart=no fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 +$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } +if test "x$ac_cv_lib_pq_PQconnectStart" = xyes; then : + PGSQL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" + TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" + +$as_echo "#define HAVE_PGSQL 1" >>confdefs.h -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi else - ac_cv_path_EGREP=$EGREP + as_fn_error $? "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 fi - fi + LDFLAGS="" + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + fi # end pgsql-include , pgsql-libs + +# end PostgreSQL detection fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" +#Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : @@ -5368,23 +6100,6 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -6592,7 +7307,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 $as_me, which was +This file was extended by motion $as_me trunkREVUNKNOWN, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6654,7 +7369,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="\\ -config.status +motion config.status trunkREVUNKNOWN configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index d36ef2f..1be77bd 100755 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,7 @@ # Process this file with autoconf to produce a configure script AC_INIT(motion, esyscmd(['./version.sh'])) +AC_GNU_SOURCE AC_CONFIG_SRCDIR([motion.c]) AC_CONFIG_HEADERS(config.h) AC_PROG_CC diff --git a/ffmpeg.h b/ffmpeg.h index 86f4ec9..c64fd9e 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -95,7 +95,9 @@ void ffmpeg_deinterlace(unsigned char *, int, int); /* Setup an avcodec log handler. */ void ffmpeg_avcodec_log(void *, int, const char *, va_list); +#ifdef HAVE_FFMPEG AVFrame *my_frame_alloc(void); void my_frame_free(AVFrame *frame); +#endif #endif /* _INCLUDE_FFMPEG_H_ */ diff --git a/motion-dist.conf b/motion-dist.conf new file mode 100644 index 0000000..3c853f0 --- /dev/null +++ b/motion-dist.conf @@ -0,0 +1,732 @@ +# Rename this distribution example file to motion.conf +# +# This config file was generated by motion trunkREVUNKNOWN + + +############################################################ +# Daemon +############################################################ + +# Start in daemon (background) mode and release terminal (default: off) +daemon on + +# File to store the process ID, also called pid file. (default: not defined) +process_id_file /var/run/motion/motion.pid + +############################################################ +# Basic Setup Mode +############################################################ + +# Start in Setup-Mode, daemon disabled. (default: off) +setup_mode off + + +# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) +;logfile /tmp/motion.log + +# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) +log_level 6 + +# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) +log_type all + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video0 + +# v4l2_palette allows to choose preferable palette to be use by motion +# to capture from those supported by your videodevice. (default: 17) +# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and +# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. +# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 +# instead. +# +# Values : +# V4L2_PIX_FMT_SN9C10X : 0 'S910' +# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' +# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' +# V4L2_PIX_FMT_SPCA561 : 3 'S561' +# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' +# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' +# V4L2_PIX_FMT_PAC207 : 6 'P207' +# V4L2_PIX_FMT_PJPG : 7 'PJPG' +# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' +# V4L2_PIX_FMT_JPEG : 9 'JPEG' +# V4L2_PIX_FMT_RGB24 : 10 'RGB3' +# V4L2_PIX_FMT_SPCA501 : 11 'S501' +# V4L2_PIX_FMT_SPCA505 : 12 'S505' +# V4L2_PIX_FMT_SPCA508 : 13 'S508' +# V4L2_PIX_FMT_UYVY : 14 'UYVY' +# V4L2_PIX_FMT_YUYV : 15 'YUYV' +# V4L2_PIX_FMT_YUV422P : 16 '422P' +# V4L2_PIX_FMT_YUV420 : 17 'YU12' +# +v4l2_palette 17 + +# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) +# This is ONLY used for FreeBSD. Leave it commented out for Linux +; tunerdevice /dev/tuner0 + +# 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) +norm 0 + +# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) +frequency 0 + +# Rotate image this number of degrees. The rotation affects all saved images as +# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. +rotate 0 + +# Image width (pixels). Valid range: Camera dependent, default: 352 +width 320 + +# Image height (pixels). Valid range: Camera dependent, default: 288 +height 240 + +# Maximum number of frames to be captured per second. +# Valid range: 2-100. Default: 100 (almost no limit). +framerate 2 + +# Minimum time in seconds between capturing picture frames from the camera. +# Default: 0 = disabled - the capture rate is given by the camera framerate. +# This option is used when you want to capture images at a rate lower than 2 per second. +minimum_frame_time 0 + +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// or file:///) +# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined +; netcam_url value + +# Username and password for network camera (only if required). Default: not defined +# Syntax is user:password +; netcam_userpass value + +# The setting for keep-alive of network socket, should improve performance on compatible net cameras. +# off: The historical implementation using HTTP/1.0, closing the socket after each http request. +# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +# on: Use HTTP/1.1 requests that support keep alive as default. +# Default: off +netcam_keepalive off + +# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". +# If a port number other than 80 is needed, use "http://myproxy:1234". +# Default: not defined +; netcam_proxy value + +# Set less strict jpeg checks for network cameras with a poor/buggy firmware. +# Default: off +netcam_tolerant_check off + +# Let motion regulate the brightness of a video device (default: off). +# The auto_brightness feature uses the brightness option as its target value. +# If brightness is zero auto_brightness will adjust to average brightness value 128. +# Only recommended for cameras without auto brightness +auto_brightness off + +# Set the initial brightness of a video device. +# If auto_brightness is enabled, this value defines the average brightness level +# which Motion will try and adjust to. +# Valid range 0-255, default 0 = disabled +brightness 0 + +# Set the contrast of a video device. +# Valid range 0-255, default 0 = disabled +contrast 0 + +# Set the saturation of a video device. +# Valid range 0-255, default 0 = disabled +saturation 0 + +# Set the hue of a video device (NTSC feature). +# Valid range 0-255, default 0 = disabled +hue 0 + + +############################################################ +# Round Robin (multiple inputs on same video device name) +############################################################ + +# Number of frames to capture in each roundrobin step (default: 1) +roundrobin_frames 1 + +# Number of frames to skip before each roundrobin step (default: 1) +roundrobin_skip 1 + +# Try to filter out noise generated by roundrobin (default: off) +switchfilter off + + +############################################################ +# Motion Detection Settings: +############################################################ + +# Threshold for number of changed pixels in an image that +# triggers motion detection (default: 1500) +threshold 1500 + +# Automatically tune the threshold down if possible (default: off) +threshold_tune off + +# Noise threshold for the motion detection (default: 32) +noise_level 32 + +# Automatically tune the noise threshold (default: on) +noise_tune on + +# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) +# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. +# (l)abeling must only be used once and the 'l' must be the last letter. +# Comment out to disable +despeckle_filter EedDl + +# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 +# A script (on_area_detected) is started immediately when motion is 4 5 6 +# detected in one of the given areas, but only once during an event. 7 8 9 +# One or more areas can be specified with this option. Take care: This option +# does NOT restrict detection to these areas! (Default: not defined) +; area_detect value + +# PGM file to use as a sensitivity mask. +# Full path name to. (Default: not defined) +; mask_file value + +# Dynamically create a mask file during operation (default: 0) +# Adjust speed of mask changes from 0 (off) to 10 (fast) +smart_mask_speed 0 + +# Ignore sudden massive light intensity changes given as a percentage of the picture +# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled +lightswitch 0 + +# Picture frames must contain motion at least the specified number of frames +# in a row before they are detected as true motion. At the default of 1, all +# motion is detected. Valid range: 1 to thousands, recommended 1-5 +minimum_motion_frames 1 + +# Specifies the number of pre-captured (buffered) pictures from before motion +# was detected that will be output at motion detection. +# Recommended range: 0 to 5 (default: 0) +# Do not use large values! Large values will cause Motion to skip video frames and +# cause unsmooth movies. To smooth movies use larger values of post_capture instead. +pre_capture 0 + +# Number of frames to capture after motion is no longer detected (default: 0) +post_capture 0 + +# Event Gap is the seconds of no motion detection that triggers the end of an event. +# An event is defined as a series of motion images taken within a short timeframe. +# Recommended value is 60 seconds (Default). The value -1 is allowed and disables +# events causing all Motion to be written to one single movie file and no pre_capture. +# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An +# event ends right after no more motion is detected and post_capture is over. +event_gap 60 + +# Maximum length in seconds of a movie +# When value is exceeded a new movie file is created. (Default: 0 = infinite) +max_movie_time 0 + +# Always save images even if there was no motion (default: off) +emulate_motion off + + +############################################################ +# Image File Output +############################################################ + +# Output 'normal' pictures when motion is detected (default: on) +# Valid values: on, off, first, best, center +# When set to 'first', only the first picture of an event is saved. +# Picture with most motion of an event is saved when set to 'best'. +# Picture with motion nearest center of picture is saved when set to 'center'. +# Can be used as preview shot for the corresponding movie. +output_pictures on + +# Output pictures with only the pixels moving object (ghost images) (default: off) +output_debug_pictures off + +# The quality (in percent) to be used by the jpeg compression (default: 75) +quality 75 + +# Type of output images +# Valid values: jpeg, ppm (default: jpeg) +picture_type jpeg + +############################################################ +# FFMPEG related options +# Film (movies) file output, and deinterlacing of the video input +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################ + +# Use ffmpeg to encode movies in realtime (default: off) +ffmpeg_output_movies on + +# Use ffmpeg to make movies with only the pixels moving +# object (ghost images) (default: off) +ffmpeg_output_debug_movies off + +# Use ffmpeg to encode a timelapse movie +# Default value 0 = off - else save frame every Nth second +ffmpeg_timelapse 0 + +# The file rollover mode of the timelapse video +# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual +ffmpeg_timelapse_mode daily + +# Bitrate to be used by the ffmpeg encoder (default: 400000) +# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) +ffmpeg_bps 500000 + +# Enables and defines variable bitrate for the ffmpeg encoder. +# ffmpeg_bps is ignored if variable bitrate is enabled. +# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, +# or the range 2 - 31 where 2 means best quality and 31 is worst. +ffmpeg_variable_bitrate 0 + +# Codec to used by ffmpeg for the video compression. +# Timelapse mpegs are always made in mpeg1 format independent from this option. +# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. +# mpeg1 - gives you files with extension .mpg +# mpeg4 or msmpeg4 - gives you files with extension .avi +# msmpeg4 is recommended for use with Windows Media Player because +# it requires no installation of codec on the Windows client. +# swf - gives you a flash film with extension .swf +# flv - gives you a flash video with extension .flv +# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) +# mov - QuickTime ( testing ) +# ogg - Ogg/Theora ( testing ) +ffmpeg_video_codec mpeg4 + +# Use ffmpeg to deinterlace video. Necessary if you use an analog camera +# and see horizontal combing on moving objects in video or pictures. +# (default: off) +ffmpeg_deinterlace off + +############################################################ +# SDL Window +############################################################ + +# Number of motion thread to show in SDL Window (default: 0 = disabled) +sdl_threadnr 0 + +############################################################ +# External pipe to video encoder +# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################# + +# Bool to enable or disable extpipe (default: off) +use_extpipe off + +# External program (full path and opts) to pipe raw video to +# Generally, use '-' for STDIN... +;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps + + + +############################################################ +# Snapshots (Traditional Periodic Webcam File Output) +############################################################ + +# Make automated snapshot every N seconds (default: 0 = disabled) +snapshot_interval 0 + + +############################################################ +# Text Display +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, \n = new line, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event - do not use with text_event! +# You can put quotation marks around the text to allow +# leading spaces +############################################################ + +# Locate and draw a box around the moving object. +# Valid values: on, off, preview (default: off) +# Set to 'preview' will only draw a box in preview_shot pictures. +locate_motion_mode off + +# Set the look and style of the locate box if enabled. +# Valid values: box, redbox, cross, redcross (default: box) +# Set to 'box' will draw the traditional box. +# Set to 'redbox' will draw a red box. +# Set to 'cross' will draw a little cross to mark center. +# Set to 'redcross' will draw a little red cross to mark center. +locate_motion_style box + +# Draws the timestamp using same options as C function strftime(3) +# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +# Text is placed in lower right corner +text_right %Y-%m-%d\n%T-%q + +# Draw a user defined text on the images using same options as C function strftime(3) +# Default: Not defined = no text +# Text is placed in lower left corner +; text_left CAMERA %t + +# Draw the number of changed pixed on the images (default: off) +# Will normally be set to off except when you setup and adjust the motion settings +# Text is placed in upper right corner +text_changes off + +# This option defines the value of the special event conversion specifier %C +# You can use any conversion specifier in this option except %C. Date and time +# values are from the timestamp of the first image in the current event. +# Default: %Y%m%d%H%M%S +# The idea is that %C can be used filenames and text_left/right for creating +# a unique identifier for each event. +text_event %Y%m%d%H%M%S + +# Draw characters at twice normal size on images. (default: off) +text_double off + + +# Text to include in a JPEG EXIF comment +# May be any text, including conversion specifiers. +# The EXIF timestamp is included independent of this text. +;exif_text %i%J/%K%L + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, picture_, movie_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute path. (Default: current working directory) +target_dir /usr/local/apache2/htdocs/cam1 + +# File path for snapshots (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-snapshot +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot +# File extension .jpg or .ppm is automatically added so do not include this. +# Note: A symbolic link called lastsnap.jpg created in the target_dir will always +# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +snapshot_filename %v-%Y%m%d%H%M%S-snapshot + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename %v-%Y%m%d%H%M%S-%q + +# File path for motion triggered ffmpeg films (movies) relative to target_dir +# Default: %v-%Y%m%d%H%M%S +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S +# File extension .mpg or .avi is automatically added so do not include this +# This option was previously called ffmpeg_filename +movie_filename %v-%Y%m%d%H%M%S + +# File path for timelapse movies relative to target_dir +# Default: %Y%m%d-timelapse +# Default value is near equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse +# File extension .mpg is automatically added so do not include this +timelapse_filename %Y%m%d-timelapse + +############################################################ +# Global Network Options +############################################################ +# Enable or disable IPV6 for http control and stream (default: off ) +ipv6_enabled off + +############################################################ +# Live Stream Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +stream_port 8081 + +# Quality of the jpeg (in percent) images produced (default: 50) +stream_quality 50 + +# Output frames at 1 fps when no motion is detected and increase to the +# rate given by stream_maxrate when motion is detected (default: off) +stream_motion off + +# Maximum framerate for stream streams (default: 1) +stream_maxrate 1 + +# Restrict stream connections to localhost only (default: on) +stream_localhost on + +# Limits the number of images per connection (default: 0 = unlimited) +# Number can be defined by multiplying actual stream rate by desired number of seconds +# Actual stream rate is the smallest of the numbers framerate and stream_maxrate +stream_limit 0 + +# Set the authentication method (default: 0) +# 0 = disabled +# 1 = Basic authentication +# 2 = MD5 digest (the safer authentication) +stream_auth_method 0 + +# Authentication for the stream. Syntax username:password +# Default: not defined (Disabled) +; stream_authentication username:password + + +############################################################ +# HTTP Based Control +############################################################ + +# TCP/IP port for the http server to listen on (default: 0 = disabled) +webcontrol_port 8080 + +# Restrict control connections to localhost only (default: on) +webcontrol_localhost on + +# Output for http server, select off to choose raw text plain (default: on) +webcontrol_html_output on + +# Authentication for the http based control. Syntax username:password +# Default: not defined (Disabled) +; webcontrol_authentication username:password + + +############################################################ +# Tracking (Pan/Tilt) +############################################################# + +# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) +# The generic type enables the definition of motion center and motion size to +# be used with the conversion specifiers for options like on_motion_detected +track_type 0 + +# Enable auto tracking (default: off) +track_auto off + +# Serial port of motor (default: none) +;track_port /dev/ttyS0 + +# Motor number for x-axis (default: 0) +;track_motorx 0 + +# Set motorx reverse (default: 0) +;track_motorx_reverse 0 + +# Motor number for y-axis (default: 0) +;track_motory 1 + +# Set motory reverse (default: 0) +;track_motory_reverse 0 + +# Maximum value on x-axis (default: 0) +;track_maxx 200 + +# Minimum value on x-axis (default: 0) +;track_minx 50 + +# Maximum value on y-axis (default: 0) +;track_maxy 200 + +# Minimum value on y-axis (default: 0) +;track_miny 50 + +# Center value on x-axis (default: 0) +;track_homex 128 + +# Center value on y-axis (default: 0) +;track_homey 128 + +# ID of an iomojo camera if used (default: 0) +track_iomojo_id 0 + +# Angle in degrees the camera moves per step on the X-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_x 10 + +# Angle in degrees the camera moves per step on the Y-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_y 10 + +# Delay to wait for after tracking movement as number +# of picture frames (default: 10) +track_move_wait 10 + +# Speed to set the motor to (stepper motor option) (default: 255) +track_speed 255 + +# Number of steps to make (stepper motor option) (default: 40) +track_stepsize 40 + + +############################################################ +# External Commands, Warnings and Logging: +# You can use conversion specifiers for the on_xxxx commands +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# %f = filename with full path +# %n = number indicating filetype +# Both %f and %n are only defined for on_picture_save, +# on_movie_start and on_movie_end +# Quotation marks round string are allowed. +############################################################ + +# Do not sound beeps when detecting motion (default: on) +# Note: Motion never beeps when running in daemon mode. +quiet on + +# Command to be executed when an event starts. (default: none) +# An event starts at first motion detected after a period of no motion defined by event_gap +; on_event_start value + +# Command to be executed when an event ends after a period of no motion +# (default: none). The period of no motion is defined by option event_gap. +; on_event_end value + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# To give the filename as an argument to a command append it with %f +; on_picture_save value + +# Command to be executed when a motion frame is detected (default: none) +; on_motion_detected value + +# Command to be executed when motion in a predefined area is detected +# Check option 'area_detect'. (default: none) +; on_area_detected value + +# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_start value + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_end value + +# Command to be executed when a camera can't be opened or if it is lost +# NOTE: There is situations when motion don't detect a lost camera! +# It depends on the driver, some drivers dosn't detect a lost camera at all +# Some hangs the motion thread. Some even hangs the PC! (default: none) +; on_camera_lost value + +##################################################################### +# Common Options for database features. +# Options require database options to be active also. +##################################################################### + +# Log to the database when creating motion triggered picture file (default: on) +; sql_log_picture on + +# Log to the database when creating a snapshot image file (default: on) +; sql_log_snapshot on + +# Log to the database when creating motion triggered movie file (default: off) +; sql_log_movie off + +# Log to the database when creating timelapse movies file (default: off) +; sql_log_timelapse off + +# SQL query string that is sent to the database +# Use same conversion specifiers has for text features +# Additional special conversion specifiers are +# %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') + + +############################################################ +# Database Options +############################################################ + +# database type : mysql, postgresql, sqlite3 (default : not defined) +; database_type value + +# database to log to (default: not defined) +; database_dbname value + +# The host on which the database is located (default: localhost) +; database_host value + +# User account name for database (default: not defined) +; database_user value + +# User password for database (default: not defined) +; database_password value + +# Port on which the database is located +# mysql 3306 , postgresql 5432 (default: not defined) +; database_port value + +############################################################ +# Database Options For SQLite3 +############################################################ + +# SQLite3 database (file path) (default: not defined) +; sqlite3_db value + + + +############################################################ +# Video Loopback Device (vloopback project) +############################################################ + +# Output images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; video_pipe value + +# Output motion images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; motion_video_pipe value + + +############################################################## +# Thread config files - One for each camera. +# Except if only one camera - You only need this config file. +# If you have more than one camera you MUST define one thread +# config file for each camera in addition to this config file. +############################################################## + +# Remember: If you have more than one camera you must have one +# thread file for each camera. E.g. 2 cameras requires 3 files: +# This motion.conf file AND thread1.conf and thread2.conf. +# Only put the options that are unique to each camera in the +# thread config files. +; thread /usr/local/etc/thread1.conf +; thread /usr/local/etc/thread2.conf +; thread /usr/local/etc/thread3.conf +; thread /usr/local/etc/thread4.conf + diff --git a/netcam_rtsp.c b/netcam_rtsp.c index d0c3e01..edda659 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -2,15 +2,28 @@ #include "netcam_rtsp.h" #include "motion.h" -#ifdef HAVE_FFMPEG /*********************************************************** - * This top section is the real code that opens and processes - * the rtsp camera. In the #else section below there are - * basic functions that indicate that if FFmpeg/Libav is - * not installed, rtsp is not available. By blocking the - * #IFs this way, we are able to isolate all the rtsp code - * and avoid numerous #IF blocks in the other components. + * In the top section are the functions that are used + * when processing the RTSP camera feed. Since these functions + * are internal to the RTSP module, and many require FFmpeg + * structures in their declarations, they are within the + * HAVE_FFMPEG block that eliminates them entirely when + * FFmpeg is not present. + * + * The functions: + * netcam_setup_rtsp + * netcam_connect_rtsp + * netcam_shutdown_rtsp + * are called from netcam.c therefore must be defined even + * if FFmpeg is not present. They must also not have FFmpeg + * structures are in the declarations. Simple error + * messages are raised if called when no FFmpeg is found. + * + * Comments inside the function structure are particular + * to that function. Comments outside a function (such as + * these) are applicable to the entire module. ***********************************************************/ +#ifdef HAVE_FFMPEG #include "ffmpeg.h" @@ -76,6 +89,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram int frame_size = 0; int ret = 0; + cc->err_recognition = 3; ret = avcodec_decode_video2(cc, frame, &check, packet); if (ret < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); @@ -83,7 +97,6 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram } if (check == 0) { - // no frame could be decoded...keep trying return 0; } @@ -139,7 +152,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find codec!"); return -1; } - + /* Open the codec */ ret = avcodec_open2(dec_ctx, dec, NULL); if (ret < 0) { @@ -147,7 +160,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); return ret; } - + return 0; } @@ -218,6 +231,109 @@ static int netcam_interrupt_rtsp(void *ctx){ return 0; } +int netcam_read_rtsp_image(netcam_context_ptr netcam){ +/** +* netcam_read_rtsp_image +* +* This function reads the packet from the camera. +* It is called extensively so only absolutely essential +* functions and allocations are performed. +* +* Parameters +* +* netcam The netcam context to read from +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ + + struct timeval curtime; + netcam_buff_ptr buffer; + AVPacket packet; + int size_decoded; + static int usual_size_decoded; + + /* Point to our working buffer. */ + buffer = netcam->receiving; + buffer->used = 0; + + av_init_packet(&packet); + packet.data = NULL; + packet.size = 0; + + size_decoded = 0; + usual_size_decoded = 0; + + if (gettimeofday(&curtime, NULL) < 0) { + MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); + } + netcam->rtsp->startreadtime = curtime; + + netcam->rtsp->readingframe = 1; + while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { + if(packet.stream_index != netcam->rtsp->video_stream_index) { + av_free_packet(&packet); + av_init_packet(&packet); + packet.data = NULL; + packet.size = 0; + // not our packet, skip + continue; + } + size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); + + av_free_packet(&packet); + av_init_packet(&packet); + packet.data = NULL; + packet.size = 0; + } + netcam->rtsp->readingframe = 0; + + // at this point, we are finished with the packet + av_free_packet(&packet); + + if (size_decoded == 0) { + // something went wrong, end of stream? Interupted? + my_frame_free(netcam->rtsp->frame); + avcodec_close(netcam->rtsp->codec_context); + avformat_close_input(&netcam->rtsp->format_context); + return -1; + } + + if (size_decoded != usual_size_decoded) { + if (usual_size_decoded !=0) { + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: unusual frame size of %d!", size_decoded); + } + usual_size_decoded = size_decoded; + } + + + /* + * read is complete - set the current 'receiving' buffer atomically + * as 'latest', and make the buffer previously in 'latest' become + * the new 'receiving' and signal pic_ready. + */ + netcam->receiving->image_time = curtime; + netcam->last_image = curtime; + netcam_buff *xchg; + + pthread_mutex_lock(&netcam->mutex); + xchg = netcam->latest; + netcam->latest = netcam->receiving; + netcam->receiving = xchg; + netcam->imgcnt++; + pthread_cond_signal(&netcam->pic_ready); + pthread_mutex_unlock(&netcam->mutex); + + return 0; +} + +/*********************************************************** + * This ends the section of functions that rely upon FFmpeg + ***********************************************************/ +#endif /* End HAVE_FFMPEG */ + int netcam_connect_rtsp(netcam_context_ptr netcam){ /** * netcam_connect_rtsp @@ -233,6 +349,7 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ * Success 0(zero) * */ +#ifdef HAVE_FFMPEG int ret; char errstr[128]; @@ -246,17 +363,19 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ // open the network connection AVDictionary *opts = 0; - //av_dict_set(&opts, "rtsp_transport", "tcp", 0); - + av_dict_set(&opts, "rtsp_transport", "tcp", 0); + //av_dict_set(&opts, "rtsp_transport", "udp", 0); + //av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default + netcam->rtsp->format_context = avformat_alloc_context(); netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; - + ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); if (ret < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); } av_dict_free(&opts); //The format context gets freed upon any error from open_input. @@ -312,10 +431,9 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ /* * Get an image from the feed, this serves - * two purposes. One get the dimensions of the pic - * validate that the previous steps really did open - * something we can use. Some cameras get this far - * without throwing an error + * two purposes. + * 1. Get the dimensions of the pic + * 2. Validate that the previous steps opened the camera */ ret = netcam_read_rtsp_image(netcam); @@ -334,104 +452,13 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Camera connected"); return 0; -} - -int netcam_read_rtsp_image(netcam_context_ptr netcam){ -/** -* netcam_read_rtsp_image -* -* This function reads the packet from the camera. -* It is called extensively so only absolutely essential -* functions and allocations are performed. -* -* Parameters -* -* netcam The netcam context to read from -* -* Returns: -* Failure -1 -* Success 0(zero) -* -*/ - - struct timeval curtime; - netcam_buff_ptr buffer; - AVPacket packet; - int size_decoded; - static int usual_size_decoded; - - /* Point to our working buffer. */ - buffer = netcam->receiving; - buffer->used = 0; - - av_init_packet(&packet); - packet.data = NULL; - packet.size = 0; - - size_decoded = 0; - usual_size_decoded = 0; - - if (gettimeofday(&curtime, NULL) < 0) { - MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - } - netcam->rtsp->startreadtime = curtime; - - netcam->rtsp->readingframe = 1; - while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { - if(packet.stream_index != netcam->rtsp->video_stream_index) { - av_free_packet(&packet); - av_init_packet(&packet); - packet.data = NULL; - packet.size = 0; - // not our packet, skip - continue; - } - size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); - - av_free_packet(&packet); - av_init_packet(&packet); - packet.data = NULL; - packet.size = 0; - } - netcam->rtsp->readingframe = 0; - - // at this point, we are finished with the packet - av_free_packet(&packet); - - if (size_decoded == 0) { - // something went wrong, end of stream? Interupted? - my_frame_free(netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); - return -1; - } - - if (size_decoded != usual_size_decoded) { - if (usual_size_decoded !=0) { - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: unusual frame size of %d!", size_decoded); - } - usual_size_decoded = size_decoded; - } - - - /* - * read is complete - set the current 'receiving' buffer atomically - * as 'latest', and make the buffer previously in 'latest' become - * the new 'receiving' and signal pic_ready. - */ - netcam->receiving->image_time = curtime; - netcam->last_image = curtime; - netcam_buff *xchg; - - pthread_mutex_lock(&netcam->mutex); - xchg = netcam->latest; - netcam->latest = netcam->receiving; - netcam->receiving = xchg; - netcam->imgcnt++; - pthread_cond_signal(&netcam->pic_ready); - pthread_mutex_unlock(&netcam->mutex); - - return 0; + +#else /* No FFmpeg/Libav */ + netcam->rtsp->status = RTSP_NOTCONNECTED; + netcam->rtsp->format_context = NULL; + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); + return -1; +#endif /* End #ifdef HAVE_FFMPEG */ } void netcam_shutdown_rtsp(netcam_context_ptr netcam){ @@ -449,6 +476,8 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ * Success nothing * */ +#ifdef HAVE_FFMPEG + if (netcam->rtsp->status == RTSP_CONNECTED) { my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); @@ -464,6 +493,9 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ free(netcam->rtsp); netcam->rtsp = NULL; +#else /* No FFmpeg/Libav */ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); +#endif /* End #ifdef HAVE_FFMPEG */ } int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ @@ -483,6 +515,8 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ * Success 0(zero) * */ +#ifdef HAVE_FFMPEG + struct context *cnt = netcam->cnt; const char *ptr; int ret = -1; @@ -527,15 +561,9 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ } /* - Need a method to query the path and - determine the authentication type if needed. - avformat_open_input returns file not found when - it wants authentication and it is not provided. - right now, if user specified a password, we will - prepend it onto the path to make it happier so we - can at least try basic authentication. - */ - + * Need a method to query the path and + * determine the authentication type + */ if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) + 5 + strlen(url->path) + 5 @@ -560,6 +588,9 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->rtsp->readingframe = 0; netcam->rtsp->status = RTSP_NOTCONNECTED; + av_register_all(); + avformat_network_init(); + /* * The RTSP context should be all ready to attempt a connection with * the server, so we try .... @@ -572,25 +603,9 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->get_image = netcam_read_rtsp_image; return 0; -} - -#else -/*********************************************************** - * This section is when there is no FFmpeg/Libav. It only - * contains the functions called from netcam and they all - * return fail error codes and user messages. - ***********************************************************/ -int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ + +#else /* No FFmpeg/Libav */ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); return -1; +#endif /* End #ifdef HAVE_FFMPEG */ } -void netcam_shutdown_rtsp(netcam_context_ptr netcam){ - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); -}; -int netcam_connect_rtsp(netcam_context_ptr netcam){ - netcam->rtsp->status = RTSP_NOTCONNECTED; - netcam->rtsp->format_context = NULL; - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); - return -1; -}; -#endif diff --git a/netcam_rtsp.h b/netcam_rtsp.h index b0bd3d8..edff985 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -8,7 +8,10 @@ #include #include +#endif /* end HAVE_FFMPEG */ + struct rtsp_context { +#ifdef HAVE_FFMPEG AVFormatContext* format_context; AVCodecContext* codec_context; AVFrame* frame; @@ -19,19 +22,13 @@ struct rtsp_context { int readingframe; int status; struct timeval startreadtime; -}; -#else -/**************************************** - * Dummy context for when no FFMPEG/Libav - * is on machine. These need to be primitive - * data types - *****************************************/ -struct rtsp_context { + +#else /* Do not have FFmpeg */ int* format_context; int readingframe; int status; +#endif /* end HAVE_FFMPEG */ }; -#endif struct rtsp_context *rtsp_new_context(void); void netcam_shutdown_rtsp(netcam_context_ptr netcam); From b993616a5601627d4bef7852440278855d9be083 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 5 Jul 2014 15:56:18 -0700 Subject: [PATCH 021/233] Merge with unstable --- config.h.in | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/config.h.in b/config.h.in index 31262da..ac42b9c 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,4 @@ -/* config.h.in. Generated from configure.in by autoheader. */ +/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H @@ -108,20 +108,37 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + /* Define to empty if `const' does not conform to ANSI C. */ #undef const - -/* Define to 1 if you have av_avformat_alloc_context support */ -#undef have_av_avformat_alloc_context - -/* Define to 1 if you have av_get_media_type_string support */ -#undef have_av_get_media_type_string - -/* Define to 1 if you have av_register_protocol support */ -#undef have_av_register_protocol - -/* Define to 1 if you have av_register_protocol2 support */ -#undef have_av_register_protocol2 - -/* Define to 1 if you have avformat_alloc_context support */ -#undef have_avformat_alloc_context From 8b1266974705270c1bb93d1eaf4f4f25f3ae2041 Mon Sep 17 00:00:00 2001 From: Mr-Dave Date: Mon, 7 Jul 2014 16:52:30 -0600 Subject: [PATCH 022/233] Gray image upon disconnection --- CHANGELOG | 1 + configure | 255 ++++++++++++++++++++++++----------------------- motion-dist.conf | 2 +- netcam.c | 4 + 4 files changed, 138 insertions(+), 124 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2bb0199..f2b4504 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -79,6 +79,7 @@ Features * Removed seg fault on failure to open first image, comments, isolation of RTSP * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. * Implement inits of AV functions from bcl fork + * Add gray image upon disconnection Bugfixes diff --git a/configure b/configure index 5cc0faf..ac8bb45 100755 --- a/configure +++ b/configure @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for motion trunkREVUNKNOWN. +# Generated by GNU Autoconf 2.69 for motion trunkREVUNKNOWN. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -134,6 +132,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -212,21 +236,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -328,6 +356,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -449,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -483,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -504,28 +544,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -1141,8 +1161,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1440,9 +1458,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF motion configure trunkREVUNKNOWN -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1715,7 +1733,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1872,7 +1890,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1888,7 +1907,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1914,7 +1934,8 @@ int main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1930,7 +1951,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1964,7 +1986,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2037,7 +2060,7 @@ 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 trunkREVUNKNOWN, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2406,7 +2429,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2446,7 +2469,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2499,7 +2522,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2540,7 +2563,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2598,7 +2621,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2642,7 +2665,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3088,8 +3111,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3329,7 +3351,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3395,7 +3417,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3602,8 +3624,8 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -3659,7 +3681,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3699,7 +3721,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3752,7 +3774,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3793,7 +3815,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3851,7 +3873,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3895,7 +3917,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4091,8 +4113,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4284,7 +4305,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4324,7 +4345,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4377,7 +4398,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4418,7 +4439,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -4476,7 +4497,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4520,7 +4541,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4716,8 +4737,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -6432,11 +6452,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -6453,8 +6473,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -6470,10 +6491,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -7196,16 +7217,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -7265,28 +7286,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -7308,7 +7317,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by motion $as_me trunkREVUNKNOWN, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -7370,10 +7379,10 @@ 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 trunkREVUNKNOWN -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -7461,7 +7470,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/motion-dist.conf b/motion-dist.conf index 3c853f0..30b094f 100644 --- a/motion-dist.conf +++ b/motion-dist.conf @@ -101,7 +101,7 @@ framerate 2 # This option is used when you want to capture images at a rate lower than 2 per second. minimum_frame_time 0 -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// or file:///) +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///) # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ; netcam_url value diff --git a/netcam.c b/netcam.c index efdc296..781b4f4 100644 --- a/netcam.c +++ b/netcam.c @@ -2665,6 +2665,10 @@ int netcam_next(struct context *cnt, unsigned char *image) } if (netcam->caps.streaming == NCS_RTSP) { + + if (netcam->rtsp->status == RTSP_RECONNECTING) + return NETCAM_NOTHING_NEW_ERROR; + memcpy(image, netcam->latest->ptr, netcam->latest->used); return 0; } From eeafdf7cf300b81f051d6b0ca87073ae42f52ef0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 Jul 2014 14:13:57 +0300 Subject: [PATCH 023/233] Add grey picture on rtsp disconnect by Mr-Dave https://github.com/Mr-Dave/motion/commit/8b1266974705270c1bb93d1eaf4f4f25f3ae2041 --- netcam.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netcam.c b/netcam.c index efdc296..781b4f4 100644 --- a/netcam.c +++ b/netcam.c @@ -2665,6 +2665,10 @@ int netcam_next(struct context *cnt, unsigned char *image) } if (netcam->caps.streaming == NCS_RTSP) { + + if (netcam->rtsp->status == RTSP_RECONNECTING) + return NETCAM_NOTHING_NEW_ERROR; + memcpy(image, netcam->latest->ptr, netcam->latest->used); return 0; } From e85feb01e96b0fa9838a04731d6ce506de3ede7c Mon Sep 17 00:00:00 2001 From: Mr-Dave Date: Tue, 8 Jul 2014 21:46:46 -0600 Subject: [PATCH 024/233] Add config option for transport from Hyberbolic2346 commit 423ef7bb --- CHANGELOG | 2 ++ conf.c | 10 ++++++++++ conf.h | 1 + motion-dist.conf | 6 +++++- netcam_rtsp.c | 52 ++++++++++++++++++++++++------------------------ 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2b4504..2696072 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -80,6 +80,8 @@ Features * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. * Implement inits of AV functions from bcl fork * Add gray image upon disconnection + * Added tcp/udp transport config option from hyperbolic(commit 423ef7bb3) + * Revised comments to be in line with application standard. Bugfixes diff --git a/conf.c b/conf.c index 26585ee..cf905c6 100644 --- a/conf.c +++ b/conf.c @@ -146,6 +146,7 @@ struct config conf_template = { netcam_keepalive: "off", netcam_proxy: NULL, netcam_tolerant_check: 0, + rtsp_uses_tcp: 1, text_changes: 0, text_left: NULL, text_right: DEF_TIMESTAMP, @@ -411,6 +412,15 @@ config_param config_params[] = { print_bool }, { + "rtsp_uses_tcp", + "# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption.\n" + "# Default: on", + 1, + CONF_OFFSET(rtsp_uses_tcp), + copy_bool, + print_bool + }, + { "auto_brightness", "# Let motion regulate the brightness of a video device (default: off).\n" "# The auto_brightness feature uses the brightness option as its target value.\n" diff --git a/conf.h b/conf.h index b03397e..c487b9e 100644 --- a/conf.h +++ b/conf.h @@ -123,6 +123,7 @@ struct config { const char *netcam_keepalive; const char *netcam_proxy; unsigned int netcam_tolerant_check; + unsigned int rtsp_uses_tcp; int text_changes; const char *text_left; const char *text_right; diff --git a/motion-dist.conf b/motion-dist.conf index 30b094f..98cea53 100644 --- a/motion-dist.conf +++ b/motion-dist.conf @@ -101,7 +101,7 @@ framerate 2 # This option is used when you want to capture images at a rate lower than 2 per second. minimum_frame_time 0 -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///) +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// or file:///) # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ; netcam_url value @@ -125,6 +125,10 @@ netcam_keepalive off # Default: off netcam_tolerant_check off +# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. +# Default: on +rtsp_uses_tcp on + # Let motion regulate the brightness of a video device (default: off). # The auto_brightness feature uses the brightness option as its target value. # If brightness is zero auto_brightness will adjust to average brightness value 128. diff --git a/netcam_rtsp.c b/netcam_rtsp.c index edda659..67a4a6c 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -1,7 +1,3 @@ -#include -#include "netcam_rtsp.h" -#include "motion.h" - /*********************************************************** * In the top section are the functions that are used * when processing the RTSP camera feed. Since these functions @@ -19,15 +15,16 @@ * structures are in the declarations. Simple error * messages are raised if called when no FFmpeg is found. * - * Comments inside the function structure are particular - * to that function. Comments outside a function (such as - * these) are applicable to the entire module. ***********************************************************/ + +#include +#include "netcam_rtsp.h" +#include "motion.h" + #ifdef HAVE_FFMPEG #include "ffmpeg.h" -static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ /** * netcam_buffsize_rtsp * @@ -41,6 +38,7 @@ static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ * * Returns: Nothing */ +static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ int min_size_to_alloc; int real_alloc; @@ -66,7 +64,6 @@ static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ buff->size = new_size; } -static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ /** * decode_packet * @@ -84,7 +81,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram * Failure 0(zero) * Success The size of the frame decoded */ - +static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ int check = 0; int frame_size = 0; int ret = 0; @@ -112,7 +109,6 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram return frame_size; } -static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ /** * open_codec_context * @@ -128,7 +124,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV * Failure Error code from FFmpeg (Negative number) * Success 0(Zero) */ - +static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ int ret; char errstr[128]; AVStream *st; @@ -164,7 +160,6 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV return 0; } -struct rtsp_context *rtsp_new_context(void){ /** * rtsp_new_context * @@ -177,7 +172,7 @@ struct rtsp_context *rtsp_new_context(void){ * Returns: Pointer to the newly-created structure, NULL if error. * */ - +struct rtsp_context *rtsp_new_context(void){ struct rtsp_context *ret; /* Note that mymalloc will exit on any problem. */ @@ -188,7 +183,6 @@ struct rtsp_context *rtsp_new_context(void){ return ret; } -static int netcam_interrupt_rtsp(void *ctx){ /** * netcam_interrupt_rtsp * @@ -209,7 +203,7 @@ static int netcam_interrupt_rtsp(void *ctx){ * Success 0(zero which indicates to let process continue) * */ - +static int netcam_interrupt_rtsp(void *ctx){ struct rtsp_context *rtsp = (struct rtsp_context *)ctx; if (rtsp->readingframe != 1) { @@ -231,7 +225,6 @@ static int netcam_interrupt_rtsp(void *ctx){ return 0; } -int netcam_read_rtsp_image(netcam_context_ptr netcam){ /** * netcam_read_rtsp_image * @@ -248,7 +241,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ * Success 0(zero) * */ - +int netcam_read_rtsp_image(netcam_context_ptr netcam){ struct timeval curtime; netcam_buff_ptr buffer; AVPacket packet; @@ -333,8 +326,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ * This ends the section of functions that rely upon FFmpeg ***********************************************************/ #endif /* End HAVE_FFMPEG */ - -int netcam_connect_rtsp(netcam_context_ptr netcam){ + /** * netcam_connect_rtsp * @@ -348,7 +340,8 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ * Failure -1 * Success 0(zero) * -*/ +*/ +int netcam_connect_rtsp(netcam_context_ptr netcam){ #ifdef HAVE_FFMPEG int ret; @@ -363,9 +356,16 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ // open the network connection AVDictionary *opts = 0; - av_dict_set(&opts, "rtsp_transport", "tcp", 0); - //av_dict_set(&opts, "rtsp_transport", "udp", 0); - //av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default + if (netcam->cnt->conf.rtsp_uses_tcp) { + av_dict_set(&opts, "rtsp_transport", "tcp", 0); + if (netcam->rtsp->status == RTSP_NOTCONNECTED) + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using tcp transport"); + } else { + av_dict_set(&opts, "rtsp_transport", "udp", 0); + av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default + if (netcam->rtsp->status == RTSP_NOTCONNECTED) + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using udp transport"); + } netcam->rtsp->format_context = avformat_alloc_context(); netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; @@ -461,7 +461,6 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ #endif /* End #ifdef HAVE_FFMPEG */ } -void netcam_shutdown_rtsp(netcam_context_ptr netcam){ /** * netcam_shutdown_rtsp * @@ -476,6 +475,7 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ * Success nothing * */ +void netcam_shutdown_rtsp(netcam_context_ptr netcam){ #ifdef HAVE_FFMPEG if (netcam->rtsp->status == RTSP_CONNECTED) { @@ -498,7 +498,6 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ #endif /* End #ifdef HAVE_FFMPEG */ } -int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ /** * netcam_setup_rtsp * @@ -515,6 +514,7 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ * Success 0(zero) * */ +int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ #ifdef HAVE_FFMPEG struct context *cnt = netcam->cnt; From e9abd61a923be82276ebbbb11da2a4717be7aead Mon Sep 17 00:00:00 2001 From: Mr-Dave Date: Sat, 12 Jul 2014 16:08:24 -0600 Subject: [PATCH 025/233] Revised motion-dist --- motion-dist.conf | 2 +- motion-dist.conf.in | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/motion-dist.conf b/motion-dist.conf index 98cea53..8979464 100644 --- a/motion-dist.conf +++ b/motion-dist.conf @@ -128,7 +128,7 @@ netcam_tolerant_check off # RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. # Default: on rtsp_uses_tcp on - + # Let motion regulate the brightness of a video device (default: off). # The auto_brightness feature uses the brightness option as its target value. # If brightness is zero auto_brightness will adjust to average brightness value 128. diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 630cbf8..5e3dbe3 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -101,7 +101,7 @@ framerate 2 # This option is used when you want to capture images at a rate lower than 2 per second. minimum_frame_time 0 -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///) +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// or file:///) # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ; netcam_url value @@ -125,6 +125,10 @@ netcam_keepalive off # Default: off netcam_tolerant_check off +# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. +# Default: on +rtsp_uses_tcp on + # Let motion regulate the brightness of a video device (default: off). # The auto_brightness feature uses the brightness option as its target value. # If brightness is zero auto_brightness will adjust to average brightness value 128. From c6a7bae0a01d621defaaa8cb413f392bab684b99 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 16:02:58 +0300 Subject: [PATCH 026/233] Removed motion-dist.conf, it is autogenerated upon configure --- motion-dist.conf | 736 ----------------------------------------------- 1 file changed, 736 deletions(-) delete mode 100644 motion-dist.conf diff --git a/motion-dist.conf b/motion-dist.conf deleted file mode 100644 index 8979464..0000000 --- a/motion-dist.conf +++ /dev/null @@ -1,736 +0,0 @@ -# Rename this distribution example file to motion.conf -# -# This config file was generated by motion trunkREVUNKNOWN - - -############################################################ -# Daemon -############################################################ - -# Start in daemon (background) mode and release terminal (default: off) -daemon on - -# File to store the process ID, also called pid file. (default: not defined) -process_id_file /var/run/motion/motion.pid - -############################################################ -# Basic Setup Mode -############################################################ - -# Start in Setup-Mode, daemon disabled. (default: off) -setup_mode off - - -# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) -;logfile /tmp/motion.log - -# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -log_level 6 - -# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -log_type all - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video0 - -# v4l2_palette allows to choose preferable palette to be use by motion -# to capture from those supported by your videodevice. (default: 17) -# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and -# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. -# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 -# instead. -# -# Values : -# V4L2_PIX_FMT_SN9C10X : 0 'S910' -# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -# V4L2_PIX_FMT_SPCA561 : 3 'S561' -# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -# V4L2_PIX_FMT_PAC207 : 6 'P207' -# V4L2_PIX_FMT_PJPG : 7 'PJPG' -# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -# V4L2_PIX_FMT_JPEG : 9 'JPEG' -# V4L2_PIX_FMT_RGB24 : 10 'RGB3' -# V4L2_PIX_FMT_SPCA501 : 11 'S501' -# V4L2_PIX_FMT_SPCA505 : 12 'S505' -# V4L2_PIX_FMT_SPCA508 : 13 'S508' -# V4L2_PIX_FMT_UYVY : 14 'UYVY' -# V4L2_PIX_FMT_YUYV : 15 'YUYV' -# V4L2_PIX_FMT_YUV422P : 16 '422P' -# V4L2_PIX_FMT_YUV420 : 17 'YU12' -# -v4l2_palette 17 - -# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) -# This is ONLY used for FreeBSD. Leave it commented out for Linux -; tunerdevice /dev/tuner0 - -# 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) -norm 0 - -# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) -frequency 0 - -# Rotate image this number of degrees. The rotation affects all saved images as -# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. -rotate 0 - -# Image width (pixels). Valid range: Camera dependent, default: 352 -width 320 - -# Image height (pixels). Valid range: Camera dependent, default: 288 -height 240 - -# Maximum number of frames to be captured per second. -# Valid range: 2-100. Default: 100 (almost no limit). -framerate 2 - -# Minimum time in seconds between capturing picture frames from the camera. -# Default: 0 = disabled - the capture rate is given by the camera framerate. -# This option is used when you want to capture images at a rate lower than 2 per second. -minimum_frame_time 0 - -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -; netcam_url value - -# Username and password for network camera (only if required). Default: not defined -# Syntax is user:password -; netcam_userpass value - -# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -# on: Use HTTP/1.1 requests that support keep alive as default. -# Default: off -netcam_keepalive off - -# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". -# If a port number other than 80 is needed, use "http://myproxy:1234". -# Default: not defined -; netcam_proxy value - -# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -# Default: off -netcam_tolerant_check off - -# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. -# Default: on -rtsp_uses_tcp on - -# Let motion regulate the brightness of a video device (default: off). -# The auto_brightness feature uses the brightness option as its target value. -# If brightness is zero auto_brightness will adjust to average brightness value 128. -# Only recommended for cameras without auto brightness -auto_brightness off - -# Set the initial brightness of a video device. -# If auto_brightness is enabled, this value defines the average brightness level -# which Motion will try and adjust to. -# Valid range 0-255, default 0 = disabled -brightness 0 - -# Set the contrast of a video device. -# Valid range 0-255, default 0 = disabled -contrast 0 - -# Set the saturation of a video device. -# Valid range 0-255, default 0 = disabled -saturation 0 - -# Set the hue of a video device (NTSC feature). -# Valid range 0-255, default 0 = disabled -hue 0 - - -############################################################ -# Round Robin (multiple inputs on same video device name) -############################################################ - -# Number of frames to capture in each roundrobin step (default: 1) -roundrobin_frames 1 - -# Number of frames to skip before each roundrobin step (default: 1) -roundrobin_skip 1 - -# Try to filter out noise generated by roundrobin (default: off) -switchfilter off - - -############################################################ -# Motion Detection Settings: -############################################################ - -# Threshold for number of changed pixels in an image that -# triggers motion detection (default: 1500) -threshold 1500 - -# Automatically tune the threshold down if possible (default: off) -threshold_tune off - -# Noise threshold for the motion detection (default: 32) -noise_level 32 - -# Automatically tune the noise threshold (default: on) -noise_tune on - -# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) -# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. -# (l)abeling must only be used once and the 'l' must be the last letter. -# Comment out to disable -despeckle_filter EedDl - -# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -# A script (on_area_detected) is started immediately when motion is 4 5 6 -# detected in one of the given areas, but only once during an event. 7 8 9 -# One or more areas can be specified with this option. Take care: This option -# does NOT restrict detection to these areas! (Default: not defined) -; area_detect value - -# PGM file to use as a sensitivity mask. -# Full path name to. (Default: not defined) -; mask_file value - -# Dynamically create a mask file during operation (default: 0) -# Adjust speed of mask changes from 0 (off) to 10 (fast) -smart_mask_speed 0 - -# Ignore sudden massive light intensity changes given as a percentage of the picture -# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled -lightswitch 0 - -# Picture frames must contain motion at least the specified number of frames -# in a row before they are detected as true motion. At the default of 1, all -# motion is detected. Valid range: 1 to thousands, recommended 1-5 -minimum_motion_frames 1 - -# Specifies the number of pre-captured (buffered) pictures from before motion -# was detected that will be output at motion detection. -# Recommended range: 0 to 5 (default: 0) -# Do not use large values! Large values will cause Motion to skip video frames and -# cause unsmooth movies. To smooth movies use larger values of post_capture instead. -pre_capture 0 - -# Number of frames to capture after motion is no longer detected (default: 0) -post_capture 0 - -# Event Gap is the seconds of no motion detection that triggers the end of an event. -# An event is defined as a series of motion images taken within a short timeframe. -# Recommended value is 60 seconds (Default). The value -1 is allowed and disables -# events causing all Motion to be written to one single movie file and no pre_capture. -# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An -# event ends right after no more motion is detected and post_capture is over. -event_gap 60 - -# Maximum length in seconds of a movie -# When value is exceeded a new movie file is created. (Default: 0 = infinite) -max_movie_time 0 - -# Always save images even if there was no motion (default: off) -emulate_motion off - - -############################################################ -# Image File Output -############################################################ - -# Output 'normal' pictures when motion is detected (default: on) -# Valid values: on, off, first, best, center -# When set to 'first', only the first picture of an event is saved. -# Picture with most motion of an event is saved when set to 'best'. -# Picture with motion nearest center of picture is saved when set to 'center'. -# Can be used as preview shot for the corresponding movie. -output_pictures on - -# Output pictures with only the pixels moving object (ghost images) (default: off) -output_debug_pictures off - -# The quality (in percent) to be used by the jpeg compression (default: 75) -quality 75 - -# Type of output images -# Valid values: jpeg, ppm (default: jpeg) -picture_type jpeg - -############################################################ -# FFMPEG related options -# Film (movies) file output, and deinterlacing of the video input -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################ - -# Use ffmpeg to encode movies in realtime (default: off) -ffmpeg_output_movies on - -# Use ffmpeg to make movies with only the pixels moving -# object (ghost images) (default: off) -ffmpeg_output_debug_movies off - -# Use ffmpeg to encode a timelapse movie -# Default value 0 = off - else save frame every Nth second -ffmpeg_timelapse 0 - -# The file rollover mode of the timelapse video -# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual -ffmpeg_timelapse_mode daily - -# Bitrate to be used by the ffmpeg encoder (default: 400000) -# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) -ffmpeg_bps 500000 - -# Enables and defines variable bitrate for the ffmpeg encoder. -# ffmpeg_bps is ignored if variable bitrate is enabled. -# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, -# or the range 2 - 31 where 2 means best quality and 31 is worst. -ffmpeg_variable_bitrate 0 - -# Codec to used by ffmpeg for the video compression. -# Timelapse mpegs are always made in mpeg1 format independent from this option. -# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. -# mpeg1 - gives you files with extension .mpg -# mpeg4 or msmpeg4 - gives you files with extension .avi -# msmpeg4 is recommended for use with Windows Media Player because -# it requires no installation of codec on the Windows client. -# swf - gives you a flash film with extension .swf -# flv - gives you a flash video with extension .flv -# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -# mov - QuickTime ( testing ) -# ogg - Ogg/Theora ( testing ) -ffmpeg_video_codec mpeg4 - -# Use ffmpeg to deinterlace video. Necessary if you use an analog camera -# and see horizontal combing on moving objects in video or pictures. -# (default: off) -ffmpeg_deinterlace off - -############################################################ -# SDL Window -############################################################ - -# Number of motion thread to show in SDL Window (default: 0 = disabled) -sdl_threadnr 0 - -############################################################ -# External pipe to video encoder -# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################# - -# Bool to enable or disable extpipe (default: off) -use_extpipe off - -# External program (full path and opts) to pipe raw video to -# Generally, use '-' for STDIN... -;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps - - - -############################################################ -# Snapshots (Traditional Periodic Webcam File Output) -############################################################ - -# Make automated snapshot every N seconds (default: 0 = disabled) -snapshot_interval 0 - - -############################################################ -# Text Display -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, \n = new line, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event - do not use with text_event! -# You can put quotation marks around the text to allow -# leading spaces -############################################################ - -# Locate and draw a box around the moving object. -# Valid values: on, off, preview (default: off) -# Set to 'preview' will only draw a box in preview_shot pictures. -locate_motion_mode off - -# Set the look and style of the locate box if enabled. -# Valid values: box, redbox, cross, redcross (default: box) -# Set to 'box' will draw the traditional box. -# Set to 'redbox' will draw a red box. -# Set to 'cross' will draw a little cross to mark center. -# Set to 'redcross' will draw a little red cross to mark center. -locate_motion_style box - -# Draws the timestamp using same options as C function strftime(3) -# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -# Text is placed in lower right corner -text_right %Y-%m-%d\n%T-%q - -# Draw a user defined text on the images using same options as C function strftime(3) -# Default: Not defined = no text -# Text is placed in lower left corner -; text_left CAMERA %t - -# Draw the number of changed pixed on the images (default: off) -# Will normally be set to off except when you setup and adjust the motion settings -# Text is placed in upper right corner -text_changes off - -# This option defines the value of the special event conversion specifier %C -# You can use any conversion specifier in this option except %C. Date and time -# values are from the timestamp of the first image in the current event. -# Default: %Y%m%d%H%M%S -# The idea is that %C can be used filenames and text_left/right for creating -# a unique identifier for each event. -text_event %Y%m%d%H%M%S - -# Draw characters at twice normal size on images. (default: off) -text_double off - - -# Text to include in a JPEG EXIF comment -# May be any text, including conversion specifiers. -# The EXIF timestamp is included independent of this text. -;exif_text %i%J/%K%L - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, movie_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute path. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam1 - -# File path for snapshots (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-snapshot -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot -# File extension .jpg or .ppm is automatically added so do not include this. -# Note: A symbolic link called lastsnap.jpg created in the target_dir will always -# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -snapshot_filename %v-%Y%m%d%H%M%S-snapshot - -# File path for motion triggered images (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-%q -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this -# Set to 'preview' together with best-preview feature enables special naming -# convention for preview shots. See motion guide for details -picture_filename %v-%Y%m%d%H%M%S-%q - -# File path for motion triggered ffmpeg films (movies) relative to target_dir -# Default: %v-%Y%m%d%H%M%S -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -# File extension .mpg or .avi is automatically added so do not include this -# This option was previously called ffmpeg_filename -movie_filename %v-%Y%m%d%H%M%S - -# File path for timelapse movies relative to target_dir -# Default: %Y%m%d-timelapse -# Default value is near equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse -# File extension .mpg is automatically added so do not include this -timelapse_filename %Y%m%d-timelapse - -############################################################ -# Global Network Options -############################################################ -# Enable or disable IPV6 for http control and stream (default: off ) -ipv6_enabled off - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8081 - -# Quality of the jpeg (in percent) images produced (default: 50) -stream_quality 50 - -# Output frames at 1 fps when no motion is detected and increase to the -# rate given by stream_maxrate when motion is detected (default: off) -stream_motion off - -# Maximum framerate for stream streams (default: 1) -stream_maxrate 1 - -# Restrict stream connections to localhost only (default: on) -stream_localhost on - -# Limits the number of images per connection (default: 0 = unlimited) -# Number can be defined by multiplying actual stream rate by desired number of seconds -# Actual stream rate is the smallest of the numbers framerate and stream_maxrate -stream_limit 0 - -# Set the authentication method (default: 0) -# 0 = disabled -# 1 = Basic authentication -# 2 = MD5 digest (the safer authentication) -stream_auth_method 0 - -# Authentication for the stream. Syntax username:password -# Default: not defined (Disabled) -; stream_authentication username:password - - -############################################################ -# HTTP Based Control -############################################################ - -# TCP/IP port for the http server to listen on (default: 0 = disabled) -webcontrol_port 8080 - -# Restrict control connections to localhost only (default: on) -webcontrol_localhost on - -# Output for http server, select off to choose raw text plain (default: on) -webcontrol_html_output on - -# Authentication for the http based control. Syntax username:password -# Default: not defined (Disabled) -; webcontrol_authentication username:password - - -############################################################ -# Tracking (Pan/Tilt) -############################################################# - -# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) -# The generic type enables the definition of motion center and motion size to -# be used with the conversion specifiers for options like on_motion_detected -track_type 0 - -# Enable auto tracking (default: off) -track_auto off - -# Serial port of motor (default: none) -;track_port /dev/ttyS0 - -# Motor number for x-axis (default: 0) -;track_motorx 0 - -# Set motorx reverse (default: 0) -;track_motorx_reverse 0 - -# Motor number for y-axis (default: 0) -;track_motory 1 - -# Set motory reverse (default: 0) -;track_motory_reverse 0 - -# Maximum value on x-axis (default: 0) -;track_maxx 200 - -# Minimum value on x-axis (default: 0) -;track_minx 50 - -# Maximum value on y-axis (default: 0) -;track_maxy 200 - -# Minimum value on y-axis (default: 0) -;track_miny 50 - -# Center value on x-axis (default: 0) -;track_homex 128 - -# Center value on y-axis (default: 0) -;track_homey 128 - -# ID of an iomojo camera if used (default: 0) -track_iomojo_id 0 - -# Angle in degrees the camera moves per step on the X-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_x 10 - -# Angle in degrees the camera moves per step on the Y-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_y 10 - -# Delay to wait for after tracking movement as number -# of picture frames (default: 10) -track_move_wait 10 - -# Speed to set the motor to (stepper motor option) (default: 255) -track_speed 255 - -# Number of steps to make (stepper motor option) (default: 40) -track_stepsize 40 - - -############################################################ -# External Commands, Warnings and Logging: -# You can use conversion specifiers for the on_xxxx commands -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# %f = filename with full path -# %n = number indicating filetype -# Both %f and %n are only defined for on_picture_save, -# on_movie_start and on_movie_end -# Quotation marks round string are allowed. -############################################################ - -# Do not sound beeps when detecting motion (default: on) -# Note: Motion never beeps when running in daemon mode. -quiet on - -# Command to be executed when an event starts. (default: none) -# An event starts at first motion detected after a period of no motion defined by event_gap -; on_event_start value - -# Command to be executed when an event ends after a period of no motion -# (default: none). The period of no motion is defined by option event_gap. -; on_event_end value - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# To give the filename as an argument to a command append it with %f -; on_picture_save value - -# Command to be executed when a motion frame is detected (default: none) -; on_motion_detected value - -# Command to be executed when motion in a predefined area is detected -# Check option 'area_detect'. (default: none) -; on_area_detected value - -# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_start value - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_end value - -# Command to be executed when a camera can't be opened or if it is lost -# NOTE: There is situations when motion don't detect a lost camera! -# It depends on the driver, some drivers dosn't detect a lost camera at all -# Some hangs the motion thread. Some even hangs the PC! (default: none) -; on_camera_lost value - -##################################################################### -# Common Options for database features. -# Options require database options to be active also. -##################################################################### - -# Log to the database when creating motion triggered picture file (default: on) -; sql_log_picture on - -# Log to the database when creating a snapshot image file (default: on) -; sql_log_snapshot on - -# Log to the database when creating motion triggered movie file (default: off) -; sql_log_movie off - -# Log to the database when creating timelapse movies file (default: off) -; sql_log_timelapse off - -# SQL query string that is sent to the database -# Use same conversion specifiers has for text features -# Additional special conversion specifiers are -# %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') - - -############################################################ -# Database Options -############################################################ - -# database type : mysql, postgresql, sqlite3 (default : not defined) -; database_type value - -# database to log to (default: not defined) -; database_dbname value - -# The host on which the database is located (default: localhost) -; database_host value - -# User account name for database (default: not defined) -; database_user value - -# User password for database (default: not defined) -; database_password value - -# Port on which the database is located -# mysql 3306 , postgresql 5432 (default: not defined) -; database_port value - -############################################################ -# Database Options For SQLite3 -############################################################ - -# SQLite3 database (file path) (default: not defined) -; sqlite3_db value - - - -############################################################ -# Video Loopback Device (vloopback project) -############################################################ - -# Output images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; video_pipe value - -# Output motion images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; motion_video_pipe value - - -############################################################## -# Thread config files - One for each camera. -# Except if only one camera - You only need this config file. -# If you have more than one camera you MUST define one thread -# config file for each camera in addition to this config file. -############################################################## - -# Remember: If you have more than one camera you must have one -# thread file for each camera. E.g. 2 cameras requires 3 files: -# This motion.conf file AND thread1.conf and thread2.conf. -# Only put the options that are unique to each camera in the -# thread config files. -; thread /usr/local/etc/thread1.conf -; thread /usr/local/etc/thread2.conf -; thread /usr/local/etc/thread3.conf -; thread /usr/local/etc/thread4.conf - From 259f959e0deb5a901b1d8f314ce95c9f5b63f488 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 17:14:46 +0300 Subject: [PATCH 027/233] Whitespace fix --- CHANGELOG | 5 +-- INSTALL | 121 +++++++++++++++++++++++++++--------------------------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2696072..dd812db 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,7 +53,7 @@ Features * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) * Buffer overflow vulnerabilities (hyperbolic2346) * Redundand -- boundary prefix (torao) - * Proper size for memset and allocation size (Alfred Klomp) + * Proper size for memset and allocation size (Alfred Klomp) * Removed compiler warnings: (Mr-Dave) logger.c,jpegutils.c,netcam_ftp.c,track.c, picture.c,webhttpd.c,stream.c,ffmpeg.c @@ -78,12 +78,11 @@ Features * Additional validations for RTSP connection and corrected free sequences * Removed seg fault on failure to open first image, comments, isolation of RTSP * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. - * Implement inits of AV functions from bcl fork + * Implement inits of AV functions from bcl fork * Add gray image upon disconnection * Added tcp/udp transport config option from hyperbolic(commit 423ef7bb3) * Revised comments to be in line with application standard. - Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) diff --git a/INSTALL b/INSTALL index 4a2c39a..48d9951 100644 --- a/INSTALL +++ b/INSTALL @@ -1,61 +1,62 @@ NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point - and may need modification by the time you read this. - -********************************** -*** DEBIAN BASED SYSTEMS *** - -Required Packages: - sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev - -Obtain source code (via git) - sudo apt-get install git - cd ~ - git clone {https://github.com/your favorite fork} - -To rebuild the motion configure file use - autoreconf - -Optional: With FFMPEG support: - Build FFMPEG via their instructions - Configure with manually built ffmpeg which currently installs to ~/bin and ~/ffmpeg_build - Basic - ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include - - With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG - ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " - - With extra libraries for ffmpeg and install to ~/motion_build - ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " - -With LIBAV APT versions of libraries - sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools - -Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat - ./configure - -Sample PI configuration with LIBAV - ./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf --with-ffmpeg-headers=/usr/include - - -Once configured type: - make - make install - -***************************** -*** OpenSUSE SYSTEM *** - -sudo zypper install autoconf automake libtool git -sudo zypper install --type pattern devel_basis -sudo zypper install libjpeg8-devel -sudo zypper install -t pattern devel_C_C++ - -Optional: FFmpeg files -sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials -sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia -sudo zypper install libffmpeg-devel - -./configure - make - make install - -************************* + and may need modification by the time you read this. + +********************************** +*** DEBIAN BASED SYSTEMS *** + +Required Packages: + sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev + +Obtain source code (via git) + sudo apt-get install git + cd ~ + git clone {https://github.com/your favorite fork} + +To rebuild the motion configure file use + autoreconf + +Optional: With FFMPEG support: + Build FFMPEG via their instructions + Configure with manually built ffmpeg which currently installs to ~/bin and ~/ffmpeg_build + Basic + ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include + + With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG + ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + + With extra libraries for ffmpeg and install to ~/motion_build + ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + +With LIBAV APT versions of libraries + sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools + +Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat + ./configure + +Sample PI configuration with LIBAV + ./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf --with-ffmpeg-headers=/usr/include + + +Once configured type: + make + make install + +***************************** +*** OpenSUSE SYSTEM *** + +sudo zypper install autoconf automake libtool git +sudo zypper install --type pattern devel_basis +sudo zypper install libjpeg8-devel +sudo zypper install -t pattern devel_C_C++ + +Optional: FFmpeg files +sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials +sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia +sudo zypper install libffmpeg-devel + +./configure + make + make install + +************************* + From 1184a9c3f4e493e7da5f91231ee931757545fd59 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 17:16:07 +0300 Subject: [PATCH 028/233] Whitespace fix --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 48d9951..682662c 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point +NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point and may need modification by the time you read this. ********************************** From 250b2e41bee9a799aade9eaa7677873fa2618a99 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 17:24:25 +0300 Subject: [PATCH 029/233] Whitespace fix (finnaly INSTALL is done) --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 682662c..aaf526e 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point +NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point and may need modification by the time you read this. ********************************** From 3528e659aaf0ccfe27f75ac4fed17f59ff1c4486 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 17:43:27 +0300 Subject: [PATCH 030/233] Whitespace fix --- configure.ac | 118 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/configure.ac b/configure.ac index 1be77bd..a56fabf 100755 --- a/configure.ac +++ b/configure.ac @@ -46,7 +46,7 @@ if test "${Darwin}" = ""; then if test "${LINUXTHREADS}" = "no"; then AC_MSG_CHECKING(Linuxthreads) AC_MSG_RESULT(skipping) - else + else THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" fi @@ -54,9 +54,9 @@ if test "${Darwin}" = ""; then if test "${PWCBSD}" != "no"; then VIDEO="video.o video2.o video_common.o" TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" - else + else VIDEO="video_freebsd.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" fi TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" @@ -96,7 +96,7 @@ if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" fi # -# Check to Exclude BKTR +# Check to Exclude BKTR # BKTR="yes" AC_ARG_WITH(bktr, @@ -108,7 +108,7 @@ BKTR="$withval" ) if test "${BKTR}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" fi else @@ -140,10 +140,10 @@ AC_MSG_CHECKING(for linuxthreads) # Check for thread header # if test -f "${THREAD_CHECK}"; then - HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" - THREADS="yes" + HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" + THREADS="yes" else - THREADS="no" + THREADS="no" fi # @@ -153,7 +153,7 @@ AC_MSG_CHECKING(for linuxthreads) THREADS="yes" LIB_THREAD="-llthread -llgcc_r" else - THREADS="no" + THREADS="no" fi # Checks for Library linuxthreads for FreeBSD @@ -199,12 +199,12 @@ if test x$PTHREAD_LIB != xyes; then fi PTHREAD_SUPPORT="yes" fi - AC_MSG_RESULT($PTHREAD_SUPPORT) + AC_MSG_RESULT($PTHREAD_SUPPORT) else echo echo "You do not have threads support" - echo + echo fi @@ -318,7 +318,7 @@ if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then elif test "${JPEG_MMX}" = "yes"; then # AUTODETECT STATIC LIB AC_MSG_CHECKING(for libjpeg-mmx autodetecting) - + if test -f /usr/lib/libjpeg-mmx.a ; then AC_MSG_RESULT(found) JPEG_MMX_OK="found" @@ -330,8 +330,8 @@ elif test "${JPEG_MMX}" = "yes"; then else AC_MSG_RESULT(not found) fi -else - AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) +else + AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then AC_MSG_RESULT(found) JPEG_MMX_OK="found" @@ -382,7 +382,7 @@ FFMPEG_OK="no_found" FFMPEG_OBJ="" AC_ARG_WITH(ffmpeg, [ --with-ffmpeg[=DIR] Specify the prefix for the install path for - libavcodec/libavformat (part of ffmpeg) be able to + libavcodec/libavformat (part of ffmpeg) be able to encode mpeg movies realtime. If this is not specified motion will try to find the libraries in /usr and /usr/local. @@ -390,7 +390,7 @@ AC_ARG_WITH(ffmpeg, FFMPEG_DIR="$withval" ) -# +# # ffmpeg headers custom location # FFMPEG_HEADERS_DIR="yes" @@ -420,7 +420,7 @@ if test "${FFMPEG_DIR}" = "no"; then # with-ffmpeg= or nothing # else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB + # AUTODETECT STATIC/SHARED LIB AC_MSG_CHECKING(for ffmpeg autodetecting libraries) if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then @@ -447,7 +447,7 @@ else if test "${FFMPEG_DIR}" = "yes"; then AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/i386-linux-gnu" - FFMPEG_DIR="/usr" + FFMPEG_DIR="/usr" else AC_MSG_RESULT(not found) echo "" @@ -459,8 +459,8 @@ else if test "${FFMPEG_DIR}" = "yes"; then echo "* Please read the Motion Guide for help: *" echo "* http://motion.sourceforge.net *" echo "**********************************************" - echo "" - fi + echo "" + fi else AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then @@ -520,12 +520,12 @@ if test "${FFMPEG_OK}" = "found"; then elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" + AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" + AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then AC_MSG_RESULT(found ${FFMPEG_DIR}/libavformat/avformat.h) @@ -547,10 +547,10 @@ if test "${FFMPEG_OK}" = "found"; then fi # -# If ffmpeg libs and headers have been found +# If ffmpeg libs and headers have been found # - if test "${FFMPEG_OK}" = "found"; then + if test "${FFMPEG_OK}" = "found"; then TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" @@ -564,7 +564,7 @@ if test "${FFMPEG_OK}" = "found"; then CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" LIBS="$TEMP_LIBS" - + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ [ #include <${AVFORMAT_DIR}> @@ -583,7 +583,7 @@ if test "${FFMPEG_OK}" = "found"; then CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS fi -fi +fi fi # Revised RTSP module so that it can be included @@ -621,7 +621,7 @@ else CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS -fi +fi # @@ -691,13 +691,13 @@ else fi done elif test "${MYSQL_HEADERS}" = "no"; then - AC_MSG_CHECKING(for mysql headers) + AC_MSG_CHECKING(for mysql headers) AC_MSG_RESULT(skipped) else AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) # Manual detection for - if test -f $MYSQL_HEADERS/mysql.h; then - MYSQL_INCDIR=$MYSQL_HEADERS + if test -f $MYSQL_HEADERS/mysql.h; then + MYSQL_INCDIR=$MYSQL_HEADERS fi fi @@ -716,7 +716,7 @@ else # ******* Search mysql libs ********* if test "${MYSQL_LIBS}" = "yes"; then AC_MSG_CHECKING(autodect mysql libs) - # Autodetect + # Autodetect for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do # check for plain setups if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then @@ -735,7 +735,7 @@ else fi done elif test "${MYSQL_LIBS}" = "no"; then - AC_MSG_CHECKING(for mysql libs) + AC_MSG_CHECKING(for mysql libs) AC_MSG_RESULT(skipped) else AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) @@ -756,13 +756,13 @@ else saved_LIBS=$LIBS CFLAGS="-I$MYSQL_INCDIR" LIBS="-L$MYSQL_LIBDIR" - AC_CHECK_LIB(mysqlclient,mysql_init,[ + AC_CHECK_LIB(mysqlclient,mysql_init,[ TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" MYSQL_SUPPORT="yes" AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) ], - AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) + AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS fi @@ -829,15 +829,15 @@ else el[]PGSQL_INC_CHK(/include/postgresql) fi done - + elif test "${PGSQL_HEADERS}" = "no"; then - AC_MSG_CHECKING(for pgsql headers) + AC_MSG_CHECKING(for pgsql headers) AC_MSG_RESULT(skipped) else AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) # Manual detection for - if test -f $PGSQL_HEADERS/libpq-fe.h; then - PGSQL_INCDIR=$PGSQL_HEADERS + if test -f $PGSQL_HEADERS/libpq-fe.h; then + PGSQL_INCDIR=$PGSQL_HEADERS fi fi @@ -863,10 +863,10 @@ else if test -f /usr/lib64/libpq.so ; then PGSQL_LIBDIR=/usr/lib64 elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql + PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql - elif test -f $PGSQL_DIR/lib/libpq.so ; then + elif test -f $PGSQL_DIR/lib/libpq.so ; then PGSQL_LIBDIR=$PGSQL_DIR/lib else PGSQL_LIBDIR="" @@ -875,7 +875,7 @@ else AC_MSG_RESULT($PGSQL_LIBDIR) elif test "${PGSQL_LIBS}" = "no"; then - AC_MSG_CHECKING(for pgsql libs) + AC_MSG_CHECKING(for pgsql libs) AC_MSG_RESULT(skipped) else AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) @@ -900,13 +900,13 @@ else TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) - ], + ], AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) - LDFLAGS="" + LDFLAGS="" CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS fi - + fi # end pgsql-include , pgsql-libs # end PostgreSQL detection @@ -927,17 +927,17 @@ if test "${V4L}" = "no"; then AC_MSG_CHECKING(for V42L support) AC_MSG_RESULT(skipping) else - AC_CHECK_TYPE([struct v4l2_buffer], - [SUPPORTED_V4L2=true], - [SUPPORTED_V4L2=false], - [#include + AC_CHECK_TYPE([struct v4l2_buffer], + [SUPPORTED_V4L2=true], + [SUPPORTED_V4L2=false], + [#include #include ]) AC_MSG_CHECKING(for V42L support) if test x$SUPPORTED_V4L2 = xtrue; then AC_MSG_RESULT(yes) TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" - else + else AC_MSG_RESULT(no) fi @@ -1063,12 +1063,12 @@ if test -e "/proc/cpuinfo" ; then amd[[1543]]="-march=athlon64" amd[[1544]]="-march=athlon64" amd[[1565]]="-march=opteron" - amd[[1572]]="-march=k8" + amd[[1572]]="-march=k8" via[[67]]="-march=c3" via[[68]]="-march=c3" - via[[69]]="-march=i686" + via[[69]]="-march=i686" via[[610]]="-march=i686" - + CPU_TYPE="known" CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` @@ -1232,7 +1232,7 @@ AC_LINK_IFELSE([ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" AC_MSG_RESULT(yes) ], - [ + [ AC_MSG_RESULT(no) ]) @@ -1287,14 +1287,14 @@ echo " **************************" echo " Configure status " echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" echo " **************************" -echo +echo if test "${Darwin}" != ""; then echo "OS : Darwin" elif test "${FreeBSD}" != ""; then - echo "OS : *BSD" -else + echo "OS : *BSD" +else echo "OS : Linux" fi @@ -1304,7 +1304,7 @@ else echo "pthread support: No" echo "**********************************************" echo "** Fatal Error YOU MUST HAVE pthread Support *" - echo "**********************************************" + echo "**********************************************" fi @@ -1342,7 +1342,7 @@ else fi if test x$SUPPORTED_V4L2 = xtrue; then - echo "V4L2 support: Yes" + echo "V4L2 support: Yes" else echo "V4L2 support: No" fi @@ -1377,7 +1377,7 @@ if test "${PGSQL_SUPPORT}" = "yes"; then else echo "PostgreSQL support: No" fi -echo +echo echo "CFLAGS: $CFLAGS" echo "LIBS: $LIBS" echo "LDFLAGS: $LDFLAGS" From 0dfdbec0ece097e01e4a4b637737c02e934f9536 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 17:49:34 +0300 Subject: [PATCH 031/233] Whitespace fix --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index ac8bb45..6cfaf4a 100755 --- a/configure +++ b/configure @@ -5923,7 +5923,7 @@ $as_echo_n "checking autodect pgsql libs... " >&6; } $as_echo "$PGSQL_LIBDIR" >&6; } elif test "${PGSQL_LIBS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 $as_echo_n "checking for pgsql libs... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 $as_echo "skipped" >&6; } From 7a55468d01548c8114633426e3b899513b216ce6 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 18:04:44 +0300 Subject: [PATCH 032/233] Whitespace fix --- ffmpeg.c | 10 ++--- netcam.c | 10 ++--- netcam_rtsp.c | 110 +++++++++++++++++++++++++------------------------- 3 files changed, 65 insertions(+), 65 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index afde3f4..6127542 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -14,7 +14,7 @@ #include "ffmpeg.h" #include "motion.h" - + #if LIBAVCODEC_BUILD > 4680 /* * FFmpeg after build 4680 doesn't have support for mpeg1 videos with @@ -154,8 +154,8 @@ URLProtocol mpeg1_file_protocol = { #endif // FF_API_NEW_AVIO /**************************************************************************** - * The section below is the "my" section of functions. - * These are designed to be extremely simple version specific + * The section below is the "my" section of functions. + * These are designed to be extremely simple version specific * variants of the libav functions. ****************************************************************************/ AVFrame *my_frame_alloc(void){ @@ -168,7 +168,7 @@ AVFrame *my_frame_alloc(void){ return pic; } -void my_frame_free(AVFrame *frame){ +void my_frame_free(AVFrame *frame){ #if (LIBAVFORMAT_VERSION_MAJOR >= 55) av_frame_free(&frame); #else @@ -423,7 +423,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, #if (LIBAVFORMAT_VERSION_MAJOR >= 53) c->codec_type = AVMEDIA_TYPE_VIDEO; #else - c->codec_type = CODEC_TYPE_VIDEO; + c->codec_type = CODEC_TYPE_VIDEO; #endif is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; diff --git a/netcam.c b/netcam.c index 781b4f4..ea8158c 100644 --- a/netcam.c +++ b/netcam.c @@ -2009,7 +2009,7 @@ static void *netcam_handler_loop(void *arg) */ } } - + if (netcam->caps.streaming == NCS_RTSP) { if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect if (netcam->rtsp->status == RTSP_CONNECTED){ @@ -2611,7 +2611,7 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) free(netcam->response); - if (netcam->caps.streaming == NCS_RTSP) + if (netcam->caps.streaming == NCS_RTSP) netcam_shutdown_rtsp(netcam); pthread_mutex_destroy(&netcam->mutex); @@ -2665,10 +2665,10 @@ int netcam_next(struct context *cnt, unsigned char *image) } if (netcam->caps.streaming == NCS_RTSP) { - + if (netcam->rtsp->status == RTSP_RECONNECTING) return NETCAM_NOTHING_NEW_ERROR; - + memcpy(image, netcam->latest->ptr, netcam->latest->used); return 0; } @@ -2912,7 +2912,7 @@ int netcam_start(struct context *cnt) " is not modulo 8", netcam->height); return -3; } - } + } /* Fill in camera details into context structure. */ cnt->imgs.width = netcam->width; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 67a4a6c..91c184a 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -1,20 +1,20 @@ /*********************************************************** - * In the top section are the functions that are used + * In the top section are the functions that are used * when processing the RTSP camera feed. Since these functions - * are internal to the RTSP module, and many require FFmpeg - * structures in their declarations, they are within the - * HAVE_FFMPEG block that eliminates them entirely when - * FFmpeg is not present. + * are internal to the RTSP module, and many require FFmpeg + * structures in their declarations, they are within the + * HAVE_FFMPEG block that eliminates them entirely when + * FFmpeg is not present. * - * The functions: + * The functions: * netcam_setup_rtsp * netcam_connect_rtsp * netcam_shutdown_rtsp - * are called from netcam.c therefore must be defined even - * if FFmpeg is not present. They must also not have FFmpeg + * are called from netcam.c therefore must be defined even + * if FFmpeg is not present. They must also not have FFmpeg * structures are in the declarations. Simple error * messages are raised if called when no FFmpeg is found. - * + * ***********************************************************/ #include @@ -39,7 +39,7 @@ * Returns: Nothing */ static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ - + int min_size_to_alloc; int real_alloc; int new_size; @@ -84,8 +84,8 @@ static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ int check = 0; int frame_size = 0; - int ret = 0; - + int ret = 0; + cc->err_recognition = 3; ret = avcodec_decode_video2(cc, frame, &check, packet); if (ret < 0) { @@ -98,11 +98,11 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram } frame_size = avpicture_get_size(cc->pix_fmt, cc->width, cc->height); - + netcam_buffsize_rtsp(buffer, frame_size); - + avpicture_layout((const AVPicture*)frame,cc->pix_fmt,cc->width,cc->height - ,(unsigned char *)buffer->ptr,frame_size ); + ,(unsigned char *)buffer->ptr,frame_size ); buffer->used = frame_size; @@ -130,14 +130,14 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV AVStream *st; AVCodecContext *dec_ctx = NULL; AVCodec *dec = NULL; - + ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); if (ret < 0) { av_strerror(ret, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream in input!: %s",errstr); return ret; - } - + } + *stream_idx = ret; st = fmt_ctx->streams[*stream_idx]; @@ -188,17 +188,17 @@ struct rtsp_context *rtsp_new_context(void){ * * This function is called during the FFmpeg blocking functions. * These include the opening of the format context as well as the -* reading of the packets from the stream. Since this is called +* reading of the packets from the stream. Since this is called * during all blocking functions, the process uses the readingframe * flag to determine whether to timeout the process. * * Parameters * -* ctx We pass in the rtsp context to use it to look for the -* readingframe flag as well as the time that we started +* ctx We pass in the rtsp context to use it to look for the +* readingframe flag as well as the time that we started * the read attempt. * -* Returns: +* Returns: * Failure -1(which triggers an interupt) * Success 0(zero which indicates to let process continue) * @@ -228,7 +228,7 @@ static int netcam_interrupt_rtsp(void *ctx){ /** * netcam_read_rtsp_image * -* This function reads the packet from the camera. +* This function reads the packet from the camera. * It is called extensively so only absolutely essential * functions and allocations are performed. * @@ -236,7 +236,7 @@ static int netcam_interrupt_rtsp(void *ctx){ * * netcam The netcam context to read from * -* Returns: +* Returns: * Failure -1 * Success 0(zero) * @@ -334,19 +334,19 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ * * Parameters * -* netcam The netcam context to open. +* netcam The netcam context to open. * -* Returns: +* Returns: * Failure -1 * Success 0(zero) * -*/ +*/ int netcam_connect_rtsp(netcam_context_ptr netcam){ #ifdef HAVE_FFMPEG - int ret; + int ret; char errstr[128]; - + if (netcam->rtsp->path == NULL) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); @@ -365,12 +365,12 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default if (netcam->rtsp->status == RTSP_NOTCONNECTED) MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using udp transport"); - } - + } + netcam->rtsp->format_context = avformat_alloc_context(); netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; - + ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); if (ret < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ @@ -378,9 +378,9 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); } av_dict_free(&opts); - //The format context gets freed upon any error from open_input. + //The format context gets freed upon any error from open_input. return ret; - } + } av_dict_free(&opts); // fill out stream information @@ -400,7 +400,7 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ av_strerror(ret, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); } - avformat_close_input(&netcam->rtsp->format_context); + avformat_close_input(&netcam->rtsp->format_context); return -1; } @@ -412,7 +412,7 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); } avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); + avformat_close_input(&netcam->rtsp->format_context); return -1; } @@ -425,13 +425,13 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ } my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); + avformat_close_input(&netcam->rtsp->format_context); return -1; } - - /* + + /* * Get an image from the feed, this serves - * two purposes. + * two purposes. * 1. Get the dimensions of the pic * 2. Validate that the previous steps opened the camera */ @@ -443,7 +443,7 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ } return -1; } - + netcam->width = netcam->rtsp->codec_context->width; netcam->height = netcam->rtsp->codec_context->height; @@ -452,7 +452,7 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Camera connected"); return 0; - + #else /* No FFmpeg/Libav */ netcam->rtsp->status = RTSP_NOTCONNECTED; netcam->rtsp->format_context = NULL; @@ -468,9 +468,9 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ * * Parameters * -* netcam The netcam context to free. +* netcam The netcam context to free. * -* Returns: +* Returns: * Failure nothing * Success nothing * @@ -482,17 +482,17 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ my_frame_free(netcam->rtsp->frame); avcodec_close(netcam->rtsp->codec_context); avformat_close_input(&netcam->rtsp->format_context); - + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); } - + if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); - + free(netcam->rtsp); netcam->rtsp = NULL; - + #else /* No FFmpeg/Libav */ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); #endif /* End #ifdef HAVE_FFMPEG */ @@ -501,15 +501,15 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ /** * netcam_setup_rtsp * -* This function sets up all the necessary items for the -* rtsp camera. +* This function sets up all the necessary items for the +* rtsp camera. * * Parameters * -* netcam The netcam context to free. +* netcam The netcam context to free. * url The URL of the camera * -* Returns: +* Returns: * Failure -1 * Success 0(zero) * @@ -562,7 +562,7 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ /* * Need a method to query the path and - * determine the authentication type + * determine the authentication type */ if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) @@ -587,7 +587,7 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ */ netcam->rtsp->readingframe = 0; netcam->rtsp->status = RTSP_NOTCONNECTED; - + av_register_all(); avformat_network_init(); @@ -603,7 +603,7 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->get_image = netcam_read_rtsp_image; return 0; - + #else /* No FFmpeg/Libav */ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); return -1; From 02ff96547480499ecfcc2ed7334b90592710ea27 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 18:06:47 +0300 Subject: [PATCH 033/233] Whitespace fix --- netcam_rtsp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netcam_rtsp.h b/netcam_rtsp.h index edff985..25055c6 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -24,7 +24,7 @@ struct rtsp_context { struct timeval startreadtime; #else /* Do not have FFmpeg */ - int* format_context; + int* format_context; int readingframe; int status; #endif /* end HAVE_FFMPEG */ From 646fb10b8b3244f083806f8abe8c4f7e971b8d4b Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 18:11:53 +0300 Subject: [PATCH 034/233] Whitespace fix --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a56fabf..2656c9e 100755 --- a/configure.ac +++ b/configure.ac @@ -202,7 +202,7 @@ fi AC_MSG_RESULT($PTHREAD_SUPPORT) else - echo + echo echo "You do not have threads support" echo fi From 8f4d2cc6fac4cc836995a05c0f11425dfbfde1da Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 18:14:58 +0300 Subject: [PATCH 035/233] Whitespace fix --- netcam_rtsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 91c184a..53221d7 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -68,7 +68,7 @@ static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ * decode_packet * * This routine takes in the packet from the read and decodes it into - * the frame. It then takes the frame and copies it into the netcam + * the frame. It then takes the frame and copies it into the netcam * buffer * * Parameters: @@ -153,7 +153,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV ret = avcodec_open2(dec_ctx, dec, NULL); if (ret < 0) { av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); return ret; } From 3aeaef7e262683974f56d522c64d1b1b57851c54 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 23 Jul 2014 18:18:25 +0300 Subject: [PATCH 036/233] Whitespace fix --- INSTALL | 1 - configure.ac | 1 - 2 files changed, 2 deletions(-) diff --git a/INSTALL b/INSTALL index aaf526e..65271b6 100644 --- a/INSTALL +++ b/INSTALL @@ -59,4 +59,3 @@ sudo zypper install libffmpeg-devel make install ************************* - diff --git a/configure.ac b/configure.ac index 2656c9e..e7342a6 100755 --- a/configure.ac +++ b/configure.ac @@ -1384,4 +1384,3 @@ echo "LDFLAGS: $LDFLAGS" echo echo "Install prefix: $prefix" echo - From de77c45abc57d3f629ce13f966f937384967dcec Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sun, 10 Aug 2014 20:47:11 -0700 Subject: [PATCH 037/233] RTSP rotate/resize/non YUV420/MJPEG. Now requires libswscale-dev --- .gitignore | 14 ++ CHANGELOG | 1 + INSTALL | 2 +- configure | 280 +++++++++++++-------------- configure.ac | 2 +- motion-dist.conf.in | 2 +- netcam.c | 46 +++-- netcam_rtsp.c | 457 ++++++++++++++++++++++++++++++++++++-------- netcam_rtsp.h | 6 + 9 files changed, 565 insertions(+), 245 deletions(-) diff --git a/.gitignore b/.gitignore index 9e38ca5..b730f6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,17 @@ *.log .svn/ *.o +.depend +motion +config.h +config.status +Makefile +motion-dist.conf +motion.init-Debian +motion.init-Fedora +motion.init-FreeBSD.sh +motion.spec +thread1.conf +thread2.conf +thread3.conf +thread4.conf diff --git a/CHANGELOG b/CHANGELOG index dd812db..5b3d285 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -82,6 +82,7 @@ Features * Add gray image upon disconnection * Added tcp/udp transport config option from hyperbolic(commit 423ef7bb3) * Revised comments to be in line with application standard. + * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/INSTALL b/INSTALL index 65271b6..8773bff 100644 --- a/INSTALL +++ b/INSTALL @@ -28,7 +28,7 @@ Optional: With FFMPEG support: ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " With LIBAV APT versions of libraries - sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools + sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools libswscale-dev Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat ./configure diff --git a/configure b/configure index 6cfaf4a..d6d7ee5 100755 --- a/configure +++ b/configure @@ -1,9 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for motion trunkREVUNKNOWN. +# Generated by GNU Autoconf 2.68 for motion trunkREVUNKNOWN. # # -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -132,31 +134,6 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -190,8 +167,7 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" +test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -236,25 +212,21 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -356,14 +328,6 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -485,10 +449,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -523,16 +483,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -544,8 +504,28 @@ else as_mkdir_p=false fi -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -1161,6 +1141,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1458,9 +1440,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF motion configure trunkREVUNKNOWN -generated by GNU Autoconf 2.69 +generated by GNU Autoconf 2.68 -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1733,7 +1715,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - test -x conftest$ac_exeext + $as_test_x conftest$ac_exeext }; then : ac_retval=0 else @@ -1890,8 +1872,7 @@ int main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1907,8 +1888,7 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1934,8 +1914,7 @@ int main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1951,8 +1930,7 @@ int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -1986,8 +1964,7 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; +test_array [0] = 0 ; return 0; @@ -2060,7 +2037,7 @@ 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 trunkREVUNKNOWN, which was -generated by GNU Autoconf 2.69. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2429,7 +2406,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2469,7 +2446,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2522,7 +2499,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2563,7 +2540,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2621,7 +2598,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2665,7 +2642,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3111,7 +3088,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3351,7 +3329,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3417,7 +3395,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3624,8 +3602,8 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -3681,7 +3659,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3721,7 +3699,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3774,7 +3752,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3815,7 +3793,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3873,7 +3851,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3917,7 +3895,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4113,7 +4091,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4305,7 +4284,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4345,7 +4324,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4398,7 +4377,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4439,7 +4418,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -4497,7 +4476,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4541,7 +4520,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4737,7 +4716,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4853,7 +4833,7 @@ fi if test "${BKTR}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" fi else @@ -4887,10 +4867,10 @@ $as_echo_n "checking for linuxthreads... " >&6; } # Check for thread header # if test -f "${THREAD_CHECK}"; then - HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" - THREADS="yes" + HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" + THREADS="yes" else - THREADS="no" + THREADS="no" fi # @@ -4900,7 +4880,7 @@ $as_echo_n "checking for linuxthreads... " >&6; } THREADS="yes" LIB_THREAD="-llthread -llgcc_r" else - THREADS="no" + THREADS="no" fi # Checks for Library linuxthreads for FreeBSD @@ -5305,7 +5285,7 @@ fi # # ffmpeg custom extra libraries # -FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz " +FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " # Check whether --with-ffmpeg-libs was given. if test "${with_ffmpeg_libs+set}" = set; then : @@ -5683,8 +5663,8 @@ $as_echo "skipped" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers in $MYSQL_HEADERS" >&5 $as_echo_n "checking for mysql headers in $MYSQL_HEADERS... " >&6; } # Manual detection for - if test -f $MYSQL_HEADERS/mysql.h; then - MYSQL_INCDIR=$MYSQL_HEADERS + if test -f $MYSQL_HEADERS/mysql.h; then + MYSQL_INCDIR=$MYSQL_HEADERS fi fi @@ -5706,7 +5686,7 @@ $as_echo "$MYSQL_INCDIR yes" >&6; } if test "${MYSQL_LIBS}" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql libs" >&5 $as_echo_n "checking autodect mysql libs... " >&6; } - # Autodetect + # Autodetect for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do # check for plain setups if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then @@ -5725,7 +5705,7 @@ $as_echo_n "checking autodect mysql libs... " >&6; } fi done elif test "${MYSQL_LIBS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 $as_echo_n "checking for mysql libs... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 $as_echo "skipped" >&6; } @@ -5880,8 +5860,8 @@ $as_echo "skipped" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers in $PGSQL_HEADERS" >&5 $as_echo_n "checking for pgsql headers in $PGSQL_HEADERS... " >&6; } # Manual detection for - if test -f $PGSQL_HEADERS/libpq-fe.h; then - PGSQL_INCDIR=$PGSQL_HEADERS + if test -f $PGSQL_HEADERS/libpq-fe.h; then + PGSQL_INCDIR=$PGSQL_HEADERS fi fi @@ -6452,11 +6432,11 @@ else int main () { - +/* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ + /* Ultrix mips cc rejects this. */ typedef int charset[2]; - const charset cs = { 0, 0 }; + const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -6473,9 +6453,8 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this sort of thing. */ - char tx; - char *t = &tx; + { /* SCO 3.2v4 cc rejects this. */ + char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -6491,10 +6470,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; b->j = 5; + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -7217,16 +7196,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -7286,16 +7265,28 @@ else as_mkdir_p=false fi - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -7317,7 +7308,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by motion $as_me trunkREVUNKNOWN, which was -generated by GNU Autoconf 2.69. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -7379,10 +7370,10 @@ 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 trunkREVUNKNOWN -configured by $0, generated by GNU Autoconf 2.69, +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -7470,7 +7461,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -8194,4 +8185,3 @@ echo "LDFLAGS: $LDFLAGS" echo echo "Install prefix: $prefix" echo - diff --git a/configure.ac b/configure.ac index e7342a6..a92e8b8 100755 --- a/configure.ac +++ b/configure.ac @@ -403,7 +403,7 @@ FFMPEG_HEADERS_DIR="$withval" # # ffmpeg custom extra libraries # -FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz " +FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " AC_ARG_WITH(ffmpeg-libs, [ --with-ffmpeg-libs[=libs] Specify the extra libs for ffmpeg ], diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 5e3dbe3..51f4221 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -101,7 +101,7 @@ framerate 2 # This option is used when you want to capture images at a rate lower than 2 per second. minimum_frame_time 0 -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// or file:///) +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ; netcam_url value diff --git a/netcam.c b/netcam.c index ea8158c..3c2b481 100644 --- a/netcam.c +++ b/netcam.c @@ -148,7 +148,7 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) char *s; int i; - const char *re = "(http|ftp|mjpg|rtsp)://(((.*):(.*))@)?" + const char *re = "(http|ftp|mjpg|mjpeg|rtsp)://(((.*):(.*))@)?" "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; regex_t pattbuf; regmatch_t matches[10]; @@ -1262,7 +1262,7 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) * module netcam_wget.c to do this job! */ - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Potential split boundary - " "%d chars flushed, %d " "re-positioned", ix, @@ -2669,7 +2669,9 @@ int netcam_next(struct context *cnt, unsigned char *image) if (netcam->rtsp->status == RTSP_RECONNECTING) return NETCAM_NOTHING_NEW_ERROR; - memcpy(image, netcam->latest->ptr, netcam->latest->used); + if (netcam_next_rtsp(image , netcam) < 0) + return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; + return 0; } @@ -2850,6 +2852,12 @@ int netcam_start(struct context *cnt) strcpy(url.service, "http"); /* Put back a real URL service. */ retval = netcam_setup_mjpg(netcam, &url); + } else if ((url.service) && (!strcmp(url.service, "mjpeg"))) { + MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" + " netcam_setup_mjpeg()"); + + strcpy(url.service, "http"); /* Put back a real URL service. */ + retval = netcam_setup_rtsp(netcam, &url); } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" " netcam_setup_rtsp()"); @@ -2857,7 +2865,7 @@ int netcam_start(struct context *cnt) retval = netcam_setup_rtsp(netcam, &url); } else { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam service '%s' - " - "must be http, ftp, mjpg or file.", url.service); + "must be http, ftp, mjpg, mjpeg or file.", url.service); netcam_url_free(&url); return -1; } @@ -2896,23 +2904,23 @@ int netcam_start(struct context *cnt) netcam->netcam_tolerant_check = cnt->conf.netcam_tolerant_check; netcam->JFIF_marker = 0; netcam_get_dimensions(netcam); + } + /* + * Motion currently requires that image height and width is a + * multiple of 16. So we check for this. + */ + if (netcam->width % 8) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" + " is not modulo 8", netcam->width); + return -3; + } - /* - * Motion currently requires that image height and width is a - * multiple of 16. So we check for this. - */ - if (netcam->width % 8) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" - " is not modulo 8", netcam->width); - return -3; - } - - if (netcam->height % 8) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" - " is not modulo 8", netcam->height); - return -3; - } + if (netcam->height % 8) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" + " is not modulo 8", netcam->height); + return -3; } + /* Fill in camera details into context structure. */ cnt->imgs.width = netcam->width; diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 53221d7..4e5a55f 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -10,21 +10,70 @@ * netcam_setup_rtsp * netcam_connect_rtsp * netcam_shutdown_rtsp + * netcam_next_rtsp * are called from netcam.c therefore must be defined even * if FFmpeg is not present. They must also not have FFmpeg - * structures are in the declarations. Simple error + * structures in the declarations. Simple error * messages are raised if called when no FFmpeg is found. * ***********************************************************/ #include #include "netcam_rtsp.h" -#include "motion.h" +#include "rotate.h" /* already includes motion.h */ #ifdef HAVE_FFMPEG #include "ffmpeg.h" +/** + * netcam_check_pixfmt + * + * Determine whether pix_format is YUV420P + */ +int netcam_check_pixfmt(netcam_context_ptr netcam){ + int retcd; + + retcd = -1; + + if ((netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUV420P) || + (netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUVJ420P)) retcd = 0; + + return retcd; + +} +/** + * netcam_rtsp_null_context + * + * Null all the context + */ +void netcam_rtsp_null_context(netcam_context_ptr netcam){ + + netcam->rtsp->swsctx = NULL; + netcam->rtsp->swsframe_in = NULL; + netcam->rtsp->swsframe_out = NULL; + netcam->rtsp->frame = NULL; + netcam->rtsp->codec_context = NULL; + netcam->rtsp->format_context = NULL; + +} +/** + * netcam_rtsp_close_context + * + * Close all the context that could be open + */ +void netcam_rtsp_close_context(netcam_context_ptr netcam){ + + if (netcam->rtsp->swsctx != NULL) sws_freeContext(netcam->rtsp->swsctx); + if (netcam->rtsp->swsframe_in != NULL) my_frame_free(netcam->rtsp->swsframe_in); + if (netcam->rtsp->swsframe_out != NULL) my_frame_free(netcam->rtsp->swsframe_out); + if (netcam->rtsp->frame != NULL) my_frame_free(netcam->rtsp->frame); + if (netcam->rtsp->codec_context != NULL) avcodec_close(netcam->rtsp->codec_context); + if (netcam->rtsp->format_context != NULL) avformat_close_input(&netcam->rtsp->format_context); + + netcam_rtsp_null_context(netcam); +} + /** * netcam_buffsize_rtsp * @@ -86,7 +135,6 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram int frame_size = 0; int ret = 0; - cc->err_recognition = 3; ret = avcodec_decode_video2(cc, frame, &check, packet); if (ret < 0) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); @@ -110,7 +158,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram } /** - * open_codec_context + * netcam_open_codec * * This routine opens the codec context for the indicated stream * @@ -124,7 +172,7 @@ static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *fram * Failure Error code from FFmpeg (Negative number) * Success 0(Zero) */ -static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ +static int netcam_open_codec(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ int ret; char errstr[128]; AVStream *st; @@ -153,7 +201,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV ret = avcodec_open2(dec_ctx, dec, NULL); if (ret < 0) { av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); return ret; } @@ -182,7 +230,6 @@ struct rtsp_context *rtsp_new_context(void){ return ret; } - /** * netcam_interrupt_rtsp * @@ -224,7 +271,6 @@ static int netcam_interrupt_rtsp(void *ctx){ //should not be possible to get here return 0; } - /** * netcam_read_rtsp_image * @@ -246,7 +292,6 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ netcam_buff_ptr buffer; AVPacket packet; int size_decoded; - static int usual_size_decoded; /* Point to our working buffer. */ buffer = netcam->receiving; @@ -257,7 +302,6 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ packet.size = 0; size_decoded = 0; - usual_size_decoded = 0; if (gettimeofday(&curtime, NULL) < 0) { MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); @@ -288,20 +332,10 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ if (size_decoded == 0) { // something went wrong, end of stream? Interupted? - my_frame_free(netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); + netcam_rtsp_close_context(netcam); return -1; } - if (size_decoded != usual_size_decoded) { - if (usual_size_decoded !=0) { - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: unusual frame size of %d!", size_decoded); - } - usual_size_decoded = size_decoded; - } - - /* * read is complete - set the current 'receiving' buffer atomically * as 'latest', and make the buffer previously in 'latest' become @@ -321,30 +355,77 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ return 0; } +/** +* netcam_rtsp_resize_ntc +* +* This function notifies the user of the need to transcode +* the netcam image which uses a lot of CPU resources +* +* Parameters +* +* netcam The netcam context to read from +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ +int netcam_rtsp_resize_ntc(netcam_context_ptr netcam){ + + if ((netcam->width != netcam->rtsp->codec_context->width) || + (netcam->height != netcam->rtsp->codec_context->height) || + (netcam_check_pixfmt(netcam) != 0) ){ + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: "); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: ****************************************************************"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: The network camera is sending pictures in a different"); + if ((netcam->width != netcam->rtsp->codec_context->width) || + (netcam->height != netcam->rtsp->codec_context->height)) { + if (netcam_check_pixfmt(netcam) != 0) { + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: size than specified in the config and also a "); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: different picture format. The picture is being"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: transcoded to YUV420P and into the size requested"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: in the config file. If possible change netcam to"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: be in YUV420P format and the size requested in the"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: config to possibly lower CPU usage."); + } else { + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: size than specified in the configuration file."); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: The picture is being transcoded into the size "); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: requested in the configuration. If possible change"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: netcam or configuration to indicate the same size"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: to possibly lower CPU usage."); + } + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Netcam: %d x %d => Config: %d x %d" + ,netcam->rtsp->codec_context->width,netcam->rtsp->codec_context->height + ,netcam->width,netcam->height); + } else { + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: format than YUV420P. The image sent is being "); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: trancoded to YUV420P. If possible change netcam "); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: picture format to YUV420P to possibly lower CPU usage."); + } + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: ****************************************************************"); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: "); + } -/*********************************************************** - * This ends the section of functions that rely upon FFmpeg - ***********************************************************/ -#endif /* End HAVE_FFMPEG */ + return 0; +} /** -* netcam_connect_rtsp +* netcam_rtsp_open_context * -* This function initiates the connection to the rtsp camera. +* This function opens the format context for the camera. * * Parameters * -* netcam The netcam context to open. +* netcam The netcam context to read from * * Returns: * Failure -1 * Success 0(zero) * */ -int netcam_connect_rtsp(netcam_context_ptr netcam){ -#ifdef HAVE_FFMPEG +int netcam_rtsp_open_context(netcam_context_ptr netcam){ - int ret; + int retcd; char errstr[128]; if (netcam->rtsp->path == NULL) { @@ -356,51 +437,55 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ // open the network connection AVDictionary *opts = 0; - if (netcam->cnt->conf.rtsp_uses_tcp) { - av_dict_set(&opts, "rtsp_transport", "tcp", 0); - if (netcam->rtsp->status == RTSP_NOTCONNECTED) - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using tcp transport"); - } else { - av_dict_set(&opts, "rtsp_transport", "udp", 0); - av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default - if (netcam->rtsp->status == RTSP_NOTCONNECTED) - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using udp transport"); - } - netcam->rtsp->format_context = avformat_alloc_context(); netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; - ret = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); - if (ret < 0) { + if (strncmp(netcam->rtsp->path, "http", 4) == 0 ){ + netcam->rtsp->format_context->iformat = av_find_input_format("mjpeg"); + } else { + if (netcam->cnt->conf.rtsp_uses_tcp) { + av_dict_set(&opts, "rtsp_transport", "tcp", 0); + if (netcam->rtsp->status == RTSP_NOTCONNECTED) + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using tcp transport"); + } else { + av_dict_set(&opts, "rtsp_transport", "udp", 0); + av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default + if (netcam->rtsp->status == RTSP_NOTCONNECTED) + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using udp transport"); + } + } + + retcd = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); + if (retcd < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ - av_strerror(ret, errstr, sizeof(errstr)); + av_strerror(retcd, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); } av_dict_free(&opts); //The format context gets freed upon any error from open_input. - return ret; + return retcd; } av_dict_free(&opts); // fill out stream information - ret = avformat_find_stream_info(netcam->rtsp->format_context, NULL); - if (ret < 0) { + retcd = avformat_find_stream_info(netcam->rtsp->format_context, NULL); + if (retcd < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ - av_strerror(ret, errstr, sizeof(errstr)); + av_strerror(retcd, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %s", errstr); } - avformat_close_input(&netcam->rtsp->format_context); + netcam_rtsp_close_context(netcam); return -1; } - ret = open_codec_context(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); - if (ret < 0) { + retcd = netcam_open_codec(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); + if (retcd < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ - av_strerror(ret, errstr, sizeof(errstr)); + av_strerror(retcd, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); } - avformat_close_input(&netcam->rtsp->format_context); + netcam_rtsp_close_context(netcam); return -1; } @@ -411,41 +496,219 @@ int netcam_connect_rtsp(netcam_context_ptr netcam){ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); } - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); + netcam_rtsp_close_context(netcam); return -1; } - // start up the feed - ret = av_read_play(netcam->rtsp->format_context); - if (ret < 0) { + /* + * Validate that the previous steps opened the camera + */ + retcd = netcam_read_rtsp_image(netcam); + if (retcd < 0) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first image"); + } + netcam_rtsp_close_context(netcam); + return -1; + } + + return 0; + +} +/** +* netcam_rtsp_open_sws +* +* This function opens the rescaling context components. +* +* Parameters +* +* netcam The netcam context to read from +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ +int netcam_rtsp_open_sws(netcam_context_ptr netcam){ + + netcam->width = ((netcam->cnt->conf.width / 8) * 8); + netcam->height = ((netcam->cnt->conf.height / 8) * 8); + + + netcam->rtsp->swsframe_in = my_frame_alloc(); + if (netcam->rtsp->swsframe_in == NULL) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); + } + netcam_rtsp_close_context(netcam); + return -1; + } + + netcam->rtsp->swsframe_out = my_frame_alloc(); + if (netcam->rtsp->swsframe_out == NULL) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ - av_strerror(ret, errstr, sizeof(errstr)); - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open the camera: %s", errstr); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); } - my_frame_free(netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); + netcam_rtsp_close_context(netcam); return -1; } /* - * Get an image from the feed, this serves - * two purposes. - * 1. Get the dimensions of the pic - * 2. Validate that the previous steps opened the camera + * The scaling context is used to change dimensions to config file and + * also if the format sent by the camera is not YUV420. */ + netcam->rtsp->swsctx = sws_getContext( + netcam->rtsp->codec_context->width + ,netcam->rtsp->codec_context->height + ,netcam->rtsp->codec_context->pix_fmt + ,netcam->width + ,netcam->height + ,PIX_FMT_YUV420P + ,SWS_BICUBIC,NULL,NULL,NULL); + if (netcam->rtsp->swsctx == NULL) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate scaling context. Fatal error. Check FFmpeg/Libav configuration"); + } + netcam_rtsp_close_context(netcam); + return -1; + } - ret = netcam_read_rtsp_image(netcam); - if (ret < 0) { + netcam->rtsp->swsframe_size = avpicture_get_size( + PIX_FMT_YUV420P + ,netcam->width + ,netcam->height); + if (netcam->rtsp->swsframe_size <= 0) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error determining size of frame out"); + } + netcam_rtsp_close_context(netcam); + return -1; + } + + return 0; + +} +/** +* netcam_rtsp_resize +* +* This function reencodes the image to yuv420p with the desired size +* +* Parameters +* +* netcam The netcam context to read from +* image The destination image. +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ +int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ + + int retcd; + char errstr[128]; + uint8_t *buffer_out; + + retcd = avpicture_fill( + (AVPicture*)netcam->rtsp->swsframe_in + ,(uint8_t*)netcam->latest->ptr + ,netcam->rtsp->codec_context->pix_fmt + ,netcam->rtsp->codec_context->width + ,netcam->rtsp->codec_context->height); + if (retcd < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ - MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first image"); + av_strerror(retcd, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error allocating picture in: %s", errstr); + } + netcam_rtsp_close_context(netcam); + return -1; + } + + + buffer_out=(uint8_t *)av_malloc(netcam->rtsp->swsframe_size*sizeof(uint8_t)); + + retcd = avpicture_fill( + (AVPicture*)netcam->rtsp->swsframe_out + ,buffer_out + ,PIX_FMT_YUV420P + ,netcam->width + ,netcam->height); + if (retcd < 0) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(retcd, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error allocating picture out: %s", errstr); + } + netcam_rtsp_close_context(netcam); + return -1; + } + + retcd = sws_scale( + netcam->rtsp->swsctx + ,(const uint8_t* const *)netcam->rtsp->swsframe_in->data + ,netcam->rtsp->swsframe_in->linesize + ,0 + ,netcam->rtsp->codec_context->height + ,netcam->rtsp->swsframe_out->data + ,netcam->rtsp->swsframe_out->linesize); + if (retcd < 0) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(retcd, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error resizing/reformatting: %s", errstr); + } + netcam_rtsp_close_context(netcam); + return -1; + } + + retcd = avpicture_layout( + (const AVPicture*)netcam->rtsp->swsframe_out + ,PIX_FMT_YUV420P + ,netcam->width + ,netcam->height + ,(unsigned char *)image + ,netcam->rtsp->swsframe_size ); + if (retcd < 0) { + if (netcam->rtsp->status == RTSP_NOTCONNECTED){ + av_strerror(retcd, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error putting frame into output buffer: %s", errstr); } + netcam_rtsp_close_context(netcam); return -1; } - netcam->width = netcam->rtsp->codec_context->width; - netcam->height = netcam->rtsp->codec_context->height; + av_free(buffer_out); + + return 0; + +} +/********************************************************* + * This ends the section of functions that rely upon FFmpeg + ***********************************************************/ +#endif /* End HAVE_FFMPEG */ + +/** +* netcam_connect_rtsp +* +* This function initiates the connection to the rtsp camera. +* +* Parameters +* +* netcam The netcam context to open. +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ +int netcam_connect_rtsp(netcam_context_ptr netcam){ +#ifdef HAVE_FFMPEG + + if (netcam_rtsp_open_context(netcam) < 0) return -1; + + if (netcam_rtsp_open_sws(netcam) < 0) return -1; + + if (netcam_rtsp_resize_ntc(netcam) < 0 ) return -1; + + if (netcam_read_rtsp_image(netcam) < 0) return -1; netcam->rtsp->status = RTSP_CONNECTED; @@ -479,11 +742,8 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ #ifdef HAVE_FFMPEG if (netcam->rtsp->status == RTSP_CONNECTED) { - my_frame_free(netcam->rtsp->frame); - avcodec_close(netcam->rtsp->codec_context); - avformat_close_input(&netcam->rtsp->format_context); - - MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: rtsp shut down"); + netcam_rtsp_close_context(netcam); + MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: netcam shut down"); } if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); @@ -525,6 +785,8 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->rtsp = rtsp_new_context(); + netcam_rtsp_null_context(netcam); + if (netcam->rtsp == NULL) { MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); netcam_shutdown_rtsp(netcam); @@ -590,6 +852,7 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ av_register_all(); avformat_network_init(); + avcodec_register_all(); /* * The RTSP context should be all ready to attempt a connection with @@ -609,3 +872,41 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ return -1; #endif /* End #ifdef HAVE_FFMPEG */ } + +/** +* netcam_next_rtsp +* +* This function moves the picture to the image buffer. +* If the picture is not in the correct format for size +* it will put it into the requested format +* +* Parameters +* +* netcam The netcam context to free. +* url The URL of the camera +* +* Returns: +* Failure -1 +* Success 0(zero) +* +*/ +int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam){ +#ifdef HAVE_FFMPEG + + if ((netcam->width != netcam->rtsp->codec_context->width) || + (netcam->height != netcam->rtsp->codec_context->height) || + (netcam_check_pixfmt(netcam) != 0) ){ + netcam_rtsp_resize(image ,netcam); + } else { + memcpy(image, netcam->latest->ptr, netcam->latest->used); + } + if (netcam->cnt->rotate_data.degrees > 0) + /* Rotate as specified */ + rotate_map(netcam->cnt, image); + + return 0; +#else /* No FFmpeg/Libav */ + MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); + return -1; +#endif /* End #ifdef HAVE_FFMPEG */ +} diff --git a/netcam_rtsp.h b/netcam_rtsp.h index 25055c6..a09d295 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -7,6 +7,7 @@ #include #include #include +#include #endif /* end HAVE_FFMPEG */ @@ -15,6 +16,9 @@ struct rtsp_context { AVFormatContext* format_context; AVCodecContext* codec_context; AVFrame* frame; + AVFrame* swsframe_in; + AVFrame* swsframe_out; + int swsframe_size; int video_stream_index; char* path; char* user; @@ -22,6 +26,7 @@ struct rtsp_context { int readingframe; int status; struct timeval startreadtime; + struct SwsContext* swsctx; #else /* Do not have FFmpeg */ int* format_context; @@ -35,3 +40,4 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam); int netcam_connect_rtsp(netcam_context_ptr netcam); int netcam_read_rtsp_image(netcam_context_ptr netcam); int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); +int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam); From 815923d8bba2d9c107e2ba84a6009fdb3a2f3203 Mon Sep 17 00:00:00 2001 From: MrDave Date: Wed, 3 Sep 2014 21:59:18 -0700 Subject: [PATCH 038/233] Add git commit number to version number --- version.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/version.sh b/version.sh index 68dc73e..5963498 100755 --- a/version.sh +++ b/version.sh @@ -3,4 +3,6 @@ SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` test $SNV_VERSION || SNV_VERSION=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` test $SNV_VERSION || SNV_VERSION=UNKNOWN -echo -n "trunkREV$SNV_VERSION" +SNV_VERSION=`git show -s --format=%h` +echo -n "3.2.12-Git-$SNV_VERSION" + From fbabd5d5fb00789931508a54ef8b8e605132b0e3 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sat, 6 Sep 2014 07:48:36 -0700 Subject: [PATCH 039/233] Rollback memset to allow for formal pull. --- CHANGELOG | 7 ++++--- alg.c | 4 ++-- motion.c | 24 ++++++------------------ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5b3d285..0b354c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,7 +53,6 @@ Features * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) * Buffer overflow vulnerabilities (hyperbolic2346) * Redundand -- boundary prefix (torao) - * Proper size for memset and allocation size (Alfred Klomp) * Removed compiler warnings: (Mr-Dave) logger.c,jpegutils.c,netcam_ftp.c,track.c, picture.c,webhttpd.c,stream.c,ffmpeg.c @@ -63,7 +62,7 @@ Features * Resolve additional compiler warnings in ffmpeg (Mr-Dave) * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) - * Plugged most(?) memory leaks in RTSP. (Mr-Dave) + * Plugged most memory leaks in RTSP. (Mr-Dave) * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) * Regession fix for memory leaks and reconnection (Mr-Dave) @@ -80,9 +79,11 @@ Features * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. * Implement inits of AV functions from bcl fork * Add gray image upon disconnection - * Added tcp/udp transport config option from hyperbolic(commit 423ef7bb3) + * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) * Revised comments to be in line with application standard. * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format + * Revise version.sh to put out the git commit. + * Rollback revision to allow for a formal pull request. Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/alg.c b/alg.c index 343ff47..93c260f 100644 --- a/alg.c +++ b/alg.c @@ -534,7 +534,7 @@ static int alg_labeling(struct context *cnt) imgs->labels_above = 0; /* Init: 0 means no label set / not checked. */ - memset(labels, 0, width * height * sizeof(*labels)); + memset(labels, 0, width * height * sizeof(labels)); pixelpos = 0; for (iy = 0; iy < height - 1; iy++) { @@ -1363,6 +1363,6 @@ void alg_update_reference_frame(struct context *cnt, int action) /* Copy fresh image */ memcpy(cnt->imgs.ref, cnt->imgs.image_virgin, cnt->imgs.size); /* Reset static objects */ - memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); + memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); } } diff --git a/motion.c b/motion.c index fc48e64..5666770 100644 --- a/motion.c +++ b/motion.c @@ -723,13 +723,13 @@ static int motion_init(struct context *cnt) memset(cnt->imgs.out, 0, cnt->imgs.size); /* contains the moving objects of ref. frame */ - cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); + cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); cnt->imgs.image_virgin = mymalloc(cnt->imgs.size); cnt->imgs.smartmask = mymalloc(cnt->imgs.motionsize); cnt->imgs.smartmask_final = mymalloc(cnt->imgs.motionsize); - cnt->imgs.smartmask_buffer = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.smartmask_buffer)); - cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.labels)); - cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(*cnt->imgs.labelsize)); + cnt->imgs.smartmask_buffer = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.smartmask_buffer)); + cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.labels)); + cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(cnt->imgs.labelsize)); /* Set output picture type */ if (!strcmp(cnt->conf.picture_type, "ppm")) @@ -917,7 +917,7 @@ static int motion_init(struct context *cnt) /* Always initialize smart_mask - someone could turn it on later... */ memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); memset(cnt->imgs.smartmask_final, 255, cnt->imgs.motionsize); - memset(cnt->imgs.smartmask_buffer, 0, cnt->imgs.motionsize * sizeof(*cnt->imgs.smartmask_buffer)); + memset(cnt->imgs.smartmask_buffer, 0, cnt->imgs.motionsize*sizeof(cnt->imgs.smartmask_buffer)); /* Set noise level */ cnt->noise = cnt->conf.noise; @@ -1294,7 +1294,7 @@ static void *motion_loop(void *arg) cnt->current_image->timestamp_tm = old_image->timestamp_tm; cnt->current_image->shot = old_image->shot; cnt->current_image->cent_dist = old_image->cent_dist; - cnt->current_image->flags = old_image->flags & (~IMAGE_SAVED); + cnt->current_image->flags = old_image->flags; cnt->current_image->location = old_image->location; cnt->current_image->total_labels = old_image->total_labels; } @@ -2714,12 +2714,8 @@ int main (int argc, char **argv) cnt_list[i]->threadnr = i ? i : 1; if (strcmp(cnt_list[i]->conf_filename, "")) - { - cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", cnt_list[i]->threadnr, cnt_list[i]->conf_filename); - } MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? @@ -3204,14 +3200,6 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us ++pos_userformat; break; - case 'w': // picture width - sprintf(tempstr, "%d", cnt->imgs.width); - break; - - case 'h': // picture height - sprintf(tempstr, "%d", cnt->imgs.height); - break; - case 'f': // filename -- or %fps if ((*(pos_userformat+1) == 'p') && (*(pos_userformat+2) == 's')) { sprintf(tempstr, "%d", cnt->movie_fps); From a86905737472a6c66bbb624ca13283aa5d58c85d Mon Sep 17 00:00:00 2001 From: MrDave Date: Sat, 6 Sep 2014 08:51:43 -0700 Subject: [PATCH 040/233] Recommit changes from tosiara commit 9ebee031 --- CHANGELOG | 1 + motion.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0b354c4..ddcb585 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -84,6 +84,7 @@ Features * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format * Revise version.sh to put out the git commit. * Rollback revision to allow for a formal pull request. + * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/motion.c b/motion.c index 5666770..ceaa44d 100644 --- a/motion.c +++ b/motion.c @@ -1294,7 +1294,7 @@ static void *motion_loop(void *arg) cnt->current_image->timestamp_tm = old_image->timestamp_tm; cnt->current_image->shot = old_image->shot; cnt->current_image->cent_dist = old_image->cent_dist; - cnt->current_image->flags = old_image->flags; + cnt->current_image->flags = old_image->flags & (~IMAGE_SAVED); cnt->current_image->location = old_image->location; cnt->current_image->total_labels = old_image->total_labels; } @@ -2714,8 +2714,12 @@ int main (int argc, char **argv) cnt_list[i]->threadnr = i ? i : 1; if (strcmp(cnt_list[i]->conf_filename, "")) + { + cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", cnt_list[i]->threadnr, cnt_list[i]->conf_filename); + } MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? @@ -3200,6 +3204,14 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us ++pos_userformat; break; + case 'w': // picture width + sprintf(tempstr, "%d", cnt->imgs.width); + break; + + case 'h': // picture height + sprintf(tempstr, "%d", cnt->imgs.height); + break; + case 'f': // filename -- or %fps if ((*(pos_userformat+1) == 'p') && (*(pos_userformat+2) == 's')) { sprintf(tempstr, "%d", cnt->movie_fps); From bd730643efb6caad916c7b6ea135579790041bb8 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sat, 6 Sep 2014 09:39:55 -0700 Subject: [PATCH 041/233] Implement modulo 16 for netcams to avoid seg fault in stream --- CHANGELOG | 1 + netcam.c | 8 ++++---- netcam_rtsp.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ddcb585..94e8fb3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -85,6 +85,7 @@ Features * Revise version.sh to put out the git commit. * Rollback revision to allow for a formal pull request. * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 + * Implement requirement of modulo 16 to avoid seg fault when opening stream Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/netcam.c b/netcam.c index 3c2b481..700009f 100644 --- a/netcam.c +++ b/netcam.c @@ -2909,15 +2909,15 @@ int netcam_start(struct context *cnt) * Motion currently requires that image height and width is a * multiple of 16. So we check for this. */ - if (netcam->width % 8) { + if (netcam->width % 16) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" - " is not modulo 8", netcam->width); + " is not modulo 16", netcam->width); return -3; } - if (netcam->height % 8) { + if (netcam->height % 16) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" - " is not modulo 8", netcam->height); + " is not modulo 16", netcam->height); return -3; } diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 4e5a55f..1c90a81 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -850,6 +850,20 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->rtsp->readingframe = 0; netcam->rtsp->status = RTSP_NOTCONNECTED; + /* + * Warn and fix dimensions as needed. + */ + if (netcam->cnt->conf.width % 16) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image width (%d) requested is not modulo 16.", netcam->cnt->conf.width); + netcam->cnt->conf.width = netcam->cnt->conf.width - (netcam->cnt->conf.width % 16) + 16; + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting width to next higher multiple of 16 (%d).", netcam->cnt->conf.width); + } + if (netcam->cnt->conf.height % 16) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image height (%d) requested is not modulo 16.", netcam->cnt->conf.height); + netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 16) + 16; + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 16 (%d).", netcam->cnt->conf.height); + } + av_register_all(); avformat_network_init(); avcodec_register_all(); From 7d5537c2ae2709f2a7044a50c6b2c570a1184ec6 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 6 Sep 2014 14:03:03 -0700 Subject: [PATCH 042/233] Add debian packaging files from 14.04. --- CHANGELOG | 1 + debian/NEWS | 7 + debian/README.Debian | 12 + debian/changelog | 539 ++++++++++++++++ debian/compat | 1 + debian/control | 31 + debian/copyright | 14 + debian/dirs | 6 + debian/docs | 5 + debian/init.d | 111 ++++ debian/motion.1 | 821 ++++++++++++++++++++++++ debian/motion.conf | 598 +++++++++++++++++ debian/motion.config | 12 + debian/motion.default | 3 + debian/motion.postinst | 44 ++ debian/motion.postinst.save | 53 ++ debian/motion.templates | 11 + debian/patches/01_videodev.h.diff | 27 + debian/patches/020101107~5273773.patch | 95 +++ debian/patches/020111022~58627b0.patch | 141 ++++ debian/patches/020111022~734155f.patch | 35 + debian/patches/020111027~5dd9ed4.patch | 68 ++ debian/patches/020120717~0fb31d.patch | 0 debian/patches/02_libav_multiarch.patch | 20 + debian/patches/copy-old-api.patch | 76 +++ debian/patches/series | 8 + debian/patches/use-new-api.patch | 165 +++++ debian/po/POTFILES.in | 1 + debian/po/cs.po | 55 ++ debian/po/da.po | 61 ++ debian/po/de.po | 58 ++ debian/po/es.po | 78 +++ debian/po/fr.po | 56 ++ debian/po/gl.po | 48 ++ debian/po/it.po | 51 ++ debian/po/ja.po | 47 ++ debian/po/nl.po | 49 ++ debian/po/pt.po | 48 ++ debian/po/pt_BR.po | 48 ++ debian/po/ru.po | 50 ++ debian/po/sv.po | 54 ++ debian/po/templates.pot | 42 ++ debian/po/vi.po | 42 ++ debian/postrm | 26 + debian/prerm | 34 + debian/rules | 108 ++++ debian/source/format | 1 + debian/watch | 4 + 48 files changed, 3865 insertions(+) create mode 100644 debian/NEWS create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100644 debian/init.d create mode 100644 debian/motion.1 create mode 100644 debian/motion.conf create mode 100644 debian/motion.config create mode 100644 debian/motion.default create mode 100644 debian/motion.postinst create mode 100644 debian/motion.postinst.save create mode 100644 debian/motion.templates create mode 100644 debian/patches/01_videodev.h.diff create mode 100644 debian/patches/020101107~5273773.patch create mode 100644 debian/patches/020111022~58627b0.patch create mode 100644 debian/patches/020111022~734155f.patch create mode 100644 debian/patches/020111027~5dd9ed4.patch create mode 100644 debian/patches/020120717~0fb31d.patch create mode 100644 debian/patches/02_libav_multiarch.patch create mode 100644 debian/patches/copy-old-api.patch create mode 100644 debian/patches/series create mode 100644 debian/patches/use-new-api.patch create mode 100644 debian/po/POTFILES.in create mode 100644 debian/po/cs.po create mode 100644 debian/po/da.po create mode 100644 debian/po/de.po create mode 100644 debian/po/es.po create mode 100644 debian/po/fr.po create mode 100644 debian/po/gl.po create mode 100644 debian/po/it.po create mode 100644 debian/po/ja.po create mode 100644 debian/po/nl.po create mode 100644 debian/po/pt.po create mode 100644 debian/po/pt_BR.po create mode 100644 debian/po/ru.po create mode 100644 debian/po/sv.po create mode 100644 debian/po/templates.pot create mode 100644 debian/po/vi.po create mode 100644 debian/postrm create mode 100644 debian/prerm create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/watch diff --git a/CHANGELOG b/CHANGELOG index 94e8fb3..96fd45b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -86,6 +86,7 @@ Features * Rollback revision to allow for a formal pull request. * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 * Implement requirement of modulo 16 to avoid seg fault when opening stream + * Add debian build files from trusty(14.04) Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) diff --git a/debian/NEWS b/debian/NEWS new file mode 100644 index 0000000..f6d7452 --- /dev/null +++ b/debian/NEWS @@ -0,0 +1,7 @@ +motion (3.2.9-3) unstable; urgency=low + + The file motion-contro is no longer present in the package motion. If + you want more information about "API for HTTP Interface" can visit the + following URL: http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpAPI + + -- Juan Angulo Moreno Thu, 27 may 2008 20:19:56 -0430 \ No newline at end of file diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..4cd2703 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,12 @@ +Motion for Debian +----------------- + +Motion supports Debian's ffmpeg, but currently it encodes in SWF by +default since the latest versions of ffmpeg stripped support for mpeg1, +mpeg4, and msmpeg4 due to patents. + +You can see more in: http://packages.debian.org/changelogs/pool/main/f/ffmpeg/current/changelog + +Enjoy :) + + -- Juan Angulo Moreno Wed, 14 Nov 2007 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..976c46e --- /dev/null +++ b/debian/changelog @@ -0,0 +1,539 @@ +motion (3.2.12-4) unstable; urgency=medium + + * New maintainer. + * Update for new libav/ffmpeg API. (Closes: #720814) + + -- Ximin Luo Mon, 10 Mar 2014 02:09:03 +0000 + +motion (3.2.12-3.4) unstable; urgency=low + + * Non-maintainer upload. + * Fix "No longer has support for mysql", step 2: + make build dependency on libmysqlclient-dev versioned; + 5.5.17-4 is the first upload with complete multi-arch support, as needed + by dpkg-architecture in debian/rules. + (Closes: #697221) + + -- gregor herrmann Mon, 25 Mar 2013 20:52:43 +0100 + +motion (3.2.12-3.3) unstable; urgency=low + + * Non-maintainer upload. + * Properly find MySQL in /usr/lib/$(DEB_HOST_MULTIARCH). + + Build-Depend on dpkg-dev >= 1.16 + + Get DEB_HOST_MULTIARCH from dpkg-architecture. + + Pass --with-mysql-dir=/usr/lib/$(DEB_HOST_MULTIARCH) to configure. + Closes: #697221 + + -- Evgeni Golov Thu, 03 Jan 2013 12:00:38 +0100 + +motion (3.2.12-3.2) unstable; urgency=medium + + * Non-maintainer upload. + * debian/control: update Build-Depends for libjpeg transition + - libjpeg62-dev->libjpeg-dev (Closes: #643637) + * Rebuild against current libav version (Closes: #650031) + * debian/rules: + - config.status should not depend on configure since it create it. + + -- Bill Allombert Wed, 06 Jun 2012 11:34:23 +0200 + +motion (3.2.12-3.1) unstable; urgency=low + + * * Non-maintainer upload. + * Autogenerate autotools files. Build-depend on dh-autoreconf (not + autoconf-dev). + * Add patches cherry-picked from upstream VCS and unfuzzed, to fix + linking against recent libav*. + Closes: bug#640562. Thanks to Moritz Muehlenhoff and Stephen Kitt. + * Add patch 02, to autodetect multiarch libavcodec path in autoconf. + Closes: bug#644006. Thanks to Moritz Muehlenhoff and Stephen Kitt. + * Create piddir when started (not when installed). + Closes: bug#631198. Thanks to Ibragimov Rinat. + + -- Jonas Smedegaard Sun, 12 Feb 2012 23:02:18 +0100 + +motion (3.2.12-3) unstable; urgency=low + + * Added: libv4l-dev in debian/control. + * Patch: videodev.h by libv4l1-videodev.h and videodev2.h (new format for + kernels > 2.6.38). (Closes: #621962). + * Bumped Standards-Version to 3.9.2. + * Fixed: debian-rules-missing-recommended-target in debian/rules. + * Fixed: motion creates motion gid with 1000 (Closes: #560539). + Thanks Timo Juhani Lindfors . + + -- Juan Angulo Moreno Tue, 23 Aug 2011 11:01:54 -0430 + +motion (3.2.12-2) unstable; urgency=low + + * Bumped Standards-Version to 3.9.1 + * Fixed: Depends on unversioned libmysqlclient-dev (Closes: #589011). + Thanks Angel Abad. + * Fixed: Wrong implementation of the init-functions (Closes: #580379). + * Fixed: motion randomly segfaults (Closes: #550689). + + -- Juan Angulo Moreno Sun, 08 Aug 2010 17:20:01 -0430 + +motion (3.2.12-1) unstable; urgency=low + + * New upstream version. + + -- Juan Angulo Moreno Tue, 22 Jun 2010 04:42:25 -0430 + +motion (3.2.11.1-1) unstable; urgency=low + + * New upstream version. + * Fixed: motion FTBFS with libjpeg8 (Closes: #565325) + * Fixed: group motion isn't created if user motion alredy exists + (Closes: #557416). Thanks Jean-Baptiste Lallment. + * Debconf template translation: + - Vietnamese: Update. Clytie Siddal. (Closes: #576132) + _ Italian: New. Vicenzo Campanella. (Closes: #575094) + * Fixed: Package seems to use ffmpeg-config. (Closes: #487920) + * Bumped Standards-Version to 3.8.4. + * Switch to dpkg-source 3.0 (quilt) format + + -- Juan Angulo Moreno Sat, 10 Apr 2010 10:21:49 -0430 + +motion (3.2.11-2.1) unstable; urgency=low + + * Non-maintainer upload. + * Add $remote_fs to Required-{Start|Stop} in init script + to guarantee that /usr is mounted when needed to start + and stop the daemon + * Fix pending l10n issues. Debconf translations: + * Russian (Yuri Kozlov). Closes: #538650 + * Vietnamese (Clytie Siddall). Closes: #312968 + + -- Christian Perrier Tue, 23 Mar 2010 04:57:55 +0100 + +motion (3.2.11-2) unstable; urgency=low + + * Fixed: init.d script action reload is wrong (Closes: #535769). + * Fixed: error 'file_seek' undeclared function. (Closes: #517568). + Thanks Cyril Brulebois. + * Fixed: Depends on libavcodec51 which is unavailable (Closes: #519137). + + + -- Juan Angulo Moreno Mon, 13 Jul 2009 10:39:00 -0430 + +motion (3.2.11-1) unstable; urgency=low + + * New uptream version. + * Fixed: "Don't start by default/Allow motion to be disabled" + Thanks Eddy Petrisor. (Closes: #504245). + * Removed old patch (because it is include in new upstream). + + -- Juan Angulo Moreno Thu, 22 Jan 2009 14:43:36 -0430 + +motion (3.2.9-7) unstable; urgency=low + + * Fixed: Can't install without video device present (Closes: #501462). + * Fixed: Can not install motion package (Closes: #501206). + + -- Juan Angulo Moreno Wed, 08 Oct 2008 08:24:08 -0430 + +motion (3.2.9-6) unstable; urgency=low + + * Fixed: FTBFS in MIPS. (Closes: #497634). Thanks Angel Carpintero. + * Added patch for fix V4L2 warning. Thanks Angel Carpintero. + * Fixed: Initscript errors. (Closes: #489528). Thanks Angel Carpintero. + + -- Juan Angulo Moreno Wed, 17 Sep 2008 06:03:44 -0400 + +motion (3.2.9-5) unstable; urgency=low + + * Added chgrp in debian/motion.postinst (Closes: #487568). + + -- Juan Angulo Moreno Sun, 27 Jul 2008 22:01:42 -0430 + +motion (3.2.9-4) unstable; urgency=low + + * Fixed errors in the file debian/rules that affected the non-apply of + two patches (01_ffmpeg_creation_update_API.dpatch and + 02_webhttpd_security_video2_backport.dpatch) (Closes: #484566). + * Bumped Standards-Version to 3.8.0. No changes to package necessary. + + -- Juan Angulo Moreno Tue, 10 Jun 2008 09:15:47 -0430 + +motion (3.2.9-3) unstable; urgency=low + + * Debconf translation: Galician (Closes: #484148). + Thanks Jacobo Tarrio. + * Fixed: Document removal of motion-control (Closes: #419158). + * Fixed: Bashism in debian/rules (Closes: #484410). + * Fixed: Off-by-one in webhttpd.c (Closes: #484572). + Thanks Angel Carpintero. + * Fixed: Motion crashes after some time of running + (Closes: #484566). Thanks Angel Carpintero. + * Fixed: motion.conf world readable and thus writable through web + interface by default (Closes: #484570). + + -- Juan Angulo Moreno Fri, 06 Jun 2008 23:29:02 -0430 + +motion (3.2.9-2) unstable; urgency=low + + * Add debian/prerm and debian/postrm. + * Fixed: init script hangs on startup (Closes: #461763). + * Fixed: group 'motion' already exists (Closes: #463396). + * Minor fix in debian/init.d. + + -- Juan Angulo Moreno Mon, 4 Feb 2008 21:48:32 -0430 + +motion (3.2.9-1) unstable; urgency=low + + * New maintainer. Package was orphaned (Closes: #445750). + * New upstream release (Closes: #385938). + * Add init.d script (Thanks Angel Carpintero) (Closes: #394242). + * Add user/group postinst support (Thanks Angel Carpintero) + (Closes: #328752). + * Fixed store motion-triggered movies (this is not present in the + new upstream) (Closes: #436200). + * Change deps (libavcodec0d to libavcodec-dev) and (libavformat0d + to libavformat-dev) (Closes: #427228). + * Report logs #394196 is not present in motion (See motion FAQs in: + http://www.lavrsen.dk/twiki/bin/view/Motion/FrequentlyAskedQuestions) + (Closes: #394196). + * Fixed segfault motion detection (this is not presente in the new + upstream) (Closes: #285247). + * Fixed Motion crashes/exists frequently (this is not presente in + the new upstream). (Closes: #410074). + * Added README.Debian + * motion.conf: Default ffmpeg_video_code is swf (libavcodec-dev and + libavformat-dev don't have support to mpeg in Debian). See changelog + ffmpeg-free. + * Fixed debian/watch. + * Fixed motion manpage. + * Delete motion.preinst and added motion.config (with debconf rules). + * Debconf translations: + - Brazilian Portuguese (Closes: #447013). + - Portuguese (Closes: #425774). + - Dutch (Closes: #415512). + + -- Juan Angulo Moreno Wed, 14 Nov 2007 15:14:33 -0400 + +motion (3.2.3-2.1) unstable; urgency=low + + * Non-maintainer upload to fix pending l10n issues. + * Debconf translations: + - Spanish. Closes: #404800 + - Japanese. Closes: #413003 + + -- Christian Perrier Thu, 1 Mar 2007 19:43:13 +0100 + +motion (3.2.3-2) unstable; urgency=medium + + * Acknowledgement of patch submitted by Loic Minier + (part of NMU motion 3.2.3-1.1) (Closes: #391069). + * Security: Set parameter target_dir in /etc/motion/motion.conf + to /var/lib/motion/snapshots + make small NOTE in + README.Debian (Closes: #393846). + * Add var/lib/motion/snapshots to debian/motion.dirs file. + * Change build dependency from postgresql-dev (obsolete) + to libpq-dev (Closes: #396566). + * Remove weird/improper character (looks like a pipe, but isn't) in motion + manpage on line 428 and 433. Also add an extra backslash to '\n' on + line 428, 433 and 610 (Closes: #374636). + * Make comment in manpage that when calling motion with -d (for debugging) + -c must also be specified explicitly. + * Add parameters 'threshold' and 'noise_level' to the + default configuration file + add punctuation marks (.) + at the end of all comment lines. + * Bumped Standards-Version to 3.7.2. No changes to package necessary. + + -- Frederik Dannemare Thu, 3 Nov 2006 09:41:23 +0100 + +motion (3.2.3-1.1) unstable; urgency=high + + * Non-maintainer upload. + * Pass -DFFMPEG_AVWRITEFRAME_NEWAPI to CFLAGS. closes: #389304 + + -- Loic Minier Wed, 4 Oct 2006 19:09:45 +0200 + +motion (3.2.3-1) unstable; urgency=low + + * New upstream release (Closes: #341482). + - Build problems regarding non-existent members + of AVCodecContext are fixed (Closes: #323736). + * Enable ffmpeg_video_codec msmpeg4 in motion.conf (Closes: #299953). + * Depend on debconf | debconf-2.0 (not just debconf) (Closes: #332030). + * Adjust minimal configure patch to apply cleanly against new upstream + configure file (include libs -lvorbis -lvorbisenc -ldts -la52). + * Build against libpq4 (Closes: #343209). + * Build against libmysqlclient15-dev (Closes: #343778). + * Remove Build-Depends on libxmlrpc-c3-dev and libcurl3-dev (xmlrpc + is deprecated in 3.x in favor of a new http interface to control motion). + * Remove xmlrpc-api.html from debian/motion.docs. + * Add --without-optimizecpu to configure. + * Include Czech debconf translation + by Miroslav Kure (Closes: #308023). + * Include Swedish debconf translation + by Daniel Nylander (Closes: #330538). + * Include Vietnamese debconf translation + by Clytie Siddall (Closes: #312968). + * Upload sponsored by Ari Pollak . + + -- Frederik Dannemare Wed, 14 Dec 2005 20:24:35 +0100 + +motion (3.1.19-1) unstable; urgency=low + + * New upstream release (Closes: #297671). + * Add support for ffmpeg (add Build-Depends on libavcodec-dev and + libavformat-dev). + * Update debian/README.Debian to mention the new support for ffmpeg. + * Remove debian/motion.menu (didn't make much sense really). + * Get rid of direct patching of upstream sources. Instead, apply + Debian-specific modifications at build-time from patches in debian/patches + with help from dpatch (add Build-Depends on dpatch). + * Remove Suggests on ucbmpeg (Closes: #279385). + * Add Recommends on ffmpeg. + * Include German po-debconf translation by Jens Nachtigall + (Closes: #283017). + * Patch configure to really remove rpath + add -lvorbis -lvorbisenc -ldts + -la52 to LIBS. Thanks to Sam Hocevar (ffmpeg maintainer) for hints on + how to properly build with ffmpeg support. + * Upload sponsored by Ari Pollak . + + -- Frederik Dannemare Wed, 14 Mar 2005 01:03:18 +0100 + +motion (3.1.17-1) unstable; urgency=low + + * New upstream release (Closes: #273652). + * Add motion_guide.html and xmlrpc-api.html to debian/motion.docs. + * Remove debian/motion.postrm, since debhelper automatically + handles the stuff that was in that file. + * Upload sponsored by Ari Pollak . + + -- Frederik Dannemare Fri, 29 Oct 2004 22:56:26 +0200 + +motion (3.1.14-2) unstable; urgency=low + + * Only prompt user with debconf info, if an earlier version of motion has + already been installed (Closes: #263717). + * Include French po-debconf translation by Olivier Trichet + (Closes: #264549). + * Update debian/watch file. + + -- Frederik Dannemare Tue, 10 Aug 2004 21:34:16 +0200 + +motion (3.1.14-1) unstable; urgency=low + + * New upstream release. + * New maintainer. Package was orphaned (Closes: #254336). + * Remove mentioning of included ffmpeg in README.Debian. + * Remove out-of-date debian/TODO file. + * Update debian/control file to reflect new maintainership. + * Update package description in debian/control. + * Remove tar from Build-Depends, since it is already build-essential. + * Add CREDITS to debian/docs. + * Add extra documentation files (listed in debian/motion.docs). + * Add example config files (listed in debian/motion.examples). + * Add manpage for motion-control binary. + * Update debian/rules (working from a much more recent template). + * Use /etc/motion (instead of /etc) af sysconfdir. + * Add use of gettext-based debconf templates. + * Add debconf to Depends in debian/control. + * Add po-debconf to Build-Depends in debian/control. + * Add /etc/motion/motion.conf to debian/motion.conffiles. + * Edit Makefile.in to make files install into their correct locations. + * Edit configure/configure.in to avoid use of rpath. + * Upload sponsored by Matthias Urlichs . + + -- Frederik Dannemare Mon, 29 Jul 2004 21:22:24 +0200 + +motion (3.0.6-0.1) unstable; urgency=low + + * NMU of newer upstream version (closes: Bug#211578). + * Remove all traces of ffmpeg (closes: Bug#215626). + * Remove unused debian/debian/ dir. + * Update copyright and watch file to (only) use new home + http://motion.sourceforge.net/ . + * Build-depend on debhelper >= 3 (as already set in debian/rules + DH_COMPAT) and remove debian/conffiles. This makes lintian + (somewhat) happier. + + -- Jonas Smedegaard Mon, 13 Oct 2003 22:14:51 +0200 + +motion (3.0.4-2) unstable; urgency=low + + * Builing with curl library for axis users + + -- Paul Hedderly Wed, 25 Sep 2002 21:56:47 +0100 + +motion (3.0.4-1) unstable; urgency=low + + * New upstream release + * Removed build-dependancy on libffmpeg - it's included in the + source... (Closes: #152971) + * Installing the "Motion Guide" by Kenneth Lavrsen. + * Added some missed build-depends... + + -- Paul Hedderly Mon, 26 Aug 2002 20:08:24 +0100 + +motion (3.0.3-1) unstable; urgency=low + + * New upstream release + + -- Paul Hedderly Fri, 12 Jul 2002 07:37:49 +0100 + +motion (3.0.2-2) unstable; urgency=low + + * Included ffmpeg-0.4.5 source in the build - provides static library + and motion-ffmpeg and motion-ffserver... this is a stopgap until + proper ffmpeg packages are in Debian. + + -- Paul Hedderly Fri, 5 Jul 2002 12:51:54 +0100 + +motion (3.0.2-1) unstable; urgency=low + + * New upstream release + + -- Paul Hedderly Wed, 3 Jul 2002 20:12:13 +0100 + +motion (3.0.1-1) unstable; urgency=low + + * New upstream release + + -- Paul Hedderly Wed, 3 Jul 2002 20:09:57 +0100 + +motion (3.0.0-3) unstable; urgency=low + + * Fixed some new Makefile tweaks - docs/examples go to the right place + + -- Paul Hedderly Wed, 3 Jul 2002 20:06:28 +0100 + +motion (3.0.0-2) unstable; urgency=low + + * Fixed the default path for mpeg_encode. + + -- Paul Hedderly Sat, 22 Jun 2002 21:17:17 +0100 + +motion (3.0.0-1) unstable; urgency=low + + * New upstream release. + + -- Paul Hedderly Sat, 15 Jun 2002 20:16:56 +0100 + +motion (2.6.3-4) unstable; urgency=low + + * Fixed the menu option + + -- Paul Hedderly Tue, 20 Nov 2001 19:57:07 +0000 + +motion (2.6.3-3) unstable; urgency=low + + * Added a patch to do yuv conversion for VAIO laptops (cheers Joey, + sorry it took so long - and I hope it works...) - Closes #99941 + + -- Paul Hedderly (DH/DSS) Tue, 13 Nov 2001 15:53:43 +0000 + +motion (2.6.3-2) unstable; urgency=low + + * Upgraded the package to be Standards version 3.5.2 compatible and lintian clean + * New version... Closes: #100025,#100658,#113912 + + -- Paul Hedderly (DH/DSS) Tue, 13 Nov 2001 09:26:34 +0000 + +motion (2.6.3-1) unstable; urgency=low + + * New release - actually... several new releases. Sorry for my + non-release: I lost access to any way to use/test this software. + + -- Paul Hedderly (DH/DSS) Mon, 8 Oct 2001 15:01:05 +0100 + +motion (2.3-10) unstable; urgency=low + + * Uploading to debian - (Closes: #77018) + + -- Paul Hedderly (DH/DSS) Thu, 7 Dec 2000 12:45:47 +0000 + +motion (2.3-9) unstable; urgency=low + + * Tidied up some document handling; only need one copy of the changelog + + -- Paul Hedderly (DH/DSS) Thu, 7 Dec 2000 11:36:05 +0000 + +motion (2.3-8) unstable; urgency=low + + * New maintainer address - I'm now a DD. + + -- Paul Hedderly (DH/DSS) Thu, 7 Dec 2000 11:12:13 +0000 + +motion (2.3-7) unstable; urgency=low + + * Removed motion.5 link - It's not needed? + * Remove /usr/sbin from debian/dirs - not needed any more + + Thanks to Paul Slootman, whos nose smells out every smelly + old problem :O) + + -- Paul Hedderly (DH/DSS) Tue, 28 Nov 2000 15:38:27 +0000 + +motion (2.3-6) unstable; urgency=low + + * Added build dependancy on libmysqlclient10-dev. It doesn't actually + depend on that library to build - unless you want all the available + functionality. Motion does not need mysql to run. + * Added binary suggests: mysql-client. + + -- Paul Hedderly (DH/DSS) Fri, 17 Nov 2000 11:32:13 +0000 + +motion (2.3-5) unstable; urgency=low + + * Moved man pages to share + * Added debhelper to build-depends + * Removed *ex* files which were removed from CVS... but oh well + + Thanks to Martin Michlmayr for his hints. + + -- Paul Hedderly (DH/DSS) Thu, 16 Nov 2000 11:40:25 +0000 + +motion (2.3-4) unstable; urgency=low + + * Removed my mods to Makefile.in - rules does some munging... + * Remove .ex files which will not be needed + * Misc doc updates + + -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 22:12:11 +0000 + +motion (2.3-3) unstable; urgency=low + + * Made the Makefile.in install motion.conf in /etc (it is + defined to dpkg as a conffile so should be safe during upgrades) + + -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 15:10:44 +0000 + +motion (2.3-2) unstable; urgency=low + + * Commented out a few dh_* calls from rules which are currently superfluous + * Tidied up Makefiles.in - use what's already there with minor modifications + + -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 14:03:39 +0000 + +motion (2.3-1) unstable; urgency=low + + * New upstream release + + -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 11:18:44 +0000 + +motion (2.0-3) unstable; urgency=low + + * Fixed the makefile - put docs in the right place... + + -- Paul Hedderly (DH/DSS) Wed, 20 Sep 2000 13:11:46 +0100 + +motion (2.0-2) unstable; urgency=low + + * Changed Makefile.in to put docs in /usr/share.... + * Created blank contrib directory and dummy to make install happy + + -- Paul Hedderly (DH/DSS) Wed, 20 Sep 2000 13:08:44 +0100 + +motion (2.0-1) unstable; urgency=low + + * Initial Release. + * My first DebHelper'd debian conversion! + * Trying it with NO original source changes... + + -- Paul Hedderly (DH/DSS) Wed, 20 Sep 2000 12:39:09 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +6 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..4075c3f --- /dev/null +++ b/debian/control @@ -0,0 +1,31 @@ +Source: motion +Section: graphics +Priority: optional +Maintainer: Ximin Luo +HomePage: http://motion.sf.net +Build-Depends: debhelper (>= 6), dpkg-dev (>= 1.16), dh-autoreconf, libjpeg-dev, zlib1g-dev, libavcodec-dev, libavformat-dev, libpq-dev, libmysqlclient-dev (>= 5.5.17-4), libv4l-dev +Standards-Version: 3.9.2 + +Package: motion +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, debconf +Recommends: ffmpeg +Suggests: mysql-client, postgresql-client +Description: V4L capture program supporting motion detection + Motion is a program that monitors the video signal from + one or more cameras and is able to detect if a significant + part of the picture has changed. Or in other words, it can + detect motion. + . + Motion is a command line based tool. It has no graphical + user interface. Everything is setup either via the + command line or via configuration files. + . + The output from motion can be: + - jpg files + - ppm format files + - mpeg video sequences + . + Also, motion has its own minimalistic web server. Thus, + you can access the webcam output from motion via a browser. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..eac7164 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,14 @@ +This package was originally debianized by Paul Hedderly (DH/DSS) +on Wed, 20 Sep 2000 12:39:09 +0100. + +Package is currently maintained by Juan Angulo Moreno since +Thu, 01 Jun 2007 16:47:33 -0400. + +Upstream source: http://motion.sourceforge.net/ + +Upstream Author: Kenneth Lavrsen + +Copyright: 2000-2004 by Jeroen Vreeken/Folkert Van Heusden/Kenneth Lavrsen + +This software is released under the GNU GENERAL PUBLIC LICENSE Version 2. +See /usr/share/common-licenses/GPL-2 for details. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..74f52d2 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,6 @@ +usr/bin +usr/share/man/man1 +etc/motion +etc/init.d +etc/default + diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..9af2035 --- /dev/null +++ b/debian/docs @@ -0,0 +1,5 @@ +FAQ +README +README.axis_2100 +CREDITS +motion_guide.html diff --git a/debian/init.d b/debian/init.d new file mode 100644 index 0000000..ac29630 --- /dev/null +++ b/debian/init.d @@ -0,0 +1,111 @@ +#!/bin/sh -e +# +# /etc/init.d/motion: Start the motion detection +# +### BEGIN INIT INFO +# Provides: motion +# Required-Start: $local_fs $syslog $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start Motion detection +# Description: loads motion and assigns privileges +### END INIT INFO + +# Ported to new debian way using sh and /lib/lsb/init-functions +# by Angel Carpintero +# Modified by : Juan Angulo Moreno +# Eddy Petrisor +# ArAge + +NAME=motion +PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin +DAEMON=/usr/bin/motion +PIDFILE=/var/run/$NAME.pid +DEFAULTS=/etc/default/$NAME +DESC="motion detection daemon" + +ENV="env -i LANG=C PATH=$PATH_BIN" + +. /lib/lsb/init-functions + +test -x $DAEMON || exit 0 + +RET=0 + +[ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes + + +check_daemon_enabled () { + if [ "$start_motion_daemon" = "yes" ] ; then + return 0 + else + log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" + return 1 + fi + +} + + +case "$1" in + start) + if check_daemon_enabled ; then + if ! [ -d /var/run/motion ]; then + mkdir /var/run/motion + fi + chown motion:motion /var/run/motion + + log_daemon_msg "Starting $DESC" "$NAME" +if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then + log_end_msg 0 + else + log_end_msg 1 + RET=1 + fi + fi + ;; + + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then + log_end_msg 0 + else + log_end_msg 1 + RET=1 + fi + ;; + + reload|force-reload) + log_daemon_msg "Reloading $NAME configuration" + if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then + log_end_msg 0 + else + log_end_msg 1 + RET=1 + fi + ;; + + restart-motion) + if check_daemon_enabled ; then + log_action_begin_msg "Restarting $NAME" + if $0 stop && $0 start ; then + log_action_end_msg 0 + else + log_action_cont_msg "(failed)" + RET=1 + fi + fi + ;; + + restart) + $0 restart-motion + ;; + + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" + RET=1 + ;; +esac + + +exit $RET diff --git a/debian/motion.1 b/debian/motion.1 new file mode 100644 index 0000000..44a9674 --- /dev/null +++ b/debian/motion.1 @@ -0,0 +1,821 @@ +.TH MOTION 1 2007-11-06 "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 level ] [ -p process_id_file ] +.SH DESCRIPTION +.I Motion +uses a video4linux device to detect motion. If motion is detected both normal +and motion pictures will be taken. Motion can also take actions to notify you +if needed. Creation of automated snapshots is also possible. +.SH OPTIONS +.TP +.B \-c +Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default. +.TP +.B \-h +Show help screen. +.TP +.B \-n +Run in non-daemon mode. +.TP +.B \-s +Run in setup mode. Also forces non-daemon mode +.TP +.B \-d level +Run in debug mode, level 1-9. +.TP +.B \-p +Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. +.TP +.SH "CONFIG FILE OPTIONS" +These are the options that can be used in the config file. +.I They are overridden by the commandline! +All number values are integer numbers (no decimals allowed). +Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). + +.TP +.B auto_brightness boolean +Values: on, off / Default: off +.br +Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness +.TP +.B brightness integer +Values: 0 - 255 / Default: 0 (disabled) +.br +The brightness level for the video device. +.TP +.B contrast boolean +Values: 0 - 255 / Default: 0 (disabled) +.br +The contrast level for the video device. +.TP +.B control_authentication string +Values: Max 4096 characters / Default: Not defined +.br +To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. +.TP +.B control_html_output boolean +Values: on, off / Default: on +.br +Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. +.TP +.B control_localhost boolean +Values: on, off / Default: on +.br +Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. +.TP +.B control_port integer +Values: 0 - 65535 / Default: 0 (disabled) +.br +Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. +.TP +.B daemon boolean +Values: on, off / Default: off +.br +Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. +.TP +.B despeckle string +Values: EedDl / Default: Not defined +.br +Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. +.TP +.B ffmpeg_bps integer +Values: 0 - 9999999 / Default: 400000 +.br +Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. +.TP +.B ffmpeg_cap_motion boolean +Values: on, off / Default: off +.br +Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. +.TP +.B ffmpeg_cap_new boolean +Values: on, off / Default: off +.br +Use ffmpeg libraries to encode mpeg movies in realtime. +.TP +.B ffmpeg_deinterlace boolean +Values: on, off / Default: off +.br +Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. +.TP +.B ffmpeg_timelapse boolean +Values: 0 - 2147483647 / Default: 0 (disabled) +.br +Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. +.TP +.B ffmpeg_timelapse_mode discrete strings +Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual / Default: daily +.br +The file rollover mode of the timelapse video. +.TP +.B ffmpeg_variable_bitrate integer +Values: 0, 2 - 31 / Default: 0 (disabled) +.br +Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. +.TP +.B ffmpeg_video_codec discrete strings +Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1 / Default: mpeg4 +.br +Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. +.TP +.B framerate integer +Values: 2 - 100 / Default: 100 (no limit) +.br +Maximum number of frames to be captured from the camera per second. +.TP +.B frequency boolean +Values: 0 - 999999 / Default: 0 (Not set) +.br +The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) +.TP +.B gap integer +Values: 0 - 2147483647 / Default: 60 +.br +Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. +.TP +.B height integer +Values: Device Dependent / Default: 288 +.br +The height of each frame in pixels. +.TP +.B hue integer +Values: 0 - 255 / Default: 0 (disabled) +.br +The hue level for the video device. +.TP +.B input integer +Values: 0 - 7, 8 = disabled / Default: 8 (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. +.TP +.B jpeg_filename string +Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q +.br +File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. +.TP +.B lightswitch integer +Values: 0 - 100 / Default: 0 (disabled) +.br +Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. +.TP +.B locate boolean +Values: on, off, preview / Default: off +.br +Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. +.TP +.B low_cpu integer +Values: 0 - 100 / Default: 0 (disabled) +.br +When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. +.TP +.B mask_file string +Values: Max 4095 characters / Default: Not defined +.br +PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. +.TP +.B max_mpeg_time integer +Values: 0 (infinite) - 2147483647 / Default: 3600 +.br +The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. +.TP +.B minimum_frame_time integer +Values: 0 - 2147483647 / Default: 0 +.br +Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. +.TP +.B minimum_motion_frames boolean +Values: 1 - 1000s / Default: 1 +.br +Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. +.TP +.B motion_video_pipe string +Values: Max 4095 characters / Default: Not defined +.br +The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set +.TP +.B movie_filename string +Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S +.br +File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. +.TP +.B mysql_db string +Values: Max 4095 characters / Default: Not defined +.br +Name of the MySQL database. +.TP +.B mysql_host string +Values: Max 4095 characters / Default: localhost +.br +IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. +.TP +.B mysql_password string +Values: Max 4095 characters / Default: Not defined +.br +The MySQL password. +.TP +.B mysql_user string +Values: Max 4095 characters / Default: Not defined +.br +The MySQL user name. +.TP +.B netcam_proxy string +Values: Max 4095 characters / Default: Not defined +.br +URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber +.TP +.B netcam_url string +Values: Max 4095 characters / Default: Not defined +.br +Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. +.TP +.B netcam_userpass string +Values: Max 4095 characters / Default: Not defined +.br +For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. +.TP +.B night_compensate boolean +Values: on, off / Default: off +.br +When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. +.TP +.B noise_level integer +Values: 1 - 255 / Default: 32 +.br +The noise level is used as a threshold for distinguishing between noise and motion. +.TP +.B noise_tune boolean +Values: on, off / Default: on +.br +Activates the automatic tuning of noise level. +.TP +.B norm discrete strings +Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) / Default: 0 (PAL) +.br +Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) +.TP +.B on_event_end string +Values: Max 4095 characters / Default: Not defined +.br +Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. +.TP +.B on_event_start string +Values: Max 4095 characters / Default: Not defined +.br +Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. +.TP +.B on_motion_detected string +Values: Max 4095 characters / Default: Not defined +.br +Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. +.TP +.B on_movie_end string +Values: Max 4095 characters / Default: Not defined +.br +Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. +.TP +.B on_movie_start string +Values: Max 4095 characters / Default: Not defined +.br +Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. +.TP +.B on_picture_save string +Values: Max 4095 characters / Default: Not defined +.br +Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. +.TP +.B output_all boolean +Values: on, off / Default: off +.br +Picture are saved continuously as if motion was detected all the time. +.TP +.B output_motion boolean +Values: on, off / Default: off +.br +Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. +.TP +.B output_normal discrete strings +Values: on, off, first, best / Default: on +.br +Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. +.TP +.B pgsql_db string +Values: Max 4095 characters / Default: Not defined +.br +Name of the PostgreSQL database. +.TP +.B pgsql_host string +Values: Max 4095 characters / Default: localhost +.br +IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. +.TP +.B pgsql_password string +Values: Max 4095 characters / Default: Not defined +.br +The PostgreSQL password. +.TP +.B pgsql_port integer +Values: 0 - 65535 / Default: 5432 +.br +The PostgreSQL server port number. +.TP +.B pgsql_user string +Values: Max 4095 characters / Default: Not defined +.br +The PostgreSQL user name. +.TP +.B post_capture integer +Values: 0 - 2147483647 / Default: 0 (disabled) +.br +Specifies the number of frames to be captured after motion has been detected. +.TP +.B ppm boolean +Values: on, off / Default: off +.br +Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. +.TP +.B pre_capture integer +Values: 0 - 100s / Default: 0 (disabled) +.br +Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. +.TP +.B process_id_file string +Values: Max 4095 characters / Default: Not defined +.br +File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid +.TP +.B quality integer +Values: 1 - 100 / Default: 75 +.br +The quality for the jpeg images in percent. +.TP +.B quiet boolean +Values: on, off / Default: off +.br +Be quiet, don't output beeps when detecting motion. +.TP +.B rotate discrete strings +Values: 0, 90, 180, 270 / Default: 0 (not rotated) +.br +Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. +.TP +.B roundrobin_frames integer +Values: 1 - 2147483647 / Default: 1 +.br +Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. +.TP +.B roundrobin_skip integer +Values: 1 - 2147483647 / Default: 1 +.br +Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). +.TP +.B saturation integer +Values: 0 - 255 / Default: 0 (disabled) +.br +The colour saturation level for the video device. +.TP +.B setup_mode boolean +Values: on, off / Default: off +.br +Run Motion in setup mode. +.TP +.B smart_mask_speed integer +Values: 0 - 10 / Default: 0 (disabled) +.br +Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. +.TP +.B snapshot_filename string +Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-snapshot +.br +File path for snapshots (jpeg or ppm) relative to target_dir. +.TP +.B snapshot_interval integer +Values: 0 - 2147483647 / Default: 0 (disabled) +.br +Make automated snapshots every 'snapshot_interval' seconds. +.TP +.B sql_log_image boolean +Values: on, off / Default: on +.br +Log to the database when creating motion triggered image file. +.TP +.B sql_log_mpeg boolean +Values: on, off / Default: off +.br +Log to the database when creating motion triggered mpeg file. +.TP +.B sql_log_snapshot boolean +Values: on, off / Default: on +.br +Log to the database when creating a snapshot image file. +.TP +.B sql_log_timelapse boolean +Values: on, off / Default: off +.br +Log to the database when creating timelapse mpeg file +.TP +.B sql_query string +Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') +.br +SQL query string that is sent to the database. The values for each field are given by using convertion specifiers +.TP +.B switchfilter boolean +Values: on, off / Default: off +.br +Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. +.TP +.B target_dir string +Values: Max 4095 characters / Default: Not defined = current working directory +.br +Target directory for picture and movie files. +.TP +.B text_changes boolean +Values: on, off / Default: off +.br +Turns the text showing changed pixels on/off. +.TP +.B text_double boolean +Values: on, off / Default: off +.br +Draw characters at twice normal size on images. +.TP +.B text_event string +Values: Max 4095 characters / Default: %Y%m%d%H%M%S +.br +This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. +.TP +.B text_left string +Values: Max 4095 characters / Default: Not defined +.br +User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ +and conversion specifiers (codes starting by a %). +.TP +.B text_right string +Values: Max 4095 characters / Default: %Y-%m-%d\n%T +.br +User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ +and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +.TP +.B thread string +Values: Max 4095 characters / Default: Not defined +.br +Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file. +.TP +.B threshold integer +Values: 1 - 2147483647 / Default: 1500 +.br +Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. +.TP +.B threshold_tune boolean +Values: on, off / Default: off +.br +Activates the automatic tuning of threshold level. +.TP +.B timelapse_filename string +Values: Max 4095 characters / Default: %v-%Y%m%d-timelapse +.br +File path for timelapse mpegs relative to target_dir (ffmpeg only). +.TP +.B track_auto boolean +Values: on, off / Default: off +.br +Enable auto tracking +.TP +.B track_iomojo_id integer +Values: 0 - 2147483647 / Default: 0 +.br +Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. +.TP +.B track_maxx integer +Values: 0 - 2147483647 / Default: 0 +.br +The maximum position for servo x. +.TP +.B track_maxy integer +Values: 0 - 2147483647 / Default: 0 +.br +The maximum position for servo y. +.TP +.B track_motorx integer +Values: -1 - 2147483647 / Default: -1 +.br +The motor number that is used for controlling the x-axis. +.TP +.B track_motory integer +Values: -1 - 2147483647 / Default: -1 +.br +The motor number that is used for controlling the y-axis. +.TP +.B track_move_wait integer +Values: 0 - 2147483647 / Default: 10 +.br +Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. +.TP +.B track_port string +Values: Max 4095 characters / Default: Not defined +.br +This is the device name of the serial port to which the stepper motor interface is connected. +.TP +.B track_speed integer +Values: 0 - 255 / Default: 255 +.br +Speed to set the motor to. +.TP +.B track_step_angle_x integer +Values: 0-90 / Default: 10 +.br +Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. +.TP +.B track_step_angle_y integer +Values: 0-40 / Default: 10 +.br +Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. +.TP +.B track_stepsize integer +Values: 0 - 255 / Default: 40 +.br +Number of steps to make. +.TP +.B track_type discrete strings +Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) +.br +Type of tracker. +.TP +.B tunerdevice string +Values: Max 4095 characters / Default: /dev/tuner0 +.br +The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. +.TP +.B video_pipe string +Values: Max 4095 characters / Default: Not defined +.br +The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. +.TP +.B videodevice string +Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) +.br +The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. +.TP +.B webcam_limit integer +Values: 0 - 2147483647 / Default: 0 (unlimited) +.br +Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. +.TP +.B webcam_localhost boolean +Values: on, off / Default: on +.br +Limits the access to the webcam to the localhost. +.TP +.B webcam_maxrate integer +Values: 1 - 100 / Default: 1 +.br +Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. +.TP +.B webcam_motion boolean +Values: on, off / Default: off +.br +If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. +.TP +.B webcam_port integer +Values: 0 - 65535 / Default: 0 (disabled) +.br +TCP port on which motion will listen for incoming connects with its webcam server. +.TP +.B webcam_quality integer +Values: 1 - 100 / Default: 50 +.br +Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. +.TP +.B width integer +Values: Device Dependent / Default: 352 +.br +The width in pixels of each frame. Valid range is camera dependent. + +.SH SIGNALS +Motion responds to the following signals: +.TP +.B SIGHUP +The config file will be reread. +.TP +.B SIGTERM +If needed motion will create an mpeg file of the last event and exit +.TP +.B SIGUSR1 +Motion will create an mpeg file of the current event. +.SH NOTES +.TP +.B Snapshot +A snapshot is a picture taken at regular intervals independently of any movement in the picture. +.TP +.B Motion image +A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. +.TP +.B Normal image +A "normal" image is the real image taken by the camera with text overlayed. +.TP +.B Threads and config files +If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. +.br +If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: +.br +1. Current directory from where motion was invoked +.br +2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf +.br +3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) +.br +If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. +.br +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. +.br +The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. +.br +If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. +.br +So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. +.br +An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). +.br +An option that is unique to a camera must be defined in each thread file. +.br +The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. +.br +Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. +.br +Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins. +.br +1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. +.br +2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. +.br +3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. +.br +4. Motion reads the command line option again overruling any previously defined options. +.br +So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. +.br +If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. +.br +If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. +.TP +.B Conversion Specifiers for Advanced Filename and Text Features +The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. +.br +In text_left and text_right you can additionally use '\n' for new line. + +.TP +.B %a +The abbreviated weekday name according to the current locale. +.TP +.B %A +The full weekday name according to the current locale. +.TP +.B %b +The abbreviated month name according to the current locale. +.TP +.B %B +The full month name according to the current locale. +.TP +.B %c +The preferred date and time representation for the current locale. +.TP +.B %C +Text defined by the text_event feature +.TP +.B %d +The day of the month as a decimal number (range 01 to 31). +.TP +.B %D +Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. +.TP +.B %E +Modifier: use alternative format, see below. +.TP +.B %f +File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. +.TP +.B %F +Equivalent to %Y-%m-%d (the ISO 8601 date format). +.TP +.B %H +The hour as a decimal number using a 24-hour clock (range 00 to 23). +.TP +.B %i +Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). +.TP +.B %I +The hour as a decimal number using a 12-hour clock (range 01 to 12). +.TP +.B %j +The day of the year as a decimal number (range 001 to 366). +.TP +.B %J +Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). +.TP +.B %k +The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) +.TP +.B %K +X coordinate in pixels of the center point of motion. Origin is upper left corner. +.TP +.B %l +The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) +.TP +.B %L +Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). +.TP +.B %m +The month as a decimal number (range 01 to 12). +.TP +.B %M +The minute as a decimal number (range 00 to 59). +.TP +.B %n +Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. +.TP +.B %N +Noise level. +.TP +.B %o +Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. +.TP +.B %p +Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. +.TP +.B %P +Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. +.TP +.B %q +Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. +.TP +.B %Q +Number of detected labels found by the despeckle feature +.TP +.B %r +The time in a.m. or p.m. notation. +.TP +.B %R +The time in 24-hour notation (%H:%M). +.TP +.B %s +The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. +.TP +.B %S +The second as a decimal number (range 00 to 61). +.TP +.B %t +Thread number (camera number) +.TP +.B %T +The time in 24-hour notation (%H:%M:%S). +.TP +.B %u +The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. +.TP +.B %U +The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. +.TP +.B %v +Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. +.TP +.B %V +The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. +.TP +.B %w +The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. +.TP +.B %W +The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. +.TP +.B %x +The preferred date representation for the current locale without the time. +.TP +.B %X +The preferred time representation for the current locale without the date. +.TP +.B %y +The year as a decimal number without a century (range 00 to 99). +.TP +.B %Y +The year as a decimal number including the century. +.TP +.B %z +The time-zone as hour offset from GMT. +.TP +.B %Z +The time zone or name or abbreviation. + +.TP +.B More information +Motion homepage: http://motion.sourceforge.net/ + +Motion Guide (user and installation guide): +.br http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide +.br http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice +.SH AUTHORS +Jeroen Vreeken (pe1rxq@amsat.org), +Folkert van Heusden, +Kenneth Lavrsen (kenneth@lavrsen.dk) +Juan Angulo Moreno diff --git a/debian/motion.conf b/debian/motion.conf new file mode 100644 index 0000000..c2b2ffb --- /dev/null +++ b/debian/motion.conf @@ -0,0 +1,598 @@ +# Rename this distribution example file to motion.conf +# +# This config file was generated by motion 3.2.9 + + +############################################################ +# Daemon +############################################################ + +# Start in daemon (background) mode and release terminal (default: off) +daemon off + +# File to store the process ID, also called pid file. (default: not defined) +process_id_file /var/run/motion.pid + +############################################################ +# Basic Setup Mode +############################################################ + +# Start in Setup-Mode, daemon disabled. (default: off) +setup_mode off + +########################################################### +# Capture device options +############################################################ + +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video0 + +# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) +# 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 1 for video/TV cards, and 8 for USB cameras +input 8 + +# 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) +norm 0 + +# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) +frequency 0 + +# Rotate image this number of degrees. The rotation affects all saved images as +# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270. +rotate 0 + +# Image width (pixels). Valid range: Camera dependent, default: 352 +width 320 + +# Image height (pixels). Valid range: Camera dependent, default: 288 +height 240 + +# Maximum number of frames to be captured per second. +# Valid range: 2-100. Default: 100 (almost no limit). +framerate 2 + +# Minimum time in seconds between capturing picture frames from the camera. +# Default: 0 = disabled - the capture rate is given by the camera framerate. +# This option is used when you want to capture images at a rate lower than 2 per second. +minimum_frame_time 0 + +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) +# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined +; netcam_url value + +# Username and password for network camera (only if required). Default: not defined +# Syntax is user:password +; netcam_userpass value + +# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". +# If a port number other than 80 is needed, use "http://myproxy:1234". +# Default: not defined +; netcam_proxy value + +# Let motion regulate the brightness of a video device (default: off). +# The auto_brightness feature uses the brightness option as its target value. +# If brightness is zero auto_brightness will adjust to average brightness value 128. +# Only recommended for cameras without auto brightness +auto_brightness off + +# Set the initial brightness of a video device. +# If auto_brightness is enabled, this value defines the average brightness level +# which Motion will try and adjust to. +# Valid range 0-255, default 0 = disabled +brightness 0 + +# Set the contrast of a video device. +# Valid range 0-255, default 0 = disabled +contrast 0 + +# Set the saturation of a video device. +# Valid range 0-255, default 0 = disabled +saturation 0 + +# Set the hue of a video device (NTSC feature). +# Valid range 0-255, default 0 = disabled +hue 0 + + +############################################################ +# Round Robin (multiple inputs on same video device name) +############################################################ + +# Number of frames to capture in each roundrobin step (default: 1) +roundrobin_frames 1 + +# Number of frames to skip before each roundrobin step (default: 1) +roundrobin_skip 1 + +# Try to filter out noise generated by roundrobin (default: off) +switchfilter off + + +############################################################ +# Motion Detection Settings: +############################################################ + +# Threshold for number of changed pixels in an image that +# triggers motion detection (default: 1500) +threshold 1500 + +# Automatically tune the threshold down if possible (default: off) +threshold_tune off + +# Noise threshold for the motion detection (default: 32) +noise_level 32 + +# Automatically tune the noise threshold (default: on) +noise_tune on + +# Enables motion to adjust its detection/noise level for very dark frames +# Don't use this with noise_tune on. (default: off) +night_compensate off + +# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) +# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. +# (l)abeling must only be used once and the 'l' must be the last letter. +# Comment out to disable +despeckle EedDl + +# PGM file to use as a sensitivity mask. +# Full path name to. (Default: not defined) +; mask_file value + +# Dynamically create a mask file during operation (default: 0) +# Adjust speed of mask changes from 0 (off) to 10 (fast) +smart_mask_speed 0 + +# Ignore sudden massive light intensity changes given as a percentage of the picture +# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled +lightswitch 0 + +# Picture frames must contain motion at least the specified number of frames +# in a row before they are detected as true motion. At the default of 1, all +# motion is detected. Valid range: 1 to thousands, recommended 1-5 +minimum_motion_frames 1 + +# Specifies the number of pre-captured (buffered) pictures from before motion +# was detected that will be output at motion detection. +# Recommended range: 0 to 5 (default: 0) +# Do not use large values! Large values will cause Motion to skip video frames and +# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. +pre_capture 0 + +# Number of frames to capture after motion is no longer detected (default: 0) +post_capture 0 + +# Gap is the seconds of no motion detection that triggers the end of an event +# An event is defined as a series of motion images taken within a short timeframe. +# Recommended value is 60 seconds (Default). The value 0 is allowed and disables +# events causing all Motion to be written to one single mpeg file and no pre_capture. +gap 60 + +# Maximum length in seconds of an mpeg movie +# When value is exceeded a new mpeg file is created. (Default: 0 = infinite) +max_mpeg_time 0 + +# Number of frames per second to capture when not detecting +# motion (saves CPU load) (Default: 0 = disabled) +low_cpu 0 + +# Always save images even if there was no motion (default: off) +output_all off + + +############################################################ +# Image File Output +############################################################ + +# Output 'normal' pictures when motion is detected (default: on) +# Valid values: on, off, first, best +# When set to 'first', only the first picture of an event is saved. +# Picture with most motion of an event is saved when set to 'best'. +# Can be used as preview shot for the corresponding movie. +output_normal on + +# Output pictures with only the pixels moving object (ghost images) (default: off) +output_motion off + +# The quality (in percent) to be used by the jpeg compression (default: 75) +quality 75 + +# Output ppm images instead of jpeg (default: off) +ppm off + + +############################################################ +# FFMPEG related options +# Film (mpeg) file output, and deinterlacing of the video input +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################ + +# Use ffmpeg to encode mpeg movies in realtime (default: off) +ffmpeg_cap_new on + +# Use ffmpeg to make movies with only the pixels moving +# object (ghost images) (default: off) +ffmpeg_cap_motion off + +# Use ffmpeg to encode a timelapse movie +# Default value 0 = off - else save frame every Nth second +ffmpeg_timelapse 0 + +# The file rollover mode of the timelapse video +# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual +ffmpeg_timelapse_mode daily + +# Bitrate to be used by the ffmpeg encoder (default: 400000) +# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) +ffmpeg_bps 500000 + +# Enables and defines variable bitrate for the ffmpeg encoder. +# ffmpeg_bps is ignored if variable bitrate is enabled. +# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, +# or the range 2 - 31 where 2 means best quality and 31 is worst. +ffmpeg_variable_bitrate 0 + +# Codec to used by ffmpeg for the video compression. +# Timelapse mpegs are always made in mpeg1 format independent from this option. +# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. +# mpeg1 - gives you files with extension .mpg +# mpeg4 or msmpeg4 - give you files with extension .avi +# msmpeg4 is recommended for use with Windows Media Player because +# it requires no installation of codec on the Windows client. +# swf - gives you a flash film with extension .swf +# flv - gives you a flash video with extension .flv +# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) +ffmpeg_video_codec swf + +# Use ffmpeg to deinterlace video. Necessary if you use an analog camera +# and see horizontal combing on moving objects in video or pictures. +# (default: off) +ffmpeg_deinterlace off + + +############################################################ +# Snapshots (Traditional Periodic Webcam File Output) +############################################################ + +# Make automated snapshot every N seconds (default: 0 = disabled) +snapshot_interval 0 + + +############################################################ +# Text Display +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, \n = new line, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event - do not use with text_event! +# You can put quotation marks around the text to allow +# leading spaces +############################################################ + +# Locate and draw a box around the moving object. +# Valid values: on, off and preview (default: off) +# Set to 'preview' will only draw a box in preview_shot pictures. +locate off + +# Draws the timestamp using same options as C function strftime(3) +# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +# Text is placed in lower right corner +text_right %Y-%m-%d\n%T-%q + +# Draw a user defined text on the images using same options as C function strftime(3) +# Default: Not defined = no text +# Text is placed in lower left corner +; text_left CAMERA %t + +# Draw the number of changed pixed on the images (default: off) +# Will normally be set to off except when you setup and adjust the motion settings +# Text is placed in upper right corner +text_changes off + +# This option defines the value of the special event conversion specifier %C +# You can use any conversion specifier in this option except %C. Date and time +# values are from the timestamp of the first image in the current event. +# Default: %Y%m%d%H%M%S +# The idea is that %C can be used filenames and text_left/right for creating +# a unique identifier for each event. +text_event %Y%m%d%H%M%S + +# Draw characters at twice normal size on images. (default: off) +text_double off + + +############################################################ +# Target Directories and filenames For Images And Films +# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename +# you can use conversion specifiers +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# Quotation marks round string are allowed. +############################################################ + +# Target base directory for pictures and films +# Recommended to use absolute path. (Default: current working directory) +target_dir /tmp/motion + +# File path for snapshots (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-snapshot +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot +# File extension .jpg or .ppm is automatically added so do not include this. +# Note: A symbolic link called lastsnap.jpg created in the target_dir will always +# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +snapshot_filename %v-%Y%m%d%H%M%S-snapshot + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +jpeg_filename %v-%Y%m%d%H%M%S-%q + +# File path for motion triggered ffmpeg films (mpeg) relative to target_dir +# Default: %v-%Y%m%d%H%M%S +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S +# File extension .mpg or .avi is automatically added so do not include this +# This option was previously called ffmpeg_filename +movie_filename %v-%Y%m%d%H%M%S + +# File path for timelapse mpegs relative to target_dir +# Default: %Y%m%d-timelapse +# Default value is near equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse +# File extension .mpg is automatically added so do not include this +timelapse_filename %Y%m%d-timelapse + + +############################################################ +# Live Webcam Server +############################################################ + +# The mini-http server listens to this port for requests (default: 0 = disabled) +webcam_port 8081 + +# Quality of the jpeg images produced (default: 50) +webcam_quality 50 + +# Output frames at 1 fps when no motion is detected and increase to the +# rate given by webcam_maxrate when motion is detected (default: off) +webcam_motion off + +# Maximum framerate for webcam streams (default: 1) +webcam_maxrate 1 + +# Restrict webcam connections to localhost only (default: on) +webcam_localhost on + +# Limits the number of images per connection (default: 0 = unlimited) +# Number can be defined by multiplying actual webcam rate by desired number of seconds +# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate +webcam_limit 0 + + +############################################################ +# HTTP Based Control +############################################################ + +# TCP/IP port for the http server to listen on (default: 0 = disabled) +control_port 8080 + +# Restrict control connections to localhost only (default: on) +control_localhost on + +# Output for http server, select off to choose raw text plain (default: on) +control_html_output on + +# Authentication for the http based control. Syntax username:password +# Default: not defined (Disabled) +; control_authentication username:password + + +############################################################ +# Tracking (Pan/Tilt) +############################################################ + +# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo) +# The generic type enables the definition of motion center and motion size to +# be used with the conversion specifiers for options like on_motion_detected +track_type 0 + +# Enable auto tracking (default: off) +track_auto off + +# Serial port of motor (default: none) +; track_port value + +# Motor number for x-axis (default: -1) +track_motorx -1 + +# Motor number for y-axis (default: -1) +track_motory -1 + +# Maximum value on x-axis (default: 0) +track_maxx 0 + +# Maximum value on y-axis (default: 0) +track_maxy 0 + +# ID of an iomojo camera if used (default: 0) +track_iomojo_id 0 + +# Angle in degrees the camera moves per step on the X-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_x 10 + +# Angle in degrees the camera moves per step on the Y-axis +# with auto-track (default: 10) +# Currently only used with pwc type cameras +track_step_angle_y 10 + +# Delay to wait for after tracking movement as number +# of picture frames (default: 10) +track_move_wait 10 + +# Speed to set the motor to (stepper motor option) (default: 255) +track_speed 255 + +# Number of steps to make (stepper motor option) (default: 40) +track_stepsize 40 + + +############################################################ +# External Commands, Warnings and Logging: +# You can use conversion specifiers for the on_xxxx commands +# %Y = year, %m = month, %d = date, +# %H = hour, %M = minute, %S = second, +# %v = event, %q = frame number, %t = thread (camera) number, +# %D = changed pixels, %N = noise level, +# %i and %J = width and height of motion area, +# %K and %L = X and Y coordinates of motion center +# %C = value defined by text_event +# %f = filename with full path +# %n = number indicating filetype +# Both %f and %n are only defined for on_picture_save, +# on_movie_start and on_movie_end +# Quotation marks round string are allowed. +############################################################ + +# Do not sound beeps when detecting motion (default: on) +# Note: Motion never beeps when running in daemon mode. +quiet on + +# Command to be executed when an event starts. (default: none) +# An event starts at first motion detected after a period of no motion defined by gap +; on_event_start value + +# Command to be executed when an event ends after a period of no motion +# (default: none). The period of no motion is defined by option gap. +; on_event_end value + +# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +# To give the filename as an argument to a command append it with %f +; on_picture_save value + +# Command to be executed when a motion frame is detected (default: none) +; on_motion_detected value + +# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_start value + +# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) +# To give the filename as an argument to a command append it with %f +; on_movie_end value + + +############################################################ +# Common Options For MySQL and PostgreSQL database features. +# Options require the MySQL/PostgreSQL options to be active also. +############################################################ + +# Log to the database when creating motion triggered image file (default: on) +sql_log_image on + +# Log to the database when creating a snapshot image file (default: on) +sql_log_snapshot on + +# Log to the database when creating motion triggered mpeg file (default: off) +sql_log_mpeg off + +# Log to the database when creating timelapse mpeg file (default: off) +sql_log_timelapse off + +# SQL query string that is sent to the database +# Use same conversion specifiers has for text features +# Additional special conversion specifiers are +# %n = the number representing the file_type +# %f = filename with full path +# Default value: +# 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') + + +############################################################ +# Database Options For MySQL +############################################################ + +# Mysql database to log to (default: not defined) +; mysql_db value + +# The host on which the database is located (default: localhost) +; mysql_host value + +# User account name for MySQL database (default: not defined) +; mysql_user value + +# User password for MySQL database (default: not defined) +; mysql_password value + + +############################################################ +# Database Options For PostgreSQL +############################################################ + +# PostgreSQL database to log to (default: not defined) +; pgsql_db value + +# The host on which the database is located (default: localhost) +; pgsql_host value + +# User account name for PostgreSQL database (default: not defined) +; pgsql_user value + +# User password for PostgreSQL database (default: not defined) +; pgsql_password value + +# Port on which the PostgreSQL database is located (default: 5432) +; pgsql_port 5432 + + +############################################################ +# Video Loopback Device (vloopback project) +############################################################ + +# Output images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; video_pipe value + +# Output motion images to a video4linux loopback device +# The value '-' means next available (default: not defined) +; motion_video_pipe value + + +############################################################## +# Thread config files - One for each camera. +# Except if only one camera - You only need this config file. +# If you have more than one camera you MUST define one thread +# config file for each camera in addition to this config file. +############################################################## + +# Remember: If you have more than one camera you must have one +# thread file for each camera. E.g. 2 cameras requires 3 files: +# This motion.conf file AND thread1.conf and thread2.conf. +# Only put the options that are unique to each camera in the +# thread config files. +; thread /usr/local/etc/thread1.conf +; thread /usr/local/etc/thread2.conf +; thread /usr/local/etc/thread3.conf +; thread /usr/local/etc/thread4.conf + diff --git a/debian/motion.config b/debian/motion.config new file mode 100644 index 0000000..8ac1a4e --- /dev/null +++ b/debian/motion.config @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +if dpkg --compare-versions "$2" lt-nl "3.1.14-1"; then + db_input high motion/moved_conf_dir || true + db_go || true +fi + +exit 0 diff --git a/debian/motion.default b/debian/motion.default new file mode 100644 index 0000000..08ecd83 --- /dev/null +++ b/debian/motion.default @@ -0,0 +1,3 @@ +# set to 'yes' to enable the motion daemon +start_motion_daemon=no + diff --git a/debian/motion.postinst b/debian/motion.postinst new file mode 100644 index 0000000..77eaa4f --- /dev/null +++ b/debian/motion.postinst @@ -0,0 +1,44 @@ +#!/bin/sh +# postinst script for motion +# Made by Angel Carpintero + +set -e + + +. /usr/share/debconf/confmodule + +add_group_if_missing() { + if [ -x /usr/sbin/addgroup ]; then + if ! getent group motion >/dev/null; then + addgroup --system --force-badname motion || true + fi + fi +} + +add_user_if_missing() { + if [ -x /usr/sbin/adduser ]; then + if ! id -u motion > /dev/null 2>&1; then + adduser --system --no-create-home \ + --disabled-password \ + --force-badname motion \ + --ingroup motion + adduser motion video + fi + fi +} + +add_group_if_missing +add_user_if_missing + +# Fix motion.conf permission +chmod 0640 /etc/motion/motion.conf +chgrp motion /etc/motion/motion.conf + + +db_stop + +#DEBHELPER# + +exit 0 + + diff --git a/debian/motion.postinst.save b/debian/motion.postinst.save new file mode 100644 index 0000000..5e69130 --- /dev/null +++ b/debian/motion.postinst.save @@ -0,0 +1,53 @@ +#!/bin/sh +# postinst script for motion +# Made by Angel Carpintero + +set -e + + +. /usr/share/debconf/confmodule + +add_group_if_missing() { + if [ -x /usr/sbin/addgroup ]; then + if ! getent group motion >/dev/null; then + addgroup --force-badname motion || true + + fi + fi +} + +add_user_if_missing() { + if [ -x /usr/sbin/adduser ]; then + if ! id -u motion > /dev/null 2>&1; then + adduser --system --no-create-home \ + --disabled-password \ + --force-badname motion \ + --ingroup motion + adduser motion video + fi + fi +} + +create_pid_dir(){ + if ! [ -d /var/run/motion ]; then + mkdir /var/run/motion + fi + chown motion:motion /var/run/motion +} + +add_group_if_missing +add_user_if_missing +create_pid_dir + +# Fix motion.conf permission +chmod 0640 /etc/motion/motion.conf +chgrp motion /etc/motion/motion.conf + + +db_stop + +#DEBHELPER# + +exit 0 + + diff --git a/debian/motion.templates b/debian/motion.templates new file mode 100644 index 0000000..318ef4b --- /dev/null +++ b/debian/motion.templates @@ -0,0 +1,11 @@ +Template: motion/moved_conf_dir +Type: note +_Description: Location of Motion's config files has changed + The default location of Motion's configuration files has moved from /etc/ + to /etc/motion/. So if you already have a motion.conf in /etc/ from a + previous installation of Motion, you should move this to /etc/motion/ in + order for it to take effect whenever Motion is used. + . + The same thing goes for any thread*.conf files you may have. You should + move these to /etc/motion/ as well (in this case, also remember to update + the path to the thread*.conf files inside motion.conf). diff --git a/debian/patches/01_videodev.h.diff b/debian/patches/01_videodev.h.diff new file mode 100644 index 0000000..25344ab --- /dev/null +++ b/debian/patches/01_videodev.h.diff @@ -0,0 +1,27 @@ +Index: motion-3.2.12/video.h +=================================================================== +--- motion-3.2.12.orig/video.h 2011-08-23 15:42:35.564656448 -0430 ++++ motion-3.2.12/video.h 2011-08-23 15:43:10.860657024 -0430 +@@ -12,7 +12,7 @@ + + #define _LINUX_TIME_H 1 + #ifndef WITHOUT_V4L +-#include ++#include + #include + #include "pwc-ioctl.h" + #endif +Index: motion-3.2.12/motion.h +=================================================================== +--- motion-3.2.12.orig/motion.h 2011-08-23 15:44:46.108655912 -0430 ++++ motion-3.2.12/motion.h 2011-08-23 15:45:21.240655678 -0430 +@@ -40,7 +40,8 @@ + + #define _LINUX_TIME_H 1 + #if !defined(WITHOUT_V4L) && !defined(BSD) +-#include ++#include ++#include + #endif + + #include diff --git a/debian/patches/020101107~5273773.patch b/debian/patches/020101107~5273773.patch new file mode 100644 index 0000000..56c83c4 --- /dev/null +++ b/debian/patches/020101107~5273773.patch @@ -0,0 +1,95 @@ +Description: Fix FFmpeg guess_format() deprecation warning +Author: Angel Carpintero +Origin: Upstream, https://github.com/sackmotion/motion/commit/527377#svn517 +Last-Update: 2012-02-12 + +--- a/ffmpeg.c ++++ b/ffmpeg.c +@@ -36,6 +36,11 @@ + # endif /* __GNUC__ */ + #endif /* LIBAVCODEC_BUILD > 4680 */ + ++#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR ++#if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 ++ #define GUESS_NO_DEPRECATED ++#endif ++#endif + + #if LIBAVFORMAT_BUILD >= 4616 + /* The API for av_write_frame changed with FFmpeg version 0.4.9pre1. +@@ -258,7 +263,11 @@ + /* We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would + * result in a muxed output file, which isn't appropriate here. + */ +- of = guess_format("mpeg1video", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("mpeg1video", NULL, NULL); ++#endif + if (of) { + /* But we want the trailer to be correctly written. */ + of->write_trailer = mpeg1_write_trailer; +@@ -270,24 +279,44 @@ + #endif + } else if (strcmp(codec, "mpeg4") == 0) { + ext = ".avi"; +- of = guess_format("avi", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("avi", NULL, NULL); ++#endif + } else if (strcmp(codec, "msmpeg4") == 0) { + ext = ".avi"; +- of = guess_format("avi", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("avi", NULL, NULL); ++#endif + if (of) { + /* Manually override the codec id. */ + of->video_codec = CODEC_ID_MSMPEG4V2; + } + } else if (strcmp(codec, "swf") == 0) { + ext = ".swf"; +- of = guess_format("swf", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("swf", NULL, NULL); ++#endif + } else if (strcmp(codec, "flv") == 0) { + ext = ".flv"; +- of = guess_format("flv", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("flv", NULL, NULL); ++#endif + of->video_codec = CODEC_ID_FLV1; + } else if (strcmp(codec, "ffv1") == 0) { + ext = ".avi"; +- of = guess_format("avi", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("avi", NULL, NULL); ++#endif + if (of) { + /* Use the FFMPEG Lossless Video codec (experimental!). + Requires strict_std_compliance to be <= -2 */ +@@ -295,7 +324,11 @@ + } + } else if (strcmp(codec, "mov") == 0) { + ext = ".mov"; +- of = guess_format("mov", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("mov", NULL, NULL); ++#endif + } else { + motion_log(LOG_ERR, 0, "ffmpeg_video_codec option value %s is not supported", codec); + return NULL; diff --git a/debian/patches/020111022~58627b0.patch b/debian/patches/020111022~58627b0.patch new file mode 100644 index 0000000..480819d --- /dev/null +++ b/debian/patches/020111022~58627b0.patch @@ -0,0 +1,141 @@ +Description: Improve detection of av_register_protocol() for ffmpeg. +Author: Angel Carpintero +Origin: Upstream, https://github.com/sackmotion/motion/commit/7aec4b#svn538 +Last-Update: 2012-02-12 + +--- a/configure.in ++++ b/configure.in +@@ -316,7 +316,7 @@ + # + else if test "${FFMPEG_DIR}" = "yes"; then + # AUTODETECT STATIC/SHARED LIB +- AC_MSG_CHECKING(for ffmpeg autodetecting) ++ AC_MSG_CHECKING(for ffmpeg autodetecting libraries) + + if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib64) +@@ -347,7 +347,7 @@ + echo "" + fi + else +- AC_MSG_CHECKING(for ffmpeg in -> [${FFMPEG_DIR}] <-) ++ AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) + if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then + AC_MSG_RESULT(found) + FFMPEG_OK="found" +@@ -392,9 +392,11 @@ + elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then + AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" + elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then + AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" + else + AC_MSG_RESULT(not found) + FFMPEG_OK="no_found" +@@ -423,9 +425,11 @@ + AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS +- CFLAGS="${FFMPEG_CFLAGS}" ++ ++ ++ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" + LIBS="$TEMP_LIBS" +- ++ + AC_COMPILE_IFELSE( + [ + #include +@@ -442,7 +446,35 @@ + ] + ) + CFLAGS=$saved_CFLAGS +- LIBS=$saved_LIBS ++ LIBS=$saved_LIBS ++ ++ AC_MSG_CHECKING([av_register_protocol is defined in ffmpeg ?]) ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" ++ LIBS="$TEMP_LIBS" ++ ++ AC_COMPILE_IFELSE( ++ [ ++ #include ++ URLProtocol test_file_protocol; ++ int main(void){ ++ av_register_protocol(&test_file_protocol); ++ return 0; ++ } ++ ], ++ [ ++ AC_MSG_RESULT(yes) ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL" ++ ], ++ [ ++ AC_MSG_RESULT(no) ++ ] ++ ) ++ ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++ + fi + fi + fi +--- a/ffmpeg.c ++++ b/ffmpeg.c +@@ -232,11 +232,11 @@ + mpeg1_file_protocol.url_seek = file_protocol.url_seek; + mpeg1_file_protocol.url_close = file_protocol.url_close; + +- /* Register the append file protocol. */ +-#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) ++/* Register the append file protocol. */ ++#ifdef HAVE_FFMPEG_AV_REGISTER_PROTOCOL + av_register_protocol(&mpeg1_file_protocol); + #else +- register_protocol(&mpeg1_file_protocol); ++ av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); + #endif + } + +@@ -410,7 +410,11 @@ + + ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); + c->codec_id = ffmpeg->oc->oformat->video_codec; ++#if LIBAVCODEC_VERSION_MAJOR < 53 + c->codec_type = CODEC_TYPE_VIDEO; ++#else ++ c->codec_type = AVMEDIA_TYPE_VIDEO; ++#endif + is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; + + if (strcmp(ffmpeg_video_codec, "ffv1") == 0) +@@ -679,7 +683,11 @@ + if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { + /* raw video case. The API will change slightly in the near future for that */ + #ifdef FFMPEG_AVWRITEFRAME_NEWAPI ++#if LIBAVCODEC_VERSION_MAJOR < 53 + pkt.flags |= PKT_FLAG_KEY; ++#else ++ pkt.flags |= AV_PKT_FLAG_KEY; ++#endif + pkt.data = (uint8_t *)pic; + pkt.size = sizeof(AVPicture); + ret = av_write_frame(ffmpeg->oc, &pkt); +@@ -700,7 +708,11 @@ + #ifdef FFMPEG_AVWRITEFRAME_NEWAPI + pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; + if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) { ++#if LIBAVCODEC_VERSION_MAJOR < 53 + pkt.flags |= PKT_FLAG_KEY; ++#else ++ pkt.flags |= AV_PKT_FLAG_KEY; ++#endif + } + pkt.data = ffmpeg->video_outbuf; + pkt.size = out_size; diff --git a/debian/patches/020111022~734155f.patch b/debian/patches/020111022~734155f.patch new file mode 100644 index 0000000..1d6be19 --- /dev/null +++ b/debian/patches/020111022~734155f.patch @@ -0,0 +1,35 @@ +Description: Fix avoid crash producing MPEG4 with newer FFmpeg. +Author: Angel Carpintero +Origin: Upstream, https://github.com/sackmotion/motion/commit/734155#svn539 +Bug: http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 +Last-Update: 2012-02-12 + +--- a/configure.in ++++ b/configure.in +@@ -1099,6 +1099,10 @@ + LIBS="${TEMP_LIBS}" + LDFLAGS="${TEMP_LDFLAGS}" + ++ ++AC_CHECK_FUNC(avformat_alloc_context, AC_DEFINE([have_avformat_alloc_context],1,[Define to 1 if you have avformat_alloc_context support])) ++AC_CHECK_FUNC(av_avformat_alloc_context, AC_DEFINE([have_av_avformat_alloc_context],1,[Define to 1 if you have av_avformat_alloc_context support])) ++ + # + # Add the right exec path for rc scripts + # +--- a/ffmpeg.c ++++ b/ffmpeg.c +@@ -373,7 +373,13 @@ + snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); + + /* allocation the output media context */ ++#ifdef have_avformat_alloc_context ++ ffmpeg->oc = avformat_alloc_context(); ++#elif defined have_av_avformat_alloc_context ++ ffmpeg->oc = av_alloc_format_context(); ++#else + ffmpeg->oc = av_mallocz(sizeof(AVFormatContext)); ++#endif + + if (!ffmpeg->oc) { + motion_log(LOG_ERR, 1, "Memory error while allocating output media context"); diff --git a/debian/patches/020111027~5dd9ed4.patch b/debian/patches/020111027~5dd9ed4.patch new file mode 100644 index 0000000..05abd9e --- /dev/null +++ b/debian/patches/020111027~5dd9ed4.patch @@ -0,0 +1,68 @@ +Description: Improve av_register_protocol2()/av_register_protocol() detection +Author: Angel Carpintero +Origin: Upstream, https://github.com/sackmotion/motion/commit/5dd9ed#svn540#svn540 +Last-Update: 2012-02-12 + +--- a/configure.in ++++ b/configure.in +@@ -448,33 +448,6 @@ + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + +- AC_MSG_CHECKING([av_register_protocol is defined in ffmpeg ?]) +- saved_CFLAGS=$CFLAGS +- saved_LIBS=$LIBS +- CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" +- LIBS="$TEMP_LIBS" +- +- AC_COMPILE_IFELSE( +- [ +- #include +- URLProtocol test_file_protocol; +- int main(void){ +- av_register_protocol(&test_file_protocol); +- return 0; +- } +- ], +- [ +- AC_MSG_RESULT(yes) +- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL" +- ], +- [ +- AC_MSG_RESULT(no) +- ] +- ) +- +- CFLAGS=$saved_CFLAGS +- LIBS=$saved_LIBS +- + fi + fi + fi +@@ -1102,6 +1075,9 @@ + + AC_CHECK_FUNC(avformat_alloc_context, AC_DEFINE([have_avformat_alloc_context],1,[Define to 1 if you have avformat_alloc_context support])) + AC_CHECK_FUNC(av_avformat_alloc_context, AC_DEFINE([have_av_avformat_alloc_context],1,[Define to 1 if you have av_avformat_alloc_context support])) ++AC_CHECK_FUNC(av_register_protocol2, AC_DEFINE([have_av_register_protocol2],1,[Define to 1 if you have av_register_protocol2 support])) ++AC_CHECK_FUNC(av_register_protocol, AC_DEFINE([have_av_register_protocol],1,[Define to 1 if you have av_register_protocol support])) ++ + + # + # Add the right exec path for rc scripts +--- a/ffmpeg.c ++++ b/ffmpeg.c +@@ -233,10 +233,12 @@ + mpeg1_file_protocol.url_close = file_protocol.url_close; + + /* Register the append file protocol. */ +-#ifdef HAVE_FFMPEG_AV_REGISTER_PROTOCOL ++#ifdef have_av_register_protocol2 ++ av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); ++#elif defined have_av_register_protocol + av_register_protocol(&mpeg1_file_protocol); + #else +- av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); ++# warning av_register_protocolXXX missing + #endif + } + diff --git a/debian/patches/020120717~0fb31d.patch b/debian/patches/020120717~0fb31d.patch new file mode 100644 index 0000000..e69de29 diff --git a/debian/patches/02_libav_multiarch.patch b/debian/patches/02_libav_multiarch.patch new file mode 100644 index 0000000..3c8f8d8 --- /dev/null +++ b/debian/patches/02_libav_multiarch.patch @@ -0,0 +1,20 @@ +Description: Autodetect multiarch libavcodec path in autoconf. +Author: Stephen Kitt +Last-Update: 2012-02-12 + +--- a/configure.in ++++ b/configure.in +@@ -318,7 +318,12 @@ + # AUTODETECT STATIC/SHARED LIB + AC_MSG_CHECKING(for ffmpeg autodetecting libraries) + +- if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then ++ if test -f /usr/lib/$(dpkg-architecture -qDEB_BUILD_MULTIARCH)/libavcodec.so ; then ++ AC_MSG_RESULT(found in /usr/lib/$(dpkg-architecture -qDEB_BUILD_MULTIARCH)) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib/$(dpkg-architecture -qDEB_BUILD_MULTIARCH)" ++ FFMPEG_DIR="/usr" ++ elif test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib64) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib64" diff --git a/debian/patches/copy-old-api.patch b/debian/patches/copy-old-api.patch new file mode 100644 index 0000000..00a9f11 --- /dev/null +++ b/debian/patches/copy-old-api.patch @@ -0,0 +1,76 @@ +Description: Copy old API items we still depend on + As per doc/APIchanges in libav/ffmpeg, URLContext/URLProtocol were dropped + from the public API of libavformat since 52.107.0. Pending a better solution + from motion upstream, we copy the definitions here. +Author: Ximin Luo +Bug: https://github.com/sackmotion/motion/issues/15 + +--- a/ffmpeg.c ++++ b/ffmpeg.c +@@ -15,6 +15,66 @@ + #include "ffmpeg.h" + #include "motion.h" + ++#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(52,107,0) ++/* ++ * URLContext, URLProtocol have been removed from avio.h ++ * ++ */ ++ ++typedef struct URLContext { ++ const AVClass *av_class; /**< information for av_log(). Set by url_open(). */ ++ struct URLProtocol *prot; ++ void *priv_data; ++ char *filename; /**< specified URL */ ++ int flags; ++ int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ ++ int is_streamed; /**< true if streamed (no seek possible), default = false */ ++ int is_connected; ++ AVIOInterruptCB interrupt_callback; ++ int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in mcs */ ++} URLContext; ++ ++typedef struct URLProtocol { ++ const char *name; ++ int (*url_open)( URLContext *h, const char *url, int flags); ++ /** ++ * This callback is to be used by protocols which open further nested ++ * protocols. options are then to be passed to ffurl_open()/ffurl_connect() ++ * for those nested protocols. ++ */ ++ int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); ++ ++ /** ++ * Read data from the protocol. ++ * If data is immediately available (even less than size), EOF is ++ * reached or an error occurs (including EINTR), return immediately. ++ * Otherwise: ++ * In non-blocking mode, return AVERROR(EAGAIN) immediately. ++ * In blocking mode, wait for data/EOF/error with a short timeout (0.1s), ++ * and return AVERROR(EAGAIN) on timeout. ++ * Checking interrupt_callback, looping on EINTR and EAGAIN and until ++ * enough data has been read is left to the calling function; see ++ * retry_transfer_wrapper in avio.c. ++ */ ++ int (*url_read)( URLContext *h, unsigned char *buf, int size); ++ int (*url_write)(URLContext *h, const unsigned char *buf, int size); ++ int64_t (*url_seek)( URLContext *h, int64_t pos, int whence); ++ int (*url_close)(URLContext *h); ++ struct URLProtocol *next; ++ int (*url_read_pause)(URLContext *h, int pause); ++ int64_t (*url_read_seek)(URLContext *h, int stream_index, ++ int64_t timestamp, int flags); ++ int (*url_get_file_handle)(URLContext *h); ++ int (*url_get_multi_file_handle)(URLContext *h, int **handles, ++ int *numhandles); ++ int (*url_shutdown)(URLContext *h, int flags); ++ int priv_data_size; ++ const AVClass *priv_data_class; ++ int flags; ++ int (*url_check)(URLContext *h, int mask); ++} URLProtocol; ++#endif ++ + #if LIBAVCODEC_BUILD > 4680 + /* FFmpeg after build 4680 doesn't have support for mpeg1 videos with + * non-standard framerates. Previous builds contained a broken hack diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..7cbb68a --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,8 @@ +020101107~5273773.patch +020111022~58627b0.patch +020111022~734155f.patch +020111027~5dd9ed4.patch +01_videodev.h.diff +02_libav_multiarch.patch +use-new-api.patch +copy-old-api.patch diff --git a/debian/patches/use-new-api.patch b/debian/patches/use-new-api.patch new file mode 100644 index 0000000..a5f59b4 --- /dev/null +++ b/debian/patches/use-new-api.patch @@ -0,0 +1,165 @@ +Description: Fix build for newer ffmpeg/libav API + Upgrade to the newer ffmpeg/libav API in current unstable Debian/DMO. This is + a cut-down version of https://github.com/sackmotion/motion/commit/0fb31d#diff-3 + which is a more proper fix (it detects versions correctly) but it does not + apply to the orig tarball in Debian. +Author: Ximin Luo +Forwarded: not-needed + +--- a/ffmpeg.c ++++ b/ffmpeg.c +@@ -89,9 +89,9 @@ + filename = colon + 1; + + +- if (flags & URL_RDWR) { ++ if (flags & AVIO_FLAG_READ_WRITE) { + access_flags = O_CREAT | O_APPEND | O_RDWR; +- } else if (flags & URL_WRONLY) { ++ } else if (flags & AVIO_FLAG_WRITE) { + access_flags = O_CREAT | O_APPEND | O_WRONLY; + } else { + access_flags = O_RDONLY; +@@ -106,10 +106,10 @@ + } + + /* URLProtocol entry for the append file protocol, which we use for mpeg1 videos +- * in order to get append behavior with url_fopen. ++ * in order to get append behavior with avio_open. + * + * Libavformat uses protocols for achieving flexibility when handling files +- * and other resources. A call to url_fopen will eventually be redirected to ++ * and other resources. A call to avio_open will eventually be redirected to + * a protocol-specific open function. + * + * The remaining functions (for writing, seeking etc.) are set in ffmpeg_init. +@@ -139,9 +139,9 @@ + + av_strstart(filename, "file:", &filename); + +- if (flags & URL_RDWR) { ++ if (flags & AVIO_FLAG_READ_WRITE) { + access_flags = O_CREAT | O_TRUNC | O_RDWR; +- } else if (flags & URL_WRONLY) { ++ } else if (flags & AVIO_FLAG_WRITE) { + access_flags = O_CREAT | O_TRUNC | O_WRONLY; + } else { + access_flags = O_RDONLY; +@@ -204,11 +204,11 @@ + static int mpeg1_write_trailer(AVFormatContext *s) + { + #if LIBAVFORMAT_BUILD >= (52<<16) +- put_buffer(s->pb, mpeg1_trailer, 4); +- put_flush_packet(s->pb); ++ avio_write(s->pb, mpeg1_trailer, 4); ++ avio_flush(s->pb); + #else +- put_buffer(&s->pb, mpeg1_trailer, 4); +- put_flush_packet(&s->pb); ++ avio_write(&s->pb, mpeg1_trailer, 4); ++ avio_flush(&s->pb); + #endif /* LIBAVFORMAT_BUILD >= (52<<16) */ + + return 0; /* success */ +@@ -403,9 +403,9 @@ + ffmpeg->video_st = NULL; + + if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { +- ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); ++ ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, 0); + if (!ffmpeg->video_st) { +- motion_log(LOG_ERR, 1, "av_new_stream - could not alloc stream"); ++ motion_log(LOG_ERR, 1, "avformat_new_stream - could not alloc stream"); + ffmpeg_cleanups(ffmpeg); + return NULL; + } +@@ -461,13 +461,6 @@ + c->flags |= CODEC_FLAG_GLOBAL_HEADER; + } + +- /* set the output parameters (must be done even if no parameters). */ +- if (av_set_parameters(ffmpeg->oc, NULL) < 0) { +- motion_log(LOG_ERR, 0, "ffmpeg av_set_parameters error: Invalid output format parameters"); +- ffmpeg_cleanups(ffmpeg); +- return NULL; +- } +- + /* Dump the format settings. This shows how the various streams relate to each other */ + //dump_format(ffmpeg->oc, 0, filename, 1); + +@@ -488,7 +481,7 @@ + pthread_mutex_lock(&global_lock); + + /* open the codec */ +- if (avcodec_open(c, codec) < 0) { ++ if (avcodec_open2(c, codec, NULL) < 0) { + /* Release the lock. */ + pthread_mutex_unlock(&global_lock); + motion_log(LOG_ERR, 1, "avcodec_open - could not open codec"); +@@ -535,7 +528,7 @@ + char file_proto[256]; + + /* Use append file protocol for mpeg1, to get the append behavior from +- * url_fopen, but no protocol (=> default) for other codecs. ++ * avio_open, but no protocol (=> default) for other codecs. + */ + if (is_mpeg1) + snprintf(file_proto, sizeof(file_proto), APPEND_PROTO ":%s", filename); +@@ -543,7 +536,7 @@ + snprintf(file_proto, sizeof(file_proto), "%s", filename); + + +- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { ++ if (avio_open(&ffmpeg->oc->pb, file_proto, AVIO_FLAG_WRITE) < 0) { + /* path did not exist? */ + if (errno == ENOENT) { + /* create path for file (don't use file_proto)... */ +@@ -553,15 +546,15 @@ + } + + /* and retry opening the file (use file_proto) */ +- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { +- motion_log(LOG_ERR, 1, "url_fopen - error opening file %s",filename); ++ if (avio_open(&ffmpeg->oc->pb, file_proto, AVIO_FLAG_WRITE) < 0) { ++ motion_log(LOG_ERR, 1, "avio_open - error opening file %s",filename); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + /* Permission denied */ + } else if (errno == EACCES) { + motion_log(LOG_ERR, 1, +- "url_fopen - error opening file %s" ++ "avio_open - error opening file %s" + " ... check access rights to target directory", filename); + ffmpeg_cleanups(ffmpeg); + return NULL; +@@ -574,7 +567,7 @@ + } + + /* write the stream header, if any */ +- av_write_header(ffmpeg->oc); ++ avformat_write_header(ffmpeg->oc, NULL); + + return ffmpeg; + } +@@ -605,7 +598,7 @@ + /* + if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { + // close the output file +- if (ffmpeg->oc->pb) url_fclose(&ffmpeg->oc->pb); ++ if (ffmpeg->oc->pb) avio_close(&ffmpeg->oc->pb); + } + */ + /* free the stream */ +@@ -641,9 +634,9 @@ + if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { + /* close the output file */ + #if LIBAVFORMAT_BUILD >= (52<<16) +- url_fclose(ffmpeg->oc->pb); ++ avio_close(ffmpeg->oc->pb); + #else +- url_fclose(&ffmpeg->oc->pb); ++ avio_close(&ffmpeg->oc->pb); + #endif /* LIBAVFORMAT_BUILD >= (52<<16) */ + } + diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 0000000..62d7790 --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] motion.templates diff --git a/debian/po/cs.po b/debian/po/cs.po new file mode 100644 index 0000000..988ec24 --- /dev/null +++ b/debian/po/cs.po @@ -0,0 +1,55 @@ +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# +msgid "" +msgstr "" +"Project-Id-Version: motion\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2005-05-07 13:05+0200\n" +"Last-Translator: Mireoslav Kure \n" +"Language-Team: Czech \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "UmístÄ›ní konfiguraÄních souborů programu Motion se zmÄ›nilo" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"Výchozí umístÄ›ní konfiguraÄních souborů programu Motion se pÅ™esunulo z /etc/ " +"do /etc/motion/. Pokud již máte motion.conf ze starší instalace v /etc/, " +"mÄ›li byste jej pÅ™esunout do /etc/motion/, by ho mohl nový Motion využívat." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"To stejné platí pro libovolné soubory thread*.conf, které byste v /etc/ " +"nalezli. Po jejich pÅ™esunu do /etc/motion/ nezapomeňte v motion.conf zmÄ›nit " +"cestu k tÄ›mto souborům." diff --git a/debian/po/da.po b/debian/po/da.po new file mode 100644 index 0000000..b00c4d8 --- /dev/null +++ b/debian/po/da.po @@ -0,0 +1,61 @@ +# translation of templates.po to +# translation of templates.po to +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Developers do not need to manually edit POT or PO files. +# Frederik Dannemare , 2004. +# +msgid "" +msgstr "" +"Project-Id-Version: templates\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2004-06-30 14:05+0200\n" +"Last-Translator: Frederik Dannemare \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: KBabel 1.3.1\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Placering af Motions konfigurationsfiler er ændret" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"Standardplaceringen af Motions konfigurationsfiler er flyttet fra /etc/ til /" +"etc/motion/. Hvis du allerede har en motion.conf i /etc/ fra en tidligere " +"installation af Motion, bør du flytte denne til /etc/motion/, sÃ¥ Motion er i " +"stand til at finde og bruge den." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Det samme gør sig gældende for de thread*.conf-filer, du mÃ¥ske har. Disse " +"bør ligeledes flyttes til /etc/motion/ (i dette tilfælde skal du huske ogsÃ¥ " +"at opdatere stien til thread*.conf-filerne angivet i motion.conf)." diff --git a/debian/po/de.po b/debian/po/de.po new file mode 100644 index 0000000..312dbbc --- /dev/null +++ b/debian/po/de.po @@ -0,0 +1,58 @@ +# translation of de.po to German +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans# +# Developers do not need to manually edit POT or PO files. +# Jens Nachtigall , 2004. +# +msgid "" +msgstr "" +"Project-Id-Version: de\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2004-11-26 00:32+0100\n" +"Last-Translator: Jens Nachtigall \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.9.1\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Der Ort der Motion-Konfigurationsdatei hat sich geändert" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"Der Standard-Ort von Motions Konfigurationsdatei wurde von /etc/ zu /etc/" +"motion/ geändert. Wenn Sie also von einer früheren Motion-Installation " +"bereits eine motion.conf in /etc/ haben, dann sollten Sie diese nach /etc/" +"motion/ verschieben, damit Motion diese Datei auch verwendet." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Das gleiche gilt für jede thread*.conf-Datei, die Sie eventuell haben. Sie " +"sollten diese ebenfalls nach /etc/motion/ verschieben (in diesem Fall denken " +"Sie bitte auch daran, in der motion.conf den Pfad zu den thread*.conf-" +"Dateien anzupassen)." diff --git a/debian/po/es.po b/debian/po/es.po new file mode 100644 index 0000000..f198050 --- /dev/null +++ b/debian/po/es.po @@ -0,0 +1,78 @@ +# motion po-debconf translation to spanish +# This file is distributed under the same license as the XXXX package. +# +# Changes: +# - Initial translation +# Jose Ignacio Méndez González +# - Revision +# Fernando Cerezal +# Javier Fernández-Sanguino +# +# +# Traductores, si no conoce el formato PO, merece la pena leer la +# documentación de gettext, especialmente las secciones dedicadas a este +# formato, por ejemplo ejecutando: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Equipo de traducción al español, por favor lean antes de traducir +# los siguientes documentos: +# +# - El proyecto de traducción de Debian al español +# http://www.debian.org/intl/spanish/ +# especialmente las notas y normas de traducción en +# http://www.debian.org/intl/spanish/notas +# +# - La guía de traducción de po's de debconf: +# /usr/share/doc/po-debconf/README-trans +# o http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Si tiene dudas o consultas sobre esta traducción consulte con el último +# traductor (campo Last-Translator) y ponga en copia a la lista de +# traducción de Debian al español () +# +msgid "" +msgstr "" +"Project-Id-Version: motion VERSION\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2006-12-28 11:32+0100\n" +"Last-Translator: Jose Ignacio Méndez González \n" +"Language-Team: Debian Spanish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Se ha cambiado la situación de los archivos de configuración de Motion" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"La situación por omisión de los archivos de configuración de Motion se ha " +"movido de /etc/ a /etc/motion/. Por tanto, si usted ya tiene un motion.conf " +"en /etc/ de una instalación anterior de Motion, debe mover éste a /etc/" +"motion/ para que se considere cuando se utilice Motion." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Lo mismo sucede para cualquier archivo thread*.conf que tenga. Usted debe " +"mover éstos también a /etc/motion/ (en este caso, recuerde también " +"actualizar la ruta de los archivos thread*.conf dentro del archivo motion." +"conf)." diff --git a/debian/po/fr.po b/debian/po/fr.po new file mode 100644 index 0000000..ca1caed --- /dev/null +++ b/debian/po/fr.po @@ -0,0 +1,56 @@ +# +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans# +# Developers do not need to manually edit POT or PO files. +# Olivier Trichet , 2004. +# +msgid "" +msgstr "" +"Project-Id-Version: motion_3.1.14-1\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2004-08-04 16:54+0200\n" +"Last-Translator: Olivier Trichet \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.3.1\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Changement de l'emplacement des fichiers de configuration" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"L'emplacement par défaut des fichiers de configuration de Motion n'est plus /" +"etc/ mais /etc/motion. En conséquence, si vous avez déjà un fichier motion." +"conf dans /etc/, d'une installation précédente, vous devriez le déplacer " +"vers /etc/motion/ afin que Motion puisse le prendre en compte." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Il en va de même pour les fichiers thread*.conf que vous pourriez avoir. " +"Vous devriez les déplacer vers /etc/motion/ ; dans ce cas, modifiez le " +"chemin vers ces fichiers thread*.conf dans motion.conf." diff --git a/debian/po/gl.po b/debian/po/gl.po new file mode 100644 index 0000000..7b8b2e9 --- /dev/null +++ b/debian/po/gl.po @@ -0,0 +1,48 @@ +# Galician translation of motion's debconf templates +# This file is distributed under the same license as the motion package. +# Jacobo Tarrio , 2008. +# +msgid "" +msgstr "" +"Project-Id-Version: motion\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2008-06-02 18:58+0100\n" +"Last-Translator: Jacobo Tarrio \n" +"Language-Team: Galician \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Cambiou a ubicación dos ficheiros de configuración de Motion" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"A ubicación por defecto dos ficheiros de configuración de Motion trasladouse " +"de /etc/ a /etc/motion/. Así que se xa ten un ficheiro motion.conf en /etc/ " +"dunha instalación anterior de Motion, debería trasladarlo a /etc/motion/ " +"para que tome efecto cando empregue Motion." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"O mesmo serve para os ficheiros thread*.conf que teña. Debería trasladalos " +"tamén a /etc/motion/ (neste caso, lembre actualizar a ruta aos ficheiros " +"thread*.conf en motion.conf)." + diff --git a/debian/po/it.po b/debian/po/it.po new file mode 100644 index 0000000..b9ae9dd --- /dev/null +++ b/debian/po/it.po @@ -0,0 +1,51 @@ +# ITALIAN TRANSLATION OF MOTION'S PO-DEBCONF FILE. +# COPYRIGHT (C) 2010 THE MOTION'S COPYRIGHT HOLDER +# This file is distributed under the same license as the motion package. +# Vincenzo Campanella , 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: motion\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2010-03-16 10:07+0100\n" +"Last-Translator: Vincenzo Campanella \n" +"Language-Team: Italian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "La posizione dei file di configurazione di Motion è stata modificata" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"La posizione predefinita dei file di configurazione di Motion è stata " +"spostata da «/etc/» a «/etc/motion». Pertanto, se si possiede già una " +"configurazione di Motion in «/etc/» da una precedente installazione, la si " +"dovrebbe spostare in «/etc/motion» affinché possa funzionare quando Motion " +"viene utilizzato." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Lo stesso vale per qualsiasi file di configurazione «thread*.conf»: se se ne " +"hanno, li si dovrebbe spostare a loro volta in «/etc/motion/». In tal caso, " +"ricordarsi anche di aggiornare il percorso dei file di configurazione " +"«thread*.conf» all'interno di «motion.conf»." + diff --git a/debian/po/ja.po b/debian/po/ja.po new file mode 100644 index 0000000..fdcc6f3 --- /dev/null +++ b/debian/po/ja.po @@ -0,0 +1,47 @@ +# Japanese debconf templates translation for motion. +# Copyright (C) 2007 Noritada Kobayashi +# This file is distributed under the same license as the motion package. +# +msgid "" +msgstr "" +"Project-Id-Version: motion (debconf) 3.2.3-2\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2007-03-01 17:18+0900\n" +"Last-Translator: Noritada Kobayashi \n" +"Language-Team: Japanese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Motion ã®è¨­å®šãƒ•ァイルã®å ´æ‰€ãŒå¤‰ã‚りã¾ã—ãŸ" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"Motion ã®è¨­å®šãƒ•ァイルã®ãƒ‡ãƒ•ォルトã®å ´æ‰€ãŒã€/etc/ ã‹ã‚‰ /etc/motion/ ã«å¤‰æ›´ã•れ" +"ã¾ã—ãŸã€‚ã—ãŸãŒã£ã¦ã€ä»¥å‰ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—㟠Motion ã® motion.conf ㌠/etc/ ã«æ—¢" +"ã«å­˜åœ¨ã—ã¦ã„ã‚‹å ´åˆã¯ã€Motion を使用ã™ã‚‹ã¨ãã«ã„ã¤ã§ã‚‚ãã®ãƒ•ã‚¡ã‚¤ãƒ«ãŒæœ‰åйã«ãªã‚‹" +"よã†ã€ãƒ•ァイルを /etc/motion/ ã«ç§»å‹•ã—ã¦ãã ã•ã„。" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"ã‚らゆる thread*.conf ファイルã«ã¤ã„ã¦ã‚‚åŒã˜ã“ã¨ãŒè¨€ãˆã¾ã™ã€‚ã“れらã®ãƒ•ァイル" +"ã‚’åŒæ§˜ã« /etc/motion/ ã«ç§»å‹•ã—ã¦ãã ã•ã„ (ãã®éš›ã€motion.conf 内㮠thread*." +"conf ファイルã¸ã®ãƒ‘スも忘れãšã«æ›´æ–°ã—ã¦ãã ã•ã„)。" diff --git a/debian/po/nl.po b/debian/po/nl.po new file mode 100644 index 0000000..2c0f2ae --- /dev/null +++ b/debian/po/nl.po @@ -0,0 +1,49 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: motion\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2007-03-07 20:50+0100\n" +"Last-Translator: Bart Cornelis \n" +"Language-Team: debian-l10n-dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Dutch\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "De locatie van Motion's configuratiebestanden is veranderd." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"De standaardlocatie van de configuratiebestanden van Motion is verplaatst " +"van /etc/ naar /etc/motion/. Mocht u al een motion.conf hebben van een " +"eerdere installatie van Motion in /etc/ dient u dit te verplaatsen naar /etc/" +"motion/ opdat dit effect heeft bij gebruik van Motion." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Hetzelfde geldt voor alle 'thread*.conf'-bestanden die u heeft. Ook deze " +"dient u te verplaatsen naar /etc/motion/ (vergeet niet om in dat geval ook " +"het pad naar de 'thread*.conf'-bestanden aan te passen in motion.conf)." diff --git a/debian/po/pt.po b/debian/po/pt.po new file mode 100644 index 0000000..afb3cb1 --- /dev/null +++ b/debian/po/pt.po @@ -0,0 +1,48 @@ +# Portuguese translation for motion debconf messages. +# Copyright (C) 2007 Pedro Ribeiro +# This file is distributed under the same license as the motion package. +# Pedro Ribeiro , 2007 +# +msgid "" +msgstr "" +"Project-Id-Version: motion 3.2.3-2.1\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2007-05-23 21:38+0100\n" +"Last-Translator: Pedro Ribeiro \n" +"Language-Team: Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "A localização dos ficheiros de configuração do Motion mudou" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"A localização padrão para os ficheiros de configuração do Motion mudou de /" +"etc/ para /etc/motion/. Portanto, se tem um ficheiro motion.conf em /etc/ de " +"uma instalação anterior do Motion, deve movê-lo para /etc/motion/ para que " +"seja usado quando executar Motion." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"A mesma situação aplica-se para qualquer ficheros thread*.conf que possa " +"ter. Deve movê-los também para /etc/motion/ (neste caso não se esqueça de " +"alterar o caminho para os ficheiros thread*.conf em motion.conf)." diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po new file mode 100644 index 0000000..6572227 --- /dev/null +++ b/debian/po/pt_BR.po @@ -0,0 +1,48 @@ +# motion Brazilian Portuguese translation. +# Copyright (C) 2007 motion's PACKAGE COPYRIGHT HOLDER +# This file is distributed under the same license as the motion package. +# Beraldo Leal , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: motion 3.2.3-2.1\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2007-10-03 17:32-0300\n" +"Last-Translator: Beraldo Leal \n" +"Language-Team: l10n portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "O local dos arquivos de configuração do Motion mudou" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"O local padrão dos arquivos de configuração do Motion foi movido de /etc/ " +"para /etc/motion/. Portanto, se você já possui um motion.conf em /etc/ de " +"uma instalação anterior do Motion, você deveria movê-lo para /etc/motion/ " +"para que tenha efeito sempre que o Motion for usado." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"O mesmo deve ser feito para quaisquer arquivos thread*.conf que você tenha. " +"Você também deveria movê-los para /etc/motion/ (neste caso, lembre-se também " +"de atualizar o caminho para os arquivos thread*.conf dentro de motion.conf)." diff --git a/debian/po/ru.po b/debian/po/ru.po new file mode 100644 index 0000000..1aad71e --- /dev/null +++ b/debian/po/ru.po @@ -0,0 +1,50 @@ +# translation of ru.po to Russian +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Yuri Kozlov , 2009. +msgid "" +msgstr "" +"Project-Id-Version: motion 3.2.11-1\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2009-07-17 18:13+0400\n" +"Last-Translator: Yuri Kozlov \n" +"Language-Team: Russian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" +"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "ИзменилоÑÑŒ раÑположение файлов наÑтройки Motion" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"Файлы наÑтройки Motion перенеÑены из /etc/ в /etc/motion/. ПоÑтому, еÑли у " +"Ð²Ð°Ñ ÐµÑть файл motion.conf в /etc/ от предыдущей уÑтановки Motion, " +"перемеÑтите его в каталог /etc/motion/ (чтобы Motion Ñнова начал " +"иÑпользовать его)." + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Это каÑаетÑÑ Ð¸ файлов thread*.conf. ПеремеÑтите их в /etc/motion/ (в Ñтом " +"Ñлучае, не забудьте иÑправить путь к файлам thread*.conf в motion.conf)." diff --git a/debian/po/sv.po b/debian/po/sv.po new file mode 100644 index 0000000..d786870 --- /dev/null +++ b/debian/po/sv.po @@ -0,0 +1,54 @@ +# Translators, if you are not familiar with the PO format, gettext +# documentation is worth reading, especially sections dedicated to +# this format, e.g. by running: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# Some information specific to po-debconf are available at +# /usr/share/doc/po-debconf/README-trans +# or http://www.debian.org/intl/l10n/po-debconf/README-trans +# Developers do not need to manually edit POT or PO files. +# , fuzzy +# +# +msgid "" +msgstr "" +"Project-Id-Version: motion 3.1.19-1\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2005-09-28 17:41-0700\n" +"Last-Translator: Daniel Nylander \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "Sökvägen till Motion's konfigurationsfiler har ändrats" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" +"Standard sökväg till Motion's konfigurationsfiler har flyttats från /etc/ " +"till /etc/motion/. Om du redan har en motion.conf i /etc/ från en tidigare " +"installation av Motion kan du flytta denna till /etc/motion/" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" +"Samma sak gäller för alla thread*.conf-filer som du har. Du bör flytta dessa " +"till /etc/motion/ (kom i håg att uppdatera sökvägen till thread*.conf-" +"filerna i motion.conf)." diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 0000000..eb5fc04 --- /dev/null +++ b/debian/po/templates.pot @@ -0,0 +1,42 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "Location of Motion's config files has changed" +msgstr "" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "" + +#. Type: note +#. Description +#: ../motion.templates:1001 +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "" diff --git a/debian/po/vi.po b/debian/po/vi.po new file mode 100644 index 0000000..14917f8 --- /dev/null +++ b/debian/po/vi.po @@ -0,0 +1,42 @@ +# Vietnamese translation for Motion. +# Copyright © 2010 Free Software Foundation, Inc. +# Clytie Siddall , 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: motion\n" +"Report-Msgid-Bugs-To: juan@apuntale.com\n" +"POT-Creation-Date: 2007-11-02 20:04-0400\n" +"PO-Revision-Date: 2010-04-01 16:59+1030\n" +"Last-Translator: Clytie Siddall \n" +"Language-Team: Vietnamese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: LocFactoryEditor 1.8\n" + +#: ../motion.templates:1001 +#. Type: note +#. Description +msgid "Location of Motion's config files has changed" +msgstr "Tập tin cấu hình Motion có vị trí khác" + +#: ../motion.templates:1001 +#. Type: note +#. Description +msgid "" +"The default location of Motion's configuration files has moved from /etc/ " +"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " +"previous installation of Motion, you should move this to /etc/motion/ in " +"order for it to take effect whenever Motion is used." +msgstr "Vị trí mặc định cá»§a các tập tin cấu hình Motion đã di chuyển từ « /etc/ » sang « /etc/motion/ ». Vì thế nếu bạn có má»™t tập tin « motion.conf » trong « /etc/ » từ má»™t bản cài đặt Motion trước thì bạn nên di chuyển nó sang « /etc/motion/ » để có tác động khi chạy Motion." + +#: ../motion.templates:1001 +#. Type: note +#. Description +msgid "" +"The same thing goes for any thread*.conf files you may have. You should move " +"these to /etc/motion/ as well (in this case, also remember to update the " +"path to the thread*.conf files inside motion.conf)." +msgstr "Tương tá»± vá»›i tập tin « thread*.conf » nào — di chuyển tập tin như vậy sang « /etc/motion/ ». Trong trưá»ng hợp này, cÅ©ng cần phải cập nhật đưá»ng dẫn đến các tập tin « thread*.conf » bên trong tập tin « motion.conf »." diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..fb6a47e --- /dev/null +++ b/debian/postrm @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +case "$1" in + + purge) + + rm -rf /etc/motion + userdel motion || true + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + + ;; + + *) + + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..b668bb2 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,34 @@ +#!/bin/sh + +set -e + +case "$1" in + + remove|remove-in-favour|deconfigure|deconfigure-in-favour) + + if [ -x /etc/init.d/motion ]; then + if [ -x /usr/sbin/invoke-rc.d ] ; then + invoke-rc.d motion stop + else + /etc/init.d/motion stop + fi + fi + + ;; + + upgrade|failed-upgrade) + + ;; + + *) + + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + + ;; + +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..56040d8 --- /dev/null +++ b/debian/rules @@ -0,0 +1,108 @@ +#!/usr/bin/make -f +# export DH_VERBOSE=1 + +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + +CFLAGS = -Wall -g +LDFLAGS = -Wl,--as-needed + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +config.status: + dh_testdir + dh_autoreconf + # Add here commands to configure the package. + CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure \ + --prefix=/usr \ + --bindir=\$${prefix}/bin \ + --build=${DEB_BUILD_GNU_TYPE} \ + --host=${DEB_HOST_GNU_TYPE} \ + --datadir=\$${prefix}/share \ + --mandir=\$${datadir}/man \ + --infodir=\$${datadir}/info \ + --sysconfdir=/etc/motion \ + --with-ffmpeg \ + --with-mysql \ + --with-mysql-lib=/usr/lib/$(DEB_HOST_MULTIARCH) \ + --with-pgsql \ + --without-optimizecpu \ + --without-jpeg-mmx + touch configure-stamp + +build: build-arch build-indep +build-arch: build-stamp +build-indep: build-stamp + +build-stamp: config.status + dh_testdir + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + -[ ! -f Makefile ] || $(MAKE) distclean + dh_autoreconf_clean + dh_clean + +install: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + # Add here commands to install the package into debian/motion. + $(MAKE) install DESTDIR=$(CURDIR)/debian/motion + # Offer a minimal default config file. + cp thread*.conf debian/motion/etc/motion + cp debian/NEWS debian/motion/usr/share/doc/motion + # Remove unwanted/misplaced files. + rm -rf $(CURDIR)/debian/motion/usr/share/doc/motion* + rm -f $(CURDIR)/debian/motion/etc/motion/motion-dist.conf + # Fix mode Daemon + cat $(CURDIR)/motion-dist.conf | sed 's/^daemon on/daemon off/g' > motion.conf + mv motion.conf $(CURDIR)/debian/motion/etc/motion/motion.conf + # Fix path directory for pictures and films + cat $(CURDIR)/debian/motion/etc/motion/motion.conf | sed 's/target_dir \/usr\/local\/apache2\/htdocs\/cam1/target_dir \/tmp\/motion/g' > motion.conf + mv motion.conf $(CURDIR)/debian/motion/etc/motion/motion.conf + # Fix default format encoding + cat $(CURDIR)/debian/motion/etc/motion/motion.conf | sed 's/^ffmpeg_video_codec mpeg4/ffmpeg_video_codec swf/g' > motion.conf + mv motion.conf $(CURDIR)/debian/motion/etc/motion/motion.conf + # Remove dir/files unnecessary + rm -rf $(CURDIR)/debian/motion/usr/share/motion-3.2.12 + +# Build architecture-independent files here. +binary-indep: build-stamp install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build-stamp install + dh_testdir + dh_testroot + dh_installchangelogs CHANGELOG + dh_installdocs + dh_installinit --init-script=motion \ + --update-rcd-params='start 60 2 3 4 5 . stop 60 0 1 6 .' + dh_installman debian/motion.1 + dh_installdebconf + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build-stamp clean binary-indep binary-arch binary install diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..29df717 --- /dev/null +++ b/debian/watch @@ -0,0 +1,4 @@ +version=3 +http://sf.net/motion/motion-(.*)\.tar\.gz + + From 9b42f85c04b270f9aef3ec01ccdb54f6cc063bc1 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 6 Sep 2014 14:18:16 -0700 Subject: [PATCH 043/233] Change some defaults for config file --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 96fd45b..ad9e4d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -87,6 +87,7 @@ Features * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 * Implement requirement of modulo 16 to avoid seg fault when opening stream * Add debian build files from trusty(14.04) + * Revise default values for motion.conf Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) From 4579bbb726cf82ca0a070e8cd78d92ca08e6cc7d Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 6 Sep 2014 17:22:29 -0700 Subject: [PATCH 044/233] Depoyed to ppa as 3.2.12-4ppa01~precise --- CHANGELOG | 11 +- debian/changelog | 134 + debian/control | 2 +- debian/motion.conf | 354 +- debian/motion.postinst | 2 +- debian/motion.postinst.save | 2 +- debian/patches/01_videodev.h.diff | 27 - debian/patches/020101107~5273773.patch | 95 - debian/patches/020111022~58627b0.patch | 141 - debian/patches/020111022~734155f.patch | 35 - debian/patches/020111027~5dd9ed4.patch | 68 - debian/patches/020120717~0fb31d.patch | 0 debian/patches/02_libav_multiarch.patch | 20 - debian/patches/copy-old-api.patch | 76 - debian/patches/github-changes | 48045 ++++++++++++++++++++++ debian/patches/series | 9 +- debian/patches/use-new-api.patch | 165 - motion-dist.conf.in | 6 +- 18 files changed, 48439 insertions(+), 753 deletions(-) delete mode 100644 debian/patches/01_videodev.h.diff delete mode 100644 debian/patches/020101107~5273773.patch delete mode 100644 debian/patches/020111022~58627b0.patch delete mode 100644 debian/patches/020111022~734155f.patch delete mode 100644 debian/patches/020111027~5dd9ed4.patch delete mode 100644 debian/patches/020120717~0fb31d.patch delete mode 100644 debian/patches/02_libav_multiarch.patch delete mode 100644 debian/patches/copy-old-api.patch create mode 100644 debian/patches/github-changes delete mode 100644 debian/patches/use-new-api.patch diff --git a/CHANGELOG b/CHANGELOG index ad9e4d5..28dfd80 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ -SVN trunk Summary of Changes - -Features + * + * Revised debian packaging files + * Implement new sequence for this file (CHANGELOG) newest to oldest. + * + * Features * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 (Jeroen Massar & Angel Carpintero) @@ -88,8 +90,9 @@ Features * Implement requirement of modulo 16 to avoid seg fault when opening stream * Add debian build files from trusty(14.04) * Revise default values for motion.conf + * Revise CHANGELOG to conform with debian format -Bugfixes + * Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 diff --git a/debian/changelog b/debian/changelog index 976c46e..e9aa3af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,137 @@ +motion (3.2.12-4ppa01~precise) precise; urgency=low + + * Nonmaintainer upload + * Due to conficts, removed patches (Mr Dave) + * Revise motion.postinst to put motion.conf at 0644 instead of 0640(Mr Dave) + * Many many changes from github repos of many many developers since 3.2.12 was released. + * + * Features + * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) + * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 + (Jeroen Massar & Angel Carpintero) + * Experimental approach for MJPEG streams (Motion JPEG) for network cameras + http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch ( ... ) + * Add draw a RED box around the movement as default (Joerg Weber) + * Add write/read nonblock functions in webhttpd( timeout on read/write). (Angel Carpintero) + * More changes in option names from http://www.lavrsen.dk/twiki/bin/view/Motion/IntuitiveOptionNamesDiscussion + (Angel Carpintero) + * motion_locate new parameter names : red , center , redcross instead of only on, off. (Angel Carpintero) + * External pipe to allow external video encoders + http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) + * Split locate_motion into separate 'mode' and 'style' option to allow all + possible combinations. (Joerg Weber) + * Implement 'gapless' event mode to allow for recording of movies without 'holes'. (Joerg Weber) + * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. (Joerg Weber) + * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. + http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 + Increased buffer in ffmpeg to allow encoding at 1600x1200 (Angel Carpintero) + * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch (Giacomo Graziosi) + * New RPM SPEC file and startup scripts compliant with Fedora 10 guidelines and above (Steven Moix) + * Increase write buffer size for writing image files and ffmpegs + http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionWriteBuffersPatch (Craig West) + * Fixed mask overlay in setup mode is now green instead of white (Joerg Weber) + * Add new config option 'ipv6_enabled' to enable/disable IPV6 (Angel Carpintero) + * Remove VIDIOC_S_JPEGCOMP support is deprecated. (Angel Carpintero) + * Use static memory allocation in ffmpeg_deinterlace() (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic + * Atom optimizacion in configure.in (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations + * Allow to change Standard method ( PAL / NECAM / SECAM ) (Angel Carpintero) + * Add authentication methods 'Basic Authentication' and 'Digest Authentication' + to the "Live Stream Server". (Michael Finsterbusch) + http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch + * Implemented new logging system + http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero) + * Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero) + * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis) + * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). + * 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) + * Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8. (Jeroen Massar) + * Added codec Ogg/Theora as new output format for regular movies. + http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) + * Added support for ffmpeg 0.11 new API. + * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) + * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) + * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) + * Buffer overflow vulnerabilities (hyperbolic2346) + * Redundand -- boundary prefix (torao) + * Removed compiler warnings: (Mr-Dave) + logger.c,jpegutils.c,netcam_ftp.c,track.c, + picture.c,webhttpd.c,stream.c,ffmpeg.c + * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) + * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) + * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) + * Resolve additional compiler warnings in ffmpeg (Mr-Dave) + * Revised INSTALL with samples(Mr-Dave) + * Revisions for RTSP and code standard.(Mr-Dave) + * Plugged most memory leaks in RTSP. (Mr-Dave) + * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) + * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) + * Regession fix for memory leaks and reconnection (Mr-Dave) + * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) + * Revised RTSP to support version 53 of libavformat (Mr-Dave) + * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) + * Revised INSTALL to have sample PI configure option.(Mr-Dave) + * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) + * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) + * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) + * Clean up the messaging for RTSP. + * Additional validations for RTSP connection and corrected free sequences + * Removed seg fault on failure to open first image, comments, isolation of RTSP + * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. + * Implement inits of AV functions from bcl fork + * Add gray image upon disconnection + * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) + * Revised comments to be in line with application standard. + * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format + * Revise version.sh to put out the git commit. + * Rollback revision to allow for a formal pull request. + * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 + * Implement requirement of modulo 16 to avoid seg fault when opening stream + * Add debian build files from trusty(14.04) + * Revise default values for motion.conf + * Revise CHANGELOG to conform with debian format + + * Bugfixes + * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) + * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 + * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) + * Avoid compile vloopback in BSD (Angel Carpintero) + * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. (Isaac Richter) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 + * 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) + * Fix introduced bug for Content-Lenght = 0 in svn r476. (Angel Carpintero) + * 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 + * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 (Angel Carpintero) + * Fix issue with JPEG , adding dinfo.do_fancy_upsampling = FALSE; + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x08x20x194659 + * Made micro-lightswitch optional (see lightwitch option in motion.conf) + * 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. + * Replace malloc() by calloc(). (Jeroen Massar) + * Free file descriptor buffers on exit. + * Avoid segfault when text_left or text_right uses non supported chars. + * Fixed leak in vloopback. + * Fixed a build of motion for some kernel version with not good videodev.h + * Netcam Modulo 8 + + -- Mr Dave Sat, 06 Sep 2014 14:26:03 -0700 + motion (3.2.12-4) unstable; urgency=medium * New maintainer. diff --git a/debian/control b/debian/control index 4075c3f..1a31bc8 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: graphics Priority: optional Maintainer: Ximin Luo HomePage: http://motion.sf.net -Build-Depends: debhelper (>= 6), dpkg-dev (>= 1.16), dh-autoreconf, libjpeg-dev, zlib1g-dev, libavcodec-dev, libavformat-dev, libpq-dev, libmysqlclient-dev (>= 5.5.17-4), libv4l-dev +Build-Depends: debhelper (>= 6), dpkg-dev (>= 1.16), dh-autoreconf, libjpeg-dev, zlib1g-dev, libavcodec-dev, libavformat-dev, libpq-dev, libmysqlclient-dev (>= 5.5.17-4), libv4l-dev, libswscale-dev Standards-Version: 3.9.2 Package: motion diff --git a/debian/motion.conf b/debian/motion.conf index c2b2ffb..10b9e28 100644 --- a/debian/motion.conf +++ b/debian/motion.conf @@ -1,6 +1,6 @@ # Rename this distribution example file to motion.conf # -# This config file was generated by motion 3.2.9 +# This config file was generated by motion 3.2.12-4ppa01 ############################################################ @@ -11,7 +11,7 @@ daemon off # File to store the process ID, also called pid file. (default: not defined) -process_id_file /var/run/motion.pid +process_id_file /var/run/motion/motion.pid ############################################################ # Basic Setup Mode @@ -20,6 +20,16 @@ process_id_file /var/run/motion.pid # Start in Setup-Mode, daemon disabled. (default: off) setup_mode off + +# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) +;logfile /tmp/motion.log + +# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) +log_level 6 + +# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) +log_type all + ########################################################### # Capture device options ############################################################ @@ -28,13 +38,42 @@ setup_mode off # for FreeBSD default is /dev/bktr0 videodevice /dev/video0 +# v4l2_palette allows to choose preferable palette to be use by motion +# to capture from those supported by your videodevice. (default: 17) +# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and +# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. +# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 +# instead. +# +# Values : +# V4L2_PIX_FMT_SN9C10X : 0 'S910' +# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' +# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' +# V4L2_PIX_FMT_SPCA561 : 3 'S561' +# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' +# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' +# V4L2_PIX_FMT_PAC207 : 6 'P207' +# V4L2_PIX_FMT_PJPG : 7 'PJPG' +# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' +# V4L2_PIX_FMT_JPEG : 9 'JPEG' +# V4L2_PIX_FMT_RGB24 : 10 'RGB3' +# V4L2_PIX_FMT_SPCA501 : 11 'S501' +# V4L2_PIX_FMT_SPCA505 : 12 'S505' +# V4L2_PIX_FMT_SPCA508 : 13 'S508' +# V4L2_PIX_FMT_UYVY : 14 'UYVY' +# V4L2_PIX_FMT_YUYV : 15 'YUYV' +# V4L2_PIX_FMT_YUV422P : 16 '422P' +# V4L2_PIX_FMT_YUV420 : 17 'YU12' +# +v4l2_palette 17 + # Tuner device to be used for capturing using tuner as source (default /dev/tuner0) # 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 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) @@ -44,7 +83,7 @@ norm 0 frequency 0 # Rotate image this number of degrees. The rotation affects all saved images as -# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270. +# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. rotate 0 # Image width (pixels). Valid range: Camera dependent, default: 352 @@ -62,7 +101,7 @@ framerate 2 # This option is used when you want to capture images at a rate lower than 2 per second. minimum_frame_time 0 -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) +# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ; netcam_url value @@ -70,10 +109,25 @@ minimum_frame_time 0 # Syntax is user:password ; netcam_userpass value +# The setting for keep-alive of network socket, should improve performance on compatible net cameras. +# off: The historical implementation using HTTP/1.0, closing the socket after each http request. +# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +# on: Use HTTP/1.1 requests that support keep alive as default. +# Default: off +netcam_keepalive off + # URL to use for a netcam proxy server, if required, e.g. "http://myproxy". # If a port number other than 80 is needed, use "http://myproxy:1234". # Default: not defined -; netcam_proxy value +; netcam_proxy value + +# Set less strict jpeg checks for network cameras with a poor/buggy firmware. +# Default: off +netcam_tolerant_check off + +# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. +# Default: on +rtsp_uses_tcp on # Let motion regulate the brightness of a video device (default: off). # The auto_brightness feature uses the brightness option as its target value. @@ -131,15 +185,18 @@ noise_level 32 # Automatically tune the noise threshold (default: on) noise_tune on -# Enables motion to adjust its detection/noise level for very dark frames -# Don't use this with noise_tune on. (default: off) -night_compensate off - # Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) # Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. # (l)abeling must only be used once and the 'l' must be the last letter. # Comment out to disable -despeckle EedDl +despeckle_filter EedDl + +# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 +# A script (on_area_detected) is started immediately when motion is 4 5 6 +# detected in one of the given areas, but only once during an event. 7 8 9 +# One or more areas can be specified with this option. Take care: This option +# does NOT restrict detection to these areas! (Default: not defined) +; area_detect value # PGM file to use as a sensitivity mask. # Full path name to. (Default: not defined) @@ -162,28 +219,26 @@ minimum_motion_frames 1 # was detected that will be output at motion detection. # Recommended range: 0 to 5 (default: 0) # Do not use large values! Large values will cause Motion to skip video frames and -# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. +# cause unsmooth movies. To smooth movies use larger values of post_capture instead. pre_capture 0 # Number of frames to capture after motion is no longer detected (default: 0) post_capture 0 -# Gap is the seconds of no motion detection that triggers the end of an event +# Event Gap is the seconds of no motion detection that triggers the end of an event. # An event is defined as a series of motion images taken within a short timeframe. -# Recommended value is 60 seconds (Default). The value 0 is allowed and disables -# events causing all Motion to be written to one single mpeg file and no pre_capture. -gap 60 - -# Maximum length in seconds of an mpeg movie -# When value is exceeded a new mpeg file is created. (Default: 0 = infinite) -max_mpeg_time 0 +# Recommended value is 60 seconds (Default). The value -1 is allowed and disables +# events causing all Motion to be written to one single movie file and no pre_capture. +# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An +# event ends right after no more motion is detected and post_capture is over. +event_gap 60 -# Number of frames per second to capture when not detecting -# motion (saves CPU load) (Default: 0 = disabled) -low_cpu 0 +# Maximum length in seconds of a movie +# When value is exceeded a new movie file is created. (Default: 0 = infinite) +max_movie_time 0 # Always save images even if there was no motion (default: off) -output_all off +emulate_motion off ############################################################ @@ -191,37 +246,38 @@ output_all off ############################################################ # Output 'normal' pictures when motion is detected (default: on) -# Valid values: on, off, first, best +# Valid values: on, off, first, best, center # When set to 'first', only the first picture of an event is saved. # Picture with most motion of an event is saved when set to 'best'. +# Picture with motion nearest center of picture is saved when set to 'center'. # Can be used as preview shot for the corresponding movie. -output_normal on +output_pictures on # Output pictures with only the pixels moving object (ghost images) (default: off) -output_motion off +output_debug_pictures off # The quality (in percent) to be used by the jpeg compression (default: 75) quality 75 -# Output ppm images instead of jpeg (default: off) -ppm off - +# Type of output images +# Valid values: jpeg, ppm (default: jpeg) +picture_type jpeg ############################################################ # FFMPEG related options -# Film (mpeg) file output, and deinterlacing of the video input +# Film (movies) file output, and deinterlacing of the video input # The options movie_filename and timelapse_filename are also used # by the ffmpeg feature ############################################################ -# Use ffmpeg to encode mpeg movies in realtime (default: off) -ffmpeg_cap_new on +# Use ffmpeg to encode movies in realtime (default: off) +ffmpeg_output_movies on # Use ffmpeg to make movies with only the pixels moving # object (ghost images) (default: off) -ffmpeg_cap_motion off +ffmpeg_output_debug_movies off -# Use ffmpeg to encode a timelapse movie +# Use ffmpeg to encode a timelapse movie # Default value 0 = off - else save frame every Nth second ffmpeg_timelapse 0 @@ -243,19 +299,43 @@ ffmpeg_variable_bitrate 0 # Timelapse mpegs are always made in mpeg1 format independent from this option. # Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. # mpeg1 - gives you files with extension .mpg -# mpeg4 or msmpeg4 - give you files with extension .avi +# mpeg4 or msmpeg4 - gives you files with extension .avi # msmpeg4 is recommended for use with Windows Media Player because # it requires no installation of codec on the Windows client. # swf - gives you a flash film with extension .swf # flv - gives you a flash video with extension .flv # ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -ffmpeg_video_codec swf +# mov - QuickTime ( testing ) +# ogg - Ogg/Theora ( testing ) +ffmpeg_video_codec mpeg4 # Use ffmpeg to deinterlace video. Necessary if you use an analog camera # and see horizontal combing on moving objects in video or pictures. # (default: off) ffmpeg_deinterlace off +############################################################ +# SDL Window +############################################################ + +# Number of motion thread to show in SDL Window (default: 0 = disabled) +#sdl_threadnr 0 + +############################################################ +# External pipe to video encoder +# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. +# The options movie_filename and timelapse_filename are also used +# by the ffmpeg feature +############################################################# + +# Bool to enable or disable extpipe (default: off) +use_extpipe off + +# External program (full path and opts) to pipe raw video to +# Generally, use '-' for STDIN... +;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps + + ############################################################ # Snapshots (Traditional Periodic Webcam File Output) @@ -279,9 +359,17 @@ snapshot_interval 0 ############################################################ # Locate and draw a box around the moving object. -# Valid values: on, off and preview (default: off) +# Valid values: on, off, preview (default: off) # Set to 'preview' will only draw a box in preview_shot pictures. -locate off +locate_motion_mode off + +# Set the look and style of the locate box if enabled. +# Valid values: box, redbox, cross, redcross (default: box) +# Set to 'box' will draw the traditional box. +# Set to 'redbox' will draw a red box. +# Set to 'cross' will draw a little cross to mark center. +# Set to 'redcross' will draw a little red cross to mark center. +locate_motion_style box # Draws the timestamp using same options as C function strftime(3) # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock @@ -310,9 +398,14 @@ text_event %Y%m%d%H%M%S text_double off +# Text to include in a JPEG EXIF comment +# May be any text, including conversion specifiers. +# The EXIF timestamp is included independent of this text. +;exif_text %i%J/%K%L + ############################################################ # Target Directories and filenames For Images And Films -# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename +# For the options snapshot_, picture_, movie_ and timelapse_filename # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, @@ -344,9 +437,9 @@ snapshot_filename %v-%Y%m%d%H%M%S-snapshot # File extension .jpg or .ppm is automatically added so do not include this # Set to 'preview' together with best-preview feature enables special naming # convention for preview shots. See motion guide for details -jpeg_filename %v-%Y%m%d%H%M%S-%q +picture_filename %v-%Y%m%d%H%M%S-%q -# File path for motion triggered ffmpeg films (mpeg) relative to target_dir +# File path for motion triggered ffmpeg films (movies) relative to target_dir # Default: %v-%Y%m%d%H%M%S # Default value is equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S @@ -354,38 +447,53 @@ jpeg_filename %v-%Y%m%d%H%M%S-%q # This option was previously called ffmpeg_filename movie_filename %v-%Y%m%d%H%M%S -# File path for timelapse mpegs relative to target_dir +# File path for timelapse movies relative to target_dir # Default: %Y%m%d-timelapse # Default value is near equivalent to legacy oldlayout option # For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse # File extension .mpg is automatically added so do not include this timelapse_filename %Y%m%d-timelapse +############################################################ +# Global Network Options +############################################################ +# Enable or disable IPV6 for http control and stream (default: off ) +ipv6_enabled off ############################################################ -# Live Webcam Server +# Live Stream Server ############################################################ # The mini-http server listens to this port for requests (default: 0 = disabled) -webcam_port 8081 +stream_port 8081 -# Quality of the jpeg images produced (default: 50) -webcam_quality 50 +# Quality of the jpeg (in percent) images produced (default: 50) +stream_quality 50 # Output frames at 1 fps when no motion is detected and increase to the -# rate given by webcam_maxrate when motion is detected (default: off) -webcam_motion off +# rate given by stream_maxrate when motion is detected (default: off) +stream_motion off -# Maximum framerate for webcam streams (default: 1) -webcam_maxrate 1 +# Maximum framerate for stream streams (default: 1) +stream_maxrate 1 -# Restrict webcam connections to localhost only (default: on) -webcam_localhost on +# Restrict stream connections to localhost only (default: on) +stream_localhost on # Limits the number of images per connection (default: 0 = unlimited) -# Number can be defined by multiplying actual webcam rate by desired number of seconds -# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate -webcam_limit 0 +# Number can be defined by multiplying actual stream rate by desired number of seconds +# Actual stream rate is the smallest of the numbers framerate and stream_maxrate +stream_limit 0 + +# Set the authentication method (default: 0) +# 0 = disabled +# 1 = Basic authentication +# 2 = MD5 digest (the safer authentication) +stream_auth_method 0 + +# Authentication for the stream. Syntax username:password +# Default: not defined (Disabled) +; stream_authentication username:password ############################################################ @@ -393,24 +501,24 @@ webcam_limit 0 ############################################################ # TCP/IP port for the http server to listen on (default: 0 = disabled) -control_port 8080 +webcontrol_port 8080 # Restrict control connections to localhost only (default: on) -control_localhost on +webcontrol_localhost on # Output for http server, select off to choose raw text plain (default: on) -control_html_output on +webcontrol_html_output on # Authentication for the http based control. Syntax username:password # Default: not defined (Disabled) -; control_authentication username:password +; webcontrol_authentication username:password ############################################################ # Tracking (Pan/Tilt) -############################################################ +############################################################# -# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo) +# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) # The generic type enables the definition of motion center and motion size to # be used with the conversion specifiers for options like on_motion_detected track_type 0 @@ -419,19 +527,37 @@ track_type 0 track_auto off # Serial port of motor (default: none) -; track_port value +;track_port /dev/ttyS0 + +# Motor number for x-axis (default: 0) +;track_motorx 0 -# Motor number for x-axis (default: -1) -track_motorx -1 +# Set motorx reverse (default: 0) +;track_motorx_reverse 0 -# Motor number for y-axis (default: -1) -track_motory -1 +# Motor number for y-axis (default: 0) +;track_motory 1 + +# Set motory reverse (default: 0) +;track_motory_reverse 0 # Maximum value on x-axis (default: 0) -track_maxx 0 +;track_maxx 200 + +# Minimum value on x-axis (default: 0) +;track_minx 50 # Maximum value on y-axis (default: 0) -track_maxy 0 +;track_maxy 200 + +# Minimum value on y-axis (default: 0) +;track_miny 50 + +# Center value on x-axis (default: 0) +;track_homex 128 + +# Center value on y-axis (default: 0) +;track_homey 128 # ID of an iomojo camera if used (default: 0) track_iomojo_id 0 @@ -479,11 +605,11 @@ track_stepsize 40 quiet on # Command to be executed when an event starts. (default: none) -# An event starts at first motion detected after a period of no motion defined by gap +# An event starts at first motion detected after a period of no motion defined by event_gap ; on_event_start value # Command to be executed when an event ends after a period of no motion -# (default: none). The period of no motion is defined by option gap. +# (default: none). The period of no motion is defined by option event_gap. ; on_event_end value # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) @@ -493,6 +619,10 @@ quiet on # Command to be executed when a motion frame is detected (default: none) ; on_motion_detected value +# Command to be executed when motion in a predefined area is detected +# Check option 'area_detect'. (default: none) +; on_area_detected value + # Command to be executed when a movie file (.mpg|.avi) is created. (default: none) # To give the filename as an argument to a command append it with %f ; on_movie_start value @@ -501,23 +631,28 @@ quiet on # To give the filename as an argument to a command append it with %f ; on_movie_end value +# Command to be executed when a camera can't be opened or if it is lost +# NOTE: There is situations when motion don't detect a lost camera! +# It depends on the driver, some drivers dosn't detect a lost camera at all +# Some hangs the motion thread. Some even hangs the PC! (default: none) +; on_camera_lost value -############################################################ -# Common Options For MySQL and PostgreSQL database features. -# Options require the MySQL/PostgreSQL options to be active also. -############################################################ +##################################################################### +# Common Options for database features. +# Options require database options to be active also. +##################################################################### -# Log to the database when creating motion triggered image file (default: on) -sql_log_image on +# Log to the database when creating motion triggered picture file (default: on) +; sql_log_picture on # Log to the database when creating a snapshot image file (default: on) -sql_log_snapshot on +; sql_log_snapshot on -# Log to the database when creating motion triggered mpeg file (default: off) -sql_log_mpeg off +# Log to the database when creating motion triggered movie file (default: off) +; sql_log_movie off -# Log to the database when creating timelapse mpeg file (default: off) -sql_log_timelapse off +# Log to the database when creating timelapse movies file (default: off) +; sql_log_timelapse off # SQL query string that is sent to the database # Use same conversion specifiers has for text features @@ -525,45 +660,48 @@ sql_log_timelapse off # %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') +; 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') ############################################################ -# Database Options For MySQL +# Database Options ############################################################ -# Mysql database to log to (default: not defined) -; mysql_db value +# database type : mysql, postgresql, sqlite3 (default : not defined) +; database_type value + +# database to log to (default: not defined) +; database_dbname value # The host on which the database is located (default: localhost) -; mysql_host value +; database_host value -# User account name for MySQL database (default: not defined) -; mysql_user value +# User account name for database (default: not defined) +; database_user value -# User password for MySQL database (default: not defined) -; mysql_password value +# User password for database (default: not defined) +; database_password value +# Port on which the database is located +# mysql 3306 , postgresql 5432 (default: not defined) +; database_port value ############################################################ -# Database Options For PostgreSQL +# Database Options For SQLite3 ############################################################ -# PostgreSQL database to log to (default: not defined) -; pgsql_db value - -# The host on which the database is located (default: localhost) -; pgsql_host value - -# User account name for PostgreSQL database (default: not defined) -; pgsql_user value - -# User password for PostgreSQL database (default: not defined) -; pgsql_password value +# SQLite3 database (file path) (default: not defined) +; sqlite3_db value -# Port on which the PostgreSQL database is located (default: 5432) -; pgsql_port 5432 ############################################################ @@ -590,7 +728,7 @@ sql_query insert into security(camera, filename, frame, file_type, time_stamp, e # thread file for each camera. E.g. 2 cameras requires 3 files: # This motion.conf file AND thread1.conf and thread2.conf. # Only put the options that are unique to each camera in the -# thread config files. +# thread config files. ; thread /usr/local/etc/thread1.conf ; thread /usr/local/etc/thread2.conf ; thread /usr/local/etc/thread3.conf diff --git a/debian/motion.postinst b/debian/motion.postinst index 77eaa4f..29ac59c 100644 --- a/debian/motion.postinst +++ b/debian/motion.postinst @@ -31,7 +31,7 @@ add_group_if_missing add_user_if_missing # Fix motion.conf permission -chmod 0640 /etc/motion/motion.conf +chmod 0644 /etc/motion/motion.conf chgrp motion /etc/motion/motion.conf diff --git a/debian/motion.postinst.save b/debian/motion.postinst.save index 5e69130..b753792 100644 --- a/debian/motion.postinst.save +++ b/debian/motion.postinst.save @@ -40,7 +40,7 @@ add_user_if_missing create_pid_dir # Fix motion.conf permission -chmod 0640 /etc/motion/motion.conf +chmod 0644 /etc/motion/motion.conf chgrp motion /etc/motion/motion.conf diff --git a/debian/patches/01_videodev.h.diff b/debian/patches/01_videodev.h.diff deleted file mode 100644 index 25344ab..0000000 --- a/debian/patches/01_videodev.h.diff +++ /dev/null @@ -1,27 +0,0 @@ -Index: motion-3.2.12/video.h -=================================================================== ---- motion-3.2.12.orig/video.h 2011-08-23 15:42:35.564656448 -0430 -+++ motion-3.2.12/video.h 2011-08-23 15:43:10.860657024 -0430 -@@ -12,7 +12,7 @@ - - #define _LINUX_TIME_H 1 - #ifndef WITHOUT_V4L --#include -+#include - #include - #include "pwc-ioctl.h" - #endif -Index: motion-3.2.12/motion.h -=================================================================== ---- motion-3.2.12.orig/motion.h 2011-08-23 15:44:46.108655912 -0430 -+++ motion-3.2.12/motion.h 2011-08-23 15:45:21.240655678 -0430 -@@ -40,7 +40,8 @@ - - #define _LINUX_TIME_H 1 - #if !defined(WITHOUT_V4L) && !defined(BSD) --#include -+#include -+#include - #endif - - #include diff --git a/debian/patches/020101107~5273773.patch b/debian/patches/020101107~5273773.patch deleted file mode 100644 index 56c83c4..0000000 --- a/debian/patches/020101107~5273773.patch +++ /dev/null @@ -1,95 +0,0 @@ -Description: Fix FFmpeg guess_format() deprecation warning -Author: Angel Carpintero -Origin: Upstream, https://github.com/sackmotion/motion/commit/527377#svn517 -Last-Update: 2012-02-12 - ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -36,6 +36,11 @@ - # endif /* __GNUC__ */ - #endif /* LIBAVCODEC_BUILD > 4680 */ - -+#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR -+#if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 -+ #define GUESS_NO_DEPRECATED -+#endif -+#endif - - #if LIBAVFORMAT_BUILD >= 4616 - /* The API for av_write_frame changed with FFmpeg version 0.4.9pre1. -@@ -258,7 +263,11 @@ - /* We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would - * result in a muxed output file, which isn't appropriate here. - */ -- of = guess_format("mpeg1video", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("mpeg1video", NULL, NULL); -+#endif - if (of) { - /* But we want the trailer to be correctly written. */ - of->write_trailer = mpeg1_write_trailer; -@@ -270,24 +279,44 @@ - #endif - } else if (strcmp(codec, "mpeg4") == 0) { - ext = ".avi"; -- of = guess_format("avi", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("avi", NULL, NULL); -+#endif - } else if (strcmp(codec, "msmpeg4") == 0) { - ext = ".avi"; -- of = guess_format("avi", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("avi", NULL, NULL); -+#endif - if (of) { - /* Manually override the codec id. */ - of->video_codec = CODEC_ID_MSMPEG4V2; - } - } else if (strcmp(codec, "swf") == 0) { - ext = ".swf"; -- of = guess_format("swf", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("swf", NULL, NULL); -+#endif - } else if (strcmp(codec, "flv") == 0) { - ext = ".flv"; -- of = guess_format("flv", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("flv", NULL, NULL); -+#endif - of->video_codec = CODEC_ID_FLV1; - } else if (strcmp(codec, "ffv1") == 0) { - ext = ".avi"; -- of = guess_format("avi", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("avi", NULL, NULL); -+#endif - if (of) { - /* Use the FFMPEG Lossless Video codec (experimental!). - Requires strict_std_compliance to be <= -2 */ -@@ -295,7 +324,11 @@ - } - } else if (strcmp(codec, "mov") == 0) { - ext = ".mov"; -- of = guess_format("mov", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("mov", NULL, NULL); -+#endif - } else { - motion_log(LOG_ERR, 0, "ffmpeg_video_codec option value %s is not supported", codec); - return NULL; diff --git a/debian/patches/020111022~58627b0.patch b/debian/patches/020111022~58627b0.patch deleted file mode 100644 index 480819d..0000000 --- a/debian/patches/020111022~58627b0.patch +++ /dev/null @@ -1,141 +0,0 @@ -Description: Improve detection of av_register_protocol() for ffmpeg. -Author: Angel Carpintero -Origin: Upstream, https://github.com/sackmotion/motion/commit/7aec4b#svn538 -Last-Update: 2012-02-12 - ---- a/configure.in -+++ b/configure.in -@@ -316,7 +316,7 @@ - # - else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB -- AC_MSG_CHECKING(for ffmpeg autodetecting) -+ AC_MSG_CHECKING(for ffmpeg autodetecting libraries) - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib64) -@@ -347,7 +347,7 @@ - echo "" - fi - else -- AC_MSG_CHECKING(for ffmpeg in -> [${FFMPEG_DIR}] <-) -+ AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_OK="found" -@@ -392,9 +392,11 @@ - elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" - else - AC_MSG_RESULT(not found) - FFMPEG_OK="no_found" -@@ -423,9 +425,11 @@ - AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS -- CFLAGS="${FFMPEG_CFLAGS}" -+ -+ -+ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" -- -+ - AC_COMPILE_IFELSE( - [ - #include -@@ -442,7 +446,35 @@ - ] - ) - CFLAGS=$saved_CFLAGS -- LIBS=$saved_LIBS -+ LIBS=$saved_LIBS -+ -+ AC_MSG_CHECKING([av_register_protocol is defined in ffmpeg ?]) -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" -+ LIBS="$TEMP_LIBS" -+ -+ AC_COMPILE_IFELSE( -+ [ -+ #include -+ URLProtocol test_file_protocol; -+ int main(void){ -+ av_register_protocol(&test_file_protocol); -+ return 0; -+ } -+ ], -+ [ -+ AC_MSG_RESULT(yes) -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL" -+ ], -+ [ -+ AC_MSG_RESULT(no) -+ ] -+ ) -+ -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+ - fi - fi - fi ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -232,11 +232,11 @@ - mpeg1_file_protocol.url_seek = file_protocol.url_seek; - mpeg1_file_protocol.url_close = file_protocol.url_close; - -- /* Register the append file protocol. */ --#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) -+/* Register the append file protocol. */ -+#ifdef HAVE_FFMPEG_AV_REGISTER_PROTOCOL - av_register_protocol(&mpeg1_file_protocol); - #else -- register_protocol(&mpeg1_file_protocol); -+ av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); - #endif - } - -@@ -410,7 +410,11 @@ - - ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); - c->codec_id = ffmpeg->oc->oformat->video_codec; -+#if LIBAVCODEC_VERSION_MAJOR < 53 - c->codec_type = CODEC_TYPE_VIDEO; -+#else -+ c->codec_type = AVMEDIA_TYPE_VIDEO; -+#endif - is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; - - if (strcmp(ffmpeg_video_codec, "ffv1") == 0) -@@ -679,7 +683,11 @@ - if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { - /* raw video case. The API will change slightly in the near future for that */ - #ifdef FFMPEG_AVWRITEFRAME_NEWAPI -+#if LIBAVCODEC_VERSION_MAJOR < 53 - pkt.flags |= PKT_FLAG_KEY; -+#else -+ pkt.flags |= AV_PKT_FLAG_KEY; -+#endif - pkt.data = (uint8_t *)pic; - pkt.size = sizeof(AVPicture); - ret = av_write_frame(ffmpeg->oc, &pkt); -@@ -700,7 +708,11 @@ - #ifdef FFMPEG_AVWRITEFRAME_NEWAPI - pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; - if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) { -+#if LIBAVCODEC_VERSION_MAJOR < 53 - pkt.flags |= PKT_FLAG_KEY; -+#else -+ pkt.flags |= AV_PKT_FLAG_KEY; -+#endif - } - pkt.data = ffmpeg->video_outbuf; - pkt.size = out_size; diff --git a/debian/patches/020111022~734155f.patch b/debian/patches/020111022~734155f.patch deleted file mode 100644 index 1d6be19..0000000 --- a/debian/patches/020111022~734155f.patch +++ /dev/null @@ -1,35 +0,0 @@ -Description: Fix avoid crash producing MPEG4 with newer FFmpeg. -Author: Angel Carpintero -Origin: Upstream, https://github.com/sackmotion/motion/commit/734155#svn539 -Bug: http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 -Last-Update: 2012-02-12 - ---- a/configure.in -+++ b/configure.in -@@ -1099,6 +1099,10 @@ - LIBS="${TEMP_LIBS}" - LDFLAGS="${TEMP_LDFLAGS}" - -+ -+AC_CHECK_FUNC(avformat_alloc_context, AC_DEFINE([have_avformat_alloc_context],1,[Define to 1 if you have avformat_alloc_context support])) -+AC_CHECK_FUNC(av_avformat_alloc_context, AC_DEFINE([have_av_avformat_alloc_context],1,[Define to 1 if you have av_avformat_alloc_context support])) -+ - # - # Add the right exec path for rc scripts - # ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -373,7 +373,13 @@ - snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); - - /* allocation the output media context */ -+#ifdef have_avformat_alloc_context -+ ffmpeg->oc = avformat_alloc_context(); -+#elif defined have_av_avformat_alloc_context -+ ffmpeg->oc = av_alloc_format_context(); -+#else - ffmpeg->oc = av_mallocz(sizeof(AVFormatContext)); -+#endif - - if (!ffmpeg->oc) { - motion_log(LOG_ERR, 1, "Memory error while allocating output media context"); diff --git a/debian/patches/020111027~5dd9ed4.patch b/debian/patches/020111027~5dd9ed4.patch deleted file mode 100644 index 05abd9e..0000000 --- a/debian/patches/020111027~5dd9ed4.patch +++ /dev/null @@ -1,68 +0,0 @@ -Description: Improve av_register_protocol2()/av_register_protocol() detection -Author: Angel Carpintero -Origin: Upstream, https://github.com/sackmotion/motion/commit/5dd9ed#svn540#svn540 -Last-Update: 2012-02-12 - ---- a/configure.in -+++ b/configure.in -@@ -448,33 +448,6 @@ - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - -- AC_MSG_CHECKING([av_register_protocol is defined in ffmpeg ?]) -- saved_CFLAGS=$CFLAGS -- saved_LIBS=$LIBS -- CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" -- LIBS="$TEMP_LIBS" -- -- AC_COMPILE_IFELSE( -- [ -- #include -- URLProtocol test_file_protocol; -- int main(void){ -- av_register_protocol(&test_file_protocol); -- return 0; -- } -- ], -- [ -- AC_MSG_RESULT(yes) -- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL" -- ], -- [ -- AC_MSG_RESULT(no) -- ] -- ) -- -- CFLAGS=$saved_CFLAGS -- LIBS=$saved_LIBS -- - fi - fi - fi -@@ -1102,6 +1075,9 @@ - - AC_CHECK_FUNC(avformat_alloc_context, AC_DEFINE([have_avformat_alloc_context],1,[Define to 1 if you have avformat_alloc_context support])) - AC_CHECK_FUNC(av_avformat_alloc_context, AC_DEFINE([have_av_avformat_alloc_context],1,[Define to 1 if you have av_avformat_alloc_context support])) -+AC_CHECK_FUNC(av_register_protocol2, AC_DEFINE([have_av_register_protocol2],1,[Define to 1 if you have av_register_protocol2 support])) -+AC_CHECK_FUNC(av_register_protocol, AC_DEFINE([have_av_register_protocol],1,[Define to 1 if you have av_register_protocol support])) -+ - - # - # Add the right exec path for rc scripts ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -233,10 +233,12 @@ - mpeg1_file_protocol.url_close = file_protocol.url_close; - - /* Register the append file protocol. */ --#ifdef HAVE_FFMPEG_AV_REGISTER_PROTOCOL -+#ifdef have_av_register_protocol2 -+ av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); -+#elif defined have_av_register_protocol - av_register_protocol(&mpeg1_file_protocol); - #else -- av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); -+# warning av_register_protocolXXX missing - #endif - } - diff --git a/debian/patches/020120717~0fb31d.patch b/debian/patches/020120717~0fb31d.patch deleted file mode 100644 index e69de29..0000000 diff --git a/debian/patches/02_libav_multiarch.patch b/debian/patches/02_libav_multiarch.patch deleted file mode 100644 index 3c8f8d8..0000000 --- a/debian/patches/02_libav_multiarch.patch +++ /dev/null @@ -1,20 +0,0 @@ -Description: Autodetect multiarch libavcodec path in autoconf. -Author: Stephen Kitt -Last-Update: 2012-02-12 - ---- a/configure.in -+++ b/configure.in -@@ -318,7 +318,12 @@ - # AUTODETECT STATIC/SHARED LIB - AC_MSG_CHECKING(for ffmpeg autodetecting libraries) - -- if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then -+ if test -f /usr/lib/$(dpkg-architecture -qDEB_BUILD_MULTIARCH)/libavcodec.so ; then -+ AC_MSG_RESULT(found in /usr/lib/$(dpkg-architecture -qDEB_BUILD_MULTIARCH)) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib/$(dpkg-architecture -qDEB_BUILD_MULTIARCH)" -+ FFMPEG_DIR="/usr" -+ elif test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib64) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" diff --git a/debian/patches/copy-old-api.patch b/debian/patches/copy-old-api.patch deleted file mode 100644 index 00a9f11..0000000 --- a/debian/patches/copy-old-api.patch +++ /dev/null @@ -1,76 +0,0 @@ -Description: Copy old API items we still depend on - As per doc/APIchanges in libav/ffmpeg, URLContext/URLProtocol were dropped - from the public API of libavformat since 52.107.0. Pending a better solution - from motion upstream, we copy the definitions here. -Author: Ximin Luo -Bug: https://github.com/sackmotion/motion/issues/15 - ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -15,6 +15,66 @@ - #include "ffmpeg.h" - #include "motion.h" - -+#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(52,107,0) -+/* -+ * URLContext, URLProtocol have been removed from avio.h -+ * -+ */ -+ -+typedef struct URLContext { -+ const AVClass *av_class; /**< information for av_log(). Set by url_open(). */ -+ struct URLProtocol *prot; -+ void *priv_data; -+ char *filename; /**< specified URL */ -+ int flags; -+ int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ -+ int is_streamed; /**< true if streamed (no seek possible), default = false */ -+ int is_connected; -+ AVIOInterruptCB interrupt_callback; -+ int64_t rw_timeout; /**< maximum time to wait for (network) read/write operation completion, in mcs */ -+} URLContext; -+ -+typedef struct URLProtocol { -+ const char *name; -+ int (*url_open)( URLContext *h, const char *url, int flags); -+ /** -+ * This callback is to be used by protocols which open further nested -+ * protocols. options are then to be passed to ffurl_open()/ffurl_connect() -+ * for those nested protocols. -+ */ -+ int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options); -+ -+ /** -+ * Read data from the protocol. -+ * If data is immediately available (even less than size), EOF is -+ * reached or an error occurs (including EINTR), return immediately. -+ * Otherwise: -+ * In non-blocking mode, return AVERROR(EAGAIN) immediately. -+ * In blocking mode, wait for data/EOF/error with a short timeout (0.1s), -+ * and return AVERROR(EAGAIN) on timeout. -+ * Checking interrupt_callback, looping on EINTR and EAGAIN and until -+ * enough data has been read is left to the calling function; see -+ * retry_transfer_wrapper in avio.c. -+ */ -+ int (*url_read)( URLContext *h, unsigned char *buf, int size); -+ int (*url_write)(URLContext *h, const unsigned char *buf, int size); -+ int64_t (*url_seek)( URLContext *h, int64_t pos, int whence); -+ int (*url_close)(URLContext *h); -+ struct URLProtocol *next; -+ int (*url_read_pause)(URLContext *h, int pause); -+ int64_t (*url_read_seek)(URLContext *h, int stream_index, -+ int64_t timestamp, int flags); -+ int (*url_get_file_handle)(URLContext *h); -+ int (*url_get_multi_file_handle)(URLContext *h, int **handles, -+ int *numhandles); -+ int (*url_shutdown)(URLContext *h, int flags); -+ int priv_data_size; -+ const AVClass *priv_data_class; -+ int flags; -+ int (*url_check)(URLContext *h, int mask); -+} URLProtocol; -+#endif -+ - #if LIBAVCODEC_BUILD > 4680 - /* FFmpeg after build 4680 doesn't have support for mpeg1 videos with - * non-standard framerates. Previous builds contained a broken hack diff --git a/debian/patches/github-changes b/debian/patches/github-changes new file mode 100644 index 0000000..cc7bd64 --- /dev/null +++ b/debian/patches/github-changes @@ -0,0 +1,48045 @@ +Description: + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + motion (3.2.12-4ppa01) trusty; urgency=low + . + * Nonmaintainer upload + * Due to conficts, removed patches (Mr Dave) + * Revise motion.postinst to put motion.conf at 0644 instead of 0640(Mr Dave) + * Many many changes from github repos of many many developers since 3.2.12 was released. + * + * Features + * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) + * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 + (Jeroen Massar & Angel Carpintero) + * Experimental approach for MJPEG streams (Motion JPEG) for network cameras + http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch ( ... ) + * Add draw a RED box around the movement as default (Joerg Weber) + * Add write/read nonblock functions in webhttpd( timeout on read/write). (Angel Carpintero) + * More changes in option names from http://www.lavrsen.dk/twiki/bin/view/Motion/IntuitiveOptionNamesDiscussion + (Angel Carpintero) + * motion_locate new parameter names : red , center , redcross instead of only on, off. (Angel Carpintero) + * External pipe to allow external video encoders + http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) + * Split locate_motion into separate 'mode' and 'style' option to allow all + possible combinations. (Joerg Weber) + * Implement 'gapless' event mode to allow for recording of movies without 'holes'. (Joerg Weber) + * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. (Joerg Weber) + * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. + http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 + Increased buffer in ffmpeg to allow encoding at 1600x1200 (Angel Carpintero) + * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch (Giacomo Graziosi) + * New RPM SPEC file and startup scripts compliant with Fedora 10 guidelines and above (Steven Moix) + * Increase write buffer size for writing image files and ffmpegs + http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionWriteBuffersPatch (Craig West) + * Fixed mask overlay in setup mode is now green instead of white (Joerg Weber) + * Add new config option 'ipv6_enabled' to enable/disable IPV6 (Angel Carpintero) + * Remove VIDIOC_S_JPEGCOMP support is deprecated. (Angel Carpintero) + * Use static memory allocation in ffmpeg_deinterlace() (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic + * Atom optimizacion in configure.in (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations + * Allow to change Standard method ( PAL / NECAM / SECAM ) (Angel Carpintero) + * Add authentication methods 'Basic Authentication' and 'Digest Authentication' + to the "Live Stream Server". (Michael Finsterbusch) + http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch + * Implemented new logging system + http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero) + * Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero) + * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis) + * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). + * 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) + * Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8. (Jeroen Massar) + * Added codec Ogg/Theora as new output format for regular movies. + http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) + * Added support for ffmpeg 0.11 new API. + * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) + * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) + * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) + * Buffer overflow vulnerabilities (hyperbolic2346) + * Redundand -- boundary prefix (torao) + * Removed compiler warnings: (Mr-Dave) + logger.c,jpegutils.c,netcam_ftp.c,track.c, + picture.c,webhttpd.c,stream.c,ffmpeg.c + * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) + * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) + * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) + * Resolve additional compiler warnings in ffmpeg (Mr-Dave) + * Revised INSTALL with samples(Mr-Dave) + * Revisions for RTSP and code standard.(Mr-Dave) + * Plugged most memory leaks in RTSP. (Mr-Dave) + * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) + * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) + * Regession fix for memory leaks and reconnection (Mr-Dave) + * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) + * Revised RTSP to support version 53 of libavformat (Mr-Dave) + * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) + * Revised INSTALL to have sample PI configure option.(Mr-Dave) + * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) + * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) + * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) + * Clean up the messaging for RTSP. + * Additional validations for RTSP connection and corrected free sequences + * Removed seg fault on failure to open first image, comments, isolation of RTSP + * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. + * Implement inits of AV functions from bcl fork + * Add gray image upon disconnection + * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) + * Revised comments to be in line with application standard. + * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format + * Revise version.sh to put out the git commit. + * Rollback revision to allow for a formal pull request. + * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 + * Implement requirement of modulo 16 to avoid seg fault when opening stream + * Add debian build files from trusty(14.04) + * Revise default values for motion.conf + * Revise CHANGELOG to conform with debian format + . + * Bugfixes + * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) + * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 + * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) + * Avoid compile vloopback in BSD (Angel Carpintero) + * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. (Isaac Richter) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 + * 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) + * Fix introduced bug for Content-Lenght = 0 in svn r476. (Angel Carpintero) + * 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 + * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 (Angel Carpintero) + * Fix issue with JPEG , adding dinfo.do_fancy_upsampling = FALSE; + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x08x20x194659 + * Made micro-lightswitch optional (see lightwitch option in motion.conf) + * 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. + * Replace malloc() by calloc(). (Jeroen Massar) + * Free file descriptor buffers on exit. + * Avoid segfault when text_left or text_right uses non supported chars. + * Fixed leak in vloopback. + * Fixed a build of motion for some kernel version with not good videodev.h + * Netcam Modulo 8 +Author: Mr Dave + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: , +Bug: +Bug-Debian: http://bugs.debian.org/ +Bug-Ubuntu: https://launchpad.net/bugs/ +Forwarded: +Reviewed-By: +Last-Update: + +--- motion-3.2.12.orig/CHANGELOG ++++ motion-3.2.12/CHANGELOG +@@ -1,3 +1,129 @@ ++ * ++ * Features ++ * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) ++ * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 ++ (Jeroen Massar & Angel Carpintero) ++ * Experimental approach for MJPEG streams (Motion JPEG) for network cameras ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch ( ... ) ++ * Add draw a RED box around the movement as default (Joerg Weber) ++ * Add write/read nonblock functions in webhttpd( timeout on read/write). (Angel Carpintero) ++ * More changes in option names from http://www.lavrsen.dk/twiki/bin/view/Motion/IntuitiveOptionNamesDiscussion ++ (Angel Carpintero) ++ * motion_locate new parameter names : red , center , redcross instead of only on, off. (Angel Carpintero) ++ * External pipe to allow external video encoders ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) ++ * Split locate_motion into separate 'mode' and 'style' option to allow all ++ possible combinations. (Joerg Weber) ++ * Implement 'gapless' event mode to allow for recording of movies without 'holes'. (Joerg Weber) ++ * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. (Joerg Weber) ++ * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 ++ Increased buffer in ffmpeg to allow encoding at 1600x1200 (Angel Carpintero) ++ * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch (Giacomo Graziosi) ++ * New RPM SPEC file and startup scripts compliant with Fedora 10 guidelines and above (Steven Moix) ++ * Increase write buffer size for writing image files and ffmpegs ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionWriteBuffersPatch (Craig West) ++ * Fixed mask overlay in setup mode is now green instead of white (Joerg Weber) ++ * Add new config option 'ipv6_enabled' to enable/disable IPV6 (Angel Carpintero) ++ * Remove VIDIOC_S_JPEGCOMP support is deprecated. (Angel Carpintero) ++ * Use static memory allocation in ffmpeg_deinterlace() (Peter Holik) ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic ++ * Atom optimizacion in configure.in (Peter Holik) ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations ++ * Allow to change Standard method ( PAL / NECAM / SECAM ) (Angel Carpintero) ++ * Add authentication methods 'Basic Authentication' and 'Digest Authentication' ++ to the "Live Stream Server". (Michael Finsterbusch) ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch ++ * Implemented new logging system ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero) ++ * Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero) ++ * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis) ++ * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). ++ * 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) ++ * Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8. (Jeroen Massar) ++ * Added codec Ogg/Theora as new output format for regular movies. ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) ++ * Added support for ffmpeg 0.11 new API. ++ * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) ++ * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) ++ * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) ++ * Buffer overflow vulnerabilities (hyperbolic2346) ++ * Redundand -- boundary prefix (torao) ++ * Removed compiler warnings: (Mr-Dave) ++ logger.c,jpegutils.c,netcam_ftp.c,track.c, ++ picture.c,webhttpd.c,stream.c,ffmpeg.c ++ * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) ++ * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) ++ * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) ++ * Resolve additional compiler warnings in ffmpeg (Mr-Dave) ++ * Revised INSTALL with samples(Mr-Dave) ++ * Revisions for RTSP and code standard.(Mr-Dave) ++ * Plugged most memory leaks in RTSP. (Mr-Dave) ++ * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) ++ * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) ++ * Regession fix for memory leaks and reconnection (Mr-Dave) ++ * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) ++ * Revised RTSP to support version 53 of libavformat (Mr-Dave) ++ * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) ++ * Revised INSTALL to have sample PI configure option.(Mr-Dave) ++ * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) ++ * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) ++ * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) ++ * Clean up the messaging for RTSP. ++ * Additional validations for RTSP connection and corrected free sequences ++ * Removed seg fault on failure to open first image, comments, isolation of RTSP ++ * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. ++ * Implement inits of AV functions from bcl fork ++ * Add gray image upon disconnection ++ * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) ++ * Revised comments to be in line with application standard. ++ * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format ++ * Revise version.sh to put out the git commit. ++ * Rollback revision to allow for a formal pull request. ++ * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 ++ * Implement requirement of modulo 16 to avoid seg fault when opening stream ++ * Add debian build files from trusty(14.04) ++ * Revise default values for motion.conf ++ * Revise CHANGELOG to conform with debian format ++ ++ * Bugfixes ++ * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) ++ * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 ++ * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) ++ * Avoid compile vloopback in BSD (Angel Carpintero) ++ * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. (Isaac Richter) ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 ++ * 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) ++ * Fix introduced bug for Content-Lenght = 0 in svn r476. (Angel Carpintero) ++ * 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 ++ * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 (Angel Carpintero) ++ * Fix issue with JPEG , adding dinfo.do_fancy_upsampling = FALSE; ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x08x20x194659 ++ * Made micro-lightswitch optional (see lightwitch option in motion.conf) ++ * 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. ++ * Replace malloc() by calloc(). (Jeroen Massar) ++ * Free file descriptor buffers on exit. ++ * Avoid segfault when text_left or text_right uses non supported chars. ++ * Fixed leak in vloopback. ++ * Fixed a build of motion for some kernel version with not good videodev.h ++ * Netcam Modulo 8 ++ + 3.2.12 Summary of Changes + + Bugfixes +@@ -6,10 +132,11 @@ Bugfixes + * Fixed FFV1 codec encode with ffmpeg (Angel Carpintero) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x13x032553 + * Fix conv_uyvyto420p segfault ( William M Brack ) +- * Enhancing the palette selection ( William M Brack ) ++ * Enhancing the palette selection ( William M Brack ) + * Fix zombies on OpenBSD. (Mark Feenstra) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x28x054348 + ++ + 3.2.11.1 Sumary of Changes + + Bugfixes +@@ -18,16 +145,15 @@ Bugfixes + * Fix fd leaks in external pipe. (Angel Carpintero) + * Avoid possible stack smashing in v4l_open_vidpipe(). (Angel Carpintero) + * Allow compile with OpenSuse ffmpeg package (15594svn-20081010) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x10x25x070400 (Angel Carpintero) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x10x25x070400 (Angel Carpintero) + * Fix warning for syslog(). (Angel Carpintero) +- * Better detection of ffmpeg +- http://www.lavrsen.dk/foswiki/pub/Motion/ReleaseNoteMotion3x2x11/ffmpeg-detection.diff.gz +- (Angel Carpintero) +- * Fix warning for __USE_GNU redefined (Peter Holik) ++ * Better detection of ffmpeg ++ http://www.lavrsen.dk/foswiki/pub/Motion/ReleaseNoteMotion3x2x11/ffmpeg-detection.diff.gz ++ (Angel Carpintero) ++ * Fix warning for __USE_GNU redefined (Peter Holik) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x122137 (Peter Holik) + * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) + * Fix segfault for new libjpeg v7. (Angel Carpintero) +- + + 3.2.11 Summary of Changes + +@@ -39,29 +165,31 @@ Features + + + Bugfixes +- * Fix Problem Encoding 1280x1024 resolution videos +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x06x11x183727 (Angel Carpintero) ++ * Fix Problem Encoding 1280x1024 resolution videos ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x06x11x183727 (Angel Carpintero) + * Add a new parameter netcam_tolerant_check, to be less strict with some buggy network cameras firmwares. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x06x19x123218 (Angel Carpintero) +- * Fix round robin in BSD switching to METEOR_CAP_SINGLE. (Angel Carpintero) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x06x19x123218 (Angel Carpintero) ++ * Fix round robin in BSD switching to METEOR_CAP_SINGLE. (Angel Carpintero) + * Fix rotate for v4l2 devices using JPEG / MJPEG palettes. (Angel Carpintero) +- * Fix v4l2_palette http://www.lavrsen.dk/foswiki/bin/view/Motion/UvcvideoMjpegPatch (Gerrit Hannaert) ++ * Fix v4l2_palette http://www.lavrsen.dk/twiki/bin/view/Motion/UvcvideoMjpegPatch (Gerrit Hannaert) + * Fix warning for x86_64 in conf.c using pointers LP64 compliant ( Angel Carpintero ). ++ * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) ( Peter Holik ) ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 ++ + + 3.2.10.1 Summary of Changes + + Bugfixes + * Fix a security issue in web control interface http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484572 +- (Angel Carpintero) +- ++ (Angel Carpintero) + + 3.2.10 Summary of Changes + + Features + * Added the pre_capture buffer redesign to throttle load and enhance pre_capture feature. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreCaptureRedesign (Dag Erlandsson). ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PreCaptureRedesign (Dag Erlandsson). + * Added preview center feature. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewCenter (Dag Erlandsson). ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewCenter (Dag Erlandsson). + * Removed low_cpu feature, as it is not really compatible with pre_capture and a lot of other + features rely on the pre_capture buffer behind the scenes. (Joerg Weber) + * Removed night_compensate feature. This functionality is covered by noise_tune. (Joerg Weber) +@@ -69,8 +197,8 @@ Features + * Improved smartmask feature: real moving objects don't trigger the mask anymore. (Joerg Weber) + * Added area_detect feature. New config options: area_detect, on_area_detected. (Joerg Weber) + * Added help in http control +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x181541 (Angel Carpintero) +- * Added Choose V4L2 palette http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x032318 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x181541 (Angel Carpintero) ++ * Added Choose V4L2 palette http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x032318 + (Angel Carpintero) + * Improved http control ( 'back' link, select box, show current values when are going to be changed ). + (Angel Carpintero) +@@ -78,7 +206,7 @@ Features + * Watchdog, restart hang threads (Dag Erlandsson) + * Added ON_CAMERA_LOST event (Dag Erlandsson) + * Motion start if a camera isn't there at start, retries to connect if lost (Dag Erlandsson) +- * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x01x22x231542 ++ * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x01x22x231542 + (Simon Walls) + * Added mov , Quicktime file format (Andrew Hamilton). + * Added to configure.in --with-pwcbsd to allow compile motion in freebsd with webcam support instead of bktr +@@ -87,25 +215,25 @@ Features + Bugfixes + * Fixed a problem with locate and fixed mask overlay (Dag Erlandsson). + * Preview pictures get the timestamp of moment they were captured (Dag Erlandsson). +- * Fixed http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x23x093651 (Angel Carpintero) ++ * Fixed http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x23x093651 (Angel Carpintero) + * Fix process_id_file when is passed from command line (Angel Carpintero) +- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x27x150419 (Angel Carpintero) +- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x25x102808 (Angel Carpintero) ++ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x27x150419 (Angel Carpintero) ++ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x25x102808 (Angel Carpintero) + * Avoid random errors , initialising some structs for V4L1 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) + * Fix motion segfault because ffmpeg API change +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2007x12x29x175530 (Angel Carpintero) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2007x12x29x175530 (Angel Carpintero) + * Little fix in ffmpeg.c comparing version of LIBAVFORMAT_BUILD, since ffmpeg svn -r4486 LIBAVFORMAT_BUILD and + LIBAVCODEC_BUILD uses LIBAVFORMAT_VERSION_INT ((49<<16)+(0<<8)+0) and LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+0) + (Angel Carpintero) +- * Fix choose v4l2 palette , http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x01x21x043812 (Onakra) ++ * Fix choose v4l2 palette , http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x01x21x043812 (Onakra) + * Get current directory to allow write motion.conf properly +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x013419 (John Bray) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x013419 (John Bray) + * Fix broken PostgreSQL detection for custom location, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x025134 ( Angel Carpintero ) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x025134 ( Angel Carpintero ) + * Fixed stepper when is used track_auto on ( Angel Carpintero ). + * Better debug in netcam for "Error reading image header" +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x27x092849 (Simon Walls) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x27x092849 (Simon Walls) + + + 3.2.9 Formal Release - Summary of Changes +@@ -115,20 +243,20 @@ Features + ( no needed to deploy BSD port here ) directories. ( Angel Carpintero ) + * Added --chuid motion to debian init.d script. ( Angel Carpintero ) + * Added Flash video format (FLV) to ffmpeg. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x07x19x131921 (Timo Taskinen). ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x07x19x131921 (Timo Taskinen). + * Added FFV1 ( FF video codec 1 ) codec , Lossless encoding +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LosslessEncoding (Andrew Hamilton). ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LosslessEncoding (Andrew Hamilton). + + + Bugfixes + * Fix segfault in webhttpd.c on motion restart (Angel Carpintero) +- * Fix segfault in debian http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x09x24x175945 ++ * Fix segfault in debian http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x09x24x175945 + (Angel Carpintero) + * Fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391055 , change + motion man page , -d requires level. (Angel Carpintero) + * Handle mjpeg decoding and fix colour issue adding mjpegtools dependency +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegColorIssue +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegToYUV420pPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegColorIssue ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch + (Marius Rieder, Angel Carpintero). + * Add debug level > 5 to get logs from v4l2_select_input, v4l2_set_control and v4l2_set_input. + (Angel Carpintero) +@@ -139,17 +267,17 @@ Bugfixes + Features + * Added connection status for all devices available from http web interface. + (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x11x09x050638 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x11x09x050638 + * Improved deb packaging, install the init.d script. (Angel Carpintero). + * Added swf codec to video creation (Bowser Pete, Andy Brown). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FFmpegSWFcreation ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FFmpegSWFcreation + * Added V4L2 support (Krzysztof Blaszkowski, Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoForLinuxTwoDiscussion, ++ http://www.lavrsen.dk/twiki/bin/view/Motion/VideoForLinuxTwoDiscussion, + * Added support for V4L2_PIX_FMT_SBGGR8 ( bayer ), V4L2_PIX_FMT_SN9C10X, + V4L2_PIX_FMT_MJPEG and V4L2_PIX_FMT_UYVY (Angel Carpintero). + * ucvideo track pan/tilt support ( Michal Licko ,Dirk Wesenberg and + Angel Carpintero ) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch + * Added a FreeBSD directory to allow people from BSD to get a daily version + and create a port. (Angel Carpintero). + * Removed mysql dependency from debian package and added a note to setup +@@ -164,18 +292,18 @@ Features + Bugfixes + * Removed a duplicate call to jpeg_destroy_decompress already is called from + netcam_image_conv (Krzysztof Blaszkowski). +- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x10x10x081903, ++ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x10x10x081903, + reconnect to mysql if connection dropped (Angel Carpintero). + * Fix memory management in ffmpeg.c (Rafis Khayrullin). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x19x062432 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x19x062432 + * Fix of ffmpeg_avcodec_log code (Alain Guidez). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x25x074612 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x25x074612 + * Fix a segfault adding correct size to be used for bayer2rgb24() + (Damian Wrobel) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x30x175913 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x30x175913 + * Fix an error in FreeBSD, the use of capture even fields depends on height + value. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x03x073610 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x03x073610 + * Fixed autodetection for VIA cpu, no needed to use --without-optimizecpu. + Added many others (Angel Carpintero) + * Fix, don't remove pid file when motion reload config file( HUP signal ) +@@ -184,12 +312,12 @@ Bugfixes + * Fixed the thread number assignment which could goof up if netcams started + very quickly before all thread were created at startup. (Kenneth Lavrsen) + * Fix RoundRobin v4l2 buffers in driver when switching input, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x07x07x182605 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x07x07x182605 + (Dag Erlandsson and Angel Carpintero). + * Check EIO for VIDIOC_DQBUF to workaround saa7134 problem. + (Dag Erlandsson and Angel Carpintero). + * Change bayer2rgb24() to fix a problem with sn9c102 driver +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x06x05x012249 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x06x05x012249 + (Jared D and Angel Carpintero). + + 3.2.7 Formal Release - Summary of Changes +@@ -200,30 +328,30 @@ Features + than 2 frames per second (Kenneth Lavrsen and Angel Carpintero) + * Made the creation of reference frame and the decay mechanism depending + on how much motion was detected relative to threshold setting (Joerg Weber) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReferenceFramePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReferenceFramePatch + * Added process_id_file feature (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x06x06x123003 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x06x06x123003 + + Bugfixes + * Fixed problem related to fetching images from Network camera and error + handling when it fails. Motion would end in infinite loops (Bill Brack). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x10x000151 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x10x000151 + * Improved reporting of thread numbers during startup in setup mode. + (Peter Smith and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging + * Ffmpeg code mutex locking fix (Peter Smith) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 + * Ffmpeg avicodec logging improved (Peter Smith and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegAvicodecLogging ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegAvicodecLogging + * Improved upon a few ambiguous log messages which may be emitted by the Event + handling code with regards to Ffmpeg (Peter Smith) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LoggingEventFix ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LoggingEventFix + * Implemented a fix for the rare problem where some experienced that the + move file names would only consist of the extension .mpg or .avi with no + name in front. The root cause was the use of sprintf for appending to + strings. (Mike Kenney and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2005x09x05x133031 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x06x19x174238 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2005x09x05x133031 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x06x19x174238 + * Altered the risky use of sprintf to snprintf in all places related to + use with config strings that can become very long (Kenneth Lavrsen) + * Removed annoying debug messages (v4l_set_input really needed ?) in the FreeBSD +@@ -236,20 +364,20 @@ Bugfixes + * Fixed interlace issue with METEOR_GEO_EVEN_ONLY in FreeBSD (Angel Carpintero) + * Fixed possible syntax error in configure related to MySQL (Angel Carpintero) + * Avoid open file descriptor when connecting to network cameras fails (Peter Holik) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidOpenfiledescriptors ++ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidOpenfiledescriptors + * Fixed http pause feature so that pausing thread 0 now pauses all threads. + (GunnarSkjold) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x10x111239 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x10x111239 + * Put a new global mutex around avcodec_close to avoid problems with not thread + safe functions in ffmpeg (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 + * On FreeBSD configure defines a redundant freebsd for motion. Fixed by replacing + -D__freebsd_ by BSD macro included in sys/param.h for BSD platforms. + (JukkaUkkonen and Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x070417 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x070417 + * For BSD platforms changed to using native pthreads as default and adding + linuxthreads as a optional parameter from configure. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x071646 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x071646 + * Smartmask overlay feature did not set intensity correctly. (Kenneth Lavrsen) + + +@@ -257,14 +385,14 @@ Bugfixes + * Fixed bug where variables time_last_frame and time_current_frame had been + extended to also be used for snapshot feature but declaration was hidden + between #ifdef HAVE_FFMPEG. (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x09x012244 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x09x012244 + * Fixed a bug that only allowed remote control of max 9 cameras. Now + Motion can present up to 99 cameras in its http remote control interface + (Angel Carpintero based on idea by Chuck Sheehan) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHttpManyThreads ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebHttpManyThreads + * text_changes now shows a '-' when motion detection is paused instead of + just showing 0 (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x03x16x095713 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x03x16x095713 + + 3.2.5.1 Doc and man page correction + * ffmpeg_filename has changed name to movie_filename to prepare for +@@ -285,30 +413,30 @@ Bugfixes + * Remove cpu optimization (is broken) + * Fixed memory leak in ffmpeg code. (Andrew Hamilton) + * Fixed http control of pan and tilt (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x12x22x122649 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x12x22x122649 + * Fixed netcamera bug related to separating frames in an mjpeg stream. + (Peter Holik). From mailing list 23 Dec 2005. + * Fix related to connecting to the netcam (William Black) + From mailing list 23 Dec 2005. +- * Changed CHANGELOG to same bullet format as used by Foswiki to make it easier ++ * Changed CHANGELOG to same bullet format as used by TWiki to make it easier + to write release notes (Kenneth Lavrsen) + * Changed CREDITS to same bullet format as CHANGELOG (Kenneth Lavrsen) + * Fixed sql_mask not initialised correctly (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x09x175603 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x09x175603 + * Fixed the management of strings from http remote control , setting to NULL + when they are set to "blank" and fixes a problem with despeckle , that didn't + allow to remove labeling action from http remote control. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixStringsAndDisableLabeling ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FixStringsAndDisableLabeling + * Fix many typos in comments ( i ran aspell against the code ). Also there's a + fix to free cnt->eventtime_tm when motion exits. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixTypoInComments ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FixTypoInComments + * Fix the problem that happens in FreeBSD and Debian Sarge because + version of ffmpeg is LIBAVFORMAT_BUILD < 4629. ( Pete Shipley and Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x12x120335 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x12x120335 + * Updated motion.spec. Changing D_FORTIFY_SOURCE=2 by D_FORTIFY_SOURCE=1 to fix + problem related to building with ffmpeg. (Angel Carpintero) + * Implemented fix for missed snapshots with slow network cameras (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x162149 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x162149 + * Added some constants in video.c function v4l_picture_controls() which can help + people hack an optimal set of values for controlling auto brightness for their + particular camera. For now I am do not want to add all of these to the already +@@ -316,19 +444,19 @@ Bugfixes + permanently change the constants and add an additional auto brightness option. + Or maybe a combined option that sets more constant based on an algorithm. + (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x212816 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x212816 + * Fixed a syntax error in picture.c get_pgm() which caused the program to segfault + when a mask file size did not match the picture size. Now the program + correctly gives an error message and continues without the mask. (Kenneth + Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x08x150720 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x08x150720 + * Added Tilt support to stepper track. ( Angel Carpintero ). + * CPU VIA Ezra C3 autodetection support added. (James Van Vleet) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/VIAEzraC3Patch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/VIAEzraC3Patch + * Fixed mysql configure auto-detection for x64 systems. ( Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x03x02x152208 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x03x02x152208 + * Added the ffmpeg_deinterlace feature (Andrew Hamilton) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionffmpegDeinterlace ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionffmpegDeinterlace + + 3.2.4 Formal Release. Summary of changes + +@@ -353,7 +481,7 @@ Features + after the camera has moved (auto or manual) during which motion detection + is disabled. This option should be set so low that the motion detection + is re-enabled the minute the camera is standing still again. +- * Added new sql_query option. This in combination with conversion ++ * Added new sql_query option. This in combination with convertion + specifiers incl the two new %f and %n enables the user to use any database + structure they please. Adding fields is now a simple matter of modifying + the sql query. +@@ -380,7 +508,7 @@ Features + and brightness, support large resolutions. + * RPM specs file changed as suggested for use in the Livna repository. + * Changed the sequence of events connected with creating files. Data is +- now written to the databases (if used) before an external commends is ++ now written to the databases (if used) before an external comments is + on (on_xxxx options) allowing the external program to use the new data + in the database. + * Motion is now also works on MaxOSX with similar feature set as FreeBSD. +@@ -427,21 +555,21 @@ snap1 + We now encourage developers to ensure that new code is checked with + --with-developer-flags and code made so that no new warnings shows originating + from the motion sources. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch + * Fixed error message with unknown config option (Bill Brack) + * Fixed small mistake in allocating memory for cnt->imgs.common_buffer + (Angel Carpintero). + * Implemented a speed-up patch of the draw text feature (Peter Holik). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextspeedup ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextspeedup + * http control updated: (null) messages replaced by "disabled", last parameter + in conf/list are displayed correctly and only in Main thread. When motion runs + with only one thread, it displays "No threads". (Angel Carpintero) + * Enhanced compatibility with Lumenera (Bill Brack) + * http control: selectbox instead of a textfield for changing boolean configs + (Peter Holik and Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebhttpEnhancements. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebhttpEnhancements. + * Introduced check for device image size being a multiple of 16 (Peter Holik). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamModulo16Patch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamModulo16Patch + * Added the debian sub directory so that people can build the deb package + (Angel Carpintero). + * Sync configure.in.freebsd (adding support for jpeg-mmx, developer-flags and +@@ -452,8 +580,8 @@ snap1 + cnt struct around just to be able to print the thread number in the log and + on the console. (Per Jönsson with additional removal of unused cnt by + Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadNrTlsPatch +- * Moved the motion_loop initialisation into a new function motion_init ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadNrTlsPatch ++ * Moved the motion_loop initialization into a new function motion_init + (Bill Brack). + * Removed old unused code related to read mode (not mmap) from V4L devices + (Kenneth Lavrsen). +@@ -481,7 +609,7 @@ snap1 + snap2 + * Simplified rotation code based on the fact that images must have dimensions + that are a multiple of 16 (Per Jönsson) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateSimplificationPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateSimplificationPatch + * Switchfilter feature repaired. It was called inside motion_detected() + after overlays on cnt->img.out were added which meant that the feature also + detected all the overlays, smartmasks, fixed mask and text. It is now moved +@@ -499,7 +627,7 @@ snap2 + and minimum_motion_frames images are time stamped before the event happens + so %C in text_left/right does not have any effect on those images (Kenneth + Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/EventConvertionSpecifierDiscussion ++ http://www.lavrsen.dk/twiki/bin/view/Motion/EventConvertionSpecifierDiscussion + * Renamed some variables related to time to be better descriptive of function + and type (Kenneth Lavrsen). + * Added new option 'sql_user_text'. This can be defined with the same +@@ -511,10 +639,10 @@ snap2 + + snap3 + * Enhancement to Netcam Code for Connection to Pixord Cameras (Bill Brack). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFixPixordBug ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFixPixordBug + * Implemented fix to configure so that LDFLAGS from the environment are used + when making the Makefile (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x09x15x185558 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x09x15x185558 + * Changed configure so that --with-jpeg-mmx is default off as a reaction to + known problems seen when using the jpeg-mmx library (Angel Carpintero). + * RPM specs file changed as suggested for use in the Livna repository. +@@ -523,35 +651,35 @@ snap3 + despeckle features are run. This should ensure that both algorithms work on + raw unfiltered motion pixels which they both were designed for. (Kenneth + Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x05x212444 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x05x212444 + + snap4 + * Integrated NetcamWithFtp patch. To use ftp simply use a URL starting with + ftp:// (Bill Brack). Code was additionally cleaned up by Kenneth Lavrsen. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFTP ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFTP + * Changed error handling in vid_start so that failing to open the video + device no longer causes an exit but a return with error code -1. (Kenneth + Lavrsen) + * Added the %t conversion specifier to show the thread number. (Angel + Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadConversionSpecifierPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadConversionSpecifierPatch + * Added help texts in conf.c and motion-dist.conf describing the %t + specifier. Added a good example of use in motion-dist.conf. (Kenneth + Lavrsen). + * Fixed bug related to init of mutex in netcam code (Angel Carpintero). + * Improved fix for netcam mutex init (Bill Brack). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFixPthreadInit ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFixPthreadInit + * Netcam_ftp code fixes (Angel Carpintero and Asbjørn Pettersen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFtpEnhancements ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFtpEnhancements + * Enhanced ffmpeg detection (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BetterFFmpegDetection ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BetterFFmpegDetection + * Added two new conversion specifiers: %f which is filename (full path) + and %n which is filetype (sqltype) valid in on_picture_save, on_movie_start, + on_movie_end and sql_query. This also means that filename is no longer + appended at the end of the 3 on_xxxx commands. (Kenneth Lavrsen) + * Removed the sql_user_text option that was added in snap 2 (Kenneth + Lavrsen) +- * Added new sql_query option. This in combination with conversion ++ * Added new sql_query option. This in combination with convertion + specifiers incl the two new %f and %n enables the user to use any database + structure they please. Added fields is now a simple matter of modifying + the sql query. The default is the same as the default in snap1. +@@ -569,7 +697,7 @@ snap4 + a good idea to setup width and height so it is the same as the netcam. + If the dimensions are the same Motion will switch over to the netcam + seemlessly. If the dimensions are different Motion will perform a quick +- restart so all the many internal buffers can be initialised properly ++ restart so all the many internal buffers can be initialized properly + (Kenneth Lavrsen). + * Added a better error handling of a netcam that changes dimensions + while Motion is running. Instead of just writing error messages Motion +@@ -584,7 +712,7 @@ snap5 + * Restored the function sigchild_handler so it contains the same code + as before motion-3.2.1_snap9. They is done in an attempt to fix an old + problem with zombie child processes that has shown up again. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x11x13x115016 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x11x13x115016 + (Kenneth Lavrsen). + * Move the declaration of sig_handler_action and sigchild_action from + the setup_signals function where they are local and will be destroyed +@@ -608,11 +736,11 @@ Release + is re-enabled the minute the camera is standing still again. Feature + originally made by Moshe Van Der Sterre. Kenneth Lavrsen extended it to + be more generic. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PwcConfiguration ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PwcConfiguration + * New Feature: Motion is now also supported on MaxOSX with similar + feature set as for Free BSD. See README.MacOSX for details how to install + it. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MacOSXPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MacOSXPatch + * Added a work-around so people in FreeBSD that uses a capture card + where input 1 is not tuner can use motion if frequency is set -1 in + motion.conf or thread#.conf (Angel Carpintero). +@@ -629,11 +757,11 @@ Release + not changed so that the ring buffer is used for timestamped images + and the image used for detection is in a buffer cnt->imgs.image_virgin. + (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x15x140701 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x15x140701 + * Auto brightness used the first image in ring buffer instead of the + latest image and it used an image with time stamping. It now uses the new + cnt->imgs.image_virgin buffer. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x15x160208 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x15x160208 + * Cleaned out unused code from httpd control (Angel Carpintero). + * Option switch_filter used print_int instead of print_bool when motion.conf + was saved (Kenneth Lavrsen). +@@ -704,15 +832,15 @@ Bug Fixes + 3.2.2 Detailed changes for 3.2.2 + snap1 + * Pthread deadlock in motion 3.2.1 fixed (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x26x125712 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x26x125712 + * http lockup bugfixes and ConvertSignalToSigaction only for webhttpd + (Angel Carpintero) + * alg_draw_location: Use temporary variables to store the values used in + for() loops instead of compute them in each loop (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImproveAlgDrawLocation ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ImproveAlgDrawLocation + * Small speed boost to the function draw_textn (Andrew Hamilton and + Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextnImprovement ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextnImprovement + * Added two new convertion specifiers: %o for threshold and %Q for number + of labels. (Kenneth Lavrsen) + * Improved the config file description for pre_capture to get people to +@@ -723,7 +851,7 @@ snap2 + strdup to avoid segfault is target_dir parameter is not supplied in + motion.conf. Moves out from signal handler the cleanup for pipe and mpipe. + (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidCleanupSegfault ++ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidCleanupSegfault + * Major code cleanup concerning signedness of chars all over the code to + allow compilation with gcc4.0 (like in Fedora Core 4) without any + errors or warnings. This will probably require that some of the not yet +@@ -752,27 +880,27 @@ snap4 + * Netcam First Header patch. If an error with jpeg decompression occurred at + connecting to a mjpeg streaming webcam, this patch skips this jpeg and tries + to decompress next jpeg up to MAX_HEADER_RETRIES (20) (Peter Holik). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFirstHeader ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFirstHeader + + snap5 + * Small improvement in framerate accuracy (Peter Holik). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FramerateAdjust ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FramerateAdjust + * Fixed a bug in the autobrightness algorithm (Per Johnsson) + * Fixed a bug in the webhttpd code related to pan/tilt. Bug was introduced in + snap4 (Angel Carpintero, Kenneth Lavrsen). + * Improved the labelling algorithm so that locate feature and tracking features + includes all labelled areas above threshold (Joerg Weber). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImprovedLabellingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ImprovedLabellingPatch + * Fixed bug reporting errors when creating symlink to last snap (Bill Maidment) + * Changed all use of localtime to localtime_r which is threadsafe + (Kenneth Lavrsen). + * Implemented a modified version of the WebcamCompressInMemory so that Motion + no longer uses the tmpfile() function for buffering the frames of the mjpeg + stream (Peter Holik). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory + * Modified the WebcamCompressInMemory patch so that Motion now supports the + mjpeg webcam stream while being setup for saving PPM images (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory + * Major clean-up of code in picture.c and webcam.c so that function names and + variable names are less confusing. Also added many comments in picture.c. + (Kenneth Lavrsen). +@@ -787,13 +915,13 @@ snap6 + + snap7 + * Implemented WebcamShortWriteHandling patch (Bill Brack) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamShortWriteHandlingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamShortWriteHandlingPatch + * Implemented the libjpeg-mmx patch. Installing the MMX version of libjpeg + can increase performance. Especially for machines with very little CPU power. + It only modifies the configure script. If you do not have the libjpeg-mmx + the configure script with ignore this and use the standard libjpeg. + Note that RPMS will be built without this (Peter Holik and Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LibJpegMmx ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LibJpegMmx + + snap8 + * Small code cleanup in webcam.c and picture.c and .h for the webcam code +@@ -803,19 +931,19 @@ snap8 + overflow every 71 minutes. (Bill Brack and Kenneth Lavrsen) + * Implemented a fix/work around to a bug related to building and installing + RPMs on Suse. (Paul Beltrani) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x07x14x212356 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x07x14x212356 + * Small speed optimization in the creation of reference frame (Peter Holik). + * Complete rewrite of the Netcam code. Should fix many of the reported and + still open netcam bugs. This is first release in a snapshot. Expect to find + bugs. Testing is important. If you have a netcam please test this and report + bugs. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamCodeRewritePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamCodeRewritePatch + + snap9 + * Fixed bug related to disabled webcam or duplicate webcam port. Error log + accept(): Socket operation on non-socket continuously written to syslog. + (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x01x150922 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x01x150922 + * Fixed memory leak in webhttpd related to use of strdup (Angel Carpintero). + * Improved the error reporting in the Netcam code and did a few minor + corrections and code cleanups (Bill Brack). +@@ -823,21 +951,21 @@ snap9 + calls to printf and syslog. The implementation to actually use this has been + implemented in video.c and the Netcam code files. Rest will be in next snap. + This code change as no impact to the user (Bill Brack). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch + * Fixed a bug in video.c so that VIDEO_PALETTE_GREY cameras now actually work + (Bill Brack). + * Implemented the conversion of signal to sigaction which should be more + thread safe. Hopefully this still keeps Motion from making Zombies. + (Christophe Grenier). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ConvertSignalToSigaction ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ConvertSignalToSigaction + * Added new feature: Double size text. A new config option 'text_double' can + be set 'on' and this scales the text to double size. Default is off. + (Andrew Hamilton). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/TextScalingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/TextScalingPatch + + snap10 + * Error Logging Enhancement Patch v 1.3 (Angel Carpintero) including: +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch + * Populate the motion_log to the whole motion source code. + * Fixed FreeBSD compilation. + * Added the possibility to pass NULL as struct context * +@@ -853,9 +981,9 @@ snap10 + * fixed bug where initialization would be incomplete for invalid degrees + of rotation + * now uses motion_log for error reporting +- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateBswapFix ++ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateBswapFix + * Re-mplementation of optional Proxy Server for Network Cameras (Bill Brack). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamProxyServerPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamProxyServerPatch + * Included a CODE_STANDARD text file to help new developers make patches + that are easier to integrate without too much manual editing. (Kenneth + Lavrsen) +@@ -864,7 +992,7 @@ snap10 + snap11 + * Updated the ffmpeg.c code so that Motion can now be built with ffmpeg CVS + release from the June/July 2005 timeframe (Per Jönsson). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegCodecPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegCodecPatch + * Improved error handling of missing picture frames from camera. Especially + network cameras will often not be able to provide a picture frame from time + to time. Motion would retry before and eventually and rather quickly exit +@@ -884,12 +1012,12 @@ snap11 + "Without Locking" portion of his proposal). + Version 2 however does not seems to recover when an mjpeg stream resumes + after a period of not being available. (Bill Brack) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamErrorImprovementPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamErrorImprovementPatch + * Note: Snap11 release as a developer sync release. Bug reports welcome. + FreeBSD code changes not tested yet. + + Release +- * Netcam error handling improvements and cleanup from Walgrind analysis ++ * Netcam error handling improvements and cleanup from Valgrind analysis + (Bill Brack). + * Added a configure option --with-developer-flags which enables many compiler + warnings that can be used by developers to make code more robust. Not +@@ -897,12 +1025,12 @@ Release + * http-control: Fixed segfault when motion is restarted from command line + ( kill -s 1 pid_motion ). Improved control code so Motion can Restart and + Finish 'smoothly'. (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Changed the 5 second missed camera signal timeout to 30 seconds. (Kenneth + Lavrsen) + * Fixed bug where an extra jpeg is saved if you have output_normal=best + and you stop motion after an event has ended. (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x05x173526 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x05x173526 + + + +@@ -910,19 +1038,19 @@ Release + snap1 + * Major new feature. XMLRPC is replaced by a simpler http remote control + interface (implemented by Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + + snap2 + * Fixed netcam->userpass problem (Angel Carpintero) + * Added support in configure for athlon64 from +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x190907 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x190907 + (Angel Carpintero and William M Brack) + * Fixed some gcc warnings (William M Brack) + * Code cleanup from a valgrind analysis (William M. Brack). + + snap3 + * Added Best Preview Patch (Joerg Weber) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BestPreviewShot ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BestPreviewShot + + snap4 + * Fix for tracking control with http control (Angel Carpintero) +@@ -932,7 +1060,7 @@ snap4 + for daemon mode debugging. + The patch is still being worked on and is not finished. + Changes in the FreeBSD code are not yet tested. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SetupModePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SetupModePatch + Remove most command line options and replace them by an option to specify + location to motion.conf and a few options related to setting up motion. + (Joerg Weber). This is also included in SetupModePatch. +@@ -948,7 +1076,7 @@ snap5 + + snap6 + * Netcam fixes and debug code by Christopher Price +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + snap5_post1_video.c and snap5-post1 patches + * Fixed netcam startup race condition. + * Refactored image handling back to single unified function +@@ -1017,20 +1145,20 @@ snap9 + snap10 + * Fixed a problem when compiling with --without-v4l configuration. + (Philip Marien) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x27x112843 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x27x112843 + * Threw away the file descriptor leak fix from snap 9 because it caused + more trouble than it fixed. Removed the close_anything_open() and the + cnt_list.control_socket_server field. Replaced it all with a simple + piece of code that all server daemons call when started: setsid() followed + by for (i=getdtablesize(); i>2; --i) close(i). Dirty and simple. + (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x21x070534 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x21x070534 + * Fixed a bug where rate of fetching picture frames was disturned by + the signal SIG_CHLD from exec_command programs terminating. The symptom + was that the number of post_capture frames became inaccurate and motion + in mpegs did not have constant time between frames. (Kenneth Lavrsen) + * Fixed a bug where motion did not work with gap=1 (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x073616 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x073616 + * Added the feature gap=0 which now also works. It disables gap completely + so that one single mpeg file is created. You can end the event from the + remote control interface make movie feature using for example cron. +@@ -1058,11 +1186,11 @@ snap11 + Movie starts (mpeg file opened) --- onmpeg --- on_movie_start + Movie ends (mpeg file closed) --- onffmpegclose --- on_movie_end + Motion detected --- New! --- on_motion_detected +- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxCommandsPatch and +- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxxFeatureDiscussion ++ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxCommandsPatch and ++ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxxFeatureDiscussion + (Joerg Weber) + * More Netcam Stability Fixes (snap10-post1-6) (Christopher Price) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + * Destroy mutexes in netcam_cleanup(). + * Add reconnection for netcam_start() - this may block other cameras + from starting up!. +@@ -1093,11 +1221,11 @@ snap11 + + snap12 + * Fixed a bug in the rgb2yuv420p function. (Daniel Ladd) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x30x011107 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x30x011107 + * Fixed a bug of locate feature for movement images combined with the + new output_normal best feature (Joerg Weber) + * More Netcam Stability Fixes (snap11-post1-4) (Christopher Price) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + * Reworked thread signal/wait conditions, should fix some race conditions. + * Use gettimeofday() to determine thread timeouts, results in better accuracy. + * Adjusted condition timeouts to smaller values due to usage of gettimeofday() +@@ -1112,7 +1240,7 @@ snap12 + * Fix bug in streaming camera without content-length, recent mod broke. + * Fix bug in startup of single image reads without content-length. + * Motion Guide refactored completely for 3.2.1 with better web navigation and +- auto generation of pages. Makefile updated so that the Motion Foswiki topic ++ auto generation of pages. Makefile updated so that the Motion TWiki topic + MotionGuideOneLargeDocument is fetched when updating the guide and making + releases. (Kenneth Lavrsen). + +@@ -1135,7 +1263,7 @@ snap13 + * Userpass now allowed in url (http://user:pass@example.com/). + Netcam_userpass has precedence, it will override a userpass embedded in + the url. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + + snap14 + * Added basic authentication to the http control interface introducing new +@@ -1150,30 +1278,30 @@ snap14 + snap15 + * Added new feature which shows the fixed mask (in addition to the smart mask) + in bright red on the Motion type images (Joerg Weber). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch + * Added new feature. When you specify a mask file in the config file and start + Motion, and the mask file does not exist, Motion will create a new clear + (white) mask file for you in the right size. Then it is easy to simply + open the file in your favourite paint program and add the masking in black + (Joerg Weber). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch + * Fixed a bug in the low_cpu feature where cpu load increased instead of + decreasing because the framerate calculations were completely wrong. This was + an old bug introduced in 3.0.1 (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x04x24x205933 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x04x24x205933 + * Improved the auto-brightness algorithm. When auto-brightness is enabled + the brightness option becomes a target value for the brightness level. + This should also close a bug report (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x26x195358 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x26x195358 + * http interface small fixes (motion-3.2.1_snap14-small-fixes 1.1) incl + Add 'back' link to response_client errors (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Started adding tuner_number as option. This is not fully implemented. First + code is added and rest will be done in next snap. (Kenneth Lavrsen) + + snap16 + * Made the http control interface more RFC compliant (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x180550 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x180550 + * Made the http control HTML responses nicer to look at as sources and + therefore easier to debug errors (Kenneth Lavrsen). + * Code style cleanup of webhttpd.c (Kenneth Lavrsen). +@@ -1182,23 +1310,23 @@ snap16 + Carpintero. However this fix made Firefox flicker even more than it normally + does. Final fix which works in both Palantir client, Firefox and Cambozola + was made by Kenneth Lavrsen. This closes the following bugs: +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 + + snap17 + * Fixed small bug when pre_capture buffer is resized during operation. + (Joerg Weber). + * In httpd control code: Fixed RAW syntax following API specs. (Angel + Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Added new conversion specifiers: %D (diffs), (noise) %K (motion center x), + %L (motion center y), %i (locate width x) and %J (locate width y). These + changes also required a refactoring of the alg_locate code. This change + is part of the implementation of a generic tracking feature and it enables + implementing external programs that can perform simple prediction features. + (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion +- http://www.lavrsen.dk/foswiki/bin/view/Motion/GenericTrackingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion ++ http://www.lavrsen.dk/twiki/bin/view/Motion/GenericTrackingPatch + * Fixed a bug in switchfilter which caused motion detection to not work + when the feature was enabled (Kenneth Lavrsen). + +@@ -1206,26 +1334,26 @@ Release + * Change the working directory to / in daemon mode. This way you don't have + to kill motion to umount the partition from where you start it. (Christophe + Grenier) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch + * In netcam-wget header_get() didn't always in add a \0 string terminator. + This was fixed by Christophe Grenier +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch + * Fix for Unknown content type with lumenera cameras (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x06x174416 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x06x174416 + * MotionHttpControl Patch motion-3.2.1_snap18-pre1 v,1.0 19 May 2005. + Fixed some HTTP response codes and added header copyrights. (Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Implemented pthread fix by Christophe Grenier. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PthreadFixPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PthreadFixPatch + * Fixed problem compiling "ffmpeg reports only YUV420 is supported" when + ffmpeg is a recent CVS version. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x22x213229 +- * Man page updated. It is now semi-autogenerated in the Motion Foswiki ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x22x213229 ++ * Man page updated. It is now semi-autogenerated in the Motion TWiki + (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionOptionsAlphabeticalManpage ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionOptionsAlphabeticalManpage + * Bug fix in netcam code: Sometimes motion try to free an invalid memory area + (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x21x105335 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x21x105335 + * Small configure fix related to --without-v4l (Angel Carpintero) + * Fixes for http control HTML code (Angel Carpintero) + * Added init script to RPM (Angel Carpintero) +@@ -1235,15 +1363,15 @@ Release + snap1 + * Fixed bug which caused Motion 3.1.18 fail to save timelapse mpegs when + setting ffmpeg_timelapse = 1 (fixed by Michael Reuschling) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x31x211756 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x31x211756 + * Fixed several bugs in new netcam code introduced in 3.1.18 + (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x16x030209 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x01x071546 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x03x035918 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x16x030209 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x01x071546 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x03x035918 + * Added patch that enables Motion to work with vloopback version 0.94 + and kernel 2.6.10+. (patch by William M Brack). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch + + snap2 + * Following bugfixes all by Angel Carpintero +@@ -1307,17 +1435,17 @@ Detailed changes for all 3.1.18 snapshot + snap1 + * Removed the Berkeley mpeg feature (code commented out) + * Implemented a bugfixed version of +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BrightnessContrastPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BrightnessContrastPatch + Released as snapshot for developers to merge other patches. + The snap1 is not recommended for normal use. + + snap2 + * Improved the Makefile with automatic check of dependencies and + nicer output for the user. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MakefileWithAutoDependencies ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MakefileWithAutoDependencies + * Implemented first phase of the rotate patch. Need to fix the storage + method for image height and width +- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotatePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/RotatePatch + + snap3 + * Implemented phase 2 of the rotate patch +@@ -1327,7 +1455,7 @@ snap4 + * Added the new smart mask feature. It is working but it is still under + development. It currently outputs an extra smart mask timelapse movie + when the normal timelapse is enabled. This will be removed in the final +- version. http://www.lavrsen.dk/foswiki/bin/view/Motion/PatchSmartMask ++ version. http://www.lavrsen.dk/twiki/bin/view/Motion/PatchSmartMask + * Added a new config option --without-optimizecpu which disables the + CPU specific compiler optimizations introduced with the rotate phase 2 + patch. The purpose of the new option is to enable a packager to build +@@ -1344,7 +1472,7 @@ snap4 + getting lost when saving with xmlrpc. For text_left and text_right + Motion now puts the string in quotation marks if the value starts with + a leading space. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x24x135840 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x24x135840 + + snap5 + * Implemented the November 10 update for smartmask +@@ -1353,7 +1481,7 @@ snap5 + + snap6 + * Merged in the DilateNineSpeedPatch +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DilateNineSpeedPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DilateNineSpeedPatch + * Changed a few image char definitions to unsigned char. Still many to fix. + + snap7 +@@ -1364,10 +1492,10 @@ snap7 + The patch is now in ReleasedScheduled state for 3.1.18. + * Implemented Angel Carpintero's FreeBSD auto-detection CPU/ARCH fix. + * Merged in Per Johnsson's DilateFiveSpeedPatch +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DilateFiveSpeedPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DilateFiveSpeedPatch + * Removed the prediction feature from the code (commented out for now). + * Included fix by Jan X. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x11x13x202132 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x11x13x202132 + + snap8 + * Implemented an improvement of Smartmask so that the mask is cleared when +@@ -1377,40 +1505,40 @@ snap8 + * Improved the picture control function so that cameras are only probed + when needed to avoid USB errors. (Kenneth Lavrsen) + * Implemented new ffmpeg patch (Per Jönsson) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegPatch049 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegPatch049 + * Implemented new preview patch (Joerg Weber) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewShotsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewShotsPatch + * Removed commented code from obsolete Berkeley and Prediction features + * Implemented labelling speed patch (Per Jönsson) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LabelingSpeedPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LabelingSpeedPatch + + snap9 + * Implemented Streaming Netcam Without Curl which enables connecting to + network cameras both with single jpeg frame mode and streaming mjpeg + mode. This enables much higher framerates with Netcams. (by Christopher + Price and Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/StreamingNetcamWithoutCurl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/StreamingNetcamWithoutCurl + * Implemented a significant speed improvement in the motion detection + algorithm (by Per Jönsson). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/AlgDiffStandardMmxPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/AlgDiffStandardMmxPatch + * Fixed a small bug which caused in jumpy mpeg1 videos with ffmpeg 0.4.8. + + snap10 + * Corrected a small error in the usage help text +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x05x174139 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x05x174139 + * Improved the help text for config option night_compensate in docs, + conf.c, motion man pages and config file. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x103939 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x103939 + * Improved the Netcam patch (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ ++ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ + (pre2 patch fixes problem with not detecting Content-length and segfaults + in netcam) + * Improved the signal handling of ctrl-C as suggested by Per Jonsson +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x181426 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x181426 + * Implemented a POSIX compliant SIGCHLD signal handler as replacement for + the traditional signal(SIGCHLD, SIG_IGN) which can cause floods of + warnings in some RedHat versions. (Angel Carpintero and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x26x134906 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x26x134906 + * Changed the reporting of the changes of noise detection level so that + it is only displayed in the console (daemon off) when the always_changes + option is enabled. (Kenneth Lavrsen) +@@ -1423,7 +1551,7 @@ snap11 + * The noise tune value displayed in the upper left corner along with + number of changed pixels is no longer displayed (was there for debugging). + * Improved the Netcam patch (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ ++ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ + (pre3 reconnection feature added) + * Changed the SIGCHLD handler introduced in snap10 so that it is a shorter + and faster function. Disabled this handler in the xmlrpc thread as this +@@ -1434,7 +1562,7 @@ snap11 + very high or the time was changes by ntp. Motion will now catch up a few + seconds later if this happens. Also fixed the code for monthly rollover + (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x23x133554 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x23x133554 + + Release + * Fixed a bug in the timelapse feature. Both the rollover events of the +@@ -1442,7 +1570,7 @@ Release + very high or the time was changes by ntp. Motion will now catch up a few + seconds later if this happens. Also fixed the code for monthly rollover + (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x23x133554 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x23x133554 + * Small improvement in timelapse feature so that an image is added when + the new mpeg is created and not waiting till the following timelapse + (Kenneth Lavrsen). +@@ -1456,15 +1584,15 @@ snap1 + when Motion receives SIGTERM or SIGHUB. + * Implemented fix for compiling errors when building the FreeBSD version + without bktr support. +- (http://www.lavrsen.dk/foswiki/bin/view/Motion/FreeBSDFixCompile) ++ (http://www.lavrsen.dk/twiki/bin/view/Motion/FreeBSDFixCompile) + * Commented out many unnecessary syslog debug only messages. The commented + out code was first patched by Mike Lees patch related to syslog causing + instability and hanging motion processes. +- (http://www.lavrsen.dk/foswiki/bin/view/Motion/SyslogEventPatch). ++ (http://www.lavrsen.dk/twiki/bin/view/Motion/SyslogEventPatch). + * Included Kalle Andersson's patch that ensures that Motion detaches from + the stdin and stout devices so that a secure shell that was used to start + Motion in daemon mode does not hang when you exit the shell. +- (http://www.lavrsen.dk/foswiki/bin/view/Motion/DaemonDetachFromSTDIO) ++ (http://www.lavrsen.dk/twiki/bin/view/Motion/DaemonDetachFromSTDIO) + + snap2 + * Implemented a new lightswitch feature so that is now triggers lightswitch +@@ -1797,7 +1925,7 @@ rc1 + is in "idle" mode. + * added Kenneth's patch: motion with ffmpeg-0.4.8 now compiles + again! +- * small optimalisation: if a file is created, the path is now ++ * small optimisation: if a file is created, the path is now + only recreated when it did not already exist. + + +@@ -2083,7 +2211,7 @@ van Heusden (http://www.vanheusden.com/) + -locate is on by default (-l function now works reversed) + -night_compensate is on by default + Added mpeg framerate adjustment. +- Added night_compenstate for dark pictures. ++ Added night_compensate for dark pictures. + + 2.0 froze 2.0 + Integrated motion tracking. +--- motion-3.2.12.orig/CODE_STANDARD ++++ motion-3.2.12/CODE_STANDARD +@@ -17,7 +17,8 @@ void * mymalloc(size_t nbytes) + void *dummy = malloc(nbytes); + if (!dummy) { + printf("Could not allocate %llu bytes of memory!\n", (unsigned long long) nbytes); +- syslog(LOG_EMERG, "Could not allocate %llu bytes of memory!", (unsigned long long) nbytes); ++ syslog(EMERG, TYPE_ALL, "%s: Could not allocate %llu bytes of memory!", ++ __FUNCTION__, (unsigned long long) nbytes); + exit(1); + } + +@@ -41,8 +42,8 @@ void * mymalloc(size_t nbytes) + if (!dummy) { + printf("Could not allocate %llu bytes of memory!\n", + (unsigned long long) nbytes); +- syslog(LOG_EMERG, "Could not allocate %llu bytes of memory!", +- (unsigned long long) nbytes); ++ syslog(EMERG, TYPE_ALL,"Could not allocate %llu bytes of memory!", ++ __FUNCTION__, (unsigned long long) nbytes); + exit(1); + } + +--- motion-3.2.12.orig/CREDITS ++++ motion-3.2.12/CREDITS +@@ -32,14 +32,14 @@ Ryan Ayers + Paul Beltrani + * Implemented a fix/work around to a bug related to building and installing + RPMs on Suse. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x07x14x212356 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x07x14x212356 + + Michael Newlyn Blake + * For setting up the motion mailinglist and the onsave command. + + Krzysztof Blaszkowski + * Removed a duplicate call to jpeg_destroy_decompress already is called from netcam_image_conv. +- * Added V4L2 support http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). ++ * Added V4L2 support http://www.lavrsen.dk/twiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). + + Mathias Bogaert + * Lots of good ideas and the motion logos +@@ -47,30 +47,30 @@ Mathias Bogaert + William M Brack + * Added patch that enables Motion to work with vloopback version 0.94 + and kernel 2.6.10+. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch + * Added support in configure for athlon64 from +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x190907 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x190907 + (Angel Carpintero and William M Brack) + * Fixed some gcc warnings + * Code cleanup from a valgrind analysis. + * Implemented WebcamShortWriteHandling patch +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamShortWriteHandlingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamShortWriteHandlingPatch + * Small code cleanup in motion.c for the variable holding the number of + microseconds since epoch. The old code worked fine but relied on an integer + overflow every 71 minutes. (Bill Brack and Kenneth Lavrsen) + * Complete rewrite of the Netcam code. Should fix many of the reported and + still open netcam bugs. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamCodeRewritePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamCodeRewritePatch + * Improved the error reporting in the Netcam code and did a few minor + corrections and code cleanups. + * Implemented a much easier to use motion_log function which replaces the + calls to printf and syslog. The implementation to actually use this has been + implemented in video.c and the Netcam code files. Rest will be in next snap. + This code change as no impact to the user. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch + * Fixed a buf in video.c so that VIDEO_PALETTE_GREY cameras now actually work. + * Re-mplementation of optional Proxy Server for Network Cameras. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamProxyServerPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamProxyServerPatch + * Added the missing rotate feature in the new netcam code (Billl Brack) + * Netcam error handling improvements and cleanup from Valgrind analysis. + * Added a configure option --with-developer-flags which enables many compiler +@@ -80,7 +80,7 @@ William M Brack + ./configure --with-developer-flags. + The modifications were done by the following people: Peter Holik, Bill Brack, + Angel Carpintero and Kenneth Lavrsen. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch + * Fixed error message with unknown config option. + * Enhanced compatibility with Lumenera. + * Moved the motion_loop initialization into a new function motion_init. +@@ -89,17 +89,17 @@ William M Brack + * Last --with-developer-flags warnings eliminated simply by swapping the + order of the #include statements in the sources (Bill Brack and Kenneth Lavrsen). + * Enhancement to Netcam Code for Connection to Pixord Cameras. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFixPixordBug ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFixPixordBug + * Fix related to connecting to the netcam. From mailing list 23 Dec 2005. + * Fixed problem related to fetching images from Network camera and error + handling when it fails. Motion would end in infinite loops. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x10x000151 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x10x000151 + * Fix conv_uyvyto420p segfault. + * Enhancing the palette selection. + + John Bray + * Get current directory to allow write motion.conf properly +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x013419 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x013419 + + Andy Brown + * Add swf codec to video creation (on behalf of Bowser Pete). +@@ -130,21 +130,21 @@ Angel Carpintero + mode. This enables much higher framerates with Netcams. (with + Christopher Price). + * Improved the Netcam patch (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ ++ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ + (pre2 patch fixes problem with not detecting Content-length and segfaults + in netcam) + * Implemented a POSIX compliant SIGCHLD signal handler as replacement for + the traditional signal(SIGCHLD, SIG_IGN) which can cause floods of + warnings in some RedHat versions. (with Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x26x134906 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x26x134906 + * Improved the Netcam patch (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ ++ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ + (pre3 reconnection feature added) + * Fixed several bugs in new netcam code introduced in 3.1.18 + (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x16x030209 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x01x071546 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x03x035918 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x16x030209 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x01x071546 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x03x035918 + * Netcam code: Change printf() to fprintf(). + * Netcam code: Cleanup memory netcam (netcam.c , motion.c ). + * Netcam code: Redesign of reconnection feature. +@@ -154,10 +154,10 @@ Angel Carpintero + * Added fix to BugReport2005x02x11x150802 + * Major new feature. XMLRPC is replaced by a simpler http remote control + interface. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Fixed netcam->userpass problem + * Added support in configure for athlon64 from +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x190907 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x190907 + (Angel Carpintero and William M Brack) + * Updated code so Motion again runs on FreeBSD. + * Removed check for memmem from configure. +@@ -174,42 +174,42 @@ Angel Carpintero + (string) by submitting blank entry field in the http control interface. + * http interface small fixes (motion-3.2.1_snap14-small-fixes 1.1) incl + Add 'back' link to response_client errors. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Made the http control interface more RFC compliant. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x180550 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x180550 + * Fixed compatibility problem with Palantir. Fixed by making output more + compatible with RFC (\r\n). Original fixes by Roberto Spadim and Angel + Carpintero. However this fix made Firefox flicker even more than it normally + does. Final fix which works in both Palantir client, Firefox and Cambozola + was made by Kenneth Lavrsen. This closes the following bugs: +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 + * In httpd control code: Fixed RAW syntax following API specs. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * MotionHttpControl Patch motion-3.2.1_snap18-pre1 v,1.0 19 May 2005. + Fixed some HTTP response codes and added header copyrights. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl + * Fixed problem compiling "ffmpeg reports only YUV420 is supported" when + ffmpeg is a recent CVS version. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x22x213229 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x22x213229 + * Bug fix in netcam code: Sometimes motion try to free an invalid memory area +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x21x105335 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x21x105335 + * Small configure fix related to --without-v4l. + * Fixes for http control HTML code. + * Added init script to RPM. + * Pthread deadlock in motion 3.2.1 fixed. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x26x125712 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x26x125712 + * http lockup bugfixes and ConvertSignalToSigaction only for webhttpd + * alg_draw_location: Use temporary variables to store the values used in + for() loops instead of compute them in each loop +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImproveAlgDrawLocation. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ImproveAlgDrawLocation. + * Small speed boost to the function draw_textn (Andrew Hamilton and + Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextnImprovement ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextnImprovement + * Avoid Cleanup Segfault. Avoid Cleanup Segfault. Allocates filepath using + strdup to avoid segfault is target_dir parameter is not supplied in + motion.conf. Moves out from signal handler the cleanup for pipe and mpipe. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidCleanupSegfault ++ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidCleanupSegfault + * Changed the configure script so that rpms can be made by normal non-root + users. + * Above change in configure script for 64 bit ffmpeg support also implemented +@@ -222,7 +222,7 @@ Angel Carpintero + It only modifies the configure script. If you do not have the libjpeg-mmx + the configure script with ignore this and use the standard libjpeg. + Note that RPMS will be built without this (Peter Holik and Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LibJpegMmx ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LibJpegMmx + * Fixed memory leak in webhttpd related to use of strdup. + * Error Logging Enhancement Patch v 1.3 including: + * Populate the motion_log to the whole motion source code. +@@ -234,25 +234,25 @@ Angel Carpintero + * Fixed a bug when not motion.conf is found + * Removed printf from all files + * Fixed the conf_list[] index in motion.c +- * http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch ++ * http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch + * http-control: Fixed segfault when motion is restarted from command line + ( kill -s 1 pid_motion ). Improved control code so Motion can Restart and + Finish 'smoothly'. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl. + * Fixed a bug in the http control code that failed to accept a client + connecting in some systems + * Removed all warnings originating from the motion sources when running + ./configure --with-developer-flags. + The modifications were done by the following people: Peter Holik, Bill Brack, + Angel Carpintero and Kenneth Lavrsen. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch + * Fixed small mistake in allocating memory for cnt->imgs.common_buffer. + * http control updated: (null) messages replaced by "disabled", last parameter + in conf/list are displayed correctly and only in Main thread. When motion runs + with only one thread, it displays "No threads". + * http control: selectbox instead of a textfield for changing boolean configs + (Peter Holik and Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebhttpEnhancements. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebhttpEnhancements. + * Added the debian sub directory so that people can build the deb package. + * Sync configure.in.freebsd (adding support for jpeg-mmx, developer-flags and + some cosmetic changes ). +@@ -271,20 +271,20 @@ Angel Carpintero + * Cleanup code and fix warnings. + * Implemented fix to configure so that LDFLAGS from the environment are used + when making the Makefile. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x09x15x185558 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x09x15x185558 + * Changed configure so that --with-jpeg-mmx is default off as a reaction to + known problems seen when using the jpeg-mmx library. + * Added the %t conversion specifier to show the thread number. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadConversionSpecifierPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadConversionSpecifierPatch + * Fixed bug related to init of mutex in netcam code. + * Netcam_ftp code fixes (Angel Carpintero and Asbjørn Pettersen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFtpEnhancements ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFtpEnhancements + * Enhanced ffmpeg detection. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BetterFFmpegDetection ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BetterFFmpegDetection + * New Feature: Motion is now also supported on MaxOSX with similar + feature set as for Free BSD. See README.MacOSX for details how to install + it. (Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MacOSXPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MacOSXPatch + * Added a work-around so people in FreeBSD that uses a capture card + where input 1 is not tuner can use motion if frequency is set -1 in + motion.conf or thread#.conf. +@@ -298,28 +298,28 @@ Angel Carpintero + * Remove a warning when used --without-bktr + * Remove cpu optimization (is broken) + * Fixed http control of pan and tilt. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x12x22x122649 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x12x22x122649 + * Fixed sql_mask not initialised correctly +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x09x175603 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x09x175603 + * Fixed the management of strings from http remote control , setting to NULL + when they are set to "blank" and fixes a problem with despeckle , that didn't + allow to remove labeling action from http remote control. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixStringsAndDisableLabeling ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FixStringsAndDisableLabeling + * Fix many typos in comments ( i ran aspell against the code ). Also there's a + fix to free cnt->eventtime_tm when motion exits. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixTypoInComments ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FixTypoInComments + * Fix the problem that happens in FreeBSD and Debian Sarge because + version of ffmpeg is LIBAVFORMAT_BUILD < 4629. ( Pete Shipley and Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x12x120335 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x12x120335 + * Updated motion.spec. Changing D_FORTIFY_SOURCE=2 by D_FORTIFY_SOURCE=1 to fix + problem related to building with ffmpeg. (Angel Carpintero) + * Added Tilt support to stepper track. + * Fixed mysql configure auto-detection for x64 systems. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x03x02x152208 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x03x02x152208 + * Fixed a bug that only allowed remote control of max 9 cameras. Now + Motion can present up to 99 cameras in its http remote control interface + (Angel Carpintero based on idea by Chuck Sheehan) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHttpManyThreads ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebHttpManyThreads + * Removed annoying debug messages (v4l_set_input really needed ?) in the FreeBSD + version. + * Added new feature: minimum_frame_time which enables capturing at a lower rate +@@ -331,97 +331,112 @@ Angel Carpintero + safe functions in ffmpeg + * Put a new global mutex around avcodec_close to avoid problems with not thread + safe functions in ffmpeg. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 + * On FreeBSD configure defines a redundant freebsd for motion. Fixed by replacing + -D__freebsd_ by BSD macro included in sys/param.h for BSD platforms. + (JukkaUkkonen and Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x070417 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x070417 + * For BSD platforms changed to using native pthreads as default and adding + linuxthreads as a optional parameter from configure. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x071646 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x071646 + * Added process_id_file feature +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x06x06x123003 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x06x06x123003 + * Add connection status for all devices available from http web interface. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x11x09x050638 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x11x09x050638 + * Improved deb packaging , install the init.d script. + * Reconnect to mysql if connection dropped. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x10x10x081903 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x10x10x081903 + * Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero ) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch +- * Added V4L2 support http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch ++ * Added V4L2 support http://www.lavrsen.dk/twiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). + * Added support for V4L2_PIX_FMT_SBGGR8 ( bayer ), V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_MJPEG and V4L2_PIX_FMT_UYVY. + * Added a FreeBSD directory to allow people from BSD to get a daily version and create a port. + * Removed mysql dependency from debian package and added a note to setup motion to run as daemon to create the pid file. +- * Changed the way configure search mysql headers and libs, added 3 parameters to configure --without-mysql to disable support, --with- mysql-include directory of mysql.h and --with-mysql-lib directory of libmysqlclient.a or libmysqlclient.so ++ * Changed the way configure search mysql headers and libs, added 3 parameters to configure --without-mysql to disable support, ++ --with-mysql-include directory of mysql.h and --with-mysql-lib directory of libmysqlclient.a or libmysqlclient.so + * Fix an error in FreeBSD , the use of capture even fields depends on height value. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x03x073610 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x03x073610 + * Fixed autodetection for VIA cpu , no needed to use --without-optimizecpu. Added many others. + * Fix , don't remove pid file when motion reload config file( HUP signal ). + * Fix compilation broken by uvc track type. + * Fix RoundRobin v4l2 buffers in driver when switching input, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x07x07x182605 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x07x07x182605 + (Dag Erlandsson and Angel Carpintero). + * Check EIO for VIDIOC_DQBUF to workaround saa7134 problem. + (Dag Erlandsson and Angel Carpintero). + * Change bayer2rgb24() to fix a problem with sn9c102 driver +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x06x05x012249 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x06x05x012249 + (Jared D and Angel Carpintero). + * Added MYSQL_OPT_RECONNECT flag for mysql connection (MYSQL 5.x only) and + changed default value for mysql_host. + * Fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391055 , change + motion man page , -d requires level. + * Handle mjpeg decoding and fix colour issue adding mjpegtools dependency +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegColorIssue +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegToYUV420pPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegColorIssue ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch + (Marius Rieder, Angel Carpintero). + * Fix segfault in webhttpd.c on motion restart. +- * Fix segfault in debian http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x09x24x175945 ++ * Fix segfault in debian http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x09x24x175945 + * Add debug level > 5 to get logs from v4l2_select_input, v4l2_set_control and v4l2_set_input. + * Removed debian ( to avoid conflicts with debian package) and FreeBSD + ( no needed to deploy BSD port here ) directories. + * Improve debian package, create user/group motion and added --chuid motion to init script. +- * Added help in http control http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x181541 +- * Fixed http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x23x093651 ++ * Added help in http control http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x181541 ++ * Fixed http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x23x093651 + * Fix process_id_file when is passed from command line +- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x27x150419 +- * Added Choose V4L2 palette http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x032318 ++ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x27x150419 ++ * Added Choose V4L2 palette http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x032318 + * Improved in http control ( 'back' link, select box, show current values when are going to be changed ). +- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x25x102808 ++ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x25x102808 + * Avoid random errors , initialising some structs for V4L1 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) + * Fix motion segfault because ffmpeg API change +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2007x12x29x17553 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2007x12x29x17553 + * Little fix in ffmpeg.c comparing version of LIBAVFORMAT_BUILD, since ffmpeg svn -r4486 LIBAVFORMAT_BUILD and + LIBAVCODEC_BUILD uses LIBAVFORMAT_VERSION_INT ((49<<16)+(0<<8)+0) and LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+0) + * Fix broken PostgreSQL detection for custom location, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x025134 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x025134 + * Fixed stepper when is used track_auto on. + * Added to configure.in --with-pwcbsd to allow compile motion in freebsd with webcam support instead of bktr. ++ * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 ++ (Jeroen Massar & Angel Carpintero) + * Fix a security issue in web control interface http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484572 + * Fix Problem Encoding 1280x1024 resolution videos +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x06x11x183727 +- * Remove mjpegtools dependencies and integrate only needed functions from library. +- * Fix rotate for v4l2 devices using JPEG / MJPEG palettes. +- * Allow change/setup framerate in FreeBSD using pwcbsd. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x06x11x183727 ++ * Add write/read nonblock functions in webhttpd( timeout on read/write). + * Add a new parameter netcam_tolerant_check, to be less strict with some buggy network cameras firmwares. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x06x19x123218 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x06x19x123218 ++ * Remove mjpegtools dependencies and integrate only needed functions from library. ++ * Fix rotate for v4l2 devices using JPEG / MJPEG palettes. ++ * External pipe to allow external video encoders ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) ++ * Allow change/setup framerate in FreeBSD using pwcbsd + * Get rid of ffmpeg-config in configure.in for debian. + * Fix warning for x86_64 in conf.c using pointers LP64 compliant. +- * Fix fd leaks in external pipe. +- * Avoid possible stack smashing in v4l_open_vidpipe(). ++ * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 ++ Increased buffer in ffmpeg to allow encoding at 1600x1200 ++ * Avoid possible stack smashing in v4l_open_vidpipe(). + * Allow compile with OpenSuse ffmpeg package (15594svn-20081010) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x10x25x070400 +- * Better detection of ffmpeg +- http://www.lavrsen.dk/foswiki/pub/Motion/ReleaseNoteMotion3x2x11/ffmpeg-detection.diff.gz +- (Angel Carpintero) +- * Fix warning for syslog(). ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x10x25x070400 ++ * Avoid segfault detecting strerror_r() version GNU or SUSv3. ++ * 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. + * Fixed FFV1 codec encode with ffmpeg. + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x13x032553 ++ * 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 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x06x05x012249 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x06x05x012249 + (Jared D and Angel Carpintero). + + John Edwards +@@ -429,23 +444,30 @@ John Edwards + + Dag Erlandsson + * Fix RoundRobin v4l2 buffers in driver when switching input, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x07x07x182605 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x07x07x182605 + (Dag Erlandsson and Angel Carpintero). + * Check EIO for VIDIOC_DQBUF to workaround saa7134 problem. + (Dag Erlandsson and Angel Carpintero). + * Added the pre_capture buffer redesign to throttle load and enhance pre_capture feature. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreCaptureRedesign ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PreCaptureRedesign + * Fixed a problem with locate and fixed mask overlay + * Added preview center feature. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewCenter ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewCenter + * Fixed timestamp for preview pictures. ++ * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 + + Stephen Farrugia + * Fixing the division by zero problem. + This makes motion a lot more stable. + ++Michael Finsterbusch ++ ++ * Add authentication methods 'Basic Authentication' and 'Digest Authentication' ++ to the "Live Stream Server". ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch ++ + Mark Feenstra +- * Fix zombies on OpenBSD. ++ * Fix zombies on OpenBSD. + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x28x054348 + + Miguel Freitas +@@ -455,6 +477,9 @@ Aaron Gage + * Pointed me to the vid_mmap/int problem when calling SYNC in + video.c + ++Giacomo Graziosi ++ * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch ++ + Christophe Grenier + * Fixed some file descriptor leaks in webcam.c and netcam.c. + * Renamed the top level global context structure to cnt_list so it can be +@@ -467,15 +492,15 @@ Christophe Grenier + Kenneth Lavrsen. + * Change the working directory to / in daemon mode. This way you don't have + to kill motion to umount the partition from where you start it. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch + * In netcam-wget header_get() didn't always in add a \0 string terminator. + This was fixed. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch + * Made a pthread fix. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PthreadFixPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PthreadFixPatch + * Implemented the conversion of signal to sigaction which should be more + thread safe. Hopefully this still keeps Motion from making Zombies. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ConvertSignalToSigaction ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ConvertSignalToSigaction + + Mihnea-Costin Grigore + * Fixed the oldlayout behaviour of snapshots. +@@ -485,7 +510,7 @@ Mihnea-Costin Grigore + + Alain Guidez + * Fix of ffmpeg_avcodec_log code. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x25x074612 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x25x074612 + + Jan Gyselinck + * Original time/date-stamp code. +@@ -502,37 +527,38 @@ Steffen Haas + Andrew Hamilton + * Small speed boost to the function draw_textn (Andrew Hamilton and + Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextnImprovement ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextnImprovement + * Added new feature: Double size text. A new config option 'text_double' can + be set 'on' and this scales the text to double size. Default is off. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/TextScalingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/TextScalingPatch + * Fixed memory leak in ffmpeg code. + * Added the ffmpeg_deinterlace feature +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionffmpegDeinterlace ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionffmpegDeinterlace + * Added FFV1 ( FF video codec 1 ) codec , Lossless encoding +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LosslessEncoding ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LosslessEncoding + * Added mov , Quicktime file format (Andrew Hamilton). + + Gerrit Hannaert +- * Fix v4l2_palette http://www.lavrsen.dk/foswiki/bin/view/Motion/UvcvideoMjpegPatch ++ ++ * Fix v4l2_palette http://www.lavrsen.dk/twiki/bin/view/Motion/UvcvideoMjpegPatch + + Peter Holik + * Netcam First Header patch. If an error with jpeg decompression occurred at + connecting to a mjpeg streaming webcam, this patch skips this jpeg and tries + to decompress next jpeg up to MAX_HEADER_RETRIES (20). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFirstHeader ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFirstHeader + * Small improvement in framerate accuracy. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FramerateAdjust ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FramerateAdjust + * Implemented a modified version of the WebcamCompressInMemory so that Motion + no longer uses the tmpfile() function for buffering the frames of the mjpeg + stream. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory + * Implemented the libjpeg-mmx patch. Installing the MMX version of libjpeg + can increase performance. Especially for machines with very little CPU power. + It only modifies the configure script. If you do not have the libjpeg-mmx + the configure script with ignore this and use the standard libjpeg. + Note that RPMS will be built without this (Peter Holik and Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LibJpegMmx ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LibJpegMmx + * Small code cleanup in webcam.c and picture.c and .h for the webcam code + (Peter Holik and Kenneth Lavrsen). + * Small speed optimization in the creation of reference frame. +@@ -540,22 +566,27 @@ Peter Holik + ./configure --with-developer-flags. + The modifications were done by the following people: Peter Holik, Bill Brack, + Angel Carpintero and Kenneth Lavrsen. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch + * Implemented a speed-up patch of the draw text feature. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextspeedup ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextspeedup + * http control: selectbox instead of a textfield for changing boolean configs + (Peter Holik and Angel Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebhttpEnhancements. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebhttpEnhancements. + * Introduced check for device image size being a multiple of 16. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamModulo16Patch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamModulo16Patch + * Fixed netcamera bug related to separating frames in an mjpeg stream. + From mailing list 23 Dec 2005. + * Avoid open file descriptor when connecting to network cameras fails +- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidOpenfiledescriptors ++ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidOpenfiledescriptors + * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) + http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 + * Fix warning for __USE_GNU redefined +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x122137 ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x122137 ++ * Use static memory allocation in ffmpeg_deinterlace() ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic ++ * Atom optimizacion in configure.in ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations ++ + + Wesley Hosking + * For pointing me to the absence of a frame length check using +@@ -569,15 +600,15 @@ Per Jönsson + * Added the rotate feature. + * Improved the Makefile with automatic check of dependencies and + nicer output for the user. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MakefileWithAutoDependencies ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MakefileWithAutoDependencies + * Improved rotate feature (speed) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotatePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/RotatePatch + * Implemented new ffmpeg patch +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegPatch049 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegPatch049 + * Implemented labelling speed patch +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LabelingSpeedPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LabelingSpeedPatch + * Improved the signal handling of ctrl-C +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x181426 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x181426 + * Fixed the ffmpeg code so that Motion also compiles against libavcodec + build 4754 or later. + * Fixed a bug in the autobrightness algorithm. +@@ -587,28 +618,28 @@ Per Jönsson + * fixed bug where initialization would be incomplete for invalid degrees + of rotation + * now uses motion_log for error reporting +- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateBswapFix ++ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateBswapFix + * Implemented Threadnr in TLS (thread-local storage)patch. It puts the thread + number into TLS and modifies motion_log() so that we do not have to drag the + cnt struct around just to be able to print the thread number in the log and + on the console. (Per Jönsson with additional removal of unused cnt by + Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadNrTlsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadNrTlsPatch + * Simplified rotation code based on the fact that images must have dimensions + that are a multiple of 16. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateSimplificationPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateSimplificationPatch + + Mike Kenney + * Implemented a fix for the rare problem where some experienced that the + move file names would only consist of the extension .mpg or .avi with no + name in front. The root cause was the use of sprintf for appending to + strings. (Mike Kenney and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2005x09x05x133031 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x06x19x174238 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2005x09x05x133031 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x06x19x174238 + + Rafis Khayrullin + * Fix memory management in ffmpeg.c +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x19x062432 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x19x062432 + + Matthias Kilian + * Configure patch which enables configure to find and use a +@@ -616,7 +647,7 @@ Matthias Kilian + + Daniel Ladd + * Fixed a bug in the rgb2yuv420p function. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x30x011107 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x30x011107 + + Kenneth Lavrsen (Currently project managing Motion) + * Wrote the excellent Motion Guide. (Jeroen wrote this :-) ) +@@ -720,14 +751,14 @@ Kenneth Lavrsen (Currently project manag + * Fixed a bug in netcam_start() - wrong imgs.size calculation. + * Removed the obsolete Berkeley mpeg feature. + * Corrected a small error in the usage help text +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x05x174139 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x05x174139 + * Improved the help text for config option night_compensate in docs, + conf.c, motion man pages and config file. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x103939 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x103939 + * Implemented a POSIX compliant SIGCHLD signal handler as replacement for + the traditional signal(SIGCHLD, SIG_IGN) which can cause floods of + warnings in some RedHat versions. (with Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x26x134906 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x26x134906 + * Changed the reporting of the changes of noise detection level so that + it is only displayed in the console (daemon off) when the always_changes + option is enabled. (Kenneth Lavrsen) +@@ -746,7 +777,7 @@ Kenneth Lavrsen (Currently project manag + very high or the time was changes by ntp. Motion will now catch up a few + seconds later if this happens. Also fixed the code for monthly rollover. + (Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x23x133554 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x23x133554 + * Small improvement in timelapse feature so that an image is added when + the new mpeg is created and not waiting till the following timelapse + (Kenneth Lavrsen). +@@ -786,13 +817,13 @@ Kenneth Lavrsen (Currently project manag + cnt_list.control_socket_server field. Replaced it all with a simple + piece of code that all server daemons call when started: setsid() followed + by for (i=getdtablesize(); i>2; --i) close(i). Dirty and simple. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x21x070534 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x21x070534 + * Fixed a bug where rate of fetching picture frames was disturned by + the signal SIG_CHLD from exec_command programs terminating. The symptom + was that the number of post_capture frames became inaccurate and motion + in mpegs did not have constant time between frames. + * Fixed a bug where motion did not work with gap=1. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x073616 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x073616 + * Added the feature gap=0 which now also works. It disables gap completely + so that one single mpeg file is created. You can end the event from the + remote control interface make movie feature using for example cron. +@@ -806,7 +837,7 @@ Kenneth Lavrsen (Currently project manag + * Improvements of motion.conf help comments including improvements in new + onxxxx options. + * Motion Guide refactored completely for 3.2.1 with better web navigation and +- auto generation of pages. Makefile updated so that the Motion Foswiki topic ++ auto generation of pages. Makefile updated so that the Motion TWiki topic + MotionGuideOneLargeDocument is fetched when updating the guide and making + releases. + * Removed the debug_parameter option which had no use. Programmers can still +@@ -822,11 +853,11 @@ Kenneth Lavrsen (Currently project manag + * Fixed a bug in the low_cpu feature where cpu load increased instead of + decreasing because the framerate calculations were completely wrong. This was + an old bug introduced in 3.0.1. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x04x24x205933 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x04x24x205933 + * Improved the auto-brightness algorithm. When auto-brightness is enabled + the brightness option becomes a target value for the brightness level. + This should also close a bug report. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x26x195358. ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x26x195358. + * Made the http control HTML responses nicer to look at as sources and + therefore easier to debug errors. + * Code style cleanup of webhttpd.c. +@@ -835,22 +866,22 @@ Kenneth Lavrsen (Currently project manag + Carpintero. However this fix made Firefox flicker even more than it normally + does. Final fix which works in both Palantir client, Firefox and Cambozola + was made by Kenneth Lavrsen. This closes the following bugs: +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 + * Added new conversion specifiers: %D (diffs), (noise) %K (motion center x), + %L (motion center y), %i (locate width x) and %J (locate width y). These + changes also required a refactoring of the alg_locate code. This change + is part of the implementation of a generic tracking feature and it enables + implementing external programs that can perform simple prediction features. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion +- http://www.lavrsen.dk/foswiki/bin/view/Motion/GenericTrackingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion ++ http://www.lavrsen.dk/twiki/bin/view/Motion/GenericTrackingPatch + * Fixed a bug in switchfilter which caused motion detection to not work + when the feature was enabled. + * Fix for Unknown content type with lumenera cameras +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x06x174416 +- * Man page updated. It is now semi-autogenerated in the Motion Foswiki +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionOptionsAlphabeticalManpage +- * Added two new conversion specifiers: %o for threshold and %Q for number ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x06x174416 ++ * Man page updated. It is now semi-autogenerated in the Motion TWiki ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionOptionsAlphabeticalManpage ++ * Added two new convertion specifiers: %o for threshold and %Q for number + of labels. + * Improved the config file description for pre_capture to get people to + use small values. +@@ -868,7 +899,7 @@ Kenneth Lavrsen (Currently project manag + * Changed all use of localtime to localtime_r which is threadsafe. + * Modified the WebcamCompressInMemory patch so that Motion now supports the + mjpeg webcam stream while being setup for saving PPM images. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory ++ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory + * Major clean-up of code in picture.c and webcam.c so that function names and + variable names are less confusing. Also added many comments in picture.c. + * Webcam code commented more. +@@ -884,26 +915,26 @@ Kenneth Lavrsen (Currently project manag + overflow every 71 minutes. (Bill Brack and Kenneth Lavrsen) + * Fixed bug related to disabled webcam or duplicate webcam port. Error log + accept(): Socket operation on non-socket continuously written to syslog. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x01x150922 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x01x150922 + * Included a CODE_STANDARD text file to help new developers make patches + that are easier to integrate without too much manual editing. + * Changed the 5 second missed camera signal timeout to 30 seconds. + * Fixed bug where an extra jpeg is saved if you have output_normal=best + and you stop motion after an event has ended. (Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x05x173526 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x05x173526 + * Option switch filter used print_int instead of print_bool when motion.conf + was saved. + * Removed all warnings originating from the motion sources when running + ./configure --with-developer-flags. + The modifications were done by the following people: Peter Holik, Bill Brack, + Angel Carpintero and Kenneth Lavrsen. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch + * Implemented Threadnr in TLS (thread-local storage)patch. It puts the thread + number into TLS and modifies motion_log() so that we do not have to drag the + cnt struct around just to be able to print the thread number in the log and + on the console. (Per Jönsson with additional removal of unused cnt by + Kenneth Lavrsen). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadNrTlsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadNrTlsPatch + * Removed old unused code related to read mode (not mmap) from V4L devices. + * Motion loop resets its frame timer when the image received is from a netcam. + This lowers the actual framerate of Motion to the rate the netcam can actually +@@ -925,7 +956,7 @@ Kenneth Lavrsen (Currently project manag + string when no event is in progress (gap period expired). Pre_captured + and minimum_motion_frames images are time stamped before the event happens + so %C in text_left/right does not have any effect on those images. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/EventConvertionSpecifierDiscussion ++ http://www.lavrsen.dk/twiki/bin/view/Motion/EventConvertionSpecifierDiscussion + * Renamed some variables related to time to be better descriptive of function + and type. + * Added new option 'sql_user_text'. This can be defined with the same +@@ -937,7 +968,7 @@ Kenneth Lavrsen (Currently project manag + * The lightswitch and switchfilter features have been moved up before the + despeckle features are run. This should ensure that both algorithms work on + raw unfiltered motion pixels which they both were designed for. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x05x212444 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x05x212444 + * Added help texts in conf.c and motion-dist.conf describing the %t + specifier. Added a good example of use in motion-dist.conf. + * Added two new conversion specifiers: %f which is filename (full path) +@@ -973,7 +1004,7 @@ Kenneth Lavrsen (Currently project manag + * Restored the function sigchild_handler so it contains the same code + as before motion-3.2.1_snap9. They is done in an attempt to fix an old + problem with zombie child processes that has shown up again. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x11x13x115016 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x11x13x115016 + * Move the declaration of sig_handler_action and sigchild_action from + the setup_signals function where they are local and will be destroyed + and out in main just before setup_signals is called. Changed the +@@ -993,39 +1024,39 @@ Kenneth Lavrsen (Currently project manag + is re-enabled the minute the camera is standing still again. Feature + originally made by Moshe Van Der Sterre. Kenneth Lavrsen extended it to + be more generic. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PwcConfiguration ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PwcConfiguration + * Implemented fix for missed snapshots with slow network cameras +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x162149 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x162149 + * Added some constants in video.c function v4l_picture_controls() which can help + people hack an optimal set of values for controlling auto brightness for their + particular camera. For now I am do not want to add all of these to the already + too large number of motion config options. Maybe based on feedback we can + permanently change the constants and add an additional auto brightness option. + Or maybe a combined option that sets more constant based on an algorithm. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x212816 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x212816 + * Fixed a syntax error in picture.c get_pgm() which caused the program to segfault + when a mask file size did not match the picture size. Now the program + correctly gives an error message and continues without the mask. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x08x150720 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x08x150720 + * ffmpeg_filename has changed name to movie_filename to prepare for + alternative movie encoding to the current ffmpeg based implementation + and ffmpeg_filename will then be a bad name. + * Fixed bug where variables time_last_frame and time_current_frame had been + extended to also be used for snapshot feature but declaration was hidden + between #ifdef HAVE_FFMPEG. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x09x012244 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x09x012244 + * text_changes now shows a '-' when motion detection is paused instead of + just showing 0 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x03x16x095713 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x03x16x095713 + * Improved reporting of thread numbers during startup in setup mode. + (Peter Smith and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging + * Implemented a fix for the rare problem where some experienced that the + move file names would only consist of the extension .mpg or .avi with no + name in front. The root cause was the use of sprintf for appending to + strings. (Mike Kenney and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2005x09x05x133031 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x06x19x174238 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2005x09x05x133031 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x06x19x174238 + * Altered the risky use of sprintf to snprintf in all places related to + use with config strings that can become very long. + * Removed the minimum_gap feature which was utterly useless +@@ -1045,11 +1076,20 @@ Mike Lees + * Fixed a serious stability issue related to syslog not being a fully + re-entrant function. + * Implemented the new brightness, contrast, hue, saturation features +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BrightnessContrastPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BrightnessContrastPatch ++ ++Wim Lewis ++ ++ * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch + + Michal Licko + * Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero ) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch ++ ++Michael Luich ++ ++ * Added codec Ogg/Theora as new output format for regular movies. ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse + + Bill Maidment + * Fixed bug reporting errors when creating symlink to last snap. +@@ -1057,6 +1097,10 @@ Bill Maidment + Philip Marien + * Fixed a problem when compiling with --without-v4l configuration. + ++Jeroen Massar ++ * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 ++ (Jeroen Massar & Angel Carpintero) ++ + Lionnel Maugis + * ffmpeg code + +@@ -1091,17 +1135,21 @@ nullset? + * For the ir script to turn motion and lights on and of + + Onakra +- * Fix choose v4l2 palette , http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x01x21x043812 ++ * Fix choose v4l2 palette , http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x01x21x043812 + + Mikko Paananen + * Changed netcam open to use pipes and fixed authentication. + ++Bill Payne, ++ * External pipe to allow external video encoders ++ http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Angel Carpintero, Bill Payne) ++ + Bowser Pete + * Add swf codec to video creation. + + Asbjørn Pettersen + * Netcam_ftp code fixes (Angel Carpintero and Asbjørn Pettersen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFtpEnhancements ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFtpEnhancements + + Pawel Pierscionek + * Signal blocking during ioctls. +@@ -1120,9 +1168,9 @@ Christopher Price + network cameras both with single jpeg frame mode and streaming mjpeg + mode. This enables much higher framerates with Netcams. (with Angel + Carpintero). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/StreamingNetcamWithoutCurl ++ http://www.lavrsen.dk/twiki/bin/view/Motion/StreamingNetcamWithoutCurl + * Netcam fixes and debug code by Christopher Price +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + * snap5_post1_video.c and snap5-post1 patches + * Fixed netcam startup race condition. + * Refactored image handling back to single unified function +@@ -1137,7 +1185,7 @@ Christopher Price + * Added support for netcams without content-length header (streaming only) + * Remove memmem from netcam_wget.[c|h] (no longer used) + * Several miscellaneous code cosmetic changes +- * Netcam Stabilty Patch version 3.2.1-snap7-post1 ++ * Netcam Stability Patch version 3.2.1-snap7-post1 + * Added support for non-streaming (image based) netcams without + content-lengthheader. + * Contributed code for new function in event.c close_anything_open() +@@ -1146,7 +1194,7 @@ Christopher Price + causing freezing and instability. Code contributed by Christophe Grenier, + Christopher Price and Kenneth Lavrsen. + * More Netcam Stability Fixes (snap10-post1-6) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + * Destroy mutexes in netcam_cleanup(). + * Add reconnection for netcam_start() - this may block other cameras + from starting up!. +@@ -1173,7 +1221,7 @@ Christopher Price + * Rearranged timeout assignments for pthread_cond_timedwait() calls. + * Adjusted TIMEOUT_COND_WHICH to 4 seconds. + * More Netcam Stability Fixes (snap11-post1-4) (Christopher Price) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + * Reworked thread signal/wait conditions, should fix some race conditions. + * Use gettimeofday() to determine thread timeouts, results in better accuracy. + * Adjusted condition timeouts to smaller values due to usage of gettimeofday() +@@ -1188,7 +1236,7 @@ Christopher Price + * Fix bug in streaming camera without content-length, recent mod broke. + * Fix bug in startup of single image reads without content-length. + * More Netcam Stability Fixes (snap12-post1) (Christopher Price) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch + * Newrote url parser, better syntax checking and error handling of urls. + * Userpass now allowed in url (http://user:pass@example.com/). + Netcam_userpass has precedence, it will override a userpass embedded in +@@ -1206,15 +1254,19 @@ rasca + Michael Reuschling + * Fixed bug which caused Motion 3.1.18 fail to save timelapse mpegs when + setting ffmpeg_timelapse = 1 (fixed by Michael Reuschling) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x31x211756 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x31x211756 + + Petter Reinholdtsen + * Adding the install option to the makefile. + ++Isaac Richte ++ * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. ++ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 ++ + Marius Rieder + * Handle mjpeg decoding and fix colour issue adding mjpegtools dependency +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegColorIssue +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegToYUV420pPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegColorIssue ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch + (Marius Rieder, Angel Carpintero). + + James A. Russo. +@@ -1227,29 +1279,29 @@ James A. Russo. + + Jason Sharpee + * Avoid random errors , initialising some structs for V4L1 +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) + + + Pete Shipley + * Fix the problem that happens in FreeBSD and Debian Sarge because + version of ffmpeg is LIBAVFORMAT_BUILD < 4629. ( Angel Carpintero and Pete Shipley) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x12x120335 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x12x120335 + + Gunnar Skjold + * Fixed http pause feature so that pausing thread 0 now pauses all threads. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x10x111239 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x10x111239 + + Peter Smith + * Improved reporting of thread numbers during startup in setup mode. + (Peter Smith and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging + * Ffmpeg code mutex locking fix +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 + * Ffmpeg avicodec logging improved (Peter Smith and Kenneth Lavrsen) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegAvicodecLogging ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegAvicodecLogging + * Improved upon a few ambiguous log messages which may be emitted by the Event + handling code with regards to Ffmpeg (Peter Smith) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LoggingEventFix ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LoggingEventFix + + Roberto Spadim + * Fixed compatibility problem with Palantir. Fixed by making output more +@@ -1257,8 +1309,8 @@ Roberto Spadim + Carpintero. However this fix made Firefox flicker even more than it normally + does. Final fix which works in both Palantir client, Firefox and Cambozola + was made by Kenneth Lavrsen. This closes the following bugs: +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 + + Daniel Sterling + * Studies of the performance of Motion. +@@ -1284,7 +1336,7 @@ Tommy Svensson + + Timo Taskinen + * Added Flash video format (FLV) to ffmpeg. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x07x19x131921 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x07x19x131921 + + technolust.cx + * For hosting motion.technolust.cx +@@ -1302,7 +1354,7 @@ Jukka Ukkonen + * On FreeBSD configure defines a redundant freebsd for motion. Fixed by replacing + -D__freebsd_ by BSD macro included in sys/param.h for BSD platforms. + (JukkaUkkonen and Angel Carpintero) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x070417 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x070417 + + Moshe Van Der Sterre + * Added 3 new tracking options: track_step_angle_x, track_step_angle_y, +@@ -1315,14 +1367,14 @@ Moshe Van Der Sterre + is re-enabled the minute the camera is standing still again. Feature + originally made by Moshe Van Der Sterre. Kenneth Lavrsen extended it to + be more generic. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PwcConfiguration ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PwcConfiguration + + Folkert Van Heusden + * Maintained the code from version 3.1.9 till 3.1.12-rc1 + Including features like.. + * Error reporting to syslog. + * Better memory allocation. +- low_cpu feature extention to configurable frame rate. ++ low_cpu feature extension to configurable frame rate. + * First work on Logitech Sphere/Orbit tracking. + * Implemented original pre-record feature. + Misc code optimisations +@@ -1331,13 +1383,12 @@ Folkert Van Heusden + + James Van Vleet + * CPU VIA Ezra C3 autodetection support added. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/VIAEzraC3Patch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/VIAEzraC3Patch + + Simon Walls +- * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x01x22x231542 ++ * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x01x22x231542 + * Better debug in netcam for "Error reading image header" +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x27x092849 +- ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x27x092849 (Simon Walls) + + Sean Watkins + * Created a centralized logging function that became event() +@@ -1346,18 +1397,18 @@ Joerg Weber + * Added the new labeling motion detection feature. + * Added the new Smartmask feature. + * Implemented new preview patch (Joerg Weber) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewShotsPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewShotsPatch + * Implemented an improvement of Smartmask so that the mask is cleared when + the smart_mask_speed is set from a non-zero to zero + * Implemented an improvement of noise_tune with smart mask (and probably + also in general) + * Added Best Preview Patch +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BestPreviewShot ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BestPreviewShot + * Added the new feature Setup Mode (Joerg Weber). This also enables + much more error messages given to the console when in non-daemon mode + while still preserving the messages in syslog which are important + for daemon mode debugging. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/SetupModePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/SetupModePatch + * Fixed a bug in noise tune which was most visible at very low light. + * Improved console output in setup mode. Now also outputs threshold. + * Improvement in the noise-tune algorithm. +@@ -1369,8 +1420,8 @@ Joerg Weber + Movie starts (mpeg file opened) --- onmpeg --- on_movie_start + Movie ends (mpeg file closed) --- onffmpegclose --- on_movie_end + Motion detected --- New! --- on_motion_detected +- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxCommandsPatch and +- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxxFeatureDiscussion ++ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxCommandsPatch and ++ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxxFeatureDiscussion + * Fixed small bug when pre_capture buffer is resized during operation. + * Changed the order of drawing the red mask in setup mode so that the + smartmask is drawn after the fixed mask. +@@ -1379,19 +1430,25 @@ Joerg Weber + a fixed mask. + * Improved the labelling algorithm so that locate feature and tracking + features includes all labelled areas above threshold. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImprovedLabellingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ImprovedLabellingPatch + * Make the creation of reference frame and the decay mechanism depending + on how much motion was detected relative to threshold setting. +- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReferenceFramePatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/ReferenceFramePatch + * Removed low_cpu feature. + * Removed night_compensate feature + * Implemented a new reference frame algorithm to improve object recognition and location. + * Improved smartmask feature: real moving objects don't trigger the mask anymore. + * Added area_detect feature. +- ++ * Add draw a RED box around the movement as default. ++ * Split locate_motion into separate 'mode' and 'style' option to allow all ++ possible combinations. ++ * Gapless_event mode. ++ * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. ++ * Fixed mask overlay in setup mode is now green instead of white. ++ + Dirk Wesenberg + * Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero ) +- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch ++ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch + + Tristan Willy + * Wrote Axis 2100 support and added the check for ~/.motion/motion.conf +@@ -1404,7 +1461,7 @@ Andreas Wrede + + Damian Wrobel + * Fix a segfault adding correct size to be used for bayer2rgb24(). +- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x30x175913 ++ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x30x175913 + + Yieldtech + * These guys are making a complete linux based security system +--- motion-3.2.12.orig/FAQ ++++ motion-3.2.12/FAQ +@@ -1,6 +1,6 @@ + This FAQ is no longer kept up to date + Look at this URL for a more up to date wiki based FAQ +-http://www.lavrsen.dk/foswiki/bin/view/Motion/FrequentlyAskedQuestions ++http://www.lavrsen.dk/twiki/bin/view/Motion/FrequentlyAskedQuestions + + Q: motion crashes while parsing the config file. + +--- motion-3.2.12.orig/INSTALL ++++ motion-3.2.12/INSTALL +@@ -1,16 +1,61 @@ +-Very simple: ++NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point ++ and may need modification by the time you read this. + +-type: ++********************************** ++*** DEBIAN BASED SYSTEMS *** + ++Required Packages: ++ sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev ++ ++Obtain source code (via git) ++ sudo apt-get install git ++ cd ~ ++ git clone {https://github.com/your favorite fork} ++ ++To rebuild the motion configure file use ++ autoreconf ++ ++Optional: With FFMPEG support: ++ Build FFMPEG via their instructions ++ Configure with manually built ffmpeg which currently installs to ~/bin and ~/ffmpeg_build ++ Basic ++ ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include ++ ++ With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG ++ ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " ++ ++ With extra libraries for ffmpeg and install to ~/motion_build ++ ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " ++ ++With LIBAV APT versions of libraries ++ sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools libswscale-dev ++ ++Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat + ./configure + +-followed by: ++Sample PI configuration with LIBAV ++ ./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf --with-ffmpeg-headers=/usr/include ++ + ++Once configured type: + make ++ make install + +-And ++***************************** ++*** OpenSUSE SYSTEM *** + ++sudo zypper install autoconf automake libtool git ++sudo zypper install --type pattern devel_basis ++sudo zypper install libjpeg8-devel ++sudo zypper install -t pattern devel_C_C++ ++ ++Optional: FFmpeg files ++sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials ++sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia ++sudo zypper install libffmpeg-devel ++ ++./configure ++ make + make install + +- +-Next read the README ++************************* +--- /dev/null ++++ motion-3.2.12/Makefile +@@ -0,0 +1,279 @@ ++################################################################################ ++# Makefile for Motion # ++################################################################################ ++# Copyright 2000 by Jeroen Vreeken # ++# # ++# This program is published under the GNU public license version 2.0 or later. # ++# Please read the file COPYING for more info. # ++################################################################################ ++# Please visit the Motion home page: # ++# http://www.lavrsen.dk/twiki/bin/view/Motion # ++################################################################################ ++ ++CC = gcc ++INSTALL = install ++ ++################################################################################ ++# Install locations, controlled by setting configure flags. # ++################################################################################ ++prefix = /home/dave/motion_build ++exec_prefix = ${prefix} ++bindir = ${exec_prefix}/bin ++mandir = ${datarootdir}/man ++sysconfdir = ${prefix}/etc ++datadir = ${datarootdir} ++datarootdir = ${prefix}/share ++docdir = $(datadir)/doc/motion-3.2.12-4ppa01 ++examplesdir = $(datadir)/motion-3.2.12-4ppa01/examples ++ ++################################################################################ ++# These variables contain compiler flags, object files to build and files to # ++# install. # ++################################################################################ ++CFLAGS = -g -O2 -D_REENTRANT -DHAVE_FFMPEG -I/usr/include -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW -DMOTION_V4L2 -DMOTION_V4L2_OLD -DTYPE_32BIT="int" -DHAVE_BSWAP -march=native -mtune=native -Wall -DVERSION=\"3.2.12-4ppa01\" -Dsysconfdir=\"$(sysconfdir)\" ++LDFLAGS = -L/usr/lib/x86_64-linux-gnu ++LIBS = -lm -lpthread -ljpeg -L/usr/lib/x86_64-linux-gnu -lavformat -lavcodec -lavutil -lm -lz -lswscale ++VIDEO_OBJ = video.o video2.o video_common.o ++OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ ++ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ ++ alg.o event.o picture.o rotate.o webhttpd.o \ ++ stream.o md5.o ffmpeg.o netcam_rtsp.o ++SRC = $(OBJ:.o=.c) ++DOC = CHANGELOG COPYING CREDITS INSTALL README motion_guide.html ++EXAMPLES = *.conf motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh ++PROGS = motion ++DEPEND_FILE = .depend ++ ++################################################################################ ++# ALL and PROGS build Motion and, possibly, Motion-control. # ++################################################################################ ++all: progs ++ifneq (,$(findstring freebsd,$(VIDEO_OBJ))) ++ @echo "Build complete, run \"gmake install\" to install Motion!" ++else ++ @echo "Build complete, run \"make install\" to install Motion!" ++endif ++ @echo ++ ++progs: pre-build-info $(PROGS) ++ ++################################################################################ ++# PRE-BUILD-INFO outputs some general info before the build process starts. # ++################################################################################ ++pre-build-info: ++ @echo "Welcome to the setup procedure for Motion, the motion detection daemon! If you get" ++ @echo "error messages during this procedure, please report them to the mailing list. The" ++ @echo "Motion Guide contains all information you should need to get Motion up and running." ++ @echo "Run \"make updateguide\" to download the latest version of the Motion Guide." ++ @echo ++ @echo "Version: 3.2.12-4ppa01" ++ifneq (,$(findstring freebsd,$(VIDEO_OBJ))) ++ @echo "Platform: FreeBSD" ++else ++ @echo "Platform: Linux (if this is incorrect, please read README.FreeBSD)" ++endif ++ @echo ++ ++################################################################################ ++# MOTION builds motion. MOTION-OBJECTS and PRE-MOBJECT-INFO are helpers. # ++################################################################################ ++motion: motion-objects ++ @echo "Linking Motion..." ++ @echo "--------------------------------------------------------------------------------" ++ $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) ++ @echo "--------------------------------------------------------------------------------" ++ @echo "Motion has been linked." ++ @echo ++ ++motion-objects: dep pre-mobject-info $(OBJ) ++ @echo "--------------------------------------------------------------------------------" ++ @echo "Motion object files compiled." ++ @echo ++ ++pre-mobject-info: ++ @echo "Compiling Motion object files..." ++ @echo "--------------------------------------------------------------------------------" ++ ++################################################################################ ++# Define the compile command for C files. # ++################################################################################ ++#%.o: %.c ++# @echo -e "\tCompiling $< into $@..." ++# @$(CC) -c $(CFLAGS) $< -o $@ ++ ++################################################################################ ++# Include the dependency file if it exists. # ++################################################################################ ++ifeq ($(DEPEND_FILE), $(wildcard $(DEPEND_FILE))) ++ifeq (,$(findstring clean,$(MAKECMDGOALS))) ++-include $(DEPEND_FILE) ++endif ++endif ++ ++################################################################################ ++# Make the dependency file depend on all header files and all relevant source # ++# files. This forces the file to be re-generated if the source/header files # ++# change. Note, however, that the existing version will be included before # ++# re-generation. # ++################################################################################ ++$(DEPEND_FILE): *.h $(SRC) ++ @echo "Generating dependencies, please wait..." ++ @$(CC) $(CFLAGS) -M $(SRC) > .tmp ++ @mv -f .tmp $(DEPEND_FILE) ++ @echo ++ ++################################################################################ ++# DEP, DEPEND and FASTDEP generate the dependency file. # ++################################################################################ ++dep depend fastdep: $(DEPEND_FILE) ++ ++ ++################################################################################ ++# DEV, BUILD with developer flags # ++################################################################################ ++dev: distclean autotools all ++ ++################################################################################ ++# DEV-GIT, BUILD with developer flags # ++################################################################################ ++dev-git: distclean autotools-git all ++ ++ ++################################################################################ ++# GIT, BUILD with developer flags # ++################################################################################ ++build-commit-git: distclean set-version-git all ++ ++################################################################################ ++# CURRENT, BUILD current svn trunk. # ++################################################################################ ++current: distclean svn autotools all ++ ++svn: ++ svn update ++ ++autotools: ++ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in ++ autoconf ++ ./configure --with-developer-flags ++ ++autotools-git: ++ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in ++ autoconf ++ ./configure --with-developer-flags ++ ++ ++build-commit: distclean svn set-version all ++ ++set-version: ++ @sed -i 's/.\/version.sh/.\/commit-version.sh/g' configure.in ++ autoconf ++ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in ++ ./configure --with-developer-flags ++ ++set-version-git: ++ @sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.in ++ autoconf ++ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in ++ ./configure --with-developer-flags ++ ++ ++help: ++ @echo "--------------------------------------------------------------------------------" ++ @echo "make Build motion from local copy in your computer" ++ @echo "make current Build last version of motion from svn" ++ @echo "make dev Build motion with dev flags" ++ @echo "make dev-git Build motion with dev flags for git" ++ @echo "make build-commit Build last version of motion and prepare to commit to svn" ++ @echo "make build-commit-git Build last version of motion and prepare to commit to git" ++ @echo "make clean Clean objects" ++ @echo "make distclean Clean everything" ++ @echo "make install Install binary , examples , docs and config files" ++ @echo "make uninstall Uninstall all installed files" ++ @echo "--------------------------------------------------------------------------------" ++ @echo ++ ++################################################################################ ++# INSTALL installs all relevant files. # ++################################################################################ ++install: ++ @echo "Installing files..." ++ @echo "--------------------------------------------------------------------------------" ++ mkdir -p $(DESTDIR)$(bindir) ++ mkdir -p $(DESTDIR)$(mandir)/man1 ++ mkdir -p $(DESTDIR)$(sysconfdir) ++ mkdir -p $(DESTDIR)$(docdir) ++ mkdir -p $(DESTDIR)$(examplesdir) ++ $(INSTALL) motion.1 $(DESTDIR)$(mandir)/man1 ++ $(INSTALL) $(DOC) $(DESTDIR)$(docdir) ++ $(INSTALL) $(EXAMPLES) $(DESTDIR)$(examplesdir) ++ $(INSTALL) motion-dist.conf $(DESTDIR)$(sysconfdir) ++ for prog in $(PROGS); \ ++ do \ ++ ($(INSTALL) $$prog $(DESTDIR)$(bindir) ); \ ++ done ++ @echo "--------------------------------------------------------------------------------" ++ @echo "Install complete! The default configuration file, motion-dist.conf, has been" ++ @echo "installed to $(sysconfdir). You need to rename/copy it to $(sysconfdir)/motion.conf" ++ @echo "for Motion to find it. More configuration examples as well as init scripts" ++ @echo "can be found in $(examplesdir)." ++ @echo ++ ++################################################################################ ++# UNINSTALL and REMOVE uninstall already installed files. # ++################################################################################ ++uninstall remove: pre-build-info ++ @echo "Uninstalling files..." ++ @echo "--------------------------------------------------------------------------------" ++ for prog in $(PROGS); \ ++ do \ ++ ($ rm -f $(bindir)/$$prog ); \ ++ done ++ rm -f $(mandir)/man1/motion.1 ++ rm -f $(sysconfdir)/motion-dist.conf ++ rm -rf $(docdir) ++ rm -rf $(examplesdir) ++ @echo "--------------------------------------------------------------------------------" ++ @echo "Uninstall complete!" ++ @echo ++ ++################################################################################ ++# CLEAN is basic cleaning; removes object files and executables, but does not # ++# remove files generated from the configure step. # ++################################################################################ ++clean: pre-build-info ++ @echo "Removing compiled files and binaries..." ++ @rm -f *~ *.jpg *.o $(PROGS) combine $(DEPEND_FILE) ++ ++################################################################################ ++# DIST restores the directory to distribution state. # ++################################################################################ ++dist: distclean updateguide ++ @chmod -R 644 * ++ @chmod 755 configure ++ @chmod 755 version.sh ++ ++################################################################################ ++# DISTCLEAN removes all files generated during the configure step in addition # ++# to basic cleaning. # ++################################################################################ ++distclean: clean ++ @echo "Removing files generated by configure..." ++ @rm -f config.status config.log config.cache Makefile motion.init-Fedora motion.init-Debian motion.init-FreeBSD.sh ++ @rm -f thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion-help.conf motion.spec ++ @rm -rf autom4te.cache config.h ++ @echo "You will need to re-run configure if you want to build Motion." ++ @echo ++ ++################################################################################ ++# UPDATEGUIDE downloads the Motion Guide from TWiki. # ++################################################################################ ++updateguide: pre-build-info ++ @echo "Downloading Motion Guide. If it fails, please check your Internet connection." ++ @echo ++ wget www.lavrsen.dk/twiki/bin/view/Motion/MotionGuideOneLargeDocument?skin=text -O motion_guide.tmp ++ @echo "Cleaning up and fixing links..." ++ @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/twiki/,"http://www.lavrsen.dk/twiki/,g' > motion_guide.html ++ @rm -f motion_guide.tmp ++ @echo "All done, you should now have an up-to-date local copy of the Motion guide." ++ @echo +--- motion-3.2.12.orig/Makefile.in ++++ motion-3.2.12/Makefile.in +@@ -7,7 +7,7 @@ + # Please read the file COPYING for more info. # + ################################################################################ + # Please visit the Motion home page: # +-# http://www.lavrsen.dk/foswiki/bin/view/Motion # ++# http://www.lavrsen.dk/twiki/bin/view/Motion # + ################################################################################ + + CC = @CC@ +@@ -23,7 +23,7 @@ mandir = @mandir@ + sysconfdir = @sysconfdir@ + datadir = @datadir@ + datarootdir = @datarootdir@ +-docdir = $(datadir)/doc/@PACKAGE_NAME@-@PACKAGE_VERSION@ ++docdir = $(datadir)/doc/@PACKAGE_NAME@-@PACKAGE_VERSION@ + examplesdir = $(datadir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/examples + + ################################################################################ +@@ -34,10 +34,10 @@ CFLAGS = @CFLAGS@ -Wall -DVERSION= + LDFLAGS = @LDFLAGS@ + LIBS = @LIBS@ + VIDEO_OBJ = @VIDEO@ +-OBJ = motion.o conf.o draw.o jpegutils.o $(VIDEO_OBJ) netcam.o \ +- netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ ++OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ ++ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ + alg.o event.o picture.o rotate.o webhttpd.o \ +- webcam.o @FFMPEG_OBJ@ ++ stream.o md5.o @FFMPEG_OBJ@ @SDL_OBJ@ @RTPS_OBJ@ + SRC = $(OBJ:.o=.c) + DOC = CHANGELOG COPYING CREDITS INSTALL README motion_guide.html + EXAMPLES = *.conf motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh +@@ -127,6 +127,72 @@ $(DEPEND_FILE): *.h $(SRC) + ################################################################################ + dep depend fastdep: $(DEPEND_FILE) + ++ ++################################################################################ ++# DEV, BUILD with developer flags # ++################################################################################ ++dev: distclean autotools all ++ ++################################################################################ ++# DEV-GIT, BUILD with developer flags # ++################################################################################ ++dev-git: distclean autotools-git all ++ ++ ++################################################################################ ++# GIT, BUILD with developer flags # ++################################################################################ ++build-commit-git: distclean set-version-git all ++ ++################################################################################ ++# CURRENT, BUILD current svn trunk. # ++################################################################################ ++current: distclean svn autotools all ++ ++svn: ++ svn update ++ ++autotools: ++ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in ++ autoconf ++ ./configure --with-developer-flags ++ ++autotools-git: ++ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in ++ autoconf ++ ./configure --with-developer-flags ++ ++ ++build-commit: distclean svn set-version all ++ ++set-version: ++ @sed -i 's/.\/version.sh/.\/commit-version.sh/g' configure.in ++ autoconf ++ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in ++ ./configure --with-developer-flags ++ ++set-version-git: ++ @sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.in ++ autoconf ++ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in ++ ./configure --with-developer-flags ++ ++ ++help: ++ @echo "--------------------------------------------------------------------------------" ++ @echo "make Build motion from local copy in your computer" ++ @echo "make current Build last version of motion from svn" ++ @echo "make dev Build motion with dev flags" ++ @echo "make dev-git Build motion with dev flags for git" ++ @echo "make build-commit Build last version of motion and prepare to commit to svn" ++ @echo "make build-commit-git Build last version of motion and prepare to commit to git" ++ @echo "make clean Clean objects" ++ @echo "make distclean Clean everything" ++ @echo "make install Install binary , examples , docs and config files" ++ @echo "make uninstall Uninstall all installed files" ++ @echo "--------------------------------------------------------------------------------" ++ @echo ++ + ################################################################################ + # INSTALL installs all relevant files. # + ################################################################################ +@@ -185,6 +251,7 @@ clean: pre-build-info + dist: distclean updateguide + @chmod -R 644 * + @chmod 755 configure ++ @chmod 755 version.sh + + ################################################################################ + # DISTCLEAN removes all files generated during the configure step in addition # +@@ -199,14 +266,14 @@ distclean: clean + @echo + + ################################################################################ +-# UPDATEGUIDE downloads the Motion Guide from the Motion Foswiki. # ++# UPDATEGUIDE downloads the Motion Guide from TWiki. # + ################################################################################ + updateguide: pre-build-info + @echo "Downloading Motion Guide. If it fails, please check your Internet connection." + @echo +- wget www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuideOneLargeDocument?skin=text -O motion_guide.tmp ++ wget www.lavrsen.dk/twiki/bin/view/Motion/MotionGuideOneLargeDocument?skin=text -O motion_guide.tmp + @echo "Cleaning up and fixing links..." +- @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/foswiki/,"http://www.lavrsen.dk/foswiki/,g' > motion_guide.html ++ @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/twiki/,"http://www.lavrsen.dk/twiki/,g' > motion_guide.html + @rm -f motion_guide.tmp + @echo "All done, you should now have an up-to-date local copy of the Motion guide." + @echo +--- motion-3.2.12.orig/README ++++ motion-3.2.12/README +@@ -44,17 +44,17 @@ installation and use. + The Motion Guide is part of the distribution (motion_guide.htm). + You are encouraged to look up an up to date version by visiting the Motion + homepage at +-http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome ++http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome + and specifically the Motion Guide at +-http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide ++http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide + + + Support: + +-Lots of resources at http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome ++Lots of resources at http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome + + Please join the mailing list +-http://www.lavrsen.dk/foswiki/bin/view/Motion/MailingList ++http://www.lavrsen.dk/twiki/bin/view/Motion/MailingList + Newbies and silly questions are welcome. We prefer support through the mailing + list because more will have benefit from the answers. + +--- motion-3.2.12.orig/README.FreeBSD ++++ motion-3.2.12/README.FreeBSD +@@ -78,11 +78,11 @@ Packages needed (dependencies for 6.x): + Any question / fix / suggestion please send it to motion mailing list. + + +- http://www.lavrsen.dk/foswiki/bin/view/Motion/FreeBSD ++ http://www.lavrsen.dk/twiki/bin/view/Motion/FreeBSD + + * WEBCAMS + ---------- +- http://www.lavrsen.dk/foswiki/bin/view/Motion/HowtoMotionPwcFreeBSD ++ http://www.lavrsen.dk/twiki/bin/view/Motion/HowtoMotionPwcFreeBSD + + Angel Carpintero + ack@telefonica.net +--- motion-3.2.12.orig/alg.c ++++ motion-3.2.12/alg.c +@@ -17,7 +17,10 @@ + #define MAX2(x, y) ((x) > (y) ? (x) : (y)) + #define MAX3(x, y, z) ((x) > (y) ? ((x) > (z) ? (x) : (z)) : ((y) > (z) ? (y) : (z))) + +-/* locate the center and size of the movement. */ ++/** ++ * alg_locate_center_size ++ * Locates the center and size of the movement. ++ */ + void alg_locate_center_size(struct images *imgs, int width, int height, struct coord *cent) + { + unsigned char *out = imgs->out; +@@ -31,18 +34,19 @@ void alg_locate_center_size(struct image + cent->minx = width; + cent->miny = height; + +- /* If Labeling enabled - locate center of largest labelgroup */ ++ /* If Labeling enabled - locate center of largest labelgroup. */ + if (imgs->labelsize_max) { + /* Locate largest labelgroup */ + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { +- if (*(labels++)&32768) { ++ if (*(labels++) & 32768) { + cent->x += x; + cent->y += y; + centc++; + } + } + } ++ + } else { + /* Locate movement */ + for (y = 0; y < height; y++) { +@@ -54,6 +58,7 @@ void alg_locate_center_size(struct image + } + } + } ++ + } + + if (centc) { +@@ -61,18 +66,18 @@ void alg_locate_center_size(struct image + cent->y = cent->y / centc; + } + +- /* Now we find the size of the Motion */ ++ /* Now we find the size of the Motion. */ + +- /* First reset pointers back to initial value */ ++ /* First reset pointers back to initial value. */ + centc = 0; + labels = imgs->labels; + out = imgs->out; + +- /* If Labeling then we find the area around largest labelgroup instead */ ++ /* If Labeling then we find the area around largest labelgroup instead. */ + if (imgs->labelsize_max) { + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { +- if (*(labels++)&32768) { ++ if (*(labels++) & 32768) { + if (x > cent->x) + xdist += x - cent->x; + else if (x < cent->x) +@@ -87,6 +92,7 @@ void alg_locate_center_size(struct image + } + } + } ++ + } else { + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { +@@ -105,14 +111,17 @@ void alg_locate_center_size(struct image + } + } + } ++ + } + + if (centc) { + cent->minx = cent->x - xdist / centc * 2; + cent->maxx = cent->x + xdist / centc * 2; +- /* Make the box a little bigger in y direction to make sure the +- heads fit in so we multiply by 3 instead of 2 which seems to +- to work well in practical */ ++ /* ++ * Make the box a little bigger in y direction to make sure the ++ * heads fit in so we multiply by 3 instead of 2 which seems to ++ * to work well in practical. ++ */ + cent->miny = cent->y - ydist / centc * 3; + cent->maxy = cent->y + ydist / centc * 2; + } +@@ -126,85 +135,227 @@ void alg_locate_center_size(struct image + cent->maxy = height - 1; + else if (cent->maxy < 0) + cent->maxy = 0; +- ++ + if (cent->minx > width - 1) + cent->minx = width - 1; + else if (cent->minx < 0) + cent->minx = 0; +- ++ + if (cent->miny > height - 1) + cent->miny = height - 1; + else if (cent->miny < 0) + cent->miny = 0; ++ ++ /* Align for better locate box handling */ ++ cent->minx += cent->minx % 2; ++ cent->miny += cent->miny % 2; ++ cent->maxx -= cent->maxx % 2; ++ cent->maxy -= cent->maxy % 2; + + cent->width = cent->maxx - cent->minx; + cent->height = cent->maxy - cent->miny; + +- /* We want to center Y coordinate to be the center of the action. +- The head of a person is important so we correct the cent.y coordinate +- to match the correction to include a persons head that we just did above */ ++ /* ++ * We want to center Y coordinate to be the center of the action. ++ * The head of a person is important so we correct the cent.y coordinate ++ * to match the correction to include a persons head that we just did above. ++ */ + cent->y = (cent->miny + cent->maxy) / 2; + + } + + +-/* draw a box around the movement */ +-void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, int mode) ++/** ++ * alg_draw_location ++ * Draws a box around the movement. ++ */ ++void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, ++ int style, int mode, int process_thisframe) + { + unsigned char *out = imgs->out; + int x, y; + + out = imgs->out; + +- /* Draw a box around the movement */ +- if (mode == LOCATE_BOTH){ /* both normal and motion image gets a box */ ++ /* Debug image always gets a 'normal' box. */ ++ if ((mode == LOCATE_BOTH) && process_thisframe) { + int width_miny = width * cent->miny; + int width_maxy = width * cent->maxy; + + for (x = cent->minx; x <= cent->maxx; x++) { + int width_miny_x = x + width_miny; + int width_maxy_x = x + width_maxy; +- new[width_miny_x]=~new[width_miny_x]; +- new[width_maxy_x]=~new[width_maxy_x]; +- out[width_miny_x]=~out[width_miny_x]; +- out[width_maxy_x]=~out[width_maxy_x]; ++ ++ out[width_miny_x] =~out[width_miny_x]; ++ out[width_maxy_x] =~out[width_maxy_x]; + } + + for (y = cent->miny; y <= cent->maxy; y++) { + int width_minx_y = cent->minx + y * width; + int width_maxx_y = cent->maxx + y * width; +- new[width_minx_y]=~new[width_minx_y]; +- new[width_maxx_y]=~new[width_maxx_y]; +- out[width_minx_y]=~out[width_minx_y]; +- out[width_maxx_y]=~out[width_maxx_y]; ++ ++ out[width_minx_y] =~out[width_minx_y]; ++ out[width_maxx_y] =~out[width_maxx_y]; + } +- } else { /* normal image only (e.g. preview shot) */ ++ } ++ if (style == LOCATE_BOX) { /* Draw a box on normal images. */ + int width_miny = width * cent->miny; + int width_maxy = width * cent->maxy; ++ + for (x = cent->minx; x <= cent->maxx; x++) { +- int width_miny_x = width_miny + x; +- int width_maxy_x = width_maxy + x; +- new[width_miny_x]=~new[width_miny_x]; +- new[width_maxy_x]=~new[width_maxy_x]; ++ int width_miny_x = x + width_miny; ++ int width_maxy_x = x + width_maxy; ++ ++ new[width_miny_x] =~new[width_miny_x]; ++ new[width_maxy_x] =~new[width_maxy_x]; + } + + for (y = cent->miny; y <= cent->maxy; y++) { +- int minx_y = cent->minx + y * width; +- int maxx_y = cent->maxx + y * width; +- new[minx_y]=~new[minx_y]; +- new[maxx_y]=~new[maxx_y]; ++ int width_minx_y = cent->minx + y * width; ++ int width_maxx_y = cent->maxx + y * width; ++ ++ new[width_minx_y] =~new[width_minx_y]; ++ new[width_maxx_y] =~new[width_maxx_y]; ++ } ++ } else if (style == LOCATE_CROSS) { /* Draw a cross on normal images. */ ++ int centy = cent->y * width; ++ ++ for (x = cent->x - 10; x <= cent->x + 10; x++) { ++ new[centy + x] =~new[centy + x]; ++ out[centy + x] =~out[centy + x]; + } ++ ++ for (y = cent->y - 10; y <= cent->y + 10; y++) { ++ new[cent->x + y * width] =~new[cent->x + y * width]; ++ out[cent->x + y * width] =~out[cent->x + y * width]; ++ } + } + } + + ++/** ++ * alg_draw_red_location ++ * Draws a RED box around the movement. ++ */ ++void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, ++ int style, int mode, int process_thisframe) ++{ ++ unsigned char *out = imgs->out; ++ unsigned char *new_u, *new_v; ++ int x, y, v, cwidth, cblock; ++ ++ cwidth = width / 2; ++ cblock = imgs->motionsize / 4; ++ x = imgs->motionsize; ++ v = x + cblock; ++ out = imgs->out; ++ new_u = new + x; ++ new_v = new + v; ++ ++ /* Debug image always gets a 'normal' box. */ ++ if ((mode == LOCATE_BOTH) && process_thisframe) { ++ int width_miny = width * cent->miny; ++ int width_maxy = width * cent->maxy; ++ ++ for (x = cent->minx; x <= cent->maxx; x++) { ++ int width_miny_x = x + width_miny; ++ int width_maxy_x = x + width_maxy; ++ ++ out[width_miny_x] =~out[width_miny_x]; ++ out[width_maxy_x] =~out[width_maxy_x]; ++ } ++ ++ for (y = cent->miny; y <= cent->maxy; y++) { ++ int width_minx_y = cent->minx + y * width; ++ int width_maxx_y = cent->maxx + y * width; ++ ++ out[width_minx_y] =~out[width_minx_y]; ++ out[width_maxx_y] =~out[width_maxx_y]; ++ } ++ } ++ ++ if (style == LOCATE_REDBOX) { /* Draw a red box on normal images. */ ++ int width_miny = width * cent->miny; ++ int width_maxy = width * cent->maxy; ++ int cwidth_miny = cwidth * (cent->miny / 2); ++ int cwidth_maxy = cwidth * (cent->maxy / 2); ++ ++ for (x = cent->minx + 2; x <= cent->maxx - 2; x += 2) { ++ int width_miny_x = x + width_miny; ++ int width_maxy_x = x + width_maxy; ++ int cwidth_miny_x = x / 2 + cwidth_miny; ++ int cwidth_maxy_x = x / 2 + cwidth_maxy; ++ ++ new_u[cwidth_miny_x] = 128; ++ new_u[cwidth_maxy_x] = 128; ++ new_v[cwidth_miny_x] = 255; ++ new_v[cwidth_maxy_x] = 255; ++ ++ new[width_miny_x] = 128; ++ new[width_maxy_x] = 128; ++ ++ new[width_miny_x + 1] = 128; ++ new[width_maxy_x + 1] = 128; ++ ++ new[width_miny_x + width] = 128; ++ new[width_maxy_x + width] = 128; ++ ++ new[width_miny_x + 1 + width] = 128; ++ new[width_maxy_x + 1 + width] = 128; ++ } ++ ++ for (y = cent->miny; y <= cent->maxy; y += 2) { ++ int width_minx_y = cent->minx + y * width; ++ int width_maxx_y = cent->maxx + y * width; ++ int cwidth_minx_y = (cent->minx / 2) + (y / 2) * cwidth; ++ int cwidth_maxx_y = (cent->maxx / 2) + (y / 2) * cwidth; ++ ++ new_u[cwidth_minx_y] = 128; ++ new_u[cwidth_maxx_y] = 128; ++ new_v[cwidth_minx_y] = 255; ++ new_v[cwidth_maxx_y] = 255; ++ ++ new[width_minx_y] = 128; ++ new[width_maxx_y] = 128; ++ ++ new[width_minx_y + width] = 128; ++ new[width_maxx_y + width] = 128; ++ ++ new[width_minx_y + 1] = 128; ++ new[width_maxx_y + 1] = 128; ++ ++ new[width_minx_y + width + 1] = 128; ++ new[width_maxx_y + width + 1] = 128; ++ } ++ } else if (style == LOCATE_REDCROSS) { /* Draw a red cross on normal images. */ ++ int cwidth_maxy = cwidth * (cent->y / 2); ++ ++ for (x = cent->x - 10; x <= cent->x + 10; x += 2) { ++ int cwidth_maxy_x = x / 2 + cwidth_maxy; ++ ++ new_u[cwidth_maxy_x] = 128; ++ new_v[cwidth_maxy_x] = 255; ++ } ++ ++ for (y = cent->y - 10; y <= cent->y + 10; y += 2) { ++ int cwidth_minx_y = (cent->x / 2) + (y / 2) * cwidth; ++ ++ new_u[cwidth_minx_y] = 128; ++ new_v[cwidth_minx_y] = 255; ++ } ++ } ++} ++ + + #define NORM 100 + #define ABS(x) ((x) < 0 ? -(x) : (x)) +-#define DIFF(x, y) (ABS((x) - (y))) +-#define NDIFF(x, y) (ABS(x) * NORM/(ABS(x) + 2 * DIFF(x,y))) +- ++#define DIFF(x, y) (ABS((x)-(y))) ++#define NDIFF(x, y) (ABS(x) * NORM / (ABS(x) + 2 * DIFF(x, y))) + ++/** ++ * alg_noise_tune ++ * ++ */ + void alg_noise_tune(struct context *cnt, unsigned char *new) + { + struct images *imgs = &cnt->imgs; +@@ -216,25 +367,33 @@ void alg_noise_tune(struct context *cnt, + + i = imgs->motionsize; + +- for (; i>0; i--) { ++ for (; i > 0; i--) { + diff = ABS(*ref - *new); ++ + if (mask) +- diff = ((diff * *mask++)/255); +- if (*smartmask){ ++ diff = ((diff * *mask++) / 255); ++ ++ if (*smartmask) { + sum += diff + 1; + count++; + } ++ + ref++; + new++; + smartmask++; + } + +- if (count > 3) /* avoid divide by zero */ ++ if (count > 3) /* Avoid divide by zero. */ + sum /= count / 3; + +- cnt->noise = 4 + (cnt->noise + sum) / 2; /* 5: safe, 4: regular, 3: more sensitive */ ++ /* 5: safe, 4: regular, 3: more sensitive */ ++ cnt->noise = 4 + (cnt->noise + sum) / 2; + } + ++/** ++ * alg_threshold_tune ++ * ++ */ + void alg_threshold_tune(struct context *cnt, int diffs, int motion) + { + int i; +@@ -248,6 +407,7 @@ void alg_threshold_tune(struct context * + + for (i = 0; i < THRESHOLD_TUNE_LENGTH - 1; i++) { + sum += cnt->diffs_last[i]; ++ + if (cnt->diffs_last[i + 1] && !motion) + cnt->diffs_last[i] = cnt->diffs_last[i + 1]; + else +@@ -256,10 +416,12 @@ void alg_threshold_tune(struct context * + if (cnt->diffs_last[i] > top) + top = cnt->diffs_last[i]; + } ++ + sum += cnt->diffs_last[i]; + cnt->diffs_last[i] = diffs; + + sum /= THRESHOLD_TUNE_LENGTH / 4; ++ + if (sum < top * 2) + sum = top * 2; + +@@ -268,47 +430,50 @@ void alg_threshold_tune(struct context * + } + + /* +-Labeling by Joerg Weber. Based on an idea from Hubert Mara. +-Floodfill enhanced by Ian McConnel based on code from +-http://www.acm.org/pubs/tog/GraphicsGems/ +-http://www.codeproject.com/gdi/QuickFill.asp +-*/ ++ * Labeling by Joerg Weber. Based on an idea from Hubert Mara. ++ * Floodfill enhanced by Ian McConnel based on code from ++ * http://www.acm.org/pubs/tog/GraphicsGems/ ++ * http://www.codeproject.com/gdi/QuickFill.asp + +-/* +- * Filled horizontal segment of scanline y for xl<=x<=xr. +- * Parent segment was on line y-dy. dy=1 or -1 ++ * Filled horizontal segment of scanline y for xl <= x <= xr. ++ * Parent segment was on line y - dy. dy = 1 or -1 + */ + + #define MAXS 10000 /* max depth of stack */ + +-#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \ +- if (sp= 0 && Y+(DY) < height) \ ++#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \ ++ if (sp= 0 && Y+(DY) < height) \ + {sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++;} + +-#define POP(Y, XL, XR, DY) /* pop segment off stack */ \ ++#define POP(Y, XL, XR, DY) /* pop segment off stack */ \ + {sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;} + +-typedef struct {short y, xl, xr, dy;} Segment; ++typedef struct { ++ short y, xl, xr, dy; ++} Segment; + +- +-static int iflood(int x, int y, +- int width, int height, unsigned char *out, int *labels, int newvalue, int oldvalue) ++/** ++ * iflood ++ * ++ */ ++static int iflood(int x, int y, int width, int height, ++ unsigned char *out, int *labels, int newvalue, int oldvalue) + { + int l, x1, x2, dy; +- Segment stack[MAXS], *sp = stack; /* stack of filled segments */ ++ Segment stack[MAXS], *sp = stack; /* Stack of filled segments. */ + int count = 0; + + if (x < 0 || x >= width || y < 0 || y >= height) + return 0; + +- PUSH(y, x, x, 1); /* needed in some cases */ +- PUSH(y+1, x, x, -1); /* seed segment (popped 1st) */ ++ PUSH(y, x, x, 1); /* Needed in some cases. */ ++ PUSH(y+1, x, x, -1); /* Seed segment (popped 1st). */ + + while (sp > stack) { +- /* pop segment off stack and fill a neighboring scan line */ ++ /* Pop segment off stack and fill a neighboring scan line. */ + POP(y, x1, x2, dy); + /* +- * segment of scan line y-dy for x1<=x<=x2 was previously filled, ++ * Segment of scan line y-dy for x1<=x<=x2 was previously filled, + * now explore adjacent pixels in scan line y + */ + for (x = x1; x >= 0 && out[y * width + x] != 0 && labels[y * width + x] == oldvalue; x--) { +@@ -322,7 +487,7 @@ static int iflood(int x, int y, + l = x + 1; + + if (l < x1) +- PUSH(y, l, x1-1, -dy); /* leak on left? */ ++ PUSH(y, l, x1 - 1, -dy); /* Leak on left? */ + + x = x1 + 1; + +@@ -335,7 +500,7 @@ static int iflood(int x, int y, + PUSH(y, l, x - 1, dy); + + if (x > x2 + 1) +- PUSH(y, x2 + 1, x - 1, -dy); /* leak on right? */ ++ PUSH(y, x2 + 1, x - 1, -dy); /* Leak on right? */ + + skip: + +@@ -347,6 +512,10 @@ static int iflood(int x, int y, + return count; + } + ++/** ++ * alg_labeling ++ * ++ */ + static int alg_labeling(struct context *cnt) + { + struct images *imgs = &cnt->imgs; +@@ -357,60 +526,76 @@ static int alg_labeling(struct context * + int height = imgs->height; + int labelsize = 0; + int current_label = 2; ++ + cnt->current_image->total_labels = 0; + imgs->labelsize_max = 0; +- /* ALL labels above threshold are counted as labelgroup */ ++ /* ALL labels above threshold are counted as labelgroup. */ + imgs->labelgroup_max = 0; + imgs->labels_above = 0; + +- /* init: 0 means no label set / not checked */ ++ /* Init: 0 means no label set / not checked. */ + memset(labels, 0, width * height * sizeof(labels)); + pixelpos = 0; ++ + for (iy = 0; iy < height - 1; iy++) { + for (ix = 0; ix < width - 1; ix++, pixelpos++) { +- /* no motion - no label */ ++ /* No motion - no label */ + if (out[pixelpos] == 0) { + labels[pixelpos] = 1; + continue; + } + +- /* already visited by iflood */ ++ /* Already visited by iflood */ + if (labels[pixelpos] > 0) + continue; +- labelsize=iflood(ix, iy, width, height, out, labels, current_label, 0); ++ ++ labelsize = iflood(ix, iy, width, height, out, labels, current_label, 0); + + if (labelsize > 0) { +- /* Label above threshold? Mark it again (add 32768 to labelnumber) */ ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Label: %i (%i) Size: %i (%i,%i)", ++ current_label, cnt->current_image->total_labels, ++ labelsize, ix, iy); ++ ++ /* Label above threshold? Mark it again (add 32768 to labelnumber). */ + if (labelsize > cnt->threshold) { +- labelsize=iflood(ix, iy, width, height, out, labels, current_label + 32768, current_label); ++ labelsize = iflood(ix, iy, width, height, out, labels, current_label + 32768, current_label); + imgs->labelgroup_max += labelsize; + imgs->labels_above++; + } + + if (imgs->labelsize_max < labelsize) { +- imgs->labelsize_max=labelsize; +- imgs->largest_label=current_label; ++ imgs->labelsize_max = labelsize; ++ imgs->largest_label = current_label; + } + + cnt->current_image->total_labels++; + current_label++; + } + } +- pixelpos++; /* compensate for ixlargest_label, imgs->labelsize_max, ++ cnt->current_image->total_labels); ++ ++ /* Return group of significant labels. */ + return imgs->labelgroup_max; + } + +-/* Dilates a 3x3 box */ ++/** ++ * dilate9 ++ * Dilates a 3x3 box. ++ */ + static int dilate9(unsigned char *img, int width, int height, void *buffer) + { +- /* - row1, row2 and row3 represent lines in the temporary buffer +- * - window is a sliding window containing max values of the columns +- * in the 3x3 matrix +- * - widx is an index into the sliding window (this is faster than +- * doing modulo 3 on i) +- * - blob keeps the current max value ++ /* ++ * - row1, row2 and row3 represent lines in the temporary buffer. ++ * - Window is a sliding window containing max values of the columns ++ * in the 3x3 matrix. ++ * - width is an index into the sliding window (this is faster than ++ * doing modulo 3 on i). ++ * - blob keeps the current max value. + */ + int y, i, sum = 0, widx; + unsigned char *row1, *row2, *row3, *rowTemp,*yp; +@@ -439,7 +624,7 @@ static int dilate9(unsigned char *img, i + if (y == height - 1) + memset(row3, 0, width); + else +- memcpy(row3, yp + width, width); ++ memcpy(row3, yp+width, width); + + /* Init slots 0 and 1 in the moving window. */ + window[0] = MAX3(row1[0], row2[0], row3[0]); +@@ -449,14 +634,16 @@ static int dilate9(unsigned char *img, i + blob = MAX2(window[0], window[1]); + widx = 2; + +- /* Iterate over the current row; index i is off by one to eliminate ++ /* ++ * Iterate over the current row; index i is off by one to eliminate + * a lot of +1es in the loop. + */ + for (i = 2; i <= width - 1; i++) { + /* Get the max value of the next column in the 3x3 matrix. */ + latest = window[widx] = MAX3(row1[i], row2[i], row3[i]); + +- /* If the value is larger than the current max, use it. Otherwise, ++ /* ++ * If the value is larger than the current max, use it. Otherwise, + * calculate a new max (because the new value may not be the max. + */ + if (latest >= blob) +@@ -483,11 +670,15 @@ static int dilate9(unsigned char *img, i + return sum; + } + +-/* Dilates a + shape */ ++/** ++ * dilate5 ++ * Dilates a + shape. ++ */ + static int dilate5(unsigned char *img, int width, int height, void *buffer) + { +- /* - row1, row2 and row3 represent lines in the temporary buffer +- * - mem holds the max value of the overlapping part of two + shapes ++ /* ++ * - row1, row2 and row3 represent lines in the temporary buffer. ++ * - mem holds the max value of the overlapping part of two + shapes. + */ + int y, i, sum = 0; + unsigned char *row1, *row2, *row3, *rowTemp, *yp; +@@ -516,7 +707,7 @@ static int dilate5(unsigned char *img, i + if (y == height - 1) + memset(row3, 0, width); + else +- memcpy(row3, yp+width, width); ++ memcpy(row3, yp + width, width); + + /* Init mem and set blob to force an evaluation of the entire + shape. */ + mem = MAX2(row2[0], row2[1]); +@@ -550,48 +741,59 @@ static int dilate5(unsigned char *img, i + return sum; + } + +-/* Erodes a 3x3 box */ ++/** ++ * erode9 ++ * Erodes a 3x3 box. ++ */ + static int erode9(unsigned char *img, int width, int height, void *buffer, unsigned char flag) + { + int y, i, sum = 0; + char *Row1,*Row2,*Row3; ++ + Row1 = buffer; + Row2 = Row1 + width; +- Row3 = Row1 + 2*width; ++ Row3 = Row1 + 2 * width; + memset(Row2, flag, width); + memcpy(Row3, img, width); ++ + for (y = 0; y < height; y++) { + memcpy(Row1, Row2, width); + memcpy(Row2, Row3, width); +- if (y == height - 1) ++ ++ if (y == height-1) + memset(Row3, flag, width); + else +- memcpy(Row3, img+(y + 1) * width, width); ++ memcpy(Row3, img + (y+1) * width, width); + +- for (i = width-2; i >= 1; i--) { +- if (Row1[i-1] == 0 || +- Row1[i] == 0 || +- Row1[i+1] == 0 || +- Row2[i-1] == 0 || +- Row2[i] == 0 || +- Row2[i+1] == 0 || +- Row3[i-1] == 0 || +- Row3[i] == 0 || +- Row3[i+1] == 0) ++ for (i = width - 2; i >= 1; i--) { ++ if (Row1[i - 1] == 0 || ++ Row1[i] == 0 || ++ Row1[i + 1] == 0 || ++ Row2[i - 1] == 0 || ++ Row2[i] == 0 || ++ Row2[i + 1] == 0 || ++ Row3[i - 1] == 0 || ++ Row3[i] == 0 || ++ Row3[i + 1] == 0) + img[y * width + i] = 0; + else + sum++; + } ++ + img[y * width] = img[y * width + width - 1] = flag; + } + return sum; + } + +-/* Erodes in a + shape */ ++/** ++ * erode5 ++ * Erodes in a + shape. ++ */ + static int erode5(unsigned char *img, int width, int height, void *buffer, unsigned char flag) + { + int y, i, sum = 0; + char *Row1,*Row2,*Row3; ++ + Row1 = buffer; + Row2 = Row1 + width; + Row3 = Row1 + 2 * width; +@@ -607,12 +809,12 @@ static int erode5(unsigned char *img, in + else + memcpy(Row3, img + (y + 1) * width, width); + +- for (i = width-2; i >= 1; i--) { +- if (Row1[i] == 0 || +- Row2[i-1] == 0 || +- Row2[i] == 0 || +- Row2[i+1] == 0 || +- Row3[i] == 0) ++ for (i = width - 2; i >= 1; i--) { ++ if (Row1[i] == 0 || ++ Row2[i - 1] == 0 || ++ Row2[i] == 0 || ++ Row2[i + 1] == 0 || ++ Row3[i] == 0) + img[y * width + i] = 0; + else + sum++; +@@ -623,20 +825,21 @@ static int erode5(unsigned char *img, in + return sum; + } + +-/* +- * Despeckling routine to remove noisy detections. ++/** ++ * alg_despeckle ++ * Despeckling routine to remove noisy detections. + */ + int alg_despeckle(struct context *cnt, int olddiffs) + { + int diffs = 0; + unsigned char *out = cnt->imgs.out; + int width = cnt->imgs.width; +- int height= cnt->imgs.height; +- int done = 0, i, len = strlen(cnt->conf.despeckle); ++ int height = cnt->imgs.height; ++ int done = 0, i, len = strlen(cnt->conf.despeckle_filter); + unsigned char *common_buffer = cnt->imgs.common_buffer; + + for (i = 0; i < len; i++) { +- switch (cnt->conf.despeckle[i]) { ++ switch (cnt->conf.despeckle_filter[i]) { + case 'E': + if ((diffs = erode9(out, width, height, common_buffer, 0)) == 0) + i = len; +@@ -655,7 +858,7 @@ int alg_despeckle(struct context *cnt, i + diffs = dilate5(out, width, height, common_buffer); + done = 1; + break; +- /* no further despeckle after labeling! */ ++ /* No further despeckle after labeling! */ + case 'l': + diffs = alg_labeling(cnt); + i = len; +@@ -664,58 +867,66 @@ int alg_despeckle(struct context *cnt, i + } + } + +- /* If conf.despeckle contains any valid action EeDdl */ ++ /* If conf.despeckle_filter contains any valid action EeDdl */ + if (done) { + if (done != 2) + cnt->imgs.labelsize_max = 0; // Disable Labeling + return diffs; + } else { + cnt->imgs.labelsize_max = 0; // Disable Labeling +- } +- ++ } ++ + return olddiffs; + } + +-/* Generate actual smartmask. Calculate sensitivity based on motion */ ++/** ++ * alg_tune_smartmask ++ * Generates actual smartmask. Calculate sensitivity based on motion. ++ */ + void alg_tune_smartmask(struct context *cnt) + { + int i, diff; +- + int motionsize = cnt->imgs.motionsize; + unsigned char *smartmask = cnt->imgs.smartmask; + unsigned char *smartmask_final = cnt->imgs.smartmask_final; + int *smartmask_buffer = cnt->imgs.smartmask_buffer; +- int sensitivity=cnt->lastrate*(11-cnt->smartmask_speed); ++ int sensitivity = cnt->lastrate * (11 - cnt->smartmask_speed); + + for (i = 0; i < motionsize; i++) { +- +- /* Decrease smart_mask sensitivity every 5*speed seconds only */ ++ /* Decrease smart_mask sensitivity every 5*speed seconds only. */ + if (smartmask[i] > 0) + smartmask[i]--; +- /* Increase smart_mask sensitivity based on the buffered values */ ++ /* Increase smart_mask sensitivity based on the buffered values. */ + diff = smartmask_buffer[i]/sensitivity; ++ + if (diff) { + if (smartmask[i] <= diff + 80) + smartmask[i] += diff; + else +- smartmask[i]=80; +- smartmask_buffer[i]%=sensitivity; ++ smartmask[i] = 80; ++ smartmask_buffer[i] %= sensitivity; + } +- /* Transfer raw mask to the final stage when above trigger value */ ++ /* Transfer raw mask to the final stage when above trigger value. */ + if (smartmask[i] > 20) + smartmask_final[i] = 0; + else + smartmask_final[i] = 255; + } +- /* Further expansion (here:erode due to inverted logic!) of the mask */ +- diff = erode9(smartmask_final, cnt->imgs.width, cnt->imgs.height, cnt->imgs.common_buffer, 255); +- diff = erode5(smartmask_final, cnt->imgs.width, cnt->imgs.height, cnt->imgs.common_buffer, 255); ++ /* Further expansion (here:erode due to inverted logic!) of the mask. */ ++ diff = erode9(smartmask_final, cnt->imgs.width, cnt->imgs.height, ++ cnt->imgs.common_buffer, 255); ++ diff = erode5(smartmask_final, cnt->imgs.width, cnt->imgs.height, ++ cnt->imgs.common_buffer, 255); + } + + /* Increment for *smartmask_buffer in alg_diff_standard. */ + #define SMARTMASK_SENSITIVITY_INCR 5 + +-int alg_diff_standard (struct context *cnt, unsigned char *new) ++/** ++ * alg_diff_standard ++ * ++ */ ++int alg_diff_standard(struct context *cnt, unsigned char *new) + { + struct images *imgs = &cnt->imgs; + int i, diffs = 0; +@@ -724,23 +935,25 @@ int alg_diff_standard (struct context *c + unsigned char *ref = imgs->ref; + unsigned char *out = imgs->out; + unsigned char *mask = imgs->mask; +- unsigned char *smartmask_final=imgs->smartmask_final; ++ unsigned char *smartmask_final = imgs->smartmask_final; + int *smartmask_buffer = imgs->smartmask_buffer; + #ifdef HAVE_MMX +- mmx_t mmtemp; /* used for transferring to/from memory */ +- int unload; /* counter for unloading diff counts */ ++ mmx_t mmtemp; /* Used for transferring to/from memory. */ ++ int unload; /* Counter for unloading diff counts. */ + #endif + + i = imgs->motionsize; +- memset(out + i, 128, i / 2); /* motion pictures are now b/w i.o. green */ +- /* Keeping this memset in the MMX case when zeroes are necessarily ++ memset(out + i, 128, i / 2); /* Motion pictures are now b/w i.o. green */ ++ /* ++ * Keeping this memset in the MMX case when zeroes are necessarily + * written anyway seems to be beneficial in terms of speed. Perhaps a + * cache thing? + */ + memset(out, 0, i); + + #ifdef HAVE_MMX +- /* NOTE: The Pentium has two instruction pipes: U and V. I have grouped MMX ++ /* ++ * NOTE: The Pentium has two instruction pipes: U and V. I have grouped MMX + * instructions in pairs according to how I think they will be scheduled in + * the U and V pipes. Due to pairing constraints, the V pipe will sometimes + * be empty (for example, memory access always goes into the U pipe). +@@ -753,13 +966,16 @@ int alg_diff_standard (struct context *c + * -- Per Jonsson + */ + +- /* To avoid a div, we work with differences multiplied by 255 in the ++ /* ++ * To avoid a div, we work with differences multiplied by 255 in the + * default case and *mask otherwise. Thus, the limit to compare with is +- * 255*(noise+1)-1). ++ * 255 * (noise + 1) - 1). + */ +- mmtemp.uw[0] = mmtemp.uw[1] = mmtemp.uw[2] = mmtemp.uw[3] = (unsigned short)(noise * 255 + 254); ++ mmtemp.uw[0] = mmtemp.uw[1] = mmtemp.uw[2] = mmtemp.uw[3] = ++ (unsigned short)(noise * 255 + 254); + +- /* Reset mm5 to zero, set the mm6 mask, and store the multiplied noise ++ /* ++ * Reset mm5 to zero, set the mm6 mask, and store the multiplied noise + * level as four words in mm7. + */ + movq_m2r(mmtemp, mm7); /* U */ +@@ -768,7 +984,8 @@ int alg_diff_standard (struct context *c + pxor_r2r(mm5, mm5); /* U */ + psrlw_i2r(8, mm6); /* V */ + +- /* We must unload mm5 every 255th round, because the diffs accumulate ++ /* ++ * We must unload mm5 every 255th round, because the diffs accumulate + * in each packed byte, which can hold at most 255 diffs before it + * gets saturated. + */ +@@ -796,7 +1013,8 @@ int alg_diff_standard (struct context *c + punpckhbw_r2r(mm4, mm1); /* U: mm1 = d7 d6 d5 d4 */ + + if (mask) { +- /* Load and expand 8 mask bytes to words in mm2 and mm3. Then ++ /* ++ * Load and expand 8 mask bytes to words in mm2 and mm3. Then + * multiply by mm0 and mm1, respectively. + */ + movq_m2r(*mask, mm2); /* U: mm2 = m7 m6 m5 m4 m3 m2 m1 m0 */ +@@ -809,9 +1027,10 @@ int alg_diff_standard (struct context *c + + pmullw_r2r(mm3, mm1); /* U: mm1 = (d7*m7) ... (d4*m4) */ + +- mask+=8; ++ mask += 8; + } else { +- /* Not using mask - multiply the absolute differences by 255. We ++ /* ++ * Not using mask - multiply the absolute differences by 255. We + * do this by left-shifting 8 places and then subtracting dX. + */ + movq_r2r(mm0, mm2); /* U: mm2 = d3 d2 d1 d0 */ +@@ -824,7 +1043,8 @@ int alg_diff_standard (struct context *c + psubusw_r2r(mm3, mm1); /* V */ + } + +- /* Next, compare the multiplied absolute differences with the multiplied ++ /* ++ * Next, compare the multiplied absolute differences with the multiplied + * noise level (repeated as 4 words in mm7), resulting in a "motion flag" + * for each pixel. + * +@@ -851,32 +1071,34 @@ int alg_diff_standard (struct context *c + packuswb_r2r(mm1, mm0); /* U: mm0 = f7 f6 f5 f4 f3 f2 f1 f0 */ + + if (smartmask_speed) { +- /* Apply the smartmask. Basically, if *smartmask_final is 0, the ++ /* ++ * Apply the smartmask. Basically, if *smartmask_final is 0, the + * corresponding "motion flag" in mm0 will be reset. + */ + movq_m2r(*smartmask_final, mm3); /* U: mm3 = s7 s6 s5 s4 s3 s2 s1 s0 */ + +- /* ...but move the "motion flags" to memory before, in order to ++ /* ++ * ...but move the "motion flags" to memory before, in order to + * increment *smartmask_buffer properly below. + */ + movq_r2m(mm0, mmtemp); /* U */ + pcmpeqb_r2r(mm4, mm3); /* V: mm3 = 0xff where sX==0 */ + +- /* ANDN negates the target before anding. */ ++ /* AND negates the target before anding. */ + pandn_r2r(mm0, mm3); /* U: mm3 = 0xff where dX>noise && sX>0 */ + + movq_r2r(mm3, mm0); /* U */ + + /* Add to *smartmask_buffer. This is probably the fastest way to do it. */ + if (cnt->event_nr != cnt->prev_event) { +- if (mmtemp.ub[0]) smartmask_buffer[0]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[1]) smartmask_buffer[1]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[2]) smartmask_buffer[2]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[3]) smartmask_buffer[3]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[4]) smartmask_buffer[4]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[5]) smartmask_buffer[5]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[6]) smartmask_buffer[6]+=SMARTMASK_SENSITIVITY_INCR; +- if (mmtemp.ub[7]) smartmask_buffer[7]+=SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[0]) smartmask_buffer[0] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[1]) smartmask_buffer[1] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[2]) smartmask_buffer[2] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[3]) smartmask_buffer[3] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[4]) smartmask_buffer[4] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[5]) smartmask_buffer[5] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[6]) smartmask_buffer[6] += SMARTMASK_SENSITIVITY_INCR; ++ if (mmtemp.ub[7]) smartmask_buffer[7] += SMARTMASK_SENSITIVITY_INCR; + } + + smartmask_buffer += 8; +@@ -885,19 +1107,22 @@ int alg_diff_standard (struct context *c + + movq_m2r(*new, mm2); /* U: mm1 = n7 n6 n5 n4 n3 n2 n1 n0 */ + +- /* Cancel out pixels in *new according to the "motion flags" in mm0. ++ /* ++ * Cancel out pixels in *new according to the "motion flags" in mm0. + * Each NX is either 0 or nX as from *new. + */ + pand_r2r(mm0, mm2); /* U: mm1 = N7 N6 N5 N4 N3 N2 N1 N0 */ + psubb_r2r(mm0, mm4); /* V: mm4 = 0x01 where dX>noise */ + +- /* mm5 holds 8 separate counts - each one is increased according to ++ /* ++ * mm5 holds 8 separate counts - each one is increased according to + * the contents of mm4 (where each byte is either 0x00 or 0x01). + */ + movq_r2m(mm2, *out); /* U: this will stall */ + paddusb_r2r(mm4, mm5); /* V: add counts to mm5 */ + +- /* Every 255th turn, we need to unload mm5 into the diffs variable, ++ /* ++ * Every 255th turn, we need to unload mm5 into the diffs variable, + * because otherwise the packed bytes will get saturated. + */ + if (--unload == 0) { +@@ -910,12 +1135,13 @@ int alg_diff_standard (struct context *c + unload = 255; + } + +- out+=8; +- ref+=8; +- new+=8; ++ out += 8; ++ ref += 8; ++ new += 8; + } + +- /* Check if there are diffs left in mm5 that need to be copied to the ++ /* ++ * Check if there are diffs left in mm5 that need to be copied to the + * diffs variable. + */ + if (unload < 255) { +@@ -927,27 +1153,30 @@ int alg_diff_standard (struct context *c + emms(); + + #endif +- /* Note that the non-MMX code is present even if the MMX code is present. ++ /* ++ * Note that the non-MMX code is present even if the MMX code is present. + * This is necessary if the resolution is not a multiple of 8, in which + * case the non-MMX code needs to take care of the remaining pixels. + */ + +- for (; i>0; i--) { +- register unsigned char curdiff=(int)(abs(*ref - *new)); /* using a temp variable is 12% faster */ +- /* apply fixed mask */ ++ for (; i > 0; i--) { ++ register unsigned char curdiff = (int)(abs(*ref - *new)); /* Using a temp variable is 12% faster. */ ++ /* Apply fixed mask */ + if (mask) +- curdiff=((int)(curdiff * *mask++) / 255); ++ curdiff = ((int)(curdiff * *mask++) / 255); + + if (smartmask_speed) { + if (curdiff > noise) { +- /* increase smart_mask sensitivity every frame when motion +- is detected. (with speed=5, mask is increased by 1 every +- second. To be able to increase by 5 every second (with +- speed=10) we add 5 here. NOT related to the 5 at ratio- +- calculation. */ ++ /* ++ * Increase smart_mask sensitivity every frame when motion ++ * is detected. (with speed=5, mask is increased by 1 every ++ * second. To be able to increase by 5 every second (with ++ * speed=10) we add 5 here. NOT related to the 5 at ratio- ++ * calculation. ++ */ + if (cnt->event_nr != cnt->prev_event) + (*smartmask_buffer) += SMARTMASK_SENSITIVITY_INCR; +- /* apply smart_mask */ ++ /* Apply smart_mask */ + if (!*smartmask_final) + curdiff = 0; + } +@@ -966,25 +1195,26 @@ int alg_diff_standard (struct context *c + return diffs; + } + +-/* +- Very fast diff function, does not apply mask overlaying. +-*/ ++/** ++ * alg_diff_fast ++ * Very fast diff function, does not apply mask overlaying. ++ */ + static char alg_diff_fast(struct context *cnt, int max_n_changes, unsigned char *new) + { + struct images *imgs = &cnt->imgs; +- int i, diffs = 0, step = imgs->motionsize / 10000; +- int noise=cnt->noise; ++ int i, diffs = 0, step = imgs->motionsize/10000; ++ int noise = cnt->noise; + unsigned char *ref = imgs->ref; + + if (!step % 2) + step++; +- /* we're checking only 1 of several pixels */ ++ /* We're checking only 1 of several pixels. */ + max_n_changes /= step; + + i = imgs->motionsize; + + for (; i > 0; i -= step) { +- register unsigned char curdiff = (int)(abs((char)(*ref-*new))); /* using a temp variable is 12% faster */ ++ register unsigned char curdiff = (int)(abs((char)(*ref - *new))); /* Using a temp variable is 12% faster. */ + if (curdiff > noise) { + diffs++; + if (diffs > max_n_changes) +@@ -997,9 +1227,11 @@ static char alg_diff_fast(struct context + return 0; + } + +-/* alg_diff uses diff_fast to quickly decide if there is anything worth +- * sending to diff_standard. +-*/ ++/** ++ * alg_diff ++ * Uses diff_fast to quickly decide if there is anything worth ++ * sending to diff_standard. ++ */ + int alg_diff(struct context *cnt, unsigned char *new) + { + int diffs = 0; +@@ -1010,9 +1242,11 @@ int alg_diff(struct context *cnt, unsign + return diffs; + } + +-/* Detect a sudden massive change in the picture. +- It is assumed to be the light being switched on or a camera displacement. +- In any way the user doesn't think it is worth capturing. ++/** ++ * alg_lightswitch ++ * Detects a sudden massive change in the picture. ++ * It is assumed to be the light being switched on or a camera displacement. ++ * In any way the user doesn't think it is worth capturing. + */ + int alg_lightswitch(struct context *cnt, int diffs) + { +@@ -1023,13 +1257,17 @@ int alg_lightswitch(struct context *cnt, + if (cnt->conf.lightswitch > 100) + cnt->conf.lightswitch = 100; + +- /* is lightswitch percent of the image changed? */ ++ /* Is lightswitch percent of the image changed? */ + if (diffs > (imgs->motionsize * cnt->conf.lightswitch / 100)) + return 1; + + return 0; + } + ++/** ++ * alg_switchfilter ++ * ++ */ + int alg_switchfilter(struct context *cnt, int diffs, unsigned char *newimg) + { + int linediff = diffs / cnt->imgs.height; +@@ -1042,7 +1280,6 @@ int alg_switchfilter(struct context *cnt + for (x = 0; x < cnt->imgs.width; x++) { + if (*(out++)) + line++; +- + } + + if (line > cnt->imgs.width / 18) +@@ -1050,7 +1287,6 @@ int alg_switchfilter(struct context *cnt + + if (line > linediff * 2) + lines++; +- + } + + if (vertlines > cnt->imgs.height / 10 && lines < vertlines / 3 && +@@ -1058,7 +1294,7 @@ int alg_switchfilter(struct context *cnt + if (cnt->conf.text_changes) { + char tmp[80]; + sprintf(tmp, "%d %d", lines, vertlines); +- draw_text(newimg, cnt->imgs.width-10, 20, cnt->imgs.width, tmp, cnt->conf.text_double); ++ draw_text(newimg, cnt->imgs.width - 10, 20, cnt->imgs.width, tmp, cnt->conf.text_double); + } + return diffs; + } +@@ -1078,8 +1314,7 @@ int alg_switchfilter(struct context *cnt + * action - UPDATE_REF_FRAME or RESET_REF_FRAME + * + */ +-/* Seconds */ +-#define ACCEPT_STATIC_OBJECT_TIME 10 ++#define ACCEPT_STATIC_OBJECT_TIME 10 /* Seconds */ + #define EXCLUDE_LEVEL_PERCENT 20 + void alg_update_reference_frame(struct context *cnt, int action) + { +@@ -1091,40 +1326,43 @@ void alg_update_reference_frame(struct c + unsigned char *smartmask = cnt->imgs.smartmask_final; + unsigned char *out = cnt->imgs.out; + +- if (cnt->lastrate > 5) /* match rate limit */ ++ if (cnt->lastrate > 5) /* Match rate limit */ + accept_timer /= (cnt->lastrate / 3); + +- if (action == UPDATE_REF_FRAME) { /* black&white only for better performance */ ++ if (action == UPDATE_REF_FRAME) { /* Black&white only for better performance. */ + threshold_ref = cnt->noise * EXCLUDE_LEVEL_PERCENT / 100; ++ + for (i = cnt->imgs.motionsize; i > 0; i--) { +- /* exclude pixels from ref frame well below noise level */ ++ /* Exclude pixels from ref frame well below noise level. */ + if (((int)(abs(*ref - *image_virgin)) > threshold_ref) && (*smartmask)) { +- if (*ref_dyn == 0) { /* Always give new pixels a chance */ ++ if (*ref_dyn == 0) { /* Always give new pixels a chance. */ + *ref_dyn = 1; +- } else if (*ref_dyn > accept_timer) { /* Include static Object after some time */ ++ } else if (*ref_dyn > accept_timer) { /* Include static Object after some time. */ + *ref_dyn = 0; + *ref = *image_virgin; + } else if (*out) { +- (*ref_dyn)++; /* Motionpixel? Keep excluding from ref frame */ ++ (*ref_dyn)++; /* Motionpixel? Keep excluding from ref frame. */ + } else { +- *ref_dyn = 0; /* Nothing special - release pixel */ ++ *ref_dyn = 0; /* Nothing special - release pixel. */ + *ref = (*ref + *image_virgin) / 2; + } + +- } else { /* No motion: copy to ref frame */ +- *ref_dyn = 0; /* reset pixel */ ++ } else { /* No motion: copy to ref frame. */ ++ *ref_dyn = 0; /* Reset pixel */ + *ref = *image_virgin; + } ++ + ref++; + image_virgin++; + smartmask++; + ref_dyn++; + out++; + } /* end for i */ +- } else { /* action == RESET_REF_FRAME - also used to initialize the frame at startup */ +- /* copy fresh image */ ++ ++ } else { /* action == RESET_REF_FRAME - also used to initialize the frame at startup. */ ++ /* Copy fresh image */ + memcpy(cnt->imgs.ref, cnt->imgs.image_virgin, cnt->imgs.size); +- /* reset static objects */ +- memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); ++ /* Reset static objects */ ++ memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); + } + } +--- motion-3.2.12.orig/alg.h ++++ motion-3.2.12/alg.h +@@ -32,7 +32,8 @@ struct segment { + }; + + void alg_locate_center_size(struct images *, int width, int height, struct coord *); +-void alg_draw_location(struct coord *, struct images *, int width, unsigned char *, int); ++void alg_draw_location(struct coord *, struct images *, int width, unsigned char *, int, int, int); ++void alg_draw_red_location(struct coord *, struct images *, int width, unsigned char *, int, int, int); + int alg_diff(struct context *, unsigned char *); + int alg_diff_standard(struct context *, unsigned char *); + int alg_lightswitch(struct context *, int diffs); +--- /dev/null ++++ motion-3.2.12/commit-version.sh +@@ -0,0 +1,5 @@ ++#!/bin/sh ++ ++SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` ++SNV_VERSION=`expr $SNV_VERSION + 1` ++echo -n "trunkREV$SNV_VERSION" +--- motion-3.2.12.orig/conf.c ++++ motion-3.2.12/conf.c +@@ -25,8 +25,7 @@ + */ + #include "motion.h" + +- +-#if (defined(BSD)) ++#if (defined(BSD) && !defined(PWCBSD)) + #include "video_freebsd.h" + #else + #include "video.h" +@@ -35,140 +34,151 @@ + #ifndef HAVE_GET_CURRENT_DIR_NAME + char *get_current_dir_name(void) + { +- char *buf = malloc(MAXPATHLEN); ++ char *buf = mymalloc(MAXPATHLEN); + getwd(buf); + return buf; + } + #endif + +- +-#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0;} +- ++#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0; } + + struct config conf_template = { +- width: DEF_WIDTH, +- height: DEF_HEIGHT, +- quality: DEF_QUALITY, +- rotate_deg: 0, +- max_changes: DEF_CHANGES, +- threshold_tune: 0, +- output_normal: "on", +- motion_img: 0, +- output_all: 0, +- gap: DEF_GAP, +- maxmpegtime: DEF_MAXMPEGTIME, +- snapshot_interval: 0, +- locate: "off", +- input: IN_DEFAULT, +- norm: 0, +- frame_limit: DEF_MAXFRAMERATE, +- quiet: 1, +- ppm: 0, +- noise: DEF_NOISELEVEL, +- noise_tune: 1, +- minimum_frame_time: 0, +- lightswitch: 0, +- autobright: 0, +- brightness: 0, +- contrast: 0, +- saturation: 0, +- hue: 0, +- roundrobin_frames: 1, +- roundrobin_skip: 1, +- pre_capture: 0, +- post_capture: 0, +- switchfilter: 0, +- ffmpeg_cap_new: 0, +- ffmpeg_cap_motion: 0, +- ffmpeg_bps: DEF_FFMPEG_BPS, +- ffmpeg_vbr: DEF_FFMPEG_VBR, +- ffmpeg_video_codec: DEF_FFMPEG_CODEC, +- webcam_port: 0, +- webcam_quality: 50, +- webcam_motion: 0, +- webcam_maxrate: 1, +- webcam_localhost: 1, +- webcam_limit: 0, +- control_port: 0, +- control_localhost: 1, +- control_html_output: 1, +- control_authentication: NULL, +- frequency: 0, +- tuner_number: 0, +- timelapse: 0, +- timelapse_mode: DEF_TIMELAPSE_MODE, ++ width: DEF_WIDTH, ++ height: DEF_HEIGHT, ++ quality: DEF_QUALITY, ++ rotate_deg: 0, ++ max_changes: DEF_CHANGES, ++ threshold_tune: 0, ++ output_pictures: "on", ++ motion_img: 0, ++ emulate_motion: 0, ++ event_gap: DEF_EVENT_GAP, ++ max_movie_time: DEF_MAXMOVIETIME, ++ snapshot_interval: 0, ++ locate_motion_mode: "off", ++ locate_motion_style: "box", ++ input: IN_DEFAULT, ++ norm: 0, ++ frame_limit: DEF_MAXFRAMERATE, ++ quiet: 1, ++ picture_type: "jpeg", ++ noise: DEF_NOISELEVEL, ++ noise_tune: 1, ++ minimum_frame_time: 0, ++ lightswitch: 0, ++ autobright: 0, ++ brightness: 0, ++ contrast: 0, ++ saturation: 0, ++ hue: 0, ++ roundrobin_frames: 1, ++ roundrobin_skip: 1, ++ pre_capture: 0, ++ post_capture: 0, ++ switchfilter: 0, ++ ffmpeg_output: 0, ++ extpipe: NULL, ++ useextpipe: 0, ++ ffmpeg_output_debug: 0, ++ ffmpeg_bps: DEF_FFMPEG_BPS, ++ ffmpeg_vbr: DEF_FFMPEG_VBR, ++ ffmpeg_video_codec: DEF_FFMPEG_CODEC, ++#ifdef HAVE_SDL ++ sdl_threadnr: 0, ++#endif ++ ipv6_enabled: 0, ++ stream_port: 0, ++ stream_quality: 50, ++ stream_motion: 0, ++ stream_maxrate: 1, ++ stream_localhost: 1, ++ stream_limit: 0, ++ stream_auth_method: 0, ++ stream_authentication: NULL, ++ webcontrol_port: 0, ++ webcontrol_localhost: 1, ++ webcontrol_html_output: 1, ++ webcontrol_authentication: NULL, ++ frequency: 0, ++ tuner_number: 0, ++ timelapse: 0, ++ timelapse_mode: DEF_TIMELAPSE_MODE, + #if (defined(BSD)) +- tuner_device: NULL, ++ tuner_device: NULL, ++#endif ++ video_device: VIDEO_DEVICE, ++ v4l2_palette: DEF_PALETTE, ++ vidpipe: NULL, ++ filepath: NULL, ++ imagepath: DEF_IMAGEPATH, ++ moviepath: DEF_MOVIEPATH, ++ snappath: DEF_SNAPPATH, ++ timepath: DEF_TIMEPATH, ++ on_event_start: NULL, ++ on_event_end: NULL, ++ mask_file: NULL, ++ smart_mask_speed: 0, ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) ++ sql_log_image: 1, ++ sql_log_snapshot: 1, ++ sql_log_movie: 0, ++ sql_log_timelapse: 0, ++ sql_query: DEF_SQL_QUERY, ++ database_type: NULL, ++ database_dbname: NULL, ++ database_host: "localhost", ++ database_user: NULL, ++ database_password: NULL, ++ database_port: 0, ++#ifdef HAVE_SQLITE3 ++ sqlite3_db: NULL, + #endif +- video_device: VIDEO_DEVICE, +- v4l2_palette: 8, +- vidpipe: NULL, +- filepath: NULL, +- jpegpath: DEF_JPEGPATH, +- mpegpath: DEF_MPEGPATH, +- snappath: DEF_SNAPPATH, +- timepath: DEF_TIMEPATH, +- on_event_start: NULL, +- on_event_end: NULL, +- mask_file: NULL, +- smart_mask_speed: 0, +- sql_log_image: 1, +- sql_log_snapshot: 1, +- sql_log_mpeg: 0, +- sql_log_timelapse: 0, +- sql_query: DEF_SQL_QUERY, +- mysql_db: NULL, +- mysql_host: "localhost", +- mysql_user: NULL, +- mysql_password: NULL, +- on_picture_save: NULL, +- on_motion_detected: NULL, +- on_area_detected: NULL, +- on_movie_start: NULL, +- on_movie_end: NULL, +- on_camera_lost: NULL, +- motionvidpipe: NULL, +- netcam_url: NULL, +- netcam_userpass: NULL, +- netcam_http: "1.0", /* Choices: 1.0, 1.1, or keep_alive */ +- netcam_proxy: NULL, +- netcam_tolerant_check: 0, +- pgsql_db: NULL, +- pgsql_host: "localhost", +- pgsql_user: NULL, +- pgsql_password: NULL, +- pgsql_port: 5432, +- text_changes: 0, +- text_left: NULL, +- text_right: DEF_TIMESTAMP, +- text_event: DEF_EVENTSTAMP, +- text_double: 0, +- despeckle: NULL, +- area_detect: NULL, +- minimum_motion_frames: 1, +- pid_file: NULL, ++#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || define(HAVE_SQLITE3) */ ++ on_picture_save: NULL, ++ on_motion_detected: NULL, ++ on_area_detected: NULL, ++ on_movie_start: NULL, ++ on_movie_end: NULL, ++ on_camera_lost: NULL, ++ motionvidpipe: NULL, ++ netcam_url: NULL, ++ netcam_userpass: NULL, ++ netcam_keepalive: "off", ++ netcam_proxy: NULL, ++ netcam_tolerant_check: 0, ++ rtsp_uses_tcp: 1, ++ text_changes: 0, ++ text_left: NULL, ++ text_right: DEF_TIMESTAMP, ++ text_event: DEF_EVENTSTAMP, ++ text_double: 0, ++ despeckle_filter: NULL, ++ area_detect: NULL, ++ minimum_motion_frames: 1, ++ exif_text: NULL, ++ pid_file: NULL, ++ log_file: NULL, ++ log_level: LEVEL_DEFAULT+10, ++ log_type_str: NULL, + }; + + +- +-static struct context ** copy_bool(struct context **, const char *, int); +-static struct context ** copy_int(struct context **, const char *, int); +-static struct context ** copy_short(struct context **, const char *, int); +-static struct context ** config_thread(struct context **cnt, const char *str, int val); +- +-static const char * print_bool(struct context **, char **, int, unsigned short int); +-static const char * print_int(struct context **, char **, int, unsigned short int); +-static const char * print_short(struct context **, char **, int, unsigned short int); +-static const char * print_string(struct context **, char **, int, unsigned short int); +-static const char * print_thread(struct context **, char **, int, unsigned short int); ++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); ++ ++static const char *print_bool(struct context **, char **, int, unsigned int); ++static const char *print_int(struct context **, char **, int, unsigned int); ++static const char *print_string(struct context **, char **, int, unsigned int); ++static const char *print_thread(struct context **, char **, int, unsigned int); + + static void usage(void); + + /* Pointer magic to determine relative addresses of variables to a + struct context pointer */ + #define CNT_OFFSET(varname) ((long)&((struct context *)NULL)->varname) +-#define CONF_OFFSET(varname) ((long)&((struct context *)NULL)->conf.varname) +-#define TRACK_OFFSET(varname) ((long)&((struct context *)NULL)->track.varname) ++#define CONF_OFFSET(varname) ((long)&((struct context *)NULL)->conf.varname) ++#define TRACK_OFFSET(varname) ((long)&((struct context *)NULL)->track.varname) + + config_param config_params[] = { + { +@@ -202,6 +212,30 @@ config_param config_params[] = { + print_bool + }, + { ++ "logfile", ++ "# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)", ++ 1, ++ CONF_OFFSET(log_file), ++ copy_string, ++ print_string ++ }, ++ { ++ "log_level", ++ "# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC)", ++ 1, ++ CONF_OFFSET(log_level), ++ copy_int, ++ print_int ++ }, ++ { ++ "log_type", ++ "# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)", ++ 1, ++ CONF_OFFSET(log_type_str), ++ copy_string, ++ print_string ++ }, ++ { + "videodevice", + "\n###########################################################\n" + "# Capture device options\n" +@@ -216,26 +250,36 @@ config_param config_params[] = { + { + "v4l2_palette", + "# v4l2_palette allows to choose preferable palette to be use by motion\n" +- "# to capture from those supported by your videodevice. (default: 8)\n" ++ "# to capture from those supported by your videodevice. (default: 17)\n" + "# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and\n" + "# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG.\n" +- "# Setting v4l2_palette to 1 forces motion to use V4L2_PIX_FMT_SBGGR8\n" ++ "# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8\n" + "# instead.\n" + "#\n" + "# Values :\n" + "# V4L2_PIX_FMT_SN9C10X : 0 'S910'\n" +- "# V4L2_PIX_FMT_SBGGR8 : 1 'BA81'\n" +- "# V4L2_PIX_FMT_MJPEG : 2 'MJPEG'\n" +- "# V4L2_PIX_FMT_JPEG : 3 'JPEG'\n" +- "# V4L2_PIX_FMT_RGB24 : 4 'RGB3'\n" +- "# V4L2_PIX_FMT_UYVY : 5 'UYVY'\n" +- "# V4L2_PIX_FMT_YUYV : 6 'YUYV'\n" +- "# V4L2_PIX_FMT_YUV422P : 7 '422P'\n" +- "# V4L2_PIX_FMT_YUV420 : 8 'YU12'", ++ "# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2'\n" ++ "# V4L2_PIX_FMT_SBGGR8 : 2 'BA81'\n" ++ "# V4L2_PIX_FMT_SPCA561 : 3 'S561'\n" ++ "# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG'\n" ++ "# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG'\n" ++ "# V4L2_PIX_FMT_PAC207 : 6 'P207'\n" ++ "# V4L2_PIX_FMT_PJPG : 7 'PJPG'\n" ++ "# V4L2_PIX_FMT_MJPEG : 8 'MJPEG'\n" ++ "# V4L2_PIX_FMT_JPEG : 9 'JPEG'\n" ++ "# V4L2_PIX_FMT_RGB24 : 10 'RGB3'\n" ++ "# V4L2_PIX_FMT_SPCA501 : 11 'S501'\n" ++ "# V4L2_PIX_FMT_SPCA505 : 12 'S505'\n" ++ "# V4L2_PIX_FMT_SPCA508 : 13 'S508'\n" ++ "# V4L2_PIX_FMT_UYVY : 14 'UYVY'\n" ++ "# V4L2_PIX_FMT_YUYV : 15 'YUYV'\n" ++ "# V4L2_PIX_FMT_YUV422P : 16 '422P'\n" ++ "# V4L2_PIX_FMT_YUV420 : 17 'YU12'\n" ++ "#", + 0, + CONF_OFFSET(v4l2_palette), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + #if (defined(BSD)) + { +@@ -250,8 +294,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, +@@ -277,7 +321,7 @@ config_param config_params[] = { + { + "rotate", + "# Rotate image this number of degrees. The rotation affects all saved images as\n" +- "# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270.", ++ "# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270.", + 0, + CONF_OFFSET(rotate_deg), + copy_int, +@@ -320,7 +364,7 @@ config_param config_params[] = { + }, + { + "netcam_url", +- "# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///)\n" ++ "# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// or file:///)\n" + "# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined", + 0, + CONF_OFFSET(netcam_url), +@@ -337,14 +381,14 @@ config_param config_params[] = { + print_string + }, + { +- "netcam_http", ++ "netcam_keepalive", + "# The setting for keep-alive of network socket, should improve performance on compatible net cameras.\n" +- "# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request.\n" +- "# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection.\n" +- "# 1.1: Use HTTP/1.1 requests that support keep alive as default.\n" +- "# Default: 1.0", ++ "# off: The historical implementation using HTTP/1.0, closing the socket after each http request.\n" ++ "# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection.\n" ++ "# on: Use HTTP/1.1 requests that support keep alive as default.\n" ++ "# Default: off", + 0, +- CONF_OFFSET(netcam_http), ++ CONF_OFFSET(netcam_keepalive), + copy_string, + print_string + }, +@@ -361,11 +405,20 @@ config_param config_params[] = { + { + "netcam_tolerant_check", + "# Set less strict jpeg checks for network cameras with a poor/buggy firmware.\n" +- "# Default: off", ++ "# Default: off", + 0, + CONF_OFFSET(netcam_tolerant_check), + copy_bool, +- print_bool ++ print_bool ++ }, ++ { ++ "rtsp_uses_tcp", ++ "# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption.\n" ++ "# Default: on", ++ 1, ++ CONF_OFFSET(rtsp_uses_tcp), ++ copy_bool, ++ print_bool + }, + { + "auto_brightness", +@@ -480,22 +533,23 @@ config_param config_params[] = { + print_bool + }, + { +- "despeckle", ++ "despeckle_filter", + "# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined)\n" + "# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid.\n" + "# (l)abeling must only be used once and the 'l' must be the last letter.\n" + "# Comment out to disable", + 0, +- CONF_OFFSET(despeckle), ++ CONF_OFFSET(despeckle_filter), + copy_string, + print_string + }, + { + "area_detect", +- "# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3\n" ++ "# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3\n" + "# A script (on_area_detected) is started immediately when motion is 4 5 6\n" + "# detected in one of the given areas, but only once during an event. 7 8 9\n" +- "# One or more areas can be specified with this option. (Default: not defined)", ++ "# One or more areas can be specified with this option. Take care: This option\n" ++ "# does NOT restrict detection to these areas! (Default: not defined)", + 0, + CONF_OFFSET(area_detect), + copy_string, +@@ -522,7 +576,9 @@ config_param config_params[] = { + { + "lightswitch", + "# Ignore sudden massive light intensity changes given as a percentage of the picture\n" +- "# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled", ++ "# area that changed intensity. If set to 1, motion will do some kind of\n" ++ "# auto-lightswitch. Valid range: 0 - 100 , default: 0 = disabled", ++ + 0, + CONF_OFFSET(lightswitch), + copy_int, +@@ -544,7 +600,7 @@ config_param config_params[] = { + "# was detected that will be output at motion detection.\n" + "# Recommended range: 0 to 5 (default: 0)\n" + "# Do not use large values! Large values will cause Motion to skip video frames and\n" +- "# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.", ++ "# cause unsmooth movies. To smooth movies use larger values of post_capture instead.", + 0, + CONF_OFFSET(pre_capture), + copy_int, +@@ -559,35 +615,37 @@ config_param config_params[] = { + print_int + }, + { +- "gap", +- "# Gap is the seconds of no motion detection that triggers the end of an event\n" ++ "event_gap", ++ "# Event Gap is the seconds of no motion detection that triggers the end of an event.\n" + "# An event is defined as a series of motion images taken within a short timeframe.\n" +- "# Recommended value is 60 seconds (Default). The value 0 is allowed and disables\n" +- "# events causing all Motion to be written to one single mpeg file and no pre_capture.", ++ "# Recommended value is 60 seconds (Default). The value -1 is allowed and disables\n" ++ "# events causing all Motion to be written to one single movie file and no pre_capture.\n" ++ "# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An\n" ++ "# event ends right after no more motion is detected and post_capture is over.", + 0, +- CONF_OFFSET(gap), ++ CONF_OFFSET(event_gap), + copy_int, + print_int + }, + { +- "max_mpeg_time", +- "# Maximum length in seconds of an mpeg movie\n" +- "# When value is exceeded a new mpeg file is created. (Default: 0 = infinite)", ++ "max_movie_time", ++ "# Maximum length in seconds of a movie\n" ++ "# When value is exceeded a new movie file is created. (Default: 0 = infinite)", + 0, +- CONF_OFFSET(maxmpegtime), ++ CONF_OFFSET(max_movie_time), + copy_int, + print_int + }, + { +- "output_all", ++ "emulate_motion", + "# Always save images even if there was no motion (default: off)", + 0, +- CONF_OFFSET(output_all), ++ CONF_OFFSET(emulate_motion), + copy_bool, + print_bool + }, + { +- "output_normal", ++ "output_pictures", + "\n############################################################\n" + "# Image File Output\n" + "############################################################\n\n" +@@ -598,12 +656,12 @@ config_param config_params[] = { + "# Picture with motion nearest center of picture is saved when set to 'center'.\n" + "# Can be used as preview shot for the corresponding movie.", + 0, +- CONF_OFFSET(output_normal), ++ CONF_OFFSET(output_pictures), + copy_string, + print_string + }, + { +- "output_motion", ++ "output_debug_pictures", + "# Output pictures with only the pixels moving object (ghost images) (default: off)", + 0, + CONF_OFFSET(motion_img), +@@ -619,34 +677,35 @@ config_param config_params[] = { + print_int + }, + { +- "ppm", +- "# Output ppm images instead of jpeg (default: off)", ++ "picture_type", ++ "# Type of output images\n" ++ "# Valid values: jpeg, ppm (default: jpeg)", + 0, +- CONF_OFFSET(ppm), +- copy_bool, +- print_bool ++ CONF_OFFSET(picture_type), ++ copy_string, ++ print_string + }, + #ifdef HAVE_FFMPEG + { +- "ffmpeg_cap_new", ++ "ffmpeg_output_movies", + "\n############################################################\n" + "# FFMPEG related options\n" +- "# Film (mpeg) file output, and deinterlacing of the video input\n" ++ "# Film (movie) file output, and deinterlacing of the video input\n" + "# The options movie_filename and timelapse_filename are also used\n" + "# by the ffmpeg feature\n" + "############################################################\n\n" +- "# Use ffmpeg to encode mpeg movies in realtime (default: off)", ++ "# Use ffmpeg to encode movies in realtime (default: off)", + 0, +- CONF_OFFSET(ffmpeg_cap_new), ++ CONF_OFFSET(ffmpeg_output), + copy_bool, + print_bool + }, + { +- "ffmpeg_cap_motion", ++ "ffmpeg_output_debug_movies", + "# Use ffmpeg to make movies with only the pixels moving\n" + "# object (ghost images) (default: off)", + 0, +- CONF_OFFSET(ffmpeg_cap_motion), ++ CONF_OFFSET(ffmpeg_output_debug), + copy_bool, + print_bool + }, +@@ -691,7 +750,7 @@ config_param config_params[] = { + { + "ffmpeg_video_codec", + "# Codec to used by ffmpeg for the video compression.\n" +- "# Timelapse mpegs are always made in mpeg1 format independent from this option.\n" ++ "# Timelapse movies are always made in mpeg1 format independent from this option.\n" + "# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4.\n" + "# mpeg1 - gives you files with extension .mpg\n" + "# mpeg4 or msmpeg4 - gives you files with extension .avi\n" +@@ -700,7 +759,8 @@ config_param config_params[] = { + "# swf - gives you a flash film with extension .swf\n" + "# flv - gives you a flash video with extension .flv\n" + "# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )\n" +- "# mov - QuickTime ( testing )", ++ "# mov - QuickTime ( testing )\n" ++ "# ogg - Ogg/Theora ( testing )", + 0, + CONF_OFFSET(ffmpeg_video_codec), + copy_string, +@@ -717,6 +777,42 @@ config_param config_params[] = { + print_bool + }, + #endif /* HAVE_FFMPEG */ ++#ifdef HAVE_SDL ++ { ++ "sdl_threadnr", ++ "\n############################################################\n" ++ "# SDL Window\n" ++ "############################################################\n\n" ++ "# Number of motion thread to show in SDL Window (default: 0 = disabled)", ++ 1, ++ CONF_OFFSET(sdl_threadnr), ++ copy_int, ++ print_int ++ }, ++#endif /* HAVE_SDL */ ++ { ++ "use_extpipe", ++ "\n############################################################\n" ++ "# External pipe to video encoder\n" ++ "# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only.\n" ++ "# The options movie_filename and timelapse_filename are also used\n" ++ "# by the ffmpeg feature\n" ++ "############################################################\n\n" ++ "# Bool to enable or disable extpipe (default: off)", ++ 0, ++ CONF_OFFSET(useextpipe), ++ copy_bool, ++ print_bool ++ }, ++ { ++ "extpipe", ++ "# External program (full path and opts) to pipe raw video to\n" ++ "# Generally, use '-' for STDIN...", ++ 0, ++ CONF_OFFSET(extpipe), ++ copy_string, ++ print_string ++ }, + { + "snapshot_interval", + "\n############################################################\n" +@@ -729,7 +825,7 @@ config_param config_params[] = { + print_int + }, + { +- "locate", ++ "locate_motion_mode", + "\n############################################################\n" + "# Text Display\n" + "# %Y = year, %m = month, %d = date,\n" +@@ -743,10 +839,23 @@ config_param config_params[] = { + "# leading spaces\n" + "############################################################\n\n" + "# Locate and draw a box around the moving object.\n" +- "# Valid values: on, off and preview (default: off)\n" ++ "# Valid values: on, off, preview (default: off)\n" + "# Set to 'preview' will only draw a box in preview_shot pictures.", + 0, +- CONF_OFFSET(locate), ++ CONF_OFFSET(locate_motion_mode), ++ copy_string, ++ print_string ++ }, ++ { ++ "locate_motion_style", ++ "# Set the look and style of the locate box if enabled.\n" ++ "# Valid values: box, redbox, cross, redcross (default: box)\n" ++ "# Set to 'box' will draw the traditional box.\n" ++ "# Set to 'redbox' will draw a red box.\n" ++ "# Set to 'cross' will draw a little cross to mark center.\n" ++ "# Set to 'redcross' will draw a little red cross to mark center.", ++ 0, ++ CONF_OFFSET(locate_motion_style), + copy_string, + print_string + }, +@@ -770,7 +879,7 @@ config_param config_params[] = { + copy_string, + print_string + }, +- { ++ { + "text_changes", + "# Draw the number of changed pixed on the images (default: off)\n" + "# Will normally be set to off except when you setup and adjust the motion settings\n" +@@ -802,10 +911,20 @@ config_param config_params[] = { + print_bool + }, + { ++ "exif_text", ++ "# Text to include in a JPEG EXIF comment\n" ++ "# May be any text, including conversion specifiers.\n" ++ "# The EXIF timestamp is included independent of this text.", ++ 0, ++ CONF_OFFSET(exif_text), ++ copy_string, ++ print_string ++ }, ++ { + "target_dir", + "\n############################################################\n" + "# Target Directories and filenames For Images And Films\n" +- "# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename\n" ++ "# For the options snapshot_, picture_, movie_ and timelapse_filename\n" + "# you can use conversion specifiers\n" + "# %Y = year, %m = month, %d = date,\n" + "# %H = hour, %M = minute, %S = second,\n" +@@ -838,36 +957,36 @@ config_param config_params[] = { + print_string + }, + { +- "jpeg_filename", ++ "picture_filename", + "# File path for motion triggered images (jpeg or ppm) relative to target_dir\n" +- "# Default: "DEF_JPEGPATH"\n" ++ "# Default: "DEF_IMAGEPATH"\n" + "# Default value is equivalent to legacy oldlayout option\n" + "# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q\n" + "# File extension .jpg or .ppm is automatically added so do not include this\n" + "# Set to 'preview' together with best-preview feature enables special naming\n" + "# convention for preview shots. See motion guide for details", + 0, +- CONF_OFFSET(jpegpath), ++ CONF_OFFSET(imagepath), + copy_string, + print_string + }, + #ifdef HAVE_FFMPEG + { + "movie_filename", +- "# File path for motion triggered ffmpeg films (mpeg) relative to target_dir\n" +- "# Default: "DEF_MPEGPATH"\n" ++ "# File path for motion triggered ffmpeg films (movies) relative to target_dir\n" ++ "# Default: "DEF_MOVIEPATH"\n" + "# Default value is equivalent to legacy oldlayout option\n" + "# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S\n" + "# File extension .mpg or .avi is automatically added so do not include this\n" + "# This option was previously called ffmpeg_filename", + 0, +- CONF_OFFSET(mpegpath), ++ CONF_OFFSET(moviepath), + copy_string, + print_string + }, + { + "timelapse_filename", +- "# File path for timelapse mpegs relative to target_dir\n" ++ "# File path for timelapse movies relative to target_dir\n" + "# Default: "DEF_TIMEPATH"\n" + "# Default value is near equivalent to legacy oldlayout option\n" + "# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse\n" +@@ -879,107 +998,138 @@ config_param config_params[] = { + }, + #endif /* HAVE_FFMPEG */ + { +- "webcam_port", ++ "ipv6_enabled", + "\n############################################################\n" +- "# Live Webcam Server\n" ++ "# Global Network Options\n" ++ "############################################################\n\n" ++ "# Enable or disable IPV6 for http control and stream (default: off)", ++ 0, ++ CONF_OFFSET(ipv6_enabled), ++ copy_bool, ++ print_bool ++ }, ++ { ++ "stream_port", ++ "\n############################################################\n" ++ "# Live Stream Server\n" + "############################################################\n\n" + "# The mini-http server listens to this port for requests (default: 0 = disabled)", + 0, +- CONF_OFFSET(webcam_port), ++ CONF_OFFSET(stream_port), + copy_int, + print_int + }, + { +- "webcam_quality", ++ "stream_quality", + "# Quality of the jpeg (in percent) images produced (default: 50)", + 0, +- CONF_OFFSET(webcam_quality), ++ CONF_OFFSET(stream_quality), + copy_int, + print_int + }, + { +- "webcam_motion", ++ "stream_motion", + "# Output frames at 1 fps when no motion is detected and increase to the\n" +- "# rate given by webcam_maxrate when motion is detected (default: off)", ++ "# rate given by stream_maxrate when motion is detected (default: off)", + 0, +- CONF_OFFSET(webcam_motion), ++ CONF_OFFSET(stream_motion), + copy_bool, + print_bool + }, + { +- "webcam_maxrate", +- "# Maximum framerate for webcam streams (default: 1)", ++ "stream_maxrate", ++ "# Maximum framerate for streams (default: 1)", + 0, +- CONF_OFFSET(webcam_maxrate), ++ CONF_OFFSET(stream_maxrate), + copy_int, + print_int + }, + { +- "webcam_localhost", +- "# Restrict webcam connections to localhost only (default: on)", ++ "stream_localhost", ++ "# Restrict stream connections to localhost only (default: on)", + 0, +- CONF_OFFSET(webcam_localhost), ++ CONF_OFFSET(stream_localhost), + copy_bool, + print_bool + }, + { +- "webcam_limit", ++ "stream_limit", + "# Limits the number of images per connection (default: 0 = unlimited)\n" +- "# Number can be defined by multiplying actual webcam rate by desired number of seconds\n" +- "# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate", ++ "# Number can be defined by multiplying actual stream rate by desired number of seconds\n" ++ "# Actual stream rate is the smallest of the numbers framerate and stream_maxrate", ++ 0, ++ CONF_OFFSET(stream_limit), ++ copy_int, ++ print_int ++ }, ++ { ++ "stream_auth_method", ++ "# Set the authentication method (default: 0)\n" ++ "# 0 = disabled \n" ++ "# 1 = Basic authentication\n" ++ "# 2 = MD5 digest (the safer authentication)\n", + 0, +- CONF_OFFSET(webcam_limit), ++ CONF_OFFSET(stream_auth_method), + copy_int, + print_int + }, + { +- "control_port", ++ "stream_authentication", ++ "# Authentication for the stream. Syntax username:password\n" ++ "# Default: not defined (Disabled)", ++ 1, ++ CONF_OFFSET(stream_authentication), ++ copy_string, ++ print_string ++ }, ++ { ++ "webcontrol_port", + "\n############################################################\n" + "# HTTP Based Control\n" + "############################################################\n\n" + "# TCP/IP port for the http server to listen on (default: 0 = disabled)", + 1, +- CONF_OFFSET(control_port), ++ CONF_OFFSET(webcontrol_port), + copy_int, + print_int + }, + { +- "control_localhost", ++ "webcontrol_localhost", + "# Restrict control connections to localhost only (default: on)", + 1, +- CONF_OFFSET(control_localhost), ++ CONF_OFFSET(webcontrol_localhost), + copy_bool, + print_bool + }, + { +- "control_html_output", ++ "webcontrol_html_output", + "# Output for http server, select off to choose raw text plain (default: on)", + 1, +- CONF_OFFSET(control_html_output), ++ CONF_OFFSET(webcontrol_html_output), + copy_bool, + print_bool + }, + { +- "control_authentication", ++ "webcontrol_authentication", + "# Authentication for the http based control. Syntax username:password\n" + "# Default: not defined (Disabled)", + 1, +- CONF_OFFSET(control_authentication), ++ CONF_OFFSET(webcontrol_authentication), + copy_string, + print_string +- }, ++ }, + { + "track_type", + "\n############################################################\n" + "# Tracking (Pan/Tilt)\n" + "############################################################\n\n" +- "# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo)\n" ++ "# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo)\n" + "# The generic type enables the definition of motion center and motion size to\n" + "# be used with the conversion specifiers for options like on_motion_detected", + 0, + TRACK_OFFSET(type), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "track_auto", +@@ -1002,40 +1152,88 @@ config_param config_params[] = { + "# Motor number for x-axis (default: 0)", + 0, + TRACK_OFFSET(motorx), +- copy_short, +- print_short ++ copy_int, ++ print_int ++ }, ++ { ++ "track_motorx_reverse", ++ "# Set motorx reverse (default: off)", ++ 0, ++ TRACK_OFFSET(motorx_reverse), ++ copy_bool, ++ print_bool + }, + { + "track_motory", + "# Motor number for y-axis (default: 0)", + 0, + TRACK_OFFSET(motory), +- copy_short, +- print_short ++ copy_int, ++ print_int ++ }, ++ { ++ "track_motory_reverse", ++ "# Set motory reverse (default: off)", ++ 0, ++ TRACK_OFFSET(motory_reverse), ++ copy_bool, ++ print_bool + }, + { + "track_maxx", + "# Maximum value on x-axis (default: 0)", + 0, + TRACK_OFFSET(maxx), +- copy_short, +- print_short ++ copy_int, ++ print_int ++ }, ++ { ++ "track_minx", ++ "# Minimum value on x-axis (default: 0)", ++ 0, ++ TRACK_OFFSET(minx), ++ copy_int, ++ print_int + }, + { + "track_maxy", + "# Maximum value on y-axis (default: 0)", + 0, + TRACK_OFFSET(maxy), +- copy_short, +- print_short ++ copy_int, ++ print_int ++ }, ++ { ++ "track_miny", ++ "# Minimum value on y-axis (default: 0)", ++ 0, ++ TRACK_OFFSET(miny), ++ copy_int, ++ print_int ++ }, ++ { ++ "track_homex", ++ "# Center value on x-axis (default: 0)", ++ 0, ++ TRACK_OFFSET(homex), ++ copy_int, ++ print_int ++ }, ++ { ++ "track_homey", ++ "# Center value on y-axis (default: 0)", ++ 0, ++ TRACK_OFFSET(homey), ++ copy_int, ++ print_int + }, + { + "track_iomojo_id", + "# ID of an iomojo camera if used (default: 0)", + 0, + TRACK_OFFSET(iomojo_id), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "track_step_angle_x", +@@ -1044,8 +1242,8 @@ config_param config_params[] = { + "# Currently only used with pwc type cameras", + 0, + TRACK_OFFSET(step_angle_x), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "track_step_angle_y", +@@ -1054,8 +1252,8 @@ config_param config_params[] = { + "# Currently only used with pwc type cameras", + 0, + TRACK_OFFSET(step_angle_y), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "track_move_wait", +@@ -1063,24 +1261,24 @@ config_param config_params[] = { + "# of picture frames (default: 10)", + 0, + TRACK_OFFSET(move_wait), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "track_speed", + "# Speed to set the motor to (stepper motor option) (default: 255)", + 0, + TRACK_OFFSET(speed), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "track_stepsize", + "# Number of steps to make (stepper motor option) (default: 40)", + 0, + TRACK_OFFSET(stepsize), +- copy_short, +- print_short ++ copy_int, ++ print_int + }, + { + "quiet", +@@ -1097,7 +1295,7 @@ config_param config_params[] = { + "# %f = filename with full path\n" + "# %n = number indicating filetype\n" + "# Both %f and %n are only defined for on_picture_save,\n" +- "# on_movie_start and on_movie_end\n" ++ "# on_movie_start and on_movie_end\n" + "# Quotation marks round string are allowed.\n" + "############################################################\n\n" + "# Do not sound beeps when detecting motion (default: on)\n" +@@ -1110,7 +1308,7 @@ config_param config_params[] = { + { + "on_event_start", + "# Command to be executed when an event starts. (default: none)\n" +- "# An event starts at first motion detected after a period of no motion defined by gap ", ++ "# An event starts at first motion detected after a period of no motion defined by event_gap ", + 0, + CONF_OFFSET(on_event_start), + copy_string, +@@ -1119,7 +1317,7 @@ config_param config_params[] = { + { + "on_event_end", + "# Command to be executed when an event ends after a period of no motion\n" +- "# (default: none). The period of no motion is defined by option gap.", ++ "# (default: none). The period of no motion is defined by option event_gap.", + 0, + CONF_OFFSET(on_event_end), + copy_string, +@@ -1174,21 +1372,21 @@ config_param config_params[] = { + { + "on_camera_lost", + "# Command to be executed when a camera can't be opened or if it is lost\n" +- "# NOTE: There is situations when motion doesn't detect a lost camera!\n" +- "# It depends on the driver, some drivers don't detect a lost camera at all\n" +- "# Some hang the motion thread. Some even hang the PC! (default: none)", ++ "# NOTE: There is situations when motion don't detect a lost camera!\n" ++ "# It depends on the driver, some drivers dosn't detect a lost camera at all\n" ++ "# Some hangs the motion thread. Some even hangs the PC! (default: none)", + 0, + CONF_OFFSET(on_camera_lost), + copy_string, + print_string + }, + +-#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) + { +- "sql_log_image", ++ "sql_log_picture", + "\n############################################################\n" +- "# Common Options For MySQL and PostgreSQL database features.\n" +- "# Options require the MySQL/PostgreSQL options to be active also.\n" ++ "# Common Options for database features.\n" ++ "# Options require the database options to be active also.\n" + "############################################################\n\n" + "# Log to the database when creating motion triggered image file (default: on)", + 0, +@@ -1205,16 +1403,16 @@ config_param config_params[] = { + print_bool + }, + { +- "sql_log_mpeg", +- "# Log to the database when creating motion triggered mpeg file (default: off)", ++ "sql_log_movie", ++ "# Log to the database when creating motion triggered movie file (default: off)", + 0, +- CONF_OFFSET(sql_log_mpeg), ++ CONF_OFFSET(sql_log_movie), + copy_bool, + print_bool + }, + { + "sql_log_timelapse", +- "# Log to the database when creating timelapse mpeg file (default: off)", ++ "# Log to the database when creating timelapse movie file (default: off)", + 0, + CONF_OFFSET(sql_log_timelapse), + copy_bool, +@@ -1227,6 +1425,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, +@@ -1234,98 +1440,80 @@ config_param config_params[] = { + copy_string, + print_string + }, +-#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) */ +- +-#ifdef HAVE_MYSQL + { +- "mysql_db", ++ "database_type", + "\n############################################################\n" +- "# Database Options For MySQL\n" ++ "# Database Options \n" + "############################################################\n\n" +- "# Mysql database to log to (default: not defined)", ++ "# database type : mysql, postgresql, sqlite3 (default : not defined)", + 0, +- CONF_OFFSET(mysql_db), ++ CONF_OFFSET(database_type), + copy_string, + print_string + }, + { +- "mysql_host", +- "# The host on which the database is located (default: localhost)", ++ "database_dbname", ++ "# database to log to (default: not defined)", + 0, +- CONF_OFFSET(mysql_host), ++ CONF_OFFSET(database_dbname), + copy_string, + print_string + }, + { +- "mysql_user", +- "# User account name for MySQL database (default: not defined)", ++ "database_host", ++ "# The host on which the database is located (default: not defined)", + 0, +- CONF_OFFSET(mysql_user), ++ CONF_OFFSET(database_host), + copy_string, + print_string + }, + { +- "mysql_password", +- "# User password for MySQL database (default: not defined)", ++ "database_user", ++ "# User account name for database (default: not defined)", + 0, +- CONF_OFFSET(mysql_password), ++ CONF_OFFSET(database_user), + copy_string, + print_string + }, +-#endif /* HAVE_MYSQL */ +- +-#ifdef HAVE_PGSQL + { +- "pgsql_db", +- "\n############################################################\n" +- "# Database Options For PostgreSQL\n" +- "############################################################\n\n" +- "# PostgreSQL database to log to (default: not defined)", ++ "database_password", ++ "# User password for database (default: not defined)", + 0, +- CONF_OFFSET(pgsql_db), ++ CONF_OFFSET(database_password), + copy_string, + print_string + }, + { +- "pgsql_host", +- "# The host on which the database is located (default: localhost)", ++ "database_port", ++ "# Port on which the database is located (default: not defined)\n" ++ "# mysql 3306 , postgresql 5432 (default: not defined)", + 0, +- CONF_OFFSET(pgsql_host), +- copy_string, +- print_string +- }, +- { +- "pgsql_user", +- "# User account name for PostgreSQL database (default: not defined)", +- 0, +- CONF_OFFSET(pgsql_user), +- copy_string, +- print_string ++ CONF_OFFSET(database_port), ++ copy_int, ++ print_int + }, ++#ifdef HAVE_SQLITE3 + { +- "pgsql_password", +- "# User password for PostgreSQL database (default: not defined)", ++ "sqlite3_db", ++ "\n############################################################\n" ++ "# Database Options For SQLite3\n" ++ "############################################################\n\n" ++ "# SQLite3 database to log to (default: not defined)", + 0, +- CONF_OFFSET(pgsql_password), ++ CONF_OFFSET(sqlite3_db), + copy_string, + print_string + }, +- { +- "pgsql_port", +- "# Port on which the PostgreSQL database is located (default: 5432)", +- 0, +- CONF_OFFSET(pgsql_port), +- copy_int, +- print_int +- }, +-#endif /* HAVE_PGSQL */ ++#endif /* HAVE_SQLITE3 */ ++ ++#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ + { + "video_pipe", + "\n############################################################\n" + "# Video Loopback Device (vloopback project)\n" + "############################################################\n\n" + "# Output images to a video4linux loopback device\n" +- "# The value '-' means next available (default: not defined)", ++ "# The value '-' means next available (default: not defined)", + 0, + CONF_OFFSET(vidpipe), + copy_string, +@@ -1356,22 +1544,27 @@ config_param config_params[] = { + { NULL, NULL, 0, 0, NULL, NULL } + }; + +-/* conf_cmdline sets the conf struct options as defined by the command line. +- * Any option already set from a config file are overridden. ++/** ++ * conf_cmdline ++ * Sets the conf struct options as defined by the Command-line. ++ * Any option already set from a config file are overridden. ++ * ++ * Returns nothing. + */ +-static void conf_cmdline(struct context *cnt, short int thread) ++static void conf_cmdline(struct context *cnt, int thread) + { + struct config *conf = &cnt->conf; + int c; + +- /* For the string options, we free() if necessary and malloc() ++ /* ++ * For the string options, we free() if necessary and malloc() + * 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:")) != EOF) ++ while ((c = getopt(conf->argc, conf->argv, "c:d:hmns?p:k:l:")) != EOF) + switch (c) { + case 'c': +- if (thread == -1) ++ if (thread == -1) + strcpy(cnt->conf_filename, optarg); + break; + case 'n': +@@ -1381,59 +1574,83 @@ static void conf_cmdline(struct context + conf->setup_mode = 1; + break; + case 'd': +- /* no validation - just take what user gives */ +- debug_level = (unsigned short int)atoi(optarg); ++ /* No validation - just take what user gives. */ ++ if (thread == -1) ++ cnt->log_level = (unsigned int)atoi(optarg); + break; ++ case 'k': ++ if (thread == -1) { ++ strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); ++ cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; ++ } ++ break; + case 'p': +- if (thread == -1) +- strcpy(cnt->pid_file, optarg); ++ if (thread == -1) { ++ strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); ++ cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; ++ } ++ break; ++ case 'l': ++ if (thread == -1) { ++ strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); ++ cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; ++ } ++ break; ++ case 'm': ++ cnt->pause = 1; + break; + case 'h': + case '?': + default: +- usage(); +- exit(1); ++ usage(); ++ exit(1); + } ++ + optind = 1; + } + + +-/* conf_cmdparse sets a config option given by 'cmd' to the value given by 'arg1'. +- * Based on the name of the option it searches through the struct 'config_params' +- * for an option where the config_params[i].param_name matches the option. +- * By calling the function pointed to by config_params[i].copy the option gets +- * assigned. ++/** ++ * conf_cmdparse ++ * Sets a config option given by 'cmd' to the value given by 'arg1'. ++ * Based on the name of the option it searches through the struct 'config_params' ++ * for an option where the config_params[i].param_name matches the option. ++ * By calling the function pointed to by config_params[i].copy the option gets ++ * assigned. ++ * ++ * Returns context struct. + */ + struct context **conf_cmdparse(struct context **cnt, const char *cmd, const char *arg1) + { +- unsigned short int i = 0; ++ unsigned int i = 0; + + if (!cmd) + return cnt; + +- /* We search through config_params until we find a param_name that matches +- * our option given by cmd (or reach the end = NULL) ++ /* ++ * We search through config_params until we find a param_name that matches ++ * our option given by cmd (or reach the end = NULL). + */ + while (config_params[i].param_name != NULL) { + if (!strncasecmp(cmd, config_params[i].param_name , 255 + 50)) { // Why +50? +- +- /* if config_param is string we don't want to check arg1 */ +- if (strcmp(config_type(&config_params[i]),"string")) { ++ ++ /* If config_param is string we don't want to check arg1. */ ++ if (strcmp(config_type(&config_params[i]), "string")) { + if (config_params[i].conf_value && !arg1) + return cnt; + } +- +- /* We call the function given by the pointer config_params[i].copy ++ ++ /* ++ * We call the function given by the pointer config_params[i].copy + * If the option is a bool, copy_bool is called. + * If the option is an int, copy_int is called. +- * If the option is a short, copy_short is called. + * If the option is a string, copy_string is called. + * If the option is a thread, config_thread is called. + * The arguments to the function are: +- * cnt - a pointer to the context structure +- * arg1 - a pointer to the new option value (represented as string) ++ * cnt - a pointer to the context structure. ++ * arg1 - a pointer to the new option value (represented as string). + * config_params[i].conf_value - an integer value which is a pointer +- * to the context structure member relative to the pointer cnt. ++ * to the context structure member relative to the pointer cnt. + */ + cnt = config_params[i].copy(cnt, arg1, config_params[i].conf_value); + return cnt; +@@ -1441,78 +1658,85 @@ struct context **conf_cmdparse(struct co + i++; + } + +- /* We reached the end of config_params without finding a matching option */ +- motion_log(LOG_ERR, 0, "Unknown config option \"%s\"", cmd); ++ /* We reached the end of config_params without finding a matching option. */ ++ MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, "%s: Unknown config option \"%s\"", ++ cmd); + + return cnt; + } + +-/* conf_process walks through an already open config file line by line +- * Any line starting with '#' or ';' or empty lines are ignored as a comments. +- * Any non empty line is process so that the first word is the name of an option 'cnd' +- * and the rest of the line is the argument 'arg1' +- * White space before the first word, between option and argument and end of the line +- * is discarded. A '=' between option and first word in argument is also discarded. +- * Quotation marks round the argument are also discarded. +- * For each option/argument pair the function conf_cmdparse is called which takes +- * care of assigning the value to the option in the config structures. ++/** ++ * conf_process ++ * Walks through an already open config file line by line ++ * Any line starting with '#' or ';' or empty lines are ignored as a comments. ++ * Any non empty line is process so that the first word is the name of an option 'cnd' ++ * and the rest of the line is the argument 'arg1' ++ * White space before the first word, between option and argument and end of the line ++ * is discarded. A '=' between option and first word in argument is also discarded. ++ * Quotation marks round the argument are also discarded. ++ * For each option/argument pair the function conf_cmdparse is called which takes ++ * care of assigning the value to the option in the config structures. ++ * ++ * Returns context struct. + */ + static struct context **conf_process(struct context **cnt, FILE *fp) + { +- /* process each line from the config file */ +- ++ /* Process each line from the config file. */ ++ + char line[PATH_MAX], *cmd = NULL, *arg1 = NULL; + char *beg = NULL, *end = NULL; + + while (fgets(line, PATH_MAX-1, fp)) { +- if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) {/* skipcomment */ +- ++ if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) {/* skipcomment */ ++ + arg1 = NULL; + +- /* trim white space and any CR or LF at the end of the line */ +- end = line + strlen(line) - 1; /* Point to the last non-null character in the string */ ++ /* Trim white space and any CR or LF at the end of the line. */ ++ end = line + strlen(line) - 1; /* Point to the last non-null character in the string. */ + while (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r') + end--; + + *(end+1) = '\0'; +- +- /* If line is only whitespace we continue to the next line */ ++ ++ /* If line is only whitespace we continue to the next line. */ + if (strlen(line) == 0) + continue; + +- /* trim leading whitespace from the line and find command */ ++ /* Trim leading whitespace from the line and find command. */ + beg = line; +- + while (*beg == ' ' || *beg == '\t') + beg++; + +- cmd = beg; /* command starts here */ ++ ++ cmd = beg; /* Command starts here. */ + + while (*beg != ' ' && *beg != '\t' && *beg != '=' && *beg != '\0') + beg++; +- +- *beg = '\0'; /* command string terminates here */ + +- /* trim space between command and argument */ ++ *beg = '\0'; /* Command string terminates here. */ ++ ++ /* Trim space between command and argument. */ + beg++; + + if (strlen(beg) > 0) { + while (*beg == ' ' || *beg == '\t' || *beg == '=' || *beg == '\n' || *beg == '\r') + beg++; +- + +- /* If argument is in "" we will strip them off +- It is important that we can use "" so that we can use +- leading spaces in text_left and text_right */ +- if ((beg[0]=='"' && beg[strlen(beg)-1]=='"') || +- (beg[0]=='\'' && beg[strlen(beg)-1]=='\'')) { +- beg[strlen(beg)-1]='\0'; ++ ++ /* ++ * If argument is in "" we will strip them off ++ * It is important that we can use "" so that we can use ++ * leading spaces in text_left and text_right. ++ */ ++ if ((beg[0] == '"' && beg[strlen(beg)-1] == '"') || ++ (beg[0] == '\'' && beg[strlen(beg)-1] == '\'')) { ++ beg[strlen(beg)-1] = '\0'; + beg++; + } +- ++ + arg1 = beg; /* Argument starts here */ + } +- /* else arg1 stays null pointer */ ++ /* Else arg1 stays null pointer */ + + cnt = conf_cmdparse(cnt, cmd, arg1); + } +@@ -1522,19 +1746,25 @@ static struct context **conf_process(str + } + + +-/* conf_print is used to write out the config file(s) motion.conf and any thread +- * config files. The function is called when using http remote control. ++/** ++ * conf_print ++ * Is used to write out the config file(s) motion.conf and any thread ++ * config files. The function is called when using http remote control. ++ * ++ * Returns nothing. + */ + void conf_print(struct context **cnt) + { + const char *retval; + char *val; +- unsigned short int i, thread; ++ unsigned int i, thread; + FILE *conffile; + + for (thread = 0; cnt[thread]; thread++) { +- motion_log(LOG_INFO, 0, "Writing config file to %s",cnt[thread]->conf_filename); +- conffile=myfopen(cnt[thread]->conf_filename, "w"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Writing config file to %s", ++ cnt[thread]->conf_filename); ++ ++ conffile = myfopen(cnt[thread]->conf_filename, "w", 0); + + if (!conffile) + continue; +@@ -1544,13 +1774,14 @@ void conf_print(struct context **cnt) + fprintf(conffile, "\n\n"); + + for (i = 0; config_params[i].param_name; i++) { +- retval=config_params[i].print(cnt, NULL, i, thread); +- /*If config parameter has a value (not NULL) print it to the config file*/ +- ++ retval = config_params[i].print(cnt, NULL, i, thread); ++ /* If config parameter has a value (not NULL) print it to the config file. */ + if (retval) { + fprintf(conffile, "%s\n", config_params[i].param_help); +- /* If the option is a text_* and first char is a space put +- quotation marks around to allow leading spaces */ ++ /* ++ * If the option is a text_* and first char is a space put ++ * quotation marks around to allow leading spaces. ++ */ + if (strncmp(config_params[i].param_name, "text", 4) || strncmp(retval, " ", 1)) + fprintf(conffile, "%s %s\n\n", config_params[i].param_name, retval); + else +@@ -1558,34 +1789,38 @@ void conf_print(struct context **cnt) + } else { + val = NULL; + config_params[i].print(cnt, &val, i, thread); +- /* It can either be a thread file parameter or a disabled parameter +- If it is a thread parameter write it out +- Else write the disabled option to the config file but with a +- comment mark in front of the parameter name */ ++ /* ++ * It can either be a thread file parameter or a disabled parameter. ++ * If it is a thread parameter write it out. ++ * Else write the disabled option to the config file but with a ++ * comment mark in front of the parameter name. ++ */ + if (val) { +- fprintf(conffile,"%s\n", config_params[i].param_help); ++ fprintf(conffile, "%s\n", config_params[i].param_help); + fprintf(conffile, "%s\n", val); + + if (strlen(val) == 0) +- fprintf(conffile,"; thread /usr/local/etc/thread1.conf\n"); ++ fprintf(conffile, "; thread /usr/local/etc/thread1.conf\n"); ++ + free(val); +- } else if (thread == 0) { +- fprintf(conffile,"%s\n", config_params[i].param_help); +- fprintf(conffile,"; %s value\n\n", config_params[i].param_name); ++ } else if (thread == 0) { ++ fprintf(conffile, "%s\n", config_params[i].param_help); ++ fprintf(conffile, "; %s value\n\n", config_params[i].param_name); + } + } + } + + fprintf(conffile, "\n"); +- fclose(conffile); ++ myfclose(conffile); + conffile = NULL; + } + } + +-/************************************************************************** +- * conf_load is the main function, called from motion.c ++/** ++ * conf_load ++ * Is the main function, called from motion.c + * The function sets the important context structure "cnt" including +- * loading the config parameters from config files and command line. ++ * loading the config parameters from config files and Command-line. + * The following takes place in the function: + * - The default start values for cnt stored in the struct conf_template + * are copied to cnt[0] which is the default context structure common to +@@ -1596,31 +1831,35 @@ void conf_print(struct context **cnt) + * - motion.conf is opened and processed. The process populates the cnt[0] and + * for each thread config file it populates a cnt[1], cnt[2]... for each + * thread +- * - Finally it process the options given in the command line. This is done +- * for each thread cnt[i] so that the command line options overrides any ++ * - Finally it process the options given in the Command-line. This is done ++ * for each thread cnt[i] so that the Command-line options overrides any + * option given by motion.conf or a thread config file. +- **************************************************************************/ ++ * ++ * Returns context struct. ++ */ + struct context **conf_load(struct context **cnt) + { + FILE *fp = NULL; + char filename[PATH_MAX]; + int i; +- /* We preserve argc and argv because they get overwritten by the memcpy command */ ++ /* We preserve argc and argv because they get overwritten by the memcpy command. */ + char **argv = cnt[0]->conf.argv; + int argc = cnt[0]->conf.argc; + +- /* Copy the template config structure with all the default config values ++ /* ++ * Copy the template config structure with all the default config values + * into cnt[0]->conf + */ + memcpy(&cnt[0]->conf, &conf_template, sizeof(struct config)); +- +- /* For each member of cnt[0] which is a pointer to a string +- * if the member points to a string in conf_template and is not NULL +- * 1. Reserve (malloc) memory for the string +- * 2. Copy the conf_template given string to the reserved memory +- * 3. Change the cnt[0] member (char*) pointing to the string in reserved memory ++ ++ /* ++ * For each member of cnt[0] which is a pointer to a string ++ * if the member points to a string in conf_template and is not NULL. ++ * 1. Reserve (malloc) memory for the string. ++ * 2. Copy the conf_template given string to the reserved memory. ++ * 3. Change the cnt[0] member (char*) pointing to the string in reserved memory. + * This ensures that we can free and malloc the string when changed +- * via http remote control or config file or command line options ++ * via http remote control or config file or Command-line options. + */ + malloc_strings(cnt[0]); + +@@ -1628,29 +1867,37 @@ struct context **conf_load(struct contex + cnt[0]->conf.argv = argv; + cnt[0]->conf.argc = argc; + +- /* Open the motion.conf file. We try in this sequence: +- * 1. commandline ++ /* ++ * Open the motion.conf file. We try in this sequence: ++ * 1. Command-line + * 2. current working directory + * 3. $HOME/.motion/motion.conf + * 4. sysconfig/motion.conf + */ +- /* Get filename & pid file from commandline */ ++ /* Get filename , pid file & log file from Command-line. */ ++ cnt[0]->log_type_str[0] = 0; + cnt[0]->conf_filename[0] = 0; + cnt[0]->pid_file[0] = 0; ++ cnt[0]->log_file[0] = 0; ++ cnt[0]->log_level = -1; + + conf_cmdline(cnt[0], -1); +- if (cnt[0]->conf_filename[0]) { /* User has supplied filename on commandline*/ +- strcpy(filename, cnt[0]->conf_filename); +- fp = fopen (filename, "r"); ++ ++ if (cnt[0]->conf_filename[0]) { /* User has supplied filename on Command-line. */ ++ strncpy(filename, cnt[0]->conf_filename, PATH_MAX-1); ++ filename[PATH_MAX-1] = '\0'; ++ fp = fopen (filename, "r"); + } + +- if (!fp) { /* Commandline didn't work, try current dir */ ++ if (!fp) { /* Command-line didn't work, try current dir. */ + char *path = NULL; ++ + if (cnt[0]->conf_filename[0]) +- motion_log(-1, 1, "Configfile %s not found - trying defaults.", filename); +- ++ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Configfile %s not found - trying defaults.", ++ filename); ++ + if ((path = get_current_dir_name()) == NULL) { +- motion_log(LOG_ERR, 1, "Error get_current_dir_name"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error get_current_dir_name"); + exit(-1); + } + +@@ -1659,65 +1906,89 @@ struct context **conf_load(struct contex + free(path); + } + +- if (!fp) { /* specified file does not exist... try default file */ ++ if (!fp) { /* Specified file does not exist... try default file. */ + snprintf(filename, PATH_MAX, "%s/.motion/motion.conf", getenv("HOME")); + fp = fopen(filename, "r"); ++ + if (!fp) { + snprintf(filename, PATH_MAX, "%s/motion.conf", sysconfdir); + fp = fopen(filename, "r"); +- if (!fp) /* there is no config file.... use defaults */ +- motion_log(-1, 1, "could not open configfile %s",filename); ++ ++ if (!fp) /* There is no config file.... use defaults. */ ++ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: could not open configfile %s", ++ filename); + } + } + +- /* Now we process the motion.conf config file and close it*/ ++ /* Now we process the motion.conf config file and close it. */ + if (fp) { +- strcpy(cnt[0]->conf_filename, filename); +- motion_log(LOG_INFO, 0, "Processing thread 0 - config file %s",filename); +- cnt = conf_process(cnt, fp); +- fclose(fp); ++ strncpy(cnt[0]->conf_filename, filename, sizeof(cnt[0]->conf_filename) - 1); ++ cnt[0]->conf_filename[sizeof(cnt[0]->conf_filename) - 1] = '\0'; ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing thread 0 - config file %s", ++ filename); ++ cnt = conf_process(cnt, fp); ++ myfclose(fp); + } else { +- motion_log(LOG_INFO, 0, "Not config file to process using default values"); ++ MOTION_LOG(CRT, TYPE_ALL, NO_ERRNO, "%s: Not config file to process using default values"); + } +- + +- /* For each thread (given by cnt[i]) being not null ++ ++ /* ++ * For each thread (given by cnt[i]) being not null + * cnt is an array of pointers to a context type structure + * cnt[0] is the default context structure + * cnt[1], cnt[2], ... are context structures for each thread + * Command line options always wins over config file options +- * so we go through each thread and overrides any set command line +- * options ++ * so we go through each thread and overrides any set Command-line ++ * options. + */ + i = -1; ++ + while (cnt[++i]) + conf_cmdline(cnt[i], i); + +- /* if pid file was passed from command line copy to main thread conf struct */ +- if (cnt[0]->pid_file[0]) ++ /* If pid file was passed from Command-line copy to main thread conf struct. */ ++ if (cnt[0]->pid_file[0]) + cnt[0]->conf.pid_file = mystrcpy(cnt[0]->conf.pid_file, cnt[0]->pid_file); + ++ /* If log file was passed from Command-line copy to main thread conf struct. */ ++ if (cnt[0]->log_file[0]) ++ cnt[0]->conf.log_file = mystrcpy(cnt[0]->conf.log_file, cnt[0]->log_file); ++ ++ /* If log type string was passed from Command-line copy to main thread conf struct. */ ++ if (cnt[0]->log_type_str[0]) ++ cnt[0]->conf.log_type_str = mystrcpy(cnt[0]->conf.log_type_str, cnt[0]->log_type_str); ++ ++ /* if log level was passed from Command-line copy to main thread conf struct. */ ++ if (cnt[0]->log_level != -1) ++ cnt[0]->conf.log_level = cnt[0]->log_level; ++ + return cnt; + } + +-/* malloc_strings goes through the members of a context structure. +- * For each context structure member which is a pointer to a string it does this: +- * If the member points to a string and is not NULL +- * 1. Reserve (malloc) memory for the string +- * 2. Copy the original string to the reserved memory +- * 3. Change the cnt member (char*) pointing to the string in reserved memory +- * This ensures that we can free and malloc the string if it is later changed ++/** ++ * malloc_strings ++ * goes through the members of a context structure. ++ * For each context structure member which is a pointer to a string it does this: ++ * If the member points to a string and is not NULL ++ * 1. Reserve (malloc) memory for the string ++ * 2. Copy the original string to the reserved memory ++ * 3. Change the cnt member (char*) pointing to the string in reserved memory ++ * This ensures that we can free and malloc the string if it is later changed ++ * ++ * Returns nothing. + */ +-void malloc_strings(struct context * cnt) ++void malloc_strings(struct context *cnt) + { +- unsigned short int i = 0; ++ unsigned int i = 0; + char **val; + while (config_params[i].param_name != NULL) { + if (config_params[i].copy == copy_string) { /* if member is a string */ +- /* val is made to point to a pointer to the current string */ ++ /* val is made to point to a pointer to the current string. */ + val = (char **)((char *)cnt+config_params[i].conf_value); + +- /* if there is a string, malloc() space for it, copy ++ /* ++ * If there is a string, malloc() space for it, copy + * the string to new space, and point to the new + * string. we don't free() because we're copying a + * static string. +@@ -1733,7 +2004,6 @@ void malloc_strings(struct context * cnt + * + * copy_bool - convert a bool representation to int + * copy_int - convert a string to int +- * copy_short - convert a string to short + * copy_string - just a string copy + * + * @param str - A char *, pointing to a string representation of the +@@ -1752,10 +2022,14 @@ void malloc_strings(struct context * cnt + * the function will only assign the value for the given thread. + ***********************************************************************/ + +-/* copy_bool assigns a config option to a new boolean value. +- * The boolean is given as a string in str which is converted to 0 or 1 +- * by the function. Values 1, yes and on are converted to 1 ignoring case. +- * Any other value is converted to 0. ++/** ++ * copy_bool ++ * Assigns a config option to a new boolean value. ++ * The boolean is given as a string in str which is converted to 0 or 1 ++ * by the function. Values 1, yes and on are converted to 1 ignoring case. ++ * Any other value is converted to 0. ++ * ++ * Returns context struct. + */ + static struct context **copy_bool(struct context **cnt, const char *str, int val_ptr) + { +@@ -1764,8 +2038,9 @@ static struct context **copy_bool(struct + + i = -1; + while (cnt[++i]) { +- tmp = (char *)cnt[i] + (int)val_ptr; +- if (!strcmp(str, "1") || !strcasecmp(str, "yes") || !strcasecmp(str,"on")) { ++ tmp = (char *)cnt[i]+(int)val_ptr; ++ ++ if (!strcmp(str, "1") || !strcasecmp(str, "yes") || !strcasecmp(str, "on")) { + *((int *)tmp) = 1; + } else { + *((int *)tmp) = 0; +@@ -1774,11 +2049,17 @@ static struct context **copy_bool(struct + if (cnt[0]->threadnr) + return cnt; + } ++ + return cnt; + } + +-/* copy_int assigns a config option to a new integer value. +- * The integer is given as a string in str which is converted to integer by the function. ++/** ++ * copy_int ++ * Assigns a config option to a new integer value. ++ * The integer is given as a string in str which is converted to integer ++ * by the function. ++ * ++ * Returns context struct. + */ + static struct context **copy_int(struct context **cnt, const char *str, int val_ptr) + { +@@ -1787,38 +2068,26 @@ static struct context **copy_int(struct + + i = -1; + while (cnt[++i]) { +- tmp = (char *)cnt[i] + val_ptr; ++ tmp = (char *)cnt[i]+val_ptr; + *((int *)tmp) = atoi(str); +- if (cnt[0]->threadnr) +- return cnt; +- } +- return cnt; +-} +- +-/* copy_short assigns a config option to a new short value. +- * The integer is given as a string in str which is converted to short by the function. +- */ +-static struct context **copy_short(struct context **cnt, const char *str, int val_ptr) +-{ +- void *tmp; +- int i; + +- i = -1; +- while (cnt[++i]) { +- tmp = (char *)cnt[i] + val_ptr; +- *((short int *)tmp) = atoi(str); + if (cnt[0]->threadnr) + return cnt; + } ++ + return cnt; + } + +-/* copy_string assigns a new string value to a config option. +- * Strings are handled differently from bool and int. +- * the char *conf->option that we are working on is free()'d +- * (if memory for it has already been malloc()'d), and set to +- * a freshly malloc()'d string with the value from str, +- * or NULL if str is blank ++/** ++ * copy_string ++ * Assigns a new string value to a config option. ++ * Strings are handled differently from bool and int. ++ * the char *conf->option that we are working on is free()'d ++ * (if memory for it has already been malloc()'d), and set to ++ * a freshly malloc()'d string with the value from str, ++ * or NULL if str is blank. ++ * ++ * Returns context struct. + */ + struct context **copy_string(struct context **cnt, const char *str, int val_ptr) + { +@@ -1826,64 +2095,75 @@ struct context **copy_string(struct cont + int i; + + i = -1; ++ + while (cnt[++i]) { + tmp = (char **)((char *)cnt[i] + val_ptr); + +- /* mystrcpy assigns the new string value ++ /* ++ * mystrcpy assigns the new string value + * including free'ing and reserving new memory for it. + */ + *tmp = mystrcpy(*tmp, str); + +- /* set the option on all threads if setting the option +- * for thread 0; otherwise just set that one thread's option ++ /* ++ * Set the option on all threads if setting the option ++ * for thread 0; otherwise just set that one thread's option. + */ + if (cnt[0]->threadnr) + return cnt; + } ++ + return cnt; + } + + +-/* mystrcpy is used to assign string type fields (e.g. config options) +- * In a way so that we the memory is malloc'ed to fit the string. +- * If a field is already pointing to a string (not NULL) the memory of the +- * old string is free'd and new memory is malloc'ed and filled with the +- * new string is copied into the the memory and with the char pointer +- * pointing to the new string. ++/** ++ * mystrcpy ++ * Is used to assign string type fields (e.g. config options) ++ * In a way so that we the memory is malloc'ed to fit the string. ++ * If a field is already pointing to a string (not NULL) the memory of the ++ * old string is free'd and new memory is malloc'ed and filled with the ++ * new string is copied into the the memory and with the char pointer ++ * pointing to the new string. ++ * ++ * from - pointer to the new string we want to copy ++ * to - the pointer to the current string (or pointing to NULL) ++ * If not NULL the memory it points to is free'd. + * +- * from - pointer to the new string we want to copy +- * to - the pointer to the current string (or pointing to NULL) +- * If not NULL the memory it points to is free'd. +- * function returns pointer to the new string which is in malloc'ed memory ++ * Returns pointer to the new string which is in malloc'ed memory + * FIXME The strings that are malloc'ed with this function should be freed + * when the motion program is terminated normally instead of relying on the + * OS to clean up. + */ + char *mystrcpy(char *to, const char *from) + { +- /* free the memory used by the to string, if such memory exists, ++ /* ++ * Free the memory used by the to string, if such memory exists, + * and return a pointer to a freshly malloc()'d string with the + * same value as from. + */ + +- if (to != NULL) ++ if (to != NULL) + free(to); + + return mystrdup(from); + } + + +-/* mystrdup return a pointer to a freshly malloc()'d string with the same +- * value as the string that the input parameter 'from' points to, +- * or NULL if the from string is 0 characters. +- * The function truncates the string to the length given by the environment +- * variable PATH_MAX to ensure that config options can always contain +- * a really long path but no more than that. ++/** ++ * mystrdup ++ * Truncates the string to the length given by the environment ++ * variable PATH_MAX to ensure that config options can always contain ++ * a really long path but no more than that. ++ * ++ * Returns a pointer to a freshly malloc()'d string with the same ++ * value as the string that the input parameter 'from' points to, ++ * or NULL if the from string is 0 characters. + */ + char *mystrdup(const char *from) + { + char *tmp; +- int stringlength; ++ size_t stringlength; + + if (from == NULL || !strlen(from)) { + tmp = NULL; +@@ -1893,33 +2173,46 @@ char *mystrdup(const char *from) + tmp = (char *)mymalloc(stringlength + 1); + strncpy(tmp, from, stringlength); + +- /* We must ensure the string always has a NULL terminator. ++ /* ++ * We must ensure the string always has a NULL terminator. + * This necessary because strncpy will not append a NULL terminator +- * if the original string is greater than stringlength. ++ * if the original string is greater than string length. + */ + tmp += stringlength; + *tmp = '\0'; + tmp -= stringlength; + } ++ + return tmp; + } + ++/** ++ * config_type ++ * Returns a pointer to string containing value the type of config parameter passed. ++ * ++ * Returns const char *. ++ */ + const char *config_type(config_param *configparam) + { + if (configparam->copy == copy_string) + return "string"; + if (configparam->copy == copy_int) + return "int"; +- if (configparam->copy == copy_short) +- return "short"; + if (configparam->copy == copy_bool) + return "bool"; + + return "unknown"; + } + ++ ++/** ++ * print_bool ++ * Returns a pointer to string containing boolean value 'on' / 'off' or NULL. ++ * ++ * Returns const char *. ++ */ + static const char *print_bool(struct context **cnt, char **str ATTRIBUTE_UNUSED, +- int parm, unsigned short int threadnr) ++ int parm, unsigned int threadnr) + { + int val = config_params[parm].conf_value; + +@@ -1933,22 +2226,27 @@ static const char *print_bool(struct con + return "off"; + } + +-/* print_string returns a pointer to a string containing the value of the config option +- * If the option is not defined NULL is returned. +- * If the thread number is not 0 the string is compared with the value of the same +- * option in thread 0. If the value is the same, NULL is returned which means that +- * the option is not written to the thread config file. ++/** ++ * print_string ++ * Returns a pointer to a string containing the value of the config option, ++ * If the thread number is not 0 the string is compared with the value of the same ++ * option in thread 0. ++ * ++ * Returns If the option is not defined NULL is returned. ++ * If the value is the same, NULL is returned which means that ++ * the option is not written to the thread config file. + */ + static const char *print_string(struct context **cnt, +- char **str ATTRIBUTE_UNUSED, int parm, +- unsigned short int threadnr) ++ char **str ATTRIBUTE_UNUSED, int parm, ++ unsigned int threadnr) + { + int val = config_params[parm].conf_value; + const char **cptr0, **cptr1; +- +- /* strcmp does not like NULL so we have to check for this also */ ++ ++ /* strcmp does not like NULL so we have to check for this also. */ + cptr0 = (const char **)((char *)cnt[0] + val); + cptr1 = (const char **)((char *)cnt[threadnr] + val); ++ + if ((threadnr) && (*cptr0 != NULL) && (*cptr1 != NULL) && (!strcmp(*cptr0, *cptr1))) + return NULL; + +@@ -1956,7 +2254,7 @@ static const char *print_string(struct c + } + + static const char *print_int(struct context **cnt, char **str ATTRIBUTE_UNUSED, +- int parm, unsigned short int threadnr) ++ int parm, unsigned int threadnr) + { + static char retval[20]; + int val = config_params[parm].conf_value; +@@ -1971,106 +2269,107 @@ static const char *print_int(struct cont + } + + +-static const char *print_short(struct context **cnt, char **str ATTRIBUTE_UNUSED, +- int parm, unsigned short int threadnr) +-{ +- static char retval[20]; +- int val = config_params[parm].conf_value; +- +- if (threadnr && +- *(short int*)((char *)cnt[threadnr] + val) == *(short int*)((char *)cnt[0] + val)) +- return NULL; +- +- sprintf(retval, "%d", *(short int*)((char *)cnt[threadnr] + val)); +- +- return retval; +-} +- + static const char *print_thread(struct context **cnt, char **str, +- int parm ATTRIBUTE_UNUSED, unsigned short int threadnr) ++ int parm ATTRIBUTE_UNUSED, unsigned int threadnr) + { + char *retval; +- unsigned short int i = 0; ++ unsigned int i = 0; + + if (!str || threadnr) + return NULL; + + retval = mymalloc(1); + retval[0] = 0; ++ + while (cnt[++i]) { +- retval = myrealloc(retval, strlen(retval) + strlen(cnt[i]->conf_filename) + 10, "print_thread"); ++ retval = myrealloc(retval, strlen(retval) + strlen(cnt[i]->conf_filename) + 10, ++ "print_thread"); + sprintf(retval + strlen(retval), "thread %s\n", cnt[i]->conf_filename); + } ++ + *str = retval; + + return NULL; + } + +-/* config_thread() is called during initial config file loading each time Motion +- * finds a thread option in motion.conf +- * The size of the context array is increased and the main context's values are +- * copied to the new thread. ++/** ++ * config_thread ++ * Is called during initial config file loading each time Motion ++ * finds a thread option in motion.conf ++ * The size of the context array is increased and the main context's values are ++ * copied to the new thread. + * +- * cnt - pointer to the array of pointers pointing to the context structures +- * str - pointer to a string which is the filename of the thread config file +- * val - is not used. It is defined to be function header compatible with +- * copy_int, copy_bool and copy_string. ++ * cnt - pointer to the array of pointers pointing to the context structures ++ * str - pointer to a string which is the filename of the thread config file ++ * val - is not used. It is defined to be function header compatible with ++ * copy_int, copy_bool and copy_string. + */ + static struct context **config_thread(struct context **cnt, const char *str, +- int val ATTRIBUTE_UNUSED) ++ int val ATTRIBUTE_UNUSED) + { + int i; + FILE *fp; +- ++ + if (cnt[0]->threadnr) + return cnt; + + fp = fopen(str, "r"); + + if (!fp) { +- motion_log(LOG_ERR, 1, "Thread config file %s not found",str); ++ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Thread config file %s not found", ++ str); + return cnt; + } + + /* Find the current number of threads defined. */ + i = -1; ++ + while (cnt[++i]); + +- /* Make space for the threads + the terminating NULL pointer ++ /* ++ * Make space for the threads + the terminating NULL pointer + * in the array of pointers to context structures +- * First thread is 0 so the number of threads is i+1 +- * plus an extra for the NULL pointer. This gives i+2 ++ * First thread is 0 so the number of threads is i + 1 ++ * plus an extra for the NULL pointer. This gives i + 2 + */ + cnt = myrealloc(cnt, sizeof(struct context *) * (i + 2), "config_thread"); + + /* Now malloc space for an additional context structure for thread nr. i */ + cnt[i] = mymalloc(sizeof(struct context)); +- ++ + /* And make this an exact clone of the context structure for thread 0 */ + memcpy(cnt[i], cnt[0], sizeof(struct context)); + +- /* All the integers are copies of the actual value. ++ /* ++ * All the integers are copies of the actual value. + * The strings are all pointers to strings so we need to create + * unique malloc'ed space for all the strings that are not NULL and + * change the string pointers to point to the new strings. + * malloc_strings takes care of this. + */ + malloc_strings(cnt[i]); +- +- /* Mark the end if the array of pointers to context structures */ ++ ++ /* Mark the end if the array of pointers to context structures. */ + cnt[i + 1] = NULL; + +- /* process the thread's config file and notify user on console */ ++ /* Process the thread's config file and notify user on console. */ + strcpy(cnt[i]->conf_filename, str); +- motion_log(LOG_INFO, 0, "Processing config file %s", str); +- conf_process(cnt+i, fp); +- +- /* Finally we close the thread config file */ +- fclose(fp); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing config file %s", ++ str); ++ conf_process(cnt + i, fp); ++ ++ /* Finally we close the thread config file. */ ++ myfclose(fp); + + return cnt; + } + ++/** ++ * usage ++ * Prints usage and options allowed from Command-line. ++ * ++ * Returns nothing. ++ */ + static void usage() + { + printf("motion Version "VERSION", Copyright 2000-2005 Jeroen Vreeken/Folkert van Heusden/Kenneth Lavrsen\n"); +@@ -2080,8 +2379,11 @@ static void usage() + printf("-n\t\t\tRun in non-daemon mode.\n"); + 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\tDebug mode.\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 (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"); +--- motion-3.2.12.orig/conf.h ++++ motion-3.2.12/conf.h +@@ -1,24 +1,27 @@ + /* +- ** +- ** conf.h - function prototypes for the config handling routines +- ** +- ** Originally written for the dproxy package by Matthew Pratt. +- ** +- ** Copyright 2000 Jeroen Vreeken (pe1rxq@chello.nl) +- ** +- ** This software is licensed under the terms of the GNU General +- ** Public License (GPL). Please see the file COPYING for details. +- ** +- ** +-*/ ++ * ++ * conf.h - function prototypes for the config handling routines ++ * ++ * Originally written for the dproxy package by Matthew Pratt. ++ * ++ * Copyright 2000 Jeroen Vreeken (pe1rxq@chello.nl) ++ * ++ * This software is licensed under the terms of the GNU General ++ * Public License (GPL). Please see the file COPYING for details. ++ * ++ * ++ */ + + #ifndef _INCLUDE_CONF_H + #define _INCLUDE_CONF_H + + /* +- more parameters may be added later. ++ * More parameters may be added later. + */ + struct config { ++ unsigned int log_level; ++ char *log_type_str; ++ char *log_file; + int setup_mode; + int width; + int height; +@@ -26,18 +29,21 @@ struct config { + int rotate_deg; + int max_changes; + int threshold_tune; +- const char *output_normal; ++ const char *output_pictures; + int motion_img; +- int output_all; +- int gap; +- int maxmpegtime; ++ int emulate_motion; ++ int event_gap; ++ int max_movie_time; + int snapshot_interval; +- const char *locate; ++ const char *locate_motion_mode; ++ const char *locate_motion_style; + int input; + int norm; + int frame_limit; + int quiet; +- int ppm; ++ int useextpipe; /* ext_pipe on or off */ ++ const char *extpipe; /* full Command-line for pipe -- must accept YUV420P images */ ++ const char *picture_type; + int noise; + int noise_tune; + int minimum_frame_time; +@@ -52,22 +58,28 @@ struct config { + int pre_capture; + int post_capture; + int switchfilter; +- int ffmpeg_cap_new; +- int ffmpeg_cap_motion; ++ int ffmpeg_output; ++ int ffmpeg_output_debug; + int ffmpeg_bps; + int ffmpeg_vbr; + int ffmpeg_deinterlace; + const char *ffmpeg_video_codec; +- int webcam_port; +- int webcam_quality; +- int webcam_motion; +- int webcam_maxrate; +- int webcam_localhost; +- int webcam_limit; +- int control_port; +- int control_localhost; +- int control_html_output; +- const char *control_authentication; ++#ifdef HAVE_SDL ++ int sdl_threadnr; ++#endif ++ int ipv6_enabled; ++ int stream_port; ++ int stream_quality; ++ int stream_motion; ++ int stream_maxrate; ++ int stream_localhost; ++ int stream_limit; ++ int stream_auth_method; ++ const char *stream_authentication; ++ int webcontrol_port; ++ int webcontrol_localhost; ++ int webcontrol_html_output; ++ const char *webcontrol_authentication; + unsigned long frequency; + int tuner_number; + int timelapse; +@@ -76,11 +88,11 @@ struct config { + const char *tuner_device; + #endif + const char *video_device; +- short unsigned int v4l2_palette; ++ int v4l2_palette; + const char *vidpipe; + const char *filepath; +- const char *jpegpath; +- const char *mpegpath; ++ const char *imagepath; ++ const char *moviepath; + const char *snappath; + const char *timepath; + char *on_event_start; +@@ -89,13 +101,16 @@ struct config { + int smart_mask_speed; + int sql_log_image; + int sql_log_snapshot; +- int sql_log_mpeg; ++ int sql_log_movie; + int sql_log_timelapse; + const char *sql_query; +- const char *mysql_db; +- const char *mysql_host; +- const char *mysql_user; +- const char *mysql_password; ++ const char *database_type; ++ const char *database_dbname; ++ const char *database_host; ++ const char *database_user; ++ const char *database_password; ++ const char *sqlite3_db; ++ int database_port; + char *on_picture_save; + char *on_area_detected; + char *on_motion_detected; +@@ -105,22 +120,19 @@ struct config { + const char *motionvidpipe; + const char *netcam_url; + const char *netcam_userpass; +- const char *netcam_http; ++ const char *netcam_keepalive; + const char *netcam_proxy; + unsigned int netcam_tolerant_check; +- const char *pgsql_db; +- const char *pgsql_host; +- const char *pgsql_user; +- const char *pgsql_password; +- int pgsql_port; ++ unsigned int rtsp_uses_tcp; + int text_changes; + const char *text_left; + const char *text_right; + const char *text_event; + int text_double; +- const char *despeckle; ++ const char *despeckle_filter; + const char *area_detect; + int minimum_motion_frames; ++ const char *exif_text; + char *pid_file; + int argc; + char **argv; +@@ -130,28 +142,27 @@ struct config { + * typedef for a param copy function. + */ + typedef struct context ** (* conf_copy_func)(struct context **, const char *, int); +-typedef const char *(* conf_print_func)(struct context **, char **, int, unsigned short int); ++typedef const char *(* conf_print_func)(struct context **, char **, int, unsigned int); + + /** + * description for parameters in the config file + */ + typedef struct { +- const char * param_name; /* name for this parameter */ +- const char * param_help; /* short explanation for parameter */ +- unsigned short int main_thread; /* belong only to main thread when value>0 */ +- int conf_value; /* pointer to a field in struct context */ +- conf_copy_func copy; /* a function to set the value in 'config' */ +- conf_print_func print; /* a function to output the value to a file */ ++ const char *param_name; /* name for this parameter */ ++ const char *param_help; /* short explanation for parameter */ ++ unsigned int main_thread; /* belong only to main thread when value>0 */ ++ int conf_value; /* pointer to a field in struct context */ ++ conf_copy_func copy; /* a function to set the value in 'config' */ ++ conf_print_func print; /* a function to output the value to a file */ + } config_param; + +- + extern config_param config_params[]; + + struct context **conf_load(struct context **); + struct context **conf_cmdparse(struct context **, const char *, const char *); + const char *config_type(config_param *); + void conf_print(struct context **); +-void malloc_strings (struct context *); ++void malloc_strings(struct context *); + char *mystrdup(const char *); + char *mystrcpy(char *, const char *); + struct context **copy_string(struct context **, const char *, int); +@@ -160,5 +171,4 @@ struct context **copy_string(struct cont + char *get_current_dir_name(void); + #endif + +- + #endif /* _INCLUDE_CONF_H */ +--- /dev/null ++++ motion-3.2.12/config.h +@@ -0,0 +1,145 @@ ++/* config.h. Generated from config.h.in by configure. */ ++/* config.h.in. Generated from configure.ac by autoheader. */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_FCNTL_H 1 ++ ++/* Define to 1 if you have the `get_current_dir_name' function. */ ++#define HAVE_GET_CURRENT_DIR_NAME 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_INTTYPES_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_LINUX_VIDEODEV2_H 1 ++ ++/* Define to 1 if you have the header file. */ ++/* #undef HAVE_LINUX_VIDEODEV_H */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_MEMORY_H 1 ++ ++/* Define to 1 if you have MySQL support */ ++/* #undef HAVE_MYSQL */ ++ ++/* Define to 1 if you have PostgreSQL support */ ++/* #undef HAVE_PGSQL */ ++ ++/* Define to 1 if you have SDL support */ ++/* #undef HAVE_SDL */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SIGNAL_H 1 ++ ++/* Define to 1 if you have SQLITE3 support */ ++/* #undef HAVE_SQLITE3 */ ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STDINT_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STDIO_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STDLIB_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STRINGS_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_STRING_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_IOCTL_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_MMAN_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_PARAM_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_STAT_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_SYS_TYPES_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_TIME_H 1 ++ ++/* Define to 1 if you have the header file. */ ++#define HAVE_UNISTD_H 1 ++ ++/* Define to the address where bug reports for this package should be sent. */ ++#define PACKAGE_BUGREPORT "" ++ ++/* Define to the full name of this package. */ ++#define PACKAGE_NAME "motion" ++ ++/* Define to the full name and version of this package. */ ++#define PACKAGE_STRING "motion 3.2.12-4ppa01" ++ ++/* Define to the one symbol short name of this package. */ ++#define PACKAGE_TARNAME "motion" ++ ++/* Define to the home page for this package. */ ++#define PACKAGE_URL "" ++ ++/* Define to the version of this package. */ ++#define PACKAGE_VERSION "3.2.12-4ppa01" ++ ++/* The size of `int', as computed by sizeof. */ ++#define SIZEOF_INT 4 ++ ++/* The size of `int *', as computed by sizeof. */ ++#define SIZEOF_INT_P 8 ++ ++/* The size of `long int', as computed by sizeof. */ ++#define SIZEOF_LONG_INT 8 ++ ++/* The size of `long long', as computed by sizeof. */ ++#define SIZEOF_LONG_LONG 8 ++ ++/* The size of `short', as computed by sizeof. */ ++#define SIZEOF_SHORT 2 ++ ++/* The size of `void *', as computed by sizeof. */ ++#define SIZEOF_VOID_P 8 ++ ++/* Define to 1 if you have the ANSI C header files. */ ++#define STDC_HEADERS 1 ++ ++/* Enable extensions on AIX 3, Interix. */ ++#ifndef _ALL_SOURCE ++# define _ALL_SOURCE 1 ++#endif ++/* Enable GNU extensions on systems that have them. */ ++#ifndef _GNU_SOURCE ++# define _GNU_SOURCE 1 ++#endif ++/* Enable threading extensions on Solaris. */ ++#ifndef _POSIX_PTHREAD_SEMANTICS ++# define _POSIX_PTHREAD_SEMANTICS 1 ++#endif ++/* Enable extensions on HP NonStop. */ ++#ifndef _TANDEM_SOURCE ++# define _TANDEM_SOURCE 1 ++#endif ++/* Enable general extensions on Solaris. */ ++#ifndef __EXTENSIONS__ ++# define __EXTENSIONS__ 1 ++#endif ++ ++ ++/* Define to 1 if on MINIX. */ ++/* #undef _MINIX */ ++ ++/* Define to 2 if the system does not provide POSIX.1 features except with ++ this defined. */ ++/* #undef _POSIX_1_SOURCE */ ++ ++/* Define to 1 if you need to in order for `stat' and other things to work. */ ++/* #undef _POSIX_SOURCE */ ++ ++/* Define to empty if `const' does not conform to ANSI C. */ ++/* #undef const */ +--- motion-3.2.12.orig/config.h.in ++++ motion-3.2.12/config.h.in +@@ -1,4 +1,4 @@ +-/* config.h.in. Generated from configure.in by autoheader. */ ++/* config.h.in. Generated from configure.ac by autoheader. */ + + /* Define to 1 if you have the header file. */ + #undef HAVE_FCNTL_H +@@ -24,9 +24,15 @@ + /* Define to 1 if you have PostgreSQL support */ + #undef HAVE_PGSQL + ++/* Define to 1 if you have SDL support */ ++#undef HAVE_SDL ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_SIGNAL_H + ++/* Define to 1 if you have SQLITE3 support */ ++#undef HAVE_SQLITE3 ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_STDINT_H + +@@ -75,20 +81,64 @@ + /* Define to the one symbol short name of this package. */ + #undef PACKAGE_TARNAME + ++/* Define to the home page for this package. */ ++#undef PACKAGE_URL ++ + /* Define to the version of this package. */ + #undef PACKAGE_VERSION + + /* The size of `int', as computed by sizeof. */ + #undef SIZEOF_INT + ++/* The size of `int *', as computed by sizeof. */ ++#undef SIZEOF_INT_P ++ + /* The size of `long int', as computed by sizeof. */ + #undef SIZEOF_LONG_INT + +-/* The size of `short int', as computed by sizeof. */ +-#undef SIZEOF_SHORT_INT ++/* The size of `long long', as computed by sizeof. */ ++#undef SIZEOF_LONG_LONG ++ ++/* The size of `short', as computed by sizeof. */ ++#undef SIZEOF_SHORT ++ ++/* The size of `void *', as computed by sizeof. */ ++#undef SIZEOF_VOID_P + + /* Define to 1 if you have the ANSI C header files. */ + #undef STDC_HEADERS + ++/* Enable extensions on AIX 3, Interix. */ ++#ifndef _ALL_SOURCE ++# undef _ALL_SOURCE ++#endif ++/* Enable GNU extensions on systems that have them. */ ++#ifndef _GNU_SOURCE ++# undef _GNU_SOURCE ++#endif ++/* Enable threading extensions on Solaris. */ ++#ifndef _POSIX_PTHREAD_SEMANTICS ++# undef _POSIX_PTHREAD_SEMANTICS ++#endif ++/* Enable extensions on HP NonStop. */ ++#ifndef _TANDEM_SOURCE ++# undef _TANDEM_SOURCE ++#endif ++/* Enable general extensions on Solaris. */ ++#ifndef __EXTENSIONS__ ++# undef __EXTENSIONS__ ++#endif ++ ++ ++/* Define to 1 if on MINIX. */ ++#undef _MINIX ++ ++/* Define to 2 if the system does not provide POSIX.1 features except with ++ this defined. */ ++#undef _POSIX_1_SOURCE ++ ++/* Define to 1 if you need to in order for `stat' and other things to work. */ ++#undef _POSIX_SOURCE ++ + /* Define to empty if `const' does not conform to ANSI C. */ + #undef const +--- motion-3.2.12.orig/configure ++++ motion-3.2.12/configure +@@ -1,11 +1,9 @@ + #! /bin/sh + # Guess values for system-dependent variables and create Makefiles. +-# Generated by GNU Autoconf 2.65 for motion 3.2.12. ++# Generated by GNU Autoconf 2.69 for motion 3.2.12-4ppa01. + # + # +-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +-# Inc. ++# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. + # + # + # This configure script is free software; the Free Software Foundation +@@ -89,6 +87,7 @@ fi + IFS=" "" $as_nl" + + # Find who we are. Look in the path if we contain no directory separator. ++as_myself= + case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +@@ -133,6 +132,31 @@ export LANGUAGE + # CDPATH. + (unset CDPATH) >/dev/null 2>&1 && unset CDPATH + ++# Use a proper internal environment variable to ensure we don't fall ++ # into an infinite loop, continuously re-executing ourselves. ++ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then ++ _as_can_reexec=no; export _as_can_reexec; ++ # We cannot yet assume a decent shell, so we have to provide a ++# neutralization value for shells without unset; and this also ++# works around shells that cannot unset nonexistent variables. ++# Preserve -v and -x to the replacement shell. ++BASH_ENV=/dev/null ++ENV=/dev/null ++(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV ++case $- in # (((( ++ *v*x* | *x*v* ) as_opts=-vx ;; ++ *v* ) as_opts=-v ;; ++ *x* ) as_opts=-x ;; ++ * ) as_opts= ;; ++esac ++exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} ++# Admittedly, this is quite paranoid, since all the known shells bail ++# out after a failed `exec'. ++$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 ++as_fn_exit 255 ++ fi ++ # We don't want this to propagate to other subprocesses. ++ { _as_can_reexec=; unset _as_can_reexec;} + if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh +@@ -166,7 +190,8 @@ if ( set x; as_fn_ret_success y && test + else + exitcode=1; echo positional parameters were not saved. + fi +-test x\$exitcode = x0 || exit 1" ++test x\$exitcode = x0 || exit 1 ++test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && +@@ -211,14 +236,25 @@ IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : +- # We cannot yet assume a decent shell, so we have to provide a +- # neutralization value for shells without unset; and this also +- # works around shells that cannot unset nonexistent variables. +- BASH_ENV=/dev/null +- ENV=/dev/null +- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +- export CONFIG_SHELL +- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} ++ export CONFIG_SHELL ++ # We cannot yet assume a decent shell, so we have to provide a ++# neutralization value for shells without unset; and this also ++# works around shells that cannot unset nonexistent variables. ++# Preserve -v and -x to the replacement shell. ++BASH_ENV=/dev/null ++ENV=/dev/null ++(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV ++case $- in # (((( ++ *v*x* | *x*v* ) as_opts=-vx ;; ++ *v* ) as_opts=-v ;; ++ *x* ) as_opts=-x ;; ++ * ) as_opts= ;; ++esac ++exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} ++# Admittedly, this is quite paranoid, since all the known shells bail ++# out after a failed `exec'. ++$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 ++exit 255 + fi + + if test x$as_have_required = xno; then : +@@ -316,10 +352,18 @@ $as_echo X"$as_dir" | + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" +- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" ++ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + + } # as_fn_mkdir_p ++ ++# as_fn_executable_p FILE ++# ----------------------- ++# Test if FILE is an executable regular file. ++as_fn_executable_p () ++{ ++ test -f "$1" && test -x "$1" ++} # as_fn_executable_p + # as_fn_append VAR VALUE + # ---------------------- + # Append the text in VALUE to the end of the definition contained in VAR. Take +@@ -356,19 +400,19 @@ else + fi # as_fn_arith + + +-# as_fn_error ERROR [LINENO LOG_FD] +-# --------------------------------- ++# as_fn_error STATUS ERROR [LINENO LOG_FD] ++# ---------------------------------------- + # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are + # provided, also output the error to LOG_FD, referencing LINENO. Then exit the +-# script with status $?, using 1 if that was 0. ++# script with STATUS, using 1 if that was 0. + as_fn_error () + { +- as_status=$?; test $as_status -eq 0 && as_status=1 +- if test "$3"; then +- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 ++ as_status=$1; test $as_status -eq 0 && as_status=1 ++ if test "$4"; then ++ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi +- $as_echo "$as_me: error: $1" >&2 ++ $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status + } # as_fn_error + +@@ -441,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + ++ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have ++ # already done that, so ensure we don't try to do so again and fall ++ # in an infinite loop. This has already happened in practice. ++ _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). +@@ -475,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. +- # In both cases, we have to default to `cp -p'. ++ # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || +- as_ln_s='cp -p' ++ as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else +- as_ln_s='cp -p' ++ as_ln_s='cp -pR' + fi + else +- as_ln_s='cp -p' ++ as_ln_s='cp -pR' + fi + rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file + rmdir conf$$.dir 2>/dev/null +@@ -496,28 +544,8 @@ else + as_mkdir_p=false + fi + +-if test -x / >/dev/null 2>&1; then +- as_test_x='test -x' +-else +- if ls -dL / >/dev/null 2>&1; then +- as_ls_L_option=L +- else +- as_ls_L_option= +- fi +- as_test_x=' +- eval sh -c '\'' +- if test -d "$1"; then +- test -d "$1/."; +- else +- case $1 in #( +- -*)set "./$1";; +- esac; +- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( +- ???[sx]*):;;*)false;;esac;fi +- '\'' sh +- ' +-fi +-as_executable_p=$as_test_x ++as_test_x='test -x' ++as_executable_p=as_fn_executable_p + + # Sed expression to map a string onto a valid CPP name. + as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" +@@ -530,7 +558,7 @@ test -n "$DJDIR" || exec 7<&0 &1 + + # Name of the host. +-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, ++# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, + # so uname gets run too. + ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +@@ -549,12 +577,11 @@ MAKEFLAGS= + # Identity of this package. + PACKAGE_NAME='motion' + PACKAGE_TARNAME='motion' +-PACKAGE_VERSION='3.2.12' +-PACKAGE_STRING='motion 3.2.12' ++PACKAGE_VERSION='3.2.12-4ppa01' ++PACKAGE_STRING='motion 3.2.12-4ppa01' + PACKAGE_BUGREPORT='' + PACKAGE_URL='' + +-ac_unique_file="motion.c" + # Factoring default headers for most tests. + ac_includes_default="\ + #include +@@ -591,14 +618,17 @@ ac_includes_default="\ + # include + #endif" + ++ac_unique_file="motion.c" + ac_subst_vars='LTLIBOBJS + LIBOBJS + BIN_PATH +-DOC_DIR ++RTPS_OBJ ++FFMPEG_OBJ ++SDL_OBJ ++VIDEO + EGREP + GREP + CPP +-FFMPEG_OBJ + OBJEXT + EXEEXT + ac_ct_CC +@@ -606,7 +636,6 @@ CPPFLAGS + LDFLAGS + CFLAGS + CC +-VIDEO + target_alias + host_alias + build_alias +@@ -652,8 +681,13 @@ with_linuxthreads + with_pwcbsd + with_bktr + with_v4l ++with_sdl ++with_jpeg_turbo + with_jpeg_mmx + with_ffmpeg ++with_ffmpeg_headers ++with_ffmpeg_libs ++with_sqlite3 + with_mysql + with_mysql_lib + with_mysql_include +@@ -734,8 +768,9 @@ do + fi + + case $ac_option in +- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; +- *) ac_optarg=yes ;; ++ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; ++ *=) ac_optarg= ;; ++ *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. +@@ -780,7 +815,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error "invalid feature name: $ac_useropt" ++ as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -806,7 +841,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error "invalid feature name: $ac_useropt" ++ as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1010,7 +1045,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error "invalid package name: $ac_useropt" ++ as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1026,7 +1061,7 @@ do + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && +- as_fn_error "invalid package name: $ac_useropt" ++ as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in +@@ -1056,8 +1091,8 @@ do + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + +- -*) as_fn_error "unrecognized option: \`$ac_option' +-Try \`$0 --help' for more information." ++ -*) as_fn_error $? "unrecognized option: \`$ac_option' ++Try \`$0 --help' for more information" + ;; + + *=*) +@@ -1065,7 +1100,7 @@ Try \`$0 --help' for more information." + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) +- as_fn_error "invalid variable name: \`$ac_envvar'" ;; ++ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; +@@ -1075,7 +1110,7 @@ Try \`$0 --help' for more information." + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 +- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ++ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +@@ -1083,13 +1118,13 @@ done + + if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` +- as_fn_error "missing argument to $ac_option" ++ as_fn_error $? "missing argument to $ac_option" + fi + + if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; +- fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; ++ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac + fi +@@ -1112,7 +1147,7 @@ do + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac +- as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" ++ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" + done + + # There might be people who depend on the old broken behavior: `$host' +@@ -1126,8 +1161,6 @@ target=$target_alias + if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe +- $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. +- If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +@@ -1142,9 +1175,9 @@ test "$silent" = yes && exec 6>/dev/null + ac_pwd=`pwd` && test -n "$ac_pwd" && + ac_ls_di=`ls -di .` && + ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || +- as_fn_error "working directory cannot be determined" ++ as_fn_error $? "working directory cannot be determined" + test "X$ac_ls_di" = "X$ac_pwd_ls_di" || +- as_fn_error "pwd does not report name of working directory" ++ as_fn_error $? "pwd does not report name of working directory" + + + # Find the source files, if location was not specified. +@@ -1183,11 +1216,11 @@ else + fi + if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." +- as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" ++ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" + fi + ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" + ac_abs_confdir=`( +- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" ++ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` + # When building in place, set srcdir=. + if test "$ac_abs_confdir" = "$ac_pwd"; then +@@ -1213,7 +1246,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 3.2.12 to adapt to many kinds of systems. ++\`configure' configures motion 3.2.12-4ppa01 to adapt to many kinds of systems. + + Usage: $0 [OPTION]... [VAR=VALUE]... + +@@ -1227,7 +1260,7 @@ Configuration: + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit +- -q, --quiet, --silent do not print \`checking...' messages ++ -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files +@@ -1274,7 +1307,7 @@ fi + + if test -n "$ac_init_help"; then + case $ac_init_help in +- short | recursive ) echo "Configuration of motion 3.2.12:";; ++ short | recursive ) echo "Configuration of motion 3.2.12-4ppa01:";; + esac + cat <<\_ACEOF + +@@ -1294,6 +1327,11 @@ Optional Packages: + --without-v4l Exclude using v4l (video4linux) subsystem. + Makes Motion so it only supports network cameras. + ++ --without-sdl Compile without sdl support to get stream in SDL window. ++ ++ --with-jpeg-turbo=DIR Specify the prefix for the install path for ++ jpeg-turbo for optimized jpeg handling (optional). ++ + --with-jpeg-mmx=DIR Specify the prefix for the install path for + jpeg-mmx for optimized jpeg handling (optional). + If this is not specified motion will try to find +@@ -1305,6 +1343,12 @@ Optional Packages: + If this is not specified motion will try to find + the libraries in /usr and /usr/local. + ++ --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. ++ ++ --with-ffmpeg-libs=libs Specify the extra libs for ffmpeg ++ ++ --without-sqlite3 Disable sqlite3 support in motion. ++ + --without-mysql Disable mysql support in motion. + + --with-mysql-lib=DIR Normally, configure will scan all possible default +@@ -1413,10 +1457,10 @@ fi + test -n "$ac_init_help" && exit $ac_status + if $ac_init_version; then + cat <<\_ACEOF +-motion configure 3.2.12 +-generated by GNU Autoconf 2.65 ++motion configure 3.2.12-4ppa01 ++generated by GNU Autoconf 2.69 + +-Copyright (C) 2009 Free Software Foundation, Inc. ++Copyright (C) 2012 Free Software Foundation, Inc. + This configure script is free software; the Free Software Foundation + gives unlimited permission to copy, distribute and modify it. + _ACEOF +@@ -1460,57 +1504,11 @@ sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 + fi +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + + } # ac_fn_c_try_compile + +-# ac_fn_c_try_link LINENO +-# ----------------------- +-# Try to link conftest.$ac_ext, and return whether this succeeded. +-ac_fn_c_try_link () +-{ +- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- rm -f conftest.$ac_objext conftest$ac_exeext +- if { { ac_try="$ac_link" +-case "(($ac_try" in +- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; +- *) ac_try_echo=$ac_try;; +-esac +-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +-$as_echo "$ac_try_echo"; } >&5 +- (eval "$ac_link") 2>conftest.err +- ac_status=$? +- if test -s conftest.err; then +- grep -v '^ *+' conftest.err >conftest.er1 +- cat conftest.er1 >&5 +- mv -f conftest.er1 conftest.err +- fi +- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 +- test $ac_status = 0; } && { +- test -z "$ac_c_werror_flag" || +- test ! -s conftest.err +- } && test -s conftest$ac_exeext && { +- test "$cross_compiling" = yes || +- $as_test_x conftest$ac_exeext +- }; then : +- ac_retval=0 +-else +- $as_echo "$as_me: failed program was:" >&5 +-sed 's/^/| /' conftest.$ac_ext >&5 +- +- ac_retval=1 +-fi +- # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information +- # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would +- # interfere with the next link command; also delete a directory that is +- # left behind by Apple's compiler. We do this before executing the actions. +- rm -rf conftest.dSYM conftest_ipa8_conftest.oo +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} +- as_fn_set_status $ac_retval +- +-} # ac_fn_c_try_link +- + # ac_fn_c_try_cpp LINENO + # ---------------------- + # Try to preprocess conftest.$ac_ext, and return whether this succeeded. +@@ -1532,7 +1530,7 @@ $as_echo "$ac_try_echo"; } >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 +- test $ac_status = 0; } >/dev/null && { ++ test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : +@@ -1543,53 +1541,11 @@ sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 + fi +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + + } # ac_fn_c_try_cpp + +-# ac_fn_c_try_run LINENO +-# ---------------------- +-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +-# that executables *can* be run. +-ac_fn_c_try_run () +-{ +- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- if { { ac_try="$ac_link" +-case "(($ac_try" in +- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; +- *) ac_try_echo=$ac_try;; +-esac +-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +-$as_echo "$ac_try_echo"; } >&5 +- (eval "$ac_link") 2>&5 +- ac_status=$? +- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 +- test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' +- { { case "(($ac_try" in +- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; +- *) ac_try_echo=$ac_try;; +-esac +-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +-$as_echo "$ac_try_echo"; } >&5 +- (eval "$ac_try") 2>&5 +- ac_status=$? +- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 +- test $ac_status = 0; }; }; then : +- ac_retval=0 +-else +- $as_echo "$as_me: program exited with status $ac_status" >&5 +- $as_echo "$as_me: failed program was:" >&5 +-sed 's/^/| /' conftest.$ac_ext >&5 +- +- ac_retval=$ac_status +-fi +- rm -rf conftest.dSYM conftest_ipa8_conftest.oo +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} +- as_fn_set_status $ac_retval +- +-} # ac_fn_c_try_run +- + # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES + # ------------------------------------------------------- + # Tests whether HEADER exists, giving a warning if it cannot be compiled using +@@ -1598,10 +1554,10 @@ fi + ac_fn_c_check_header_mongrel () + { + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 + $as_echo_n "checking for $2... " >&6; } +-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 + fi + eval ac_res=\$$3 +@@ -1637,7 +1593,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : + else + ac_header_preproc=no + fi +-rm -f conftest.err conftest.$ac_ext ++rm -f conftest.err conftest.i conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 + $as_echo "$ac_header_preproc" >&6; } + +@@ -1664,7 +1620,7 @@ $as_echo "$as_me: WARNING: $2: proceedin + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 + $as_echo_n "checking for $2... " >&6; } +-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 + else + eval "$3=\$ac_header_compiler" +@@ -1673,10 +1629,52 @@ eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 + $as_echo "$ac_res" >&6; } + fi +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + + } # ac_fn_c_check_header_mongrel + ++# ac_fn_c_try_run LINENO ++# ---------------------- ++# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes ++# that executables *can* be run. ++ac_fn_c_try_run () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ if { { ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_link") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' ++ { { case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_try") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; }; then : ++ ac_retval=0 ++else ++ $as_echo "$as_me: program exited with status $ac_status" >&5 ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_retval=$ac_status ++fi ++ rm -rf conftest.dSYM conftest_ipa8_conftest.oo ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno ++ as_fn_set_status $ac_retval ++ ++} # ac_fn_c_try_run ++ + # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES + # ------------------------------------------------------- + # Tests whether HEADER exists and can be compiled using the include files in +@@ -1686,7 +1684,7 @@ ac_fn_c_check_header_compile () + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 + $as_echo_n "checking for $2... " >&6; } +-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -1704,10 +1702,56 @@ fi + eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 + $as_echo "$ac_res" >&6; } +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + + } # ac_fn_c_check_header_compile + ++# ac_fn_c_try_link LINENO ++# ----------------------- ++# Try to link conftest.$ac_ext, and return whether this succeeded. ++ac_fn_c_try_link () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ rm -f conftest.$ac_objext conftest$ac_exeext ++ if { { ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_link") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ grep -v '^ *+' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ mv -f conftest.er1 conftest.err ++ fi ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest$ac_exeext && { ++ test "$cross_compiling" = yes || ++ test -x conftest$ac_exeext ++ }; then : ++ ac_retval=0 ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_retval=1 ++fi ++ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information ++ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would ++ # interfere with the next link command; also delete a directory that is ++ # left behind by Apple's compiler. We do this before executing the actions. ++ rm -rf conftest.dSYM conftest_ipa8_conftest.oo ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno ++ as_fn_set_status $ac_retval ++ ++} # ac_fn_c_try_link ++ + # ac_fn_c_check_func LINENO FUNC VAR + # ---------------------------------- + # Tests whether FUNC exists, setting the cache variable VAR accordingly +@@ -1716,7 +1760,7 @@ ac_fn_c_check_func () + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 + $as_echo_n "checking for $2... " >&6; } +-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -1771,7 +1815,7 @@ fi + eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 + $as_echo "$ac_res" >&6; } +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + + } # ac_fn_c_check_func + +@@ -1784,7 +1828,7 @@ ac_fn_c_check_type () + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 + $as_echo_n "checking for $2... " >&6; } +-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 + else + eval "$3=no" +@@ -1825,7 +1869,7 @@ fi + eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 + $as_echo "$ac_res" >&6; } +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + + } # ac_fn_c_check_type + +@@ -1846,7 +1890,8 @@ int + main () + { + static int test_array [1 - 2 * !(($2) >= 0)]; +-test_array [0] = 0 ++test_array [0] = 0; ++return test_array [0]; + + ; + return 0; +@@ -1862,7 +1907,8 @@ int + main () + { + static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +-test_array [0] = 0 ++test_array [0] = 0; ++return test_array [0]; + + ; + return 0; +@@ -1888,7 +1934,8 @@ int + main () + { + static int test_array [1 - 2 * !(($2) < 0)]; +-test_array [0] = 0 ++test_array [0] = 0; ++return test_array [0]; + + ; + return 0; +@@ -1904,7 +1951,8 @@ int + main () + { + static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +-test_array [0] = 0 ++test_array [0] = 0; ++return test_array [0]; + + ; + return 0; +@@ -1938,7 +1986,8 @@ int + main () + { + static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +-test_array [0] = 0 ++test_array [0] = 0; ++return test_array [0]; + + ; + return 0; +@@ -2002,7 +2051,7 @@ rm -f core *.core core.conftest.* gmon.o + rm -f conftest.val + + fi +- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + + } # ac_fn_c_compute_int +@@ -2010,8 +2059,8 @@ 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 3.2.12, which was +-generated by GNU Autoconf 2.65. Invocation command line was ++It was created by motion $as_me 3.2.12-4ppa01, which was ++generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +@@ -2121,11 +2170,9 @@ trap 'exit_status=$? + { + echo + +- cat <<\_ASBOX +-## ---------------- ## ++ $as_echo "## ---------------- ## + ## Cache variables. ## +-## ---------------- ## +-_ASBOX ++## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, + ( +@@ -2159,11 +2206,9 @@ $as_echo "$as_me: WARNING: cache variabl + ) + echo + +- cat <<\_ASBOX +-## ----------------- ## ++ $as_echo "## ----------------- ## + ## Output variables. ## +-## ----------------- ## +-_ASBOX ++## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do +@@ -2176,11 +2221,9 @@ _ASBOX + echo + + if test -n "$ac_subst_files"; then +- cat <<\_ASBOX +-## ------------------- ## ++ $as_echo "## ------------------- ## + ## File substitutions. ## +-## ------------------- ## +-_ASBOX ++## ------------------- ##" + echo + for ac_var in $ac_subst_files + do +@@ -2194,11 +2237,9 @@ _ASBOX + fi + + if test -s confdefs.h; then +- cat <<\_ASBOX +-## ----------- ## ++ $as_echo "## ----------- ## + ## confdefs.h. ## +-## ----------- ## +-_ASBOX ++## ----------- ##" + echo + cat confdefs.h + echo +@@ -2253,7 +2294,12 @@ _ACEOF + ac_site_file1=NONE + ac_site_file2=NONE + if test -n "$CONFIG_SITE"; then +- ac_site_file1=$CONFIG_SITE ++ # We do not want a PATH search for config.site. ++ case $CONFIG_SITE in #(( ++ -*) ac_site_file1=./$CONFIG_SITE;; ++ */*) ac_site_file1=$CONFIG_SITE;; ++ *) ac_site_file1=./$CONFIG_SITE;; ++ esac + elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +@@ -2268,7 +2314,11 @@ do + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 + $as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 +- . "$ac_site_file" ++ . "$ac_site_file" \ ++ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error $? "failed to load site script $ac_site_file ++See \`config.log' for more details" "$LINENO" 5; } + fi + done + +@@ -2344,7 +2394,7 @@ if $ac_cache_corrupted; then + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 + $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} +- as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 ++ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + fi + ## -------------------- ## + ## Main body of script. ## +@@ -2357,134 +2407,47 @@ ac_link='$CC -o conftest$ac_exeext $CFLA + ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +- +-ac_config_headers="$ac_config_headers config.h" +- +- +-THREAD_CFLAGS="" +-THREAD_CHECK="/usr/include/pthread.h" +- +-Darwin="" +-FreeBSD="" +- +-LINUXTHREADS="no" +- +-# Check whether --with-linuxthreads was given. +-if test "${with_linuxthreads+set}" = set; then : +- withval=$with_linuxthreads; LINUXTHREADS="$withval" ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="${ac_tool_prefix}gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS + + fi +- +- +-PWCBSD="no" +- +-# Check whether --with-pwcbsd was given. +-if test "${with_pwcbsd+set}" = set; then : +- withval=$with_pwcbsd; PWCBSD="$withval" +- +-fi +- +- +- +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 +-$as_echo_n "checking for Darwin... " >&6; } +-Darwin=`uname -a | grep "Darwin"` +- +-if test "${Darwin}" = ""; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 +-$as_echo_n "checking for *BSD... " >&6; } +- +- FreeBSD=`uname -a | grep "BSD"` +- if test "${FreeBSD}" = ""; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +- VIDEO="video.o video2.o video_common.o" +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; } +- if test "${LINUXTHREADS}" = "no"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linuxthreads" >&5 +-$as_echo_n "checking Linuxthreads... " >&6; } +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +-$as_echo "skipping" >&6; } +- else +- THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" +- THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" +- fi +- +- if test "${PWCBSD}" != "no"; then +- VIDEO="video.o video2.o video_common.o" +- TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" +- else +- VIDEO="video_freebsd.o" +- TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" +- fi +- +- TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" +- TEMP_LIBS="-L/usr/local/lib" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: Build with PWCBSD support $PWCBSD" >&5 +-$as_echo "Build with PWCBSD support $PWCBSD" >&6; } +- +- fi +-else +- TEMP_CFLAGS="${CFLAGS} -I/sw/include" +- TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" +- TEMP_LIBS="-L/sw/lib" +- VIDEO="video_freebsd.o" +- FINK_LIB="-L/sw/lib" +- Darwin="yes" +- V4L="no" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Darwin" >&5 +-$as_echo "$Darwin" >&6; } +-fi +- +- +- +- +-# Checks for programs. +-ac_ext=c +-ac_cpp='$CPP $CPPFLAGS' +-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +-ac_compiler_gnu=$ac_cv_c_compiler_gnu +-if test -n "$ac_tool_prefix"; then +- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +-set dummy ${ac_tool_prefix}gcc; ac_word=$2 +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +-$as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_prog_CC+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- if test -n "$CC"; then +- ac_cv_prog_CC="$CC" # Let the user override the test. +-else +-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then +- ac_cv_prog_CC="${ac_tool_prefix}gcc" +- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 +- break 2 +- fi +-done +- done +-IFS=$as_save_IFS +- +-fi +-fi +-CC=$ac_cv_prog_CC +-if test -n "$CC"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +-$as_echo "$CC" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi + + + fi +@@ -2494,7 +2457,7 @@ if test -z "$ac_cv_prog_CC"; then + set dummy gcc; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : ++if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 + else + if test -n "$ac_ct_CC"; then +@@ -2506,7 +2469,7 @@ do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 +@@ -2547,7 +2510,7 @@ if test -z "$CC"; then + set dummy ${ac_tool_prefix}cc; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_prog_CC+set}" = set; then : ++if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 + else + if test -n "$CC"; then +@@ -2559,7 +2522,7 @@ do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 +@@ -2587,7 +2550,7 @@ if test -z "$CC"; then + set dummy cc; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_prog_CC+set}" = set; then : ++if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 + else + if test -n "$CC"; then +@@ -2600,7 +2563,7 @@ do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue +@@ -2646,7 +2609,7 @@ if test -z "$CC"; then + set dummy $ac_tool_prefix$ac_prog; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_prog_CC+set}" = set; then : ++if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 + else + if test -n "$CC"; then +@@ -2658,7 +2621,7 @@ do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 +@@ -2690,7 +2653,7 @@ do + set dummy $ac_prog; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : ++if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 + else + if test -n "$ac_ct_CC"; then +@@ -2702,7 +2665,7 @@ do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do +- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 +@@ -2744,8 +2707,8 @@ fi + + test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error "no acceptable C compiler found in \$PATH +-See \`config.log' for more details." "$LINENO" 5; } ++as_fn_error $? "no acceptable C compiler found in \$PATH ++See \`config.log' for more details" "$LINENO" 5; } + + # Provide some information about the compiler. + $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +@@ -2859,9 +2822,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 + + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "C compiler cannot create executables +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "C compiler cannot create executables ++See \`config.log' for more details" "$LINENO" 5; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + $as_echo "yes" >&6; } +@@ -2903,8 +2865,8 @@ done + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error "cannot compute suffix of executables: cannot compile and link +-See \`config.log' for more details." "$LINENO" 5; } ++as_fn_error $? "cannot compute suffix of executables: cannot compile and link ++See \`config.log' for more details" "$LINENO" 5; } + fi + rm -f conftest conftest$ac_cv_exeext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +@@ -2961,9 +2923,9 @@ $as_echo "$ac_try_echo"; } >&5 + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error "cannot run C compiled programs. ++as_fn_error $? "cannot run C compiled programs. + If you meant to cross compile, use \`--host'. +-See \`config.log' for more details." "$LINENO" 5; } ++See \`config.log' for more details" "$LINENO" 5; } + fi + fi + fi +@@ -2974,7 +2936,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_ex + ac_clean_files=$ac_clean_files_save + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 + $as_echo_n "checking for suffix of object files... " >&6; } +-if test "${ac_cv_objext+set}" = set; then : ++if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -3014,8 +2976,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 + + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error "cannot compute suffix of object files: cannot compile +-See \`config.log' for more details." "$LINENO" 5; } ++as_fn_error $? "cannot compute suffix of object files: cannot compile ++See \`config.log' for more details" "$LINENO" 5; } + fi + rm -f conftest.$ac_cv_objext conftest.$ac_ext + fi +@@ -3025,7 +2987,7 @@ OBJEXT=$ac_cv_objext + ac_objext=$OBJEXT + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 + $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +-if test "${ac_cv_c_compiler_gnu+set}" = set; then : ++if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -3062,7 +3024,7 @@ ac_test_CFLAGS=${CFLAGS+set} + ac_save_CFLAGS=$CFLAGS + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 + $as_echo_n "checking whether $CC accepts -g... " >&6; } +-if test "${ac_cv_prog_cc_g+set}" = set; then : ++if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_save_c_werror_flag=$ac_c_werror_flag +@@ -3140,7 +3102,7 @@ else + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 + $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +-if test "${ac_cv_prog_cc_c89+set}" = set; then : ++if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_cv_prog_cc_c89=no +@@ -3149,8 +3111,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ + /* end confdefs.h. */ + #include + #include +-#include +-#include ++struct stat; + /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ + struct buf { int x; }; + FILE * (*rcsopen) (struct buf *, struct stat *, int); +@@ -3236,64 +3197,1688 @@ ac_link='$CC -o conftest$ac_exeext $CFLA + ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +-TEMP_LIBS="-lm ${TEMP_LIBS}" +-TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" +-TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" +- +- +-if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then +- +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking bktr headers in /usr/include/dev/bktr" >&5 +-$as_echo_n "checking bktr headers in /usr/include/dev/bktr... " >&6; } +- +- if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; } +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +- TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" +- fi +-# +-# Check to Exclude BKTR +-# +-BKTR="yes" +- +-# Check whether --with-bktr was given. +-if test "${with_bktr+set}" = set; then : +- withval=$with_bktr; BKTR="$withval" +- ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 ++$as_echo_n "checking how to run the C preprocessor... " >&6; } ++# On Suns, sometimes $CPP names a directory. ++if test -n "$CPP" && test -d "$CPP"; then ++ CPP= + fi +- +- +- +- if test "${BKTR}" = "no"; then +- TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" +- fi +- ++if test -z "$CPP"; then ++ if ${ac_cv_prog_CPP+:} false; then : ++ $as_echo_n "(cached) " >&6 + else ++ # Double quotes because CPP needs to be expanded ++ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" ++ do ++ ac_preproc_ok=false ++for ac_c_preproc_warn_flag in '' yes ++do ++ # Use a header file that comes with gcc, so configuring glibc ++ # with a fresh cross-compiler works. ++ # Prefer to if __STDC__ is defined, since ++ # exists even on freestanding compilers. ++ # On the NeXT, cc -E runs the code through the compiler's parser, ++ # not just through cpp. "Syntax error" is here to catch this case. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#ifdef __STDC__ ++# include ++#else ++# include ++#endif ++ Syntax error ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : + +-# +-# Check to Exclude V4L +-# +-V4L="yes" ++else ++ # Broken: fails on valid input. ++continue ++fi ++rm -f conftest.err conftest.i conftest.$ac_ext + +-# Check whether --with-v4l was given. +-if test "${with_v4l+set}" = set; then : +- withval=$with_v4l; V4L="$withval" ++ # OK, works on sane cases. Now check whether nonexistent headers ++ # can be detected and how. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ # Broken: success on invalid input. ++continue ++else ++ # Passes both tests. ++ac_preproc_ok=: ++break ++fi ++rm -f conftest.err conftest.i conftest.$ac_ext + ++done ++# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. ++rm -f conftest.i conftest.err conftest.$ac_ext ++if $ac_preproc_ok; then : ++ break + fi + ++ done ++ ac_cv_prog_CPP=$CPP + + fi ++ CPP=$ac_cv_prog_CPP ++else ++ ac_cv_prog_CPP=$CPP ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 ++$as_echo "$CPP" >&6; } ++ac_preproc_ok=false ++for ac_c_preproc_warn_flag in '' yes ++do ++ # Use a header file that comes with gcc, so configuring glibc ++ # with a fresh cross-compiler works. ++ # Prefer to if __STDC__ is defined, since ++ # exists even on freestanding compilers. ++ # On the NeXT, cc -E runs the code through the compiler's parser, ++ # not just through cpp. "Syntax error" is here to catch this case. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#ifdef __STDC__ ++# include ++#else ++# include ++#endif ++ Syntax error ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : + ++else ++ # Broken: fails on valid input. ++continue ++fi ++rm -f conftest.err conftest.i conftest.$ac_ext + +-if test "${V4L}" = "no"; then +- TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" ++ # OK, works on sane cases. Now check whether nonexistent headers ++ # can be detected and how. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ # Broken: success on invalid input. ++continue ++else ++ # Passes both tests. ++ac_preproc_ok=: ++break + fi ++rm -f conftest.err conftest.i conftest.$ac_ext + ++done ++# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. ++rm -f conftest.i conftest.err conftest.$ac_ext ++if $ac_preproc_ok; then : + +-if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then ++else ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error $? "C preprocessor \"$CPP\" fails sanity check ++See \`config.log' for more details" "$LINENO" 5; } ++fi ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 ++$as_echo_n "checking for grep that handles long lines and -e... " >&6; } ++if ${ac_cv_path_GREP+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -z "$GREP"; then ++ ac_path_GREP_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in grep ggrep; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" ++ as_fn_executable_p "$ac_path_GREP" || continue ++# Check for GNU ac_path_GREP and select it if it is found. ++ # Check for GNU $ac_path_GREP ++case `"$ac_path_GREP" --version 2>&1` in ++*GNU*) ++ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; ++*) ++ ac_count=0 ++ $as_echo_n 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ $as_echo 'GREP' >> "conftest.nl" ++ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_GREP_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_GREP="$ac_path_GREP" ++ ac_path_GREP_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_GREP_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_GREP"; then ++ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_GREP=$GREP ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 ++$as_echo "$ac_cv_path_GREP" >&6; } ++ GREP="$ac_cv_path_GREP" ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 ++$as_echo_n "checking for egrep... " >&6; } ++if ${ac_cv_path_EGREP+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 ++ then ac_cv_path_EGREP="$GREP -E" ++ else ++ if test -z "$EGREP"; then ++ ac_path_EGREP_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in egrep; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" ++ as_fn_executable_p "$ac_path_EGREP" || continue ++# Check for GNU ac_path_EGREP and select it if it is found. ++ # Check for GNU $ac_path_EGREP ++case `"$ac_path_EGREP" --version 2>&1` in ++*GNU*) ++ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; ++*) ++ ac_count=0 ++ $as_echo_n 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ $as_echo 'EGREP' >> "conftest.nl" ++ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_EGREP_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_EGREP="$ac_path_EGREP" ++ ac_path_EGREP_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_EGREP_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_EGREP"; then ++ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_EGREP=$EGREP ++fi ++ ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 ++$as_echo "$ac_cv_path_EGREP" >&6; } ++ EGREP="$ac_cv_path_EGREP" ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 ++$as_echo_n "checking for ANSI C header files... " >&6; } ++if ${ac_cv_header_stdc+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++#include ++#include ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_header_stdc=yes ++else ++ ac_cv_header_stdc=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ++if test $ac_cv_header_stdc = yes; then ++ # SunOS 4.x string.h does not declare mem*, contrary to ANSI. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++ ++_ACEOF ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | ++ $EGREP "memchr" >/dev/null 2>&1; then : ++ ++else ++ ac_cv_header_stdc=no ++fi ++rm -f conftest* ++ ++fi ++ ++if test $ac_cv_header_stdc = yes; then ++ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++ ++_ACEOF ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | ++ $EGREP "free" >/dev/null 2>&1; then : ++ ++else ++ ac_cv_header_stdc=no ++fi ++rm -f conftest* ++ ++fi ++ ++if test $ac_cv_header_stdc = yes; then ++ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. ++ if test "$cross_compiling" = yes; then : ++ : ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++#if ((' ' & 0x0FF) == 0x020) ++# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') ++# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) ++#else ++# define ISLOWER(c) \ ++ (('a' <= (c) && (c) <= 'i') \ ++ || ('j' <= (c) && (c) <= 'r') \ ++ || ('s' <= (c) && (c) <= 'z')) ++# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) ++#endif ++ ++#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) ++int ++main () ++{ ++ int i; ++ for (i = 0; i < 256; i++) ++ if (XOR (islower (i), ISLOWER (i)) ++ || toupper (i) != TOUPPER (i)) ++ return 2; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ ++else ++ ac_cv_header_stdc=no ++fi ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ ++ conftest.$ac_objext conftest.beam conftest.$ac_ext ++fi ++ ++fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 ++$as_echo "$ac_cv_header_stdc" >&6; } ++if test $ac_cv_header_stdc = yes; then ++ ++$as_echo "#define STDC_HEADERS 1" >>confdefs.h ++ ++fi ++ ++# On IRIX 5.3, sys/types and inttypes.h are conflicting. ++for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ ++ inttypes.h stdint.h unistd.h ++do : ++ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ++ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default ++" ++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : ++ cat >>confdefs.h <<_ACEOF ++#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 ++_ACEOF ++ ++fi ++ ++done ++ ++ ++ ++ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" ++if test "x$ac_cv_header_minix_config_h" = xyes; then : ++ MINIX=yes ++else ++ MINIX= ++fi ++ ++ ++ if test "$MINIX" = yes; then ++ ++$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h ++ ++ ++$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h ++ ++ ++$as_echo "#define _MINIX 1" >>confdefs.h ++ ++ fi ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 ++$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } ++if ${ac_cv_safe_to_define___extensions__+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++# define __EXTENSIONS__ 1 ++ $ac_includes_default ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_safe_to_define___extensions__=yes ++else ++ ac_cv_safe_to_define___extensions__=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 ++$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } ++ test $ac_cv_safe_to_define___extensions__ = yes && ++ $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h ++ ++ $as_echo "#define _ALL_SOURCE 1" >>confdefs.h ++ ++ $as_echo "#define _GNU_SOURCE 1" >>confdefs.h ++ ++ $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h ++ ++ $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h ++ ++ ++ ++ ++ac_config_headers="$ac_config_headers config.h" ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="${ac_tool_prefix}gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_CC"; then ++ ac_ct_CC=$CC ++ # Extract the first word of "gcc", so it can be a program name with args. ++set dummy gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_ac_ct_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_ac_ct_CC="gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++else ++ CC="$ac_cv_prog_CC" ++fi ++ ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="${ac_tool_prefix}cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ fi ++fi ++if test -z "$CC"; then ++ # Extract the first word of "cc", so it can be a program name with args. ++set dummy cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++ ac_prog_rejected=no ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ++ ac_prog_rejected=yes ++ continue ++ fi ++ ac_cv_prog_CC="cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++if test $ac_prog_rejected = yes; then ++ # We found a bogon in the path, so make sure we never use it. ++ set dummy $ac_cv_prog_CC ++ shift ++ if test $# != 0; then ++ # We chose a different compiler from the bogus one. ++ # However, it has the same basename, so the bogon will be chosen ++ # first if we set CC to just the basename; use the full file name. ++ shift ++ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" ++ fi ++fi ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ for ac_prog in cl.exe ++ do ++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. ++set dummy $ac_tool_prefix$ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="$ac_tool_prefix$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$CC" && break ++ done ++fi ++if test -z "$CC"; then ++ ac_ct_CC=$CC ++ for ac_prog in cl.exe ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_ac_ct_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_ac_ct_CC="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$ac_ct_CC" && break ++done ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++fi ++ ++fi ++ ++ ++test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error $? "no acceptable C compiler found in \$PATH ++See \`config.log' for more details" "$LINENO" 5; } ++ ++# Provide some information about the compiler. ++$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 ++set X $ac_compile ++ac_compiler=$2 ++for ac_option in --version -v -V -qversion; do ++ { { ac_try="$ac_compiler $ac_option >&5" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_compiler $ac_option >&5") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ sed '10a\ ++... rest of stderr output deleted ... ++ 10q' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ fi ++ rm -f conftest.er1 conftest.err ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 ++$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } ++if ${ac_cv_c_compiler_gnu+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++#ifndef __GNUC__ ++ choke me ++#endif ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_compiler_gnu=yes ++else ++ ac_compiler_gnu=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ac_cv_c_compiler_gnu=$ac_compiler_gnu ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 ++$as_echo "$ac_cv_c_compiler_gnu" >&6; } ++if test $ac_compiler_gnu = yes; then ++ GCC=yes ++else ++ GCC= ++fi ++ac_test_CFLAGS=${CFLAGS+set} ++ac_save_CFLAGS=$CFLAGS ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 ++$as_echo_n "checking whether $CC accepts -g... " >&6; } ++if ${ac_cv_prog_cc_g+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_save_c_werror_flag=$ac_c_werror_flag ++ ac_c_werror_flag=yes ++ ac_cv_prog_cc_g=no ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++else ++ CFLAGS="" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++else ++ ac_c_werror_flag=$ac_save_c_werror_flag ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ac_c_werror_flag=$ac_save_c_werror_flag ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 ++$as_echo "$ac_cv_prog_cc_g" >&6; } ++if test "$ac_test_CFLAGS" = set; then ++ CFLAGS=$ac_save_CFLAGS ++elif test $ac_cv_prog_cc_g = yes; then ++ if test "$GCC" = yes; then ++ CFLAGS="-g -O2" ++ else ++ CFLAGS="-g" ++ fi ++else ++ if test "$GCC" = yes; then ++ CFLAGS="-O2" ++ else ++ CFLAGS= ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 ++$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } ++if ${ac_cv_prog_cc_c89+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_cv_prog_cc_c89=no ++ac_save_CC=$CC ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++struct stat; ++/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ ++struct buf { int x; }; ++FILE * (*rcsopen) (struct buf *, struct stat *, int); ++static char *e (p, i) ++ char **p; ++ int i; ++{ ++ return p[i]; ++} ++static char *f (char * (*g) (char **, int), char **p, ...) ++{ ++ char *s; ++ va_list v; ++ va_start (v,p); ++ s = g (p, va_arg (v,int)); ++ va_end (v); ++ return s; ++} ++ ++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has ++ function prototypes and stuff, but not '\xHH' hex character constants. ++ These don't provoke an error unfortunately, instead are silently treated ++ as 'x'. The following induces an error, until -std is added to get ++ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an ++ array size at least. It's necessary to write '\x00'==0 to get something ++ that's true only with -std. */ ++int osf4_cc_array ['\x00' == 0 ? 1 : -1]; ++ ++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters ++ inside strings and character constants. */ ++#define FOO(x) 'x' ++int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; ++ ++int test (int i, double x); ++struct s1 {int (*f) (int a);}; ++struct s2 {int (*f) (double a);}; ++int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); ++int argc; ++char **argv; ++int ++main () ++{ ++return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ++ ; ++ return 0; ++} ++_ACEOF ++for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ ++ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" ++do ++ CC="$ac_save_CC $ac_arg" ++ if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_c89=$ac_arg ++fi ++rm -f core conftest.err conftest.$ac_objext ++ test "x$ac_cv_prog_cc_c89" != "xno" && break ++done ++rm -f conftest.$ac_ext ++CC=$ac_save_CC ++ ++fi ++# AC_CACHE_VAL ++case "x$ac_cv_prog_cc_c89" in ++ x) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 ++$as_echo "none needed" >&6; } ;; ++ xno) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 ++$as_echo "unsupported" >&6; } ;; ++ *) ++ CC="$CC $ac_cv_prog_cc_c89" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 ++$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; ++esac ++if test "x$ac_cv_prog_cc_c89" != xno; then : ++ ++fi ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++ ++THREAD_CFLAGS="" ++THREAD_CHECK="/usr/include/pthread.h" ++ ++Darwin="" ++FreeBSD="" ++ ++LINUXTHREADS="no" ++ ++# Check whether --with-linuxthreads was given. ++if test "${with_linuxthreads+set}" = set; then : ++ withval=$with_linuxthreads; LINUXTHREADS="$withval" ++ ++fi ++ ++ ++PWCBSD="no" ++ ++# Check whether --with-pwcbsd was given. ++if test "${with_pwcbsd+set}" = set; then : ++ withval=$with_pwcbsd; PWCBSD="$withval" ++ ++fi ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 ++$as_echo_n "checking for Darwin... " >&6; } ++Darwin=`uname -a | grep "Darwin"` ++ ++if test "${Darwin}" = ""; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 ++$as_echo_n "checking for *BSD... " >&6; } ++ ++ FreeBSD=`uname -a | grep "BSD"` ++ if test "${FreeBSD}" = ""; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ VIDEO="video.o video2.o video_common.o" ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ if test "${LINUXTHREADS}" = "no"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linuxthreads" >&5 ++$as_echo_n "checking Linuxthreads... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 ++$as_echo "skipping" >&6; } ++ else ++ THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" ++ THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" ++ fi ++ ++ if test "${PWCBSD}" != "no"; then ++ VIDEO="video.o video2.o video_common.o" ++ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" ++ else ++ VIDEO="video_freebsd.o" ++ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" ++ fi ++ ++ TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" ++ TEMP_LIBS="-L/usr/local/lib" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: Build with PWCBSD support $PWCBSD" >&5 ++$as_echo "Build with PWCBSD support $PWCBSD" >&6; } ++ ++ fi ++else ++ TEMP_CFLAGS="${CFLAGS} -I/sw/include" ++ TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" ++ TEMP_LIBS="-L/sw/lib" ++ VIDEO="video_freebsd.o" ++ FINK_LIB="-L/sw/lib" ++ Darwin="yes" ++ V4L="no" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Darwin" >&5 ++$as_echo "$Darwin" >&6; } ++fi ++ ++ ++ ++ ++# Checks for programs. ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="${ac_tool_prefix}gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_CC"; then ++ ac_ct_CC=$CC ++ # Extract the first word of "gcc", so it can be a program name with args. ++set dummy gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_ac_ct_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_ac_ct_CC="gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++else ++ CC="$ac_cv_prog_CC" ++fi ++ ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="${ac_tool_prefix}cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ fi ++fi ++if test -z "$CC"; then ++ # Extract the first word of "cc", so it can be a program name with args. ++set dummy cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++ ac_prog_rejected=no ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ++ ac_prog_rejected=yes ++ continue ++ fi ++ ac_cv_prog_CC="cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++if test $ac_prog_rejected = yes; then ++ # We found a bogon in the path, so make sure we never use it. ++ set dummy $ac_cv_prog_CC ++ shift ++ if test $# != 0; then ++ # We chose a different compiler from the bogus one. ++ # However, it has the same basename, so the bogon will be chosen ++ # first if we set CC to just the basename; use the full file name. ++ shift ++ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" ++ fi ++fi ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ for ac_prog in cl.exe ++ do ++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. ++set dummy $ac_tool_prefix$ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_CC="$ac_tool_prefix$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$CC" && break ++ done ++fi ++if test -z "$CC"; then ++ ac_ct_CC=$CC ++ for ac_prog in cl.exe ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_prog_ac_ct_CC+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_prog_ac_ct_CC="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$ac_ct_CC" && break ++done ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++fi ++ ++fi ++ ++ ++test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error $? "no acceptable C compiler found in \$PATH ++See \`config.log' for more details" "$LINENO" 5; } ++ ++# Provide some information about the compiler. ++$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 ++set X $ac_compile ++ac_compiler=$2 ++for ac_option in --version -v -V -qversion; do ++ { { ac_try="$ac_compiler $ac_option >&5" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_compiler $ac_option >&5") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ sed '10a\ ++... rest of stderr output deleted ... ++ 10q' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ fi ++ rm -f conftest.er1 conftest.err ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 ++$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } ++if ${ac_cv_c_compiler_gnu+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++#ifndef __GNUC__ ++ choke me ++#endif ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_compiler_gnu=yes ++else ++ ac_compiler_gnu=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ac_cv_c_compiler_gnu=$ac_compiler_gnu ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 ++$as_echo "$ac_cv_c_compiler_gnu" >&6; } ++if test $ac_compiler_gnu = yes; then ++ GCC=yes ++else ++ GCC= ++fi ++ac_test_CFLAGS=${CFLAGS+set} ++ac_save_CFLAGS=$CFLAGS ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 ++$as_echo_n "checking whether $CC accepts -g... " >&6; } ++if ${ac_cv_prog_cc_g+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_save_c_werror_flag=$ac_c_werror_flag ++ ac_c_werror_flag=yes ++ ac_cv_prog_cc_g=no ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++else ++ CFLAGS="" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++else ++ ac_c_werror_flag=$ac_save_c_werror_flag ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ac_c_werror_flag=$ac_save_c_werror_flag ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 ++$as_echo "$ac_cv_prog_cc_g" >&6; } ++if test "$ac_test_CFLAGS" = set; then ++ CFLAGS=$ac_save_CFLAGS ++elif test $ac_cv_prog_cc_g = yes; then ++ if test "$GCC" = yes; then ++ CFLAGS="-g -O2" ++ else ++ CFLAGS="-g" ++ fi ++else ++ if test "$GCC" = yes; then ++ CFLAGS="-O2" ++ else ++ CFLAGS= ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 ++$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } ++if ${ac_cv_prog_cc_c89+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_cv_prog_cc_c89=no ++ac_save_CC=$CC ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++struct stat; ++/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ ++struct buf { int x; }; ++FILE * (*rcsopen) (struct buf *, struct stat *, int); ++static char *e (p, i) ++ char **p; ++ int i; ++{ ++ return p[i]; ++} ++static char *f (char * (*g) (char **, int), char **p, ...) ++{ ++ char *s; ++ va_list v; ++ va_start (v,p); ++ s = g (p, va_arg (v,int)); ++ va_end (v); ++ return s; ++} ++ ++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has ++ function prototypes and stuff, but not '\xHH' hex character constants. ++ These don't provoke an error unfortunately, instead are silently treated ++ as 'x'. The following induces an error, until -std is added to get ++ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an ++ array size at least. It's necessary to write '\x00'==0 to get something ++ that's true only with -std. */ ++int osf4_cc_array ['\x00' == 0 ? 1 : -1]; ++ ++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters ++ inside strings and character constants. */ ++#define FOO(x) 'x' ++int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; ++ ++int test (int i, double x); ++struct s1 {int (*f) (int a);}; ++struct s2 {int (*f) (double a);}; ++int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); ++int argc; ++char **argv; ++int ++main () ++{ ++return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ++ ; ++ return 0; ++} ++_ACEOF ++for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ ++ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" ++do ++ CC="$ac_save_CC $ac_arg" ++ if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_c89=$ac_arg ++fi ++rm -f core conftest.err conftest.$ac_objext ++ test "x$ac_cv_prog_cc_c89" != "xno" && break ++done ++rm -f conftest.$ac_ext ++CC=$ac_save_CC ++ ++fi ++# AC_CACHE_VAL ++case "x$ac_cv_prog_cc_c89" in ++ x) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 ++$as_echo "none needed" >&6; } ;; ++ xno) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 ++$as_echo "unsupported" >&6; } ;; ++ *) ++ CC="$CC $ac_cv_prog_cc_c89" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 ++$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; ++esac ++if test "x$ac_cv_prog_cc_c89" != xno; then : ++ ++fi ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++TEMP_LIBS="-lm ${TEMP_LIBS}" ++TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" ++TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" ++ ++if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking bktr headers in /usr/include/dev/bktr" >&5 ++$as_echo_n "checking bktr headers in /usr/include/dev/bktr... " >&6; } ++ ++ if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" ++ fi ++# ++# Check to Exclude BKTR ++# ++BKTR="yes" ++ ++# Check whether --with-bktr was given. ++if test "${with_bktr+set}" = set; then : ++ withval=$with_bktr; BKTR="$withval" ++ ++fi ++ ++ ++ if test "${BKTR}" = "no"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" ++ fi ++ ++else ++ ++# ++# Check to Exclude V4L ++# ++V4L="yes" ++ ++# Check whether --with-v4l was given. ++if test "${with_v4l+set}" = set; then : ++ withval=$with_v4l; V4L="$withval" ++ ++fi ++ ++ ++fi ++ ++ ++if test "${V4L}" = "no"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" ++fi ++ ++ ++if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linuxthreads" >&5 + $as_echo_n "checking for linuxthreads... " >&6; } +@@ -3302,10 +4887,10 @@ $as_echo_n "checking for linuxthreads... + # Check for thread header + # + if test -f "${THREAD_CHECK}"; then +- HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" +- THREADS="yes" ++ HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" ++ THREADS="yes" + else +- THREADS="no" ++ THREADS="no" + fi + + # +@@ -3315,7 +4900,7 @@ $as_echo_n "checking for linuxthreads... + THREADS="yes" + LIB_THREAD="-llthread -llgcc_r" + else +- THREADS="no" ++ THREADS="no" + fi + + # Checks for Library linuxthreads for FreeBSD +@@ -3328,26 +4913,25 @@ $as_echo_n "checking for linuxthreads... + + if test "${THREADS}" = "yes"; then + TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" +- TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" +- THREAD_CFLAGS="-D_THREAD_SAFE" +- PTHREAD_SUPPORT="yes" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 ++ TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" ++ THREAD_CFLAGS="-D_THREAD_SAFE" ++ PTHREAD_SUPPORT="yes" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 + $as_echo "$THREADS" >&6; } +- else +- PTHREAD_SUPPORT="no" +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 ++ else ++ PTHREAD_SUPPORT="no" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 + $as_echo "$THREADS" >&6; } +- echo +- echo "You do not have linuxthread installed" +- echo +- fi ++ echo ++ echo "You do not have linuxthread installed" ++ echo ++ fi + + elif test -f "${THREAD_CHECK}"; then + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking threads" >&5 + $as_echo_n "checking threads... " >&6; } +- + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include +@@ -3388,6 +4972,142 @@ else + fi + + ++# ++# Check for sdl library ++# ++SDL_SUPPORT="no" ++ ++# Check whether --with-sdl was given. ++if test "${with_sdl+set}" = set; then : ++ withval=$with_sdl; ++fi ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl" >&5 ++$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; } ++else ++ if test "${FreeBSD}" != ""; then ++ CONFIG_SDL='sdl11-config' ++ else ++ CONFIG_SDL='sdl-config' ++ fi ++ if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ if test "$withval" = "yes"; then ++ echo "" ++ echo "****************************************************" ++ echo "* sdl-config could not be found. Please install it *" ++ echo "* and remove the --with-sdl configure argument. *" ++ echo "* libSDL can be found at http://www.libsdl.org *" ++ echo "****************************************************" ++ echo "" ++ fi ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ SDL_SUPPORT="yes" ++ TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" ++ TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" ++ ++$as_echo "#define HAVE_SDL 1" >>confdefs.h ++ ++ SDL_OBJ="sdl.o" ++ ++ fi ++fi ++ ++# ++# Check for the libjpeg-turbo library ++# ++JPEG_TURBO="no" ++JPEG_TURBO_OK="not_found" ++ ++ ++# Check whether --with-jpeg-turbo was given. ++if test "${with_jpeg_turbo+set}" = set; then : ++ withval=$with_jpeg_turbo; JPEG_TURBO="$withval" ++ ++fi ++ ++ ++if test "${JPEG_TURBO}" = "no"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo" >&5 ++$as_echo_n "checking for libjpeg-turbo... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 ++$as_echo "skipping" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo in -> ${JPEG_TURBO} <-" >&5 ++$as_echo_n "checking for libjpeg-turbo in -> ${JPEG_TURBO} <-... " >&6; } ++ if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 ++$as_echo "found" >&6; } ++ JPEG_TURBO_OK="found" ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 ++$as_echo "not found" >&6; } ++ fi ++fi ++ ++ ++if test "${JPEG_TURBO_OK}" = "found"; then ++ saved_CFLAGS="$CFLAGS" ++ saved_LIBS="$LIBS" ++ saved_LDFLAGS="$LDFLAGS" ++ LDFLAGS="-L${JPEG_TURBO}/lib" ++ CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" ++ LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 ++$as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } ++if ${ac_cv_lib_jpeg_jpeg_start_compress+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-ljpeg $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char jpeg_start_compress (); ++int ++main () ++{ ++return jpeg_start_compress (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_jpeg_jpeg_start_compress=yes ++else ++ ac_cv_lib_jpeg_jpeg_start_compress=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 ++$as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } ++if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = xyes; then : ++ TEMP_LIBS="$LIBS" ++ TEMP_CFLAGS="${CFLAGS}" ++ TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" ++ JPEG_SUPPORT="yes" ++fi ++ ++ LIBS="$saved_LIBS" ++ CFLAGS="$saved_CFLAGS" ++ LDFLAGS="$saved_LDFLAGS" ++ JPEG_SUPPORT_TURBO="yes" ++fi ++ + + # + # Check for the special mmx accelerated jpeg library +@@ -3406,7 +5126,7 @@ fi + # --without-jpeg-mmx or with-jpeg-mmx=no + # + +-if test "${JPEG_MMX}" = "no"; then ++if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx" >&5 + $as_echo_n "checking for libjpeg-mmx... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 +@@ -3450,7 +5170,7 @@ if test "${JPEG_MMX_OK}" = "found"; then + LIBS="$LIBS -L${JPEG_MMX}" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg-mmx" >&5 + $as_echo_n "checking for jpeg_start_compress in -ljpeg-mmx... " >&6; } +-if test "${ac_cv_lib_jpeg_mmx_jpeg_start_compress+set}" = set; then : ++if ${ac_cv_lib_jpeg_mmx_jpeg_start_compress+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +@@ -3484,7 +5204,7 @@ LIBS=$ac_check_lib_save_LIBS + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&5 + $as_echo "$ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&6; } +-if test "x$ac_cv_lib_jpeg_mmx_jpeg_start_compress" = x""yes; then : ++if test "x$ac_cv_lib_jpeg_mmx_jpeg_start_compress" = xyes; then : + TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" + TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" + JPEG_SUPPORT="yes" +@@ -3500,15 +5220,11 @@ fi + # + if test x$JPEG_SUPPORT != xyes ; then + # Checks for libraries +- LDFLAGS="$TEMP_LDFLAGS" +- +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg" >&5 +-$as_echo_n "checking for libjpeg... " >&6; } +- echo ++ LDFLAGS=$TEMP_LDFLAGS + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_set_defaults in -ljpeg" >&5 + $as_echo_n "checking for jpeg_set_defaults in -ljpeg... " >&6; } +-if test "${ac_cv_lib_jpeg_jpeg_set_defaults+set}" = set; then : ++if ${ac_cv_lib_jpeg_jpeg_set_defaults+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +@@ -3542,7 +5258,7 @@ LIBS=$ac_check_lib_save_LIBS + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_set_defaults" >&5 + $as_echo "$ac_cv_lib_jpeg_jpeg_set_defaults" >&6; } +-if test "x$ac_cv_lib_jpeg_jpeg_set_defaults" = x""yes; then : ++if test "x$ac_cv_lib_jpeg_jpeg_set_defaults" = xyes; then : + + TEMP_LIBS="$TEMP_LIBS -ljpeg" + JPEG_SUPPORT="yes" +@@ -3562,6 +5278,7 @@ fi + # + # Check for libavcodec and libavformat from ffmpeg + # ++ + FFMPEG_DIR="yes" + FFMPEG_OK="no_found" + FFMPEG_OBJ="" +@@ -3572,6 +5289,31 @@ if test "${with_ffmpeg+set}" = set; then + + fi + ++ ++# ++# ffmpeg headers custom location ++# ++FFMPEG_HEADERS_DIR="yes" ++ ++# Check whether --with-ffmpeg_headers was given. ++if test "${with_ffmpeg_headers+set}" = set; then : ++ withval=$with_ffmpeg_headers; FFMPEG_HEADERS_DIR="$withval" ++ ++fi ++ ++ ++# ++# ffmpeg custom extra libraries ++# ++FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " ++ ++# Check whether --with-ffmpeg-libs was given. ++if test "${with_ffmpeg_libs+set}" = set; then : ++ withval=$with_ffmpeg_libs; FFMPEG_EXTRALIBS="$withval" ++ ++fi ++ ++ + # + # --without-ffmpeg or with-ffmpeg=no + # +@@ -3585,8 +5327,8 @@ $as_echo "skipping" >&6; } + # + else if test "${FFMPEG_DIR}" = "yes"; then + # AUTODETECT STATIC/SHARED LIB +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting" >&5 +-$as_echo_n "checking for ffmpeg autodetecting... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting libraries" >&5 ++$as_echo_n "checking for ffmpeg autodetecting libraries... " >&6; } + + if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib64" >&5 +@@ -3606,6 +5348,18 @@ $as_echo "found in /usr/local/lib" >&6; + FFMPEG_OK="found" + FFMPEG_LIB="/usr/local/lib" + FFMPEG_DIR="/usr/local" ++ elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/x86_64-linux-gnu" >&5 ++$as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" ++ FFMPEG_DIR="/usr" ++ elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 ++$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib/i386-linux-gnu" ++ FFMPEG_DIR="/usr" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + $as_echo "not found" >&6; } +@@ -3621,8 +5375,8 @@ $as_echo "not found" >&6; } + echo "" + fi + else +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg in -> ${FFMPEG_DIR} <-" >&5 +-$as_echo_n "checking for ffmpeg in -> ${FFMPEG_DIR} <-... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-" >&5 ++$as_echo_n "checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-... " >&6; } + if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 + $as_echo "found" >&6; } +@@ -3651,94 +5405,202 @@ $as_echo "not found" >&6; } + fi + fi + ++ + # + # Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found + # + ++AVFORMAT_DIR="" ++ + if test "${FFMPEG_OK}" = "found"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 ++ if test "${FFMPEG_HEADERS_DIR}" = "yes"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 + $as_echo_n "checking for ffmpeg headers in ${FFMPEG_DIR}... " >&6; } ++ AVFORMAT_DIR="${FFMPEG_DIR}" ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}" >&5 ++$as_echo_n "checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}... " >&6; } ++ FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" ++ AVFORMAT_DIR="${FFMPEG_DIR}" ++ fi + +- if test -f ${FFMPEG_DIR}/include/avformat.h; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 ++ if test -f ${FFMPEG_DIR}/include/avformat.h; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 + $as_echo "found ${FFMPEG_DIR}/include/avformat.h" >&6; } +- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" +- elif test -f ${FFMPEG_DIR}/avformat.h; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" ++ elif test -f ${FFMPEG_DIR}/avformat.h; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 + $as_echo "found ${FFMPEG_DIR}/avformat.h" >&6; } +- FFMPEG_CFLAGS="-I${FFMPEG_DIR}" +- elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}" ++ AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" ++ elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 + $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; } +- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" +- elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" ++ elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 + $as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; } +- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" + elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5 + $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; } + FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 ++ AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" ++ elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/libavformat/avformat.h" >&5 ++$as_echo "found ${FFMPEG_DIR}/libavformat/avformat.h" >&6; } ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I{FFMPEG_DIR}/libavformat" ++ AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + $as_echo "not found" >&6; } +- FFMPEG_OK="no_found" +- echo "**********************************************" +- echo "* avformat.h not found: *" +- echo "* ALL FFMPEG FEATURES DISABLED *" +- echo "* *" +- echo "* Please read the Motion Guide for help: *" +- echo "* http://motion.sourceforge.net *" +- echo "**********************************************" +- echo "" +- fi ++ FFMPEG_OK="no_found" ++ AVFORMAT_DIR="avformat.h" ++ echo "**********************************************" ++ echo "* avformat.h not found: *" ++ echo "* ALL FFMPEG FEATURES DISABLED *" ++ echo "* *" ++ echo "* Please read the Motion Guide for help: *" ++ echo "* http://motion.sourceforge.net *" ++ echo "**********************************************" ++ echo "" ++ fi + + # + # If ffmpeg libs and headers have been found + # + +- if test "${FFMPEG_OK}" = "found"; then +- TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavformat -lavcodec -lavutil -lm -lz" +- TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" +- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" ++ if test "${FFMPEG_OK}" = "found"; then ++ TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" ++ TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" + +- FFMPEG_OBJ="ffmpeg.o" ++ FFMPEG_OBJ="ffmpeg.o" + + +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 + $as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } +- saved_CFLAGS=$CFLAGS +- saved_LIBS=$LIBS +- CFLAGS="${FFMPEG_CFLAGS}" +- LIBS="$TEMP_LIBS" ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ ++ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" ++ LIBS="$TEMP_LIBS" ++ ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ + +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++ ++ #include <${AVFORMAT_DIR}> ++ URLProtocol test_file_protocol; ++ int main(void){ ++ test_file_protocol.url_read = file_protocol.url_read; ++ return 0; ++ } ++ ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++else ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" ++ ++ ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++ fi ++fi ++fi ++ ++# Revised RTSP module so that it can be included ++# whether or not FFMPEG is found. ++ ++ RTPS_OBJ="netcam_rtsp.o" ++ ++ ++# ++# Check SQLITE3 ++# ++ ++SQLITE3_SUPPORT="no" ++ ++# Check whether --with-sqlite3 was given. ++if test "${with_sqlite3+set}" = set; then : ++ withval=$with_sqlite3; SQLITE3="$withval" ++ # if not given argument, assume standard ++ ++fi ++ ++ ++if test "${SQLITE3}" = "no"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3" >&5 ++$as_echo_n "checking for sqlite3... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 ++$as_echo "skipping" >&6; } ++else ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5 ++$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; } ++if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lsqlite3 $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +- #include +- URLProtocol test_file_protocol; +- int main(void){ +- test_file_protocol.url_read = file_protocol.url_read; +- return 0; +- } +- ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char sqlite3_open (); ++int ++main () ++{ ++return sqlite3_open (); ++ ; ++ return 0; ++} + _ACEOF +-if ac_fn_c_try_compile "$LINENO"; then : +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; } ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_sqlite3_sqlite3_open=yes + else ++ ac_cv_lib_sqlite3_sqlite3_open=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5 ++$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; } ++if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then : ++ ++ TEMP_LIBS="$TEMP_LIBS -lsqlite3" ++ SQLITE3_SUPPORT="yes" ++ ++$as_echo "#define HAVE_SQLITE3 1" >>confdefs.h + +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" + + + fi +-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +- CFLAGS=$saved_CFLAGS +- LIBS=$saved_LIBS +- fi +-fi ++ ++ ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS + fi + + +@@ -3821,8 +5683,8 @@ $as_echo "skipped" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers in $MYSQL_HEADERS" >&5 + $as_echo_n "checking for mysql headers in $MYSQL_HEADERS... " >&6; } + # Manual detection for +- if test -f $MYSQL_HEADERS/mysql.h; then +- MYSQL_INCDIR=$MYSQL_HEADERS ++ if test -f $MYSQL_HEADERS/mysql.h; then ++ MYSQL_INCDIR=$MYSQL_HEADERS + fi + fi + +@@ -3832,8 +5694,8 @@ $as_echo_n "checking for mysql headers i + $as_echo "not found" >&6; } + echo "Invalid MySQL directory - unable to find mysql.h." + else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_INCDIR yes" >&5 ++$as_echo "$MYSQL_INCDIR yes" >&6; } + MYSQL_HEADERS="yes" + fi + +@@ -3844,8 +5706,8 @@ $as_echo "yes" >&6; } + if test "${MYSQL_LIBS}" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql libs" >&5 + $as_echo_n "checking autodect mysql libs... " >&6; } +- # Autodetect +- for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql; do ++ # Autodetect ++ for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do + # check for plain setups + if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then + MYSQL_LIBDIR=$w +@@ -3863,7 +5725,7 @@ $as_echo_n "checking autodect mysql libs + fi + done + elif test "${MYSQL_LIBS}" = "no"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 + $as_echo_n "checking for mysql libs... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 + $as_echo "skipped" >&6; } +@@ -3891,7 +5753,7 @@ $as_echo "$MYSQL_LIBDIR" >&6; } + LIBS="-L$MYSQL_LIBDIR" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 + $as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } +-if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then : ++if ${ac_cv_lib_mysqlclient_mysql_init+:} false; then : + $as_echo_n "(cached) " >&6 + else + ac_check_lib_save_LIBS=$LIBS +@@ -3925,7 +5787,7 @@ LIBS=$ac_check_lib_save_LIBS + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 + $as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } +-if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then : ++if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then : + + TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" + TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" +@@ -3935,7 +5797,7 @@ $as_echo "#define HAVE_MYSQL 1" >>confde + + + else +- as_fn_error "MySQL support can't build without MySQL libraries" "$LINENO" 5 ++ as_fn_error $? "MySQL support can't build without MySQL libraries" "$LINENO" 5 + fi + + CFLAGS=$saved_CFLAGS +@@ -4018,8 +5880,8 @@ $as_echo "skipped" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers in $PGSQL_HEADERS" >&5 + $as_echo_n "checking for pgsql headers in $PGSQL_HEADERS... " >&6; } + # Manual detection for +- if test -f $PGSQL_HEADERS/libpq-fe.h; then +- PGSQL_INCDIR=$PGSQL_HEADERS ++ if test -f $PGSQL_HEADERS/libpq-fe.h; then ++ PGSQL_INCDIR=$PGSQL_HEADERS + fi + fi + +@@ -4037,386 +5899,118 @@ $as_echo "yes $PGSQL_INCDIR" >&6; } + + if test "${PGSQL_HEADERS}" = "yes"; then + +- # ******* Search pgsql libs ********* +- if test "${PGSQL_LIBS}" = "yes"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 +-$as_echo_n "checking autodect pgsql libs... " >&6; } +- # Autodetect +- PGSQL_INCLUDE="-I$PGSQL_INCDIR" +- PGSQL_LIBDIR=$PGSQL_DIR/lib +- +- if test -f /usr/lib64/libpq.so ; then +- PGSQL_LIBDIR=/usr/lib64 +- elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then +- PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql +- elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then +- PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql +- elif test -f $PGSQL_DIR/lib/libpq.so ; then +- PGSQL_LIBDIR=$PGSQL_DIR/lib +- else +- PGSQL_LIBDIR="" +- fi +- +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 +-$as_echo "$PGSQL_LIBDIR" >&6; } +- +- elif test "${PGSQL_LIBS}" = "no"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 +-$as_echo_n "checking for pgsql libs... " >&6; } +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 +-$as_echo "skipped" >&6; } +- else +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 +-$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } +- # Manual detection for +- if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then +- PGSQL_LIBDIR=$PGSQL_LIBS +- fi +- fi +- +- +- if test -z "$PGSQL_LIBDIR" ; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +-$as_echo "not found" >&6; } +- echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." +- else +- #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" +- saved_CFLAGS=$CFLAGS +- saved_LIBS=$LIBS +- CFLAGS="-I$PGSQL_INCDIR" +- LIBS="-L$PGSQL_LIBDIR" +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 +-$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } +-if test "${ac_cv_lib_pq_PQconnectStart+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- ac_check_lib_save_LIBS=$LIBS +-LIBS="-lpq $LIBS" +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-/* Override any GCC internal prototype to avoid an error. +- Use char because int might match the return type of a GCC +- builtin and then its argument prototype would still apply. */ +-#ifdef __cplusplus +-extern "C" +-#endif +-char PQconnectStart (); +-int +-main () +-{ +-return PQconnectStart (); +- ; +- return 0; +-} +-_ACEOF +-if ac_fn_c_try_link "$LINENO"; then : +- ac_cv_lib_pq_PQconnectStart=yes +-else +- ac_cv_lib_pq_PQconnectStart=no +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext conftest.$ac_ext +-LIBS=$ac_check_lib_save_LIBS +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 +-$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } +-if test "x$ac_cv_lib_pq_PQconnectStart" = x""yes; then : +- +- PGSQL_SUPPORT="yes" +- TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" +- TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" +- +-$as_echo "#define HAVE_PGSQL 1" >>confdefs.h +- +- +-else +- as_fn_error "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 +-fi +- +- LDFLAGS="" +- CFLAGS=$saved_CFLAGS +- LIBS=$saved_LIBS +- fi +- +- fi # end pgsql-include , pgsql-libs +- +-# end PostgreSQL detection +-fi +- +- +-#Checks for header files. +-ac_ext=c +-ac_cpp='$CPP $CPPFLAGS' +-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +-ac_compiler_gnu=$ac_cv_c_compiler_gnu +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +-$as_echo_n "checking how to run the C preprocessor... " >&6; } +-# On Suns, sometimes $CPP names a directory. +-if test -n "$CPP" && test -d "$CPP"; then +- CPP= +-fi +-if test -z "$CPP"; then +- if test "${ac_cv_prog_CPP+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- # Double quotes because CPP needs to be expanded +- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" +- do +- ac_preproc_ok=false +-for ac_c_preproc_warn_flag in '' yes +-do +- # Use a header file that comes with gcc, so configuring glibc +- # with a fresh cross-compiler works. +- # Prefer to if __STDC__ is defined, since +- # exists even on freestanding compilers. +- # On the NeXT, cc -E runs the code through the compiler's parser, +- # not just through cpp. "Syntax error" is here to catch this case. +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#ifdef __STDC__ +-# include +-#else +-# include +-#endif +- Syntax error +-_ACEOF +-if ac_fn_c_try_cpp "$LINENO"; then : +- +-else +- # Broken: fails on valid input. +-continue +-fi +-rm -f conftest.err conftest.$ac_ext +- +- # OK, works on sane cases. Now check whether nonexistent headers +- # can be detected and how. +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include +-_ACEOF +-if ac_fn_c_try_cpp "$LINENO"; then : +- # Broken: success on invalid input. +-continue +-else +- # Passes both tests. +-ac_preproc_ok=: +-break +-fi +-rm -f conftest.err conftest.$ac_ext +- +-done +-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +-rm -f conftest.err conftest.$ac_ext +-if $ac_preproc_ok; then : +- break +-fi +- +- done +- ac_cv_prog_CPP=$CPP +- +-fi +- CPP=$ac_cv_prog_CPP +-else +- ac_cv_prog_CPP=$CPP +-fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +-$as_echo "$CPP" >&6; } +-ac_preproc_ok=false +-for ac_c_preproc_warn_flag in '' yes +-do +- # Use a header file that comes with gcc, so configuring glibc +- # with a fresh cross-compiler works. +- # Prefer to if __STDC__ is defined, since +- # exists even on freestanding compilers. +- # On the NeXT, cc -E runs the code through the compiler's parser, +- # not just through cpp. "Syntax error" is here to catch this case. +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#ifdef __STDC__ +-# include +-#else +-# include +-#endif +- Syntax error +-_ACEOF +-if ac_fn_c_try_cpp "$LINENO"; then : +- +-else +- # Broken: fails on valid input. +-continue +-fi +-rm -f conftest.err conftest.$ac_ext +- +- # OK, works on sane cases. Now check whether nonexistent headers +- # can be detected and how. +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include +-_ACEOF +-if ac_fn_c_try_cpp "$LINENO"; then : +- # Broken: success on invalid input. +-continue +-else +- # Passes both tests. +-ac_preproc_ok=: +-break +-fi +-rm -f conftest.err conftest.$ac_ext +- +-done +-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +-rm -f conftest.err conftest.$ac_ext +-if $ac_preproc_ok; then : ++ # ******* Search pgsql libs ********* ++ if test "${PGSQL_LIBS}" = "yes"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 ++$as_echo_n "checking autodect pgsql libs... " >&6; } ++ # Autodetect ++ PGSQL_INCLUDE="-I$PGSQL_INCDIR" ++ PGSQL_LIBDIR=$PGSQL_DIR/lib + +-else +- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error "C preprocessor \"$CPP\" fails sanity check +-See \`config.log' for more details." "$LINENO" 5; } +-fi ++ if test -f /usr/lib64/libpq.so ; then ++ PGSQL_LIBDIR=/usr/lib64 ++ elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then ++ PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql ++ elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then ++ PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql ++ elif test -f $PGSQL_DIR/lib/libpq.so ; then ++ PGSQL_LIBDIR=$PGSQL_DIR/lib ++ else ++ PGSQL_LIBDIR="" ++ fi + +-ac_ext=c +-ac_cpp='$CPP $CPPFLAGS' +-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +-ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 ++$as_echo "$PGSQL_LIBDIR" >&6; } + ++ elif test "${PGSQL_LIBS}" = "no"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 ++$as_echo_n "checking for pgsql libs... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 ++$as_echo "skipped" >&6; } ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 ++$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } ++ # Manual detection for ++ if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then ++ PGSQL_LIBDIR=$PGSQL_LIBS ++ fi ++ fi + +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +-$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +-if test "${ac_cv_path_GREP+set}" = set; then : ++ ++ if test -z "$PGSQL_LIBDIR" ; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 ++$as_echo "not found" >&6; } ++ echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." ++ else ++ #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ CFLAGS="-I$PGSQL_INCDIR" ++ LIBS="-L$PGSQL_LIBDIR" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 ++$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } ++if ${ac_cv_lib_pq_PQconnectStart+:} false; then : + $as_echo_n "(cached) " >&6 + else +- if test -z "$GREP"; then +- ac_path_GREP_found=false +- # Loop through the user's path and test for each of PROGNAME-LIST +- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_prog in grep ggrep; do +- for ac_exec_ext in '' $ac_executable_extensions; do +- ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" +- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +-# Check for GNU ac_path_GREP and select it if it is found. +- # Check for GNU $ac_path_GREP +-case `"$ac_path_GREP" --version 2>&1` in +-*GNU*) +- ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +-*) +- ac_count=0 +- $as_echo_n 0123456789 >"conftest.in" +- while : +- do +- cat "conftest.in" "conftest.in" >"conftest.tmp" +- mv "conftest.tmp" "conftest.in" +- cp "conftest.in" "conftest.nl" +- $as_echo 'GREP' >> "conftest.nl" +- "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break +- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break +- as_fn_arith $ac_count + 1 && ac_count=$as_val +- if test $ac_count -gt ${ac_path_GREP_max-0}; then +- # Best one so far, save it but keep looking for a better one +- ac_cv_path_GREP="$ac_path_GREP" +- ac_path_GREP_max=$ac_count +- fi +- # 10*(2^10) chars as input seems more than enough +- test $ac_count -gt 10 && break +- done +- rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +-esac ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lpq $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ + +- $ac_path_GREP_found && break 3 +- done +- done +- done +-IFS=$as_save_IFS +- if test -z "$ac_cv_path_GREP"; then +- as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 +- fi ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char PQconnectStart (); ++int ++main () ++{ ++return PQconnectStart (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_pq_PQconnectStart=yes + else +- ac_cv_path_GREP=$GREP ++ ac_cv_lib_pq_PQconnectStart=no + fi +- ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +-$as_echo "$ac_cv_path_GREP" >&6; } +- GREP="$ac_cv_path_GREP" ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 ++$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } ++if test "x$ac_cv_lib_pq_PQconnectStart" = xyes; then : + ++ PGSQL_SUPPORT="yes" ++ TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" ++ TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" ++ ++$as_echo "#define HAVE_PGSQL 1" >>confdefs.h + +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +-$as_echo_n "checking for egrep... " >&6; } +-if test "${ac_cv_path_EGREP+set}" = set; then : +- $as_echo_n "(cached) " >&6 +-else +- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 +- then ac_cv_path_EGREP="$GREP -E" +- else +- if test -z "$EGREP"; then +- ac_path_EGREP_found=false +- # Loop through the user's path and test for each of PROGNAME-LIST +- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +-do +- IFS=$as_save_IFS +- test -z "$as_dir" && as_dir=. +- for ac_prog in egrep; do +- for ac_exec_ext in '' $ac_executable_extensions; do +- ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" +- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +-# Check for GNU ac_path_EGREP and select it if it is found. +- # Check for GNU $ac_path_EGREP +-case `"$ac_path_EGREP" --version 2>&1` in +-*GNU*) +- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +-*) +- ac_count=0 +- $as_echo_n 0123456789 >"conftest.in" +- while : +- do +- cat "conftest.in" "conftest.in" >"conftest.tmp" +- mv "conftest.tmp" "conftest.in" +- cp "conftest.in" "conftest.nl" +- $as_echo 'EGREP' >> "conftest.nl" +- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break +- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break +- as_fn_arith $ac_count + 1 && ac_count=$as_val +- if test $ac_count -gt ${ac_path_EGREP_max-0}; then +- # Best one so far, save it but keep looking for a better one +- ac_cv_path_EGREP="$ac_path_EGREP" +- ac_path_EGREP_max=$ac_count +- fi +- # 10*(2^10) chars as input seems more than enough +- test $ac_count -gt 10 && break +- done +- rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +-esac + +- $ac_path_EGREP_found && break 3 +- done +- done +- done +-IFS=$as_save_IFS +- if test -z "$ac_cv_path_EGREP"; then +- as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 +- fi + else +- ac_cv_path_EGREP=$EGREP ++ as_fn_error $? "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 + fi + +- fi ++ LDFLAGS="" ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++ fi ++ ++ fi # end pgsql-include , pgsql-libs ++ ++# end PostgreSQL detection + fi +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +-$as_echo "$ac_cv_path_EGREP" >&6; } +- EGREP="$ac_cv_path_EGREP" + + ++#Checks for header files. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 + $as_echo_n "checking for ANSI C header files... " >&6; } +-if test "${ac_cv_header_stdc+set}" = set; then : ++if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -4526,30 +6120,11 @@ $as_echo "#define STDC_HEADERS 1" >>conf + + fi + +-# On IRIX 5.3, sys/types and inttypes.h are conflicting. +-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ +- inttypes.h stdint.h unistd.h +-do : +- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +-" +-eval as_val=\$$as_ac_Header +- if test "x$as_val" = x""yes; then : +- cat >>confdefs.h <<_ACEOF +-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +-_ACEOF +- +-fi +- +-done +- +- + for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +-eval as_val=\$$as_ac_Header +- if test "x$as_val" = x""yes; then : ++if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF + #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 + _ACEOF +@@ -4562,7 +6137,7 @@ done + for ac_func in get_current_dir_name + do : + ac_fn_c_check_func "$LINENO" "get_current_dir_name" "ac_cv_func_get_current_dir_name" +-if test "x$ac_cv_func_get_current_dir_name" = x""yes; then : ++if test "x$ac_cv_func_get_current_dir_name" = xyes; then : + cat >>confdefs.h <<_ACEOF + #define HAVE_GET_CURRENT_DIR_NAME 1 + _ACEOF +@@ -4575,7 +6150,6 @@ done + SUPPORTED_V4L2=false + SUPPORTED_V4L2_old=false + +- + if test "${V4L}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 + $as_echo_n "checking for V42L support... " >&6; } +@@ -4585,7 +6159,7 @@ else + ac_fn_c_check_type "$LINENO" "struct v4l2_buffer" "ac_cv_type_struct_v4l2_buffer" "#include + #include + " +-if test "x$ac_cv_type_struct_v4l2_buffer" = x""yes; then : ++if test "x$ac_cv_type_struct_v4l2_buffer" = xyes; then : + SUPPORTED_V4L2=true + else + SUPPORTED_V4L2=false +@@ -4613,7 +6187,7 @@ $as_echo "testing" >&6; } + do : + ac_fn_c_check_header_compile "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "#include + " +-if test "x$ac_cv_header_linux_videodev2_h" = x""yes; then : ++if test "x$ac_cv_header_linux_videodev2_h" = xyes; then : + cat >>confdefs.h <<_ACEOF + #define HAVE_LINUX_VIDEODEV2_H 1 + _ACEOF +@@ -4640,7 +6214,7 @@ fi + # This bug is HP SR number 8606223364. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 + $as_echo_n "checking size of short... " >&6; } +-if test "${ac_cv_sizeof_short+set}" = set; then : ++if ${ac_cv_sizeof_short+:} false; then : + $as_echo_n "(cached) " >&6 + else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : +@@ -4649,9 +6223,8 @@ else + if test "$ac_cv_type_short" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "cannot compute sizeof (short) +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "cannot compute sizeof (short) ++See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_short=0 + fi +@@ -4674,7 +6247,7 @@ _ACEOF + # This bug is HP SR number 8606223364. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 + $as_echo_n "checking size of int... " >&6; } +-if test "${ac_cv_sizeof_int+set}" = set; then : ++if ${ac_cv_sizeof_int+:} false; then : + $as_echo_n "(cached) " >&6 + else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : +@@ -4683,9 +6256,8 @@ else + if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "cannot compute sizeof (int) +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "cannot compute sizeof (int) ++See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int=0 + fi +@@ -4708,7 +6280,7 @@ _ACEOF + # This bug is HP SR number 8606223364. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5 + $as_echo_n "checking size of long int... " >&6; } +-if test "${ac_cv_sizeof_long_int+set}" = set; then : ++if ${ac_cv_sizeof_long_int+:} false; then : + $as_echo_n "(cached) " >&6 + else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then : +@@ -4717,9 +6289,8 @@ else + if test "$ac_cv_type_long_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "cannot compute sizeof (long int) +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "cannot compute sizeof (long int) ++See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long_int=0 + fi +@@ -4742,7 +6313,7 @@ _ACEOF + # This bug is HP SR number 8606223364. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 + $as_echo_n "checking size of long long... " >&6; } +-if test "${ac_cv_sizeof_long_long+set}" = set; then : ++if ${ac_cv_sizeof_long_long+:} false; then : + $as_echo_n "(cached) " >&6 + else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : +@@ -4751,9 +6322,8 @@ else + if test "$ac_cv_type_long_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "cannot compute sizeof (long long) +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "cannot compute sizeof (long long) ++See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long_long=0 + fi +@@ -4776,7 +6346,7 @@ _ACEOF + # This bug is HP SR number 8606223364. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 + $as_echo_n "checking size of int *... " >&6; } +-if test "${ac_cv_sizeof_int_p+set}" = set; then : ++if ${ac_cv_sizeof_int_p+:} false; then : + $as_echo_n "(cached) " >&6 + else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : +@@ -4785,9 +6355,8 @@ else + if test "$ac_cv_type_int_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "cannot compute sizeof (int *) +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "cannot compute sizeof (int *) ++See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int_p=0 + fi +@@ -4810,7 +6379,7 @@ _ACEOF + # This bug is HP SR number 8606223364. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 + $as_echo_n "checking size of void *... " >&6; } +-if test "${ac_cv_sizeof_void_p+set}" = set; then : ++if ${ac_cv_sizeof_void_p+:} false; then : + $as_echo_n "(cached) " >&6 + else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : +@@ -4819,9 +6388,8 @@ else + if test "$ac_cv_type_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-{ as_fn_set_status 77 +-as_fn_error "cannot compute sizeof (void *) +-See \`config.log' for more details." "$LINENO" 5; }; } ++as_fn_error 77 "cannot compute sizeof (void *) ++See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_void_p=0 + fi +@@ -4875,7 +6443,7 @@ fi + # Checks for typedefs, structures, and compiler characteristics. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 + $as_echo_n "checking for an ANSI C-conforming const... " >&6; } +-if test "${ac_cv_c_const+set}" = set; then : ++if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +@@ -4884,11 +6452,11 @@ else + int + main () + { +-/* FIXME: Include the comments suggested by Paul. */ ++ + #ifndef __cplusplus +- /* Ultrix mips cc rejects this. */ ++ /* Ultrix mips cc rejects this sort of thing. */ + typedef int charset[2]; +- const charset cs; ++ const charset cs = { 0, 0 }; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; +@@ -4905,8 +6473,9 @@ main () + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; +- { /* SCO 3.2v4 cc rejects this. */ +- char *t; ++ { /* SCO 3.2v4 cc rejects this sort of thing. */ ++ char tx; ++ char *t = &tx; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; +@@ -4922,10 +6491,10 @@ main () + iptr p = 0; + ++p; + } +- { /* AIX XL C 1.02.0.0 rejects this saying ++ { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ +- struct s { int j; const int *ap[3]; }; +- struct s *b; b->j = 5; ++ struct s { int j; const int *ap[3]; } bx; ++ struct s *b = &bx; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +@@ -4992,6 +6561,7 @@ if test -e "/proc/cpuinfo" ; then + intel[152]="-march=pentium4" + intel[154]="-march=pentium4" + intel[614]="-march=prescott" ++ intel[628]="-march=core2" + amd[50]="-march=i586" + amd[51]="-march=i586" + amd[52]="-march=i586" +@@ -5063,6 +6633,9 @@ if test -e "/proc/cpuinfo" ; then + sse3) + CPU_FPU="-msse3" + ;; ++ ssse3) ++ CPU_FPU="-mfpmath=sse -msse2 -mssse3" ++ ;; + 3dnow) + CPU_EXT="$CPU_EXT -m3dnow" + ;; +@@ -5137,7 +6710,7 @@ if test "x${CPU_TYPE}" = "xunknown"; the + CPU_OPTIONS="-march=k6-3" + ;; + *) +- CPU_OPTIONS="" ++ CPU_OPTIONS="-march=native -mtune=native" + ;; + esac + fi +@@ -5205,7 +6778,7 @@ rm -f core conftest.err conftest.$ac_obj + + + if test "${DEVELOPER_FLAGS}" = "yes"; then +- TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3 " ++ TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" + fi + + CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" +@@ -5213,6 +6786,7 @@ CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU + LIBS="${TEMP_LIBS}" + LDFLAGS="${TEMP_LDFLAGS}" + ++ + # + # Add the right exec path for rc scripts + # +@@ -5234,7 +6808,6 @@ fi + + + +- + ac_config_files="$ac_config_files thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian motion.init-Fedora motion.spec Makefile" + + cat >confcache <<\_ACEOF +@@ -5301,10 +6874,21 @@ $as_echo "$as_me: WARNING: cache variabl + :end' >>confcache + if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then +- test "x$cache_file" != "x/dev/null" && ++ if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 + $as_echo "$as_me: updating cache $cache_file" >&6;} +- cat confcache >$cache_file ++ if test ! -f "$cache_file" || test -h "$cache_file"; then ++ cat confcache >"$cache_file" ++ else ++ case $cache_file in #( ++ */* | ?:*) ++ mv -f confcache "$cache_file"$$ && ++ mv -f "$cache_file"$$ "$cache_file" ;; #( ++ *) ++ mv -f confcache "$cache_file" ;; ++ esac ++ fi ++ fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 + $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} +@@ -5320,6 +6904,7 @@ DEFS=-DHAVE_CONFIG_H + + ac_libobjs= + ac_ltlibobjs= ++U= + for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' +@@ -5335,7 +6920,7 @@ LTLIBOBJS=$ac_ltlibobjs + + + +-: ${CONFIG_STATUS=./config.status} ++: "${CONFIG_STATUS=./config.status}" + ac_write_fail=0 + ac_clean_files_save=$ac_clean_files + ac_clean_files="$ac_clean_files $CONFIG_STATUS" +@@ -5436,6 +7021,7 @@ fi + IFS=" "" $as_nl" + + # Find who we are. Look in the path if we contain no directory separator. ++as_myself= + case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +@@ -5481,19 +7067,19 @@ export LANGUAGE + (unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +-# as_fn_error ERROR [LINENO LOG_FD] +-# --------------------------------- ++# as_fn_error STATUS ERROR [LINENO LOG_FD] ++# ---------------------------------------- + # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are + # provided, also output the error to LOG_FD, referencing LINENO. Then exit the +-# script with status $?, using 1 if that was 0. ++# script with STATUS, using 1 if that was 0. + as_fn_error () + { +- as_status=$?; test $as_status -eq 0 && as_status=1 +- if test "$3"; then +- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack +- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 ++ as_status=$1; test $as_status -eq 0 && as_status=1 ++ if test "$4"; then ++ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi +- $as_echo "$as_me: error: $1" >&2 ++ $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status + } # as_fn_error + +@@ -5631,16 +7217,16 @@ if (echo >conf$$.file) 2>/dev/null; then + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. +- # In both cases, we have to default to `cp -p'. ++ # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || +- as_ln_s='cp -p' ++ as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else +- as_ln_s='cp -p' ++ as_ln_s='cp -pR' + fi + else +- as_ln_s='cp -p' ++ as_ln_s='cp -pR' + fi + rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file + rmdir conf$$.dir 2>/dev/null +@@ -5689,7 +7275,7 @@ $as_echo X"$as_dir" | + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" +- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" ++ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + + } # as_fn_mkdir_p +@@ -5700,28 +7286,16 @@ else + as_mkdir_p=false + fi + +-if test -x / >/dev/null 2>&1; then +- as_test_x='test -x' +-else +- if ls -dL / >/dev/null 2>&1; then +- as_ls_L_option=L +- else +- as_ls_L_option= +- fi +- as_test_x=' +- eval sh -c '\'' +- if test -d "$1"; then +- test -d "$1/."; +- else +- case $1 in #( +- -*)set "./$1";; +- esac; +- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( +- ???[sx]*):;;*)false;;esac;fi +- '\'' sh +- ' +-fi +-as_executable_p=$as_test_x ++ ++# as_fn_executable_p FILE ++# ----------------------- ++# Test if FILE is an executable regular file. ++as_fn_executable_p () ++{ ++ test -f "$1" && test -x "$1" ++} # as_fn_executable_p ++as_test_x='test -x' ++as_executable_p=as_fn_executable_p + + # Sed expression to map a string onto a valid CPP name. + as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" +@@ -5742,8 +7316,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri + # 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 3.2.12, which was +-generated by GNU Autoconf 2.65. Invocation command line was ++This file was extended by motion $as_me 3.2.12-4ppa01, which was ++generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS +@@ -5804,11 +7378,11 @@ _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 3.2.12 +-configured by $0, generated by GNU Autoconf 2.65, ++motion config.status 3.2.12-4ppa01 ++configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +-Copyright (C) 2009 Free Software Foundation, Inc. ++Copyright (C) 2012 Free Software Foundation, Inc. + This config.status script is free software; the Free Software Foundation + gives unlimited permission to copy, distribute and modify it." + +@@ -5823,11 +7397,16 @@ ac_need_defaults=: + while test $# != 0 + do + case $1 in +- --*=*) ++ --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; ++ --*=) ++ ac_option=`expr "X$1" : 'X\([^=]*\)='` ++ ac_optarg= ++ ac_shift=: ++ ;; + *) + ac_option=$1 + ac_optarg=$2 +@@ -5849,6 +7428,7 @@ do + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; ++ '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; +@@ -5861,7 +7441,7 @@ do + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header +- as_fn_error "ambiguous option: \`$1' ++ as_fn_error $? "ambiguous option: \`$1' + Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; +@@ -5870,7 +7450,7 @@ Try \`$0 --help' for more information."; + ac_cs_silent=: ;; + + # This is an error. +- -*) as_fn_error "unrecognized option: \`$1' ++ -*) as_fn_error $? "unrecognized option: \`$1' + Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" +@@ -5890,7 +7470,7 @@ fi + _ACEOF + cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + if \$ac_cs_recheck; then +- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion ++ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' +@@ -5931,7 +7511,7 @@ do + "motion.spec") CONFIG_FILES="$CONFIG_FILES motion.spec" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + +- *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; ++ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac + done + +@@ -5953,9 +7533,10 @@ fi + # after its creation but before its name has been assigned to `$tmp'. + $debug || + { +- tmp= ++ tmp= ac_tmp= + trap 'exit_status=$? +- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ++ : "${ac_tmp:=$tmp}" ++ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + ' 0 + trap 'as_fn_exit 1' 1 2 13 15 + } +@@ -5963,12 +7544,13 @@ $debug || + + { + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && +- test -n "$tmp" && test -d "$tmp" ++ test -d "$tmp" + } || + { + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 ++} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ++ac_tmp=$tmp + + # Set up the scripts for CONFIG_FILES section. + # No need to generate them if there are no CONFIG_FILES. +@@ -5985,12 +7567,12 @@ if test "x$ac_cr" = x; then + fi + ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` + if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then +- ac_cs_awk_cr='\r' ++ ac_cs_awk_cr='\\r' + else + ac_cs_awk_cr=$ac_cr + fi + +-echo 'BEGIN {' >"$tmp/subs1.awk" && ++echo 'BEGIN {' >"$ac_tmp/subs1.awk" && + _ACEOF + + +@@ -5999,18 +7581,18 @@ _ACEOF + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" + } >conf$$subs.sh || +- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 +-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ++ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` + ac_delim='%!_!# ' + for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || +- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then +- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ++ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +@@ -6018,7 +7600,7 @@ done + rm -f conf$$subs.sh + + cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +-cat >>"\$tmp/subs1.awk" <<\\_ACAWK && ++cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && + _ACEOF + sed -n ' + h +@@ -6066,7 +7648,7 @@ t delim + rm -f conf$$subs.awk + cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + _ACAWK +-cat >>"\$tmp/subs1.awk" <<_ACAWK && ++cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +@@ -6098,21 +7680,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/n + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" + else + cat +-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ +- || as_fn_error "could not setup config files machinery" "$LINENO" 5 ++fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ ++ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 + _ACEOF + +-# VPATH may cause trouble with some makes, so we remove $(srcdir), +-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and ++# VPATH may cause trouble with some makes, so we remove sole $(srcdir), ++# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and + # trailing colons and then remove the whole line if VPATH becomes empty + # (actually we leave an empty line to preserve line numbers). + if test "x$srcdir" = x.; then +- ac_vpsub='/^[ ]*VPATH[ ]*=/{ +-s/:*\$(srcdir):*/:/ +-s/:*\${srcdir}:*/:/ +-s/:*@srcdir@:*/:/ +-s/^\([^=]*=[ ]*\):*/\1/ ++ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ ++h ++s/// ++s/^/:/ ++s/[ ]*$/:/ ++s/:\$(srcdir):/:/g ++s/:\${srcdir}:/:/g ++s/:@srcdir@:/:/g ++s/^:*// + s/:*$// ++x ++s/\(=[ ]*\).*/\1/ ++G ++s/\n// + s/^[^=]*=[ ]*$// + }' + fi +@@ -6124,7 +7714,7 @@ fi # test -n "$CONFIG_FILES" + # No need to generate them if there are no CONFIG_HEADERS. + # This happens for instance with `./config.status Makefile'. + if test -n "$CONFIG_HEADERS"; then +-cat >"$tmp/defines.awk" <<\_ACAWK || ++cat >"$ac_tmp/defines.awk" <<\_ACAWK || + BEGIN { + _ACEOF + +@@ -6136,11 +7726,11 @@ _ACEOF + # handling of long lines. + ac_delim='%!_!# ' + for ac_last_try in false false :; do +- ac_t=`sed -n "/$ac_delim/p" confdefs.h` +- if test -z "$ac_t"; then ++ ac_tt=`sed -n "/$ac_delim/p" confdefs.h` ++ if test -z "$ac_tt"; then + break + elif $ac_last_try; then +- as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 ++ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +@@ -6225,7 +7815,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_writ + _ACAWK + _ACEOF + cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +- as_fn_error "could not setup config headers machinery" "$LINENO" 5 ++ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 + fi # test -n "$CONFIG_HEADERS" + + +@@ -6238,7 +7828,7 @@ do + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; +- :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; ++ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac +@@ -6257,7 +7847,7 @@ do + for ac_f + do + case $ac_f in +- -) ac_f="$tmp/stdin";; ++ -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. +@@ -6266,7 +7856,7 @@ do + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || +- as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; ++ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" +@@ -6292,8 +7882,8 @@ $as_echo "$as_me: creating $ac_file" >&6 + esac + + case $ac_tag in +- *:-:* | *:-) cat >"$tmp/stdin" \ +- || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; ++ *:-:* | *:-) cat >"$ac_tmp/stdin" \ ++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac +@@ -6418,23 +8008,24 @@ s&@abs_builddir@&$ac_abs_builddir&;t t + s&@abs_top_builddir@&$ac_abs_top_builddir&;t t + $ac_datarootdir_hack + " +-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ +- || as_fn_error "could not create $ac_file" "$LINENO" 5 ++eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ ++ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + + test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && +- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && +- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && ++ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && ++ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ ++ "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +-which seems to be undefined. Please make sure it is defined." >&5 ++which seems to be undefined. Please make sure it is defined" >&5 + $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +-which seems to be undefined. Please make sure it is defined." >&2;} ++which seems to be undefined. Please make sure it is defined" >&2;} + +- rm -f "$tmp/stdin" ++ rm -f "$ac_tmp/stdin" + case $ac_file in +- -) cat "$tmp/out" && rm -f "$tmp/out";; +- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; ++ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; ++ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ +- || as_fn_error "could not create $ac_file" "$LINENO" 5 ++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # +@@ -6443,21 +8034,21 @@ which seems to be undefined. Please mak + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ +- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" +- } >"$tmp/config.h" \ +- || as_fn_error "could not create $ac_file" "$LINENO" 5 +- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then ++ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" ++ } >"$ac_tmp/config.h" \ ++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ++ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 + $as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" +- mv "$tmp/config.h" "$ac_file" \ +- || as_fn_error "could not create $ac_file" "$LINENO" 5 ++ mv "$ac_tmp/config.h" "$ac_file" \ ++ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ +- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ +- || as_fn_error "could not create -" "$LINENO" 5 ++ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ ++ || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + +@@ -6472,7 +8063,7 @@ _ACEOF + ac_clean_files=$ac_clean_files_save + + test $ac_write_fail = 0 || +- as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 ++ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + + # configure is writing to config.log, and then calls config.status. +@@ -6493,7 +8084,7 @@ if test "$no_create" != yes; then + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. +- $ac_cs_success || as_fn_exit $? ++ $ac_cs_success || as_fn_exit 1 + fi + if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +@@ -6502,92 +8093,104 @@ fi + + + echo "" +-echo " *******************************" +-echo " Configure status " ++echo " **************************" ++echo " Configure status " + echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" +-echo " *******************************" ++echo " **************************" + echo + + + if test "${Darwin}" != ""; then +- echo "OS : Darwin" ++ echo "OS : Darwin" + elif test "${FreeBSD}" != ""; then +- echo "OS : *BSD" ++ echo "OS : *BSD" + else +- echo "OS : Linux" ++ echo "OS : Linux" + fi + + if test "${PTHREAD_SUPPORT}" = "yes"; then +- echo "pthread Support: Yes" ++ echo "pthread support: Yes" + else +- echo "pthread Support: No" +- echo "**********************************************" +- echo "** Fatal Error YOU MUST HAVE pthread Support *" +- echo "**********************************************" ++ echo "pthread support: No" ++ echo "**********************************************" ++ echo "** Fatal Error YOU MUST HAVE pthread Support *" ++ echo "**********************************************" + fi + +-if test "${JPEG_SUPPORT_MMX}" = "yes"; then +- echo "jpeg-mmx Support: Yes" ++ ++if test "${JPEG_SUPPORT_TURBO}" = "yes"; then ++ echo "jpeg turbo support: Yes" ++elif test "${JPEG_SUPPORT_MMX}" = "yes"; then ++ echo "jpeg-mmx support: Yes" + elif test "${JPEG_SUPPORT}" = "yes"; then +- echo "jpeg Support: Yes" ++ echo "jpeg support: Yes" + else +- echo "jpeg Support: No" +- echo "**********************************************" +- echo "** Fatal Error YOU MUST HAVE jpeg Support ***" +- echo "**********************************************" ++ echo "jpeg support: No" ++ echo "**********************************************" ++ echo "** Fatal Error YOU MUST HAVE jpeg Support ***" ++ echo "**********************************************" + fi + + if test "${FreeBSD}" != ""; then + if test "${BKTR}" = "yes"; then +- echo "BKTR included: Yes" ++ echo "BKTR included: Yes" + else +- echo "BKTR included: No" ++ echo "BKTR included: No" + fi + + if test "${PWCBSD}" = "yes"; then +- echo "PWCBSD include: Yes" ++ echo "PWCBSD include: Yes" + else +- echo "PWCBSD include: No" ++ echo "PWCBSD include: No" + fi + + else + if test "${V4L}" = "yes"; then +- echo "V4L included: Yes" ++ echo "V4L support: Yes" + else +- echo "V4L included: No" ++ echo "V4L support: No" + fi + + if test x$SUPPORTED_V4L2 = xtrue; then +- echo "V4L2 supported: Yes" ++ echo "V4L2 support: Yes" + else +- echo "V4L2 supported: No" ++ echo "V4L2 support: No" + fi + fi + ++if test "${SDL_SUPPORT}" = "yes"; then ++ echo "SDL support: Yes" ++else ++ echo "SDL support: No" ++fi ++ + if test "${FFMPEG_OK}" = "found"; then +- echo "FFmpeg Support: Yes" ++ echo "FFmpeg support: Yes" ++else ++ echo "FFmpeg support: No" ++fi ++ ++if test "${SQLITE3_SUPPORT}" = "yes"; then ++ echo "SQLite3 support: Yes" + else +- echo "FFmpeg Support: No" ++ echo "SQLite3 support: No" + fi + + if test "${MYSQL_SUPPORT}" = "yes"; then +- echo "MYSQL Support: Yes" ++ echo "MYSQL support: Yes" + else +- echo "MYSQL Support: No" ++ echo "MYSQL support: No" + fi + + if test "${PGSQL_SUPPORT}" = "yes"; then +- echo "PostgreSQL Support: Yes" ++ echo "PostgreSQL support: Yes" + else +- echo "PostgreSQL Support: No" ++ echo "PostgreSQL support: No" + fi + echo +- + echo "CFLAGS: $CFLAGS" + echo "LIBS: $LIBS" + echo "LDFLAGS: $LDFLAGS" +- + echo + echo "Install prefix: $prefix" + echo +- +--- /dev/null ++++ motion-3.2.12/configure.ac +@@ -0,0 +1,1386 @@ ++# Process this file with autoconf to produce a configure script ++ ++AC_INIT(motion, esyscmd(['./version.sh'])) ++AC_GNU_SOURCE ++AC_CONFIG_SRCDIR([motion.c]) ++AC_CONFIG_HEADERS(config.h) ++AC_PROG_CC ++ ++ ++THREAD_CFLAGS="" ++THREAD_CHECK="/usr/include/pthread.h" ++ ++Darwin="" ++FreeBSD="" ++ ++LINUXTHREADS="no" ++AC_ARG_WITH(linuxthreads, ++[ --with-linuxthreads Use linuxthreads in BSD instead of native pthreads ++ ] ++ , ++LINUXTHREADS="$withval" ++) ++ ++PWCBSD="no" ++AC_ARG_WITH(pwcbsd, ++[ --with-pwcbsd Use pwcbsd based webcams ( only BSD ) ++] ++, ++PWCBSD="$withval" ++) ++ ++ ++AC_MSG_CHECKING(for Darwin) ++Darwin=`uname -a | grep "Darwin"` ++ ++if test "${Darwin}" = ""; then ++ AC_MSG_RESULT(no) ++ AC_MSG_CHECKING(for *BSD) ++ ++ FreeBSD=`uname -a | grep "BSD"` ++ if test "${FreeBSD}" = ""; then ++ AC_MSG_RESULT(no) ++ VIDEO="video.o video2.o video_common.o" ++ else ++ AC_MSG_RESULT(yes) ++ if test "${LINUXTHREADS}" = "no"; then ++ AC_MSG_CHECKING(Linuxthreads) ++ AC_MSG_RESULT(skipping) ++ else ++ THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" ++ THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" ++ fi ++ ++ if test "${PWCBSD}" != "no"; then ++ VIDEO="video.o video2.o video_common.o" ++ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" ++ else ++ VIDEO="video_freebsd.o" ++ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" ++ fi ++ ++ TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" ++ TEMP_LIBS="-L/usr/local/lib" ++ AC_MSG_RESULT(Build with PWCBSD support $PWCBSD) ++ ++ fi ++else ++ TEMP_CFLAGS="${CFLAGS} -I/sw/include" ++ TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" ++ TEMP_LIBS="-L/sw/lib" ++ VIDEO="video_freebsd.o" ++ FINK_LIB="-L/sw/lib" ++ Darwin="yes" ++ V4L="no" ++ AC_MSG_RESULT($Darwin) ++fi ++ ++ ++AC_SUBST(VIDEO) ++ ++# Checks for programs. ++AC_PROG_CC ++ ++TEMP_LIBS="-lm ${TEMP_LIBS}" ++TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" ++TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" ++ ++if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then ++ ++ AC_MSG_CHECKING(bktr headers in /usr/include/dev/bktr) ++ ++ if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then ++ AC_MSG_RESULT(yes) ++ else ++ AC_MSG_RESULT(no) ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" ++ fi ++# ++# Check to Exclude BKTR ++# ++BKTR="yes" ++AC_ARG_WITH(bktr, ++[ --without-bktr Exclude to use bktr subsystem , that usually useful ++ for devices as network cameras ( ONLY used in *BSD). ++ ] ++ , ++BKTR="$withval" ++) ++ ++ if test "${BKTR}" = "no"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" ++ fi ++ ++else ++ ++# ++# Check to Exclude V4L ++# ++V4L="yes" ++AC_ARG_WITH(v4l, ++[ --without-v4l Exclude using v4l (video4linux) subsystem. ++ Makes Motion so it only supports network cameras. ++ ], ++V4L="$withval" ++) ++ ++fi ++ ++ ++if test "${V4L}" = "no"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" ++fi ++ ++ ++if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then ++ ++AC_MSG_CHECKING(for linuxthreads) ++ ++# ++# Check for thread header ++# ++ if test -f "${THREAD_CHECK}"; then ++ HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" ++ THREADS="yes" ++ else ++ THREADS="no" ++ fi ++ ++# ++# Check for thread lib ++# ++ if test -f "${THREAD_LIB_CHECK}" ; then ++ THREADS="yes" ++ LIB_THREAD="-llthread -llgcc_r" ++ else ++ THREADS="no" ++ fi ++ ++# Checks for Library linuxthreads for FreeBSD ++# ++# linuxthreads on freeBSD, ports collection ++# /usr/local/include/pthreads/linuxthreads/pthread.h ++# #include ++# /usr/local/lib/libpthread.so ++# ++ ++ if test "${THREADS}" = "yes"; then ++ TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" ++ TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" ++ THREAD_CFLAGS="-D_THREAD_SAFE" ++ PTHREAD_SUPPORT="yes" ++ AC_MSG_RESULT($THREADS) ++ else ++ PTHREAD_SUPPORT="no" ++ AC_MSG_RESULT($THREADS) ++ echo ++ echo "You do not have linuxthread installed" ++ echo ++ fi ++ ++elif test -f "${THREAD_CHECK}"; then ++ ++ ++AC_MSG_CHECKING(threads) ++AC_TRY_LINK([#include ], ++[pthread_t th; pthread_join(th, 0); ++ pthread_attr_init(0); pthread_cleanup_push(0, 0); ++ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], ++ [PTHREAD_LIB=yes]) ++ ++if test x$PTHREAD_LIB != xyes; then ++ ++ if test "${FreeBSD}" != ""; then ++ TEMP_LIBS="$TEMP_LIBS -pthread" ++ TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" ++ else ++ TEMP_LIBS="$TEMP_LIBS -lpthread" ++ TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" ++ fi ++ PTHREAD_SUPPORT="yes" ++fi ++ AC_MSG_RESULT($PTHREAD_SUPPORT) ++ ++else ++ echo ++ echo "You do not have threads support" ++ echo ++fi ++ ++ ++# ++# Check for sdl library ++# ++SDL_SUPPORT="no" ++AC_ARG_WITH(sdl, ++[ --without-sdl Compile without sdl support to get stream in SDL window. ++], ++[], ++[]) ++AC_MSG_CHECKING(for sdl) ++if test "x$withval" = "xno"; then ++ AC_MSG_RESULT(skipped) ++else ++ if test "${FreeBSD}" != ""; then ++ CONFIG_SDL='sdl11-config' ++ else ++ CONFIG_SDL='sdl-config' ++ fi ++ if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then ++ AC_MSG_RESULT(no) ++ if test "$withval" = "yes"; then ++ echo "" ++ echo "****************************************************" ++ echo "* sdl-config could not be found. Please install it *" ++ echo "* and remove the --with-sdl configure argument. *" ++ echo "* libSDL can be found at http://www.libsdl.org *" ++ echo "****************************************************" ++ echo "" ++ fi ++ else ++ AC_MSG_RESULT(yes) ++ SDL_SUPPORT="yes" ++ TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" ++ TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" ++ AC_DEFINE([HAVE_SDL],1,[Define to 1 if you have SDL support]) ++ SDL_OBJ="sdl.o" ++ AC_SUBST(SDL_OBJ) ++ fi ++fi ++ ++# ++# Check for the libjpeg-turbo library ++# ++JPEG_TURBO="no" ++JPEG_TURBO_OK="not_found" ++ ++AC_ARG_WITH(jpeg-turbo, ++[ --with-jpeg-turbo[=DIR] Specify the prefix for the install path for ++ jpeg-turbo for optimized jpeg handling (optional). ++ ], ++JPEG_TURBO="$withval" ++) ++ ++if test "${JPEG_TURBO}" = "no"; then ++ AC_MSG_CHECKING(for libjpeg-turbo) ++ AC_MSG_RESULT(skipping) ++else ++ AC_MSG_CHECKING(for libjpeg-turbo in -> [${JPEG_TURBO}] <-) ++ if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then ++ AC_MSG_RESULT(found) ++ JPEG_TURBO_OK="found" ++ else ++ AC_MSG_RESULT(not found) ++ fi ++fi ++ ++ ++if test "${JPEG_TURBO_OK}" = "found"; then ++ saved_CFLAGS="$CFLAGS" ++ saved_LIBS="$LIBS" ++ saved_LDFLAGS="$LDFLAGS" ++ LDFLAGS="-L${JPEG_TURBO}/lib" ++ CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" ++ LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" ++ AC_CHECK_LIB(jpeg, jpeg_start_compress, ++ [ TEMP_LIBS="$LIBS" ++ TEMP_CFLAGS="${CFLAGS}" ++ TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" ++ JPEG_SUPPORT="yes"],,) ++ LIBS="$saved_LIBS" ++ CFLAGS="$saved_CFLAGS" ++ LDFLAGS="$saved_LDFLAGS" ++ JPEG_SUPPORT_TURBO="yes" ++fi ++ ++ ++# ++# Check for the special mmx accelerated jpeg library ++# ++JPEG_MMX="no" ++JPEG_MMX_OK="not_found" ++AC_ARG_WITH(jpeg-mmx, ++[ --with-jpeg-mmx[=DIR] Specify the prefix for the install path for ++ jpeg-mmx for optimized jpeg handling (optional). ++ If this is not specified motion will try to find ++ the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. ++ ], ++JPEG_MMX="$withval" ++) ++ ++# ++# --without-jpeg-mmx or with-jpeg-mmx=no ++# ++ ++if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then ++ AC_MSG_CHECKING(for libjpeg-mmx) ++ AC_MSG_RESULT(skipping) ++elif test "${JPEG_MMX}" = "yes"; then ++ # AUTODETECT STATIC LIB ++ AC_MSG_CHECKING(for libjpeg-mmx autodetecting) ++ ++ if test -f /usr/lib/libjpeg-mmx.a ; then ++ AC_MSG_RESULT(found) ++ JPEG_MMX_OK="found" ++ JPEG_MMX="/usr/lib" ++ elif test -f /usr/local/lib/libjpeg-mmx.a ; then ++ AC_MSG_RESULT(found) ++ JPEG_MMX_OK="found" ++ JPEG_MMX="/usr/local/lib" ++ else ++ AC_MSG_RESULT(not found) ++ fi ++else ++ AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) ++ if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then ++ AC_MSG_RESULT(found) ++ JPEG_MMX_OK="found" ++ else ++ AC_MSG_RESULT(not found) ++ fi ++fi ++ ++if test "${JPEG_MMX_OK}" = "found"; then ++ saved_CFLAGS="$CFLAGS" ++ saved_LIBS="$LIBS" ++ CFLAGS="$CFLAGS -I${JPEG_MMX}" ++ LIBS="$LIBS -L${JPEG_MMX}" ++ AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress, ++ [ TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" ++ TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" ++ JPEG_SUPPORT="yes"],,) ++ LIBS="$saved_LIBS" ++ CFLAGS="$saved_CFLAGS" ++ JPEG_SUPPORT_MMX="yes" ++fi ++ ++# ++# Look for _a_ jpeg lib that will work. ++# ++if test x$JPEG_SUPPORT != xyes ; then ++ # Checks for libraries ++ LDFLAGS=$TEMP_LDFLAGS ++ ++ AC_CHECK_LIB(jpeg, jpeg_set_defaults, [ ++ TEMP_LIBS="$TEMP_LIBS -ljpeg" ++ JPEG_SUPPORT="yes" ++ ], [ ++ echo ++ echo "You do not have libjpeg installed" ++ echo ++ ] ++ ) ++fi ++ ++ ++# ++# Check for libavcodec and libavformat from ffmpeg ++# ++ ++FFMPEG_DIR="yes" ++FFMPEG_OK="no_found" ++FFMPEG_OBJ="" ++AC_ARG_WITH(ffmpeg, ++[ --with-ffmpeg[=DIR] Specify the prefix for the install path for ++ libavcodec/libavformat (part of ffmpeg) be able to ++ encode mpeg movies realtime. ++ If this is not specified motion will try to find ++ the libraries in /usr and /usr/local. ++ ], ++FFMPEG_DIR="$withval" ++) ++ ++# ++# ffmpeg headers custom location ++# ++FFMPEG_HEADERS_DIR="yes" ++AC_ARG_WITH(ffmpeg_headers, ++[ --with-ffmpeg-headers[=DIR] Specify the prefix for ffmpeg headers. ++ ], ++FFMPEG_HEADERS_DIR="$withval" ++) ++ ++# ++# ffmpeg custom extra libraries ++# ++FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " ++AC_ARG_WITH(ffmpeg-libs, ++[ --with-ffmpeg-libs[=libs] Specify the extra libs for ffmpeg ++ ], ++FFMPEG_EXTRALIBS="$withval" ++) ++ ++# ++# --without-ffmpeg or with-ffmpeg=no ++# ++if test "${FFMPEG_DIR}" = "no"; then ++ AC_MSG_CHECKING(for ffmpeg) ++ AC_MSG_RESULT(skipping) ++# ++# with-ffmpeg= or nothing ++# ++else if test "${FFMPEG_DIR}" = "yes"; then ++ # AUTODETECT STATIC/SHARED LIB ++ AC_MSG_CHECKING(for ffmpeg autodetecting libraries) ++ ++ if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then ++ AC_MSG_RESULT(found in /usr/lib64) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib64" ++ FFMPEG_DIR="/usr" ++ elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then ++ AC_MSG_RESULT(found in /usr/lib) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib" ++ FFMPEG_DIR="/usr" ++ elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then ++ AC_MSG_RESULT(found in /usr/local/lib) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/local/lib" ++ FFMPEG_DIR="/usr/local" ++ elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then ++ AC_MSG_RESULT(found in /usr/lib/x86_64-linux-gnu) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" ++ FFMPEG_DIR="/usr" ++ elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then ++ AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="/usr/lib/i386-linux-gnu" ++ FFMPEG_DIR="/usr" ++ else ++ AC_MSG_RESULT(not found) ++ echo "" ++ echo "**********************************************" ++ echo "* libavcodec.a or libavcodec.so or *" ++ echo "* libavformat.a or libavformat.so not found: *" ++ echo "* ALL FFMPEG FEATURES DISABLED *" ++ echo "* *" ++ echo "* Please read the Motion Guide for help: *" ++ echo "* http://motion.sourceforge.net *" ++ echo "**********************************************" ++ echo "" ++ fi ++else ++ AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) ++ if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then ++ AC_MSG_RESULT(found) ++ FFMPEG_OK="found" ++ FFMPEG_LIB="${FFMPEG_DIR}/lib" ++ elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then ++ AC_MSG_RESULT(found) ++ FFMPEG_LIB="${FFMPEG_DIR}" ++ FFMPEG_OK="found" ++ else ++ AC_MSG_RESULT(not found) ++ if test "${FFMPEG_OK}" != "found"; then ++ echo "" ++ echo "**********************************************" ++ echo "* libavcodec.a or libavcodec.so or *" ++ echo "* libavformat.a or libavformat.so not found: *" ++ echo "* ALL FFMPEG FEATURES DISABLED *" ++ echo "* *" ++ echo "* Please read the Motion Guide for help: *" ++ echo "* http://motion.sourceforge.net *" ++ echo "**********************************************" ++ echo "" ++ fi ++ fi ++fi ++ ++ ++# ++# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found ++# ++ ++AVFORMAT_DIR="" ++ ++if test "${FFMPEG_OK}" = "found"; then ++ if test "${FFMPEG_HEADERS_DIR}" = "yes"; then ++ AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_DIR}) ++ AVFORMAT_DIR="${FFMPEG_DIR}" ++ else ++ AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_HEADERS_DIR}) ++ FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" ++ AVFORMAT_DIR="${FFMPEG_DIR}" ++ fi ++ ++ if test -f ${FFMPEG_DIR}/include/avformat.h; then ++ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/avformat.h) ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" ++ elif test -f ${FFMPEG_DIR}/avformat.h; then ++ AC_MSG_RESULT(found ${FFMPEG_DIR}/avformat.h) ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}" ++ AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" ++ elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then ++ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/avformat.h) ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" ++ elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then ++ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" ++ elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then ++ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" ++ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" ++ elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then ++ AC_MSG_RESULT(found ${FFMPEG_DIR}/libavformat/avformat.h) ++ FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" ++ AVFORMAT="-I{FFMPEG_DIR}/libavformat" ++ AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" ++ else ++ AC_MSG_RESULT(not found) ++ FFMPEG_OK="no_found" ++ AVFORMAT_DIR="avformat.h" ++ echo "**********************************************" ++ echo "* avformat.h not found: *" ++ echo "* ALL FFMPEG FEATURES DISABLED *" ++ echo "* *" ++ echo "* Please read the Motion Guide for help: *" ++ echo "* http://motion.sourceforge.net *" ++ echo "**********************************************" ++ echo "" ++ fi ++ ++# ++# If ffmpeg libs and headers have been found ++# ++ ++ if test "${FFMPEG_OK}" = "found"; then ++ TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" ++ TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" ++ ++ FFMPEG_OBJ="ffmpeg.o" ++ AC_SUBST(FFMPEG_OBJ) ++ ++ AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ ++ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" ++ LIBS="$TEMP_LIBS" ++ ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ++ [ ++ #include <${AVFORMAT_DIR}> ++ URLProtocol test_file_protocol; ++ int main(void){ ++ test_file_protocol.url_read = file_protocol.url_read; ++ return 0; ++ } ++ ]])], ++ [AC_MSG_RESULT(yes)], ++ [ ++ AC_MSG_RESULT(no) ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" ++ ] ++ ) ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++ fi ++fi ++fi ++ ++# Revised RTSP module so that it can be included ++# whether or not FFMPEG is found. ++ ++ RTPS_OBJ="netcam_rtsp.o" ++ AC_SUBST(RTPS_OBJ) ++ ++# ++# Check SQLITE3 ++# ++ ++SQLITE3_SUPPORT="no" ++AC_ARG_WITH(sqlite3, ++ [ --without-sqlite3 Disable sqlite3 support in motion. ++ ], ++ SQLITE3="$withval" ++ # if not given argument, assume standard ++) ++ ++if test "${SQLITE3}" = "no"; then ++ AC_MSG_CHECKING(for sqlite3) ++ AC_MSG_RESULT(skipping) ++else ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ ++ AC_CHECK_LIB(sqlite3, sqlite3_open, ++ [ ++ TEMP_LIBS="$TEMP_LIBS -lsqlite3" ++ SQLITE3_SUPPORT="yes" ++ AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 support]) ++ ] ++ ) ++ ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++fi ++ ++ ++# ++# Check Mysql ++# ++ ++MYSQL="yes" ++MYSQL_SUPPORT="no" ++MYSQL_HEADERS="yes" ++MYSQL_LIBS="yes" ++ ++AC_MSG_CHECKING(for mysql support) ++ ++AC_ARG_WITH(mysql, ++[ --without-mysql Disable mysql support in motion. ++ ], ++MYSQL="$withval" ++# if not given argument, assume standard ++) ++ ++AC_ARG_WITH(mysql-lib, ++[ --with-mysql-lib[=DIR] Normally, configure will scan all possible default ++ installation paths for mysql libs. When it fails, use ++ this command to tell configure where mysql libs ++ installation root directory is. ++ ], ++MYSQL_LIBS="$withval" ++# if not given argument, assume standard ++) ++ ++ ++AC_ARG_WITH(mysql-include, ++[ --with-mysql-include[=DIR] Normally, configure will scan all possible default ++ installation paths for mysql include. When it fails, use ++ this command to tell configure where mysql include ++ installation root directory is. ++ ], ++MYSQL_HEADERS="$withval" ++# if not given argument, assume standard ++) ++ ++ ++if test "${MYSQL}" = "no"; then ++ AC_MSG_RESULT(skipped) ++else ++ AC_MSG_RESULT(testing) ++ # ******* Search mysql headers ******* ++ ++ if test "${MYSQL_HEADERS}" = "yes"; then ++ AC_MSG_CHECKING(autodect mysql headers) ++ # Autodetect ++ for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do ++ # check for plain setups ++ if test -f $w/mysql.h; then ++ MYSQL_INCDIR=$w ++ break ++ fi ++ # check for "/usr/include/" type setups ++ if test -f $w/mysql/mysql.h; then ++ MYSQL_INCDIR=$w/mysql ++ break ++ fi ++ # check for "/usr//include" type setups ++ if test -f $w/mysql/include/mysql.h; then ++ MYSQL_INCDIR=$w/mysql/include ++ break ++ fi ++ done ++ elif test "${MYSQL_HEADERS}" = "no"; then ++ AC_MSG_CHECKING(for mysql headers) ++ AC_MSG_RESULT(skipped) ++ else ++ AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) ++ # Manual detection for ++ if test -f $MYSQL_HEADERS/mysql.h; then ++ MYSQL_INCDIR=$MYSQL_HEADERS ++ fi ++ fi ++ ++ if test -z "$MYSQL_INCDIR" ; then ++ MYSQL_HEADERS="no" ++ AC_MSG_RESULT(not found) ++ echo "Invalid MySQL directory - unable to find mysql.h." ++ else ++ AC_MSG_RESULT($MYSQL_INCDIR yes) ++ MYSQL_HEADERS="yes" ++ fi ++ ++ ++ if test "${MYSQL_HEADERS}" = "yes"; then ++ ++ # ******* Search mysql libs ********* ++ if test "${MYSQL_LIBS}" = "yes"; then ++ AC_MSG_CHECKING(autodect mysql libs) ++ # Autodetect ++ for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do ++ # check for plain setups ++ if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then ++ MYSQL_LIBDIR=$w ++ break ++ fi ++ # check for "/usr/lib/" type setups ++ if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then ++ MYSQL_LIBDIR=$w/mysql ++ break ++ fi ++ # check for "/usr//lib" type setups ++ if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then ++ MYSQL_LIBDIR=$w/mysql/lib ++ break ++ fi ++ done ++ elif test "${MYSQL_LIBS}" = "no"; then ++ AC_MSG_CHECKING(for mysql libs) ++ AC_MSG_RESULT(skipped) ++ else ++ AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) ++ # Manual detection for ++ if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then ++ MYSQL_LIBDIR=$MYSQL_LIBS ++ fi ++ fi ++ ++ ++ if test -z "$MYSQL_LIBDIR" ; then ++ AC_MSG_RESULT(not found) ++ echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." ++ else ++ AC_MSG_RESULT($MYSQL_LIBDIR) ++ #LDFLAGS="-L$MYSQL_LIBDIR" ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ CFLAGS="-I$MYSQL_INCDIR" ++ LIBS="-L$MYSQL_LIBDIR" ++ AC_CHECK_LIB(mysqlclient,mysql_init,[ ++ TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" ++ TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" ++ MYSQL_SUPPORT="yes" ++ AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) ++ ], ++ AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++ fi ++ ++ # end mysql-include , mysql-libs ++ fi ++ ++# end Mysql detection ++fi ++ ++ ++# ++# Check PostgreSQL ++# ++PGSQL="yes" ++PGSQL_SUPPORT="no" ++PGSQL_HEADERS="yes" ++PGSQL_LIBS="yes" ++ ++AC_DEFUN([PGSQL_INC_CHK],[if test -r $i$1/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i$1]) ++ ++AC_ARG_WITH(pgsql, ++[ --without-pgsql Disable PostgreSQL support in motion. ++ ], ++PGSQL="$withval" ++# if not given argument, assume standard ++) ++ ++AC_ARG_WITH(pgsql-lib, ++[ --with-pgsql-lib[=DIR] Normally, configure will scan all possible default ++ installation paths for pgsql libs. When it fails, use ++ this command to tell configure where pgsql libs ++ installation root directory is. ++ ], ++PGSQL_LIBS="$withval" ++# if not given argument, assume standard ++) ++ ++AC_ARG_WITH(pgsql-include, ++[ --with-pgsql-include[=DIR] Normally, configure will scan all possible default ++ installation paths for pgsql include. When it fails, use ++ this command to tell configure where pgsql include ++ installation root directory is. ++ ], ++PGSQL_HEADERS="$withval" ++# if not given argument, assume standard ++) ++ ++AC_MSG_CHECKING(for PostgreSQL) ++ ++if test "${PGSQL}" = "no"; then ++ AC_MSG_RESULT(skipped) ++else ++ AC_MSG_RESULT(testing) ++ ++ # ******* Search pgsql headers ******* ++ if test "${PGSQL_HEADERS}" = "yes"; then ++ ++ AC_MSG_CHECKING(autodect pgsql headers) ++ # Autodetect ++ for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do ++ PGSQL_INC_CHK(/include) ++ el[]PGSQL_INC_CHK(/include/pgsql) ++ el[]PGSQL_INC_CHK(/include/postgresql) ++ fi ++ done ++ ++ elif test "${PGSQL_HEADERS}" = "no"; then ++ AC_MSG_CHECKING(for pgsql headers) ++ AC_MSG_RESULT(skipped) ++ else ++ AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) ++ # Manual detection for ++ if test -f $PGSQL_HEADERS/libpq-fe.h; then ++ PGSQL_INCDIR=$PGSQL_HEADERS ++ fi ++ fi ++ ++ if test -z "$PGSQL_INCDIR" ; then ++ PGSQL_HEADERS="no" ++ AC_MSG_RESULT(not found) ++ echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." ++ else ++ AC_MSG_RESULT(yes [$PGSQL_INCDIR]) ++ PGSQL_HEADERS="yes" ++ fi ++ ++ ++ if test "${PGSQL_HEADERS}" = "yes"; then ++ ++ # ******* Search pgsql libs ********* ++ if test "${PGSQL_LIBS}" = "yes"; then ++ AC_MSG_CHECKING(autodect pgsql libs) ++ # Autodetect ++ PGSQL_INCLUDE="-I$PGSQL_INCDIR" ++ PGSQL_LIBDIR=$PGSQL_DIR/lib ++ ++ if test -f /usr/lib64/libpq.so ; then ++ PGSQL_LIBDIR=/usr/lib64 ++ elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then ++ PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql ++ elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then ++ PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql ++ elif test -f $PGSQL_DIR/lib/libpq.so ; then ++ PGSQL_LIBDIR=$PGSQL_DIR/lib ++ else ++ PGSQL_LIBDIR="" ++ fi ++ ++ AC_MSG_RESULT($PGSQL_LIBDIR) ++ ++ elif test "${PGSQL_LIBS}" = "no"; then ++ AC_MSG_CHECKING(for pgsql libs) ++ AC_MSG_RESULT(skipped) ++ else ++ AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) ++ # Manual detection for ++ if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then ++ PGSQL_LIBDIR=$PGSQL_LIBS ++ fi ++ fi ++ ++ ++ if test -z "$PGSQL_LIBDIR" ; then ++ AC_MSG_RESULT(not found) ++ echo "Invalid PostgreSQL directory [$PGSQL_LIBDIR] - unable to find libpq.a or libpq.so." ++ else ++ #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" ++ saved_CFLAGS=$CFLAGS ++ saved_LIBS=$LIBS ++ CFLAGS="-I$PGSQL_INCDIR" ++ LIBS="-L$PGSQL_LIBDIR" ++ AC_CHECK_LIB(pq, PQconnectStart, [ ++ PGSQL_SUPPORT="yes" ++ TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" ++ TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" ++ AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) ++ ], ++ AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) ++ LDFLAGS="" ++ CFLAGS=$saved_CFLAGS ++ LIBS=$saved_LIBS ++ fi ++ ++ fi # end pgsql-include , pgsql-libs ++ ++# end PostgreSQL detection ++fi ++ ++ ++#Checks for header files. ++AC_HEADER_STDC ++AC_CHECK_HEADERS(stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h) ++ ++AC_CHECK_FUNCS(get_current_dir_name) ++ ++# Check if v4l2 is available ++SUPPORTED_V4L2=false ++SUPPORTED_V4L2_old=false ++ ++if test "${V4L}" = "no"; then ++ AC_MSG_CHECKING(for V42L support) ++ AC_MSG_RESULT(skipping) ++else ++ AC_CHECK_TYPE([struct v4l2_buffer], ++ [SUPPORTED_V4L2=true], ++ [SUPPORTED_V4L2=false], ++ [#include ++ #include ]) ++ ++ AC_MSG_CHECKING(for V42L support) ++ if test x$SUPPORTED_V4L2 = xtrue; then ++ AC_MSG_RESULT(yes) ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" ++ else ++ AC_MSG_RESULT(no) ++ fi ++ ++ # linux/videodev.h doesn't include videodev2.h ++ if test x$SUPPORTED_V4L2 = xfalse; then ++ AC_MSG_CHECKING(for V42L *old* support) ++ AC_MSG_RESULT(testing) ++ AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) ++ fi ++ ++ ++ if test x$SUPPORTED_V4L2_old = xtrue; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" ++ SUPPORTED_V4L2=true ++ fi ++ ++fi ++ ++ ++# Check sizes of integer types ++AC_CHECK_SIZEOF(short) ++AC_CHECK_SIZEOF(int) ++AC_CHECK_SIZEOF(long int) ++AC_CHECK_SIZEOF(long long) ++AC_CHECK_SIZEOF(int *) ++AC_CHECK_SIZEOF(void *) ++ ++if test "$ac_cv_sizeof_short" = "4"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" ++else ++ if test "$ac_cv_sizeof_int" = "4"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" ++ else ++ if test "$ac_cv_sizeof_long_int" = "4"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" ++ fi ++ fi ++fi ++ ++ ++OPTIMIZECPU="yes" ++ ++AC_ARG_WITH(optimizecpu, ++[ --without-optimizecpu Exclude autodetecting platform and cpu type. ++ This will disable the compilation of gcc ++ optimizing code by platform and cpu. ++ ], ++OPTIMIZECPU="$withval" ++) ++ ++DEVELOPER_FLAGS="no" ++ ++AC_ARG_WITH(developer-flags, ++[ --with-developer-flags Causes practically all of the possible gcc ++ warning flags to be set. This may produce ++ a large amount of warnings.], ++DEVELOPER_FLAGS="$withval" ++) ++ ++# Checks for typedefs, structures, and compiler characteristics. ++AC_C_CONST ++ ++if test "${FreeBSD}" != ""; then ++ OPTIMIZECPU="" ++fi ++ ++if test "${OPTIMIZECPU}" = "yes"; then ++ ++# Try to autodetect cpu type ++CPU_NAME="unknown" ++CPU_TYPE="unknown" ++if test -e "/proc/cpuinfo" ; then ++ intel[[30]]="-march=i386" ++ intel[[32]]="-march=i386" ++ intel[[34]]="-march=i386" ++ intel[[40]]="-march=i486" ++ intel[[41]]="-march=i486" ++ intel[[42]]="-march=i486" ++ intel[[43]]="-march=i486" ++ intel[[44]]="-march=i486" ++ intel[[45]]="-march=i486" ++ intel[[47]]="-march=i486" ++ intel[[48]]="-march=i486" ++ intel[[51]]="-march=pentium" ++ intel[[52]]="-march=pentium" ++ intel[[54]]="-march=pentium-mmx" ++ intel[[56]]="-march=pentium-mmx" ++ intel[[61]]="-march=pentiumpro" ++ intel[[63]]="-march=pentium2" ++ intel[[65]]="-march=pentium2" ++ intel[[66]]="-march=pentium2" ++ intel[[67]]="-march=pentium3" ++ intel[[68]]="-march=pentium3" ++ intel[[610]]="-march=pentium3" ++ intel[[611]]="-march=pentium3" ++ intel[[150]]="-march=pentium4" ++ intel[[151]]="-march=pentium4" ++ intel[[152]]="-march=pentium4" ++ intel[[154]]="-march=pentium4" ++ intel[[614]]="-march=prescott" ++ intel[[628]]="-march=core2" ++ amd[[50]]="-march=i586" ++ amd[[51]]="-march=i586" ++ amd[[52]]="-march=i586" ++ amd[[53]]="-march=i586" ++ amd[[56]]="-march=k6" ++ amd[[57]]="-march=k6" ++ amd[[58]]="-march=k6-2" ++ amd[[510]]="-march=k6-2" ++ amd[[59]]="-march=k6-3" ++ amd[[513]]="-march=k6-3" ++ amd[[61]]="-march=athlon" ++ amd[[62]]="-march=athlon" ++ amd[[63]]="-march=athlon" ++ amd[[64]]="-march=athlon" ++ amd[[66]]="-march=athlon" ++ amd[[67]]="-march=athlon" ++ amd[[68]]="-march=athlon" ++ amd[[610]]="-march=athlon" ++ amd[[158]]="-march=athlon-xp" ++ amd[[154]]="-march=k8" ++ amd[[155]]="-march=athlon64" ++ amd[[1543]]="-march=athlon64" ++ amd[[1544]]="-march=athlon64" ++ amd[[1565]]="-march=opteron" ++ amd[[1572]]="-march=k8" ++ via[[67]]="-march=c3" ++ via[[68]]="-march=c3" ++ via[[69]]="-march=i686" ++ via[[610]]="-march=i686" ++ ++ CPU_TYPE="known" ++ CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` ++ CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` ++ CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` ++ CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` ++ CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` ++ CPU_FAMILY=${CPU_FAMILY#*: } ++ CPU_MODEL=${CPU_MODEL#*: } ++ CPU_NAME=${CPU_NAME#*: } ++ CPU_FLAGS=${CPU_FLAGS#*: } ++ CPU_VENDOR=${CPU_VENDOR#*: } ++ if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then ++ CPU_OPTIONS=${intel[[$CPU_FAMILY$CPU_MODEL]]} ++ fi ++ if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then ++ CPU_OPTIONS=${amd[[$CPU_FAMILY$CPU_MODEL]]} ++ fi ++ if test "x${CPU_VENDOR}" = "xCentaurHauls"; then ++ CPU_OPTIONS=${via[[$CPU_FAMILY$CPU_MODEL]]} ++ fi ++ if test "x${CPU_OPTIONS}" = "x" ; then ++ CPU_TYPE="unknown" ++ fi ++ CPU_EXT="" ++ for i in $CPU_FLAGS ; do ++ case $i in ++ fpu) ++ CPU_FPU="-mfpmath=387" ++ ;; ++ mmx) ++ CPU_EXT="$CPU_EXT -mmmx" ++ ;; ++ sse) ++ CPU_FPU="-mfpmath=sse -msse" ++ ;; ++ sse2) ++ CPU_FPU="-mfpmath=sse -msse2" ++ ;; ++ sse3) ++ CPU_FPU="-msse3" ++ ;; ++ ssse3) ++ CPU_FPU="-mfpmath=sse -msse2 -mssse3" ++ ;; ++ 3dnow) ++ CPU_EXT="$CPU_EXT -m3dnow" ++ ;; ++ esac ++ done ++ CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" ++fi ++if test "x${CPU_TYPE}" = "xunknown"; then ++ CPU_TYPE=`( uname -p ) 2>&1` ++ case $CPU_TYPE in ++ i386) ++ CPU_OPTIONS="-march=i386" ++ ;; ++ i486) ++ CPU_OPTIONS="-march=i486" ++ ;; ++ Pentium2) ++ CPU_OPTIONS="-march=pentium2" ++ ;; ++ Pentiumpro) ++ CPU_OPTIONS="-march=pentiumpro" ++ ;; ++ Pentium*) ++ CPU_OPTIONS="-march=pentium" ++ ;; ++ k6) ++ CPU_OPTIONS="-march=k6" ++ ;; ++ k6-2) ++ CPU_OPTIONS="-march=k6-2" ++ ;; ++ k6-3) ++ CPU_OPTIONS="-march=k6-3" ++ ;; ++ "VIA C3 Ezra") ++ CPU_OPTIONS="-march=c3" ++ CPU_TYPE="known" ++ ;; ++ *) ++ CPU_OPTIONS="" ++ CPU_TYPE="unknown" ++ ;; ++ esac ++ if test "x${CPU_TYPE}" = "xunknown"; then ++ CPU_TYPE=`( uname -m ) 2>&1` ++ case $CPU_TYPE in ++ i386) ++ CPU_OPTIONS="-march=i386" ++ ;; ++ i486) ++ CPU_OPTIONS="-march=i486" ++ ;; ++ i586) ++ CPU_OPTIONS="-march=i586" ++ ;; ++ i686) ++ CPU_OPTIONS="-march=i686" ++ ;; ++ Pentium2) ++ CPU_OPTIONS="-march=pentium2" ++ ;; ++ Pentiumpro) ++ CPU_OPTIONS="-march=pentiumpro" ++ ;; ++ k6) ++ CPU_OPTIONS="-march=k6" ++ ;; ++ k6-2) ++ CPU_OPTIONS="-march=k6-2" ++ ;; ++ k6-3) ++ CPU_OPTIONS="-march=k6-3" ++ ;; ++ *) ++ CPU_OPTIONS="-march=native -mtune=native" ++ ;; ++ esac ++ fi ++fi ++echo "Detected CPU: $CPU_NAME" ++# Now we check if the compiler supports the detected cpu ++COMPILER=$CC ++for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do ++ test "$I" && break ++done ++TMPC="$I/cpu_test-$RANDOM-$$.c" ++TMPO="$I/cpu_test-$RANDOM-$$.o" ++cat > $TMPC << EOF ++int main(void) { return 0; } ++EOF ++( $COMPILER $CPU_OPTIONS -o $TMPO $TMPC ) 2>&1 ++TMP="$?" ++rm -f $TMPO ++rm -f $TMPC ++ ++ ++if test "x${TMP}" = "x1" ; then ++ CPU_OPTIONS="" ++ echo "No CPU optimizations will be added" ++else ++ echo "CPU optimization: $CPU_OPTIONS" ++fi ++ ++else ++ CPU_OPTIONS="" ++fi ++ ++ ++AC_MSG_CHECKING(for bswap instruction) ++AC_LINK_IFELSE([ ++ AC_LANG_PROGRAM([ ], ++ [unsigned int __x=0; ++ register unsigned int __v; ++ __asm("bswap %0" : "=r" (__v) : "0" (__x));]) ++ ], ++ [ ++ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" ++ AC_MSG_RESULT(yes) ++ ], ++ [ ++ AC_MSG_RESULT(no) ++ ]) ++ ++ ++if test "${DEVELOPER_FLAGS}" = "yes"; then ++ TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" ++fi ++ ++CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" ++ ++LIBS="${TEMP_LIBS}" ++LDFLAGS="${TEMP_LDFLAGS}" ++ ++ ++# ++# Add the right exec path for rc scripts ++# ++if test $prefix = "NONE";then ++ BIN_PATH="$ac_default_prefix" ++ if test $exec_prefix = "NONE"; then ++ BIN_PATH="$BIN_PATH/bin" ++ else ++ BIN_PATH="$BIN_PATH/$bindir" ++ fi ++else ++ if test $exec_prefix = "NONE";then ++ BIN_PATH="$prefix/bin" ++ else ++ BIN_PATH="$prefix/$bindir" ++ fi ++fi ++ ++ ++AC_SUBST(BIN_PATH) ++ ++AC_CONFIG_FILES([ ++thread1.conf ++thread2.conf ++thread3.conf ++thread4.conf ++motion-dist.conf ++motion.init-FreeBSD.sh ++motion.init-Debian ++motion.init-Fedora ++motion.spec ++Makefile ++]) ++AC_OUTPUT ++ ++echo "" ++echo " **************************" ++echo " Configure status " ++echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" ++echo " **************************" ++echo ++ ++ ++if test "${Darwin}" != ""; then ++ echo "OS : Darwin" ++elif test "${FreeBSD}" != ""; then ++ echo "OS : *BSD" ++else ++ echo "OS : Linux" ++fi ++ ++if test "${PTHREAD_SUPPORT}" = "yes"; then ++ echo "pthread support: Yes" ++else ++ echo "pthread support: No" ++ echo "**********************************************" ++ echo "** Fatal Error YOU MUST HAVE pthread Support *" ++ echo "**********************************************" ++fi ++ ++ ++if test "${JPEG_SUPPORT_TURBO}" = "yes"; then ++ echo "jpeg turbo support: Yes" ++elif test "${JPEG_SUPPORT_MMX}" = "yes"; then ++ echo "jpeg-mmx support: Yes" ++elif test "${JPEG_SUPPORT}" = "yes"; then ++ echo "jpeg support: Yes" ++else ++ echo "jpeg support: No" ++ echo "**********************************************" ++ echo "** Fatal Error YOU MUST HAVE jpeg Support ***" ++ echo "**********************************************" ++fi ++ ++if test "${FreeBSD}" != ""; then ++ if test "${BKTR}" = "yes"; then ++ echo "BKTR included: Yes" ++ else ++ echo "BKTR included: No" ++ fi ++ ++ if test "${PWCBSD}" = "yes"; then ++ echo "PWCBSD include: Yes" ++ else ++ echo "PWCBSD include: No" ++ fi ++ ++else ++ if test "${V4L}" = "yes"; then ++ echo "V4L support: Yes" ++ else ++ echo "V4L support: No" ++ fi ++ ++ if test x$SUPPORTED_V4L2 = xtrue; then ++ echo "V4L2 support: Yes" ++ else ++ echo "V4L2 support: No" ++ fi ++fi ++ ++if test "${SDL_SUPPORT}" = "yes"; then ++ echo "SDL support: Yes" ++else ++ echo "SDL support: No" ++fi ++ ++if test "${FFMPEG_OK}" = "found"; then ++ echo "FFmpeg support: Yes" ++else ++ echo "FFmpeg support: No" ++fi ++ ++if test "${SQLITE3_SUPPORT}" = "yes"; then ++ echo "SQLite3 support: Yes" ++else ++ echo "SQLite3 support: No" ++fi ++ ++if test "${MYSQL_SUPPORT}" = "yes"; then ++ echo "MYSQL support: Yes" ++else ++ echo "MYSQL support: No" ++fi ++ ++if test "${PGSQL_SUPPORT}" = "yes"; then ++ echo "PostgreSQL support: Yes" ++else ++ echo "PostgreSQL support: No" ++fi ++echo ++echo "CFLAGS: $CFLAGS" ++echo "LIBS: $LIBS" ++echo "LDFLAGS: $LDFLAGS" ++echo ++echo "Install prefix: $prefix" ++echo +--- motion-3.2.12.orig/draw.c ++++ motion-3.2.12/draw.c +@@ -12,7 +12,7 @@ + #include + #include "motion.h" + +-/* highest ascii value is 126 (~) */ ++/* Highest ascii value is 126 (~) */ + #define ASCII_MAX 127 + + unsigned char *small_char_arr_ptr[ASCII_MAX]; +@@ -1075,8 +1075,10 @@ struct draw_char draw_table[]= { + struct big_char big_table[sizeof(draw_table) / sizeof(struct draw_char)]; + + #define NEWLINE "\\n" +- +-static int draw_textn (unsigned char *image, int startx, int starty, int width, const char *text, int len, unsigned short int factor) ++/** ++ * draw_textn ++ */ ++static int draw_textn(unsigned char *image, unsigned int startx, unsigned int starty, unsigned int width, const char *text, int len, unsigned int factor) + { + int pos, x, y, line_offset, next_char_offs; + unsigned char *image_ptr, *char_ptr, **char_arr_ptr; +@@ -1084,9 +1086,6 @@ static int draw_textn (unsigned char *im + if (startx > width / 2) + startx -= len * (6 * (factor + 1)); + +- if (startx < 0) +- startx = 0; +- + if (startx + len * 6 * (factor + 1) >= width) + len = (width-startx-1)/(6*(factor+1)); + +@@ -1098,10 +1097,19 @@ static int draw_textn (unsigned char *im + char_arr_ptr = factor ? big_char_arr_ptr : small_char_arr_ptr; + + for (pos = 0; pos < len; pos++) { +- char_ptr = char_arr_ptr[(int)text[pos]]; ++ int pos_check = (int)text[pos]; ++ ++ char_ptr = char_arr_ptr[pos_check]; + + for (y = 8 * (factor + 1); y--;) { + for (x = 7 * (factor + 1); x--;) { ++ ++ if (pos_check < 0) { ++ image_ptr++; ++ char_ptr++; ++ continue; ++ } ++ + switch(*char_ptr) { + case 1: + *image_ptr = 0; +@@ -1124,13 +1132,16 @@ static int draw_textn (unsigned char *im + return 0; + } + +-int draw_text (unsigned char *image, int startx, int starty, int width, const char *text, unsigned short int factor) ++/** ++ * draw_text ++ */ ++int draw_text(unsigned char *image, unsigned int startx, unsigned int starty, unsigned int width, const char *text, unsigned int factor) + { + int num_nl = 0; + const char *end, *begin; + const int line_space = (factor + 1) * 9; + +- /* Count the number of newlines in "text" so we scroll it up the image */ ++ /* Count the number of newlines in "text" so we scroll it up the image. */ + end = text; + + while ((end = strstr(end, NEWLINE))) { +@@ -1139,6 +1150,7 @@ int draw_text (unsigned char *image, int + } + + starty -= line_space * num_nl; ++ + begin = end = text; + + while ((end = strstr(end, NEWLINE))) { +@@ -1155,6 +1167,9 @@ int draw_text (unsigned char *image, int + return 0; + } + ++/** ++ * initialize_chars ++ */ + int initialize_chars(void) + { + unsigned int i, x, y; +@@ -1167,19 +1182,19 @@ int initialize_chars(void) + big_table[i].ascii = draw_table[i].ascii; + + for(x = 0; x < 14; x++) { +- for(y = 0; y < 16; y++) ++ for(y = 0; y < 16; y++) + big_table[i].pix[y][x] = draw_table[i].pix[y / 2][x / 2]; + + } + } + +- /* first init all char ptr's to a space character */ ++ /* First init all char ptr's to a space character. */ + for (i = 0; i < ASCII_MAX; i++) { + small_char_arr_ptr[i] = &draw_table[0].pix[0][0]; + big_char_arr_ptr[i] = &big_table[0].pix[0][0]; + } + +- /* build [big_]char_arr_ptr table to point to each available ascii */ ++ /* Build [big_]char_arr_ptr table to point to each available ascii. */ + for (i = 0; i < draw_table_size; i++) { + small_char_arr_ptr[(int)draw_table[i].ascii] = &draw_table[i].pix[0][0]; + big_char_arr_ptr[(int)draw_table[i].ascii] = &big_table[i].pix[0][0]; +--- motion-3.2.12.orig/event.c ++++ motion-3.2.12/event.c +@@ -6,34 +6,33 @@ + Copyright Jeroen Vreeken, 2002 + This software is distributed under the GNU Public License Version 2 + see also the file 'COPYING'. +- + */ + + #include "ffmpeg.h" /* must be first to avoid 'shadow' warning */ +-#include "picture.h" /* already includes motion.h */ ++#include "picture.h" /* already includes motion.h */ + #include "event.h" +-#if !defined(BSD) ++#if (!defined(BSD)) + #include "video.h" + #endif + +-/* +- * Various functions (most doing the actual action) +- */ ++/* Various functions (most doing the actual action) */ + +-/* Execute 'command' with 'arg' as its argument. +- * if !arg command is started with no arguments +- * Before we call execl we need to close all the file handles +- * that the fork inherited from the parent in order not to pass +- * the open handles on to the shell ++/** ++ * exec_command ++ * Execute 'command' with 'arg' as its argument. ++ * if !arg command is started with no arguments ++ * Before we call execl we need to close all the file handles ++ * that the fork inherited from the parent in order not to pass ++ * the open handles on to the shell + */ + static void exec_command(struct context *cnt, char *command, char *filename, int filetype) + { + char stamp[PATH_MAX]; + mystrftime(cnt, stamp, sizeof(stamp), command, &cnt->current_image->timestamp_tm, filename, filetype); +- ++ + if (!fork()) { + int i; +- ++ + /* Detach from parent */ + setsid(); + +@@ -43,27 +42,30 @@ static void exec_command(struct context + */ + for (i = getdtablesize(); i > 2; --i) + close(i); +- ++ + execl("/bin/sh", "sh", "-c", stamp, " &", NULL); + + /* if above function succeeds the program never reach here */ +- motion_log(LOG_ERR, 1, "Unable to start external command '%s'", stamp); ++ MOTION_LOG(ALR, TYPE_EVENTS, SHOW_ERRNO, "%s: Unable to start external command '%s'", ++ stamp); + + exit(1); +- } else if (cnt->conf.setup_mode) { +- motion_log(-1, 0, "Executing external command '%s'", stamp); +- } ++ } ++ ++ MOTION_LOG(DBG, TYPE_EVENTS, NO_ERRNO, "%s: Executing external command '%s'", ++ stamp); + } + +-/* +- * Event handlers ++/* ++ * Event handlers + */ + + static void event_newfile(struct context *cnt ATTRIBUTE_UNUSED, + int type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, + char *filename, void *ftype, struct tm *tm ATTRIBUTE_UNUSED) + { +- motion_log(-1, 0, "File of type %ld saved to: %s", (unsigned long)ftype, filename); ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: File of type %ld saved to: %s", ++ (unsigned long)ftype, filename); + } + + +@@ -77,17 +79,19 @@ static void event_beep(struct context *c + printf("\a"); + } + +-/* on_picture_save_command handles both on_picture_save and on_movie_start +- * If arg = FTYPE_IMAGE_ANY on_picture_save script is executed +- * If arg = FTYPE_MPEG_ANY on_movie_start script is executed +- * The scripts are executed with the filename of picture or movie appended +- * to the config parameter. ++/** ++ * on_picture_save_command ++ * handles both on_picture_save and on_movie_start ++ * If arg = FTYPE_IMAGE_ANY on_picture_save script is executed ++ * If arg = FTYPE_MPEG_ANY on_movie_start script is executed ++ * The scripts are executed with the filename of picture or movie appended ++ * to the config parameter. + */ + static void on_picture_save_command(struct context *cnt, + int type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, + char *filename, void *arg, struct tm *tm ATTRIBUTE_UNUSED) + { +- int filetype = (unsigned long)arg; ++ int filetype = (unsigned long)arg; + + if ((filetype & FTYPE_IMAGE_ANY) != 0 && cnt->conf.on_picture_save) + exec_command(cnt, cnt->conf.on_picture_save, filename, filetype); +@@ -105,7 +109,7 @@ static void on_motion_detected_command(s + exec_command(cnt, cnt->conf.on_motion_detected, NULL, 0); + } + +-#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) + + static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *dummy ATTRIBUTE_UNUSED, +@@ -114,66 +118,102 @@ static void event_sqlnewfile(struct cont + int sqltype = (unsigned long)arg; + + /* Only log the file types we want */ +- if (!(cnt->conf.mysql_db || cnt->conf.pgsql_db) || (sqltype & cnt->sql_mask) == 0) ++ if (!(cnt->conf.database_type) || (sqltype & cnt->sql_mask) == 0) + return; + +- /* We place the code in a block so we only spend time making space in memory ++ /* ++ * We place the code in a block so we only spend time making space in memory + * for the sqlquery and timestr when we actually need it. + */ + { + char sqlquery[PATH_MAX]; +- +- mystrftime(cnt, sqlquery, sizeof(sqlquery), cnt->conf.sql_query, +- &cnt->current_image->timestamp_tm, filename, sqltype); +- +-#ifdef HAVE_MYSQL +- if (cnt->conf.mysql_db) { +- int ret; + +- ret = mysql_query(cnt->database, sqlquery); ++ mystrftime(cnt, sqlquery, sizeof(sqlquery), cnt->conf.sql_query, ++ &cnt->current_image->timestamp_tm, filename, sqltype); + +- if (ret != 0) { ++#ifdef HAVE_MYSQL ++ if (!strcmp(cnt->conf.database_type, "mysql")) { ++ if (mysql_query(cnt->database, sqlquery) != 0) { + int error_code = mysql_errno(cnt->database); +- +- motion_log(LOG_ERR, 1, "Mysql query failed %s error code %d", ++ ++ MOTION_LOG(ERR, TYPE_DB, SHOW_ERRNO, "%s: Mysql query failed %s error code %d", + mysql_error(cnt->database), error_code); + /* Try to reconnect ONCE if fails continue and discard this sql query */ + if (error_code >= 2000) { ++ // Close connection before start a new connection ++ mysql_close(cnt->database); ++ + cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); + mysql_init(cnt->database); + +- if (!mysql_real_connect(cnt->database, cnt->conf.mysql_host, +- cnt->conf.mysql_user, cnt->conf.mysql_password, +- cnt->conf.mysql_db, 0, NULL, 0)) { +- motion_log(LOG_ERR, 0, "Cannot reconnect to MySQL database %s on host %s with user %s", +- cnt->conf.mysql_db, cnt->conf.mysql_host, cnt->conf.mysql_user); +- motion_log(LOG_ERR, 0, "MySQL error was %s", mysql_error(cnt->database)); +- } else { +- mysql_query(cnt->database, sqlquery); +- } +- } +- +- } ++ if (!mysql_real_connect(cnt->database, cnt->conf.database_host, ++ cnt->conf.database_user, cnt->conf.database_password, ++ cnt->conf.database_dbname, 0, NULL, 0)) { ++ MOTION_LOG(ALR, TYPE_DB, NO_ERRNO, "%s: Cannot reconnect to MySQL" ++ " database %s on host %s with user %s MySQL error was %s", ++ cnt->conf.database_dbname, ++ cnt->conf.database_host, cnt->conf.database_user, ++ mysql_error(cnt->database)); ++ } else { ++ 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_my = 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_my); ++ } ++ } ++ } ++ } + } + #endif /* HAVE_MYSQL */ + + #ifdef HAVE_PGSQL +- if (cnt->conf.pgsql_db) { ++ if (!strcmp(cnt->conf.database_type, "postgresql")) { + PGresult *res; + + res = PQexec(cnt->database_pg, sqlquery); + +- if (PQresultStatus(res) != PGRES_COMMAND_OK) { +- motion_log(LOG_ERR, 1, "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 */ + ++#ifdef HAVE_SQLITE3 ++ if ((!strcmp(cnt->conf.database_type, "sqlite3")) && (cnt->conf.sqlite3_db)) { ++ int res; ++ char *errmsg = 0; ++ res = sqlite3_exec(cnt->database_sqlite3, sqlquery, NULL, 0, &errmsg); ++ if (res != SQLITE_OK ) { ++ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: SQLite error was %s", ++ errmsg); ++ sqlite3_free(errmsg); ++ } ++ } ++#endif /* HAVE_SQLITE3 */ + } + } + +-#endif /* defined HAVE_MYSQL || defined HAVE_PGSQL */ ++#endif /* defined HAVE_MYSQL || defined HAVE_PGSQL || defined(HAVE_SQLITE3) */ + + static void on_area_command(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *dummy1 ATTRIBUTE_UNUSED, +@@ -202,41 +242,50 @@ static void on_event_end_command(struct + exec_command(cnt, cnt->conf.on_event_end, NULL, 0); + } + +-static void event_stop_webcam(struct context *cnt, int type ATTRIBUTE_UNUSED, ++static void event_stop_stream(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *dummy1 ATTRIBUTE_UNUSED, + char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, + struct tm *tm ATTRIBUTE_UNUSED) + { +- if ((cnt->conf.webcam_port) && (cnt->webcam.socket != -1)) +- webcam_stop(cnt); +- ++ if ((cnt->conf.stream_port) && (cnt->stream.socket != -1)) ++ stream_stop(cnt); + } + +-static void event_webcam_put(struct context *cnt, int type ATTRIBUTE_UNUSED, ++static void event_stream_put(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, + void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) + { +- if (cnt->conf.webcam_port) +- webcam_put(cnt, img); ++ if (cnt->conf.stream_port) ++ stream_put(cnt, img); + } + +-#if !defined(WITHOUT_V4L) && !defined(BSD) ++#ifdef HAVE_SDL ++static void event_sdl_put(struct context *cnt, int type ATTRIBUTE_UNUSED, ++ unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, ++ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) ++{ ++ sdl_put(img, cnt->imgs.width, cnt->imgs.height); ++} ++#endif ++ ++ ++#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) + static void event_vid_putpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *img, char *dummy ATTRIBUTE_UNUSED, void *devpipe, + struct tm *tm ATTRIBUTE_UNUSED) + { + if (*(int *)devpipe >= 0) { + if (vid_putpipe(*(int *)devpipe, img, cnt->imgs.size) == -1) +- motion_log(LOG_ERR, 1, "Failed to put image into video pipe"); ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Failed to put image into video pipe"); + } + } +-#endif /* WITHOUT_V4L && !BSD */ +- ++#endif /* !WITHOUT_V4L && !BSD */ + + const char *imageext(struct context *cnt) + { +- if (cnt->conf.ppm) ++ if (cnt->imgs.picture_type == IMAGE_TYPE_PPM) + return "ppm"; ++ + return "jpg"; + } + +@@ -248,17 +297,20 @@ static void event_image_detect(struct co + char filename[PATH_MAX]; + + if (cnt->new_img & NEWIMG_ON) { +- const char *jpegpath; ++ const char *imagepath; + +- /* conf.jpegpath would normally be defined but if someone deleted it by control interface +- it is better to revert to the default than fail */ +- if (cnt->conf.jpegpath) +- jpegpath = cnt->conf.jpegpath; ++ /* ++ * conf.imagepath would normally be defined but if someone deleted it by control interface ++ * it is better to revert to the default than fail ++ */ ++ if (cnt->conf.imagepath) ++ imagepath = cnt->conf.imagepath; + else +- jpegpath = DEF_JPEGPATH; +- +- mystrftime(cnt, filename, sizeof(filename), jpegpath, currenttime_tm, NULL, 0); ++ imagepath = DEF_IMAGEPATH; ++ ++ mystrftime(cnt, filename, sizeof(filename), imagepath, currenttime_tm, NULL, 0); + snprintf(fullfilename, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filename, imageext(cnt)); ++ + put_picture(cnt, fullfilename, newimg, FTYPE_IMAGE); + } + } +@@ -267,22 +319,24 @@ static void event_imagem_detect(struct c + unsigned char *newimg ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, + void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) + { +- struct config *conf=&cnt->conf; ++ struct config *conf = &cnt->conf; + char fullfilenamem[PATH_MAX]; + char filename[PATH_MAX]; + char filenamem[PATH_MAX]; + + if (conf->motion_img) { +- const char *jpegpath; ++ const char *imagepath; + +- /* conf.jpegpath would normally be defined but if someone deleted it by control interface +- it is better to revert to the default than fail */ +- if (cnt->conf.jpegpath) +- jpegpath = cnt->conf.jpegpath; ++ /* ++ * conf.imagepath would normally be defined but if someone deleted it by control interface ++ * it is better to revert to the default than fail ++ */ ++ if (cnt->conf.imagepath) ++ imagepath = cnt->conf.imagepath; + else +- jpegpath = DEF_JPEGPATH; +- +- mystrftime(cnt, filename, sizeof(filename), jpegpath, currenttime_tm, NULL, 0); ++ imagepath = DEF_IMAGEPATH; ++ ++ mystrftime(cnt, filename, sizeof(filename), imagepath, currenttime_tm, NULL, 0); + /* motion images gets same name as normal images plus an appended 'm' */ + snprintf(filenamem, PATH_MAX, "%sm", filename); + snprintf(fullfilenamem, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filenamem, imageext(cnt)); +@@ -302,25 +356,30 @@ static void event_image_snapshot(struct + char filepath[PATH_MAX]; + char linkpath[PATH_MAX]; + const char *snappath; +- /* conf.snappath would normally be defined but if someone deleted it by control interface +- it is better to revert to the default than fail */ ++ /* ++ * conf.snappath would normally be defined but if someone deleted it by control interface ++ * it is better to revert to the default than fail ++ */ + if (cnt->conf.snappath) + snappath = cnt->conf.snappath; + else + snappath = DEF_SNAPPATH; +- ++ + mystrftime(cnt, filepath, sizeof(filepath), snappath, currenttime_tm, NULL, 0); + snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); + snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); + put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); + +- /* Update symbolic link *after* image has been written so that +- the link always points to a valid file. */ ++ /* ++ * Update symbolic link *after* image has been written so that ++ * the link always points to a valid file. ++ */ + snprintf(linkpath, PATH_MAX, "%s/lastsnap.%s", cnt->conf.filepath, imageext(cnt)); + remove(linkpath); + + if (symlink(filename, linkpath)) { +- motion_log(LOG_ERR, 1, "Could not create symbolic link [%s]", filename); ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Could not create symbolic link [%s]", ++ filename); + return; + } + } else { +@@ -340,13 +399,6 @@ static void event_camera_lost(struct con + exec_command(cnt, cnt->conf.on_camera_lost, NULL, 0); + } + +-#ifdef HAVE_FFMPEG +-static void grey2yuv420p(unsigned char *u, unsigned char *v, int width, int height) +-{ +- memset(u, 128, width * height / 4); +- memset(v, 128, width * height / 4); +-} +- + static void on_movie_end_command(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *dummy ATTRIBUTE_UNUSED, char *filename, + void *arg, struct tm *tm ATTRIBUTE_UNUSED) +@@ -357,6 +409,134 @@ static void on_movie_end_command(struct + exec_command(cnt, cnt->conf.on_movie_end, filename, filetype); + } + ++static void event_extpipe_end(struct context *cnt, int type ATTRIBUTE_UNUSED, ++ unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, ++ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) ++{ ++ if (cnt->extpipe_open) { ++ cnt->extpipe_open = 0; ++ fflush(cnt->extpipe); ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: CLOSING: extpipe file desc %d, error state %d", ++ fileno(cnt->extpipe), ferror(cnt->extpipe)); ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: pclose return: %d", ++ pclose(cnt->extpipe)); ++ event(cnt, EVENT_FILECLOSE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL); ++ } ++} ++ ++static void event_create_extpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, ++ unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, ++ void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) ++{ ++ if ((cnt->conf.useextpipe) && (cnt->conf.extpipe)) { ++ char stamp[PATH_MAX] = ""; ++ const char *moviepath; ++ FILE *fd_dummy = NULL; ++ ++ /* ++ * conf.mpegpath would normally be defined but if someone deleted it by control interface ++ * it is better to revert to the default than fail ++ */ ++ if (cnt->conf.moviepath) { ++ moviepath = cnt->conf.moviepath; ++ } else { ++ moviepath = DEF_MOVIEPATH; ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: moviepath: %s", ++ moviepath); ++ } ++ ++ mystrftime(cnt, stamp, sizeof(stamp), moviepath, currenttime_tm, NULL, 0); ++ snprintf(cnt->extpipefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); ++ ++ /* Open a dummy file to check if path is correct */ ++ fd_dummy = myfopen(cnt->extpipefilename, "w", 0); ++ ++ /* TODO: trigger some warning instead of only log an error message */ ++ if (fd_dummy == NULL) { ++ /* Permission denied */ ++ if (errno == EACCES) { ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: error opening file %s ..." ++ "check access rights to target directory", ++ cnt->extpipefilename); ++ return ; ++ } else { ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: error opening file %s", ++ cnt->extpipefilename); ++ return ; ++ } ++ ++ } ++ ++ myfclose(fd_dummy); ++ unlink(cnt->extpipefilename); ++ ++ mystrftime(cnt, stamp, sizeof(stamp), cnt->conf.extpipe, currenttime_tm, cnt->extpipefilename, 0); ++ ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: pipe: %s", ++ stamp); ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: cnt->moviefps: %d", ++ cnt->movie_fps); ++ ++ event(cnt, EVENT_FILECREATE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL); ++ cnt->extpipe = popen(stamp, "w"); ++ ++ if (cnt->extpipe == NULL) { ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: popen failed"); ++ return; ++ } ++ ++ setbuf(cnt->extpipe, NULL); ++ cnt->extpipe_open = 1; ++ } ++} ++ ++static void event_extpipe_put(struct context *cnt, int type ATTRIBUTE_UNUSED, ++ unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, ++ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) ++{ ++ /* Check use_extpipe enabled and ext_pipe not NULL */ ++ if ((cnt->conf.useextpipe) && (cnt->extpipe != NULL)) { ++ MOTION_LOG(DBG, TYPE_EVENTS, NO_ERRNO, "%s:"); ++ ++ /* Check that is open */ ++ if ((cnt->extpipe_open) && (fileno(cnt->extpipe) > 0)) { ++ if (!fwrite(img, cnt->imgs.size, 1, cnt->extpipe)) ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Error writting in pipe , state error %d", ++ ferror(cnt->extpipe)); ++ } else { ++ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO, "%s: pipe %s not created or closed already ", ++ cnt->extpipe); ++ } ++ } ++} ++ ++ ++static void event_new_video(struct context *cnt, int type ATTRIBUTE_UNUSED, ++ unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, ++ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) ++{ ++ cnt->movie_last_shot = -1; ++ ++ cnt->movie_fps = cnt->lastrate; ++ ++ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s FPS %d", ++ cnt->movie_fps); ++ ++ if (cnt->movie_fps > 30) ++ cnt->movie_fps = 30; ++ else if (cnt->movie_fps < 2) ++ cnt->movie_fps = 2; ++} ++ ++#ifdef HAVE_FFMPEG ++ ++static void grey2yuv420p(unsigned char *u, unsigned char *v, int width, int height) ++{ ++ memset(u, 128, width * height / 4); ++ memset(v, 128, width * height / 4); ++} ++ ++ + static void event_ffmpeg_newfile(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, + void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) +@@ -364,30 +544,33 @@ static void event_ffmpeg_newfile(struct + int width = cnt->imgs.width; + int height = cnt->imgs.height; + unsigned char *convbuf, *y, *u, *v; +- int fps = 0; + char stamp[PATH_MAX]; +- const char *mpegpath; ++ const char *moviepath; + +- if (!cnt->conf.ffmpeg_cap_new && !cnt->conf.ffmpeg_cap_motion) ++ if (!cnt->conf.ffmpeg_output && !cnt->conf.ffmpeg_output_debug) + return; +- +- /* conf.mpegpath would normally be defined but if someone deleted it by control interface +- it is better to revert to the default than fail */ +- if (cnt->conf.mpegpath) +- mpegpath = cnt->conf.mpegpath; ++ ++ /* ++ * conf.mpegpath would normally be defined but if someone deleted it by control interface ++ * it is better to revert to the default than fail ++ */ ++ if (cnt->conf.moviepath) ++ moviepath = cnt->conf.moviepath; + else +- mpegpath = DEF_MPEGPATH; ++ moviepath = DEF_MOVIEPATH; + +- mystrftime(cnt, stamp, sizeof(stamp), mpegpath, currenttime_tm, NULL, 0); ++ mystrftime(cnt, stamp, sizeof(stamp), moviepath, currenttime_tm, NULL, 0); + +- /* motion mpegs get the same name as normal mpegs plus an appended 'm' */ +- /* PATH_MAX - 4 to allow for .mpg to be appended without overflow */ ++ /* ++ * motion movies get the same name as normal movies plus an appended 'm' ++ * PATH_MAX - 4 to allow for .mpg to be appended without overflow ++ */ + snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%sm", cnt->conf.filepath, stamp); + snprintf(cnt->newfilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); + +- if (cnt->conf.ffmpeg_cap_new) { ++ if (cnt->conf.ffmpeg_output) { + if (cnt->imgs.type == VIDEO_PALETTE_GREY) { +- convbuf=mymalloc((width * height) / 2); ++ convbuf = mymalloc((width * height) / 2); + y = img; + u = convbuf; + v = convbuf + (width * height) / 4; +@@ -399,29 +582,21 @@ static void event_ffmpeg_newfile(struct + v = u + (width * height) / 4; + } + +- fps = cnt->lastrate; +- +- if (debug_level >= CAMERA_DEBUG) +- motion_log(LOG_DEBUG, 0, "%s FPS %d",__FUNCTION__, fps); +- +- if (fps > 30) +- fps = 30; +- else if (fps < 2) +- fps = 2; +- +- if ((cnt->ffmpeg_new = +- ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->newfilename, y, u, v, +- cnt->imgs.width, cnt->imgs.height, fps, cnt->conf.ffmpeg_bps, ++ if ((cnt->ffmpeg_output = ++ ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->newfilename, y, u, v, ++ cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, + cnt->conf.ffmpeg_vbr)) == NULL) { +- motion_log(LOG_ERR, 1, "ffopen_open error creating (new) file [%s]",cnt->newfilename); ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (new) file [%s]", ++ cnt->newfilename); + cnt->finish = 1; + return; + } +- ((struct ffmpeg *)cnt->ffmpeg_new)->udata=convbuf; ++ ++ ((struct ffmpeg *)cnt->ffmpeg_output)->udata = convbuf; + event(cnt, EVENT_FILECREATE, NULL, cnt->newfilename, (void *)FTYPE_MPEG, NULL); + } + +- if (cnt->conf.ffmpeg_cap_motion) { ++ if (cnt->conf.ffmpeg_output_debug) { + if (cnt->imgs.type == VIDEO_PALETTE_GREY) { + convbuf = mymalloc((width * height) / 2); + y = cnt->imgs.out; +@@ -430,30 +605,22 @@ static void event_ffmpeg_newfile(struct + grey2yuv420p(u, v, width, height); + } else { + y = cnt->imgs.out; +- u = cnt->imgs.out + width * height; ++ u = cnt->imgs.out + width *height; + v = u + (width * height) / 4; + convbuf = NULL; + } + +- if (debug_level >= CAMERA_DEBUG) +- motion_log(LOG_DEBUG, 0, "%s FPS %d", __FUNCTION__, fps); +- +- fps = cnt->lastrate; +- +- if (fps > 30) +- fps = 30; +- else if (fps < 2) +- fps = 2; +- +- if ((cnt->ffmpeg_motion = +- ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->motionfilename, y, u, v, +- cnt->imgs.width, cnt->imgs.height, fps, cnt->conf.ffmpeg_bps, ++ if ((cnt->ffmpeg_output_debug = ++ ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->motionfilename, y, u, v, ++ cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, + cnt->conf.ffmpeg_vbr)) == NULL) { +- motion_log(LOG_ERR, 1, "ffopen_open error creating (motion) file [%s]", cnt->motionfilename); ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (motion) file [%s]", ++ cnt->motionfilename); + cnt->finish = 1; + return; + } +- cnt->ffmpeg_motion->udata = convbuf; ++ ++ cnt->ffmpeg_output_debug->udata = convbuf; + event(cnt, EVENT_FILECREATE, NULL, cnt->motionfilename, (void *)FTYPE_MPEG_MOTION, NULL); + } + } +@@ -471,23 +638,25 @@ static void event_ffmpeg_timelapse(struc + char tmp[PATH_MAX]; + const char *timepath; + +- /* conf.timepath would normally be defined but if someone deleted it by control interface +- it is better to revert to the default than fail */ ++ /* ++ * conf.timepath would normally be defined but if someone deleted it by control interface ++ * it is better to revert to the default than fail ++ */ + if (cnt->conf.timepath) + timepath = cnt->conf.timepath; + else + timepath = DEF_TIMEPATH; +- ++ + mystrftime(cnt, tmp, sizeof(tmp), timepath, currenttime_tm, NULL, 0); +- ++ + /* PATH_MAX - 4 to allow for .mpg to be appended without overflow */ + snprintf(cnt->timelapsefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, tmp); +- ++ + if (cnt->imgs.type == VIDEO_PALETTE_GREY) { + convbuf = mymalloc((width * height) / 2); + y = img; + u = convbuf; +- v = convbuf+(width * height) / 4; ++ v = convbuf + (width * height) / 4; + grey2yuv420p(u, v, width, height); + } else { + convbuf = NULL; +@@ -495,54 +664,65 @@ static void event_ffmpeg_timelapse(struc + u = img + width * height; + v = u + (width * height) / 4; + } +- ++ + if ((cnt->ffmpeg_timelapse = +- ffmpeg_open((char *)TIMELAPSE_CODEC, cnt->timelapsefilename, y, u, v, ++ ffmpeg_open((char *)TIMELAPSE_CODEC, cnt->timelapsefilename, y, u, v, + cnt->imgs.width, cnt->imgs.height, 24, cnt->conf.ffmpeg_bps, + cnt->conf.ffmpeg_vbr)) == NULL) { +- motion_log(LOG_ERR, 1, "ffopen_open error creating (timelapse) file [%s]", cnt->timelapsefilename); ++ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating " ++ "(timelapse) file [%s]", cnt->timelapsefilename); + cnt->finish = 1; + return; + } +- ++ + cnt->ffmpeg_timelapse->udata = convbuf; + event(cnt, EVENT_FILECREATE, NULL, cnt->timelapsefilename, (void *)FTYPE_MPEG_TIMELAPSE, NULL); + } +- ++ + y = img; +- ++ + if (cnt->imgs.type == VIDEO_PALETTE_GREY) + u = cnt->ffmpeg_timelapse->udata; + else + u = img + width * height; +- ++ + v = u + (width * height) / 4; +- ffmpeg_put_other_image(cnt->ffmpeg_timelapse, y, u, v); +- ++ ++ if (ffmpeg_put_other_image(cnt->ffmpeg_timelapse, y, u, v) == -1) { ++ cnt->finish = 1; ++ cnt->restart = 0; ++ } ++ + } + + static void event_ffmpeg_put(struct context *cnt, int type ATTRIBUTE_UNUSED, + unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, + void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) + { +- if (cnt->ffmpeg_new) { +- int width=cnt->imgs.width; +- int height=cnt->imgs.height; ++ if (cnt->ffmpeg_output) { ++ int width = cnt->imgs.width; ++ int height = cnt->imgs.height; + unsigned char *y = img; + unsigned char *u, *v; +- ++ + if (cnt->imgs.type == VIDEO_PALETTE_GREY) + u = cnt->ffmpeg_timelapse->udata; + else + u = y + (width * height); +- ++ + v = u + (width * height) / 4; +- ffmpeg_put_other_image(cnt->ffmpeg_new, y, u, v); ++ if (ffmpeg_put_other_image(cnt->ffmpeg_output, y, u, v) == -1) { ++ cnt->finish = 1; ++ cnt->restart = 0; ++ } ++ } ++ ++ if (cnt->ffmpeg_output_debug) { ++ if (ffmpeg_put_image(cnt->ffmpeg_output_debug) == -1) { ++ cnt->finish = 1; ++ cnt->restart = 0; ++ } + } +- +- if (cnt->ffmpeg_motion) +- ffmpeg_put_image(cnt->ffmpeg_motion); +- + } + + static void event_ffmpeg_closefile(struct context *cnt, +@@ -550,22 +730,23 @@ static void event_ffmpeg_closefile(struc + char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, + struct tm *tm ATTRIBUTE_UNUSED) + { +- +- if (cnt->ffmpeg_new) { +- if (cnt->ffmpeg_new->udata) +- free(cnt->ffmpeg_new->udata); +- ffmpeg_close(cnt->ffmpeg_new); +- cnt->ffmpeg_new = NULL; ++ ++ if (cnt->ffmpeg_output) { ++ if (cnt->ffmpeg_output->udata) ++ free(cnt->ffmpeg_output->udata); ++ ++ ffmpeg_close(cnt->ffmpeg_output); ++ cnt->ffmpeg_output = NULL; + + event(cnt, EVENT_FILECLOSE, NULL, cnt->newfilename, (void *)FTYPE_MPEG, NULL); + } + +- if (cnt->ffmpeg_motion) { +- if (cnt->ffmpeg_motion->udata) +- free(cnt->ffmpeg_motion->udata); ++ if (cnt->ffmpeg_output_debug) { ++ if (cnt->ffmpeg_output_debug->udata) ++ free(cnt->ffmpeg_output_debug->udata); + +- ffmpeg_close(cnt->ffmpeg_motion); +- cnt->ffmpeg_motion = NULL; ++ ffmpeg_close(cnt->ffmpeg_output_debug); ++ cnt->ffmpeg_output_debug = NULL; + + event(cnt, EVENT_FILECLOSE, NULL, cnt->motionfilename, (void *)FTYPE_MPEG_MOTION, NULL); + } +@@ -590,8 +771,8 @@ static void event_ffmpeg_timelapseend(st + #endif /* HAVE_FFMPEG */ + + +-/* +- * Starting point for all events ++/* ++ * Starting point for all events + */ + + struct event_handlers { +@@ -600,7 +781,7 @@ struct event_handlers { + }; + + struct event_handlers event_handlers[] = { +-#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) + { + EVENT_FILECREATE, + event_sqlnewfile +@@ -646,15 +827,29 @@ struct event_handlers event_handlers[] = + EVENT_IMAGE_SNAPSHOT, + event_image_snapshot + }, +-#if !defined(WITHOUT_V4L) && !defined(BSD) ++#ifdef HAVE_SDL + { +- EVENT_IMAGE | EVENT_IMAGEM, ++ EVENT_SDL_PUT, ++ event_sdl_put ++ }, ++#endif ++#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) ++ { ++ EVENT_IMAGE, + event_vid_putpipe + }, +-#endif /* WITHOUT_V4L && !BSD */ + { +- EVENT_WEBCAM, +- event_webcam_put ++ EVENT_IMAGEM, ++ event_vid_putpipe ++ }, ++#endif /* !WITHOUT_V4L && !BSD */ ++ { ++ EVENT_STREAM, ++ event_stream_put ++ }, ++ { ++ EVENT_FIRSTMOTION, ++ event_new_video + }, + #ifdef HAVE_FFMPEG + { +@@ -666,6 +861,10 @@ struct event_handlers event_handlers[] = + event_ffmpeg_put + }, + { ++ EVENT_FFMPEG_PUT, ++ event_ffmpeg_put ++ }, ++ { + EVENT_ENDMOTION, + event_ffmpeg_closefile + }, +@@ -677,39 +876,57 @@ struct event_handlers event_handlers[] = + EVENT_TIMELAPSEEND, + event_ffmpeg_timelapseend + }, ++#endif /* HAVE_FFMPEG */ + { + EVENT_FILECLOSE, + on_movie_end_command + }, +-#endif /* HAVE_FFMPEG */ ++ { ++ EVENT_FIRSTMOTION, ++ event_create_extpipe ++ }, ++ { ++ EVENT_IMAGE_DETECTED, ++ event_extpipe_put ++ }, ++ { ++ EVENT_FFMPEG_PUT, ++ event_extpipe_put ++ }, ++ { ++ EVENT_ENDMOTION, ++ event_extpipe_end ++ }, + { + EVENT_CAMERA_LOST, + event_camera_lost + }, + { + EVENT_STOP, +- event_stop_webcam ++ event_stop_stream + }, + {0, NULL} + }; + + +-/* The event functions are defined with the following parameters: +- * - Type as defined in event.h (EVENT_...) +- * - The global context struct cnt +- * - image - A pointer to unsigned char as used for images +- * - filename - A pointer to typically a string for a file path +- * - eventdata - A void pointer that can be cast to anything. E.g. FTYPE_... +- * - tm - A tm struct that carries a full time structure ++/** ++ * event ++ * defined with the following parameters: ++ * - Type as defined in event.h (EVENT_...) ++ * - The global context struct cnt ++ * - image - A pointer to unsigned char as used for images ++ * - filename - A pointer to typically a string for a file path ++ * - eventdata - A void pointer that can be cast to anything. E.g. FTYPE_... ++ * - tm - A tm struct that carries a full time structure + * The split between unsigned images and signed filenames was introduced in 3.2.2 + * as a code reading friendly solution to avoid a stream of compiler warnings in gcc 4.0. + */ + void event(struct context *cnt, int type, unsigned char *image, char *filename, void *eventdata, struct tm *tm) + { +- int i = -1; ++ int i=-1; + + while (event_handlers[++i].handler) { +- if (type & event_handlers[i].type) ++ if (type == event_handlers[i].type) + event_handlers[i].handler(cnt, type, image, filename, eventdata, tm); + } + } +--- motion-3.2.12.orig/event.h ++++ motion-3.2.12/event.h +@@ -13,22 +13,25 @@ + + #define EVENT_FILECREATE 1 + #define EVENT_MOTION 2 +-#define EVENT_FIRSTMOTION 4 +-#define EVENT_ENDMOTION 8 +-#define EVENT_STOP 16 +-#define EVENT_TIMELAPSE 32 +-#define EVENT_TIMELAPSEEND 64 +-#define EVENT_WEBCAM 128 +-#define EVENT_IMAGE_DETECTED 256 +-#define EVENT_IMAGEM_DETECTED 512 +-#define EVENT_IMAGE_SNAPSHOT 1024 +-#define EVENT_IMAGE 2048 +-#define EVENT_IMAGEM 8192 +-#define EVENT_FILECLOSE 16384 +-#define EVENT_DEBUG 65536 +-#define EVENT_CRITICAL 131072 +-#define EVENT_AREA_DETECTED 262144 +-#define EVENT_CAMERA_LOST 524288 ++#define EVENT_FIRSTMOTION 3 ++#define EVENT_ENDMOTION 4 ++#define EVENT_STOP 5 ++#define EVENT_TIMELAPSE 6 ++#define EVENT_TIMELAPSEEND 7 ++#define EVENT_STREAM 8 ++#define EVENT_IMAGE_DETECTED 9 ++#define EVENT_IMAGEM_DETECTED 10 ++#define EVENT_IMAGE_SNAPSHOT 11 ++#define EVENT_IMAGE 12 ++#define EVENT_IMAGEM 13 ++#define EVENT_FILECLOSE 14 ++#define EVENT_DEBUG 15 ++#define EVENT_CRITICAL 16 ++#define EVENT_AREA_DETECTED 17 ++#define EVENT_CAMERA_LOST 18 ++#define EVENT_FFMPEG_PUT 19 ++#define EVENT_SDL_PUT 20 ++ + + typedef void(* event_handler)(struct context *, int, unsigned char *, char *, void *, struct tm *); + +--- motion-3.2.12.orig/ffmpeg.c ++++ motion-3.2.12/ffmpeg.c +@@ -1,14 +1,14 @@ +-/********************************************************************** ++/* + * + * ffmpeg.c + * + * This software is distributed under the GNU Public License version 2 + * See also the file 'COPYING'. + * +- * The contents of this file has been derived from output_example.c ++ * The contents of this file has been derived from output_example.c + * and apiexample.c from the FFmpeg distribution. + * +- **********************************************************************/ ++ */ + + #ifdef HAVE_FFMPEG + +@@ -16,37 +16,32 @@ + #include "motion.h" + + #if LIBAVCODEC_BUILD > 4680 +-/* FFmpeg after build 4680 doesn't have support for mpeg1 videos with +- * non-standard framerates. Previous builds contained a broken hack ++/* ++ * FFmpeg after build 4680 doesn't have support for mpeg1 videos with ++ * non-standard framerates. Previous builds contained a broken hack + * that padded with B frames to obtain the correct framerate. + */ + # define FFMPEG_NO_NONSTD_MPEG1 +-# ifdef __GNUC__ +-/* #warning is a non-standard gcc extension */ +-# warning ************************************************** +-# warning Your version of FFmpeg is newer than version 0.4.8 +-# warning Newer versions of ffmpeg do not support MPEG1 with +-# warning non-standard framerate. MPEG1 will be disabled for +-# warning normal video output. You can still use mpeg4 and +-# warning and mpeg4ms which are both better in terms of size +-# warning and quality. MPEG1 is always used for timelapse. +-# warning Please read the Motion Guide for more information. +-# warning Note that this is not an error message! +-# warning ************************************************** +-# endif /* __GNUC__ */ + #endif /* LIBAVCODEC_BUILD > 4680 */ + ++#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR ++# if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 ++# define GUESS_NO_DEPRECATED ++# endif ++#endif + + #if LIBAVFORMAT_BUILD >= 4616 +-/* The API for av_write_frame changed with FFmpeg version 0.4.9pre1. ++/* ++ * The API for av_write_frame changed with FFmpeg version 0.4.9pre1. + * It now uses an AVPacket struct instead of direct parameters to the +- * function. The ++ * function. + */ + # define FFMPEG_AVWRITEFRAME_NEWAPI + #endif /* LIBAVFORMAT_BUILD >= 4616 */ + + #if LIBAVFORMAT_BUILD >= 4629 +-/* In this build/header version, the codec member of struct AVStream ++/* ++ * In this build/header version, the codec member of struct AVStream + * was changed to a pointer so changes to AVCodecContext shouldn't + * break binary compatibility with AVStream. + */ +@@ -55,52 +50,83 @@ + # define AVSTREAM_CODEC_PTR(avs_ptr) (&avs_ptr->codec) + #endif /* LIBAVFORMAT_BUILD >= 4629 */ + +-/* Name of custom file protocol for appending to existing files instead ++// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) ++// (54*2^16 | 6*2^8 | 100) ++#if LIBAVFORMAT_BUILD >= 3540580 ++#define FF_API_NEW_AVIO ++#define URL_RDONLY AVIO_FLAG_READ /**< read-only */ ++#define URL_WRONLY AVIO_FLAG_WRITE /**< write-only */ ++#define URL_RDWR AVIO_FLAG_READ_WRITE /**< read-write pseudo flag */ ++#endif ++ ++ ++/* ++ * Name of custom file protocol for appending to existing files instead + * of truncating. + */ + #define APPEND_PROTO "appfile" + + /* Some forward-declarations. */ +-void ffmpeg_put_frame(struct ffmpeg *, AVFrame *); ++int ffmpeg_put_frame(struct ffmpeg *, AVFrame *); + void ffmpeg_cleanups(struct ffmpeg *); +-AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, ++AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, + unsigned char *, unsigned char *); + + /* This is the trailer used to end mpeg1 videos. */ + static unsigned char mpeg1_trailer[] = {0x00, 0x00, 0x01, 0xb7}; + +-/* Append version of the file open function used in libavformat when opening +- * an ordinary file. The original file open function truncates an existing +- * file, but this version appends to it instead. ++ ++// FFMPEG API changed in 0.8 ++#if defined FF_API_NEW_AVIO ++ ++// TODO ++ ++ ++#else ++ ++/** ++ * file_open_append ++ * Append version of the file open function used in libavformat when opening ++ * an ordinary file. The original file open function truncates an existing ++ * file, but this version appends to it instead. ++ * ++ * Returns 0 on success and AVERROR(ENOENT) on error. ++ * + */ + static int file_open_append(URLContext *h, const char *filename, int flags) + { + const char *colon; +- int access_flags, fd; ++ const char *mode; ++ FILE *fh; ++ size_t bufsize = 0; + + /* Skip past the protocol part of filename. */ + colon = strchr(filename, ':'); +- if (colon) ++ ++ if (colon) + filename = colon + 1; +- ++ + + if (flags & URL_RDWR) { +- access_flags = O_CREAT | O_APPEND | O_RDWR; ++ mode = "ab+"; ++ bufsize = BUFSIZE_1MEG; + } else if (flags & URL_WRONLY) { +- access_flags = O_CREAT | O_APPEND | O_WRONLY; ++ mode = "ab"; ++ bufsize = BUFSIZE_1MEG; + } else { +- access_flags = O_RDONLY; ++ mode = "rb"; + } + +- fd = open(filename, access_flags, 0666); +- if (fd < 0) ++ fh = myfopen(filename, mode, bufsize); ++ if (fh == NULL) + return AVERROR(ENOENT); +- +- h->priv_data = (void *)(size_t)fd; ++ ++ h->priv_data = (void *)fh; + return 0; + } + +-/* URLProtocol entry for the append file protocol, which we use for mpeg1 videos ++/* ++ * URLProtocol entry for the append file protocol, which we use for mpeg1 videos + * in order to get append behavior with url_fopen. + * + * Libavformat uses protocols for achieving flexibility when handling files +@@ -117,134 +143,97 @@ URLProtocol mpeg1_file_protocol = { + + #ifdef HAVE_FFMPEG_NEW + +-/* +- * file_procotol has been removed from avio.h +- * +- */ +- ++/* file_procotol has been removed from avio.h */ + #ifdef FFMPEG_NEW_INCLUDES + #include + #else + #include "avstring.h" + #endif + +-static int file_open(URLContext *h, const char *filename, int flags) +-{ +- int access_flags, fd; +- +- av_strstart(filename, "file:", &filename); ++#endif // HAVE_FFMPEG_NEW + +- if (flags & URL_RDWR) { +- access_flags = O_CREAT | O_TRUNC | O_RDWR; +- } else if (flags & URL_WRONLY) { +- access_flags = O_CREAT | O_TRUNC | O_WRONLY; +- } else { +- access_flags = O_RDONLY; +- } +-#ifdef O_BINARY +- access_flags |= O_BINARY; ++#endif // FF_API_NEW_AVIO ++/**************************************************************************** ++ * The section below is the "my" section of functions. ++ * These are designed to be extremely simple version specific ++ * variants of the libav functions. ++ ****************************************************************************/ ++AVFrame *my_frame_alloc(void){ ++ AVFrame *pic; ++#if (LIBAVFORMAT_VERSION_MAJOR >= 55) ++ pic = av_frame_alloc(); ++#else ++ pic = avcodec_alloc_frame(); + #endif +- fd = open(filename, access_flags, 0666); +- if (fd < 0) +- return AVERROR(ENOENT); +- +- h->priv_data = (void *)(size_t)fd; +- return 0; ++ return pic; + } + +-static int file_read(URLContext *h, unsigned char *buf, int size) +-{ +- int fd = (size_t)h->priv_data; +- return read(fd, buf, size); +-} +- +-static int file_write(URLContext *h, unsigned char *buf, int size) +-{ +- int fd = (size_t)h->priv_data; +- return write(fd, buf, size); +-} +- +-static int64_t file_seek(URLContext *h, int64_t pos, int whence) +-{ +- int fd = (size_t)h->priv_data; +- return lseek(fd, pos, whence); +-} +- +-static int file_close(URLContext *h) +-{ +- int fd = (size_t)h->priv_data; +- return close(fd); +-} +- +-URLProtocol file_protocol = { +- "file", +- file_open, +- file_read, +- file_write, +- file_seek, +- file_close, +-#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) +- NULL, +- NULL, +- NULL, +-#endif +-}; +- ++void my_frame_free(AVFrame *frame){ ++#if (LIBAVFORMAT_VERSION_MAJOR >= 55) ++ av_frame_free(&frame); ++#else ++ //avcodec_free_frame(&frame); ++ //av_frame_free(&netcam->rtsp->frame); ++ av_freep(&frame); + #endif ++} + +- +-/* We set AVOutputFormat->write_trailer to this function for mpeg1. That way, +- * the mpeg1 video gets a proper trailer when it is closed. ++/**************************************************************************** ++ **************************************************************************** ++ ****************************************************************************/ ++ ++/** ++ * mpeg1_write_trailer ++ * We set AVOutputFormat->write_trailer to this function for mpeg1. That way, ++ * the mpeg1 video gets a proper trailer when it is closed. ++ * ++ * Returns 0 ++ * + */ + static int mpeg1_write_trailer(AVFormatContext *s) + { +-#if LIBAVFORMAT_BUILD >= (52<<16) +- put_buffer(s->pb, mpeg1_trailer, 4); +- put_flush_packet(s->pb); +-#else +- put_buffer(&s->pb, mpeg1_trailer, 4); +- put_flush_packet(&s->pb); +-#endif /* LIBAVFORMAT_BUILD >= (52<<16) */ ++ avio_write(s->pb, mpeg1_trailer, 4); ++ avio_flush(s->pb); + + return 0; /* success */ + } + +-/* ffmpeg_init initializes for libavformat. */ ++/** ++ * ffmpeg_init ++ * Initializes for libavformat. ++ * ++ * Returns ++ * Function returns nothing. ++ */ + void ffmpeg_init() + { +- motion_log(LOG_INFO, 0, "ffmpeg LIBAVCODEC_BUILD %d LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD); ++ MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d" ++ " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, ++ LIBAVFORMAT_BUILD); + av_register_all(); + + #if LIBAVCODEC_BUILD > 4680 +- av_log_set_callback( (void *)ffmpeg_avcodec_log ); ++ av_log_set_callback((void *)ffmpeg_avcodec_log); ++ av_log_set_level(AV_LOG_ERROR); + #endif + +- /* Copy the functions to use for the append file protocol from the standard +- * file protocol. +- */ +- mpeg1_file_protocol.url_read = file_protocol.url_read; +- mpeg1_file_protocol.url_write = file_protocol.url_write; +- mpeg1_file_protocol.url_seek = file_protocol.url_seek; +- mpeg1_file_protocol.url_close = file_protocol.url_close; +- +- /* Register the append file protocol. */ +-#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) +- av_register_protocol(&mpeg1_file_protocol); +-#else +- register_protocol(&mpeg1_file_protocol); +-#endif + } + +-/* Obtains the output format used for the specified codec. For mpeg4 codecs, +- * the format is avi; for mpeg1 codec, the format is mpeg. The filename has +- * to be passed, because it gets the appropriate extension appended onto it. ++/** ++ * get_oformat ++ * Obtains the output format used for the specified codec. For mpeg4 codecs, ++ * the format is avi; for mpeg1 codec, the format is mpeg. The filename has ++ * to be passed, because it gets the appropriate extension appended onto it. ++ * ++ * Returns ++ * AVOutputFormat pointer or NULL if any error happens. + */ + static AVOutputFormat *get_oformat(const char *codec, char *filename) + { + const char *ext; + AVOutputFormat *of = NULL; +- +- /* Here, we use guess_format to automatically setup the codec information. ++ /* ++ * Here, we use guess_format to automatically setup the codec information. + * If we are using msmpeg4, manually set that codec here. + * We also dynamically add the file extension to the filename here. This was + * done to support both mpeg1 and mpeg4 codecs since they have different extensions. +@@ -252,70 +241,118 @@ static AVOutputFormat *get_oformat(const + if ((strcmp(codec, TIMELAPSE_CODEC) == 0) + #ifndef FFMPEG_NO_NONSTD_MPEG1 + || (strcmp(codec, "mpeg1") == 0) +-#endif ++#endif + ) { + ext = ".mpg"; +- /* We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would ++ /* ++ * We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would + * result in a muxed output file, which isn't appropriate here. + */ +- of = guess_format("mpeg1video", NULL, NULL); +- if (of) { +- /* But we want the trailer to be correctly written. */ ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("mpeg1video", NULL, NULL); ++#endif ++ /* But we want the trailer to be correctly written. */ ++ if (of) + of->write_trailer = mpeg1_write_trailer; +- } ++ + #ifdef FFMPEG_NO_NONSTD_MPEG1 + } else if (strcmp(codec, "mpeg1") == 0) { +- motion_log(LOG_ERR, 0, "*** mpeg1 support for normal videos has been disabled ***"); ++ MOTION_LOG(WRN, TYPE_ENCODER, NO_ERRNO, "%s: *** mpeg1 support for normal" ++ " videos has been disabled ***"); + return NULL; + #endif + } else if (strcmp(codec, "mpeg4") == 0) { + ext = ".avi"; +- of = guess_format("avi", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("avi", NULL, NULL); ++#endif + } else if (strcmp(codec, "msmpeg4") == 0) { + ext = ".avi"; +- of = guess_format("avi", NULL, NULL); +- if (of) { +- /* Manually override the codec id. */ ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("avi", NULL, NULL); ++#endif ++ /* Manually override the codec id. */ ++ if (of) + of->video_codec = CODEC_ID_MSMPEG4V2; +- } ++ + } else if (strcmp(codec, "swf") == 0) { + ext = ".swf"; +- of = guess_format("swf", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("swf", NULL, NULL); ++#endif + } else if (strcmp(codec, "flv") == 0) { + ext = ".flv"; +- of = guess_format("flv", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("flv", NULL, NULL); ++#endif + of->video_codec = CODEC_ID_FLV1; + } else if (strcmp(codec, "ffv1") == 0) { + ext = ".avi"; +- of = guess_format("avi", NULL, NULL); +- if (of) { +- /* Use the FFMPEG Lossless Video codec (experimental!). +- Requires strict_std_compliance to be <= -2 */ ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("avi", NULL, NULL); ++#endif ++ /* ++ * Use the FFMPEG Lossless Video codec (experimental!). ++ * Requires strict_std_compliance to be <= -2 ++ */ ++ if (of) + of->video_codec = CODEC_ID_FFV1; +- } ++ + } else if (strcmp(codec, "mov") == 0) { + ext = ".mov"; +- of = guess_format("mov", NULL, NULL); ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format("mpeg1video", NULL, NULL); ++#else ++ of = av_guess_format("mov", NULL, NULL); ++#endif ++ } ++ else if (strcmp (codec, "ogg") == 0) ++ { ++ ext = ".ogg"; ++#ifdef GUESS_NO_DEPRECATED ++ of = guess_format ("ogg", NULL, NULL); ++#else ++ of = av_guess_format ("ogg", NULL, NULL); ++#endif + } else { +- motion_log(LOG_ERR, 0, "ffmpeg_video_codec option value %s is not supported", codec); ++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg_video_codec option value" ++ " %s is not supported", codec); + return NULL; + } + + if (!of) { +- motion_log(LOG_ERR, 0, "Could not guess format for %s", codec); ++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not guess format for %s", ++ codec); + return NULL; + } + +- /* The 4 allows for ".avi" or ".mpg" to be appended */ ++ /* The 4 allows for ".avi" or ".mpg" to be appended. */ + strncat(filename, ext, 4); + + return of; + } + +-/* This function opens an mpeg file using the new libavformat method. Both mpeg1 +- * and mpeg4 are supported. However, if the current ffmpeg version doesn't allow +- * mpeg1 with non-standard framerate, the open will fail. Timelapse is a special +- * case and is tested separately. ++/** ++ * ffmpeg_open ++ * Opens an mpeg file using the new libavformat method. Both mpeg1 ++ * and mpeg4 are supported. However, if the current ffmpeg version doesn't allow ++ * mpeg1 with non-standard framerate, the open will fail. Timelapse is a special ++ * case and is tested separately. ++ * ++ * Returns ++ * A new allocated ffmpeg struct or NULL if any error happens. + */ + struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, + unsigned char *y, unsigned char *u, unsigned char *v, +@@ -325,8 +362,9 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + AVCodec *codec; + struct ffmpeg *ffmpeg; + int is_mpeg1; +- +- /* Allocate space for our ffmpeg structure. This structure contains all the ++ int ret; ++ /* ++ * Allocate space for our ffmpeg structure. This structure contains all the + * codec and image information we need to generate movies. + * FIXME when motion exits we should close the movie to ensure that + * ffmpeg is freed. +@@ -335,22 +373,26 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + memset(ffmpeg, 0, sizeof(struct ffmpeg)); + + ffmpeg->vbr = vbr; +- +- /* store codec name in ffmpeg->codec, with buffer overflow check */ ++ ++ /* Store codec name in ffmpeg->codec, with buffer overflow check. */ + snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); + +- /* allocation the output media context */ +- ffmpeg->oc = av_mallocz(sizeof(AVFormatContext)); ++ /* Allocation the output media context. */ ++#if (LIBAVFORMAT_VERSION_MAJOR >= 53) ++ ffmpeg->oc = avformat_alloc_context(); ++#else ++ ffmpeg->oc = av_alloc_format_context(); ++#endif + + if (!ffmpeg->oc) { +- motion_log(LOG_ERR, 1, "Memory error while allocating output media context"); ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Memory error while allocating" ++ " output media context"); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + + /* Setup output format */ + ffmpeg->oc->oformat = get_oformat(ffmpeg_video_codec, filename); +- + if (!ffmpeg->oc->oformat) { + ffmpeg_cleanups(ffmpeg); + return NULL; +@@ -358,30 +400,35 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + + snprintf(ffmpeg->oc->filename, sizeof(ffmpeg->oc->filename), "%s", filename); + +- /* Create a new video stream and initialize the codecs */ ++ /* Create a new video stream and initialize the codecs. */ + ffmpeg->video_st = NULL; +- + if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { +- ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); ++ ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); + if (!ffmpeg->video_st) { +- motion_log(LOG_ERR, 1, "av_new_stream - could not alloc stream"); ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: av_new_stream - could" ++ " not alloc stream"); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + } else { + /* We did not get a proper video codec. */ +- motion_log(LOG_ERR, 0, "Failed to obtain a proper video codec"); ++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Failed to obtain a proper" ++ " video codec"); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + + ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); + c->codec_id = ffmpeg->oc->oformat->video_codec; ++#if (LIBAVFORMAT_VERSION_MAJOR >= 53) ++ c->codec_type = AVMEDIA_TYPE_VIDEO; ++#else + c->codec_type = CODEC_TYPE_VIDEO; ++#endif + is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; + + if (strcmp(ffmpeg_video_codec, "ffv1") == 0) +- c->strict_std_compliance = -2; ++ c->strict_std_compliance = -2; + + /* Uncomment to allow non-standard framerates. */ + //c->strict_std_compliance = -1; +@@ -391,7 +438,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + c->width = width; + c->height = height; + #if LIBAVCODEC_BUILD >= 4754 +- /* frame rate = 1/time_base, so we set 1/rate, not rate/1 */ ++ /* Frame rate = 1/time_base, so we set 1/rate, not rate/1 */ + c->time_base.num = 1; + c->time_base.den = rate; + #else +@@ -399,54 +446,55 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + c->frame_rate_base = 1; + #endif /* LIBAVCODEC_BUILD >= 4754 */ + +- if (debug_level >= CAMERA_DEBUG) +- motion_log(LOG_DEBUG, 0, "%s FPS %d",__FUNCTION__,rate); ++ MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s FPS %d", ++ rate); + + if (vbr) + c->flags |= CODEC_FLAG_QSCALE; + +- /* Set codec specific parameters. */ +- /* set intra frame distance in frames depending on codec */ ++ /* ++ * Set codec specific parameters. ++ * Set intra frame distance in frames depending on codec. ++ */ + c->gop_size = is_mpeg1 ? 10 : 12; +- +- /* some formats want stream headers to be separate */ +- if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || +- !strcmp(ffmpeg->oc->oformat->name, "mov") || +- !strcmp(ffmpeg->oc->oformat->name, "3gp")) { +- c->flags |= CODEC_FLAG_GLOBAL_HEADER; +- } + +- /* set the output parameters (must be done even if no parameters). */ +- if (av_set_parameters(ffmpeg->oc, NULL) < 0) { +- motion_log(LOG_ERR, 0, "ffmpeg av_set_parameters error: Invalid output format parameters"); +- ffmpeg_cleanups(ffmpeg); +- return NULL; ++ /* Some formats want stream headers to be separate. */ ++ if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || ++ !strcmp(ffmpeg->oc->oformat->name, "mov") || ++ !strcmp(ffmpeg->oc->oformat->name, "3gp")) { ++ c->flags |= CODEC_FLAG_GLOBAL_HEADER; + } + +- /* Dump the format settings. This shows how the various streams relate to each other */ ++ /* Dump the format settings. This shows how the various streams relate to each other. */ + //dump_format(ffmpeg->oc, 0, filename, 1); + +- /* Now that all the parameters are set, we can open the video +- codec and allocate the necessary encode buffers */ ++ /* ++ * Now that all the parameters are set, we can open the video ++ * codec and allocate the necessary encode buffers. ++ */ + codec = avcodec_find_encoder(c->codec_id); + + if (!codec) { +- motion_log(LOG_ERR, 1, "Codec not found"); ++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Codec %s not found", ++ ffmpeg_video_codec); + ffmpeg_cleanups(ffmpeg); + return NULL; + } +- ++ + /* Set the picture format - need in ffmpeg starting round April-May 2005 */ + c->pix_fmt = PIX_FMT_YUV420P; + + /* Get a mutex lock. */ + pthread_mutex_lock(&global_lock); + +- /* open the codec */ +- if (avcodec_open(c, codec) < 0) { ++ /* Open the codec */ ++ ret = avcodec_open2(c, codec, NULL /* options */ ); ++ ++ if (ret < 0) { + /* Release the lock. */ + pthread_mutex_unlock(&global_lock); +- motion_log(LOG_ERR, 1, "avcodec_open - could not open codec"); ++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_open - could not open codec %s", ++ ffmpeg_video_codec); + ffmpeg_cleanups(ffmpeg); + return NULL; + } +@@ -454,30 +502,34 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + /* Release the lock. */ + pthread_mutex_unlock(&global_lock); + +- + ffmpeg->video_outbuf = NULL; ++ + if (!(ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE)) { +- /* allocate output buffer */ +- /* XXX: API change will be done */ +- /* ffmpeg->video_outbuf_size = 20000; */ +- ffmpeg->video_outbuf_size = ffmpeg->c->width * 256; ++ /* ++ * Allocate output buffer ++ * XXX: API change will be done ++ * ffmpeg->video_outbuf_size = 200000 ++ */ ++ ffmpeg->video_outbuf_size = ffmpeg->c->width * 512; + ffmpeg->video_outbuf = mymalloc(ffmpeg->video_outbuf_size); + } + +- /* allocate the encoded raw picture */ +- ffmpeg->picture = avcodec_alloc_frame(); ++ /* Allocate the encoded raw picture. */ ++ ffmpeg->picture = my_frame_alloc(); ++ + if (!ffmpeg->picture) { +- motion_log(LOG_ERR, 1, "avcodec_alloc_frame - could not alloc frame"); ++ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -" ++ " could not alloc frame"); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + +- /* set variable bitrate if requested */ +- if (ffmpeg->vbr) ++ /* Set variable bitrate if requested. */ ++ if (ffmpeg->vbr) + ffmpeg->picture->quality = ffmpeg->vbr; +- + +- /* set the frame data */ ++ ++ /* Set the frame data. */ + ffmpeg->picture->data[0] = y; + ffmpeg->picture->data[1] = u; + ffmpeg->picture->data[2] = v; +@@ -485,85 +537,89 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ + ffmpeg->picture->linesize[1] = ffmpeg->c->width / 2; + ffmpeg->picture->linesize[2] = ffmpeg->c->width / 2; + +- /* open the output file, if needed */ ++ /* Open the output file, if needed. */ + if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { + char file_proto[256]; + +- /* Use append file protocol for mpeg1, to get the append behavior from ++ /* ++ * Use append file protocol for mpeg1, to get the append behavior from + * url_fopen, but no protocol (=> default) for other codecs. + */ +- if (is_mpeg1) ++ if (is_mpeg1) ++#if defined FF_API_NEW_AVIO ++ snprintf(file_proto, sizeof(file_proto), "%s", filename); ++#else + snprintf(file_proto, sizeof(file_proto), APPEND_PROTO ":%s", filename); +- else ++#endif ++ else + snprintf(file_proto, sizeof(file_proto), "%s", filename); +- + +- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { +- /* path did not exist? */ ++ ++ if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { ++ /* Path did not exist? */ + if (errno == ENOENT) { +- /* create path for file (don't use file_proto)... */ ++ /* Create path for file (don't use file_proto)... */ + if (create_path(filename) == -1) { + ffmpeg_cleanups(ffmpeg); + return NULL; + } + +- /* and retry opening the file (use file_proto) */ +- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { +- motion_log(LOG_ERR, 1, "url_fopen - error opening file %s",filename); ++ if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: url_fopen -" ++ " error opening file %s", filename); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + /* Permission denied */ + } else if (errno == EACCES) { +- motion_log(LOG_ERR, 1, +- "url_fopen - error opening file %s" +- " ... check access rights to target directory", filename); ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, ++ "%s: url_fopen - error opening file %s" ++ " ... check access rights to target directory", ++ filename); + ffmpeg_cleanups(ffmpeg); + return NULL; + } else { +- motion_log(LOG_ERR, 1, "Error opening file %s", filename); ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error opening file %s", ++ filename); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + } + } + +- /* write the stream header, if any */ +- av_write_header(ffmpeg->oc); +- ++ /* Write the stream header, if any. */ ++ avformat_write_header(ffmpeg->oc, NULL); + return ffmpeg; + } + +-/* +- Clean up ffmpeg struct if something was wrong +-*/ ++/** ++ * ffmpeg_cleanups ++ * Clean up ffmpeg struct if something was wrong. ++ * ++ * Returns ++ * Function returns nothing. ++ */ + void ffmpeg_cleanups(struct ffmpeg *ffmpeg) + { + unsigned int i; + +- /* close each codec */ ++ /* Close each codec */ + if (ffmpeg->video_st) { + pthread_mutex_lock(&global_lock); + #if LIBAVCODEC_BUILD > 4680 + if (ffmpeg->video_st->codec->priv_data != NULL) + #endif + avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); +- pthread_mutex_unlock(&global_lock); ++ pthread_mutex_unlock(&global_lock); + av_freep(&ffmpeg->picture); + free(ffmpeg->video_outbuf); + } + +- /* free the streams */ +- for (i = 0; i < ffmpeg->oc->nb_streams; i++) ++ /* Free the streams */ ++ for (i = 0; i < ffmpeg->oc->nb_streams; i++) + av_freep(&ffmpeg->oc->streams[i]); +- +-/* +- if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { +- // close the output file +- if (ffmpeg->oc->pb) url_fclose(&ffmpeg->oc->pb); +- } +-*/ +- /* free the stream */ ++ ++ /* Free the stream */ + av_free(ffmpeg->oc); + #if LIBAVFORMAT_BUILD >= 4629 + av_free(ffmpeg->c); +@@ -571,12 +627,18 @@ void ffmpeg_cleanups(struct ffmpeg *ffmp + free(ffmpeg); + } + +-/* Closes a video file. */ ++/** ++ * ffmpeg_close ++ * Closes a video file. ++ * ++ * Returns ++ * Function returns nothing. ++ */ + void ffmpeg_close(struct ffmpeg *ffmpeg) + { + unsigned int i; + +- /* close each codec */ ++ /* Close each codec */ + if (ffmpeg->video_st) { + pthread_mutex_lock(&global_lock); + avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); +@@ -585,24 +647,20 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) + free(ffmpeg->video_outbuf); + } + +- /* write the trailer, if any */ ++ /* Write the trailer, if any. */ + av_write_trailer(ffmpeg->oc); + +- /* free the streams */ +- for (i = 0; i < ffmpeg->oc->nb_streams; i++) ++ /* Free the streams. */ ++ for (i = 0; i < ffmpeg->oc->nb_streams; i++) + av_freep(&ffmpeg->oc->streams[i]); +- + + if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { +- /* close the output file */ +-#if LIBAVFORMAT_BUILD >= (52<<16) +- url_fclose(ffmpeg->oc->pb); +-#else +- url_fclose(&ffmpeg->oc->pb); +-#endif /* LIBAVFORMAT_BUILD >= (52<<16) */ ++ /* Close the output file. */ ++ avio_close(ffmpeg->oc->pb); + } + +- /* free the stream */ ++ ++ /* Free the stream. */ + av_free(ffmpeg->oc); + #if LIBAVFORMAT_BUILD >= 4629 + av_free(ffmpeg->c); +@@ -610,43 +668,72 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) + free(ffmpeg); + } + +-/* Puts the image pointed to by ffmpeg->picture. */ +-void ffmpeg_put_image(struct ffmpeg *ffmpeg) ++/** ++ * ffmpeg_put_image ++ * Puts the image pointed to by ffmpeg->picture. ++ * ++ * Returns ++ * value returned by ffmpeg_put_frame call. ++ */ ++int ffmpeg_put_image(struct ffmpeg *ffmpeg) + { +- ffmpeg_put_frame(ffmpeg, ffmpeg->picture); ++ return ffmpeg_put_frame(ffmpeg, ffmpeg->picture); + } + +-/* Puts an arbitrary picture defined by y, u and v. */ +-void ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, ++/** ++ * ffmpeg_put_other_image ++ * Puts an arbitrary picture defined by y, u and v. ++ * ++ * Returns ++ * Number of bytes written by ffmpeg_put_frame ++ * -1 if any error happens in ffmpeg_put_frame ++ * 0 if error allocating picture. ++ */ ++int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, + unsigned char *u, unsigned char *v) + { + AVFrame *picture; +- /* allocate the encoded raw picture */ ++ int ret = 0; ++ ++ /* Allocate the encoded raw picture. */ + picture = ffmpeg_prepare_frame(ffmpeg, y, u, v); + + if (picture) { +- ffmpeg_put_frame(ffmpeg, picture); +- av_free(picture); ++ ret = ffmpeg_put_frame(ffmpeg, picture); ++ if (!ret) ++ av_free(picture); + } ++ ++ return ret; + } + +-/* Encodes and writes a video frame using the av_write_frame API. This is +- * a helper function for ffmpeg_put_image and ffmpeg_put_other_image. ++/** ++ * ffmpeg_put_frame ++ * Encodes and writes a video frame using the av_write_frame API. This is ++ * a helper function for ffmpeg_put_image and ffmpeg_put_other_image. ++ * ++ * Returns ++ * Number of bytes written or -1 if any error happens. + */ +-void ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) ++int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) + { + int out_size, ret; ++ + #ifdef FFMPEG_AVWRITEFRAME_NEWAPI + AVPacket pkt; + +- av_init_packet(&pkt); /* init static structure */ ++ av_init_packet(&pkt); /* Init static structure. */ + pkt.stream_index = ffmpeg->video_st->index; + #endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ + + if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { +- /* raw video case. The API will change slightly in the near future for that */ ++ /* Raw video case. The API will change slightly in the near future for that. */ + #ifdef FFMPEG_AVWRITEFRAME_NEWAPI ++# if LIBAVCODEC_VERSION_MAJOR < 53 + pkt.flags |= PKT_FLAG_KEY; ++# else ++ pkt.flags |= AV_PKT_FLAG_KEY; ++# endif + pkt.data = (uint8_t *)pic; + pkt.size = sizeof(AVPicture); + ret = av_write_frame(ffmpeg->oc, &pkt); +@@ -655,62 +742,91 @@ void ffmpeg_put_frame(struct ffmpeg *ffm + (uint8_t *)pic, sizeof(AVPicture)); + #endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ + } else { +- /* encode the image */ ++ /* Encodes the image. */ ++#if defined FF_API_NEW_AVIO ++ ++ int got_packet_ptr; ++ pkt.data = ffmpeg->video_outbuf; ++ pkt.size = ffmpeg->video_outbuf_size; ++ ++ out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), ++ &pkt, pic, &got_packet_ptr); ++ if (out_size < 0) ++ // Error encondig ++ out_size = 0; ++ else ++ out_size = pkt.size; ++#else + out_size = avcodec_encode_video(AVSTREAM_CODEC_PTR(ffmpeg->video_st), +- ffmpeg->video_outbuf, ++ ffmpeg->video_outbuf, + ffmpeg->video_outbuf_size, pic); +- +- /* if zero size, it means the image was buffered */ ++#endif ++ /* If zero size, it means the image was buffered. */ + if (out_size != 0) { +- /* write the compressed frame in the media file */ +- /* XXX: in case of B frames, the pts is not yet valid */ ++ /* ++ * Writes the compressed frame in the media file. ++ * XXX: in case of B frames, the pts is not yet valid. ++ */ + #ifdef FFMPEG_AVWRITEFRAME_NEWAPI + pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; +- if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) { ++ ++ if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) ++# if LIBAVCODEC_VERSION_MAJOR < 53 + pkt.flags |= PKT_FLAG_KEY; +- } ++# else ++ pkt.flags |= AV_PKT_FLAG_KEY; ++# endif ++ + pkt.data = ffmpeg->video_outbuf; + pkt.size = out_size; + ret = av_write_frame(ffmpeg->oc, &pkt); + #else +- ret = av_write_frame(ffmpeg->oc, ffmpeg->video_st->index, ++ ret = av_write_frame(ffmpeg->oc, ffmpeg->video_st->index, + ffmpeg->video_outbuf, out_size); + #endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ ++ + } else { + ret = 0; + } + } +- ++ + if (ret != 0) { +- motion_log(LOG_ERR, 1, "Error while writing video frame"); +- return; ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error while writing" ++ " video frame"); ++ ffmpeg_cleanups(ffmpeg); ++ return -1; + } ++ ++ return ret; + } + +-/* Allocates and prepares a picture frame by setting up the U, Y and V pointers in +- * the frame according to the passed pointers. ++/** ++ * ffmpeg_prepare_frame ++ * Allocates and prepares a picture frame by setting up the U, Y and V pointers in ++ * the frame according to the passed pointers. + * +- * Returns NULL If the allocation fails. ++ * Returns ++ * NULL If the allocation fails. + * +- * The returned AVFrame pointer must be freed after use. ++ * The returned AVFrame pointer must be freed after use. + */ + AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y, + unsigned char *u, unsigned char *v) + { + AVFrame *picture; + +- picture = avcodec_alloc_frame(); ++ picture = my_frame_alloc(); ++ + if (!picture) { +- motion_log(LOG_ERR, 1, "Could not alloc frame"); ++ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc frame"); + return NULL; + } + +- /* take care of variable bitrate setting */ +- if (ffmpeg->vbr) ++ /* Take care of variable bitrate setting. */ ++ if (ffmpeg->vbr) + picture->quality = ffmpeg->vbr; +- +- +- /* setup pointers and line widths */ ++ ++ /* Setup pointers and line widths. */ + picture->data[0] = y; + picture->data[1] = u; + picture->data[2] = v; +@@ -722,9 +838,10 @@ AVFrame *ffmpeg_prepare_frame(struct ffm + } + + +-/** ffmpeg_deinterlace ++/** ++ * ffmpeg_deinterlace + * Make the image suitable for deinterlacing using ffmpeg, then deinterlace the picture. +- * ++ * + * Parameters + * img image in YUV420P format + * width image width in pixels +@@ -736,33 +853,35 @@ AVFrame *ffmpeg_prepare_frame(struct ffm + */ + void ffmpeg_deinterlace(unsigned char *img, int width, int height) + { +- AVFrame *picture; ++ AVPicture picture; + int width2 = width / 2; +- +- picture = avcodec_alloc_frame(); +- if (!picture) { +- motion_log(LOG_ERR, 1, "Could not alloc frame"); +- return; +- } +- +- picture->data[0] = img; +- picture->data[1] = img+width*height; +- picture->data[2] = picture->data[1]+(width*height)/4; +- picture->linesize[0] = width; +- picture->linesize[1] = width2; +- picture->linesize[2] = width2; +- ++ ++ picture.data[0] = img; ++ picture.data[1] = img + width * height; ++ picture.data[2] = picture.data[1] + (width * height) / 4; ++ picture.linesize[0] = width; ++ picture.linesize[1] = width2; ++ picture.linesize[2] = width2; ++ + /* We assume using 'PIX_FMT_YUV420P' always */ +- avpicture_deinterlace((AVPicture *)picture, (AVPicture *)picture, PIX_FMT_YUV420P, width, height); +- +- av_free(picture); +- ++#if (LIBAVFORMAT_VERSION_MAJOR >= 53) ++ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Deinterlace depreciated for recent versions of FFMPEG."); ++#else ++ avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height); ++#endif ++ ++ ++#if !defined(__SSE_MATH__) && (defined(__i386__) || defined(__x86_64__)) ++ __asm__ __volatile__ ( "emms"); ++#endif ++ + return; + } + +-/** ffmpeg_avcodec_log ++/** ++ * ffmpeg_avcodec_log + * Handle any logging output from the ffmpeg library avcodec. +- * ++ * + * Parameters + * *ignoreme A pointer we will ignore + * errno_flag The error number value +@@ -776,15 +895,12 @@ void ffmpeg_avcodec_log(void *ignoreme A + { + char buf[1024]; + +- /* Do not log the message coming from avcodec if the debug_level is not set. */ +- if (debug_level) { ++ /* Flatten the message coming in from avcodec. */ ++ vsnprintf(buf, sizeof(buf), fmt, vl); + +- /* Flatten the message coming in from avcodec */ +- vsnprintf(buf, sizeof(buf), fmt, vl); +- +- /* If the debug_level is correct then send the message to the motion logging routine. */ +- motion_log(LOG_ERR, 0, "ffmpeg_avcodec_log: %s - flag %d", buf, errno_flag); +- } ++ /* If the debug_level is correct then send the message to the motion logging routine. */ ++ MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s: %s - flag %d", ++ buf, errno_flag); + } + + #endif /* HAVE_FFMPEG */ +--- motion-3.2.12.orig/ffmpeg.h ++++ motion-3.2.12/ffmpeg.h +@@ -29,7 +29,8 @@ + #include + #include + +-/* Define a codec name/identifier for timelapse videos, so that we can ++/* ++ * Define a codec name/identifier for timelapse videos, so that we can + * differentiate between normal mpeg1 videos and timelapse videos. + */ + #define TIMELAPSE_CODEC "mpeg1_tl" +@@ -55,7 +56,8 @@ struct ffmpeg { + /* Initialize FFmpeg stuff. Needs to be called before ffmpeg_open. */ + void ffmpeg_init(void); + +-/* Open an mpeg file. This is a generic interface for opening either an mpeg1 or ++/* ++ * Open an mpeg file. This is a generic interface for opening either an mpeg1 or + * an mpeg4 video. If non-standard mpeg1 isn't supported (FFmpeg build > 4680), + * calling this function with "mpeg1" as codec results in an error. To create a + * timelapse video, use TIMELAPSE_CODEC as codec name. +@@ -74,10 +76,10 @@ struct ffmpeg *ffmpeg_open( + ); + + /* Puts the image pointed to by the picture member of struct ffmpeg. */ +-void ffmpeg_put_image(struct ffmpeg *); ++int ffmpeg_put_image(struct ffmpeg *); + + /* Puts the image defined by u, y and v (YUV420 format). */ +-void ffmpeg_put_other_image( ++int ffmpeg_put_other_image( + struct ffmpeg *ffmpeg, + unsigned char *y, + unsigned char *u, +@@ -87,10 +89,15 @@ void ffmpeg_put_other_image( + /* Closes the mpeg file. */ + void ffmpeg_close(struct ffmpeg *); + +-/*Deinterlace the image. */ ++/* Deinterlace the image. */ + void ffmpeg_deinterlace(unsigned char *, int, int); + +-/*Setup an avcodec log handler. */ ++/* Setup an avcodec log handler. */ + void ffmpeg_avcodec_log(void *, int, const char *, va_list); + ++#ifdef HAVE_FFMPEG ++AVFrame *my_frame_alloc(void); ++void my_frame_free(AVFrame *frame); ++#endif ++ + #endif /* _INCLUDE_FFMPEG_H_ */ +--- /dev/null ++++ motion-3.2.12/git-commit-version.sh +@@ -0,0 +1,5 @@ ++#!/bin/sh ++ ++SNV_VERSION=`git show -s --format=%H` ++echo -n "Git-$SNV_VERSION" ++ +--- motion-3.2.12.orig/jpegutils.c ++++ motion-3.2.12/jpegutils.c +@@ -4,7 +4,7 @@ + * + * Copyright (C) 1999 Rainer Johanni + * Copyright (C) 2001 pHilipp Zabel +- * Copyright (C) 2008 Angel Carpintero ++ * Copyright (C) 2008 Angel Carpintero + * + * based on jdatasrc.c and jdatadst.c from the Independent + * JPEG Group's software by Thomas G. Lane +@@ -35,7 +35,7 @@ + #include + #include + +- /* ++/* + * jpeg_data: buffer with input / output jpeg + * len: Length of jpeg buffer + * itype: 0: Not interlaced +@@ -49,8 +49,6 @@ + * width width of Y channel (width of U/V is width/2) + * height height of Y channel (height of U/V is height/2) + */ +- +- + static void jpeg_buffer_src(j_decompress_ptr cinfo, unsigned char *buffer, + long num); + static void jpeg_buffer_dest(j_compress_ptr cinfo, unsigned char *buffer, +@@ -70,13 +68,11 @@ static void jpeg_skip_ff(j_decompress_pt + * Initialize source --- called by jpeg_read_header + * before any data is actually read. + */ +- + static void init_source(j_decompress_ptr cinfo ATTRIBUTE_UNUSED) + { +- /* no work necessary here */ ++ /* No work necessary here */ + } + +- + /* + * Fill the input buffer --- called whenever buffer is emptied. + * +@@ -85,7 +81,6 @@ static void init_source(j_decompress_ptr + * which is the JPEG EOI marker; + * + */ +- + static uint8_t EOI_data[2] = { 0xFF, 0xD9 }; + + static boolean fill_input_buffer(j_decompress_ptr cinfo) +@@ -101,7 +96,6 @@ static boolean fill_input_buffer(j_decom + * uninteresting data (such as an APPn marker). + * + */ +- + static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) + { + if (num_bytes > 0) { +@@ -117,27 +111,25 @@ static void skip_input_data(j_decompress + * Terminate source --- called by jpeg_finish_decompress + * after all data has been read. Often a no-op. + */ +- + static void term_source(j_decompress_ptr cinfo ATTRIBUTE_UNUSED) + { +- /* no work necessary here */ ++ /* No work necessary here */ + } + + + /* + * Prepare for input from a data buffer. + */ +- + static void jpeg_buffer_src(j_decompress_ptr cinfo, unsigned char *buffer, long num) + { + /* The source object and input buffer are made permanent so that a series +-* of JPEG images can be read from the same buffer by calling jpeg_buffer_src +-* only before the first one. (If we discarded the buffer at the end of +-* one image, we'd likely lose the start of the next one.) +-* This makes it unsafe to use this manager and a different source +-* manager serially with the same JPEG object. Caveat programmer. +-*/ +- if (cinfo->src == NULL) { /* first time for this JPEG object? */ ++ * of JPEG images can be read from the same buffer by calling jpeg_buffer_src ++ * only before the first one. (If we discarded the buffer at the end of ++ * one image, we'd likely lose the start of the next one.) ++ * This makes it unsafe to use this manager and a different source ++ * manager serially with the same JPEG object. Caveat programmer. ++ */ ++ if (cinfo->src == NULL) { /* First time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + sizeof (struct jpeg_source_mgr)); +@@ -146,7 +138,7 @@ static void jpeg_buffer_src(j_decompress + cinfo->src->init_source = init_source; + cinfo->src->fill_input_buffer = fill_input_buffer; + cinfo->src->skip_input_data = skip_input_data; +- cinfo->src->resync_to_restart = jpeg_resync_to_restart; /* use default method */ ++ cinfo->src->resync_to_restart = jpeg_resync_to_restart; /* Use default method */ + cinfo->src->term_source = term_source; + cinfo->src->bytes_in_buffer = num; + cinfo->src->next_input_byte = (JOCTET *) buffer; +@@ -158,7 +150,6 @@ static void jpeg_buffer_src(j_decompress + * particularly useful when reading several images from the same buffer: + * It should be called to skip padding 0xff bytes beetween images. + */ +- + static void jpeg_skip_ff(j_decompress_ptr cinfo) + { + while (cinfo->src->bytes_in_buffer > 1 +@@ -183,7 +174,6 @@ static void jpeg_skip_ff(j_decompress_pt + * Initialize destination --- called by jpeg_start_compress + * before any data is actually written. + */ +- + static void init_destination(j_compress_ptr cinfo ATTRIBUTE_UNUSED) + { + /* No work necessary here */ +@@ -197,12 +187,11 @@ static void init_destination(j_compress_ + * If it gets called, the given jpeg buffer was too small. + * + */ +- + static boolean empty_output_buffer(j_compress_ptr cinfo) + { + /*FIXME: */ +- motion_log(LOG_ERR, 0, "%s: Given jpeg buffer was too small", __FUNCTION__); +- ERREXIT (cinfo, JERR_BUFFER_SIZE); /* shouldn't be FILE_WRITE but BUFFER_OVERRUN! */ ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Given jpeg buffer was too small"); ++ ERREXIT (cinfo, JERR_BUFFER_SIZE); /* Shouldn't be FILE_WRITE but BUFFER_OVERRUN! */ + return TRUE; + } + +@@ -215,10 +204,9 @@ static boolean empty_output_buffer(j_com + * application must deal with any cleanup that should happen even + * for error exit. + */ +- + static void term_destination(j_compress_ptr cinfo ATTRIBUTE_UNUSED) + { +- /* no work necessary here */ ++ /* No work necessary here */ + } + + +@@ -231,13 +219,14 @@ static void term_destination(j_compress_ + static void jpeg_buffer_dest(j_compress_ptr cinfo, unsigned char *buf, long len) + { + +- /* The destination object is made permanent so that multiple JPEG images +- * can be written to the same file without re-executing jpeg_stdio_dest. ++ /* ++ * The destination object is made permanent so that multiple JPEG images ++ * can be written to the same file without re-executing jpeg_stdio_dest. + * This makes it dangerous to use this manager and a different destination + * manager serially with the same JPEG object, because their private object + * sizes may be different. Caveat programmer. + */ +- if (cinfo->dest == NULL) { /* first time for this JPEG object? */ ++ if (cinfo->dest == NULL) { /* First time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + sizeof (struct jpeg_destination_mgr)); +@@ -264,39 +253,40 @@ static void jpeg_buffer_dest(j_compress_ + * The following kind of error handling is from the + * example.c file in the Independent JPEG Group's JPEG software + */ +- + struct my_error_mgr { + struct jpeg_error_mgr pub; /* "public" fields */ +- jmp_buf setjmp_buffer; /* for return to caller */ ++ jmp_buf setjmp_buffer; /* For return to caller */ + +- /* original emit_message method */ ++ /* Original emit_message method. */ + JMETHOD(void, original_emit_message, (j_common_ptr cinfo, int msg_level)); +- /* was a corrupt-data warning seen */ ++ /* Was a corrupt-data warning seen. */ + int warning_seen; + }; + + static void my_error_exit(j_common_ptr cinfo) + { +- /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ ++ /* cinfo->err really points to a my_error_mgr struct, so coerce pointer. */ + struct my_error_mgr *myerr = (struct my_error_mgr *) cinfo->err; + +- /* Always display the message. */ +- /* We could postpone this until after returning, if we chose. */ ++ /* ++ * Always display the message. ++ * We could postpone this until after returning, if we chose. ++ */ + (*cinfo->err->output_message) (cinfo); + +- /* Return control to the setjmp point */ ++ /* Return control to the setjmp point. */ + longjmp (myerr->setjmp_buffer, 1); + } + + static void my_emit_message(j_common_ptr cinfo, int msg_level) + { +- /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ ++ /* cinfo->err really points to a my_error_mgr struct, so coerce pointer. */ + struct my_error_mgr *myerr = (struct my_error_mgr *) cinfo->err; + +- if(msg_level < 0) ++ if (msg_level < 0) + myerr->warning_seen = 1; + +- /* call original emit_message() */ ++ /* Call original emit_message() */ + (myerr->original_emit_message)(cinfo, msg_level); + } + +@@ -311,9 +301,9 @@ static unsigned char chr2[8][MAX_CHROMA_ + + + +-#if 1 /* generation of 'std' Huffman tables... */ ++#if 1 /* Generation of 'std' Huffman tables... */ + +-static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, ++static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, + const UINT8 *bits, const UINT8 *val) + /* Define a Huffman table */ + { +@@ -322,23 +312,23 @@ static void add_huff_table(j_decompress_ + if (*htblptr == NULL) + *htblptr = jpeg_alloc_huff_table((j_common_ptr) dinfo); + +- /* Copy the number-of-symbols-of-each-code-length counts */ +- memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); ++ /* Copy the number-of-symbols-of-each-code-length counts. */ ++ memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); ++ ++ /* ++ * Validate the counts. We do this here mainly so we can copy the right ++ * number of symbols from the val[] array, without risking marching off ++ * the end of memory. jchuff.c will do a more thorough test later. ++ */ ++ nsymbols = 0; + +- /* Validate the counts. We do this here mainly so we can copy the right +- * number of symbols from the val[] array, without risking marching off +- * the end of memory. jchuff.c will do a more thorough test later. +- */ +- nsymbols = 0; +- +- for (len = 1; len <= 16; len++) +- nsymbols += bits[len]; +- +- if (nsymbols < 1 || nsymbols > 256) +- motion_log(LOG_ERR, 0, "%s: Given jpeg buffer was too small", +- __FUNCTION__); ++ for (len = 1; len <= 16; len++) ++ nsymbols += bits[len]; + +- memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8)); ++ if (nsymbols < 1 || nsymbols > 256) ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Given jpeg buffer was too small"); ++ ++ memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8)); + } + + +@@ -351,12 +341,12 @@ static void std_huff_tables (j_decompres + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_luminance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; +- ++ + static const UINT8 bits_dc_chrominance[17] = + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + static const UINT8 val_dc_chrominance[] = + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; +- ++ + static const UINT8 bits_ac_luminance[17] = + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const UINT8 val_ac_luminance[] = +@@ -381,7 +371,7 @@ static void std_huff_tables (j_decompres + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; +- ++ + static const UINT8 bits_ac_chrominance[17] = + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + static const UINT8 val_ac_chrominance[] = +@@ -406,7 +396,7 @@ static void std_huff_tables (j_decompres + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }; +- ++ + add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[0], + bits_dc_luminance, val_dc_luminance); + add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[0], +@@ -443,29 +433,28 @@ static void guarantee_huff_tables(j_deco + * ctype Chroma format for decompression. + * Currently only Y4M_CHROMA_{420JPEG,422} are available + * returns: +- * -1 on fatal error +- * 0 on success +- * 1 if jpeg lib threw a "corrupt jpeg data" warning. +- * in this case, "a damaged output image is likely." +- * ++ * -1 on fatal error ++ * 0 on success ++ * 1 if jpeg lib threw a "corrupt jpeg data" warning. ++ * in this case, "a damaged output image is likely." ++ * + */ +- + int decode_jpeg_raw (unsigned char *jpeg_data, int len, +- int itype, int ctype, unsigned int width, +- unsigned int height, unsigned char *raw0, ++ int itype, int ctype, unsigned int width, ++ unsigned int height, unsigned char *raw0, + unsigned char *raw1, unsigned char *raw2) + { + int numfields, hsf[3], field, yl, yc; + int i, xsl, xsc, xs, hdown; + unsigned int x, y = 0, vsf[3], xd; +- ++ + JSAMPROW row0[16] = { buf0[0], buf0[1], buf0[2], buf0[3], + buf0[4], buf0[5], buf0[6], buf0[7], + buf0[8], buf0[9], buf0[10], buf0[11], + buf0[12], buf0[13], buf0[14], buf0[15]}; + + JSAMPROW row1[8] = { buf1[0], buf1[1], buf1[2], buf1[3], +- buf1[4], buf1[5], buf1[6], buf1[7]}; ++ buf1[4], buf1[5], buf1[6], buf1[7]}; + + JSAMPROW row2[16] = { buf2[0], buf2[1], buf2[2], buf2[3], + buf2[4], buf2[5], buf2[6], buf2[7]}; +@@ -480,7 +469,7 @@ int decode_jpeg_raw (unsigned char *jpeg + /* We set up the normal JPEG error routines, then override error_exit. */ + dinfo.err = jpeg_std_error (&jerr.pub); + jerr.pub.error_exit = my_error_exit; +- /* also hook the emit_message routine to note corrupt-data warnings */ ++ /* Also hook the emit_message routine to note corrupt-data warnings. */ + jerr.original_emit_message = jerr.pub.emit_message; + jerr.pub.emit_message = my_emit_message; + jerr.warning_seen = 0; +@@ -489,26 +478,30 @@ int decode_jpeg_raw (unsigned char *jpeg + if (setjmp (jerr.setjmp_buffer)) { + /* If we get here, the JPEG code has signaled an error. */ + jpeg_destroy_decompress (&dinfo); +- return -1; ++ return 1; + } + + jpeg_create_decompress (&dinfo); + + jpeg_buffer_src (&dinfo, jpeg_data, len); + +- /* Read header, make some checks and try to figure out what the +- user really wants */ +- ++ /* ++ * Read header, make some checks and try to figure out what the ++ * user really wants. ++ */ + jpeg_read_header (&dinfo, TRUE); + dinfo.raw_data_out = TRUE; ++#if JPEG_LIB_VERSION >= 70 ++ dinfo.do_fancy_upsampling = FALSE; ++#endif + dinfo.out_color_space = JCS_YCbCr; + dinfo.dct_method = JDCT_IFAST; + guarantee_huff_tables(&dinfo); + jpeg_start_decompress (&dinfo); + + if (dinfo.output_components != 3) { +- motion_log(LOG_ERR, 0, "%s: Output components of JPEG image = %d, must be 3", +- __FUNCTION__, dinfo.output_components); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Output components of JPEG image" ++ " = %d, must be 3", dinfo.output_components); + goto ERR_EXIT; + } + +@@ -519,43 +512,44 @@ int decode_jpeg_raw (unsigned char *jpeg + + if ((hsf[0] != 2 && hsf[0] != 1) || hsf[1] != 1 || hsf[2] != 1 || + (vsf[0] != 1 && vsf[0] != 2) || vsf[1] != 1 || vsf[2] != 1) { +- motion_log(LOG_ERR, 0, "%s: Unsupported sampling factors, hsf=(%d, %d, %d) " +- "vsf=(%d, %d, %d) !", __FUNCTION__, hsf[0], hsf[1], hsf[2], vsf[0], vsf[1], vsf[2]); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Unsupported sampling factors," ++ " hsf=(%d, %d, %d) vsf=(%d, %d, %d) !", hsf[0], hsf[1], ++ hsf[2], vsf[0], vsf[1], vsf[2]); + goto ERR_EXIT; + } + + if (hsf[0] == 1) { + if (height % 8 != 0) { +- motion_log(LOG_ERR, 0, "%s: YUV 4:4:4 sampling, but image height %d " +- "not dividable by 8 !", __FUNCTION__, height); +- goto ERR_EXIT; ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: YUV 4:4:4 sampling, but image" ++ " height %d not dividable by 8 !", height); ++ goto ERR_EXIT; + } + +- for (y = 0; y < 16; y++) { // allocate a special buffer for the extra sampling depth ++ for (y = 0; y < 16; y++) { // Allocate a special buffer for the extra sampling depth. + row1_444[y] = (unsigned char *)malloc(dinfo.output_width * sizeof(char)); + row2_444[y] = (unsigned char *)malloc(dinfo.output_width * sizeof(char)); + } +- scanarray[1] = row1_444; +- scanarray[2] = row2_444; ++ scanarray[1] = row1_444; ++ scanarray[2] = row2_444; + } + +- /* Height match image height or be exact twice the image height */ ++ /* Height match image height or be exact twice the image height. */ + + if (dinfo.output_height == height) { + numfields = 1; + } else if (2 * dinfo.output_height == height) { + numfields = 2; + } else { +- motion_log(LOG_ERR, 0, "%s: Read JPEG: requested height = %d, " +- "height of image = %d", __FUNCTION__, height, dinfo.output_height); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Read JPEG: requested height = %d, " ++ "height of image = %d", height, dinfo.output_height); + goto ERR_EXIT; + } + + /* Width is more flexible */ + + if (dinfo.output_width > MAX_LUMA_WIDTH) { +- motion_log(LOG_ERR, 0, "%s: Image width of %d exceeds max", +- __FUNCTION__, dinfo.output_width); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image width of %d exceeds max", ++ dinfo.output_width); + goto ERR_EXIT; + } + +@@ -567,7 +561,7 @@ int decode_jpeg_raw (unsigned char *jpeg + else + xsl = 0; + } else if (width == 2 * dinfo.output_width / 3) { +- /* special case of 3:2 downsampling */ ++ /* Special case of 3:2 downsampling */ + hdown = 2; + xsl = 0; + } else { +@@ -590,6 +584,9 @@ int decode_jpeg_raw (unsigned char *jpeg + if (field > 0) { + jpeg_read_header (&dinfo, TRUE); + dinfo.raw_data_out = TRUE; ++#if JPEG_LIB_VERSION >= 70 ++ dinfo.do_fancy_upsampling = FALSE; ++#endif + dinfo.out_color_space = JCS_YCbCr; + dinfo.dct_method = JDCT_IFAST; + jpeg_start_decompress (&dinfo); +@@ -604,16 +601,16 @@ int decode_jpeg_raw (unsigned char *jpeg + yl = yc = (1 - field); + break; + default: +- motion_log(LOG_ERR, 0, "%s: Input is interlaced but no interlacing set", +- __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Input is interlaced but" ++ " no interlacing set"); + goto ERR_EXIT; + } + } else { + yl = yc = 0; +- } ++ } + + while (dinfo.output_scanline < dinfo.output_height) { +- /* read raw data */ ++ /* Read raw data */ + jpeg_read_raw_data (&dinfo, scanarray, 8 * vsf[0]); + + for (y = 0; y < 8 * vsf[0]; yl += numfields, y++) { +@@ -631,7 +628,7 @@ int decode_jpeg_raw (unsigned char *jpeg + raw0[xd] = (2 * row0[y][xs] + row0[y][xs + 1]) / 3; + raw0[xd + 1] = (2 * row0[y][xs + 2] + row0[y][xs + 1]) / 3; + } +- } ++ } + } + + /* Horizontal downsampling of chroma */ +@@ -639,23 +636,23 @@ int decode_jpeg_raw (unsigned char *jpeg + for (y = 0; y < 8; y++) { + xs = xsc; + +- if (hsf[0] == 1) +- for (x = 0; x < width / 2; x++, xs++) { +- row1[y][xs] = (row1_444[y][2*x] + row1_444[y][2*x + 1]) >> 1; +- row2[y][xs] = (row2_444[y][2*x] + row2_444[y][2*x + 1]) >> 1; +- } ++ if (hsf[0] == 1) ++ for (x = 0; x < width / 2; x++, xs++) { ++ row1[y][xs] = (row1_444[y][2*x] + row1_444[y][2*x + 1]) >> 1; ++ row2[y][xs] = (row2_444[y][2*x] + row2_444[y][2*x + 1]) >> 1; ++ } + + xs = xsc; + if (hdown == 0) { + for (x = 0; x < width / 2; x++, xs++) { +- chr1[y][x] = row1[y][xs]; +- chr2[y][x] = row2[y][xs]; +- } ++ chr1[y][x] = row1[y][xs]; ++ chr2[y][x] = row2[y][xs]; ++ } + } else if (hdown == 1) { + for (x = 0; x < width / 2; x++, xs += 2) { + chr1[y][x] = (row1[y][xs] + row1[y][xs + 1]) >> 1; + chr2[y][x] = (row2[y][xs] + row2[y][xs + 1]) >> 1; +- } ++ } + } else { + for (x = 0; x < width / 2; x += 2, xs += 3) { + chr1[y][x] = (2 * row1[y][xs] + row1[y][xs + 1]) / 3; +@@ -663,7 +660,7 @@ int decode_jpeg_raw (unsigned char *jpeg + chr2[y][x] = (2 * row2[y][xs] + row2[y][xs + 1]) / 3; + chr2[y][x + 1] = (2 * row2[y][xs + 2] + row2[y][xs + 1]) / 3; + } +- } ++ } + } + + /* Vertical resampling of chroma */ +@@ -671,68 +668,68 @@ int decode_jpeg_raw (unsigned char *jpeg + switch (ctype) { + case Y4M_CHROMA_422: + if (vsf[0] == 1) { +- /* Just copy */ +- for (y = 0; y < 8 /*&& yc < height */; y++, yc += numfields) { +- xd = yc * width / 2; +- +- for (x = 0; x < width / 2; x++, xd++) { +- raw1[xd] = chr1[y][x]; +- raw2[xd] = chr2[y][x]; +- } +- } +- } else { +- /* upsample */ +- for (y = 0; y < 8 /*&& yc < height */; y++) { +- xd = yc * width / 2; +- ++ /* Just copy */ ++ for (y = 0; y < 8 /*&& yc < height */; y++, yc += numfields) { ++ xd = yc * width / 2; ++ ++ for (x = 0; x < width / 2; x++, xd++) { ++ raw1[xd] = chr1[y][x]; ++ raw2[xd] = chr2[y][x]; ++ } ++ } ++ } else { ++ /* upsample */ ++ for (y = 0; y < 8 /*&& yc < height */; y++) { ++ xd = yc * width / 2; ++ ++ for (x = 0; x < width / 2; x++, xd++) { ++ raw1[xd] = chr1[y][x]; ++ raw2[xd] = chr2[y][x]; ++ } ++ ++ yc += numfields; ++ xd = yc * width / 2; ++ + for (x = 0; x < width / 2; x++, xd++) { +- raw1[xd] = chr1[y][x]; +- raw2[xd] = chr2[y][x]; +- } +- +- yc += numfields; +- xd = yc * width / 2; +- +- for (x = 0; x < width / 2; x++, xd++) { +- raw1[xd] = chr1[y][x]; +- raw2[xd] = chr2[y][x]; +- } +- +- yc += numfields; +- } +- } +- break; +- default: ++ raw1[xd] = chr1[y][x]; ++ raw2[xd] = chr2[y][x]; ++ } ++ ++ yc += numfields; ++ } ++ } ++ break; ++ default: + /* +- * should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some +- * pass things like '420' in with the expectation that anything other than +- * Y4M_CHROMA_422 will default to 420JPEG. +- */ ++ * Should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some ++ * pass things like '420' in with the expectation that anything other than ++ * Y4M_CHROMA_422 will default to 420JPEG. ++ */ + if (vsf[0] == 1) { +- /* Really downsample */ +- for (y = 0; y < 8 /*&& yc < height/2*/; y += 2, yc += numfields) { +- xd = yc * width / 2; +- +- for (x = 0; x < width / 2; x++, xd++) { +- assert(xd < (width * height / 4)); +- raw1[xd] = (chr1[y][x] + chr1[y + 1][x]) >> 1; +- raw2[xd] = (chr2[y][x] + chr2[y + 1][x]) >> 1; +- } +- } +- +- } else { +- /* Just copy */ +- for (y = 0; y < 8 /*&& yc < height/2 */; y++, yc += numfields) { +- xd = yc * width / 2; +- ++ /* Really downsample */ ++ for (y = 0; y < 8 /*&& yc < height/2*/; y += 2, yc += numfields) { ++ xd = yc * width / 2; ++ + for (x = 0; x < width / 2; x++, xd++) { +- raw1[xd] = chr1[y][x]; +- raw2[xd] = chr2[y][x]; +- } +- } +- } +- break; +- } ++ assert(xd < (width * height / 4)); ++ raw1[xd] = (chr1[y][x] + chr1[y + 1][x]) >> 1; ++ raw2[xd] = (chr2[y][x] + chr2[y + 1][x]) >> 1; ++ } ++ } ++ ++ } else { ++ /* Just copy */ ++ for (y = 0; y < 8 /* && yc < height / 2 */; y++, yc += numfields) { ++ xd = yc * width / 2; ++ ++ for (x = 0; x < width / 2; x++, xd++) { ++ raw1[xd] = chr1[y][x]; ++ raw2[xd] = chr2[y][x]; ++ } ++ } ++ } ++ break; ++ } + } + + (void) jpeg_finish_decompress (&dinfo); +@@ -741,10 +738,10 @@ int decode_jpeg_raw (unsigned char *jpeg + } + + if (hsf[0] == 1) { +- for (y = 0; y < 16; y++) { // allocate a special buffer for the extra sampling depth ++ for (y = 0; y < 16; y++) { // Allocate a special buffer for the extra sampling depth. + free(row1_444[y]); +- free(row2_444[y]); +- } ++ free(row2_444[y]); ++ } + } + + jpeg_destroy_decompress (&dinfo); +@@ -768,13 +765,12 @@ ERR_EXIT: + * ctype Chroma format for decompression. + * Currently only Y4M_CHROMA_{420JPEG,422} are available + */ +- + int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, +- int itype, int ctype, unsigned int width, +- unsigned int height, unsigned char *raw0, ++ int itype, int ctype, unsigned int width, ++ unsigned int height, unsigned char *raw0, + unsigned char *raw1, unsigned char *raw2) + { +- int numfields, hsf[3], field, yl, yc, xsl, xsc, xs, xd, hdown; ++ int numfields, field, yl, yc, xsl, xsc, xs, xd, hdown; + unsigned int x, y, vsf[3]; + + JSAMPROW row0[16] = { buf0[0], buf0[1], buf0[2], buf0[3], +@@ -801,43 +797,46 @@ int decode_jpeg_gray_raw(unsigned char * + + jpeg_buffer_src (&dinfo, jpeg_data, len); + +- /* Read header, make some checks and try to figure out what the +- user really wants */ +- ++ /* ++ * Read header, make some checks and try to figure out what the ++ * user really wants. ++ */ + jpeg_read_header (&dinfo, TRUE); + dinfo.raw_data_out = TRUE; ++#if JPEG_LIB_VERSION >= 70 ++ dinfo.do_fancy_upsampling = FALSE; ++#endif + dinfo.out_color_space = JCS_GRAYSCALE; + dinfo.dct_method = JDCT_IFAST; +- +- if (dinfo.jpeg_color_space != JCS_GRAYSCALE) { +- motion_log(LOG_ERR, 0, "%s: Expected grayscale colorspace for JPEG raw decoding", +- __FUNCTION__); ++ ++ if (dinfo.jpeg_color_space != JCS_GRAYSCALE) { ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Expected grayscale colorspace" ++ " for JPEG raw decoding"); + goto ERR_EXIT; + } + + guarantee_huff_tables(&dinfo); + jpeg_start_decompress (&dinfo); + +- hsf[0] = 1; hsf[1] = 1; hsf[2] = 1; + vsf[0]= 1; vsf[1] = 1; vsf[2] = 1; + +- /* Height match image height or be exact twice the image height */ ++ /* Height match image height or be exact twice the image height. */ + + if (dinfo.output_height == height) { + numfields = 1; + } else if (2 * dinfo.output_height == height) { + numfields = 2; + } else { +- motion_log(LOG_ERR, 0, "%s: Read JPEG: requested height = %d, " +- "height of image = %d", __FUNCTION__, height, dinfo.output_height); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Read JPEG: requested height = %d, " ++ "height of image = %d", height, dinfo.output_height); + goto ERR_EXIT; + } + + /* Width is more flexible */ + + if (dinfo.output_width > MAX_LUMA_WIDTH) { +- motion_log(LOG_ERR, 0, "%s: Image width of %d exceeds max", +- __FUNCTION__, dinfo.output_width); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image width of %d exceeds max", ++ dinfo.output_width); + goto ERR_EXIT; + } + +@@ -872,6 +871,9 @@ int decode_jpeg_gray_raw(unsigned char * + if (field > 0) { + jpeg_read_header (&dinfo, TRUE); + dinfo.raw_data_out = TRUE; ++#if JPEG_LIB_VERSION >= 70 ++ dinfo.do_fancy_upsampling = FALSE; ++#endif + dinfo.out_color_space = JCS_GRAYSCALE; + dinfo.dct_method = JDCT_IFAST; + jpeg_start_decompress (&dinfo); +@@ -886,13 +888,13 @@ int decode_jpeg_gray_raw(unsigned char * + yl = yc = (1 - field); + break; + default: +- motion_log(LOG_ERR, 0, "%s: Input is interlaced but no interlacing set", +- __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Input is interlaced" ++ " but no interlacing set"); + goto ERR_EXIT; + } + } else { + yl = yc = 0; +- } ++ } + + while (dinfo.output_scanline < dinfo.output_height) { + jpeg_read_raw_data (&dinfo, scanarray, 16); +@@ -901,10 +903,10 @@ int decode_jpeg_gray_raw(unsigned char * + xd = yl * width; + xs = xsl; + +- if (hdown == 0) { // no horiz downsampling ++ if (hdown == 0) { // No horiz downsampling + for (x = 0; x < width; x++) + raw0[xd++] = row0[y][xs++]; +- } else if (hdown == 1) { // half the res ++ } else if (hdown == 1) { // Half the res + for (x = 0; x < width; x++, xs += 2) + raw0[xd++] = (row0[y][xs] + row0[y][xs + 1]) >> 1; + } else { // 2:3 downsampling +@@ -912,7 +914,7 @@ int decode_jpeg_gray_raw(unsigned char * + raw0[xd] = (2 * row0[y][xs] + row0[y][xs + 1]) / 3; + raw0[xd + 1] = (2 * row0[y][xs + 2] + row0[y][xs + 1]) / 3; + } +- } ++ } + } + + +@@ -923,21 +925,21 @@ int decode_jpeg_gray_raw(unsigned char * + for (x = 0; x < width / 2; x++, xs++) { + chr1[y][x] = 0; //row1[y][xs]; + chr2[y][x] = 0; //row2[y][xs]; +- } ++ } + } else if (hdown == 1) { + for (x = 0; x < width / 2; x++, xs += 2) { +- chr1[y][x] = 0; //(row1[y][xs] + row1[y][xs + 1]) >> 1; +- chr2[y][x] = 0; //(row2[y][xs] + row2[y][xs + 1]) >> 1; +- } ++ chr1[y][x] = 0; //(row1[y][xs] + row1[y][xs + 1]) >> 1; ++ chr2[y][x] = 0; //(row2[y][xs] + row2[y][xs + 1]) >> 1; ++ } + } else { + for (x = 0; x < width / 2; x += 2, xs += 3) { +- chr1[y][x] = 0; //(2 * row1[y][xs] + row1[y][xs + 1]) / 3; +- chr1[y][x + 1] = 0; +- //(2 * row1[y][xs + 2] + row1[y][xs + 1]) / 3; +- chr2[y][x] = 0; // (2 * row2[y][xs] + row2[y][xs + 1]) / 3; +- chr2[y][x + 1] = 0; +- //(2 * row2[y][xs + 2] + row2[y][xs + 1]) / 3; +- } ++ chr1[y][x] = 0; //(2 * row1[y][xs] + row1[y][xs + 1]) / 3; ++ chr1[y][x + 1] = 0; ++ //(2 * row1[y][xs + 2] + row1[y][xs + 1]) / 3; ++ chr2[y][x] = 0; // (2 * row2[y][xs] + row2[y][xs + 1]) / 3; ++ chr2[y][x + 1] = 0; ++ //(2 * row2[y][xs + 2] + row2[y][xs + 1]) / 3; ++ } + } + } + +@@ -945,7 +947,7 @@ int decode_jpeg_gray_raw(unsigned char * + case Y4M_CHROMA_422: + if (vsf[0] == 1) { + /* Just copy */ +- for (y = 0; y < 8 /*&& yc < height */; y++, yc += numfields) { ++ for (y = 0; y < 8 /* && yc < height */; y++, yc += numfields) { + xd = yc * width / 2; + + for (x = 0; x < width / 2; x++, xd++) { +@@ -955,9 +957,9 @@ int decode_jpeg_gray_raw(unsigned char * + } + } else { + /* upsample */ +- for (y = 0; y < 8 /*&& yc < height */; y++) { ++ for (y = 0; y < 8 /* && yc < height */; y++) { + xd = yc * width / 2; +- ++ + for (x = 0; x < width / 2; x++, xd++) { + raw1[xd] = 127; //chr1[y][x]; + raw2[xd] = 127; //chr2[y][x]; +@@ -965,22 +967,22 @@ int decode_jpeg_gray_raw(unsigned char * + + yc += numfields; + xd = yc * width / 2; +- ++ + for (x = 0; x < width / 2; x++, xd++) { + raw1[xd] = 127; //chr1[y][x]; + raw2[xd] = 127; //chr2[y][x]; + } + + yc += numfields; +- } +- } +- break; ++ } ++ } ++ break; + /* +- * should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some ++ * Should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some + * pass things like '420' in with the expectation that anything other than + * Y4M_CHROMA_422 will default to 420JPEG. + */ +- default: ++ default: + if (vsf[0] == 1) { + /* Really downsample */ + for (y = 0; y < 8; y += 2, yc += numfields) { +@@ -988,11 +990,11 @@ int decode_jpeg_gray_raw(unsigned char * + + for (x = 0; x < width / 2; x++, xd++) { + raw1[xd] = 127; //(chr1[y][x] + chr1[y + 1][x]) >> 1; +- raw2[xd] = 127; //(chr2[y][x] + chr2[y + 1][x]) >> 1; ++ raw2[xd] = 127; //(chr2[y][x] + chr2[y + 1][x]) >> 1; + } +- } +- } else { +- /* Just copy */ ++ } ++ } else { ++ /* Just copy */ + + for (y = 0; y < 8; y++, yc += numfields) { + xd = yc * width / 2; +@@ -1000,11 +1002,11 @@ int decode_jpeg_gray_raw(unsigned char * + for (x = 0; x < width / 2; x++, xd++) { + raw1[xd] = 127; //chr1[y][x]; + raw2[xd] = 127; //chr2[y][x]; +- } +- } +- } +- break; +- } ++ } ++ } ++ } ++ break; ++ } + } + + (void) jpeg_finish_decompress (&dinfo); +@@ -1028,8 +1030,8 @@ ERR_EXIT: + * may be interlaced * + * * + *******************************************************************/ +- +- /* ++ ++/* + * jpeg_data: Buffer to hold output jpeg + * len: Length of buffer + * itype: 0: Not interlaced +@@ -1038,10 +1040,9 @@ ERR_EXIT: + * ctype Chroma format for decompression. + * Currently only Y4M_CHROMA_{420JPEG,422} are available + */ +- + int encode_jpeg_raw(unsigned char *jpeg_data, int len, int quality, +- int itype, int ctype, unsigned int width, +- unsigned int height, unsigned char *raw0, ++ int itype, int ctype, unsigned int width, ++ unsigned int height, unsigned char *raw0, + unsigned char *raw1, unsigned char *raw2) + { + int numfields, field, yl, yc, y, i; +@@ -1090,22 +1091,22 @@ int encode_jpeg_raw(unsigned char *jpeg_ + cinfo.input_gamma = 1.0; + + cinfo.comp_info[0].h_samp_factor = 2; +- cinfo.comp_info[0].v_samp_factor = 1; /*1||2 */ ++ cinfo.comp_info[0].v_samp_factor = 1; /*1||2 */ + cinfo.comp_info[1].h_samp_factor = 1; + cinfo.comp_info[1].v_samp_factor = 1; +- cinfo.comp_info[2].h_samp_factor = 1; /*1||2 */ ++ cinfo.comp_info[2].h_samp_factor = 1; /*1||2 */ + cinfo.comp_info[2].v_samp_factor = 1; + + + if ((width > 4096) || (height > 4096)) { +- motion_log(LOG_ERR, 0, "%s: Image dimensions (%dx%d) exceed lavtools' max " +- "(4096x4096)", __FUNCTION__, width, height); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image dimensions (%dx%d) exceed" ++ " lavtools' max (4096x4096)", width, height); + goto ERR_EXIT; + } + + if ((width % 16) || (height % 16)) { +- motion_log(LOG_ERR, 0, "%s: Image dimensions (%dx%d) not multiples of 16", +- __FUNCTION__, width, height); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image dimensions (%dx%d) not" ++ " multiples of 16", width, height); + goto ERR_EXIT; + } + +@@ -1113,14 +1114,14 @@ int encode_jpeg_raw(unsigned char *jpeg_ + + switch (itype) { + case Y4M_ILACE_TOP_FIRST: +- case Y4M_ILACE_BOTTOM_FIRST: /* interlaced */ ++ case Y4M_ILACE_BOTTOM_FIRST: /* Interlaced */ + numfields = 2; + break; + default: + numfields = 1; + if (height > 2048) { +- motion_log(LOG_ERR, 0, "%s: Image height (%d) exceeds lavtools max " +- "for non-interlaced frames", __FUNCTION__, height); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image height (%d) exceeds" ++ " lavtools max for non-interlaced frames", height); + goto ERR_EXIT; + } + } +@@ -1131,7 +1132,7 @@ int encode_jpeg_raw(unsigned char *jpeg_ + + for (field = 0; field < numfields; field++) { + jpeg_start_compress (&cinfo, FALSE); +- ++ + if (numfields == 2) { + static const JOCTET marker0[40]; + +@@ -1139,22 +1140,22 @@ int encode_jpeg_raw(unsigned char *jpeg_ + jpeg_write_marker(&cinfo, JPEG_APP0 + 1, marker0, 40); + + switch (itype) { +- case Y4M_ILACE_TOP_FIRST: /* top field first */ ++ case Y4M_ILACE_TOP_FIRST: /* Top field first */ + yl = yc = field; + break; +- case Y4M_ILACE_BOTTOM_FIRST: /* bottom field first */ ++ case Y4M_ILACE_BOTTOM_FIRST: /* Bottom field first */ + yl = yc = (1 - field); + break; + default: +- motion_log(LOG_ERR, 0, "%s: Input is interlaced but no interlacing set", +- __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Input is interlaced" ++ " but no interlacing set"); + goto ERR_EXIT; + } + + } else { + yl = yc = 0; + } +- ++ + while (cinfo.next_scanline < cinfo.image_height) { + + for (y = 0; y < 8 * cinfo.comp_info[0].v_samp_factor; +@@ -1177,12 +1178,12 @@ int encode_jpeg_raw(unsigned char *jpeg_ + + (void) jpeg_finish_compress (&cinfo); + } +- ++ + /* FIXME */ + i = len - cinfo.dest->free_in_buffer; + + jpeg_destroy_compress (&cinfo); +- return i; /* size of jpeg */ ++ return i; /* Size of jpeg */ + + ERR_EXIT: + jpeg_destroy_compress (&cinfo); +--- motion-3.2.12.orig/jpegutils.h ++++ motion-3.2.12/jpegutils.h +@@ -1,10 +1,10 @@ +-/* ++/* + * jpegutils.h: Some Utility programs for dealing with + * JPEG encoded images + * + * Copyright (C) 1999 Rainer Johanni + * Copyright (C) 2001 pHilipp Zabel +- * Copyright (C) 2008 Angel Carpintero ++ * Copyright (C) 2008 Angel Carpintero + * + */ + +@@ -44,17 +44,17 @@ + + + int decode_jpeg_raw(unsigned char *jpeg_data, int len, +- int itype, int ctype, unsigned int width, +- unsigned int height, unsigned char *raw0, ++ int itype, int ctype, unsigned int width, ++ unsigned int height, unsigned char *raw0, + unsigned char *raw1, unsigned char *raw2); + + int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, +- int itype, int ctype, unsigned int width, +- unsigned int height, unsigned char *raw0, ++ int itype, int ctype, unsigned int width, ++ unsigned int height, unsigned char *raw0, + unsigned char *raw1, unsigned char *raw2); + + int encode_jpeg_raw(unsigned char *jpeg_data, int len, int quality, +- int itype, int ctype, unsigned int width, +- unsigned int height, unsigned char *raw0, ++ int itype, int ctype, unsigned int width, ++ unsigned int height, unsigned char *raw0, + unsigned char *raw1, unsigned char *raw2); + #endif +--- /dev/null ++++ motion-3.2.12/logger.c +@@ -0,0 +1,259 @@ ++/* ++ * logger.c ++ * ++ * Logger for motion ++ * ++ * Copyright 2005, William M. Brack ++ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) ++ * This software is distributed under the GNU Public License Version 2 ++ * See also the file 'COPYING'. ++ * ++ */ ++ ++#include "logger.h" /* already includes motion.h */ ++#include ++ ++static int log_mode = LOGMODE_SYSLOG; ++static FILE *logfile; ++static unsigned int log_level = LEVEL_DEFAULT; ++static unsigned int log_type = TYPE_DEFAULT; ++ ++static const char *log_type_str[] = {NULL, "COR", "STR", "ENC", "NET", "DBL", "EVT", "TRK", "VID", "ALL"}; ++static const char *log_level_str[] = {"EMG", "ALR", "CRT", "ERR", "WRN", "NTC", "INF", "DBG", "ALL", NULL}; ++ ++ ++/** ++ * get_log_type ++ * ++ * ++ * Returns: index of log type or 0 if not valid type. ++ */ ++int get_log_type(const char *type) ++{ ++ unsigned int i, ret = 0; ++ unsigned int maxtype = sizeof(log_type_str)/sizeof(const char *); ++ ++ for (i = 1;i < maxtype; i++) { ++ if (!strncasecmp(type, log_type_str[i], 3)) { ++ ret = i; ++ break; ++ } ++ } ++ ++ return ret; ++} ++ ++/** ++ * get_log_type_str ++ * Gets string value for type log level. ++ * ++ * Returns: name of type log level. ++ */ ++const char* get_log_type_str(unsigned int type) ++{ ++ return log_type_str[type]; ++} ++ ++/** ++ * set_log_type ++ * Sets log type level. ++ * ++ * Returns: nothing. ++ */ ++void set_log_type(unsigned int type) ++{ ++ log_type = type; ++ //printf("set log type %d\n", type); ++} ++ ++/** ++ * get_log_level_str ++ * Gets string value for log level. ++ * ++ * Returns: name of log level. ++ */ ++const char* get_log_level_str(unsigned int level) ++{ ++ return log_level_str[level]; ++} ++ ++/** ++ * set_log_level ++ * Sets log level. ++ * ++ * Returns nothing. ++ */ ++void set_log_level(unsigned int level) ++{ ++ log_level = level; ++ //printf("set log level %d\n", level); ++} ++ ++/** ++ * set_log_mode ++ * Sets mode of logging , could be using syslog or files. ++ * ++ * Returns: nothing. ++ */ ++void set_log_mode(int mode) ++{ ++ log_mode = mode; ++ //printf("set log mode %d\n", mode); ++} ++ ++/** ++ * set_logfile ++ * Sets logfile to be used instead of syslog. ++ * ++ * Returns: pointer to log file. ++ */ ++FILE * set_logfile(const char *logfile_name) ++{ ++ log_mode = LOGMODE_SYSLOG; /* Setup temporary to let log if myfopen fails */ ++ logfile = myfopen(logfile_name, "a", 0); ++ ++ /* If logfile was opened correctly */ ++ if (logfile) ++ log_mode = LOGMODE_FILE; ++ ++ return logfile; ++} ++ ++/** ++ * str_time ++ * ++ * Return: string with human readable time ++ */ ++static char *str_time(void) ++{ ++ static char buffer[16]; ++ time_t now = 0; ++ ++ now = time(0); ++ strftime(buffer, 16, "%b %d %H:%M:%S", localtime(&now)); ++ return buffer; ++} ++ ++/** ++ * MOTION_LOG ++ * ++ * This routine is used for printing all informational, debug or error ++ * messages produced by any of the other motion functions. It always ++ * produces a message of the form "[n] {message}", and (if the param ++ * 'errno_flag' is set) follows the message with the associated error ++ * message from the library. ++ * ++ * Parameters: ++ * ++ * level logging level for the 'syslog' function ++ * ++ * type logging type. ++ * ++ * errno_flag if set, the log message should be followed by the ++ * error message. ++ * fmt the format string for producing the message ++ * ap variable-length argument list ++ * ++ * Returns: ++ * Nothing ++ */ ++void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, ...) ++{ ++ int errno_save, n; ++ char buf[1024]; ++/* GNU-specific strerror_r() */ ++#if (!defined(XSI_STRERROR_R)) ++ char msg_buf[100]; ++#endif ++ va_list ap; ++ int threadnr; ++ ++ /* Exit if level is greater than log_level */ ++ if ((unsigned int)level > log_level) ++ return; ++ ++ /* Exit if type is not equal to log_type and not TYPE_ALL */ ++ 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, ++ * which is nice because that's what we want in that case. ++ */ ++ threadnr = (unsigned long)pthread_getspecific(tls_key_threadnr); ++ ++ /* ++ * First we save the current 'error' value. This is required because ++ * the subsequent calls to vsnprintf could conceivably change it! ++ */ ++ errno_save = errno; ++ ++ /* ++ * Prefix the message with the log level string, log type string, ++ * time and thread number. e.g. [1] [ERR] [ENC] [Apr 03 00:08:44] blah ++ * ++ */ ++ if (!log_mode) { ++ n = snprintf(buf, sizeof(buf), "[%d] [%s] [%s] [%s] ", ++ threadnr, get_log_level_str(level), get_log_type_str(type), ++ str_time()); ++ } else { ++ /* ++ * Prefix the message with the log level string, log type string ++ * and thread number. e.g. [1] [DBG] [TRK] blah ++ */ ++ n = snprintf(buf, sizeof(buf), "[%d] [%s] [%s] ", ++ threadnr, get_log_level_str(level), get_log_type_str(type)); ++ } ++ ++ /* Next add the user's message. */ ++ va_start(ap, fmt); ++ n += vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); ++ buf[1023] = '\0'; ++ ++ /* If errno_flag is set, add on the library error message. */ ++ if (errno_flag) { ++ size_t buf_len = strlen(buf); ++ ++ // just knock off 10 characters if we're that close... ++ if (buf_len + 10 > 1024) { ++ buf[1024 - 10] = '\0'; ++ buf_len = 1024 - 10; ++ } ++ ++ strncat(buf, ": ", 1024 - buf_len); ++ n += 2; ++ /* ++ * This is bad - apparently gcc/libc wants to use the non-standard GNU ++ * version of strerror_r, which doesn't actually put the message into ++ * my buffer :-(. I have put in a 'hack' to get around this. ++ */ ++#if defined(XSI_STRERROR_R) ++ /* XSI-compliant strerror_r() */ ++ strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */ ++#else ++ /* GNU-specific strerror_r() */ ++ strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf)); ++#endif ++ } ++ ++ if (!log_mode) { ++ strncat(buf, "\n", 1024 - strlen(buf)); ++ fputs(buf, logfile); ++ fflush(logfile); ++ ++ /* If log_mode, send the message to the syslog. */ ++ } else { ++ syslog(level, "%s", buf); ++ strncat(buf, "\n", 1024 - strlen(buf)); ++ fputs(buf, stderr); ++ fflush(stderr); ++ } ++ ++ /* Clean up the argument list routine. */ ++ va_end(ap); ++} ++ +--- /dev/null ++++ motion-3.2.12/logger.h +@@ -0,0 +1,63 @@ ++/* ++ * logger.h ++ * ++ * Include file for logger.c ++ * ++ * Copyright 2005, William M. Brack ++ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) ++ * This software is distributed under the GNU Public License Version 2 ++ * See also the file 'COPYING'. ++ * ++ */ ++#ifndef _INCLUDE_LOGGER_H_ ++#define _INCLUDE_LOGGER_H_ ++ ++#include "motion.h" ++#include ++ ++/* Logging mode */ ++#define LOGMODE_FILE 0 /* Log messages to file */ ++#define LOGMODE_SYSLOG 1 /* Log messages to syslog */ ++ ++#define NO_ERRNO 0 /* Flag to avoid how message associated to errno */ ++#define SHOW_ERRNO 1 /* Flag to show message associated to errno */ ++ ++/* Log levels */ ++#define LOG_ALL 9 ++#define EMG LOG_EMERG /* syslog 0 motion 1 */ ++#define ALR LOG_ALERT /* syslog 1 motion 2 */ ++#define CRT LOG_CRIT /* syslog 2 motion 3 */ ++#define ERR LOG_ERR /* syslog 3 motion 4 */ ++#define WRN LOG_WARNING /* syslog 4 motion 5 */ ++#define NTC LOG_NOTICE /* syslog 5 motion 6 */ ++#define INF LOG_INFO /* syslog 6 motion 7 */ ++#define DBG LOG_DEBUG /* syslog 7 motion 8 */ ++#define ALL LOG_ALL /* syslog 8 motion 9 */ ++#define LEVEL_DEFAULT NTC /* syslog 5 motion 6 default */ ++#define SHOW_LEVEL_VALUE(x) (x+1) ++ ++/* Log types */ ++#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 */ ++ ++#define MOTION_LOG(x, y, z, format, args...) motion_log(x, y, z, format, __FUNCTION__, ##args) ++ ++int get_log_type(const char* type); ++const char* get_log_type_str(unsigned int type); ++void set_log_type(unsigned int type); ++const char* get_log_level_str(unsigned int level); ++void set_log_level(unsigned int level); ++void set_log_mode(int mode); ++FILE * set_logfile(const char *logfile_name); ++void motion_log(int, unsigned int, int, const char *, ...); ++ ++#endif +--- /dev/null ++++ motion-3.2.12/md5.c +@@ -0,0 +1,348 @@ ++/* ++ * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm ++ * taken from RFC 1321 ++ */ ++ ++/* ++ Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All ++rights reserved. ++ ++License to copy and use this software is granted provided that it ++is identified as the "RSA Data Security, Inc. MD5 Message-Digest ++Algorithm" in all material mentioning or referencing this software ++or this function. ++ ++License is also granted to make and use derivative works provided ++that such works are identified as "derived from the RSA Data ++Security, Inc. MD5 Message-Digest Algorithm" in all material ++mentioning or referencing the derived work. ++ ++RSA Data Security, Inc. makes no representations concerning either ++the merchantability of this software or the suitability of this ++software for any particular purpose. It is provided "as is" ++without express or implied warranty of any kind. ++ ++These notices must be retained in any copies of any part of this ++documentation and/or software. ++*/ ++ ++#include "md5.h" ++ ++/* ++ * Constants for MD5Transform routine. ++ */ ++ ++#define S11 7 ++#define S12 12 ++#define S13 17 ++#define S14 22 ++#define S21 5 ++#define S22 9 ++#define S23 14 ++#define S24 20 ++#define S31 4 ++#define S32 11 ++#define S33 16 ++#define S34 23 ++#define S41 6 ++#define S42 10 ++#define S43 15 ++#define S44 21 ++ ++static void MD5Transform(UINT4 [4], unsigned char [64]); ++static void Encode(unsigned char *, UINT4 *, unsigned int); ++static void Decode(UINT4 *, unsigned char *, unsigned int); ++static void MD5_memcpy(POINTER, POINTER, unsigned int); ++static void MD5_memset(POINTER, int, unsigned int); ++ ++static unsigned char PADDING[64] = { ++ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ++}; ++ ++/* ++ * F, G, H and I are basic MD5 functions. ++ */ ++#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) ++#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) ++#define H(x, y, z) ((x) ^ (y) ^ (z)) ++#define I(x, y, z) ((y) ^ ((x) | (~z))) ++ ++/* ++ * ROTATE_LEFT rotates x left n bits. ++ */ ++#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) ++ ++/* ++ * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. ++ * Rotation is separate from addition to prevent recomputation. ++ */ ++#define FF(a, b, c, d, x, s, ac) { \ ++ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ ++ (a) = ROTATE_LEFT ((a), (s)); \ ++ (a) += (b); \ ++ } ++#define GG(a, b, c, d, x, s, ac) { \ ++ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ ++ (a) = ROTATE_LEFT ((a), (s)); \ ++ (a) += (b); \ ++ } ++#define HH(a, b, c, d, x, s, ac) { \ ++ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ ++ (a) = ROTATE_LEFT ((a), (s)); \ ++ (a) += (b); \ ++ } ++#define II(a, b, c, d, x, s, ac) { \ ++ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ ++ (a) = ROTATE_LEFT ((a), (s)); \ ++ (a) += (b); \ ++ } ++ ++/* ++ * MD5 initialization. Begins an MD5 operation, writing a new context. ++ */ ++void MD5Init(MD5_CTX *context) ++{ ++ context->count[0] = context->count[1] = 0; ++ /* Load magic initialization constants. */ ++ context->state[0] = 0x67452301; ++ context->state[1] = 0xefcdab89; ++ context->state[2] = 0x98badcfe; ++ context->state[3] = 0x10325476; ++} ++ ++/* ++ * MD5 block update operation. Continues an MD5 message-digest ++ * operation, processing another message block, and updating the ++ * context. ++ */ ++void MD5Update ( ++ MD5_CTX *context, /* context */ ++ unsigned char *input, /* input block */ ++ unsigned int inputLen) /* length of input block */ ++{ ++ unsigned int i, index, partLen; ++ ++ /* Compute number of bytes mod 64 */ ++ index = (unsigned int)((context->count[0] >> 3) & 0x3F); ++ ++ /* Update number of bits */ ++ if ((context->count[0] += ((UINT4)inputLen << 3)) ++ < ((UINT4)inputLen << 3)) ++ context->count[1]++; ++ context->count[1] += ((UINT4)inputLen >> 29); ++ ++ partLen = 64 - index; ++ ++ /* Transform as many times as possible. */ ++ if (inputLen >= partLen) { ++ MD5_memcpy ++ ((POINTER)&context->buffer[index], (POINTER)input, partLen); ++ MD5Transform (context->state, context->buffer); ++ ++ for (i = partLen; i + 63 < inputLen; i += 64) ++ MD5Transform (context->state, &input[i]); ++ ++ index = 0; ++ } ++ else ++ i = 0; ++ ++ /* Buffer remaining input */ ++ MD5_memcpy ++ ((POINTER)&context->buffer[index], (POINTER)&input[i], ++ inputLen-i); ++} ++ ++/* ++ * MD5 finalization. Ends an MD5 message-digest operation, writing the ++ * the message digest and zeroizing the context. ++ */ ++void MD5Final ( ++ unsigned char digest[16], /* message digest */ ++ MD5_CTX *context) /* context */ ++{ ++ unsigned char bits[8]; ++ unsigned int index, padLen; ++ ++ /* Save number of bits */ ++ Encode (bits, context->count, 8); ++ ++ /* Pad out to 56 mod 64. */ ++ index = (unsigned int)((context->count[0] >> 3) & 0x3f); ++ padLen = (index < 56) ? (56 - index) : (120 - index); ++ MD5Update (context, PADDING, padLen); ++ ++ /* Append length (before padding) */ ++ MD5Update (context, bits, 8); ++ ++ /* Store state in digest */ ++ Encode (digest, context->state, 16); ++ ++ /* Zeroize sensitive information. */ ++ MD5_memset ((POINTER)context, 0, sizeof (*context)); ++} ++ ++/* ++ * MD5 basic transformation. Transforms state based on block. ++ */ ++static void MD5Transform (state, block) ++UINT4 state[4]; ++unsigned char block[64]; ++{ ++ UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; ++ ++ Decode (x, block, 64); ++ ++ /* Round 1 */ ++ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ ++ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ ++ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ ++ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ ++ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ ++ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ ++ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ ++ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ ++ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ ++ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ ++ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ ++ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ ++ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ ++ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ ++ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ ++ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ ++ ++ /* Round 2 */ ++ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ ++ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ ++ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ ++ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ ++ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ ++ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ ++ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ ++ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ ++ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ ++ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ ++ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ ++ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ ++ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ ++ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ ++ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ ++ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ ++ ++ /* Round 3 */ ++ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ ++ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ ++ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ ++ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ ++ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ ++ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ ++ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ ++ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ ++ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ ++ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ ++ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ ++ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ ++ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ ++ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ ++ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ ++ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ ++ ++ /* Round 4 */ ++ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ ++ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ ++ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ ++ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ ++ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ ++ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ ++ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ ++ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ ++ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ ++ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ ++ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ ++ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ ++ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ ++ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ ++ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ ++ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ ++ ++ state[0] += a; ++ state[1] += b; ++ state[2] += c; ++ state[3] += d; ++ ++ /* Zeroize sensitive information. */ ++ MD5_memset ((POINTER)x, 0, sizeof (x)); ++} ++ ++/* ++ * Encodes input (UINT4) into output (unsigned char). Assumes len is ++ * a multiple of 4. ++ */ ++static void Encode (output, input, len) ++unsigned char *output; ++UINT4 *input; ++unsigned int len; ++{ ++ unsigned int i, j; ++ ++ for (i = 0, j = 0; j < len; i++, j += 4) { ++ output[j] = (unsigned char)(input[i] & 0xff); ++ output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); ++ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); ++ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); ++ } ++} ++ ++/* ++ * Decodes input (unsigned char) into output (UINT4). Assumes len is ++ * a multiple of 4. ++ */ ++static void Decode (output, input, len) ++UINT4 *output; ++unsigned char *input; ++unsigned int len; ++{ ++ unsigned int i, j; ++ ++ for (i = 0, j = 0; j < len; i++, j += 4) ++ output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | ++ (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); ++} ++ ++/* Note: Replace "for loop" with standard memcpy if possible. */ ++ ++static void MD5_memcpy (output, input, len) ++POINTER output; ++POINTER input; ++unsigned int len; ++{ ++ unsigned int i; ++ ++ for (i = 0; i < len; i++) ++ output[i] = input[i]; ++} ++ ++/* Note: Replace "for loop" with standard memset if possible. */ ++static void MD5_memset (output, value, len) ++POINTER output; ++int value; ++unsigned int len; ++{ ++ unsigned int i; ++ ++ for (i = 0; i < len; i++) ++ ((char *)output)[i] = (char)value; ++} ++ ++void MD5(unsigned char *message,unsigned long message_length,unsigned char *md) ++{ ++ MD5_CTX state; ++ ++ MD5Init(&state); ++ MD5Update(&state,message,message_length); ++ MD5Final(md,&state); ++ ++ return; ++} +--- /dev/null ++++ motion-3.2.12/md5.h +@@ -0,0 +1,77 @@ ++/* ++ * MD5.H - header file for MD5C.C ++ * taken from RFC 1321 ++ */ ++ ++#ifndef MD5_H ++#define MD5_H ++ ++/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All ++rights reserved. ++ ++License to copy and use this software is granted provided that it ++is identified as the "RSA Data Security, Inc. MD5 Message-Digest ++Algorithm" in all material mentioning or referencing this software ++or this function. ++ ++License is also granted to make and use derivative works provided ++that such works are identified as "derived from the RSA Data ++Security, Inc. MD5 Message-Digest Algorithm" in all material ++mentioning or referencing the derived work. ++ ++RSA Data Security, Inc. makes no representations concerning either ++the merchantability of this software or the suitability of this ++software for any particular purpose. It is provided "as is" ++without express or implied warranty of any kind. ++ ++These notices must be retained in any copies of any part of this ++documentation and/or software. ++ */ ++ ++/* GLOBAL.H - RSAREF types and constants ++ */ ++ ++/* ++ * PROTOTYPES should be set to one if and only if the compiler supports ++ * function argument prototyping. ++ * The following makes PROTOTYPES default to 0 if it has not already ++ * been defined with C compiler flags. ++ */ ++ ++#ifndef PROTOTYPES ++#define PROTOTYPES 0 ++#endif ++ ++/* POINTER defines a generic pointer type */ ++typedef unsigned char *POINTER; ++ ++/* UINT2 defines a two byte word */ ++typedef unsigned short int UINT2; ++ ++/* UINT4 defines a four byte word */ ++typedef unsigned int UINT4; ++ ++/* ++ * PROTO_LIST is defined depending on how PROTOTYPES is defined above. ++ * If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it ++ * returns an empty list. ++ */ ++#if PROTOTYPES ++#define PROTO_LIST(list) list ++#else ++#define PROTO_LIST(list) () ++#endif ++ ++/* MD5 context. */ ++typedef struct { ++ UINT4 state[4]; /* state (ABCD) */ ++ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ ++ unsigned char buffer[64]; /* input buffer */ ++} MD5_CTX; ++ ++void MD5Init(MD5_CTX *); ++void MD5Update(MD5_CTX *, unsigned char *, unsigned int); ++void MD5Final(unsigned char [16], MD5_CTX *); ++void MD5(unsigned char *message, unsigned long message_length, unsigned char *md); ++ ++#endif // MD5_H +--- motion-3.2.12.orig/mmx.h ++++ motion-3.2.12/mmx.h +@@ -12,22 +12,22 @@ + */ + + typedef union { +- long long q; /* Quadword (64-bit) value */ +- unsigned long long uq; /* Unsigned Quadword */ +- int d[2]; /* 2 Doubleword (32-bit) values */ +- unsigned int ud[2]; /* 2 Unsigned Doubleword */ +- short w[4]; /* 4 Word (16-bit) values */ +- unsigned short uw[4]; /* 4 Unsigned Word */ +- char b[8]; /* 8 Byte (8-bit) values */ +- unsigned char ub[8]; /* 8 Unsigned Byte */ +- float s[2]; /* Single-precision (32-bit) value */ ++ long long q; /* Quadword (64-bit) value */ ++ unsigned long long uq; /* Unsigned Quadword */ ++ int d[2]; /* 2 Doubleword (32-bit) values */ ++ unsigned int ud[2]; /* 2 Unsigned Doubleword */ ++ short w[4]; /* 4 Word (16-bit) values */ ++ unsigned short uw[4]; /* 4 Unsigned Word */ ++ char b[8]; /* 8 Byte (8-bit) values */ ++ unsigned char ub[8]; /* 8 Unsigned Byte */ ++ float s[2]; /* Single-precision (32-bit) value */ + } mmx_t; /* On an 8-byte (64-bit) boundary */ + + + #define mmx_i2r(op,imm,reg) \ + __asm__ __volatile__ (#op " %0, %%" #reg \ + : /* nothing */ \ +- : "i" (imm) ) ++ : "i" (imm)) + + #define mmx_m2r(op,mem,reg) \ + __asm__ __volatile__ (#op " %0, %%" #reg \ +@@ -188,7 +188,7 @@ typedef union { + #define mmx_r2ri(op,regs,regd,imm) \ + __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \ + : /* nothing */ \ +- : "X" (imm) ) ++ : "X" (imm)) + + #define mmx_fetch(mem,hint) \ + __asm__ __volatile__ ("prefetch" #hint " %0" \ +--- /dev/null ++++ motion-3.2.12/motion-dist.conf +@@ -0,0 +1,736 @@ ++# Rename this distribution example file to motion.conf ++# ++# This config file was generated by motion 3.2.12-4ppa01 ++ ++ ++############################################################ ++# Daemon ++############################################################ ++ ++# Start in daemon (background) mode and release terminal (default: off) ++daemon off ++ ++# File to store the process ID, also called pid file. (default: not defined) ++process_id_file /var/run/motion/motion.pid ++ ++############################################################ ++# Basic Setup Mode ++############################################################ ++ ++# Start in Setup-Mode, daemon disabled. (default: off) ++setup_mode off ++ ++ ++# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) ++;logfile /tmp/motion.log ++ ++# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) ++log_level 6 ++ ++# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) ++log_type all ++ ++########################################################### ++# Capture device options ++############################################################ ++ ++# Videodevice to be used for capturing (default /dev/video0) ++# for FreeBSD default is /dev/bktr0 ++videodevice /dev/video0 ++ ++# v4l2_palette allows to choose preferable palette to be use by motion ++# to capture from those supported by your videodevice. (default: 17) ++# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and ++# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. ++# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 ++# instead. ++# ++# Values : ++# V4L2_PIX_FMT_SN9C10X : 0 'S910' ++# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' ++# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' ++# V4L2_PIX_FMT_SPCA561 : 3 'S561' ++# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' ++# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' ++# V4L2_PIX_FMT_PAC207 : 6 'P207' ++# V4L2_PIX_FMT_PJPG : 7 'PJPG' ++# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' ++# V4L2_PIX_FMT_JPEG : 9 'JPEG' ++# V4L2_PIX_FMT_RGB24 : 10 'RGB3' ++# V4L2_PIX_FMT_SPCA501 : 11 'S501' ++# V4L2_PIX_FMT_SPCA505 : 12 'S505' ++# V4L2_PIX_FMT_SPCA508 : 13 'S508' ++# V4L2_PIX_FMT_UYVY : 14 'UYVY' ++# V4L2_PIX_FMT_YUYV : 15 'YUYV' ++# V4L2_PIX_FMT_YUV422P : 16 '422P' ++# V4L2_PIX_FMT_YUV420 : 17 'YU12' ++# ++v4l2_palette 17 ++ ++# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) ++# This is ONLY used for FreeBSD. Leave it commented out for Linux ++; tunerdevice /dev/tuner0 ++ ++# 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) ++norm 0 ++ ++# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) ++frequency 0 ++ ++# Rotate image this number of degrees. The rotation affects all saved images as ++# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. ++rotate 0 ++ ++# Image width (pixels). Valid range: Camera dependent, default: 352 ++width 320 ++ ++# Image height (pixels). Valid range: Camera dependent, default: 288 ++height 240 ++ ++# Maximum number of frames to be captured per second. ++# Valid range: 2-100. Default: 100 (almost no limit). ++framerate 2 ++ ++# Minimum time in seconds between capturing picture frames from the camera. ++# Default: 0 = disabled - the capture rate is given by the camera framerate. ++# This option is used when you want to capture images at a rate lower than 2 per second. ++minimum_frame_time 0 ++ ++# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) ++# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ++; netcam_url value ++ ++# Username and password for network camera (only if required). Default: not defined ++# Syntax is user:password ++; netcam_userpass value ++ ++# The setting for keep-alive of network socket, should improve performance on compatible net cameras. ++# off: The historical implementation using HTTP/1.0, closing the socket after each http request. ++# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. ++# on: Use HTTP/1.1 requests that support keep alive as default. ++# Default: off ++netcam_keepalive off ++ ++# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". ++# If a port number other than 80 is needed, use "http://myproxy:1234". ++# Default: not defined ++; netcam_proxy value ++ ++# Set less strict jpeg checks for network cameras with a poor/buggy firmware. ++# Default: off ++netcam_tolerant_check off ++ ++# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. ++# Default: on ++rtsp_uses_tcp on ++ ++# Let motion regulate the brightness of a video device (default: off). ++# The auto_brightness feature uses the brightness option as its target value. ++# If brightness is zero auto_brightness will adjust to average brightness value 128. ++# Only recommended for cameras without auto brightness ++auto_brightness off ++ ++# Set the initial brightness of a video device. ++# If auto_brightness is enabled, this value defines the average brightness level ++# which Motion will try and adjust to. ++# Valid range 0-255, default 0 = disabled ++brightness 0 ++ ++# Set the contrast of a video device. ++# Valid range 0-255, default 0 = disabled ++contrast 0 ++ ++# Set the saturation of a video device. ++# Valid range 0-255, default 0 = disabled ++saturation 0 ++ ++# Set the hue of a video device (NTSC feature). ++# Valid range 0-255, default 0 = disabled ++hue 0 ++ ++ ++############################################################ ++# Round Robin (multiple inputs on same video device name) ++############################################################ ++ ++# Number of frames to capture in each roundrobin step (default: 1) ++roundrobin_frames 1 ++ ++# Number of frames to skip before each roundrobin step (default: 1) ++roundrobin_skip 1 ++ ++# Try to filter out noise generated by roundrobin (default: off) ++switchfilter off ++ ++ ++############################################################ ++# Motion Detection Settings: ++############################################################ ++ ++# Threshold for number of changed pixels in an image that ++# triggers motion detection (default: 1500) ++threshold 1500 ++ ++# Automatically tune the threshold down if possible (default: off) ++threshold_tune off ++ ++# Noise threshold for the motion detection (default: 32) ++noise_level 32 ++ ++# Automatically tune the noise threshold (default: on) ++noise_tune on ++ ++# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) ++# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. ++# (l)abeling must only be used once and the 'l' must be the last letter. ++# Comment out to disable ++despeckle_filter EedDl ++ ++# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 ++# A script (on_area_detected) is started immediately when motion is 4 5 6 ++# detected in one of the given areas, but only once during an event. 7 8 9 ++# One or more areas can be specified with this option. Take care: This option ++# does NOT restrict detection to these areas! (Default: not defined) ++; area_detect value ++ ++# PGM file to use as a sensitivity mask. ++# Full path name to. (Default: not defined) ++; mask_file value ++ ++# Dynamically create a mask file during operation (default: 0) ++# Adjust speed of mask changes from 0 (off) to 10 (fast) ++smart_mask_speed 0 ++ ++# Ignore sudden massive light intensity changes given as a percentage of the picture ++# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled ++lightswitch 0 ++ ++# Picture frames must contain motion at least the specified number of frames ++# in a row before they are detected as true motion. At the default of 1, all ++# motion is detected. Valid range: 1 to thousands, recommended 1-5 ++minimum_motion_frames 1 ++ ++# Specifies the number of pre-captured (buffered) pictures from before motion ++# was detected that will be output at motion detection. ++# Recommended range: 0 to 5 (default: 0) ++# Do not use large values! Large values will cause Motion to skip video frames and ++# cause unsmooth movies. To smooth movies use larger values of post_capture instead. ++pre_capture 0 ++ ++# Number of frames to capture after motion is no longer detected (default: 0) ++post_capture 0 ++ ++# Event Gap is the seconds of no motion detection that triggers the end of an event. ++# An event is defined as a series of motion images taken within a short timeframe. ++# Recommended value is 60 seconds (Default). The value -1 is allowed and disables ++# events causing all Motion to be written to one single movie file and no pre_capture. ++# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An ++# event ends right after no more motion is detected and post_capture is over. ++event_gap 60 ++ ++# Maximum length in seconds of a movie ++# When value is exceeded a new movie file is created. (Default: 0 = infinite) ++max_movie_time 0 ++ ++# Always save images even if there was no motion (default: off) ++emulate_motion off ++ ++ ++############################################################ ++# Image File Output ++############################################################ ++ ++# Output 'normal' pictures when motion is detected (default: on) ++# Valid values: on, off, first, best, center ++# When set to 'first', only the first picture of an event is saved. ++# Picture with most motion of an event is saved when set to 'best'. ++# Picture with motion nearest center of picture is saved when set to 'center'. ++# Can be used as preview shot for the corresponding movie. ++output_pictures on ++ ++# Output pictures with only the pixels moving object (ghost images) (default: off) ++output_debug_pictures off ++ ++# The quality (in percent) to be used by the jpeg compression (default: 75) ++quality 75 ++ ++# Type of output images ++# Valid values: jpeg, ppm (default: jpeg) ++picture_type jpeg ++ ++############################################################ ++# FFMPEG related options ++# Film (movies) file output, and deinterlacing of the video input ++# The options movie_filename and timelapse_filename are also used ++# by the ffmpeg feature ++############################################################ ++ ++# Use ffmpeg to encode movies in realtime (default: off) ++ffmpeg_output_movies on ++ ++# Use ffmpeg to make movies with only the pixels moving ++# object (ghost images) (default: off) ++ffmpeg_output_debug_movies off ++ ++# Use ffmpeg to encode a timelapse movie ++# Default value 0 = off - else save frame every Nth second ++ffmpeg_timelapse 0 ++ ++# The file rollover mode of the timelapse video ++# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual ++ffmpeg_timelapse_mode daily ++ ++# Bitrate to be used by the ffmpeg encoder (default: 400000) ++# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) ++ffmpeg_bps 500000 ++ ++# Enables and defines variable bitrate for the ffmpeg encoder. ++# ffmpeg_bps is ignored if variable bitrate is enabled. ++# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, ++# or the range 2 - 31 where 2 means best quality and 31 is worst. ++ffmpeg_variable_bitrate 0 ++ ++# Codec to used by ffmpeg for the video compression. ++# Timelapse mpegs are always made in mpeg1 format independent from this option. ++# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. ++# mpeg1 - gives you files with extension .mpg ++# mpeg4 or msmpeg4 - gives you files with extension .avi ++# msmpeg4 is recommended for use with Windows Media Player because ++# it requires no installation of codec on the Windows client. ++# swf - gives you a flash film with extension .swf ++# flv - gives you a flash video with extension .flv ++# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) ++# mov - QuickTime ( testing ) ++# ogg - Ogg/Theora ( testing ) ++ffmpeg_video_codec mpeg4 ++ ++# Use ffmpeg to deinterlace video. Necessary if you use an analog camera ++# and see horizontal combing on moving objects in video or pictures. ++# (default: off) ++ffmpeg_deinterlace off ++ ++############################################################ ++# SDL Window ++############################################################ ++ ++# Number of motion thread to show in SDL Window (default: 0 = disabled) ++#sdl_threadnr 0 ++ ++############################################################ ++# External pipe to video encoder ++# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. ++# The options movie_filename and timelapse_filename are also used ++# by the ffmpeg feature ++############################################################# ++ ++# Bool to enable or disable extpipe (default: off) ++use_extpipe off ++ ++# External program (full path and opts) to pipe raw video to ++# Generally, use '-' for STDIN... ++;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps ++ ++ ++ ++############################################################ ++# Snapshots (Traditional Periodic Webcam File Output) ++############################################################ ++ ++# Make automated snapshot every N seconds (default: 0 = disabled) ++snapshot_interval 0 ++ ++ ++############################################################ ++# Text Display ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, \n = new line, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event - do not use with text_event! ++# You can put quotation marks around the text to allow ++# leading spaces ++############################################################ ++ ++# Locate and draw a box around the moving object. ++# Valid values: on, off, preview (default: off) ++# Set to 'preview' will only draw a box in preview_shot pictures. ++locate_motion_mode off ++ ++# Set the look and style of the locate box if enabled. ++# Valid values: box, redbox, cross, redcross (default: box) ++# Set to 'box' will draw the traditional box. ++# Set to 'redbox' will draw a red box. ++# Set to 'cross' will draw a little cross to mark center. ++# Set to 'redcross' will draw a little red cross to mark center. ++locate_motion_style box ++ ++# Draws the timestamp using same options as C function strftime(3) ++# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock ++# Text is placed in lower right corner ++text_right %Y-%m-%d\n%T-%q ++ ++# Draw a user defined text on the images using same options as C function strftime(3) ++# Default: Not defined = no text ++# Text is placed in lower left corner ++; text_left CAMERA %t ++ ++# Draw the number of changed pixed on the images (default: off) ++# Will normally be set to off except when you setup and adjust the motion settings ++# Text is placed in upper right corner ++text_changes off ++ ++# This option defines the value of the special event conversion specifier %C ++# You can use any conversion specifier in this option except %C. Date and time ++# values are from the timestamp of the first image in the current event. ++# Default: %Y%m%d%H%M%S ++# The idea is that %C can be used filenames and text_left/right for creating ++# a unique identifier for each event. ++text_event %Y%m%d%H%M%S ++ ++# Draw characters at twice normal size on images. (default: off) ++text_double off ++ ++ ++# Text to include in a JPEG EXIF comment ++# May be any text, including conversion specifiers. ++# The EXIF timestamp is included independent of this text. ++;exif_text %i%J/%K%L ++ ++############################################################ ++# Target Directories and filenames For Images And Films ++# For the options snapshot_, picture_, movie_ and timelapse_filename ++# you can use conversion specifiers ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event ++# Quotation marks round string are allowed. ++############################################################ ++ ++# Target base directory for pictures and films ++# Recommended to use absolute path. (Default: current working directory) ++target_dir /tmp/motion ++ ++# File path for snapshots (jpeg or ppm) relative to target_dir ++# Default: %v-%Y%m%d%H%M%S-snapshot ++# Default value is equivalent to legacy oldlayout option ++# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot ++# File extension .jpg or .ppm is automatically added so do not include this. ++# Note: A symbolic link called lastsnap.jpg created in the target_dir will always ++# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' ++snapshot_filename %v-%Y%m%d%H%M%S-snapshot ++ ++# File path for motion triggered images (jpeg or ppm) relative to target_dir ++# Default: %v-%Y%m%d%H%M%S-%q ++# Default value is equivalent to legacy oldlayout option ++# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q ++# File extension .jpg or .ppm is automatically added so do not include this ++# Set to 'preview' together with best-preview feature enables special naming ++# convention for preview shots. See motion guide for details ++picture_filename %v-%Y%m%d%H%M%S-%q ++ ++# File path for motion triggered ffmpeg films (movies) relative to target_dir ++# Default: %v-%Y%m%d%H%M%S ++# Default value is equivalent to legacy oldlayout option ++# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S ++# File extension .mpg or .avi is automatically added so do not include this ++# This option was previously called ffmpeg_filename ++movie_filename %v-%Y%m%d%H%M%S ++ ++# File path for timelapse movies relative to target_dir ++# Default: %Y%m%d-timelapse ++# Default value is near equivalent to legacy oldlayout option ++# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse ++# File extension .mpg is automatically added so do not include this ++timelapse_filename %Y%m%d-timelapse ++ ++############################################################ ++# Global Network Options ++############################################################ ++# Enable or disable IPV6 for http control and stream (default: off ) ++ipv6_enabled off ++ ++############################################################ ++# Live Stream Server ++############################################################ ++ ++# The mini-http server listens to this port for requests (default: 0 = disabled) ++stream_port 8081 ++ ++# Quality of the jpeg (in percent) images produced (default: 50) ++stream_quality 50 ++ ++# Output frames at 1 fps when no motion is detected and increase to the ++# rate given by stream_maxrate when motion is detected (default: off) ++stream_motion off ++ ++# Maximum framerate for stream streams (default: 1) ++stream_maxrate 1 ++ ++# Restrict stream connections to localhost only (default: on) ++stream_localhost on ++ ++# Limits the number of images per connection (default: 0 = unlimited) ++# Number can be defined by multiplying actual stream rate by desired number of seconds ++# Actual stream rate is the smallest of the numbers framerate and stream_maxrate ++stream_limit 0 ++ ++# Set the authentication method (default: 0) ++# 0 = disabled ++# 1 = Basic authentication ++# 2 = MD5 digest (the safer authentication) ++stream_auth_method 0 ++ ++# Authentication for the stream. Syntax username:password ++# Default: not defined (Disabled) ++; stream_authentication username:password ++ ++ ++############################################################ ++# HTTP Based Control ++############################################################ ++ ++# TCP/IP port for the http server to listen on (default: 0 = disabled) ++webcontrol_port 8080 ++ ++# Restrict control connections to localhost only (default: on) ++webcontrol_localhost on ++ ++# Output for http server, select off to choose raw text plain (default: on) ++webcontrol_html_output on ++ ++# Authentication for the http based control. Syntax username:password ++# Default: not defined (Disabled) ++; webcontrol_authentication username:password ++ ++ ++############################################################ ++# Tracking (Pan/Tilt) ++############################################################# ++ ++# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) ++# The generic type enables the definition of motion center and motion size to ++# be used with the conversion specifiers for options like on_motion_detected ++track_type 0 ++ ++# Enable auto tracking (default: off) ++track_auto off ++ ++# Serial port of motor (default: none) ++;track_port /dev/ttyS0 ++ ++# Motor number for x-axis (default: 0) ++;track_motorx 0 ++ ++# Set motorx reverse (default: 0) ++;track_motorx_reverse 0 ++ ++# Motor number for y-axis (default: 0) ++;track_motory 1 ++ ++# Set motory reverse (default: 0) ++;track_motory_reverse 0 ++ ++# Maximum value on x-axis (default: 0) ++;track_maxx 200 ++ ++# Minimum value on x-axis (default: 0) ++;track_minx 50 ++ ++# Maximum value on y-axis (default: 0) ++;track_maxy 200 ++ ++# Minimum value on y-axis (default: 0) ++;track_miny 50 ++ ++# Center value on x-axis (default: 0) ++;track_homex 128 ++ ++# Center value on y-axis (default: 0) ++;track_homey 128 ++ ++# ID of an iomojo camera if used (default: 0) ++track_iomojo_id 0 ++ ++# Angle in degrees the camera moves per step on the X-axis ++# with auto-track (default: 10) ++# Currently only used with pwc type cameras ++track_step_angle_x 10 ++ ++# Angle in degrees the camera moves per step on the Y-axis ++# with auto-track (default: 10) ++# Currently only used with pwc type cameras ++track_step_angle_y 10 ++ ++# Delay to wait for after tracking movement as number ++# of picture frames (default: 10) ++track_move_wait 10 ++ ++# Speed to set the motor to (stepper motor option) (default: 255) ++track_speed 255 ++ ++# Number of steps to make (stepper motor option) (default: 40) ++track_stepsize 40 ++ ++ ++############################################################ ++# External Commands, Warnings and Logging: ++# You can use conversion specifiers for the on_xxxx commands ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event ++# %f = filename with full path ++# %n = number indicating filetype ++# Both %f and %n are only defined for on_picture_save, ++# on_movie_start and on_movie_end ++# Quotation marks round string are allowed. ++############################################################ ++ ++# Do not sound beeps when detecting motion (default: on) ++# Note: Motion never beeps when running in daemon mode. ++quiet on ++ ++# Command to be executed when an event starts. (default: none) ++# An event starts at first motion detected after a period of no motion defined by event_gap ++; on_event_start value ++ ++# Command to be executed when an event ends after a period of no motion ++# (default: none). The period of no motion is defined by option event_gap. ++; on_event_end value ++ ++# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) ++# To give the filename as an argument to a command append it with %f ++; on_picture_save value ++ ++# Command to be executed when a motion frame is detected (default: none) ++; on_motion_detected value ++ ++# Command to be executed when motion in a predefined area is detected ++# Check option 'area_detect'. (default: none) ++; on_area_detected value ++ ++# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) ++# To give the filename as an argument to a command append it with %f ++; on_movie_start value ++ ++# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) ++# To give the filename as an argument to a command append it with %f ++; on_movie_end value ++ ++# Command to be executed when a camera can't be opened or if it is lost ++# NOTE: There is situations when motion don't detect a lost camera! ++# It depends on the driver, some drivers dosn't detect a lost camera at all ++# Some hangs the motion thread. Some even hangs the PC! (default: none) ++; on_camera_lost value ++ ++##################################################################### ++# Common Options for database features. ++# Options require database options to be active also. ++##################################################################### ++ ++# Log to the database when creating motion triggered picture file (default: on) ++; sql_log_picture on ++ ++# Log to the database when creating a snapshot image file (default: on) ++; sql_log_snapshot on ++ ++# Log to the database when creating motion triggered movie file (default: off) ++; sql_log_movie off ++ ++# Log to the database when creating timelapse movies file (default: off) ++; sql_log_timelapse off ++ ++# SQL query string that is sent to the database ++# Use same conversion specifiers has for text features ++# Additional special conversion specifiers are ++# %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') ++ ++ ++############################################################ ++# Database Options ++############################################################ ++ ++# database type : mysql, postgresql, sqlite3 (default : not defined) ++; database_type value ++ ++# database to log to (default: not defined) ++; database_dbname value ++ ++# The host on which the database is located (default: localhost) ++; database_host value ++ ++# User account name for database (default: not defined) ++; database_user value ++ ++# User password for database (default: not defined) ++; database_password value ++ ++# Port on which the database is located ++# mysql 3306 , postgresql 5432 (default: not defined) ++; database_port value ++ ++############################################################ ++# Database Options For SQLite3 ++############################################################ ++ ++# SQLite3 database (file path) (default: not defined) ++; sqlite3_db value ++ ++ ++ ++############################################################ ++# Video Loopback Device (vloopback project) ++############################################################ ++ ++# Output images to a video4linux loopback device ++# The value '-' means next available (default: not defined) ++; video_pipe value ++ ++# Output motion images to a video4linux loopback device ++# The value '-' means next available (default: not defined) ++; motion_video_pipe value ++ ++ ++############################################################## ++# Thread config files - One for each camera. ++# Except if only one camera - You only need this config file. ++# If you have more than one camera you MUST define one thread ++# config file for each camera in addition to this config file. ++############################################################## ++ ++# Remember: If you have more than one camera you must have one ++# thread file for each camera. E.g. 2 cameras requires 3 files: ++# This motion.conf file AND thread1.conf and thread2.conf. ++# Only put the options that are unique to each camera in the ++# thread config files. ++; thread /usr/local/etc/thread1.conf ++; thread /usr/local/etc/thread2.conf ++; thread /usr/local/etc/thread3.conf ++; thread /usr/local/etc/thread4.conf ++ +--- motion-3.2.12.orig/motion-dist.conf.in ++++ motion-3.2.12/motion-dist.conf.in +@@ -8,10 +8,10 @@ + ############################################################ + + # Start in daemon (background) mode and release terminal (default: off) +-daemon on ++daemon off + + # File to store the process ID, also called pid file. (default: not defined) +-process_id_file /var/run/motion/motion.pid ++process_id_file /var/run/motion/motion.pid + + ############################################################ + # Basic Setup Mode +@@ -20,6 +20,16 @@ process_id_file /var/run/motion/motion.p + # Start in Setup-Mode, daemon disabled. (default: off) + setup_mode off + ++ ++# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) ++;logfile /tmp/motion.log ++ ++# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) ++log_level 6 ++ ++# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) ++log_type all ++ + ########################################################### + # Capture device options + ############################################################ +@@ -29,31 +39,41 @@ setup_mode off + videodevice /dev/video0 + + # v4l2_palette allows to choose preferable palette to be use by motion +-# to capture from those supported by your videodevice. (default: 8) ++# to capture from those supported by your videodevice. (default: 17) + # E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and + # V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. +-# Setting v4l2_palette to 1 forces motion to use V4L2_PIX_FMT_SBGGR8 ++# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 + # instead. + # + # Values : + # V4L2_PIX_FMT_SN9C10X : 0 'S910' +-# V4L2_PIX_FMT_SBGGR8 : 1 'BA81' +-# V4L2_PIX_FMT_MJPEG : 2 'MJPEG' +-# V4L2_PIX_FMT_JPEG : 3 'JPEG' +-# V4L2_PIX_FMT_RGB24 : 4 'RGB3' +-# V4L2_PIX_FMT_UYVY : 5 'UYVY' +-# V4L2_PIX_FMT_YUYV : 6 'YUYV' +-# V4L2_PIX_FMT_YUV422P : 7 '422P' +-# V4L2_PIX_FMT_YUV420 : 8 'YU12' +-v4l2_palette 8 ++# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' ++# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' ++# V4L2_PIX_FMT_SPCA561 : 3 'S561' ++# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' ++# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' ++# V4L2_PIX_FMT_PAC207 : 6 'P207' ++# V4L2_PIX_FMT_PJPG : 7 'PJPG' ++# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' ++# V4L2_PIX_FMT_JPEG : 9 'JPEG' ++# V4L2_PIX_FMT_RGB24 : 10 'RGB3' ++# V4L2_PIX_FMT_SPCA501 : 11 'S501' ++# V4L2_PIX_FMT_SPCA505 : 12 'S505' ++# V4L2_PIX_FMT_SPCA508 : 13 'S508' ++# V4L2_PIX_FMT_UYVY : 14 'UYVY' ++# V4L2_PIX_FMT_YUYV : 15 'YUYV' ++# V4L2_PIX_FMT_YUV422P : 16 '422P' ++# V4L2_PIX_FMT_YUV420 : 17 'YU12' ++# ++v4l2_palette 17 + + # Tuner device to be used for capturing using tuner as source (default /dev/tuner0) + # 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) +@@ -63,7 +83,7 @@ norm 0 + frequency 0 + + # Rotate image this number of degrees. The rotation affects all saved images as +-# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270. ++# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. + rotate 0 + + # Image width (pixels). Valid range: Camera dependent, default: 352 +@@ -81,7 +101,7 @@ framerate 2 + # This option is used when you want to capture images at a rate lower than 2 per second. + minimum_frame_time 0 + +-# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) ++# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) + # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined + ; netcam_url value + +@@ -90,21 +110,25 @@ minimum_frame_time 0 + ; netcam_userpass value + + # The setting for keep-alive of network socket, should improve performance on compatible net cameras. +-# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request. +-# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +-# 1.1: Use HTTP/1.1 requests that support keep alive as default. +-# Default: 1.0 +-; netcam_http 1.0 ++# off: The historical implementation using HTTP/1.0, closing the socket after each http request. ++# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. ++# on: Use HTTP/1.1 requests that support keep alive as default. ++# Default: off ++netcam_keepalive off + + # URL to use for a netcam proxy server, if required, e.g. "http://myproxy". + # If a port number other than 80 is needed, use "http://myproxy:1234". + # Default: not defined +-; netcam_proxy value ++; netcam_proxy value + + # Set less strict jpeg checks for network cameras with a poor/buggy firmware. + # Default: off + netcam_tolerant_check off + ++# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. ++# Default: on ++rtsp_uses_tcp on ++ + # Let motion regulate the brightness of a video device (default: off). + # The auto_brightness feature uses the brightness option as its target value. + # If brightness is zero auto_brightness will adjust to average brightness value 128. +@@ -165,12 +189,13 @@ noise_tune on + # Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. + # (l)abeling must only be used once and the 'l' must be the last letter. + # Comment out to disable +-despeckle EedDl ++despeckle_filter EedDl + + # Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 + # A script (on_area_detected) is started immediately when motion is 4 5 6 + # detected in one of the given areas, but only once during an event. 7 8 9 +-# One or more areas can be specified with this option. (Default: not defined) ++# One or more areas can be specified with this option. Take care: This option ++# does NOT restrict detection to these areas! (Default: not defined) + ; area_detect value + + # PGM file to use as a sensitivity mask. +@@ -194,24 +219,26 @@ minimum_motion_frames 1 + # was detected that will be output at motion detection. + # Recommended range: 0 to 5 (default: 0) + # Do not use large values! Large values will cause Motion to skip video frames and +-# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. ++# cause unsmooth movies. To smooth movies use larger values of post_capture instead. + pre_capture 0 + + # Number of frames to capture after motion is no longer detected (default: 0) + post_capture 0 + +-# Gap is the seconds of no motion detection that triggers the end of an event ++# Event Gap is the seconds of no motion detection that triggers the end of an event. + # An event is defined as a series of motion images taken within a short timeframe. +-# Recommended value is 60 seconds (Default). The value 0 is allowed and disables +-# events causing all Motion to be written to one single mpeg file and no pre_capture. +-gap 60 +- +-# Maximum length in seconds of an mpeg movie +-# When value is exceeded a new mpeg file is created. (Default: 0 = infinite) +-max_mpeg_time 0 ++# Recommended value is 60 seconds (Default). The value -1 is allowed and disables ++# events causing all Motion to be written to one single movie file and no pre_capture. ++# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An ++# event ends right after no more motion is detected and post_capture is over. ++event_gap 60 ++ ++# Maximum length in seconds of a movie ++# When value is exceeded a new movie file is created. (Default: 0 = infinite) ++max_movie_time 0 + + # Always save images even if there was no motion (default: off) +-output_all off ++emulate_motion off + + + ############################################################ +@@ -224,33 +251,33 @@ output_all off + # Picture with most motion of an event is saved when set to 'best'. + # Picture with motion nearest center of picture is saved when set to 'center'. + # Can be used as preview shot for the corresponding movie. +-output_normal on ++output_pictures on + + # Output pictures with only the pixels moving object (ghost images) (default: off) +-output_motion off ++output_debug_pictures off + + # The quality (in percent) to be used by the jpeg compression (default: 75) + quality 75 + +-# Output ppm images instead of jpeg (default: off) +-ppm off +- ++# Type of output images ++# Valid values: jpeg, ppm (default: jpeg) ++picture_type jpeg + + ############################################################ + # FFMPEG related options +-# Film (mpeg) file output, and deinterlacing of the video input ++# Film (movies) file output, and deinterlacing of the video input + # The options movie_filename and timelapse_filename are also used + # by the ffmpeg feature + ############################################################ + +-# Use ffmpeg to encode mpeg movies in realtime (default: off) +-ffmpeg_cap_new on ++# Use ffmpeg to encode movies in realtime (default: off) ++ffmpeg_output_movies on + + # Use ffmpeg to make movies with only the pixels moving + # object (ghost images) (default: off) +-ffmpeg_cap_motion off ++ffmpeg_output_debug_movies off + +-# Use ffmpeg to encode a timelapse movie ++# Use ffmpeg to encode a timelapse movie + # Default value 0 = off - else save frame every Nth second + ffmpeg_timelapse 0 + +@@ -279,6 +306,7 @@ ffmpeg_variable_bitrate 0 + # flv - gives you a flash video with extension .flv + # ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) + # mov - QuickTime ( testing ) ++# ogg - Ogg/Theora ( testing ) + ffmpeg_video_codec mpeg4 + + # Use ffmpeg to deinterlace video. Necessary if you use an analog camera +@@ -286,6 +314,28 @@ ffmpeg_video_codec mpeg4 + # (default: off) + ffmpeg_deinterlace off + ++############################################################ ++# SDL Window ++############################################################ ++ ++# Number of motion thread to show in SDL Window (default: 0 = disabled) ++#sdl_threadnr 0 ++ ++############################################################ ++# External pipe to video encoder ++# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. ++# The options movie_filename and timelapse_filename are also used ++# by the ffmpeg feature ++############################################################# ++ ++# Bool to enable or disable extpipe (default: off) ++use_extpipe off ++ ++# External program (full path and opts) to pipe raw video to ++# Generally, use '-' for STDIN... ++;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps ++ ++ + + ############################################################ + # Snapshots (Traditional Periodic Webcam File Output) +@@ -309,9 +359,17 @@ snapshot_interval 0 + ############################################################ + + # Locate and draw a box around the moving object. +-# Valid values: on, off and preview (default: off) ++# Valid values: on, off, preview (default: off) + # Set to 'preview' will only draw a box in preview_shot pictures. +-locate off ++locate_motion_mode off ++ ++# Set the look and style of the locate box if enabled. ++# Valid values: box, redbox, cross, redcross (default: box) ++# Set to 'box' will draw the traditional box. ++# Set to 'redbox' will draw a red box. ++# Set to 'cross' will draw a little cross to mark center. ++# Set to 'redcross' will draw a little red cross to mark center. ++locate_motion_style box + + # Draws the timestamp using same options as C function strftime(3) + # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +@@ -340,9 +398,14 @@ text_event %Y%m%d%H%M%S + text_double off + + ++# Text to include in a JPEG EXIF comment ++# May be any text, including conversion specifiers. ++# The EXIF timestamp is included independent of this text. ++;exif_text %i%J/%K%L ++ + ############################################################ + # Target Directories and filenames For Images And Films +-# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename ++# For the options snapshot_, picture_, movie_ and timelapse_filename + # you can use conversion specifiers + # %Y = year, %m = month, %d = date, + # %H = hour, %M = minute, %S = second, +@@ -356,7 +419,7 @@ text_double off + + # Target base directory for pictures and films + # Recommended to use absolute path. (Default: current working directory) +-target_dir /usr/local/apache2/htdocs/cam1 ++target_dir /tmp/motion + + # File path for snapshots (jpeg or ppm) relative to target_dir + # Default: %v-%Y%m%d%H%M%S-snapshot +@@ -374,9 +437,9 @@ snapshot_filename %v-%Y%m%d%H%M%S-snapsh + # File extension .jpg or .ppm is automatically added so do not include this + # Set to 'preview' together with best-preview feature enables special naming + # convention for preview shots. See motion guide for details +-jpeg_filename %v-%Y%m%d%H%M%S-%q ++picture_filename %v-%Y%m%d%H%M%S-%q + +-# File path for motion triggered ffmpeg films (mpeg) relative to target_dir ++# File path for motion triggered ffmpeg films (movies) relative to target_dir + # Default: %v-%Y%m%d%H%M%S + # Default value is equivalent to legacy oldlayout option + # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S +@@ -384,38 +447,53 @@ jpeg_filename %v-%Y%m%d%H%M%S-%q + # This option was previously called ffmpeg_filename + movie_filename %v-%Y%m%d%H%M%S + +-# File path for timelapse mpegs relative to target_dir ++# File path for timelapse movies relative to target_dir + # Default: %Y%m%d-timelapse + # Default value is near equivalent to legacy oldlayout option + # For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse + # File extension .mpg is automatically added so do not include this + timelapse_filename %Y%m%d-timelapse + ++############################################################ ++# Global Network Options ++############################################################ ++# Enable or disable IPV6 for http control and stream (default: off ) ++ipv6_enabled off + + ############################################################ +-# Live Webcam Server ++# Live Stream Server + ############################################################ + + # The mini-http server listens to this port for requests (default: 0 = disabled) +-webcam_port 8081 ++stream_port 8081 + +-# Quality of the jpeg (in percent) images produced (default: 50) +-webcam_quality 50 ++# Quality of the jpeg (in percent) images produced (default: 50) ++stream_quality 50 + + # Output frames at 1 fps when no motion is detected and increase to the +-# rate given by webcam_maxrate when motion is detected (default: off) +-webcam_motion off ++# rate given by stream_maxrate when motion is detected (default: off) ++stream_motion off + +-# Maximum framerate for webcam streams (default: 1) +-webcam_maxrate 1 ++# Maximum framerate for stream streams (default: 1) ++stream_maxrate 1 + +-# Restrict webcam connections to localhost only (default: on) +-webcam_localhost on ++# Restrict stream connections to localhost only (default: on) ++stream_localhost on + + # Limits the number of images per connection (default: 0 = unlimited) +-# Number can be defined by multiplying actual webcam rate by desired number of seconds +-# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate +-webcam_limit 0 ++# Number can be defined by multiplying actual stream rate by desired number of seconds ++# Actual stream rate is the smallest of the numbers framerate and stream_maxrate ++stream_limit 0 ++ ++# Set the authentication method (default: 0) ++# 0 = disabled ++# 1 = Basic authentication ++# 2 = MD5 digest (the safer authentication) ++stream_auth_method 0 ++ ++# Authentication for the stream. Syntax username:password ++# Default: not defined (Disabled) ++; stream_authentication username:password + + + ############################################################ +@@ -423,24 +501,24 @@ webcam_limit 0 + ############################################################ + + # TCP/IP port for the http server to listen on (default: 0 = disabled) +-control_port 8080 ++webcontrol_port 8080 + + # Restrict control connections to localhost only (default: on) +-control_localhost on ++webcontrol_localhost on + + # Output for http server, select off to choose raw text plain (default: on) +-control_html_output on ++webcontrol_html_output on + + # Authentication for the http based control. Syntax username:password + # Default: not defined (Disabled) +-; control_authentication username:password ++; webcontrol_authentication username:password + + + ############################################################ + # Tracking (Pan/Tilt) +-############################################################ ++############################################################# + +-# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo) ++# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) + # The generic type enables the definition of motion center and motion size to + # be used with the conversion specifiers for options like on_motion_detected + track_type 0 +@@ -449,19 +527,37 @@ track_type 0 + track_auto off + + # Serial port of motor (default: none) +-; track_port value ++;track_port /dev/ttyS0 + + # Motor number for x-axis (default: 0) +-track_motorx 0 ++;track_motorx 0 ++ ++# Set motorx reverse (default: 0) ++;track_motorx_reverse 0 + + # Motor number for y-axis (default: 0) +-track_motory 0 ++;track_motory 1 ++ ++# Set motory reverse (default: 0) ++;track_motory_reverse 0 + + # Maximum value on x-axis (default: 0) +-track_maxx 0 ++;track_maxx 200 ++ ++# Minimum value on x-axis (default: 0) ++;track_minx 50 + + # Maximum value on y-axis (default: 0) +-track_maxy 0 ++;track_maxy 200 ++ ++# Minimum value on y-axis (default: 0) ++;track_miny 50 ++ ++# Center value on x-axis (default: 0) ++;track_homex 128 ++ ++# Center value on y-axis (default: 0) ++;track_homey 128 + + # ID of an iomojo camera if used (default: 0) + track_iomojo_id 0 +@@ -509,11 +605,11 @@ track_stepsize 40 + quiet on + + # Command to be executed when an event starts. (default: none) +-# An event starts at first motion detected after a period of no motion defined by gap ++# An event starts at first motion detected after a period of no motion defined by event_gap + ; on_event_start value + + # Command to be executed when an event ends after a period of no motion +-# (default: none). The period of no motion is defined by option gap. ++# (default: none). The period of no motion is defined by option event_gap. + ; on_event_end value + + # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) +@@ -536,27 +632,27 @@ quiet on + ; on_movie_end value + + # Command to be executed when a camera can't be opened or if it is lost +-# NOTE: There is situations when motion doesn't detect a lost camera! +-# It depends on the driver, some drivers don't detect a lost camera at all +-# Some hang the motion thread. Some even hang the PC! (default: none) ++# NOTE: There is situations when motion don't detect a lost camera! ++# It depends on the driver, some drivers dosn't detect a lost camera at all ++# Some hangs the motion thread. Some even hangs the PC! (default: none) + ; on_camera_lost value + +-############################################################ +-# Common Options For MySQL and PostgreSQL database features. +-# Options require the MySQL/PostgreSQL options to be active also. +-############################################################ ++##################################################################### ++# Common Options for database features. ++# Options require database options to be active also. ++##################################################################### + +-# Log to the database when creating motion triggered image file (default: on) +-sql_log_image on ++# Log to the database when creating motion triggered picture file (default: on) ++; sql_log_picture on + + # Log to the database when creating a snapshot image file (default: on) +-sql_log_snapshot on ++; sql_log_snapshot on + +-# Log to the database when creating motion triggered mpeg file (default: off) +-sql_log_mpeg off ++# Log to the database when creating motion triggered movie file (default: off) ++; sql_log_movie off + +-# Log to the database when creating timelapse mpeg file (default: off) +-sql_log_timelapse off ++# Log to the database when creating timelapse movies file (default: off) ++; sql_log_timelapse off + + # SQL query string that is sent to the database + # Use same conversion specifiers has for text features +@@ -564,45 +660,48 @@ sql_log_timelapse off + # %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') ++; 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') + + + ############################################################ +-# Database Options For MySQL ++# Database Options + ############################################################ + +-# Mysql database to log to (default: not defined) +-; mysql_db value ++# database type : mysql, postgresql, sqlite3 (default : not defined) ++; database_type value ++ ++# database to log to (default: not defined) ++; database_dbname value + + # The host on which the database is located (default: localhost) +-; mysql_host value ++; database_host value + +-# User account name for MySQL database (default: not defined) +-; mysql_user value ++# User account name for database (default: not defined) ++; database_user value + +-# User password for MySQL database (default: not defined) +-; mysql_password value ++# User password for database (default: not defined) ++; database_password value + ++# Port on which the database is located ++# mysql 3306 , postgresql 5432 (default: not defined) ++; database_port value + + ############################################################ +-# Database Options For PostgreSQL ++# Database Options For SQLite3 + ############################################################ + +-# PostgreSQL database to log to (default: not defined) +-; pgsql_db value +- +-# The host on which the database is located (default: localhost) +-; pgsql_host value +- +-# User account name for PostgreSQL database (default: not defined) +-; pgsql_user value +- +-# User password for PostgreSQL database (default: not defined) +-; pgsql_password value ++# SQLite3 database (file path) (default: not defined) ++; sqlite3_db value + +-# Port on which the PostgreSQL database is located (default: 5432) +-; pgsql_port 5432 + + + ############################################################ +@@ -629,7 +728,7 @@ sql_query insert into security(camera, f + # thread file for each camera. E.g. 2 cameras requires 3 files: + # This motion.conf file AND thread1.conf and thread2.conf. + # Only put the options that are unique to each camera in the +-# thread config files. ++# thread config files. + ; thread /usr/local/etc/thread1.conf + ; thread /usr/local/etc/thread2.conf + ; thread /usr/local/etc/thread3.conf +--- motion-3.2.12.orig/motion.1 ++++ motion-3.2.12/motion.1 +@@ -1,9 +1,9 @@ +-.TH MOTION 1 2008-09-20 "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 level ] [ -p process_id_file ] ++[ -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,28 +17,43 @@ Full path and filename of config file. E + .B \-h + Show help screen. + .TP ++.B \-m ++Disable motion detection at startup. ++.TP + .B \-n + Run in non-daemon mode. + .TP + .B \-s + Run in setup mode. Also forces non-daemon mode + .TP +-.B \-d level +-Run in debug mode, level 1-9. ++.B \-d log level ++Set log level [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) ++.TP ++.B \-k log type ++Set type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) + .TP + .B \-p + Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. + .TP ++.B \-l ++Full path and filename of log file. ( use -l syslog to log to stderr and syslog ) ++.TP + .SH "CONFIG FILE OPTIONS" + These are the options that can be used in the config file. + .I They are overridden by the commandline! + All number values are integer numbers (no decimals allowed). + Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). + .TP +-.B area_detect string +-Values: 1 - 999999999 / Default: Not defined ++.B area_detect integer ++Values: 0 - 999999999 / Default: Not defined ++.br ++Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 ++.br ++A script (on_area_detected) is started immediately when motion is 4 5 6 + .br +-Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. ++detected in one of the given areas, but only once during an event. 7 8 9 ++.br ++One or more areas can be specified with this option. Take care: This option does NOT restrict detection to these areas! (Default: not defined) + .TP + .B auto_brightness boolean + Values: on, off / Default: off +@@ -55,57 +70,91 @@ Values: 0 - 255 / Default: 0 (disabled) + .br + The contrast level for the video device. + .TP +-.B control_authentication string +-Values: Max 4096 characters / Default: Not defined ++.B daemon boolean ++Values: on, off / Default: off + .br +-To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. ++Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. + .TP +-.B control_html_output boolean +-Values: on, off / Default: on ++.B database_dbname string ++Values: Max 4095 characters / Default: Not defined + .br +-Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. ++Name of the database. + .TP +-.B control_localhost boolean +-Values: on, off / Default: on ++.B database_host string ++Values: Max 4095 characters / Default: localhost + .br +-Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. ++IP address or domain name for the database server. Use "localhost" if motion and database runs on the same server. + .TP +-.B control_port integer +-Values: 0 - 65535 / Default: 0 (disabled) ++.B database_password string ++Values: Max 4095 characters / Default: Not defined + .br +-Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. ++The database password. + .TP +-.B daemon boolean +-Values: on, off / Default: off ++.B database_port integer ++Values: 0 - 65535 / Default: Not defined + .br +-Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. ++The database server port number. ++.TP ++.B database_type discrete strings ++Values: mysql, postgresql / Default: Not defined ++.br ++The database type ( mysql , postgresql ). + .TP +-.B despeckle string ++.B database_user string ++Values: Max 4095 characters / Default: Not defined ++.br ++The database user name. ++.TP ++.B despeckle_filter string + Values: EedDl / Default: Not defined + .br + Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. + .TP ++.B emulate_motion boolean ++Values: on, off / Default: off ++.br ++Picture are saved continuously as if motion was detected all the time. ++.TP ++.B event_gap integer ++Values: 0 - 2147483647 / Default: 60 ++.br ++Event Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. ++.TP ++.B exif_text string ++Values: Max 4095 characters / Default: Not defined ++.br ++Text to include in a JPEG EXIF comment , may be any text, including conversion specifiers. The EXIF timestamp is included independent of this text. ++.TP ++.B extpipe string ++Values: Max 4095 characters / Default: Not defined ++.br ++pipe raw video to generally - 'STDIN', allowing to use an external video encoder. ++.br ++e.g. using memcoder : ++.br ++extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt: threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps ++.TP + .B ffmpeg_bps integer + Values: 0 - 9999999 / Default: 400000 + .br +-Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. ++Bitrate of movies produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. + .TP +-.B ffmpeg_cap_motion boolean ++.B ffmpeg_output_debug_movies boolean + Values: on, off / Default: off + .br +-Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. ++Use ffmpeg libraries to encode motion type movies where you only see the pixels that changes. + .TP +-.B ffmpeg_cap_new boolean ++.B ffmpeg_output_movies boolean + Values: on, off / Default: off + .br +-Use ffmpeg libraries to encode mpeg movies in realtime. ++Use ffmpeg libraries to encode movies in realtime. + .TP + .B ffmpeg_deinterlace boolean + Values: on, off / Default: off + .br +-Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. ++Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. + .TP +-.B ffmpeg_timelapse boolean ++.B ffmpeg_timelapse integer + Values: 0 - 2147483647 / Default: 0 (disabled) + .br + Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. +@@ -121,26 +170,21 @@ Values: 0, 2 - 31 / Default: 0 (disabled + Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. + .TP + .B ffmpeg_video_codec discrete strings +-Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1, mov / Default: mpeg4 ++Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf , flv , ffv1, mov, ogg / Default: mpeg4 + .br +-Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. ++Codec to be used by ffmpeg for the video compression. Timelapse movies are always made in mpeg1 format independent from this option. + .TP + .B framerate integer + Values: 2 - 100 / Default: 100 (no limit) + .br + Maximum number of frames to be captured from the camera per second. + .TP +-.B frequency boolean ++.B frequency integer + Values: 0 - 999999 / Default: 0 (Not set) + .br + The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) + .TP +-.B gap integer +-Values: 0 - 2147483647 / Default: 60 +-.br +-Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. +-.TP +-.B height integer ++.B height integer + Values: Device Dependent / Default: 288 + .br + The height of each frame in pixels. +@@ -150,42 +194,62 @@ Values: 0 - 255 / Default: 0 (disabled) + .br + The hue level for the video device. + .TP +-.B input integer +-Values: 0 - 7, 8 = disabled / Default: 8 (disabled) ++.B input integer ++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 jpeg_filename string +-Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q ++.B ipv6_enabled boolean ++Values: on, off / Default: off + .br +-File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. ++Enable or disable IPV6 for http control and stream. + .TP +-.B lightswitch integer ++.B lightswitch integer + Values: 0 - 100 / Default: 0 (disabled) + .br + Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. + .TP +-.B locate boolean +-Values: on, off, preview / Default: off ++.B locate_motion discrete strings ++Values: on, off, redbox, center, redcross, preview / Default: off ++.br ++Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved movie. ++.TP ++.B logfile string ++Values: Max 4095 characters / Default: Not defined + .br +-Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. ++Use a file to save logs messages, if not defined stderr and syslog is used. ++.TP ++.B logfile string ++Values: Max 4095 characters / Default: Not defined ++.br ++Use a file to save logs messages, if not defined stderr and syslog is used. ( if syslog is set then will log to stderr and syslog ) ++.TP ++.B log_level integer ++Values: 1 - 9 / Default: 6 ++.br ++Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC). ++.TP ++.B log_type discrete strings ++Values: STR, ENC, NET, DBL, EVT, TRK, VID, ALL / Default: ALL ++.br ++Filter to log messages by type (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). + .TP + .B mask_file string + Values: Max 4095 characters / Default: Not defined + .br +-PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. ++PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. + .TP +-.B max_mpeg_time integer ++.B max_movie_time integer + Values: 0 (infinite) - 2147483647 / Default: 3600 + .br +-The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. ++The maximum length of a movie in seconds. Set this to zero for unlimited length. + .TP + .B minimum_frame_time integer + Values: 0 - 2147483647 / Default: 0 + .br + Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. + .TP +-.B minimum_motion_frames boolean ++.B minimum_motion_frames integer + Values: 1 - 1000s / Default: 1 + .br + Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. +@@ -198,47 +262,29 @@ The video4linux video loopback input dev + .B movie_filename string + Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S + .br +-File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. ++File path for motion triggered ffmpeg movies relative to target_dir. This was previously called ffmpeg_filename. + .TP +-.B mysql_db string +-Values: Max 4095 characters / Default: Not defined +-.br +-Name of the MySQL database. +-.TP +-.B mysql_host string +-Values: Max 4095 characters / Default: localhost +-.br +-IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. +-.TP +-.B mysql_password string +-Values: Max 4095 characters / Default: Not defined +-.br +-The MySQL password. +-.TP +-.B mysql_user string +-Values: Max 4095 characters / Default: Not defined ++.B netcam_tolerant_check boolean ++Values: on, off / Default: off + .br +-The MySQL user name. ++Set less strict jpeg checks for network cameras with a poor/buggy firmware. + .TP +-.B netcam_http discrete strings +-Values: 1.0, keep_alive, 1.1 / Default: 1.0 ++.B netcam_keepalive discrete string ++Values: off , force, on / Default: off + .br +-The setting for keep-alive of network socket, should improve performance on compatible net cameras. ( new in 3.2.10 )
++The setting for keep-alive of network socket, should improve performance on compatible net cameras. + .TP + .B netcam_proxy string + Values: Max 4095 characters / Default: Not defined + .br + URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber + .TP +-.B netcam_tolerant_check boolean +-Values: on, off / Default: off +-.br +-Set less strict jpeg checks for network cameras with a poor/buggy firmware. +-.TP + .B netcam_url string + Values: Max 4095 characters / Default: Not defined + .br + Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. ++.br ++http:// ftp:// mjpg:// or file:/// ( mjpg:// is for network cameras with codec mjpeg ). + .TP + .B netcam_userpass string + Values: Max 4095 characters / Default: Not defined +@@ -255,7 +301,7 @@ Values: on, off / Default: on + .br + Activates the automatic tuning of noise level. + .TP +-.B norm discrete strings ++.B norm integer + Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) / Default: 0 (PAL) + .br + Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) +@@ -263,22 +309,22 @@ Select the norm of the video device. Val + .B on_area_detected string + Values: Max 4095 characters / Default: Not defined + .br +-Command to be executed when motion in a predefined area is detected. Check option area_detect. ++Command to be executed when motion in a predefined area is detected, check option area_detect. + .TP +-.B on_camera_lost string ++.B on_camera_lost + Values: Max 4095 characters / Default: Not defined + .br +-Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10) ++Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. + .TP + .B on_event_end string + Values: Max 4095 characters / Default: Not defined + .br +-Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. ++Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option event_gap. You can use Conversion Specifiers and spaces as part of the command. + .TP + .B on_event_start string + Values: Max 4095 characters / Default: Not defined + .br +-Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. ++Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by event_gap. You can use ConversionSpecifiers and spaces as part of the command. + .TP + .B on_motion_detected string + Values: Max 4095 characters / Default: Not defined +@@ -293,67 +339,42 @@ Command to be executed when an ffmpeg mo + .B on_movie_start string + Values: Max 4095 characters / Default: Not defined + .br +-Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. ++Command to be executed when a movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. + .TP + .B on_picture_save string + Values: Max 4095 characters / Default: Not defined + .br + Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. + .TP +-.B output_all boolean +-Values: on, off / Default: off +-.br +-Picture are saved continuously as if motion was detected all the time. +-.TP +-.B output_motion boolean ++.B output_debug_pictures boolean + Values: on, off / Default: off + .br + Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. + .TP +-.B output_normal discrete strings +-Values: on, off, first, best, center (since 3.2.10) / Default: on ++.B output_pictures discrete strings ++Values: on, off, first, best, center / Default: on + .br + Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. + .TP +-.B pgsql_db string +-Values: Max 4095 characters / Default: Not defined +-.br +-Name of the PostgreSQL database. +-.TP +-.B pgsql_host string +-Values: Max 4095 characters / Default: localhost +-.br +-IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. +-.TP +-.B pgsql_password string +-Values: Max 4095 characters / Default: Not defined ++.B picture_filename string ++Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q + .br +-The PostgreSQL password. ++File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved movie file. + .TP +-.B pgsql_port integer +-Values: 0 - 65535 / Default: 5432 ++.B picture_type discrete strings ++Values: jpeg , ppm / Default: jpeg + .br +-The PostgreSQL server port number. +-.TP +-.B pgsql_user string +-Values: Max 4095 characters / Default: Not defined +-.br +-The PostgreSQL user name. ++Type of images motion will trigger when motion is detected. + .TP + .B post_capture integer +-Values: 0 - 2147483647 / Default: 0 (disabled) ++Values: 0 - 2147483647 / Default: 0 (disabled) + .br + Specifies the number of frames to be captured after motion has been detected. + .TP +-.B ppm boolean +-Values: on, off / Default: off +-.br +-Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. +-.TP + .B pre_capture integer + Values: 0 - 100s / Default: 0 (disabled) + .br +-Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. ++Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth movies. To smooth movies use larger values of post_capture instead. + .TP + .B process_id_file string + Values: Max 4095 characters / Default: Not defined +@@ -373,7 +394,7 @@ Be quiet, don't output beeps when detect + .B rotate discrete strings + Values: 0, 90, 180, 270 / Default: 0 (not rotated) + .br +-Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. ++Rotate image the given number of degrees. The rotation affects all saved images as well as movies. + .TP + .B roundrobin_frames integer + Values: 1 - 2147483647 / Default: 1 +@@ -390,10 +411,15 @@ Values: 0 - 255 / Default: 0 (disabled) + .br + The colour saturation level for the video device. + .TP ++.B sdl_threadnr ++Values: 0 - 2147483647 / Default: 0 (disabled) ++.br ++Number of motion thread to show in SDL Window (default: 0 = disabled) ++.TP + .B setup_mode boolean + Values: on, off / Default: off + .br +-Run Motion in setup mode. ++Run Motion in setup mode. + .TP + .B smart_mask_speed integer + Values: 0 - 10 / Default: 0 (disabled) +@@ -410,15 +436,15 @@ Values: 0 - 2147483647 / Default: 0 (dis + .br + Make automated snapshots every 'snapshot_interval' seconds. + .TP +-.B sql_log_image boolean ++.B sql_log_picture boolean + Values: on, off / Default: on + .br + Log to the database when creating motion triggered image file. + .TP +-.B sql_log_mpeg boolean ++.B sql_log_movie boolean + Values: on, off / Default: off + .br +-Log to the database when creating motion triggered mpeg file. ++Log to the database when creating motion triggered movie file. + .TP + .B sql_log_snapshot boolean + Values: on, off / Default: on +@@ -428,13 +454,53 @@ Log to the database when creating a snap + .B sql_log_timelapse boolean + Values: on, off / Default: off + .br +-Log to the database when creating timelapse mpeg file ++Log to the database when creating timelapse movie file + .TP + .B sql_query string +-Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') ++Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') + .br + SQL query string that is sent to the database. The values for each field are given by using convertion specifiers + .TP ++.B stream_auth_method integer ++Values: 0 = disabled , 1 = Basic authentication ,2 = MD5 digest (the safer authentication). / Default: 0 (disabled) ++.br ++Set the authentication method for stream. ++.TP ++.B stream_authentication string ++Values: username:password / Default: not defined (disabled) ++.br ++Authentication for the stream. ++.TP ++.B stream_limit integer ++Values: 0 - 2147483647 / Default: 0 (unlimited) ++.br ++Limit the number of frames to number frames. After 'stream_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. ++.TP ++.B stream_localhost boolean ++Values: on, off / Default: on ++.br ++Limits the access to the stream to the localhost. ++.TP ++.B stream_maxrate integer ++Values: 1 - 100 / Default: 1 ++.br ++Limit the framerate of the stream in frames per second. Default is 1. Set the value to 100 for practically unlimited. ++.TP ++.B stream_motion boolean ++Values: on, off / Default: off ++.br ++If set to 'on' Motion sends slows down the stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by stream_maxrate. When 'off' the stream always runs as defined by stream_maxrate. ++.TP ++.B stream_port integer ++Values: 0 - 65535 / Default: 0 (disabled) ++.br ++TCP port on which motion will listen for incoming connects with its stream server. ++.TP ++.B stream_quality integer ++Values: 1 - 100 / Default: 50 ++.br ++Quality setting in percent for the mjpeg picture frames transferred over the stream connection. Keep it low to restrict needed bandwidth. ++.TP + .B switchfilter boolean + Values: on, off / Default: off + .br +@@ -458,17 +524,17 @@ Draw characters at twice normal size on + .B text_event string + Values: Max 4095 characters / Default: %Y%m%d%H%M%S + .br +-This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. ++This option defines the value of the special event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. + .TP + .B text_left string + Values: Max 4095 characters / Default: Not defined + .br +-User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). ++User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). + .TP + .B text_right string + Values: Max 4095 characters / Default: %Y-%m-%d\n%T + .br +-User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock ++User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock + .TP + .B thread string + Values: Max 4095 characters / Default: Not defined +@@ -483,12 +549,12 @@ Threshold for declaring motion. The thre + .B threshold_tune boolean + Values: on, off / Default: off + .br +-Activates the automatic tuning of threshold level. ( It's broken ) ++Activates the automatic tuning of threshold level. + .TP + .B timelapse_filename string + Values: Max 4095 characters / Default: %v-%Y%m%d-timelapse + .br +-File path for timelapse mpegs relative to target_dir (ffmpeg only). ++File path for timelapse movies relative to target_dir (ffmpeg only). + .TP + .B track_auto boolean + Values: on, off / Default: off +@@ -496,17 +562,17 @@ Values: on, off / Default: off + Enable auto tracking + .TP + .B track_iomojo_id integer +-Values: 0 - 65535 / Default: 0 ++Values: 0 - 65535 / Default: 0 + .br + Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. + .TP + .B track_maxx integer +-Values: 0 - 65535 / Default: 0 ++Values: 0 - 65535 / Default: 0 + .br + The maximum position for servo x. + .TP + .B track_maxy integer +-Values: 0 - 65535 / Default: 0 ++Values: 0 - 65535 / Default: 0 + .br + The maximum position for servo y. + .TP +@@ -551,7 +617,7 @@ Values: 0 - 255 / Default: 40 + Number of steps to make. + .TP + .B track_type discrete strings +-Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) ++Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) + .br + Type of tracker. + .TP +@@ -560,55 +626,52 @@ Values: Max 4095 characters / Default: / + .br + The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. + .TP +-.B v4l2_palette integer +-Values: 0 - 8 / Default: 8 ++.B use_extpipe boolean ++Values: on, off / Default: off + .br +-Allow to choose preferable palette to be use by motion
to capture from those supported by your videodevice. ( new in 3.2.10 ) ++Enables extpipe to use an external video encoder feeding with YUV420 using a pipe . + .TP +-.B videodevice string +-Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) ++.B v4l2_palette discrete strings ++Values: 0 - 8 / Default: 8 + .br +-The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. ++Allow to choose preferable palette to be use by motion to capture from those supported by your videodevice. + .TP + .B video_pipe string + Values: Max 4095 characters / Default: Not defined + .br + The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. + .TP +-.B webcam_limit integer +-Values: 0 - 2147483647 / Default: 0 (unlimited) ++.B videodevice string ++Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) + .br +-Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. ++The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. + .TP +-.B webcam_localhost boolean +-Values: on, off / Default: on ++.B webcontrol_authentication string ++Values: Max 4096 characters / Default: Not defined + .br +-Limits the access to the webcam to the localhost. ++To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username: password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. + .TP +-.B webcam_maxrate integer +-Values: 1 - 100 / Default: 1 ++.B webcontrol_html_output boolean ++Values: on, off / Default: on + .br +-Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. ++Enable HTML in the answer sent back to a browser connecting to the webcontrol_port. This option must be placed in motion.conf and not in a thread config file. + .TP +-.B webcam_motion boolean +-Values: on, off / Default: off ++.B webcontrol_localhost boolean ++Values: on, off / Default: on + .br +-If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. ++Limits the webcontrol to the localhost. This option must be placed in motion.conf and not in a thread config file. + .TP +-.B webcam_port integer ++.B webcontrol_port integer + Values: 0 - 65535 / Default: 0 (disabled) + .br +-TCP port on which motion will listen for incoming connects with its webcam server. +-.TP +-.B webcam_quality integer +-Values: 1 - 100 / Default: 50 +-.br +-Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. ++Sets the port number for the http (html using browser) based remote webcontrol. This option must be placed in motion.conf and not in a thread config file. ++ + .TP + .B width integer + Values: Device Dependent / Default: 352 + .br + The width in pixels of each frame. Valid range is camera dependent. ++ + .SH SIGNALS + Motion responds to the following signals: + .TP +@@ -616,17 +679,17 @@ Motion responds to the following signals + The config file will be reread. + .TP + .B SIGTERM +-If needed motion will create an mpeg file of the last event and exit ++If needed motion will create a movie file of the last event and exit + .TP + .B SIGUSR1 +-Motion will create an mpeg file of the current event. ++Motion will create a movie file of the current event. + .SH NOTES + .TP + .B Snapshot + A snapshot is a picture taken at regular intervals independently of any movement in the picture. + .TP + .B Motion image +-A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. ++A "motion" image/movie shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. + .TP + .B Normal image + A "normal" image is the real image taken by the camera with text overlayed. +@@ -674,13 +737,13 @@ So always call the thread config files i + .br + If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. + .br +-If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. ++If you run the webcontrol command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. + .TP + .B Conversion Specifiers for Advanced Filename and Text Features +-The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_area_detected, on_camera_lost, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. +- ++The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, picture_filename, movie_filename, timelapse_filename, on_area_detected, on_camera_lost, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. + .br + In text_left and text_right you can additionally use '\n' for new line. ++ + .TP + .B %a + The abbreviated weekday name according to the current locale. +@@ -719,7 +782,7 @@ Equivalent to %Y-%m-%d (the ISO 8601 dat + The hour as a decimal number using a 24-hour clock (range 00 to 23). + .TP + .B %i +-Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). ++Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate_motion is on). + .TP + .B %I + The hour as a decimal number using a 12-hour clock (range 01 to 12). +@@ -728,7 +791,7 @@ The hour as a decimal number using a 12- + The day of the year as a decimal number (range 001 to 366). + .TP + .B %J +-Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). ++Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate_motion is on). + .TP + .B %k + The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) +@@ -764,7 +827,7 @@ Either 'AM' or 'PM' according to the giv + Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. + .TP + .B %q +-Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. ++Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for movies. + .TP + .B %Q + Number of detected labels found by the despeckle feature +@@ -822,16 +885,17 @@ The time-zone as hour offset from GMT. + .TP + .B %Z + The time zone or name or abbreviation. ++ + .TP + .B More information + Motion homepage: http://motion.sourceforge.net/ + + Motion Guide (user and installation guide): + .br +-http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide ++http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide + .br +-http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoFourLinuxLoopbackDevice ++http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice + .SH AUTHORS + Jeroen Vreeken (pe1rxq@amsat.org), + Folkert van Heusden, +-Kenneth Lavrsen (kenneth@lavrsen.dk) +\ No newline at end of file ++Kenneth Lavrsen (kenneth@lavrsen.dk) +--- motion-3.2.12.orig/motion.c ++++ motion-3.2.12/motion.c +@@ -9,7 +9,7 @@ + #include "ffmpeg.h" + #include "motion.h" + +-#if (defined(BSD) && !defined(PWCBSD)) ++#if (defined(BSD) && !defined(PWCBSD)) + #include "video_freebsd.h" + #else + #include "video.h" +@@ -58,15 +58,11 @@ struct context **cnt_list = NULL; + */ + volatile int threads_running = 0; + +-/* +- * debug_level is for developers, normally used to control which +- * types of messages get output. +- */ +-unsigned short int debug_level; ++/* Set this when we want main to end or restart */ ++volatile unsigned int finish = 0; + +-/* Set this when we want main to end or restart +- */ +-volatile unsigned short int finish = 0; ++/* Log file used instead of stderr and syslog */ ++FILE *ptr_logfile = NULL; + + /** + * restart +@@ -75,7 +71,7 @@ volatile unsigned short int finish = 0; + * finished running, 'main' checks if 'restart' is true and if so starts + * up again (instead of just quitting). + */ +-unsigned short int restart = 0; ++unsigned int restart = 0; + + /** + * image_ring_resize +@@ -92,29 +88,33 @@ unsigned short int restart = 0; + */ + static void image_ring_resize(struct context *cnt, int new_size) + { +- /* Only resize if : ++ /* ++ * Only resize if : + * Not in an event and + * decreasing at last position in new buffer + * increasing at last position in old buffer +- * e.g. at end of smallest buffer */ ++ * e.g. at end of smallest buffer ++ */ + if (cnt->event_nr != cnt->prev_event) { + int smallest; +- +- if (new_size < cnt->imgs.image_ring_size) { /* Decreasing */ ++ ++ if (new_size < cnt->imgs.image_ring_size) /* Decreasing */ + smallest = new_size; +- } else { /* Increasing */ ++ else /* Increasing */ + smallest = cnt->imgs.image_ring_size; +- } +- ++ + if (cnt->imgs.image_ring_in == smallest - 1 || smallest == 0) { +- motion_log(LOG_INFO, 0, "Resizing pre_capture buffer to %d items", new_size); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Resizing pre_capture buffer to %d items", ++ new_size); + + /* Create memory for new ring buffer */ + struct image_data *tmp; + tmp = mymalloc(new_size * sizeof(struct image_data)); + +- /* Copy all information from old to new +- * Smallest is 0 at initial init */ ++ /* ++ * Copy all information from old to new ++ * Smallest is 0 at initial init ++ */ + if (smallest > 0) + memcpy(tmp, cnt->imgs.image_ring, sizeof(struct image_data) * smallest); + +@@ -152,7 +152,7 @@ static void image_ring_resize(struct con + */ + static void image_ring_destroy(struct context *cnt) + { +- unsigned short int i; ++ int i; + + /* Exit if don't have any ring */ + if (cnt->imgs.image_ring == NULL) +@@ -195,16 +195,30 @@ static void image_save_as_preview(struct + /* Copy image */ + memcpy(cnt->imgs.preview_image.image, img->image, cnt->imgs.size); + +- /* If we set output_all to yes and during the event +- * there is no image with motion, diffs is 0, we are not going to save the preview event */ ++ /* ++ * If we set output_all to yes and during the event ++ * there is no image with motion, diffs is 0, we are not going to save the preview event ++ */ + if (cnt->imgs.preview_image.diffs == 0) + cnt->imgs.preview_image.diffs = 1; + +- /* If we have locate on it is already done */ +- if (cnt->locate == LOCATE_PREVIEW) +- alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, +- cnt->imgs.preview_image.image, LOCATE_NORMAL); +- ++ /* draw locate box here when mode = LOCATE_PREVIEW */ ++ if (cnt->locate_motion_mode == LOCATE_PREVIEW) { ++ ++ if (cnt->locate_motion_style == LOCATE_BOX) { ++ alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, ++ LOCATE_BOX, LOCATE_NORMAL, cnt->process_thisframe); ++ } else if (cnt->locate_motion_style == LOCATE_REDBOX) { ++ alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, ++ LOCATE_REDBOX, LOCATE_NORMAL, cnt->process_thisframe); ++ } else if (cnt->locate_motion_style == LOCATE_CROSS) { ++ alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, ++ LOCATE_CROSS, LOCATE_NORMAL, cnt->process_thisframe); ++ } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { ++ alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, ++ LOCATE_REDCROSS, LOCATE_NORMAL, cnt->process_thisframe); ++ } ++ } + } + + /** +@@ -219,9 +233,9 @@ static void image_save_as_preview(struct + * + * Returns: nothing + */ +-static void context_init (struct context *cnt) ++static void context_init(struct context *cnt) + { +- /* ++ /* + * We first clear the entire structure to zero, then fill in any + * values which have non-zero default values. Note that this + * assumes that a NULL address pointer has a value of binary 0 +@@ -255,7 +269,7 @@ static void context_init (struct context + */ + static void context_destroy(struct context *cnt) + { +- unsigned short int j; ++ unsigned int j; + + /* Free memory allocated for config parameters */ + for (j = 0; config_params[j].param_name != NULL; j++) { +@@ -279,11 +293,12 @@ static void context_destroy(struct conte + */ + static void sig_handler(int signo) + { +- short int i; ++ int i; + + switch(signo) { + case SIGALRM: +- /* Somebody (maybe we ourself) wants us to make a snapshot ++ /* ++ * Somebody (maybe we ourself) wants us to make a snapshot + * This feature triggers snapshots on ALL threads that have + * snapshot_interval different from 0. + */ +@@ -292,13 +307,15 @@ static void sig_handler(int signo) + while (cnt_list[++i]) { + if (cnt_list[i]->conf.snapshot_interval) + cnt_list[i]->snapshot = 1; +- ++ + } + } + break; + case SIGUSR1: +- /* Ouch! We have been hit from the outside! Someone wants us to +- make a movie! */ ++ /* ++ * Ouch! We have been hit from the outside! Someone wants us to ++ * make a movie! ++ */ + if (cnt_list) { + i = -1; + while (cnt_list[++i]) +@@ -307,27 +324,33 @@ static void sig_handler(int signo) + break; + case SIGHUP: + restart = 1; +- /* Fall through, as the value of 'restart' is the only difference ++ /* ++ * Fall through, as the value of 'restart' is the only difference + * between SIGHUP and the ones below. + */ + case SIGINT: + case SIGQUIT: + case SIGTERM: +- /* Somebody wants us to quit! We should better finish the actual +- movie and end up! */ ++ /* ++ * Somebody wants us to quit! We should better finish the actual ++ * movie and end up! ++ */ + if (cnt_list) { + i = -1; + while (cnt_list[++i]) { + cnt_list[i]->makemovie = 1; + cnt_list[i]->finish = 1; +- /* don't restart thread when it ends, ++ /* ++ * Don't restart thread when it ends, + * all threads restarts if global restart is set + */ +- cnt_list[i]->restart = 0; ++ cnt_list[i]->restart = 0; + } + } +- /* Set flag we want to quit main check threads loop +- * if restart is set (above) we start up again */ ++ /* ++ * Set flag we want to quit main check threads loop ++ * if restart is set (above) we start up again ++ */ + finish = 1; + break; + case SIGSEGV: +@@ -350,26 +373,34 @@ static void sigchild_handler(int signo A + } + + /** +- * motion_remove_pid +- * +- * This function remove the process id file ( pid file ) before motion exit. ++ * motion_remove_pid + * ++ * This function remove the process id file ( pid file ) before motion exit. + */ + static void motion_remove_pid(void) + { + if ((cnt_list[0]->daemon) && (cnt_list[0]->conf.pid_file) && (restart == 0)) { + if (!unlink(cnt_list[0]->conf.pid_file)) +- motion_log(LOG_INFO, 0, "Removed process id file (pid file)."); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Removed process id file (pid file)."); + else +- motion_log(LOG_INFO, 1, "Error removing pid file"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error removing pid file"); + } ++ ++ if (ptr_logfile) { ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Closing logfile (%s).", ++ cnt_list[0]->conf.log_file); ++ myfclose(ptr_logfile); ++ set_log_mode(LOGMODE_SYSLOG); ++ ptr_logfile = NULL; ++ } ++ + } + + /** + * motion_detected + * + * Called from 'motion_loop' when motion is detected +- * Can be called when no motion if output_all is set! ++ * Can be called when no motion if emulate_motion is set! + * + * Parameters: + * +@@ -384,14 +415,29 @@ static void motion_detected(struct conte + struct coord *location = &img->location; + + /* Draw location */ +- if (cnt->locate == LOCATE_ON) +- alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_BOTH); ++ if (cnt->locate_motion_mode == LOCATE_ON) { ++ ++ if (cnt->locate_motion_style == LOCATE_BOX) { ++ alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_BOX, ++ LOCATE_BOTH, cnt->process_thisframe); ++ } else if (cnt->locate_motion_style == LOCATE_REDBOX) { ++ alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDBOX, ++ LOCATE_BOTH, cnt->process_thisframe); ++ } else if (cnt->locate_motion_style == LOCATE_CROSS) { ++ alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_CROSS, ++ LOCATE_BOTH, cnt->process_thisframe); ++ } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { ++ alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDCROSS, ++ LOCATE_BOTH, cnt->process_thisframe); ++ } ++ } + + /* Calculate how centric motion is if configured preview center*/ + if (cnt->new_img & NEWIMG_CENTER) { +- unsigned int distX = abs((imgs->width/2) - location->x); +- unsigned int distY = abs((imgs->height/2) - location->y); +- img->cent_dist = distX*distX + distY*distY; ++ unsigned int distX = abs((imgs->width / 2) - location->x); ++ unsigned int distY = abs((imgs->height / 2) - location->y); ++ ++ img->cent_dist = distX * distX + distY * distY; + } + + +@@ -399,14 +445,16 @@ static void motion_detected(struct conte + if (img->flags & IMAGE_TRIGGER) { + /* Take action if this is a new event and we have a trigger image */ + if (cnt->event_nr != cnt->prev_event) { +- /* Reset prev_event number to current event and save event time ++ /* ++ * Reset prev_event number to current event and save event time + * in both time_t and struct tm format. + */ + cnt->prev_event = cnt->event_nr; + cnt->eventtime = img->timestamp; + localtime_r(&cnt->eventtime, cnt->eventtime_tm); + +- /* Since this is a new event we create the event_text_string used for ++ /* ++ * Since this is a new event we create the event_text_string used for + * the %C conversion specifier. We may already need it for + * on_motion_detected_commend so it must be done now. + */ +@@ -416,8 +464,8 @@ static void motion_detected(struct conte + /* EVENT_FIRSTMOTION triggers on_event_start_command and event_ffmpeg_newfile */ + event(cnt, EVENT_FIRSTMOTION, img->image, NULL, NULL, &img->timestamp_tm); + +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Motion detected - starting event %d", cnt->event_nr); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion detected - starting event %d", ++ cnt->event_nr); + + /* always save first motion frame as preview-shot, may be changed to an other one later */ + if (cnt->new_img & (NEWIMG_FIRST | NEWIMG_BEST | NEWIMG_CENTER)) +@@ -431,23 +479,25 @@ static void motion_detected(struct conte + + /* Limit framerate */ + if (img->shot < conf->frame_limit) { +- /* If config option webcam_motion is enabled, send the latest motion detected image +- * to the webcam but only if it is not the first shot within a second. This is to +- * avoid double frames since we already have sent a frame to the webcam. ++ /* ++ * If config option stream_motion is enabled, send the latest motion detected image ++ * to the stream but only if it is not the first shot within a second. This is to ++ * avoid double frames since we already have sent a frame to the stream. + * We also disable this in setup_mode. + */ +- if (conf->webcam_motion && !conf->setup_mode && img->shot != 1) +- event(cnt, EVENT_WEBCAM, img->image, NULL, NULL, &img->timestamp_tm); +- ++ if (conf->stream_motion && !conf->setup_mode && img->shot != 1) ++ event(cnt, EVENT_STREAM, img->image, NULL, NULL, &img->timestamp_tm); + +- /* Save motion jpeg, if configured */ +- /* Output the image_out (motion) picture. */ ++ /* ++ * Save motion jpeg, if configured ++ * Output the image_out (motion) picture. ++ */ + if (conf->motion_img) + event(cnt, EVENT_IMAGEM_DETECTED, NULL, NULL, NULL, &img->timestamp_tm); +- + } + +- if (cnt->track.type) ++ /* if track enabled and auto track on */ ++ if (cnt->track.type && cnt->track.active) + cnt->moved = track_move(cnt, dev, location, imgs, 0); + + } +@@ -466,26 +516,99 @@ static void motion_detected(struct conte + #define IMAGE_BUFFER_FLUSH ((unsigned int)-1) + static void process_image_ring(struct context *cnt, unsigned int max_images) + { +- /* we are going to send an event, in the events there is still ++ /* ++ * We are going to send an event, in the events there is still + * some code that use cnt->current_image +- * so set it temporary to our image */ ++ * so set it temporary to our image ++ */ + struct image_data *saved_current_image = cnt->current_image; + + /* If image is flaged to be saved and not saved yet, process it */ + do { + /* Check if we should save/send this image, breakout if not */ +- if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & +- (IMAGE_SAVE | IMAGE_SAVED)) != IMAGE_SAVE) ++ if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & (IMAGE_SAVE | IMAGE_SAVED)) != IMAGE_SAVE) + break; + + /* Set inte global cotext that we are working with this image */ + cnt->current_image = &cnt->imgs.image_ring[cnt->imgs.image_ring_out]; + + if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot < cnt->conf.frame_limit) { ++ if (cnt->log_level >= DBG) { ++ char tmp[32]; ++ const char *t; ++ ++ if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_TRIGGER) ++ t = "Trigger"; ++ else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_MOTION) ++ t = "Motion"; ++ else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_PRECAP) ++ t = "Precap"; ++ else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_POSTCAP) ++ t = "Postcap"; ++ else ++ t = "Other"; ++ ++ mystrftime(cnt, tmp, sizeof(tmp), "%H%M%S-%q", ++ &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm, NULL, 0); ++ draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 20, ++ cnt->imgs.width, tmp, cnt->conf.text_double); ++ draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 30, ++ cnt->imgs.width, t, cnt->conf.text_double); ++ } ++ + /* Output the picture to jpegs and ffmpeg */ + event(cnt, EVENT_IMAGE_DETECTED, + cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, + &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm); ++ ++ /* ++ * 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) && ++#ifdef HAVE_FFMPEG ++ (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { ++#else ++ (cnt->conf.useextpipe && cnt->extpipe)) { ++#endif ++ /* ++ * 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) { ++ if (cnt_list[0]->log_level >= DBG) { ++ int frames = cnt->movie_fps - (cnt->movie_last_shot + 1); ++ if (frames > 0) { ++ char tmp[15]; ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Added %d fillerframes into movie", ++ frames); ++ sprintf(tmp, "Fillerframes %d", frames); ++ draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 40, ++ cnt->imgs.width, tmp, cnt->conf.text_double); ++ } ++ } ++ /* Check how many frames it was last sec */ ++ while ((cnt->movie_last_shot + 1) < cnt->movie_fps) { ++ /* Add a filler frame into encoder */ ++ event(cnt, EVENT_FFMPEG_PUT, ++ cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, ++ &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm); ++ ++ cnt->movie_last_shot++; ++ } ++ } ++ 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! 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; + } + + /* Mark the image as saved */ +@@ -493,17 +616,17 @@ static void process_image_ring(struct co + + /* Store it as a preview image, only if it have motion */ + if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_MOTION) { +- +- /* Check for most significant preview-shot when output_normal=best */ ++ /* Check for most significant preview-shot when output_pictures=best */ + if (cnt->new_img & NEWIMG_BEST) { +- if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].diffs > cnt->imgs.preview_image.diffs) ++ if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].diffs > cnt->imgs.preview_image.diffs) { + image_save_as_preview(cnt, &cnt->imgs.image_ring[cnt->imgs.image_ring_out]); ++ } + } +- +- /* Check for most significant preview-shot when output_normal=center */ ++ /* Check for most significant preview-shot when output_pictures=center */ + if (cnt->new_img & NEWIMG_CENTER) { +- if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].cent_dist < cnt->imgs.preview_image.cent_dist) ++ if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].cent_dist < cnt->imgs.preview_image.cent_dist) { + image_save_as_preview(cnt, &cnt->imgs.image_ring[cnt->imgs.image_ring_out]); ++ } + } + } + +@@ -538,10 +661,10 @@ static void process_image_ring(struct co + * Returns: 0 OK + * -1 Fatal error, open loopback error + * -2 Fatal error, open SQL database error ++ * -3 Fatal error, image dimensions are not modulo 16 + */ + static int motion_init(struct context *cnt) + { +- int i; + FILE *picture; + + /* Store thread number in TLS. */ +@@ -555,34 +678,42 @@ static int motion_init(struct context *c + + cnt->smartmask_speed = 0; + +- /* We initialize cnt->event_nr to 1 and cnt->prev_event to 0 (not really needed) so +- * that certain code below does not run until motion has been detected the first time */ ++ /* ++ * We initialize cnt->event_nr to 1 and cnt->prev_event to 0 (not really needed) so ++ * that certain code below does not run until motion has been detected the first time ++ */ + cnt->event_nr = 1; + cnt->prev_event = 0; + cnt->lightswitch_framecounter = 0; + cnt->detecting_motion = 0; + cnt->makemovie = 0; + +- motion_log(LOG_DEBUG, 0, "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 = strdup("."); ++ cnt->conf.filepath = mystrdup("."); + + /* set the device settings */ + cnt->video_dev = vid_start(cnt); + +- /* We failed to get an initial image from a camera ++ /* ++ * We failed to get an initial image from a camera + * So we need to guess height and width based on the config + * file options. + */ +- if (cnt->video_dev < 0) { +- motion_log(LOG_ERR, 0, "Could not fetch initial image from camera"); +- motion_log(LOG_ERR, 0, "Motion continues using width and height from config file(s)"); ++ if (cnt->video_dev == -1) { ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " ++ "Motion continues using width and height from config file(s)"); + cnt->imgs.width = cnt->conf.width; + cnt->imgs.height = cnt->conf.height; + cnt->imgs.size = cnt->conf.width * cnt->conf.height * 3 / 2; + cnt->imgs.motionsize = cnt->conf.width * cnt->conf.height; + cnt->imgs.type = VIDEO_PALETTE_YUV420P; ++ } else if (cnt->video_dev == -2) { ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " ++ "Motion only supports width and height modulo 16"); ++ return -3; + } + + image_ring_resize(cnt, 1); /* Create a initial precapture ring buffer with 1 frame */ +@@ -590,6 +721,7 @@ static int motion_init(struct context *c + cnt->imgs.ref = mymalloc(cnt->imgs.size); + cnt->imgs.out = mymalloc(cnt->imgs.size); + memset(cnt->imgs.out, 0, cnt->imgs.size); ++ + /* contains the moving objects of ref. frame */ + cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); + cnt->imgs.image_virgin = mymalloc(cnt->imgs.size); +@@ -599,14 +731,23 @@ static int motion_init(struct context *c + cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.labels)); + cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(cnt->imgs.labelsize)); + ++ /* Set output picture type */ ++ if (!strcmp(cnt->conf.picture_type, "ppm")) ++ cnt->imgs.picture_type = IMAGE_TYPE_PPM; ++ else ++ cnt->imgs.picture_type = IMAGE_TYPE_JPEG; ++ + /* allocate buffer here for preview buffer */ + cnt->imgs.preview_image.image = mymalloc(cnt->imgs.size); + +- /* Allocate a buffer for temp. usage in some places */ +- /* Only despeckle & bayer2rgb24() for now for now... */ ++ /* ++ * Allocate a buffer for temp. usage in some places ++ * Only despeckle & bayer2rgb24() for now for now... ++ */ + cnt->imgs.common_buffer = mymalloc(3 * cnt->imgs.width * cnt->imgs.height); + +- /* Now is a good time to init rotation data. Since vid_start has been ++ /* ++ * Now is a good time to init rotation data. Since vid_start has been + * called, we know that we have imgs.width and imgs.height. When capturing + * from a V4L device, these are copied from the corresponding conf values + * in vid_start. When capturing from a netcam, they get set in netcam_start, +@@ -618,130 +759,160 @@ static int motion_init(struct context *c + + /* Capture first image, or we will get an alarm on start */ + if (cnt->video_dev > 0) { ++ int i; ++ + for (i = 0; i < 5; i++) { + if (vid_next(cnt, cnt->imgs.image_virgin) == 0) + break; +- SLEEP(2,0); ++ SLEEP(2, 0); + } ++ + if (i >= 5) { + memset(cnt->imgs.image_virgin, 0x80, cnt->imgs.size); /* initialize to grey */ + draw_text(cnt->imgs.image_virgin, 10, 20, cnt->imgs.width, + "Error capturing first image", cnt->conf.text_double); +- motion_log(LOG_ERR, 0, "Error capturing first image"); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Error capturing first image"); + } + } + + /* create a reference frame */ + alg_update_reference_frame(cnt, RESET_REF_FRAME); + +-#if !defined(WITHOUT_V4L) && !defined(BSD) ++#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) + /* open video loopback devices if enabled */ + if (cnt->conf.vidpipe) { +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Opening video loopback device for normal pictures"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for normal pictures"); + + /* vid_startpipe should get the output dimensions */ + cnt->pipe = vid_startpipe(cnt->conf.vidpipe, cnt->imgs.width, cnt->imgs.height, cnt->imgs.type); + + if (cnt->pipe < 0) { +- motion_log(LOG_ERR, 0, "Failed to open video loopback"); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for normal pictures"); + return -1; + } + } ++ + if (cnt->conf.motionvidpipe) { +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Opening video loopback device for motion pictures"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for motion pictures"); + + /* vid_startpipe should get the output dimensions */ + cnt->mpipe = vid_startpipe(cnt->conf.motionvidpipe, cnt->imgs.width, cnt->imgs.height, cnt->imgs.type); + + if (cnt->mpipe < 0) { +- motion_log(LOG_ERR, 0, "Failed to open video loopback"); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for motion pictures"); + return -1; + } + } +-#endif /*WITHOUT_V4L && !BSD */ ++#endif /* !WITHOUT_V4L && !BSD */ + +-#ifdef HAVE_MYSQL +- if (cnt->conf.mysql_db) { +- cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); +- mysql_init(cnt->database); +- +- if (!mysql_real_connect(cnt->database, cnt->conf.mysql_host, cnt->conf.mysql_user, +- cnt->conf.mysql_password, cnt->conf.mysql_db, 0, NULL, 0)) { +- motion_log(LOG_ERR, 0, "Cannot connect to MySQL database %s on host %s with user %s", +- cnt->conf.mysql_db, cnt->conf.mysql_host, cnt->conf.mysql_user); +- motion_log(LOG_ERR, 0, "MySQL error was %s", mysql_error(cnt->database)); +- return -2; +- } +- #if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) +- my_bool my_true = TRUE; +- mysql_options(cnt->database,MYSQL_OPT_RECONNECT,&my_true); +- #endif ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) ++ if (cnt->conf.database_type) { ++ MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: Database backend %s", ++ cnt->conf.database_type); ++ ++#ifdef HAVE_SQLITE3 ++ if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { ++ MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: DB %s", ++ cnt->conf.sqlite3_db); ++ ++ if (sqlite3_open(cnt->conf.sqlite3_db, &cnt->database_sqlite3) != SQLITE_OK) { ++ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s\n", ++ cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); ++ sqlite3_close(cnt->database_sqlite3); ++ exit(1); ++ } + } ++#endif /* HAVE_SQLITE3 */ ++ ++#ifdef HAVE_MYSQL ++ if ((!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { ++ // close database to be sure that we are not leaking ++ mysql_close(cnt->database); ++ ++ cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); ++ mysql_init(cnt->database); ++ ++ if (!mysql_real_connect(cnt->database, cnt->conf.database_host, cnt->conf.database_user, ++ cnt->conf.database_password, cnt->conf.database_dbname, 0, NULL, 0)) { ++ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Cannot connect to MySQL database %s on host %s with user %s", ++ cnt->conf.database_dbname, cnt->conf.database_host, ++ cnt->conf.database_user); ++ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: MySQL error was %s", mysql_error(cnt->database)); ++ return -2; ++ } ++#if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) ++ my_bool my_true = TRUE; ++ mysql_options(cnt->database, MYSQL_OPT_RECONNECT, &my_true); ++#endif ++ } + #endif /* HAVE_MYSQL */ + + #ifdef HAVE_PGSQL +- if (cnt->conf.pgsql_db) { +- char connstring[255]; ++ if ((!strcmp(cnt->conf.database_type, "postgresql")) && (cnt->conf.database_dbname)) { ++ char connstring[255]; + +- /* create the connection string. +- Quote the values so we can have null values (blank)*/ +- snprintf(connstring, 255, +- "dbname='%s' host='%s' user='%s' password='%s' port='%d'", +- cnt->conf.pgsql_db, /* dbname */ +- (cnt->conf.pgsql_host ? cnt->conf.pgsql_host : ""), /* host (may be blank) */ +- (cnt->conf.pgsql_user ? cnt->conf.pgsql_user : ""), /* user (may be blank) */ +- (cnt->conf.pgsql_password ? cnt->conf.pgsql_password : ""), /* password (may be blank) */ +- cnt->conf.pgsql_port +- ); +- +- cnt->database_pg = PQconnectdb(connstring); +- +- if (PQstatus(cnt->database_pg) == CONNECTION_BAD) { +- motion_log(LOG_ERR, 0, "Connection to PostgreSQL database '%s' failed: %s", +- cnt->conf.pgsql_db, PQerrorMessage(cnt->database_pg)); +- return -2; ++ /* ++ * Create the connection string. ++ * Quote the values so we can have null values (blank) ++ */ ++ snprintf(connstring, 255, ++ "dbname='%s' host='%s' user='%s' password='%s' port='%d'", ++ cnt->conf.database_dbname, /* dbname */ ++ (cnt->conf.database_host ? cnt->conf.database_host : ""), /* host (may be blank) */ ++ (cnt->conf.database_user ? cnt->conf.database_user : ""), /* user (may be blank) */ ++ (cnt->conf.database_password ? cnt->conf.database_password : ""), /* password (may be blank) */ ++ cnt->conf.database_port ++ ); ++ ++ cnt->database_pg = PQconnectdb(connstring); ++ 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)); ++ return -2; ++ } + } +- } + #endif /* HAVE_PGSQL */ ++ + ++ /* Set the sql mask file according to the SQL config options*/ + +-#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) +- /* Set the sql mask file according to the SQL config options*/ ++ cnt->sql_mask = cnt->conf.sql_log_image * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + ++ cnt->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + ++ cnt->conf.sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + ++ cnt->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; ++ } + +- cnt->sql_mask = cnt->conf.sql_log_image * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + +- cnt->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + +- cnt->conf.sql_log_mpeg * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + +- cnt->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; +-#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) */ ++#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ + + /* Load the mask file if any */ + if (cnt->conf.mask_file) { +- if ((picture = fopen(cnt->conf.mask_file, "r"))) { +- /* NOTE: The mask is expected to have the output dimensions. I.e., the mask ++ if ((picture = myfopen(cnt->conf.mask_file, "r", 0))) { ++ /* ++ * NOTE: The mask is expected to have the output dimensions. I.e., the mask + * applies to the already rotated image, not the capture image. Thus, use + * width and height from imgs. + */ + cnt->imgs.mask = get_pgm(picture, cnt->imgs.width, cnt->imgs.height); +- fclose(picture); ++ myfclose(picture); + } else { +- motion_log(LOG_ERR, 1, "Error opening mask file %s", cnt->conf.mask_file); +- /* Try to write an empty mask file to make it easier +- for the user to edit it */ ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening mask file %s", ++ cnt->conf.mask_file); ++ /* ++ * Try to write an empty mask file to make it easier ++ * for the user to edit it ++ */ + put_fixed_mask(cnt, cnt->conf.mask_file); + } + + if (!cnt->imgs.mask) { +- motion_log(LOG_ERR, 0, "Failed to read mask image. Mask feature disabled."); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to read mask image. Mask feature disabled."); + } else { +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Maskfile \"%s\" loaded.",cnt->conf.mask_file); ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Maskfile \"%s\" loaded.", ++ cnt->conf.mask_file); + } +- + } else { + cnt->imgs.mask = NULL; +- } ++ } + + /* Always initialize smart_mask - someone could turn it on later... */ + memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); +@@ -754,13 +925,15 @@ static int motion_init(struct context *c + /* Set threshold value */ + cnt->threshold = cnt->conf.max_changes; + +- /* Initialize webcam server if webcam port is specified to not 0 */ +- if (cnt->conf.webcam_port) { +- if (webcam_init(cnt) == -1) { +- motion_log(LOG_ERR, 1, "Problem enabling stream server in port %d", cnt->conf.webcam_port); ++ /* Initialize stream server if stream port is specified to not 0 */ ++ if (cnt->conf.stream_port) { ++ if (stream_init(cnt) == -1) { ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem enabling motion-stream server in port %d", ++ cnt->conf.stream_port); + cnt->finish = 1; +- } else { +- motion_log(LOG_DEBUG, 0, "Started stream webcam server in port %d", cnt->conf.webcam_port); ++ } else { ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Started motion-stream server in port %d auth %s", ++ cnt->conf.stream_port, cnt->conf.stream_auth_method ? "Enabled":"Disabled"); + } + } + +@@ -786,11 +959,11 @@ static int motion_init(struct context *c + */ + static void motion_cleanup(struct context *cnt) + { +- /* Stop webcam */ ++ /* Stop stream */ + event(cnt, EVENT_STOP, NULL, NULL, NULL, NULL); + + if (cnt->video_dev >= 0) { +- motion_log(LOG_DEBUG, 0, "Calling vid_close() from motion_cleanup"); ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Calling vid_close() from motion_cleanup"); + vid_close(cnt); + } + +@@ -874,6 +1047,26 @@ static void motion_cleanup(struct contex + free(cnt->eventtime_tm); + cnt->eventtime_tm = NULL; + } ++ ++ if (cnt->conf.database_type) { ++#ifdef HAVE_MYSQL ++ if ( (!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { ++ mysql_close(cnt->database); ++ } ++#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 ++ /* Close the SQLite database */ ++ if (cnt->conf.sqlite3_db) ++ sqlite3_close(cnt->database_sqlite3); ++#endif /* HAVE_SQLITE3 */ ++ } + } + + /** +@@ -888,34 +1081,33 @@ static void *motion_loop(void *arg) + int i, j, z = 0; + time_t lastframetime = 0; + int frame_buffer_size; +- unsigned short int ref_frame_limit = 0; ++ unsigned int rate_limit = 0; + int area_once = 0; + int area_minx[9], area_miny[9], area_maxx[9], area_maxy[9]; + int smartmask_ratio = 0; + int smartmask_count = 20; +- int smartmask_lastrate = 0; ++ unsigned int smartmask_lastrate = 0; + int olddiffs = 0; + int previous_diffs = 0, previous_location_x = 0, previous_location_y = 0; +- unsigned short int text_size_factor; +- unsigned short int passflag = 0; ++ unsigned int text_size_factor; ++ unsigned int passflag = 0; + long int *rolling_average_data = NULL; + long int rolling_average_limit, required_frame_time, frame_delay, delay_time_nsec; + int rolling_frame = 0; + struct timeval tv1, tv2; + unsigned long int rolling_average, elapsedtime; + unsigned long long int timenow = 0, timebefore = 0; +- /* Return code used when calling vid_next */ +- int vid_return_code = 0; +- /* time in seconds to skip between capturing images */ +- int minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; +- /* Flag used to signal that we capture new image when we run the loop */ +- unsigned short int get_image = 1; ++ int vid_return_code = 0; /* Return code used when calling vid_next */ ++ int minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; /* time in seconds to skip between capturing images */ ++ unsigned int get_image = 1; /* Flag used to signal that we capture new image when we run the loop */ ++ struct image_data *old_image; + +- /* Next two variables are used for snapshot and timelapse feature +- * time_last_frame is set to 1 so that first coming timelapse or second=0 ++ /* ++ * Next two variables are used for snapshot and timelapse feature ++ * time_last_frame is set to 1 so that first coming timelapse or second = 0 + * is acted upon. + */ +- unsigned long int time_last_frame=1, time_current_frame; ++ unsigned long int time_last_frame = 1, time_current_frame; + + cnt->running = 1; + +@@ -967,6 +1159,10 @@ static void *motion_loop(void *arg) + for (j = 0; j < rolling_average_limit; j++) + rolling_average_data[j] = required_frame_time; + ++ ++ if (cnt->track.type) ++ cnt->moved = track_center(cnt, cnt->video_dev, 0, 0, 0); ++ + #ifdef __OpenBSD__ + /* + * FIXMARK +@@ -977,8 +1173,10 @@ static void *motion_loop(void *arg) + setup_signals(&sig_handler_action, &sigchild_action); + #endif + +- /* MAIN MOTION LOOP BEGINS HERE */ +- /* Should go on forever... unless you bought vaporware :) */ ++ /* ++ * MAIN MOTION LOOP BEGINS HERE ++ * Should go on forever... unless you bought vaporware :) ++ */ + + while (!cnt->finish || cnt->makemovie) { + +@@ -990,34 +1188,49 @@ static void *motion_loop(void *arg) + gettimeofday(&tv1, NULL); + timenow = tv1.tv_usec + 1000000L * tv1.tv_sec; + +- /* since we don't have sanity checks done when options are set, ++ /* ++ * Calculate detection rate limit. Above 5fps we limit the detection ++ * rate to 3fps to reduce load at higher framerates. ++ */ ++ cnt->process_thisframe = 0; ++ rate_limit++; ++ if (rate_limit >= (cnt->lastrate / 3)) { ++ rate_limit = 0; ++ cnt->process_thisframe = 1; ++ } ++ ++ /* ++ * Since we don't have sanity checks done when options are set, + * this sanity check must go in the main loop :(, before pre_captures +- * are attempted. */ ++ * are attempted. ++ */ + if (cnt->conf.minimum_motion_frames < 1) + cnt->conf.minimum_motion_frames = 1; +- ++ + if (cnt->conf.pre_capture < 0) + cnt->conf.pre_capture = 0; + +- /* Check if our buffer is still the right size ++ /* ++ * Check if our buffer is still the right size + * If pre_capture or minimum_motion_frames has been changed + * via the http remote control we need to re-size the ring buffer + */ + frame_buffer_size = cnt->conf.pre_capture + cnt->conf.minimum_motion_frames; +- ++ + if (cnt->imgs.image_ring_size != frame_buffer_size) + image_ring_resize(cnt, frame_buffer_size); + +- + /* Get time for current frame */ + cnt->currenttime = time(NULL); + +- /* localtime returns static data and is not threadsafe ++ /* ++ * localtime returns static data and is not threadsafe + * so we use localtime_r which is reentrant and threadsafe + */ + localtime_r(&cnt->currenttime, cnt->currenttime_tm); + +- /* If we have started on a new second we reset the shots variable ++ /* ++ * If we have started on a new second we reset the shots variable + * lastrate is updated to be the number of the last frame. last rate + * is used as the ffmpeg framerate when motion is detected. + */ +@@ -1025,6 +1238,7 @@ static void *motion_loop(void *arg) + cnt->lastrate = cnt->shots + 1; + cnt->shots = -1; + lastframetime = cnt->currenttime; ++ + if (cnt->conf.minimum_frame_time) { + minimum_frame_time_downcounter--; + if (minimum_frame_time_downcounter == 0) +@@ -1041,7 +1255,7 @@ static void *motion_loop(void *arg) + if (cnt->startup_frames > 0) + cnt->startup_frames--; + +- if (get_image){ ++ if (get_image) { + if (cnt->conf.minimum_frame_time) { + minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; + get_image = 0; +@@ -1058,17 +1272,11 @@ static void *motion_loop(void *arg) + } + + /* cnt->current_image points to position in ring where to store image, diffs etc. */ ++ old_image = cnt->current_image; + cnt->current_image = &cnt->imgs.image_ring[cnt->imgs.image_ring_in]; + + /* Init/clear current_image */ +- { +- /* Store time with pre_captured image */ +- cnt->current_image->timestamp = cnt->currenttime; +- localtime_r(&cnt->current_image->timestamp, &cnt->current_image->timestamp_tm); +- +- /* Store shot number with pre_captured image */ +- cnt->current_image->shot = cnt->shots; +- ++ if (cnt->process_thisframe) { + /* set diffs to 0 now, will be written after we calculated diffs in new image */ + cnt->current_image->diffs = 0; + +@@ -1079,31 +1287,52 @@ static void *motion_loop(void *arg) + /* Clear location data */ + memset(&cnt->current_image->location, 0, sizeof(cnt->current_image->location)); + cnt->current_image->total_labels = 0; +- } ++ } else if (cnt->current_image && old_image) { ++ /* not processing this frame: save some important values for next image */ ++ cnt->current_image->diffs = old_image->diffs; ++ cnt->current_image->timestamp = old_image->timestamp; ++ cnt->current_image->timestamp_tm = old_image->timestamp_tm; ++ cnt->current_image->shot = old_image->shot; ++ cnt->current_image->cent_dist = old_image->cent_dist; ++ cnt->current_image->flags = old_image->flags & (~IMAGE_SAVED); ++ cnt->current_image->location = old_image->location; ++ cnt->current_image->total_labels = old_image->total_labels; ++ } ++ ++ /* Store time with pre_captured image */ ++ cnt->current_image->timestamp = cnt->currenttime; ++ localtime_r(&cnt->current_image->timestamp, &cnt->current_image->timestamp_tm); ++ ++ /* Store shot number with pre_captured image */ ++ cnt->current_image->shot = cnt->shots; + + /***** MOTION LOOP - RETRY INITIALIZING SECTION *****/ +- /* If a camera is not available we keep on retrying every 10 seconds ++ /* ++ * If a camera is not available we keep on retrying every 10 seconds + * until it shows up. + */ + if (cnt->video_dev < 0 && + cnt->currenttime % 10 == 0 && cnt->shots == 0) { +- motion_log(LOG_ERR, 0, +- "Retrying until successful connection with camera"); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, ++ "%s: Retrying until successful connection with camera"); + cnt->video_dev = vid_start(cnt); + +- /* if the netcam has different dimensions than in the config file ++ /* ++ * If the netcam has different dimensions than in the config file + * we need to restart Motion to re-allocate all the buffers + */ + if (cnt->imgs.width != cnt->conf.width || cnt->imgs.height != cnt->conf.height) { +- motion_log(LOG_ERR, 0, "Camera has finally become available"); +- motion_log(LOG_ERR, 0, "Camera image has different width and height " +- "from what is in the config file. You should fix that"); +- motion_log(LOG_ERR, 0, "Restarting Motion thread to reinitialize all " +- "image buffers to new picture dimensions"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Camera has finally become available\n" ++ "Camera image has different width and height" ++ "from what is in the config file. You should fix that\n" ++ "Restarting Motion thread to reinitialize all " ++ "image buffers to new picture dimensions"); + cnt->conf.width = cnt->imgs.width; + cnt->conf.height = cnt->imgs.height; +- /* Break out of main loop terminating thread +- * watchdog will start us again */ ++ /* ++ * Break out of main loop terminating thread ++ * watchdog will start us again ++ */ + break; + } + } +@@ -1111,7 +1340,8 @@ static void *motion_loop(void *arg) + + /***** MOTION LOOP - IMAGE CAPTURE SECTION *****/ + +- /* Fetch next frame from camera ++ /* ++ * Fetch next frame from camera + * If vid_next returns 0 all is well and we got a new picture + * Any non zero value is an error. + * 0 = OK, valid picture +@@ -1129,27 +1359,27 @@ static void *motion_loop(void *arg) + cnt->connectionlosttime = 0; + + /* If all is well reset missing_frame_counter */ +- if (cnt->missing_frame_counter >= MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) ++ if (cnt->missing_frame_counter >= MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) { + /* If we previously logged starting a grey image, now log video re-start */ +- motion_log(LOG_ERR, 0, "Video signal re-acquired"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Video signal re-acquired"); + // event for re-acquired video signal can be called here +- +- ++ } + cnt->missing_frame_counter = 0; + + #ifdef HAVE_FFMPEG + /* Deinterlace the image with ffmpeg, before the image is modified. */ + if (cnt->conf.ffmpeg_deinterlace) + ffmpeg_deinterlace(cnt->current_image->image, cnt->imgs.width, cnt->imgs.height); +- + #endif + +- /* save the newly captured still virgin image to a buffer ++ /* ++ * Save the newly captured still virgin image to a buffer + * which we will not alter with text and location graphics + */ + memcpy(cnt->imgs.image_virgin, cnt->current_image->image, cnt->imgs.size); + +- /* If the camera is a netcam we let the camera decide the pace. ++ /* ++ * If the camera is a netcam we let the camera decide the pace. + * Otherwise we will keep on adding duplicate frames. + * By resetting the timer the framerate becomes maximum the rate + * of the Netcam. +@@ -1161,9 +1391,10 @@ static void *motion_loop(void *arg) + // FATAL ERROR - leave the thread by breaking out of the main loop + } else if (vid_return_code < 0) { + /* Fatal error - Close video device */ +- motion_log(LOG_ERR, 0, "Video device fatal error - Closing video device"); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video device fatal error - Closing video device"); + vid_close(cnt); +- /* Use virgin image, if we are not able to open it again next loop ++ /* ++ * Use virgin image, if we are not able to open it again next loop + * a gray image with message is applied + * flag lost_connection + */ +@@ -1178,37 +1409,44 @@ static void *motion_loop(void *arg) + */ + } else { + +- if (debug_level >= CAMERA_VERBOSE) +- motion_log(-1, 0, "vid_return_code %d", vid_return_code); ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: vid_return_code %d", ++ vid_return_code); + +- /* Netcams that change dimensions while Motion is running will ++ /* ++ * Netcams that change dimensions while Motion is running will + * require that Motion restarts to reinitialize all the many + * buffers inside Motion. It will be a mess to try and recover any + * other way + */ + if (vid_return_code == NETCAM_RESTART_ERROR) { +- motion_log(LOG_ERR, 0, "Restarting Motion thread to reinitialize all " +- "image buffers"); +- /* Break out of main loop terminating thread ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Restarting Motion thread to reinitialize all " ++ "image buffers"); ++ /* ++ * Break out of main loop terminating thread + * watchdog will start us again +- * Set lost_connection flag on */ ++ * Set lost_connection flag on ++ */ + + cnt->lost_connection = 1; + break; + } + +- /* First missed frame - store timestamp +- * Don't reset time when thread restarts*/ ++ /* ++ * First missed frame - store timestamp ++ * Don't reset time when thread restarts ++ */ + if (cnt->connectionlosttime == 0) + cnt->connectionlosttime = cnt->currenttime; + +- /* Increase missing_frame_counter ++ /* ++ * Increase missing_frame_counter + * The first MISSING_FRAMES_TIMEOUT seconds we copy previous virgin image + * After MISSING_FRAMES_TIMEOUT seconds we put a grey error image in the buffer + * If we still have not yet received the initial image from a camera + * we go straight for the grey error image. + */ + ++cnt->missing_frame_counter; ++ + if (cnt->video_dev >= 0 && + cnt->missing_frame_counter < (MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit)) { + memcpy(cnt->current_image->image, cnt->imgs.image_virgin, cnt->imgs.size); +@@ -1231,17 +1469,20 @@ static void *motion_loop(void *arg) + + /* Write error message only once */ + if (cnt->missing_frame_counter == MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) { +- motion_log(LOG_ERR, 0, "Video signal lost - Adding grey image"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Video signal lost - Adding grey image"); + // Event for lost video signal can be called from here + event(cnt, EVENT_CAMERA_LOST, NULL, NULL, + NULL, cnt->currenttime_tm); + } + +- /* If we don't get a valid frame for a long time, try to close/reopen device +- * Only try this when a device is open */ ++ /* ++ * If we don't get a valid frame for a long time, try to close/reopen device ++ * Only try this when a device is open ++ */ + if ((cnt->video_dev > 0) && + (cnt->missing_frame_counter == (MISSING_FRAMES_TIMEOUT * 4) * cnt->conf.frame_limit)) { +- motion_log(LOG_ERR, 0, "Video signal still lost - Trying to close video device"); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video signal still lost - " ++ "Trying to close video device"); + vid_close(cnt); + } + } +@@ -1249,95 +1490,99 @@ static void *motion_loop(void *arg) + + /***** MOTION LOOP - MOTION DETECTION SECTION *****/ + +- /* The actual motion detection takes place in the following ++ /* ++ * The actual motion detection takes place in the following + * diffs is the number of pixels detected as changed + * Make a differences picture in image_out + * + * alg_diff_standard is the slower full feature motion detection algorithm + * alg_diff first calls a fast detection algorithm which only looks at a +- * fraction of the pixels. If this detects possible motion alg_diff_standard +- * is called. ++ * fraction of the pixels. If this detects possible motion alg_diff_standard ++ * is called. + */ +- if (cnt->threshold && !cnt->pause) { +- /* if we've already detected motion and we want to see if there's +- * still motion, don't bother trying the fast one first. IF there's +- * motion, the alg_diff will trigger alg_diff_standard +- * anyway +- */ +- if (cnt->detecting_motion || cnt->conf.setup_mode) +- cnt->current_image->diffs = alg_diff_standard(cnt, cnt->imgs.image_virgin); +- else +- cnt->current_image->diffs = alg_diff(cnt, cnt->imgs.image_virgin); ++ if (cnt->process_thisframe) { ++ if (cnt->threshold && !cnt->pause) { ++ /* ++ * If we've already detected motion and we want to see if there's ++ * still motion, don't bother trying the fast one first. IF there's ++ * motion, the alg_diff will trigger alg_diff_standard ++ * anyway ++ */ ++ if (cnt->detecting_motion || cnt->conf.setup_mode) ++ cnt->current_image->diffs = alg_diff_standard(cnt, cnt->imgs.image_virgin); ++ else ++ cnt->current_image->diffs = alg_diff(cnt, cnt->imgs.image_virgin); + +- /* Lightswitch feature - has light intensity changed? +- * This can happen due to change of light conditions or due to a sudden change of the camera +- * sensitivity. If alg_lightswitch detects lightswitch we suspend motion detection the next +- * 5 frames to allow the camera to settle. +- * Don't check if we have lost connection, we detect "Lost signal" frame as lightswitch +- */ +- if (cnt->conf.lightswitch && !cnt->lost_connection) { +- if (alg_lightswitch(cnt, cnt->current_image->diffs)) { +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Lightswitch detected"); ++ /* Lightswitch feature - has light intensity changed? ++ * This can happen due to change of light conditions or due to a sudden change of the camera ++ * sensitivity. If alg_lightswitch detects lightswitch we suspend motion detection the next ++ * 5 frames to allow the camera to settle. ++ * Don't check if we have lost connection, we detect "Lost signal" frame as lightswitch ++ */ ++ if (cnt->conf.lightswitch > 1 && !cnt->lost_connection) { ++ if (alg_lightswitch(cnt, cnt->current_image->diffs)) { ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Lightswitch detected"); + +- if (cnt->moved < 5) +- cnt->moved = 5; ++ if (cnt->moved < 5) ++ cnt->moved = 5; + +- cnt->current_image->diffs = 0; +- alg_update_reference_frame(cnt, RESET_REF_FRAME); ++ cnt->current_image->diffs = 0; ++ alg_update_reference_frame(cnt, RESET_REF_FRAME); ++ } + } +- } + +- /* Switchfilter feature tries to detect a change in the video signal +- * from one camera to the next. This is normally used in the Round +- * Robin feature. The algorithm is not very safe. +- * The algorithm takes a little time so we only call it when needed +- * ie. when feature is enabled and diffs>threshold. +- * We do not suspend motion detection like we did for lightswitch +- * because with Round Robin this is controlled by roundrobin_skip. +- */ +- if (cnt->conf.switchfilter && cnt->current_image->diffs > cnt->threshold) { +- cnt->current_image->diffs = alg_switchfilter(cnt, cnt->current_image->diffs, +- cnt->current_image->image); ++ /* ++ * Switchfilter feature tries to detect a change in the video signal ++ * from one camera to the next. This is normally used in the Round ++ * Robin feature. The algorithm is not very safe. ++ * The algorithm takes a little time so we only call it when needed ++ * ie. when feature is enabled and diffs>threshold. ++ * We do not suspend motion detection like we did for lightswitch ++ * because with Round Robin this is controlled by roundrobin_skip. ++ */ ++ if (cnt->conf.switchfilter && cnt->current_image->diffs > cnt->threshold) { ++ cnt->current_image->diffs = alg_switchfilter(cnt, cnt->current_image->diffs, ++ cnt->current_image->image); + +- if (cnt->current_image->diffs <= cnt->threshold) { +- cnt->current_image->diffs = 0; +- +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Switchfilter detected"); ++ if (cnt->current_image->diffs <= cnt->threshold) { ++ cnt->current_image->diffs = 0; ++ ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Switchfilter detected"); ++ } + } +- } + +- /* Despeckle feature +- * First we run (as given by the despeckle option iterations +- * of erode and dilate algorithms. +- * Finally we run the labelling feature. +- * All this is done in the alg_despeckle code. +- */ +- cnt->current_image->total_labels = 0; +- cnt->imgs.largest_label = 0; +- olddiffs = 0; +- +- if (cnt->conf.despeckle && cnt->current_image->diffs > 0) { +- olddiffs = cnt->current_image->diffs; +- cnt->current_image->diffs = alg_despeckle(cnt, olddiffs); +- } else if (cnt->imgs.labelsize_max) { +- cnt->imgs.labelsize_max = 0; /* Disable labeling if enabled */ +- } ++ /* ++ * Despeckle feature ++ * First we run (as given by the despeckle_filter option iterations ++ * of erode and dilate algorithms. ++ * Finally we run the labelling feature. ++ * All this is done in the alg_despeckle code. ++ */ ++ cnt->current_image->total_labels = 0; ++ cnt->imgs.largest_label = 0; ++ olddiffs = 0; ++ ++ if (cnt->conf.despeckle_filter && cnt->current_image->diffs > 0) { ++ olddiffs = cnt->current_image->diffs; ++ cnt->current_image->diffs = alg_despeckle(cnt, olddiffs); ++ } else if (cnt->imgs.labelsize_max) { ++ cnt->imgs.labelsize_max = 0; /* Disable labeling if enabled */ ++ } + +- } else if (!cnt->conf.setup_mode) { +- cnt->current_image->diffs = 0; ++ } else if (!cnt->conf.setup_mode) { ++ cnt->current_image->diffs = 0; ++ } + } + + /* Manipulate smart_mask sensitivity (only every smartmask_ratio seconds) */ +- if (cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) { +- if (!--smartmask_count) { +- alg_tune_smartmask(cnt); +- smartmask_count = smartmask_ratio; +- } ++ if ((cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) && ++ (!--smartmask_count)) { ++ alg_tune_smartmask(cnt); ++ smartmask_count = smartmask_ratio; + } + +- /* cnt->moved is set by the tracking code when camera has been asked to move. ++ /* ++ * cnt->moved is set by the tracking code when camera has been asked to move. + * When camera is moving we do not want motion to detect motion or we will + * get our camera chasing itself like crazy and we will get motion detected + * which is not really motion. So we pretend there is no motion by setting +@@ -1352,57 +1597,61 @@ static void *motion_loop(void *arg) + + /***** MOTION LOOP - TUNING SECTION *****/ + +- /* if noise tuning was selected, do it now. but only when ++ /* ++ * If noise tuning was selected, do it now. but only when + * no frames have been recorded and only once per second + */ +- if (cnt->conf.noise_tune && cnt->shots == 0) { +- if (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold)) +- alg_noise_tune(cnt, cnt->imgs.image_virgin); +- } ++ if ((cnt->conf.noise_tune && cnt->shots == 0) && ++ (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold))) ++ alg_noise_tune(cnt, cnt->imgs.image_virgin); ++ + +- /* if we are not noise tuning lets make sure that remote controlled ++ /* ++ * If we are not noise tuning lets make sure that remote controlled + * changes of noise_level are used. + */ +- if (!cnt->conf.noise_tune) +- cnt->noise = cnt->conf.noise; ++ if (cnt->process_thisframe) { ++ if (!cnt->conf.noise_tune) ++ cnt->noise = cnt->conf.noise; ++ ++ /* ++ * threshold tuning if enabled ++ * if we are not threshold tuning lets make sure that remote controlled ++ * changes of threshold are used. ++ */ ++ if (cnt->conf.threshold_tune) ++ alg_threshold_tune(cnt, cnt->current_image->diffs, cnt->detecting_motion); ++ else ++ cnt->threshold = cnt->conf.max_changes; + +- /* threshold tuning if enabled +- * if we are not threshold tuning lets make sure that remote controlled +- * changes of threshold are used. +- */ +- if (cnt->conf.threshold_tune) +- alg_threshold_tune(cnt, cnt->current_image->diffs, cnt->detecting_motion); +- else +- cnt->threshold = cnt->conf.max_changes; ++ /* ++ * If motion is detected (cnt->current_image->diffs > cnt->threshold) and before we add text to the pictures ++ * we find the center and size coordinates of the motion to be used for text overlays and later ++ * for adding the locate rectangle ++ */ ++ if (cnt->current_image->diffs > cnt->threshold) ++ alg_locate_center_size(&cnt->imgs, cnt->imgs.width, cnt->imgs.height, &cnt->current_image->location); + +- /* If motion is detected (cnt->current_image->diffs > cnt->threshold) and before we add text to the pictures +- we find the center and size coordinates of the motion to be used for text overlays and later +- for adding the locate rectangle */ +- if (cnt->current_image->diffs > cnt->threshold) +- alg_locate_center_size(&cnt->imgs, cnt->imgs.width, cnt->imgs.height, +- &cnt->current_image->location); +- +- /* Update reference frame. */ +- /* micro-lighswitch: e.g. neighbors cat switched on the motion sensitive * +- * frontdoor illumination. Updates are rate-limited to 3 per second at * +- * framerates above 5fps to save CPU resources and to keep sensitivity * +- * at a constant level. * +- */ +- ref_frame_limit++; +- if (ref_frame_limit >= (cnt->lastrate / 3)) { +- ref_frame_limit = 0; ++ /* ++ * Update reference frame. ++ * micro-lighswitch: trying to auto-detect lightswitch events. ++ * frontdoor illumination. Updates are rate-limited to 3 per second at ++ * framerates above 5fps to save CPU resources and to keep sensitivity ++ * at a constant level. ++ */ + +- if ((cnt->current_image->diffs > cnt->threshold) && +- (cnt->lightswitch_framecounter < (cnt->lastrate * 2)) && /* two seconds window */ ++ if ((cnt->current_image->diffs > cnt->threshold) && (cnt->conf.lightswitch == 1) && ++ (cnt->lightswitch_framecounter < (cnt->lastrate * 2)) && /* two seconds window only */ ++ /* number of changed pixels almost the same in two consecutive frames and */ + ((abs(previous_diffs - cnt->current_image->diffs)) < (previous_diffs / 15)) && ++ /* center of motion in about the same place ? */ + ((abs(cnt->current_image->location.x - previous_location_x)) <= (cnt->imgs.width / 150)) && + ((abs(cnt->current_image->location.y - previous_location_y)) <= (cnt->imgs.height / 150))) { + alg_update_reference_frame(cnt, RESET_REF_FRAME); + cnt->current_image->diffs = 0; + cnt->lightswitch_framecounter = 0; +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "micro-lightswitch!"); + ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: micro-lightswitch!"); + } else { + alg_update_reference_frame(cnt, UPDATE_REF_FRAME); + } +@@ -1414,23 +1663,26 @@ static void *motion_loop(void *arg) + + /***** MOTION LOOP - TEXT AND GRAPHICS OVERLAY SECTION *****/ + +- /* Some overlays on top of the motion image ++ /* ++ * Some overlays on top of the motion image + * Note that these now modifies the cnt->imgs.out so this buffer + * can no longer be used for motion detection features until next + * picture frame is captured. + */ + + /* Smartmask overlay */ +- if (cnt->smartmask_speed && (cnt->conf.motion_img || cnt->conf.ffmpeg_cap_motion || cnt->conf.setup_mode)) ++ if (cnt->smartmask_speed && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || ++ cnt->conf.setup_mode)) + overlay_smartmask(cnt, cnt->imgs.out); + + /* Largest labels overlay */ +- if (cnt->imgs.largest_label && (cnt->conf.motion_img || cnt->conf.ffmpeg_cap_motion || cnt->conf.setup_mode)) ++ if (cnt->imgs.largest_label && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || ++ cnt->conf.setup_mode)) + overlay_largest_label(cnt, cnt->imgs.out); + +- + /* Fixed mask overlay */ +- if (cnt->imgs.mask && (cnt->conf.motion_img || cnt->conf.ffmpeg_cap_motion || cnt->conf.setup_mode)) ++ if (cnt->imgs.mask && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || ++ cnt->conf.setup_mode)) + overlay_fixed_mask(cnt, cnt->imgs.out); + + /* Initialize the double sized characters if needed. */ +@@ -1450,15 +1702,18 @@ static void *motion_loop(void *arg) + else + sprintf(tmp, "-"); + +- draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10, cnt->imgs.width, +- tmp, cnt->conf.text_double); ++ draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10, ++ cnt->imgs.width, tmp, cnt->conf.text_double); + } + +- /* Add changed pixels to motion-images (for webcam) in setup_mode +- and always overlay smartmask (not only when motion is detected) */ ++ /* ++ * Add changed pixels to motion-images (for stream) in setup_mode ++ * and always overlay smartmask (not only when motion is detected) ++ */ + if (cnt->conf.setup_mode) { + char tmp[PATH_MAX]; +- sprintf(tmp, "D:%5d L:%3d N:%3d", cnt->current_image->diffs, cnt->current_image->total_labels, cnt->noise); ++ sprintf(tmp, "D:%5d L:%3d N:%3d", cnt->current_image->diffs, ++ cnt->current_image->total_labels, cnt->noise); + draw_text(cnt->imgs.out, cnt->imgs.width - 10, cnt->imgs.height - 30 * text_size_factor, + cnt->imgs.width, tmp, cnt->conf.text_double); + sprintf(tmp, "THREAD %d SETUP", cnt->threadnr); +@@ -1469,16 +1724,19 @@ static void *motion_loop(void *arg) + /* Add text in lower left corner of the pictures */ + if (cnt->conf.text_left) { + char tmp[PATH_MAX]; +- mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left, &cnt->current_image->timestamp_tm, NULL, 0); +- draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 * text_size_factor, cnt->imgs.width, +- tmp, cnt->conf.text_double); ++ mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left, ++ &cnt->current_image->timestamp_tm, NULL, 0); ++ draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 * text_size_factor, ++ cnt->imgs.width, tmp, cnt->conf.text_double); + } + + /* Add text in lower right corner of the pictures */ + if (cnt->conf.text_right) { + char tmp[PATH_MAX]; +- mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right, &cnt->current_image->timestamp_tm, NULL, 0); +- draw_text(cnt->current_image->image, cnt->imgs.width - 10, cnt->imgs.height - 10 * text_size_factor, ++ mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right, ++ &cnt->current_image->timestamp_tm, NULL, 0); ++ draw_text(cnt->current_image->image, cnt->imgs.width - 10, ++ cnt->imgs.height - 10 * text_size_factor, + cnt->imgs.width, tmp, cnt->conf.text_double); + } + +@@ -1489,24 +1747,36 @@ static void *motion_loop(void *arg) + /* flag this image, it have motion */ + cnt->current_image->flags |= IMAGE_MOTION; + cnt->lightswitch_framecounter++; /* micro lightswitch */ +- } else { ++ } else { + cnt->lightswitch_framecounter = 0; + } + +- /* If motion has been detected we take action and start saving ++ /* ++ * If motion has been detected we take action and start saving + * pictures and movies etc by calling motion_detected(). +- * Is output_all enabled we always call motion_detected() ++ * Is emulate_motion enabled we always call motion_detected() + * If post_capture is enabled we also take care of this in the this + * code section. + */ +- if (cnt->conf.output_all && (cnt->startup_frames == 0)) { ++ if (cnt->conf.emulate_motion && (cnt->startup_frames == 0)) { + cnt->detecting_motion = 1; +- /* Setup the postcap counter */ +- cnt->postcap = cnt->conf.post_capture; ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Emulating motion"); ++#ifdef HAVE_FFMPEG ++ if (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe)) { ++#else ++ if (cnt->conf.useextpipe && cnt->extpipe) { ++#endif ++ /* Setup the postcap counter */ ++ cnt->postcap = cnt->conf.post_capture; ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: (Em) Init post capture %d", ++ 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)) { +- /* Did we detect motion (like the cat just walked in :) )? ++ /* ++ * Did we detect motion (like the cat just walked in :) )? + * If so, ensure the motion is sustained if minimum_motion_frames + */ + +@@ -1514,7 +1784,8 @@ static void *motion_loop(void *arg) + int frame_count = 0; + int pos = cnt->imgs.image_ring_in; + +- for(i = 0; i < cnt->conf.minimum_motion_frames; i++) { ++ for (i = 0; i < cnt->conf.minimum_motion_frames; i++) { ++ + if (cnt->imgs.image_ring[pos].flags & IMAGE_MOTION) + frame_count++; + +@@ -1522,34 +1793,56 @@ static void *motion_loop(void *arg) + pos = cnt->imgs.image_ring_size-1; + else + pos--; +- + } + + 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; ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Setup post capture %d", ++ cnt->postcap); ++ + /* Mark all images in image_ring to be saved */ +- for(i = 0; i < cnt->imgs.image_ring_size; i++) ++ 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) && ++#ifdef HAVE_FFMPEG ++ (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { ++#else ++ (cnt->conf.useextpipe && cnt->extpipe)) { ++#endif ++ /* we have motion in this frame, but not enought frames for trigger. Check postcap */ + cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); + cnt->postcap--; ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", ++ 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) && ++#ifdef HAVE_FFMPEG ++ (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { ++#else ++ (cnt->conf.useextpipe && cnt->extpipe)) { ++#endif + /* No motion, doing postcap */ + cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); + cnt->postcap--; ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", ++ cnt->postcap); + } else { + /* Done with postcap, so just have the image in the precap buffer */ + cnt->current_image->flags |= IMAGE_PRECAP; ++ /* gapless movie feature */ ++ if ((cnt->conf.event_gap == 0) && (cnt->detecting_motion == 1)) ++ cnt->makemovie = 1; + cnt->detecting_motion = 0; + } + +@@ -1558,16 +1851,16 @@ static void *motion_loop(void *arg) + cnt->lasttime = cnt->current_image->timestamp; + + +- /* Simple hack to recognize motion in a specific area */ +- /* Do we need a new coversion specifier as well?? */ ++ /* ++ * Simple hack to recognize motion in a specific area ++ * Do we need a new coversion specifier as well?? ++ */ + if ((cnt->conf.area_detect) && (cnt->event_nr != area_once) && + (cnt->current_image->flags & IMAGE_TRIGGER)) { +- + j = strlen(cnt->conf.area_detect); +- ++ + for (i = 0; i < j; i++) { + z = cnt->conf.area_detect[i] - 49; /* 1 becomes 0 */ +- + if ((z >= 0) && (z < 9)) { + if (cnt->current_image->location.x > area_minx[z] && + cnt->current_image->location.x < area_maxx[z] && +@@ -1576,27 +1869,29 @@ static void *motion_loop(void *arg) + event(cnt, EVENT_AREA_DETECTED, NULL, NULL, + NULL, cnt->currenttime_tm); + area_once = cnt->event_nr; /* Fire script only once per event */ +- +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Motion in area %d detected.\n", z+1); + ++ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Motion in area %d detected.", ++ z + 1); + break; + } + } + } + } + +- /* Is the mpeg movie to long? Then make movies +- * First test for max mpegtime +- */ +- if (cnt->conf.maxmpegtime && cnt->event_nr == cnt->prev_event) +- if (cnt->currenttime - cnt->eventtime >= cnt->conf.maxmpegtime) +- cnt->makemovie = 1; ++ /* ++ * Is the movie too long? Then make movies ++ * First test for max_movie_time ++ */ ++ if ((cnt->conf.max_movie_time && cnt->event_nr == cnt->prev_event) && ++ (cnt->currenttime - cnt->eventtime >= cnt->conf.max_movie_time)) ++ cnt->makemovie = 1; + +- /* Now test for quiet longer than 'gap' OR make movie as decided in ++ /* ++ * Now test for quiet longer than 'gap' OR make movie as decided in + * previous statement. + */ +- if (((cnt->currenttime - cnt->lasttime >= cnt->conf.gap) && cnt->conf.gap > 0) || cnt->makemovie) { ++ if (((cnt->currenttime - cnt->lasttime >= cnt->conf.event_gap) && cnt->conf.event_gap > 0) || ++ cnt->makemovie) { + if (cnt->event_nr == cnt->prev_event || cnt->makemovie) { + + /* Flush image buffer */ +@@ -1610,14 +1905,15 @@ static void *motion_loop(void *arg) + + event(cnt, EVENT_ENDMOTION, NULL, NULL, NULL, cnt->currenttime_tm); + +- /* if tracking is enabled we center our camera so it does not ++ /* ++ * If tracking is enabled we center our camera so it does not + * point to a place where it will miss the next action + */ + if (cnt->track.type) + cnt->moved = track_center(cnt, cnt->video_dev, 0, 0, 0); + +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "End of event %d", cnt->event_nr); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: End of event %d", ++ cnt->event_nr); + + cnt->makemovie = 0; + /* Reset post capture */ +@@ -1627,7 +1923,8 @@ static void *motion_loop(void *arg) + cnt->event_nr++; + cnt->lightswitch_framecounter = 0; + +- /* And we unset the text_event_string to avoid that buffered ++ /* ++ * And we unset the text_event_string to avoid that buffered + * images get a timestamp from previous event. + */ + cnt->text_event_string[0] = '\0'; +@@ -1639,17 +1936,16 @@ static void *motion_loop(void *arg) + + /***** MOTION LOOP - SETUP MODE CONSOLE OUTPUT SECTION *****/ + +- /* If setup_mode enabled output some numbers to console */ ++ /* If CAMERA_VERBOSE enabled output some numbers to console */ + if (cnt->conf.setup_mode) { + char msg[1024] = "\0"; + char part[100]; + +- if (cnt->conf.despeckle) { ++ if (cnt->conf.despeckle_filter) { + snprintf(part, 99, "Raw changes: %5d - changes after '%s': %5d", +- olddiffs, cnt->conf.despeckle, cnt->current_image->diffs); ++ olddiffs, cnt->conf.despeckle_filter, cnt->current_image->diffs); + strcat(msg, part); +- +- if (strchr(cnt->conf.despeckle, 'l')){ ++ if (strchr(cnt->conf.despeckle_filter, 'l')) { + sprintf(part, " - labels: %3d", cnt->current_image->total_labels); + strcat(msg, part); + } +@@ -1668,14 +1964,15 @@ static void *motion_loop(void *arg) + strcat(msg, part); + } + +- motion_log(-1, 0, "%s", msg); ++ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: %s", msg); + } + + } /* get_image end */ + + /***** MOTION LOOP - SNAPSHOT FEATURE SECTION *****/ + +- /* Did we get triggered to make a snapshot from control http? Then shoot a snap ++ /* ++ * Did we get triggered to make a snapshot from control http? Then shoot a snap + * If snapshot_interval is not zero and time since epoch MOD snapshot_interval = 0 then snap + * We actually allow the time to run over the interval in case we have a delay + * from slow camera. +@@ -1687,10 +1984,9 @@ static void *motion_loop(void *arg) + time_current_frame = cnt->currenttime; + + if ((cnt->conf.snapshot_interval > 0 && cnt->shots == 0 && +- time_current_frame % cnt->conf.snapshot_interval <= time_last_frame % cnt->conf.snapshot_interval) || +- cnt->snapshot) { +- event(cnt, EVENT_IMAGE_SNAPSHOT, cnt->current_image->image, NULL, NULL, +- &cnt->current_image->timestamp_tm); ++ time_current_frame % cnt->conf.snapshot_interval <= time_last_frame % cnt->conf.snapshot_interval) || ++ cnt->snapshot) { ++ event(cnt, EVENT_IMAGE_SNAPSHOT, cnt->current_image->image, NULL, NULL, &cnt->current_image->timestamp_tm); + cnt->snapshot = 0; + } + +@@ -1699,11 +1995,10 @@ static void *motion_loop(void *arg) + + #ifdef HAVE_FFMPEG + +- +- + if (cnt->conf.timelapse) { + +- /* Check to see if we should start a new timelapse file. We start one when ++ /* ++ * Check to see if we should start a new timelapse file. We start one when + * we are on the first shot, and and the seconds are zero. We must use the seconds + * to prevent the timelapse file from getting reset multiple times during the minute. + */ +@@ -1711,53 +2006,56 @@ static void *motion_loop(void *arg) + (time_current_frame % 60 < time_last_frame % 60) && + cnt->shots == 0) { + +- if (strcasecmp(cnt->conf.timelapse_mode,"manual") == 0) { ++ if (strcasecmp(cnt->conf.timelapse_mode, "manual") == 0) { + ;/* No action */ + + /* If we are daily, raise timelapseend event at midnight */ + } else if (strcasecmp(cnt->conf.timelapse_mode, "daily") == 0) { + if (cnt->current_image->timestamp_tm.tm_hour == 0) +- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, +- &cnt->current_image->timestamp_tm); ++ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); + + /* handle the hourly case */ + } else if (strcasecmp(cnt->conf.timelapse_mode, "hourly") == 0) { +- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, +- &cnt->current_image->timestamp_tm); +- +- /* If we are weekly-sunday, raise timelapseend event at midnight on sunday */ ++ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); ++ ++ /* If we are weekly-sunday, raise timelapseend event at midnight on sunday */ + } else if (strcasecmp(cnt->conf.timelapse_mode, "weekly-sunday") == 0) { +- if (cnt->current_image->timestamp_tm.tm_wday == 0 && cnt->current_image->timestamp_tm.tm_hour == 0) +- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); +- ++ if (cnt->current_image->timestamp_tm.tm_wday == 0 && ++ cnt->current_image->timestamp_tm.tm_hour == 0) ++ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, ++ &cnt->current_image->timestamp_tm); + /* If we are weekly-monday, raise timelapseend event at midnight on monday */ + } else if (strcasecmp(cnt->conf.timelapse_mode, "weekly-monday") == 0) { +- if (cnt->current_image->timestamp_tm.tm_wday == 1 && cnt->current_image->timestamp_tm.tm_hour == 0) +- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); +- ++ if (cnt->current_image->timestamp_tm.tm_wday == 1 && ++ cnt->current_image->timestamp_tm.tm_hour == 0) ++ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, ++ &cnt->current_image->timestamp_tm); + /* If we are monthly, raise timelapseend event at midnight on first day of month */ + } else if (strcasecmp(cnt->conf.timelapse_mode, "monthly") == 0) { +- if (cnt->current_image->timestamp_tm.tm_mday == 1 && cnt->current_image->timestamp_tm.tm_hour == 0) +- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); +- ++ if (cnt->current_image->timestamp_tm.tm_mday == 1 && ++ cnt->current_image->timestamp_tm.tm_hour == 0) ++ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, ++ &cnt->current_image->timestamp_tm); + /* If invalid we report in syslog once and continue in manual mode */ + } else { +- motion_log(LOG_ERR, 0, "Invalid timelapse_mode argument '%s'", ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Invalid timelapse_mode argument '%s'", + cnt->conf.timelapse_mode); +- motion_log(LOG_ERR, 0, "Defaulting to manual timelapse mode"); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%:s Defaulting to manual timelapse mode"); + conf_cmdparse(&cnt, (char *)"ffmpeg_timelapse_mode",(char *)"manual"); + } + } + +- /* If ffmpeg timelapse is enabled and time since epoch MOD ffmpeg_timelaps = 0 +- * add a timelapse frame to the timelapse mpeg. ++ /* ++ * If ffmpeg timelapse is enabled and time since epoch MOD ffmpeg_timelaps = 0 ++ * add a timelapse frame to the timelapse movie. + */ +- if (cnt->shots == 0 && +- time_current_frame % cnt->conf.timelapse <= time_last_frame % cnt->conf.timelapse) ++ if (cnt->shots == 0 && time_current_frame % cnt->conf.timelapse <= ++ time_last_frame % cnt->conf.timelapse) + event(cnt, EVENT_TIMELAPSE, cnt->current_image->image, NULL, NULL, + &cnt->current_image->timestamp_tm); + } else if (cnt->ffmpeg_timelapse) { +- /* if timelapse mpeg is in progress but conf.timelapse is zero then close timelapse file ++ /* ++ * If timelapse movie is in progress but conf.timelapse is zero then close timelapse file + * This is an important feature that allows manual roll-over of timelapse file using the http + * remote control via a cron job. + */ +@@ -1771,25 +2069,35 @@ static void *motion_loop(void *arg) + + /***** MOTION LOOP - VIDEO LOOPBACK SECTION *****/ + +- /* feed last image and motion image to video device pipes and the webcam clients +- * In setup mode we send the special setup mode image to both webcam and vloopback pipe ++ /* ++ * Feed last image and motion image to video device pipes and the stream clients ++ * In setup mode we send the special setup mode image to both stream and vloopback pipe + * In normal mode we feed the latest image to vloopback device and we send +- * the image to the webcam. We always send the first image in a second to the webcam. +- * Other image are sent only when the config option webcam_motion is off +- * The result is that with webcam_motion on the webcam stream is normally at the minimal ++ * the image to the stream. We always send the first image in a second to the stream. ++ * Other image are sent only when the config option stream_motion is off ++ * The result is that with stream_motion on the stream stream is normally at the minimal + * 1 frame per second but the minute motion is detected the motion_detected() function +- * sends all detected pictures to the webcam except the 1st per second which is already sent. ++ * sends all detected pictures to the stream except the 1st per second which is already sent. + */ + if (cnt->conf.setup_mode) { + event(cnt, EVENT_IMAGE, cnt->imgs.out, NULL, &cnt->pipe, cnt->currenttime_tm); +- event(cnt, EVENT_WEBCAM, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); ++ event(cnt, EVENT_STREAM, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); ++#ifdef HAVE_SDL ++ if (cnt_list[0]->conf.sdl_threadnr == cnt->threadnr) ++ event(cnt, EVENT_SDL_PUT, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); ++#endif + } else { +- event(cnt, EVENT_IMAGE, cnt->current_image->image, NULL, &cnt->pipe, +- &cnt->current_image->timestamp_tm); ++ event(cnt, EVENT_IMAGE, cnt->current_image->image, NULL, ++ &cnt->pipe, &cnt->current_image->timestamp_tm); + +- if (!cnt->conf.webcam_motion || cnt->shots == 1) +- event(cnt, EVENT_WEBCAM, cnt->current_image->image, NULL, NULL, ++ if (!cnt->conf.stream_motion || cnt->shots == 1) ++ event(cnt, EVENT_STREAM, cnt->current_image->image, NULL, NULL, ++ &cnt->current_image->timestamp_tm); ++#ifdef HAVE_SDL ++ if (cnt_list[0]->conf.sdl_threadnr == cnt->threadnr) ++ event(cnt, EVENT_SDL_PUT, cnt->current_image->image, NULL, NULL, + &cnt->current_image->timestamp_tm); ++#endif + } + + event(cnt, EVENT_IMAGEM, cnt->imgs.out, NULL, &cnt->mpipe, cnt->currenttime_tm); +@@ -1798,52 +2106,69 @@ static void *motion_loop(void *arg) + /***** MOTION LOOP - ONCE PER SECOND PARAMETER UPDATE SECTION *****/ + + /* Check for some config parameter changes but only every second */ +- if (cnt->shots == 0){ +- if (strcasecmp(cnt->conf.output_normal, "on") == 0) ++ if (cnt->shots == 0) { ++ if (strcasecmp(cnt->conf.output_pictures, "on") == 0) + cnt->new_img = NEWIMG_ON; +- else if (strcasecmp(cnt->conf.output_normal, "first") == 0) ++ else if (strcasecmp(cnt->conf.output_pictures, "first") == 0) + cnt->new_img = NEWIMG_FIRST; +- else if (strcasecmp(cnt->conf.output_normal, "best") == 0) ++ else if (strcasecmp(cnt->conf.output_pictures, "best") == 0) + cnt->new_img = NEWIMG_BEST; +- else if (strcasecmp(cnt->conf.output_normal, "center") == 0) ++ else if (strcasecmp(cnt->conf.output_pictures, "center") == 0) + cnt->new_img = NEWIMG_CENTER; + else + cnt->new_img = NEWIMG_OFF; + +- if (strcasecmp(cnt->conf.locate, "on") == 0) +- cnt->locate = LOCATE_ON; +- else if (strcasecmp(cnt->conf.locate, "preview") == 0) +- cnt->locate = LOCATE_PREVIEW; ++ if (strcasecmp(cnt->conf.locate_motion_mode, "on") == 0) ++ cnt->locate_motion_mode = LOCATE_ON; ++ else if (strcasecmp(cnt->conf.locate_motion_mode, "preview") == 0) ++ cnt->locate_motion_mode = LOCATE_PREVIEW; + else +- cnt->locate = LOCATE_OFF; ++ cnt->locate_motion_mode = LOCATE_OFF; ++ ++ if (strcasecmp(cnt->conf.locate_motion_style, "box") == 0) ++ cnt->locate_motion_style = LOCATE_BOX; ++ else if (strcasecmp(cnt->conf.locate_motion_style, "redbox") == 0) ++ cnt->locate_motion_style = LOCATE_REDBOX; ++ else if (strcasecmp(cnt->conf.locate_motion_style, "cross") == 0) ++ cnt->locate_motion_style = LOCATE_CROSS; ++ else if (strcasecmp(cnt->conf.locate_motion_style, "redcross") == 0) ++ cnt->locate_motion_style = LOCATE_REDCROSS; ++ else ++ cnt->locate_motion_style = LOCATE_BOX; + + /* Sanity check for smart_mask_speed, silly value disables smart mask */ + if (cnt->conf.smart_mask_speed < 0 || cnt->conf.smart_mask_speed > 10) + cnt->conf.smart_mask_speed = 0; + + /* Has someone changed smart_mask_speed or framerate? */ +- if (cnt->conf.smart_mask_speed != cnt->smartmask_speed || smartmask_lastrate != cnt->lastrate){ +- if (cnt->conf.smart_mask_speed == 0){ ++ if (cnt->conf.smart_mask_speed != cnt->smartmask_speed || ++ smartmask_lastrate != cnt->lastrate) { ++ if (cnt->conf.smart_mask_speed == 0) { + memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); + memset(cnt->imgs.smartmask_final, 255, cnt->imgs.motionsize); + } ++ + smartmask_lastrate = cnt->lastrate; + cnt->smartmask_speed = cnt->conf.smart_mask_speed; +- /* Decay delay - based on smart_mask_speed (framerate independent) +- This is always 5*smartmask_speed seconds */ ++ /* ++ * Decay delay - based on smart_mask_speed (framerate independent) ++ * This is always 5*smartmask_speed seconds ++ */ + smartmask_ratio = 5 * cnt->lastrate * (11 - cnt->smartmask_speed); + } + +-#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) +- /* Set the sql mask file according to the SQL config options ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) ++ ++ /* ++ * Set the sql mask file according to the SQL config options + * We update it for every frame in case the config was updated + * via remote control. + */ + cnt->sql_mask = cnt->conf.sql_log_image * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + + cnt->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + +- cnt->conf.sql_log_mpeg * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + ++ cnt->conf.sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + + cnt->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; +-#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) */ ++#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ + + } + +@@ -1851,8 +2176,10 @@ static void *motion_loop(void *arg) + /***** MOTION LOOP - FRAMERATE TIMING AND SLEEPING SECTION *****/ + + +- /* Work out expected frame rate based on config setting which may +- have changed from http-control */ ++ /* ++ * Work out expected frame rate based on config setting which may ++ * have changed from http-control ++ */ + if (cnt->conf.frame_limit) + required_frame_time = 1000000L / cnt->conf.frame_limit; + else +@@ -1862,8 +2189,9 @@ static void *motion_loop(void *arg) + gettimeofday(&tv2, NULL); + elapsedtime = (tv2.tv_usec + 1000000L * tv2.tv_sec) - timenow; + +- /* Update history buffer but ignore first pass as timebefore +- variable will be inaccurate ++ /* ++ * Update history buffer but ignore first pass as timebefore ++ * variable will be inaccurate + */ + if (passflag) + rolling_average_data[rolling_frame] = timenow-timebefore; +@@ -1899,7 +2227,8 @@ static void *motion_loop(void *arg) + } + } + +- /* END OF MOTION MAIN LOOP ++ /* ++ * END OF MOTION MAIN LOOP + * If code continues here it is because the thread is exiting or restarting + */ + err: +@@ -1907,7 +2236,7 @@ err: + free(rolling_average_data); + + cnt->lost_connection = 1; +- motion_log(-1, 0, "Thread exiting"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread exiting"); + + motion_cleanup(cnt); + +@@ -1916,7 +2245,7 @@ err: + pthread_mutex_unlock(&global_lock); + + if (!cnt->restart) +- cnt->watchdog=WATCHDOG_OFF; ++ cnt->watchdog = WATCHDOG_OFF; + + cnt->running = 0; + cnt->finish = 0; +@@ -1956,33 +2285,38 @@ static void become_daemon(void) + + /* fork */ + if (fork()) { +- motion_log(-1, 0, "Motion going to daemon mode"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion going to daemon mode"); + exit(0); + } + +- /* Create the pid file if defined, if failed exit ++ /* ++ * Create the pid file if defined, if failed exit + * If we fail we report it. If we succeed we postpone the log entry till + * later when we have closed stdout. Otherwise Motion hangs in the terminal waiting + * for an enter. + */ + if (cnt_list[0]->conf.pid_file) { +- pidf = fopen(cnt_list[0]->conf.pid_file, "w+"); ++ pidf = myfopen(cnt_list[0]->conf.pid_file, "w+", 0); + +- if (pidf ) { ++ if (pidf) { + (void)fprintf(pidf, "%d\n", getpid()); +- fclose(pidf); ++ myfclose(pidf); + } else { +- motion_log(LOG_ERR, 1, "Exit motion, cannot create process id file (pid file) %s", +- cnt_list[0]->conf.pid_file); ++ MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Exit motion, cannot create process" ++ " id file (pid file) %s", cnt_list[0]->conf.pid_file); ++ if (ptr_logfile) ++ myfclose(ptr_logfile); + exit(0); + } + } + +- /* changing dir to root enables people to unmount a disk +- without having to stop Motion */ +- if (chdir("/")) { +- motion_log(LOG_ERR, 1, "Could not change directory"); +- } ++ /* ++ * Changing dir to root enables people to unmount a disk ++ * without having to stop Motion ++ */ ++ if (chdir("/")) ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not change directory"); ++ + + #if (defined(BSD)) + setpgrp(0, getpid()); +@@ -2013,8 +2347,8 @@ static void become_daemon(void) + } + + /* Now it is safe to add the PID creation to the logs */ +- if (pidf ) +- motion_log(LOG_INFO, 0, "Created process id file %s. Process ID is %d", ++ if (pidf) ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Created process id file %s. Process ID is %d", + cnt_list[0]->conf.pid_file, getpid()); + + sigaction(SIGTTOU, &sig_ign_action, NULL); +@@ -2037,7 +2371,8 @@ static void become_daemon(void) + */ + static void cntlist_create(int argc, char *argv[]) + { +- /* cnt_list is an array of pointers to the context structures cnt for each thread. ++ /* ++ * cnt_list is an array of pointers to the context structures cnt for each thread. + * First we reserve room for a pointer to thread 0's context structure + * and a NULL pointer which indicates that end of the array of pointers to + * thread context structures. +@@ -2053,7 +2388,8 @@ static void cntlist_create(int argc, cha + /* cnt_list[1] pointing to zero indicates no more thread context structures - they get added later */ + cnt_list[1] = NULL; + +- /* Command line arguments are being pointed to from cnt_list[0] and we call conf_load which loads ++ /* ++ * Command line arguments are being pointed to from cnt_list[0] and we call conf_load which loads + * the config options from motion.conf, thread config files and the command line. + */ + cnt_list[0]->conf.argv = argv; +@@ -2078,8 +2414,8 @@ static void motion_shutdown(void) + int i = -1; + + motion_remove_pid(); +- +- while (cnt_list[++i]) ++ ++ while (cnt_list[++i]) + context_destroy(cnt_list[i]); + + free(cnt_list); +@@ -2109,22 +2445,72 @@ static void motion_startup(int daemonize + /* Initialize our global mutex */ + pthread_mutex_init(&global_lock, NULL); + +- /* Create the list of context structures and load the ++ /* ++ * Create the list of context structures and load the + * configuration. + */ + cntlist_create(argc, argv); + +- motion_log(LOG_INFO, 0, "Motion "VERSION" Started"); ++ if ((cnt_list[0]->conf.log_level > ALL) || ++ (cnt_list[0]->conf.log_level == 0)) { ++ cnt_list[0]->conf.log_level = LEVEL_DEFAULT; ++ cnt_list[0]->log_level = cnt_list[0]->conf.log_level; ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log level (%s) (%d)", ++ get_log_level_str(cnt_list[0]->log_level), SHOW_LEVEL_VALUE(cnt_list[0]->log_level)); ++ } else { ++ cnt_list[0]->log_level = cnt_list[0]->conf.log_level - 1; // Let's make syslog compatible ++ } ++ ++ //set_log_level(cnt_list[0]->log_level); ++ ++#ifdef HAVE_SDL ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion "VERSION" Started with SDL support"); ++#else ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion "VERSION" Started"); ++#endif ++ ++ if ((cnt_list[0]->conf.log_file) && (strncmp(cnt_list[0]->conf.log_file, "syslog", 6))) { ++ set_log_mode(LOGMODE_FILE); ++ ptr_logfile = set_logfile(cnt_list[0]->conf.log_file); ++ ++ if (ptr_logfile) { ++ set_log_mode(LOGMODE_SYSLOG); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to file (%s)", ++ cnt_list[0]->conf.log_file); ++ set_log_mode(LOGMODE_FILE); ++ } else { ++ MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Exit motion, cannot create log file %s", ++ cnt_list[0]->conf.log_file); ++ exit(0); ++ } ++ } else { ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to syslog"); ++ } ++ ++ if ((cnt_list[0]->conf.log_type_str == NULL) || ++ !(cnt_list[0]->log_type = get_log_type(cnt_list[0]->conf.log_type_str))) { ++ cnt_list[0]->log_type = TYPE_DEFAULT; ++ cnt_list[0]->conf.log_type_str = mystrcpy(cnt_list[0]->conf.log_type_str, "ALL"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log type (%s)", ++ get_log_type_str(cnt_list[0]->log_type)); ++ } ++ ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using log type (%s) log level (%s)", ++ get_log_type_str(cnt_list[0]->log_type), get_log_level_str(cnt_list[0]->log_level)); ++ ++ set_log_level(cnt_list[0]->log_level); ++ set_log_type(cnt_list[0]->log_type); + + initialize_chars(); + + if (daemonize) { +- /* If daemon mode is requested, and we're not going into setup mode, ++ /* ++ * If daemon mode is requested, and we're not going into setup mode, + * become daemon. + */ + if (cnt_list[0]->daemon && cnt_list[0]->conf.setup_mode == 0) { + become_daemon(); +- motion_log(LOG_INFO, 0, "Motion running as daemon process"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion running as daemon process"); + } + } + +@@ -2163,8 +2549,8 @@ static void setup_signals(struct sigacti + sigaction(SIGCHLD, sigchild_action, NULL); + sigaction(SIGPIPE, sigchild_action, NULL); + sigaction(SIGALRM, sig_handler_action, NULL); +- sigaction(SIGHUP, sig_handler_action, NULL); +- sigaction(SIGINT, sig_handler_action, NULL); ++ sigaction(SIGHUP, sig_handler_action, NULL); ++ sigaction(SIGINT, sig_handler_action, NULL); + sigaction(SIGQUIT, sig_handler_action, NULL); + sigaction(SIGTERM, sig_handler_action, NULL); + sigaction(SIGUSR1, sig_handler_action, NULL); +@@ -2186,40 +2572,44 @@ static void start_motion_thread(struct c + { + int i; + +- /* Check the webcam port number for conflicts. ++ /* ++ * Check the stream port number for conflicts. + * First we check for conflict with the control port. + * Second we check for that two threads does not use the same port number +- * for the webcam. If a duplicate port is found the webcam feature gets disabled (port =0) ++ * for the stream. If a duplicate port is found the stream feature gets disabled (port = 0) + * for this thread and a warning is written to console and syslog. + */ + +- if (cnt->conf.webcam_port != 0) { ++ if (cnt->conf.stream_port != 0) { + /* Compare against the control port. */ +- if (cnt_list[0]->conf.control_port == cnt->conf.webcam_port) { +- motion_log(LOG_ERR, 0, +- "Webcam port number %d for thread %d conflicts with the control port", +- cnt->conf.webcam_port, cnt->threadnr); +- motion_log(LOG_ERR, 0, "Webcam feature for thread %d is disabled.", cnt->threadnr); +- cnt->conf.webcam_port = 0; ++ if (cnt_list[0]->conf.webcontrol_port == cnt->conf.stream_port) { ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, ++ "%s: Stream port number %d for thread %d conflicts with the control port", ++ cnt->conf.stream_port, cnt->threadnr); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Stream feature for thread %d is disabled.", ++ cnt->threadnr); ++ cnt->conf.stream_port = 0; + } + +- /* Compare against webcam ports of other threads. */ ++ /* Compare against stream ports of other threads. */ + for (i = 1; cnt_list[i]; i++) { + if (cnt_list[i] == cnt) + continue; + +- if (cnt_list[i]->conf.webcam_port == cnt->conf.webcam_port) { +- motion_log(LOG_ERR, 0, +- "Webcam port number %d for thread %d conflicts with thread %d", +- cnt->conf.webcam_port, cnt->threadnr, cnt_list[i]->threadnr); +- motion_log(LOG_ERR, 0, +- "Webcam feature for thread %d is disabled.", cnt->threadnr); +- cnt->conf.webcam_port = 0; ++ if (cnt_list[i]->conf.stream_port == cnt->conf.stream_port) { ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, ++ "%s: Stream port number %d for thread %d conflicts with thread %d", ++ cnt->conf.stream_port, cnt->threadnr, cnt_list[i]->threadnr); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, ++ "%s: Stream feature for thread %d is disabled.", ++ cnt->threadnr); ++ cnt->conf.stream_port = 0; + } + } + } + +- /* Update how many threads we have running. This is done within a ++ /* ++ * Update how many threads we have running. This is done within a + * mutex lock to prevent multiple simultaneous updates to + * 'threads_running'. + */ +@@ -2230,10 +2620,11 @@ static void start_motion_thread(struct c + /* Set a flag that we want this thread running */ + cnt->restart = 1; + +- /* Give the thread WATCHDOG_TMO seconds to start */ ++ /* Give the thread WATCHDOG_TMO to start */ + cnt->watchdog = WATCHDOG_TMO; + +- /* Create the actual thread. Use 'motion_loop' as the thread ++ /* ++ * Create the actual thread. Use 'motion_loop' as the thread + * function. + */ + pthread_create(&cnt->thread_id, thread_attr, &motion_loop, cnt); +@@ -2258,7 +2649,8 @@ int main (int argc, char **argv) + pthread_attr_t thread_attr; + pthread_t thread_id; + +- /* Setup signals and do some initialization. 1 in the call to ++ /* ++ * Setup signals and do some initialization. 1 in the call to + * 'motion_startup' means that Motion will become a daemon if so has been + * requested, and argc and argc are necessary for reading the command + * line options. +@@ -2270,20 +2662,23 @@ int main (int argc, char **argv) + motion_startup(1, argc, argv); + + #ifdef HAVE_FFMPEG +- /* FFMpeg initialization is only performed if FFMpeg support was found ++ /* ++ * FFMpeg initialization is only performed if FFMpeg support was found + * and not disabled during the configure phase. + */ + ffmpeg_init(); + #endif /* HAVE_FFMPEG */ + +- /* In setup mode, Motion is very communicative towards the user, which ++ /* ++ * In setup mode, Motion is very communicative towards the user, which + * allows the user to experiment with the config parameters in order to + * optimize motion detection and stuff. + */ + if (cnt_list[0]->conf.setup_mode) +- motion_log(-1, 0, "Motion running in setup mode."); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion running in setup mode."); + +- /* Create and a thread attribute for the threads we spawn later on. ++ /* ++ * Create and a thread attribute for the threads we spawn later on. + * PTHREAD_CREATE_DETACHED means to create threads detached, i.e. + * their termination cannot be synchronized through 'pthread_join'. + */ +@@ -2295,92 +2690,109 @@ int main (int argc, char **argv) + + do { + if (restart) { +- /* Handle the restart situation. Currently the approach is to ++ /* ++ * Handle the restart situation. Currently the approach is to + * cleanup everything, and then initialize everything again + * (including re-reading the config file(s)). + */ ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Restarting motion."); + motion_shutdown(); + restart = 0; /* only one reset for now */ +- motion_log(LOG_INFO,0,"motion restarted"); + #ifndef WITHOUT_V4L +- SLEEP(5,0); // maybe some cameras needs less time ++ SLEEP(5, 0); // maybe some cameras needs less time + #endif + motion_startup(0, argc, argv); /* 0 = skip daemon init */ ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Motion restarted"); + } + +- +- /* Start the motion threads. First 'cnt_list' item is global if 'thread' ++ /* ++ * Start the motion threads. First 'cnt_list' item is global if 'thread' + * option is used, so start at 1 then and 0 otherwise. + */ + for (i = cnt_list[1] != NULL ? 1 : 0; cnt_list[i]; i++) { + /* If i is 0 it means no thread files and we then set the thread number to 1 */ + cnt_list[i]->threadnr = i ? i : 1; + +- if (strcmp(cnt_list[i]->conf_filename,"") ) +- motion_log(LOG_INFO, 0, "Thread %d is from %s", cnt_list[i]->threadnr, cnt_list[i]->conf_filename ); ++ if (strcmp(cnt_list[i]->conf_filename, "")) ++ { ++ cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; + +- if (cnt_list[0]->conf.setup_mode) { +- motion_log(-1, 0, "Thread %d is device: %s input %d", cnt_list[i]->threadnr, +- cnt_list[i]->conf.netcam_url ? cnt_list[i]->conf.netcam_url : cnt_list[i]->conf.video_device, +- cnt_list[i]->conf.netcam_url ? -1 : cnt_list[i]->conf.input +- ); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", ++ cnt_list[i]->threadnr, cnt_list[i]->conf_filename); + } + +- if (cnt_list[0]->conf.setup_mode) +- motion_log(LOG_ERR, 0, "Webcam port %d", cnt_list[i]->conf.webcam_port); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", ++ cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? ++ cnt_list[i]->conf.netcam_url : cnt_list[i]->conf.video_device, ++ cnt_list[i]->conf.netcam_url ? -1 : cnt_list[i]->conf.input); ++ ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Stream port %d", ++ cnt_list[i]->conf.stream_port); + + start_motion_thread(cnt_list[i], &thread_attr); + } + +- /* Create a thread for the control interface if requested. Create it ++#ifdef HAVE_SDL ++ if (cnt_list[0]->conf.sdl_threadnr > 0) ++ sdl_start(cnt_list[cnt_list[1] != NULL ? cnt_list[0]->conf.sdl_threadnr : 0]->conf.width, ++ cnt_list[cnt_list[1] != NULL ? cnt_list[0]->conf.sdl_threadnr : 0]->conf.height); ++#endif ++ ++ /* ++ * Create a thread for the control interface if requested. Create it + * detached and with 'motion_web_control' as the thread function. + */ +- if (cnt_list[0]->conf.control_port) ++ if (cnt_list[0]->conf.webcontrol_port) + pthread_create(&thread_id, &thread_attr, &motion_web_control, cnt_list); + +- if (cnt_list[0]->conf.setup_mode) +- motion_log(-1, 0,"Waiting for threads to finish, pid: %d", getpid()); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Waiting for threads to finish, pid: %d", ++ getpid()); + +- /* Crude way of waiting for all threads to finish - check the thread ++ /* ++ * Crude way of waiting for all threads to finish - check the thread + * counter (because we cannot do join on the detached threads). + */ + while (1) { +- SLEEP(1,0); ++ SLEEP(1, 0); + +- /* Calculate how many threads runnig or wants to run ++ /* ++ * Calculate how many threads runnig or wants to run + * if zero and we want to finish, break out + */ + int motion_threads_running = 0; ++ + for (i = (cnt_list[1] != NULL ? 1 : 0); cnt_list[i]; i++) { + if (cnt_list[i]->running || cnt_list[i]->restart) + motion_threads_running++; + } + +- if (((motion_threads_running == 0 ) && finish ) || +- ((motion_threads_running == 0 ) && (threads_running == 0)) ){ +- if (debug_level >= CAMERA_DEBUG){ +- motion_log(LOG_INFO, 0, "DEBUG-1 threads_running %d motion_threads_running %d , finish %d", +- threads_running, motion_threads_running, finish); +- } ++ if (((motion_threads_running == 0) && finish) || ++ ((motion_threads_running == 0) && (threads_running == 0))) { ++ MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-1 threads_running %d motion_threads_running %d " ++ ", finish %d", threads_running, motion_threads_running, finish); + break; +- } ++ } + + for (i = (cnt_list[1] != NULL ? 1 : 0); cnt_list[i]; i++) { + /* Check if threads wants to be restarted */ +- if ((!cnt_list[i]->running) && (cnt_list[i]->restart) ) { +- motion_log(LOG_INFO, 0, "Motion thread %d restart", cnt_list[i]->threadnr); ++ if ((!cnt_list[i]->running) && (cnt_list[i]->restart)) { ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion thread %d restart", ++ cnt_list[i]->threadnr); + start_motion_thread(cnt_list[i], &thread_attr); + } ++ + if (cnt_list[i]->watchdog > WATCHDOG_OFF) { + cnt_list[i]->watchdog--; ++ + if (cnt_list[i]->watchdog == 0) { +- motion_log(LOG_ERR, 0, "Thread %d - Watchdog timeout, trying to do a graceful restart", +- cnt_list[i]->threadnr); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, trying to do " ++ "a graceful restart", cnt_list[i]->threadnr); + cnt_list[i]->finish = 1; + } ++ + if (cnt_list[i]->watchdog == -60) { +- motion_log(LOG_ERR, 0, "Thread %d - Watchdog timeout, did NOT restart graceful," +- "killing it!", cnt_list[i]->threadnr); ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, did NOT restart graceful," ++ "killing it!", cnt_list[i]->threadnr); + pthread_cancel(cnt_list[i]->thread_id); + pthread_mutex_lock(&global_lock); + threads_running--; +@@ -2392,27 +2804,29 @@ int main (int argc, char **argv) + } + } + +- if (debug_level >= CAMERA_DEBUG){ +- motion_log(LOG_INFO, 0, "DEBUG-2 threads_running %d motion_threads_running %d , finish %d", +- threads_running, motion_threads_running, finish); +- } ++ MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d", ++ threads_running, motion_threads_running, finish); + } + /* Reset end main loop flag */ + finish = 0; + +- if (cnt_list[0]->conf.setup_mode) +- motion_log(LOG_DEBUG, 0, "Threads finished"); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Threads finished"); + + /* Rest for a while if we're supposed to restart. */ + if (restart) +- SLEEP(2,0); ++ SLEEP(2, 0); + + } while (restart); /* loop if we're supposed to restart */ + ++#ifdef HAVE_SDL ++ sdl_stop(); ++#endif ++ ++ + // Be sure that http control exits fine + cnt_list[0]->finish = 1; +- SLEEP(1,0); +- motion_log(LOG_INFO, 0, "Motion terminating"); ++ SLEEP(1, 0); ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion terminating"); + + /* Perform final cleanup. */ + pthread_key_delete(tls_key_threadnr); +@@ -2444,9 +2858,11 @@ int main (int argc, char **argv) + */ + void * mymalloc(size_t nbytes) + { +- void *dummy = malloc(nbytes); ++ void *dummy = calloc(nbytes, 1); ++ + if (!dummy) { +- motion_log(LOG_EMERG, 1, "Could not allocate %llu bytes of memory!", (unsigned long long)nbytes); ++ MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Could not allocate %llu bytes of memory!", ++ (unsigned long long)nbytes); + motion_remove_pid(); + exit(1); + } +@@ -2476,14 +2892,14 @@ void *myrealloc(void *ptr, size_t size, + + if (size == 0) { + free(ptr); +- motion_log(LOG_WARNING, 0, +- "Warning! Function %s tries to resize memoryblock at %p to 0 bytes!", +- desc, ptr); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, ++ "%s: Warning! Function %s tries to resize memoryblock at %p to 0 bytes!", ++ desc, ptr); + } else { + dummy = realloc(ptr, size); + if (!dummy) { +- motion_log(LOG_EMERG, 0, +- "Could not resize memory-block at offset %p to %llu bytes (function %s)!", ++ MOTION_LOG(EMG, TYPE_ALL, NO_ERRNO, ++ "%s: Could not resize memory-block at offset %p to %llu bytes (function %s)!", + ptr, (unsigned long long)size, desc); + motion_remove_pid(); + exit(1); +@@ -2493,6 +2909,7 @@ void *myrealloc(void *ptr, size_t size, + return dummy; + } + ++ + /** + * create_path + * +@@ -2519,23 +2936,34 @@ int create_path(const char *path) + start = strchr(path, '/'); + + while (start) { +- char *buffer = strdup(path); ++ char *buffer = mystrdup(path); + buffer[start-path] = 0x00; + + if (mkdir(buffer, mode) == -1 && errno != EEXIST) { +- motion_log(LOG_ERR, 1, "Problem creating directory %s", buffer); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem creating directory %s", ++ buffer); + free(buffer); + return -1; + } + +- free(buffer); +- + start = strchr(start + 1, '/'); ++ ++ if (!start) ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: creating directory %s", buffer); ++ ++ free(buffer); + } + + return 0; + } + ++#define MYBUFCOUNT 32 ++struct MyBuffer { ++ FILE* fh; ++ char* buffer; ++ size_t bufsize; ++} buffers[MYBUFCOUNT]; ++ + /** + * myfopen + * +@@ -2543,17 +2971,25 @@ int create_path(const char *path) + * (which is: path does not exist), the path is created and then things are + * tried again. This is faster then trying to create that path over and over + * again. If someone removes the path after it was created, myfopen will +- * recreate the path automatically. ++ * recreate the path automatically. If the bufsize is set to > 0, we will ++ * allocate (or re-use) write buffers to use instead of the default ones. ++ * This gives us much higher throughput in many cases. + * + * Parameters: + * + * path - path to the file to open + * mode - open mode ++ * bufsize - size of write buffers, 0 == OS default + * + * Returns: the file stream object + */ +-FILE * myfopen(const char *path, const char *mode) ++FILE * myfopen(const char *path, const char *mode, size_t bufsize) + { ++ static int bufferInit = 0; ++ if (!bufferInit) { ++ bufferInit = 1; ++ memset(buffers, 0x00, sizeof(buffers)); ++ } + /* first, just try to open the file */ + FILE *dummy = fopen(path, mode); + +@@ -2568,28 +3004,109 @@ FILE * myfopen(const char *path, const c + + /* and retry opening the file */ + dummy = fopen(path, mode); +- if (dummy) +- return dummy; + } ++ } ++ ++ if (dummy) { ++ if (bufsize > 0) { ++ int i = 0; ++ for (i = 0; i < MYBUFCOUNT; i++) { ++ int first = -1; ++ if (!buffers[i].fh) { ++ if (first == -1) ++ first = i; ++ if (buffers[i].buffer == NULL || ++ buffers[i].bufsize >= bufsize || ++ (i == (MYBUFCOUNT - 1) && first >= 0)) { ++ if (buffers[i].buffer == NULL) { ++ /* We are allocating a new buffer */ ++ buffers[i].fh = dummy; ++ buffers[i].buffer = mymalloc(bufsize); ++ buffers[i].bufsize = bufsize; ++ } ++ else if (buffers[i].bufsize >= bufsize) { ++ /* We are using an old buffer */ ++ buffers[i].fh = dummy; ++ } ++ else { ++ /* ++ * We are reusing an old buffer, but it is too ++ * small, realloc it ++ */ ++ i = first; ++ buffers[i].fh = dummy; ++ buffers[i].buffer = myrealloc(buffers[i].buffer, ++ bufsize, "myfopen"); ++ buffers[i].bufsize = bufsize; ++ } + +- /* two possibilities +- * 1: there was an other error while trying to open the file for the first time ++ if (buffers[i].buffer == NULL) { ++ /* ++ * Our allocation failed, so just use the default ++ * OS buffers ++ */ ++ buffers[i].fh = NULL; ++ buffers[i].bufsize = 0; ++ } ++ else { ++ setvbuf(buffers[i].fh, buffers[i].buffer, ++ _IOFBF, buffers[i].bufsize); ++ } ++ break; ++ } ++ } ++ } ++ } ++ } else { ++ /* ++ * Two possibilities ++ * 1: there was an other error while trying to open the file for the ++ * first time + * 2: could still not open the file after the path was created + */ +- motion_log(LOG_ERR, 1, "Error opening file %s with mode %s", path, mode); +- +- return NULL; ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening file %s with mode %s", ++ path, mode); + } + + return dummy; + } + + /** ++ * myfclose ++ * ++ * Motion-specific variant of fclose() ++ * ++ * Returns: fclose() return value ++ */ ++int myfclose(FILE* fh) ++{ ++ int i = 0; ++ int rval = fclose(fh); ++ ++ if (rval != 0) ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error closing file"); ++ ++ for (i = 0; i < MYBUFCOUNT; i++) { ++ if (buffers[i].fh == fh) { ++ buffers[i].fh = NULL; ++ if ( finish ) { ++ /* Free the buffers */ ++ if (buffers[i].buffer) ++ free(buffers[i].buffer); ++ buffers[i].buffer = NULL; ++ buffers[i].bufsize = 0; ++ } ++ } ++ } ++ return rval; ++} ++ ++/** + * mystrftime + * + * Motion-specific variant of strftime(3) that supports additional format + * specifiers in the format string. +- * ++ * + * Parameters: + * + * cnt - current thread's context structure +@@ -2603,7 +3120,7 @@ FILE * myfopen(const char *path, const c + * + * Returns: number of bytes written to the string s + */ +-size_t mystrftime(struct context *cnt, char *s, size_t max, const char *userformat, ++size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *userformat, + const struct tm *tm, const char *filename, int sqltype) + { + char formatstring[PATH_MAX] = ""; +@@ -2622,85 +3139,107 @@ size_t mystrftime(struct context *cnt, c + for (pos_userformat = userformat; *pos_userformat; ++pos_userformat) { + + if (*pos_userformat == '%') { +- /* Reset 'tempstr' to point to the beginning of 'tempstring', ++ /* ++ * Reset 'tempstr' to point to the beginning of 'tempstring', + * otherwise we will eat up tempstring if there are many + * format specifiers. + */ + tempstr = tempstring; + tempstr[0] = '\0'; ++ + switch (*++pos_userformat) { +- case '\0': // end of string +- --pos_userformat; +- break; ++ case '\0': // end of string ++ --pos_userformat; ++ break; + +- case 'v': // event +- sprintf(tempstr, "%02d", cnt->event_nr); +- break; ++ case 'v': // event ++ sprintf(tempstr, "%02d", cnt->event_nr); ++ break; + +- case 'q': // shots +- sprintf(tempstr, "%02d", cnt->current_image->shot); +- break; ++ case 'q': // shots ++ sprintf(tempstr, "%02d", cnt->current_image->shot); ++ break; + +- case 'D': // diffs +- sprintf(tempstr, "%d", cnt->current_image->diffs); +- break; ++ case 'D': // diffs ++ sprintf(tempstr, "%d", cnt->current_image->diffs); ++ break; + +- case 'N': // noise +- sprintf(tempstr, "%d", cnt->noise); +- break; ++ case 'N': // noise ++ sprintf(tempstr, "%d", cnt->noise); ++ break; + +- case 'i': // motion width +- sprintf(tempstr, "%d", cnt->current_image->location.width); +- break; ++ case 'i': // motion width ++ sprintf(tempstr, "%d", cnt->current_image->location.width); ++ break; + +- case 'J': // motion height +- sprintf(tempstr, "%d", cnt->current_image->location.height); +- break; ++ case 'J': // motion height ++ sprintf(tempstr, "%d", cnt->current_image->location.height); ++ break; + +- case 'K': // motion center x +- sprintf(tempstr, "%d", cnt->current_image->location.x); +- break; ++ case 'K': // motion center x ++ sprintf(tempstr, "%d", cnt->current_image->location.x); ++ break; + +- case 'L': // motion center y +- sprintf(tempstr, "%d", cnt->current_image->location.y); +- break; ++ case 'L': // motion center y ++ sprintf(tempstr, "%d", cnt->current_image->location.y); ++ break; + +- case 'o': // threshold +- sprintf(tempstr, "%d", cnt->threshold); +- break; ++ case 'o': // threshold ++ sprintf(tempstr, "%d", cnt->threshold); ++ break; + +- case 'Q': // number of labels +- sprintf(tempstr, "%d", cnt->current_image->total_labels); +- break; +- case 't': // thread number +- sprintf(tempstr, "%d",(int)(unsigned long) +- pthread_getspecific(tls_key_threadnr)); +- break; +- case 'C': // text_event +- if (cnt->text_event_string && cnt->text_event_string[0]) +- snprintf(tempstr, PATH_MAX, "%s", cnt->text_event_string); +- else +- ++pos_userformat; +- break; +- case 'f': // filename +- if (filename) +- snprintf(tempstr, PATH_MAX, "%s", filename); +- else +- ++pos_userformat; +- break; +- case 'n': // sqltype +- if (sqltype) +- sprintf(tempstr, "%d", sqltype); +- else +- ++pos_userformat; ++ case 'Q': // number of labels ++ sprintf(tempstr, "%d", cnt->current_image->total_labels); ++ break; ++ ++ case 't': // thread number ++ sprintf(tempstr, "%d",(int)(unsigned long) ++ pthread_getspecific(tls_key_threadnr)); ++ break; ++ ++ case 'C': // text_event ++ if (cnt->text_event_string && cnt->text_event_string[0]) ++ snprintf(tempstr, PATH_MAX, "%s", cnt->text_event_string); ++ else ++ ++pos_userformat; ++ break; ++ ++ case 'w': // picture width ++ sprintf(tempstr, "%d", cnt->imgs.width); ++ break; ++ ++ case 'h': // picture height ++ sprintf(tempstr, "%d", cnt->imgs.height); ++ break; ++ ++ case 'f': // filename -- or %fps ++ if ((*(pos_userformat+1) == 'p') && (*(pos_userformat+2) == 's')) { ++ sprintf(tempstr, "%d", cnt->movie_fps); ++ pos_userformat += 2; + break; +- default: // Any other code is copied with the %-sign +- *format++ = '%'; +- *format++ = *pos_userformat; +- continue; ++ } ++ ++ if (filename) ++ snprintf(tempstr, PATH_MAX, "%s", filename); ++ else ++ ++pos_userformat; ++ break; ++ ++ case 'n': // sqltype ++ if (sqltype) ++ sprintf(tempstr, "%d", sqltype); ++ else ++ ++pos_userformat; ++ break; ++ ++ default: // Any other code is copied with the %-sign ++ *format++ = '%'; ++ *format++ = *pos_userformat; ++ continue; + } + +- /* If a format specifier was found and used, copy the result from ++ /* ++ * If a format specifier was found and used, copy the result from + * 'tempstr' to 'format'. + */ + if (tempstr[0]) { +@@ -2720,86 +3259,3 @@ size_t mystrftime(struct context *cnt, c + return strftime(s, max, format, tm); + } + +-/** +- * motion_log +- * +- * This routine is used for printing all informational, debug or error +- * messages produced by any of the other motion functions. It always +- * produces a message of the form "[n] {message}", and (if the param +- * 'errno_flag' is set) follows the message with the associated error +- * message from the library. +- * +- * Parameters: +- * +- * level logging level for the 'syslog' function +- * (-1 implies no syslog message should be produced) +- * errno_flag if set, the log message should be followed by the +- * error message. +- * fmt the format string for producing the message +- * ap variable-length argument list +- * +- * Returns: +- * Nothing +- */ +-void motion_log(int level, int errno_flag, const char *fmt, ...) +-{ +- int errno_save, n; +- char buf[1024]; +-#if (!defined(BSD)) && (!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) +- char msg_buf[100]; +-#endif +- va_list ap; +- int threadnr; +- +- /* 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, +- * which is nice because that's what we want in that case. +- */ +- threadnr = (unsigned long)pthread_getspecific(tls_key_threadnr); +- +- /* +- * First we save the current 'error' value. This is required because +- * the subsequent calls to vsnprintf could conceivably change it! +- */ +- errno_save = errno; +- +- /* Prefix the message with the thread number */ +- n = snprintf(buf, sizeof(buf), "[%d] ", threadnr); +- +- /* Next add the user's message */ +- va_start(ap, fmt); +- n += vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); +- +- /* If errno_flag is set, add on the library error message */ +- if (errno_flag) { +- strncat(buf, ": ", 1024 - strlen(buf)); +- n += 2; +- +- /* +- * this is bad - apparently gcc/libc wants to use the non-standard GNU +- * version of strerror_r, which doesn't actually put the message into +- * my buffer :-(. I have put in a 'hack' to get around this. +- */ +-#if (defined(BSD)) +- strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */ +-#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE +- strerror_r(errno_save, buf + n, sizeof(buf) - n); +-#else +- strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf)); +-#endif +- } +- /* If 'level' is not negative, send the message to the syslog */ +- if (level >= 0) +- syslog(level, "%s", buf); +- +- /* For printing to stderr we need to add a newline */ +- strcat(buf, "\n"); +- fputs(buf, stderr); +- fflush(stderr); +- +- /* Clean up the argument list routine */ +- va_end(ap); +-} +- +- +- +--- motion-3.2.12.orig/motion.h ++++ motion-3.2.12/motion.h +@@ -12,11 +12,24 @@ + + #include "config.h" + ++#if defined(__FreeBSD__) || defined(__NetBSD__) ++#define BSD ++#endif ++ + /* Includes */ + #ifdef HAVE_MYSQL + #include + #endif + ++#ifdef HAVE_SQLITE3 ++#include ++#endif ++ ++#ifdef HAVE_PGSQL ++#include ++#endif ++ ++ + #include + #include + #ifndef __USE_GNU +@@ -27,7 +40,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -39,20 +51,22 @@ + #include + + #define _LINUX_TIME_H 1 +-#if !defined(WITHOUT_V4L) && !defined(BSD) ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) && (!defined(BSD)) + #include + #endif + + #include + +-#ifdef HAVE_PGSQL +-#include +-#endif +- ++#include "logger.h" + #include "conf.h" +-#include "webcam.h" ++#include "stream.h" + #include "webhttpd.h" + ++#ifdef HAVE_SDL ++#include "sdl.h" ++#endif ++ ++ + /** + * ATTRIBUTE_UNUSED: + * +@@ -69,7 +83,14 @@ + #define ATTRIBUTE_UNUSED + #endif + +-/* The macro below defines a version of sleep using nanosleep ++/* strerror_r() XSI vs GNU */ ++#if (defined(BSD)) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) ++#define XSI_STRERROR_R ++#endif ++ ++ ++/* ++ * The macro below defines a version of sleep using nanosleep + * If a signal such as SIG_CHLD interrupts the sleep we just continue sleeping + */ + #define SLEEP(seconds, nanoseconds) { \ +@@ -79,9 +100,8 @@ + while (nanosleep(&tv, &tv) == -1); \ + } + ++#define CLEAR(x) memset(&(x), 0, sizeof(x)) + +-#if defined(WITHOUT_V4L) || defined(BSD) +- + #define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ + #define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ + #define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ +@@ -100,17 +120,8 @@ + #define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ + #define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ + #define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ +-#endif +- +- +-/* Debug levels FIXME */ +-#define CAMERA_WARNINGS 3 /* warnings only */ +-#define CAMERA_INFO 5 /* info debug */ +-#define CAMERA_VIDEO 6 /* video debug */ +-#define CAMERA_DEBUG 7 /* debug but not verbose */ +-#define CAMERA_VERBOSE 8 /* verbose level */ +-#define CAMERA_ALL 9 /* everything */ + ++#define DEF_PALETTE 17 + + /* Default picture settings */ + #define DEF_WIDTH 352 +@@ -122,8 +133,8 @@ + #define DEF_NOISELEVEL 32 + + /* Minimum time between two 'actions' (email, sms, external) */ +-#define DEF_GAP 60 /* 1 minutes */ +-#define DEF_MAXMPEGTIME 3600 /* 60 minutes */ ++#define DEF_EVENT_GAP 60 /* 1 minutes */ ++#define DEF_MAXMOVIETIME 3600 /* 60 minutes */ + + #define DEF_FFMPEG_BPS 400000 + #define DEF_FFMPEG_VBR 0 +@@ -132,26 +143,26 @@ + #define THRESHOLD_TUNE_LENGTH 256 + + #define MISSING_FRAMES_TIMEOUT 30 /* When failing to get picture frame from camera +- * we reuse the previous frame until +- * MISSING_FRAMES_TIMEOUT seconds has passed +- * and then we show a grey image instead ++ we reuse the previous frame until ++ MISSING_FRAMES_TIMEOUT seconds has passed ++ and then we show a grey image instead + */ + +-#define WATCHDOG_TMO 30 /* 10 sec max motion_loop interval */ +-#define WATCHDOG_OFF -127 /* Turn off watchdog, used when we wants to quit a thread */ ++#define WATCHDOG_TMO 30 /* 30 sec max motion_loop interval */ ++#define WATCHDOG_OFF -127 /* Turn off watchdog, used when we wants to quit a thread */ + +-#define CONNECTION_KO "Lost connection" +-#define CONNECTION_OK "Connection OK" ++#define CONNECTION_KO "Lost connection" ++#define CONNECTION_OK "Connection OK" + +-#define DEF_MAXSTREAMS 10 /* Maximum number of webcam clients per camera */ +-#define DEF_MAXWEBQUEUE 10 /* Maximum number of webcam client in queue */ ++#define DEF_MAXSTREAMS 10 /* Maximum number of stream clients per camera */ ++#define DEF_MAXWEBQUEUE 10 /* Maximum number of stream client in queue */ + + #define DEF_TIMESTAMP "%Y-%m-%d\\n%T" + #define DEF_EVENTSTAMP "%Y%m%d%H%M%S" + + #define DEF_SNAPPATH "%v-%Y%m%d%H%M%S-snapshot" +-#define DEF_JPEGPATH "%v-%Y%m%d%H%M%S-%q" +-#define DEF_MPEGPATH "%v-%Y%m%d%H%M%S" ++#define DEF_IMAGEPATH "%v-%Y%m%d%H%M%S-%q" ++#define DEF_MOVIEPATH "%v-%Y%m%d%H%M%S" + #define DEF_TIMEPATH "%Y%m%d-timelapse" + + #define DEF_TIMELAPSE_MODE "daily" +@@ -159,33 +170,44 @@ + /* Do not break this line into two or more. Must be ONE line */ + #define DEF_SQL_QUERY "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')" + ++ ++/* OUTPUT Image types */ ++#define IMAGE_TYPE_JPEG 0 ++#define IMAGE_TYPE_PPM 1 ++ + /* Filetype defines */ +-#define FTYPE_IMAGE 1 +-#define FTYPE_IMAGE_SNAPSHOT 2 +-#define FTYPE_IMAGE_MOTION 4 +-#define FTYPE_MPEG 8 +-#define FTYPE_MPEG_MOTION 16 +-#define FTYPE_MPEG_TIMELAPSE 32 ++#define FTYPE_IMAGE 1 ++#define FTYPE_IMAGE_SNAPSHOT 2 ++#define FTYPE_IMAGE_MOTION 4 ++#define FTYPE_MPEG 8 ++#define FTYPE_MPEG_MOTION 16 ++#define FTYPE_MPEG_TIMELAPSE 32 + + #define FTYPE_MPEG_ANY (FTYPE_MPEG | FTYPE_MPEG_MOTION | FTYPE_MPEG_TIMELAPSE) + #define FTYPE_IMAGE_ANY (FTYPE_IMAGE | FTYPE_IMAGE_SNAPSHOT | FTYPE_IMAGE_MOTION) + +-/* What types of jpeg files do we want to have */ +-#define NEWIMG_OFF 0 +-#define NEWIMG_ON 1 +-#define NEWIMG_FIRST 2 +-#define NEWIMG_BEST 4 +-#define NEWIMG_CENTER 8 +- +-#define LOCATE_OFF 0 +-#define LOCATE_ON 1 +-#define LOCATE_PREVIEW 2 ++/* What types of images files do we want to have */ ++#define NEWIMG_OFF 0 ++#define NEWIMG_ON 1 ++#define NEWIMG_FIRST 2 ++#define NEWIMG_BEST 4 ++#define NEWIMG_CENTER 8 ++ ++#define LOCATE_OFF 0 ++#define LOCATE_ON 1 ++#define LOCATE_PREVIEW 2 ++#define LOCATE_BOX 1 ++#define LOCATE_REDBOX 2 ++#define LOCATE_CROSS 4 ++#define LOCATE_REDCROSS 8 ++ ++#define LOCATE_NORMAL 1 ++#define LOCATE_BOTH 2 + +-#define LOCATE_NORMAL 0 +-#define LOCATE_BOTH 1 ++#define UPDATE_REF_FRAME 1 ++#define RESET_REF_FRAME 2 + +-#define UPDATE_REF_FRAME 1 +-#define RESET_REF_FRAME 2 ++#define BUFSIZE_1MEG (1024 * 1024) + + /* Forward declaration, used in track.h */ + struct images; +@@ -193,39 +215,44 @@ struct images; + #include "track.h" + #include "netcam.h" + +-/* Structure to hold images information ++/* ++ * Structure to hold images information + * The idea is that this should have all information about a picture e.g. diffs, timestamp etc. + * The exception is the label information, it uses a lot of memory + * When the image is stored all texts motion marks etc. is written to the image + * so we only have to send it out when/if we want. + */ ++ + /* A image can have detected motion in it, but dosn't trigger an event, if we use minimum_motion_frames */ +-#define IMAGE_MOTION 1 +-#define IMAGE_TRIGGER 2 +-#define IMAGE_SAVE 4 +-#define IMAGE_SAVED 8 +-#define IMAGE_PRECAP 16 +-#define IMAGE_POSTCAP 32 ++#define IMAGE_MOTION 1 ++#define IMAGE_TRIGGER 2 ++#define IMAGE_SAVE 4 ++#define IMAGE_SAVED 8 ++#define IMAGE_PRECAP 16 ++#define IMAGE_POSTCAP 32 + + struct image_data { + unsigned char *image; + int diffs; +- time_t timestamp; /* Timestamp when image was captured */ ++ time_t timestamp; /* Timestamp when image was captured */ + struct tm timestamp_tm; +- int shot; /* Sub second timestamp count */ ++ int shot; /* Sub second timestamp count */ + +- /* movement center to img center distance +- * Note Dist is calculated distX*distX + distY*distY */ ++ /* ++ * Movement center to img center distance ++ * Note: Dist is calculated distX*distX + distY*distY ++ */ + unsigned long cent_dist; + +- unsigned int flags; /* Se IMAGE_* defines */ ++ unsigned int flags; /* Se IMAGE_* defines */ + +- struct coord location; /* coordinates for center and size of last motion detection*/ ++ struct coord location; /* coordinates for center and size of last motion detection*/ + + int total_labels; + }; + +-/* DIFFERENCES BETWEEN imgs.width, conf.width AND rotate_data.cap_width ++/* ++ * DIFFERENCES BETWEEN imgs.width, conf.width AND rotate_data.cap_width + * (and the corresponding height values, of course) + * =========================================================================== + * Location Purpose +@@ -251,7 +278,7 @@ struct image_data { + */ + + /* date/time drawing, draw.c */ +-int draw_text (unsigned char *image, int startx, int starty, int width, const char *text, unsigned short int factor); ++int draw_text(unsigned char *image, unsigned int startx, unsigned int starty, unsigned int width, const char *text, unsigned int factor); + int initialize_chars(void); + + struct images { +@@ -275,6 +302,7 @@ struct images { + int width; + int height; + int type; ++ int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ + int size; + int motionsize; + int labelgroup_max; +@@ -287,36 +315,47 @@ struct images { + struct rotdata { + /* Temporary buffer for 90 and 270 degrees rotation. */ + unsigned char *temp_buf; +- /* Degrees to rotate; copied from conf.rotate_deg. This is the value ++ /* ++ * Degrees to rotate; copied from conf.rotate_deg. This is the value + * that is actually used. The value of conf.rotate_deg cannot be used + * because it can be changed by motion-control, and changing rotation + * while Motion is running just causes problems. + */ + int degrees; +- /* Capture width and height - different from output width and height if +- * rotating 90 or 270 degrees. */ ++ /* ++ * Capture width and height - different from output width and height if ++ * rotating 90 or 270 degrees. ++ */ + int cap_width; + int cap_height; + }; + + /* +- these used to be global variables but now each thread will have its +- own context ++ * These used to be global variables but now each thread will have its ++ * own context + */ + struct context { ++ FILE *extpipe; ++ int extpipe_open; + char conf_filename[PATH_MAX]; + int threadnr; +- unsigned short int daemon; ++ unsigned int daemon; + char pid_file[PATH_MAX]; ++ char log_file[PATH_MAX]; ++ char log_type_str[6]; ++ int log_level; ++ unsigned int log_type; + + struct config conf; + struct images imgs; + struct trackoptions track; + struct netcam_context *netcam; + struct image_data *current_image; /* Pointer to a structure where the image, diffs etc is stored */ +- unsigned short int new_img; ++ unsigned int new_img; + +- int locate; ++ int locate_motion_mode; ++ int locate_motion_style; ++ int process_thisframe; + struct rotdata rotate_data; /* rotation data is thread-specific */ + + int noise; +@@ -325,39 +364,39 @@ struct context { + int smartmask_speed; + + /* Commands to the motion thread */ +- volatile unsigned short int snapshot; /* Make a snapshot */ +- volatile unsigned short int makemovie; /* End a movie */ +- volatile unsigned short int finish; /* End the thread */ +- volatile unsigned short int restart; /* Restart the thread when it ends */ ++ volatile unsigned int snapshot; /* Make a snapshot */ ++ volatile unsigned int makemovie; /* End a movie */ ++ volatile unsigned int finish; /* End the thread */ ++ volatile unsigned int restart; /* Restart the thread when it ends */ + /* Is the motion thread running */ +- volatile unsigned short int running; ++ volatile unsigned int running; + volatile int watchdog; + + pthread_t thread_id; + + int event_nr; + int prev_event; +- int lightswitch_framecounter; +- char text_event_string[PATH_MAX]; /* The text for conv. spec. %C - +- we assume PATH_MAX normally 4096 characters is fine */ +- int postcap; /* downcounter, frames left to to send post event */ ++ unsigned int lightswitch_framecounter; ++ char text_event_string[PATH_MAX]; /* The text for conv. spec. %C - ++ we assume PATH_MAX normally 4096 characters is fine */ ++ int postcap; /* downcounter, frames left to to send post event */ + +- short int shots; +- unsigned short int detecting_motion; ++ int shots; ++ unsigned int detecting_motion; + struct tm *currenttime_tm; + struct tm *eventtime_tm; + + time_t currenttime; + time_t lasttime; + time_t eventtime; +- time_t connectionlosttime; /* timestamp from connection lost */ ++ time_t connectionlosttime; /* timestamp from connection lost */ + +- int lastrate; +- unsigned short int startup_frames; +- unsigned short int moved; +- unsigned short int pause; +- int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ +- unsigned short int lost_connection; ++ unsigned int lastrate; ++ unsigned int startup_frames; ++ unsigned int moved; ++ unsigned int pause; ++ int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ ++ unsigned int lost_connection; + + #if (defined(BSD)) + int tuner_dev; +@@ -366,13 +405,17 @@ struct context { + int pipe; + int mpipe; + +- struct webcam webcam; ++ struct stream stream; + int stream_count; + +-#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) ++#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) + int sql_mask; + #endif + ++#ifdef HAVE_SQLITE3 ++ sqlite3 *database_sqlite3; ++#endif ++ + #ifdef HAVE_MYSQL + MYSQL *database; + #endif +@@ -381,29 +424,33 @@ struct context { + PGconn *database_pg; + #endif + ++ int movie_fps; ++ char newfilename[PATH_MAX]; ++ char extpipefilename[PATH_MAX]; ++ int movie_last_shot; ++ + #ifdef HAVE_FFMPEG +- struct ffmpeg *ffmpeg_new; +- struct ffmpeg *ffmpeg_motion; ++ struct ffmpeg *ffmpeg_output; ++ struct ffmpeg *ffmpeg_output_debug; + struct ffmpeg *ffmpeg_timelapse; + struct ffmpeg *ffmpeg_smartmask; +- char newfilename[PATH_MAX]; +- char motionfilename[PATH_MAX]; + char timelapsefilename[PATH_MAX]; ++ char motionfilename[PATH_MAX]; + #endif + }; + + extern pthread_mutex_t global_lock; + extern volatile int threads_running; +-extern unsigned short int debug_level; ++extern FILE *ptr_logfile; + + /* TLS keys below */ + extern pthread_key_t tls_key_threadnr; /* key for thread number */ + +-int http_bindsock(int, int); ++int http_bindsock(int, int, int); + void * mymalloc(size_t); + void * myrealloc(void *, size_t, const char *); +-FILE * myfopen(const char *, const char *); +-size_t mystrftime(struct context *, char *, size_t, const char *, const struct tm *, const char *, int); ++FILE * myfopen(const char *, const char *, size_t); ++int myfclose(FILE *); ++size_t mystrftime(const struct context *, char *, size_t, const char *, const struct tm *, const char *, int); + int create_path(const char *); +-void motion_log(int, int, const char *, ...); + #endif /* _INCLUDE_MOTION_H */ +--- /dev/null ++++ motion-3.2.12/motion.init-Debian +@@ -0,0 +1,69 @@ ++#! /bin/bash ++# ++# motion 3.2.12-4ppa01 ++# Start the motion detection . ++# ++ ++NAME=motion ++PATH=/bin:/usr/bin:/sbin:/usr/sbin ++DAEMON=/home/dave/motion_build/bin/motion ++PIDFILE=/var/run/motion/$NAME.pid ++ ++ ++trap "" 1 ++export LANG=C ++export PATH ++ ++test -f $DAEMON || exit 0 ++ ++ ++case "$1" in ++ start) ++ echo "Starting motion detection : $NAME" ++ start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --chuid motion ++ ;; ++ ++ stop) ++ echo "Stopping motion detection : $NAME" ++ start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON --retry 30 ++ ;; ++ ++ status) ++ echo "Status motion detection : $NAME" ++ if (test -f $PIDFILE); then ++ echo -n "Running process for $NAME : " ++ pidof $NAME ++ else ++ echo "Stopped" ++ fi ++ ;; ++ ++ reload-config) ++ echo "Reloading $NAME configuration" ++ start-stop-daemon --stop --pidfile $PIDFILE --signal HUP --exec $DAEMON ++ ;; ++ ++ restart-motion) ++ echo "Restarting $NAME" ++ start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON --retry 30 ++ start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --chuid motion ++ ;; ++ ++ restart) ++ $0 restart-motion ++ exit $? ++ ;; ++ ++ *) ++ echo "Usage: /etc/init.d/$NAME {start|stop|status|reload-config|restart}" ++ exit 1 ++ ;; ++esac ++ ++if [ $? == 0 ]; then ++ echo . ++ exit 0 ++else ++ echo failed ++ exit 1 ++fi +--- /dev/null ++++ motion-3.2.12/motion.init-Fedora +@@ -0,0 +1,118 @@ ++#!/bin/bash ++# ++# motion Startup script for the Motion Detection System ++# ++# chkconfig: - 85 15 ++# description: Motion detection system. It is used to detect movement based \ ++# on compare images. ++# processname: motion ++# pidfile: /var/run/motion.pid ++# config: /etc/motion.conf ++# ++### BEGIN INIT INFO ++# Provides: motion ++# Required-Start: $local_fs ++# Required-Stop: $local_fs ++# Default-Start: ++# Default-Stop: ++# Short-Description: Start and stop motion detection system ++# Description: The Motion detection system is used to detect movement based ++# on image comparison. ++### END INIT INFO ++ ++# Source function library. ++. /etc/rc.d/init.d/functions ++ ++motion=${MOTION-/usr/bin/motion} ++prog=motion ++pidfile=/var/run/motion.pid ++lockfile=/var/lock/subsys/motion ++ ++start() { ++ [ -x $exec ] || exit 5 ++ [ -f $config ] || exit 6 ++ echo -n $"Starting $prog: " ++ # We try to determine which architecture we have so we can ++ # load libv4l to support more USB cameras. x86_64 and ppc64 ++ # are both supported by rpmfusion. ++ case $(uname -i) in ++ "x86_64" ) ++ #We load libv4l for 64 Bit x86 architectures ++ LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; ++ "ppc64" ) ++ #We load libv4l for 64 Bit PPC architectures ++ LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; ++ * ) ++ #Default case, we load libv4l for all 32 Bit architectures ++ LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; ++ esac ++ retval=$? ++ echo ++ [ $retval -eq 0 ] && touch $lockfile ++ return $retval ++} ++ ++stop() { ++ echo -n $"Stopping $prog: " ++ killproc $motion ++ retval=$? ++ echo ++ [ $retval = 0 ] && rm -f $lockfile ++} ++ ++restart() { ++ stop ++ start ++} ++ ++reload() { ++ echo -n $"Reloading $prog configuration: " ++ killproc $motion -HUP ++ retval=$? ++ echo ++ return $retval ++} ++ ++rh_status() { ++ # run checks to determine if the service is running or use generic status ++ status $prog ++} ++ ++rh_status_q() { ++ rh_status >/dev/null 2>&1 ++} ++ ++ ++# See how we were called. ++case "$1" in ++ start) ++ rh_status_q && exit 0 ++ $1 ++ ;; ++ stop) ++ rh_status_q || exit 0 ++ $1 ++ ;; ++ restart) ++ $1 ++ ;; ++ reload) ++ rh_status_q || exit 7 ++ $1 ++ ;; ++ force-reload) ++ #force_reload ++ reload ++ ;; ++ status) ++ rh_status ++ ;; ++ condrestart|try-restart) ++ rh_status_q || exit 0 ++ restart ++ ;; ++ *) ++ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" ++ exit 1 ++esac ++exit $? +--- /dev/null ++++ motion-3.2.12/motion.init-FreeBSD.sh +@@ -0,0 +1,26 @@ ++#!/bin/sh ++# ++# motion.sh for rc.d usage 2006 Angel Carpintero ++# ++# Add the following line in /etc/rc.conf to enable motion at startup ++# ++# motion_enable="YES" ++# ++ ++# PROVIDE: motion ++# REQUIRE: DAEMON ++# KEYWORD: shutdown ++ ++. /etc/rc.subr ++ ++motion_enable="${motion_enable-NO}" ++ ++name="motion" ++rcvar=`set_rcvar` ++ ++command="/home/dave/motion_build/bin/${name}" ++pidfile="/var/run/${name}.pid" ++required_files="/usr/local/etc/${name}.conf" ++ ++load_rc_config $name ++run_rc_command "$1" +--- /dev/null ++++ motion-3.2.12/motion.spec +@@ -0,0 +1,134 @@ ++Name: motion ++Version: 3.2.12-4ppa01 ++Release: 1%{?dist} ++Summary: A motion detection system ++ ++Group: Applications/Multimedia ++License: GPLv2+ ++URL: http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome ++Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz ++BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) ++ ++BuildRequires: libjpeg-devel ffmpeg-devel zlib-devel ++#This requires comes from the startup script, it will be there until motion supports libv4l calls in the code ++Requires: libv4l ++Requires(post): chkconfig ++Requires(preun): chkconfig initscripts ++Requires(postun): initscripts ++ ++%description ++Motion is a software motion detector. It grabs images from video4linux devices ++and/or from webcams (such as the axis network cameras). Motion is the perfect ++tool for keeping an eye on your property keeping only those images that are ++interesting. Motion is strictly command line driven and can run as a daemon ++with a rather small footprint. This version is built with ffmpeg support but ++without MySQL and PostgreSQL support. ++ ++%prep ++%setup -q ++ ++%build ++%configure --sysconfdir=%{_sysconfdir}/%{name} --without-optimizecpu --with-ffmpeg --without-mysql --without-pgsql ++make %{?_smp_mflags} ++ ++%install ++rm -rf %{buildroot} ++make install DESTDIR=%{buildroot} ++#We rename the configuration file ++mv %{buildroot}%{_sysconfdir}/%{name}/motion-dist.conf %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++#We change the PID file path to match the one in the startup script ++sed -i 's|/var/run/motion/motion.pid|/var/run/motion.pid|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++#We remove SQL directives in the configuration file, as we don't use them ++sed -i 's|sql_log_image|; sql_log_image|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++sed -i 's|sql_log_snapshot|; sql_log_snapshot|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++sed -i 's|sql_log_mpeg|; sql_log_mpeg|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++sed -i 's|sql_log_timelapse|; sql_log_timelapse|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++sed -i 's|sql_query|; sql_query|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++#We set the log file and target directory - logging is for 3.3 branch ++sed -i 's|;logfile|logfile /var/log/motion.log|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++sed -i 's|target_dir /usr/local/apache2/htdocs/cam1|target_dir /var/motion|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++#We install our startup script ++install -D -m 0755 motion.init-Fedora %{buildroot}%{_initrddir}/%{name} ++ ++%post ++#We add the motion init script to the services when installing ++/sbin/chkconfig --add %{name} ++ ++%preun ++#We stop the service and remove it from init scripts when erasing ++if [ $1 = 0 ] ; then ++ /sbin/service %{name} stop >/dev/null 2>&1 ++ /sbin/chkconfig --del %{name} ++fi ++ ++%postun ++#We restart the service during an upgrade ++if [ "$1" -ge "1" ] ; then ++ /sbin/service %{name} condrestart >/dev/null 2>&1 ++fi ++ ++%clean ++rm -rf %{buildroot} ++ ++%files ++#Permissions are bogus upstream, we need to be sure to set them here ++%defattr (-,root,root,-) ++%dir %{_sysconfdir}/%{name} ++%dir %{_datadir}/%{name}-%{version} ++%dir %{_datadir}/%{name}-%{version}/examples ++%doc CHANGELOG COPYING CREDITS INSTALL README motion_guide.html ++%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/motion-dist.conf ++%attr(0755,root,root) %{_datadir}/%{name}-%{version}/examples/motion.init-Debian ++%attr(0755,root,root) %{_datadir}/%{name}-%{version}/examples/motion.init-FreeBSD.sh ++%attr(0755,root,root) %{_datadir}/%{name}-%{version}/examples/motion.init-Fedora ++%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread1.conf ++%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread2.conf ++%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread3.conf ++%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread4.conf ++%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/motion.conf ++%attr(0755,root,root) %{_bindir}/motion ++%attr(0644,root,root) %{_mandir}/man1/motion.1* ++%attr(0755,root,root) %{_initrddir}/%{name} ++ ++%changelog ++* Thu Mar 06 2010 Steven Moix - 3.2.12-1 ++- New upstream release, important bugfixes only ++ ++* Wed Oct 21 2009 Thorsten Leemhuis - 3.2.11.1-3 ++- rebuild for new ffmpeg ++ ++* Tue Aug 11 2009 Steven Moix - 3.2.11.1-1 ++- Drop patch for ffmpeg 0.5 compatibility ++- Drop ffmpeg detection patch ++- Moved default output directory to /var/motion ++- New startup script with added v4l2convert to support more cameras - https://bugzilla.rpmfusion.org/show_bug.cgi?id=681 ++- Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) ++- Fix fd leaks in external pipe ++- Avoid possible stack smashing in v4l_open_vidpipe() ++- Fix segfault for new libjpeg v7 ++ ++* Mon Jul 06 2009 Steven Moix - 3.3.0-1 ++- SPEC Preparation for the 3.3 branch ++ ++* Sun Jun 05 2009 Steven Moix - 3.2.11-5 ++- Patch and rebuild for ffmpeg 0.5 ++ ++* Sun Mar 29 2009 Thorsten Leemhuis - 3.2.11-4 ++- rebuild for new F11 features ++ ++* Wed Mar 18 2009 Steven Moix - 3.2.11-3 ++- Even more corrected init script thanks to Stewart Adam ++ ++* Sun Mar 15 2009 Steven Moix - 3.2.11-2 ++- Removed the ffmpeg requires ++- Corrected the spec file ++- New init script with a corrected start() function and LSB header support ++ ++* Tue Mar 03 2009 Steven Moix - 3.2.11-1 ++- Updated to Fedora 10 standard ++ ++* Sun Sep 18 2005 Kenneth Lavrsen - 3.2.4-1 ++- Generic version of livna spec file replacing the old less optimal specfile. ++ ++* Thu Sep 15 2005 Dams - 3.2.3-0.lvn.1 ++- Initial released based upon upstream spec file +--- motion-3.2.12.orig/motion.spec.in ++++ motion-3.2.12/motion.spec.in +@@ -5,7 +5,7 @@ Summary: A motion detection syste + + Group: Applications/Multimedia + License: GPLv2+ +-URL: http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome ++URL: http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome + Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +@@ -45,7 +45,7 @@ sed -i 's|sql_log_mpeg|; sql_log_mpeg|g' + sed -i 's|sql_log_timelapse|; sql_log_timelapse|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf + sed -i 's|sql_query|; sql_query|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf + #We set the log file and target directory - logging is for 3.3 branch +-#sed -i 's|;logfile|logfile /var/log/motion.log|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf ++sed -i 's|;logfile|logfile /var/log/motion.log|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf + sed -i 's|target_dir /usr/local/apache2/htdocs/cam1|target_dir /var/motion|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf + #We install our startup script + install -D -m 0755 motion.init-Fedora %{buildroot}%{_initrddir}/%{name} +--- motion-3.2.12.orig/motion_guide.html ++++ motion-3.2.12/motion_guide.html +@@ -1,13 +1,13 @@ +-

Motion Guide - One Large Document.

++

Motion Guide - One Large Document.

+ This version of the Guide is made for inclusion in the Motion download package for off line reading. +

+-If you read this document from the distribution package of Motion or from some not up to date mirror you should know that the URL for the always up to date version is http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide. If you are already on the Foswiki based Motion site clicking the link just mentioned will lead you to the index page for the Motion Guide documents. ++If you read this document from the distribution package of Motion or from some not up to date mirror you should know that the URL for the always up to date version is http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide. If you are already on the new TWiki based Motion site clicking the link just mentioned will lead you to the index page for the Motion Guide documents. +


+ This topic consists of the following subtopics: +-MotionOverview, KnownProblems, InstallOverview, PrepareInstall, ConfigureScript, MakeInstall, UpgradingFromOlderVersion, RunningMotionConfigFiles, CommandLineOptions, ConfigFileOptions, SignalsKill, ErrorLogging, CaptureDeviceOptions, MotionDetectionSettings, ImageFileOutput, TuningMotion, MpegFilmsFFmpeg, SnapshotsWebCam, TextFeatures, AdvancedFilenames, ConversionSpecifiers, WebcamServer, RemoteControlHttp, ExternalCommands, TrackingControl, UsingDatabases, LoopbackDevice. ++MotionOverview, KnownProblems, InstallOverview, PrepareInstall, ConfigureScript, MakeInstall, UpgradingFromOlderVersion, RunningMotionConfigFiles, CommandLineOptions, ConfigFileOptions, SignalsKill, ErrorLogging, CaptureDeviceOptions, MotionDetectionSettings, ImageFileOutput, TuningMotion, MpegFilmsFFmpeg, SnapshotsWebCam, TextFeatures, AdvancedFilenames, ConversionSpecifiers, WebcamServer, RemoteControlHttp, ExternalCommands, TrackingControl, UsingDatabases, LoopbackDevice. +
+

+-

    ++
      +
    • Motion Guide - Installation +
    • Motion Detection Settings +
    • External Commands
        +-
      • on_area_detected +-
      • on_camera_lost +-
      • on_event_end ++
      • on_event_end +
      • on_event_start +
      • on_motion_detected +
      • on_movie_end +@@ -205,10 +201,10 @@ This topic consists of the following sub +

        +

        Motion Guide - Installation

        +

        +-

        Motion Overview

        ++

        Motion Overview

        +

        +-

        What is Motion?

        +- Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. Or in other words, it can detect motion. ++

        What is Motion?

        ++Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. Or in other words, it can detect motion. +

        + The program is written in C and is made for the Linux operating system. +

        +@@ -218,18 +214,18 @@ The output from motion can be: +

          +
        • jpg files +
        • ppm format files +-
        • mpeg video sequences ++
        • mpeg video sequences +
        +

        +

        How do I get Motion and what does it cost?

        +- Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project. ++Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project. +

        +

        Maintenance and Support

        +- Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day. ++Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day. +

        +-To get motion direct your browser to the Motion Homepage. ++To get motion direct your browser to the Motion Homepage. +

        +-On the Download Files page you will find a links to the latest stable version both as sources and binaries for some of the most popular Linux distributions. You will also find links to development versions. Snapshot releases are special test releases that are normally very stable. Every day a Motion Daily Source Snap is created from the Motion Subversion ++On the Download Files page you will find a links to the latest stable version both as sources and binaries for some of the most popular Linux distributions. You will also find links to development versions. Snapshot releases are special test releases that are normally very stable. Every day a Motion Daily Source Snap is created from the Motion Subversion +

        + Motion was originally written by Jeroen Vreeken who still actively participates in the development of Motion and later Folkert van Heusden continued as a lead programmer with Kenneth Lavrsen responsible for Motion Guide, website and releases on Sourceforge. +

        +@@ -238,14 +234,14 @@ From version 3.1.12 Motion is now projec + For support we encourage you to join the mailing list instead of writing to Jeroen, Folkert or Kenneth directly. We are all very active on the mailing list and by using the mailing list much more users will have benefit of the answers. Newbies and stupid questions are welcome on the list. Contributions in the form of patches are also very welcome on the mailing list. +

        +

        Which version to download and use?

        +- Versions 3.2.X are the current version. There is at the moment no development branch. The versions 3.1.X ended at 3.1.20 and there will be no more 3.1.X releases. If you use use a version older than 3.2.X you are encouraged to update. ++Versions 3.2.X are the current version. There is at the moment no development branch. The versions 3.1.X ended at 3.1.20 and there will be no more 3.1.X releases. If you use use a version older than 3.2.X you are encouraged to update. +

        +-Since 3.1.13 quite many options have been renamed to make setting up Motion easier. From 3.1.17-18 some unfinished features have been removed. The Berkeley mpeg feature is now removed because the ffmpeg feature is now mature and much better working. At version 3.1.18 a new network camera feature was introduced replacing the old cURL based netcam code and introducing support of mjpeg streaming cameras. However this new code was quite difficult to get stable. During the development of 3.2.2 the network camera code was totally rewritten again learning from our experience and now finally it seems to be stable. ++Since 3.1.13 quite many options have been renamed to make setting up Motion easier. From 3.1.17-18 some unfinished features have been removed. The Berkeley mpeg feature is now removed because the ffmpeg feature is now mature and much better working. At version 3.1.18 a new network camera feature was introduced replacing the old cURL based netcam code and introducing support of mjpeg streaming cameras. However this new code was quite difficult to get stable. During the development of 3.2.2 the network camera code was totally rewritten again learning from our experience and now finally it seems to be stable. +

        +-Motion is included in Debian, while Ubuntu and RPM users can find binary packages on the Motion Sourceforge file download page. ++Since 3.2.3 Debian users can find binary packages on the Motion Sourceforge file download page. You can find Debian versions of Motion in different Debian repositories but they are all out of date and hardly ever get updated. +

        +-

        What features does Motion have?

        +- See more description at the Motion Homepage.
          ++

          What features does Motion have?

          ++See more description at the Motion Homepage.
            +
          • Taking snapshots of movement +
          • Watch multiple video devices at the same time +
          • Watch multiple inputs on one capture card at the same time +@@ -253,63 +249,65 @@ Motion is included in Debian, while Ubun +
          • Real time creation of mpeg movies using libraries from ffmpeg +
          • Take automated snapshots on regular intervals +
          • Take automated snapshots at irregular intervals using cron +-
          • Executing external program when detecting movement +-
          • Execute external program at the beginning of an event of several motion detections. ++
          • Executing external program when detecting movement ++
          • Execute external program at the beginning of an event of several motion detections. +
          • Execute external program at the end of an event of several motion detections. +-
          • Execute external program when a picture is saved. +-
          • Execute external program when a movie mpeg is created (opened) ++
          • Execute external program when a picture is saved. ++
          • Execute external program when a movie mpeg is created (opened) +
          • Execite external program when a movie mpeg ends (closed) +
          • Motion tracking +
          • Feed events to an MySQL or PostgreSQL database. +
          • Feed video back to a video4linux loopback for real time viewing +-
          • Web interface using Motion Related Projects such as motion.cgi, Kenneths Webcam Package, Kevins Webpage, X-Motion and many more. +-
          • User configurable and user defined on screen display. +-
          • Control via simple web interface. +-
          • Automatic noise and threshold control +-
          • Ability to control the pan/tilt of a Logitech Sphere (or Orbit) camera +-
          • Highly configurable display of text on images. +-
          • High configurable definition of path and file names of the stored images and films. ++
          • Web interface using Motion Related Projects such as motion.cgi, Kenneths Webcam Package, Kevins Webpage, X-Motion and many more. ++
          • User configurable and user defined on screen display. ++
          • Control via simple web interface. ++
          • Automatic noise and threshold control ++
          • Ability to control the pan/tilt of a Logitech Sphere (or Orbit) camera ++
          • Highly configurable display of text on images. ++
          • High configurable definition of path and file names of the stored images and films. +
          +

          +-You can find more information and links at the Motion Homepage. ++You can find more information and links at the Motion Homepage. +

          +-

          FreeBSD

          ++

          FreeBSD

          +

          +-Motion is originally developed for Linux and it is still mainly developed and supported for this platform. From version 3.1.15 an experimental port has been made by Angel Carpintero. Not all features of Motion are supported at this time and it still needs a lot of test time on different hardware. Angel is very interested in feedback. Join the Motion Mailing List and give your feedback there. Patches for bugfixes and for enabling the missing features are very welcome. The rest of this guide is still mainly targeted for Linux users. Follow this topic to Install FreeBSD. ++Motion is originally developed for Linux and it is still mainly developed and supported for this platform. From version 3.1.15 an experimental port has been made by Angel Carpintero. Not all features of Motion are supported at this time and it still needs a lot of test time on different hardware. Angel is very interested in feedback. Join the Motion Mailing List and give your feedback there. Patches for bugfixes and for enabling the missing features are very welcome. The rest of this guide is still mainly targeted for Linux users. Follow this topic to Install FreeBSD. +

          +-

          MacOSX

          ++

          MacOSX

          +

          +-From Motion version 3.2.4 it is now also possible to build and install Motion under MacOSX. Feature set it the same as for FreeBSD. See the MacOSX topic for specific help how to install Motion and its dependencies on MacOSX. Again this port has been contributed by Angel Carpintero. ++From Motion version 3.2.4 it is now also possible to build and install Motion under MacOSX. Feature set it the same as for FreeBSD. See the MacOSX topic for specific help how to install Motion and its dependencies on MacOSX. Again this port has been contributed by Angel Carpintero. +

          +

          Documentation

          +- You have the following sources of information: ++You have the following sources of information: +

          +

          +

          Supported Hardware

          +- Input devices: Here we are thinking about the cameras. ++Input devices: Here we are thinking about the cameras. +

          + Motion supports video input from two kinds of sources. +

          + Standard video4linux devices (e.g. /dev/video0). Motion has no drivers for cameras. Installing the camera itself is outside the scope of this document. But here are some nice links.

          ++Network cameras (which are actually cameras with a built in web server that can be connected directory to your network). +

          +

          +-

          Known Problems

          +-See also the Frequently Asked Questions and Bug Reports for known open bugs. ++

          Known Problems

          ++See also the Frequently Asked Questions and Bug Reports for known open bugs. +

          +-Kernel 2.6 and pwc. Note that for kernel 2.6 there is a new release of the Philips WebCam (pwc) drivers 10.0.X. It is recommended to install this. At the time of this being written the 2.6.12+ kernels have a version of pwc built-in but it is a cripled version which can only support very small picture size. You can however download the latest source code of the pwc driver (at this time 10.0.11) and build it without having to rebuild your kernel. But you will need to have either the kernel sources or a special kernel-header package installed to compile it. See Installation of PWC page which is also hosted in this wiki. ++Kernel 2.6 and pwc. Note that for kernel 2.6 there is a new release of the Philips WebCam (pwc) drivers 10.0.X. It is recommended to install this. At the time of this being written the 2.6.12+ kernels have a version of pwc built-in but it is a cripled version which can only support very small picture size. You can however download the latest source code of the pwc driver (at this time 10.0.11) and build it without having to rebuild your kernel. But you will need to have either the kernel sources or a special kernel-header package installed to compile it. See Installation of PWC page which is also hosted in this wiki. +

          + If you use use a Logitech Quickcam Orbit or Sphere using the driver pwc/pwcx and kernel 2.6.X you should replace the file in the Motion sources called pwc-ioctl.h with the one that comes with the your pwc version. Motion is shipped with 3 versions of pwc-ioctl.h-VERSION. Rename the one that fits your major pwc version number best to pwc-ioctl.h (after renaming the current to something else). There has been some small adjustments in the API that requires that you have the right header file. +

          +@@ -323,8 +321,7 @@ The 3.2.5 release contains a motion_guid + A bug in 3.2.5 and 3.2.5.1 where a bugfix related to snapshot feature has created a new bug when you compile Motion without ffmpeg libs installed. This is fixed in 3.2.6. +

          +

          +-

          +-

          How do I install Motion?

          ++

          How do I install Motion?

          + Motion is mainly distributed as source files that you must compile yourself. There is also an RPM made on Fedora Core 3. And Debian packages are available for selected versions. +

          + The short overview of the steps to install Motion from sources.

            +@@ -389,60 +386,28 @@ motion +
          +

          +

          +-

          Preparation For Install

          ++

          Preparation For Install

          +

          +-Note: If you're using SuSE 9.2, you might want to ADDITIONALLY have a look at Compiling on SuSE 9.2. As mentioned on that page as well, you will still need to read the instructions here as well. ++Note: If you're using SuSE 9.2, you might want to ADDITIONALLY have a look at Compiling on SuSE 9.2. As mentioned on that page as well, you will still need to read the instructions here as well. +

          + Before you start you may need to install a number of shared libraries that Motion uses. If they are missing the feature will simply normally not be included. Most of these libraries can be found on the CDs of your distribution. A few will have to be downloaded from the Internet. Note that when you install software using pre-compiled binaries (Redhat type RPMs, Debian debs etc) you normally only get what is needed to run the programs themselves. In order to compile other programs from source that uses these pre-compiled libraries you also need to installed the development packages. These are normally called the same name as the package suffixed by -devel or -dev. These development packages contains the header files (xxx.h) that Motion needs to build with the shared libraries. If you build a library from sources you already have these header files. It is recommended to simply install the pre-compiled binary packages and their development brothers. +

          + This is a list of shared libraries used by Motion and the RPM packages that provides them. +

          + Motion will always need these libraries to be built and work +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
          Library RPM Packages Debian Packages
          libm, libresolv, libdl, libpthread, libc, ld-linux, libcrypt, and libnsl glibc and glibc-devel libc6 , libc6-dev ,libglib1.2
          libjpeg libjpeg and libjpeg-devel libjpeg62 and libjpeg62-dev ( optional libjpeg-mmx-dev )
          libz zlib and zlib-devel zlib1g and zlib1g-dev
          ++ ++ ++ ++ ++
          Library RPM Packages Debian Packages
          libm, libresolv, libdl, libpthread, libc, ld-linux, libcrypt, and libnsl glibc and glibc-devel libc6 , libc6-dev ,libglib1.2
          libjpeg libjpeg and libjpeg-devel libjpeg62 and libjpeg62-dev ( optional libjpeg-mmx-dev )
          libz zlib and zlib-devel zlib1g and zlib1g-dev
          +

          + For generating mpeg films with ffmpeg you need this library:
          +-(See also the section Generating MPEG films with ffmpeg for how to install ffmpeg and libavformat/libavcodec)
          ++(See also the section Generating MPEG films with ffmpeg for how to install ffmpeg and libavformat/libavcodec)
          + Motion must be installed with revision 0.4.8 or 0.4.9pre1 of ffmpeg. Motion will also work with later CVS snapshots of ffmpeg but the API of the ffmpeg libraries changes all the time and without warning. If you have problems compiling Motion or with running an RPM of Motion you may try with an older CVS snapshot of ffmpeg. The Motion developers will like to know when ffmpeg changes and breaks Motion so we can fix it. Please file a bug report then with the exact date of the ffmpeg CVS version you have trouble with. +

          +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
          Library RPM Packages Debian Packages
          libavcodec, libavformat ffmpeg and ffmpeg-devel or install from source libavcodec-dev libavcodec0d libavformat-dev libavformat0d (*)
          ++ ++ ++
          Library RPM Packages Debian Packages
          libavcodec, libavformat ffmpeg and ffmpeg-devel or install from source libavcodec-dev libavcodec0d libavformat-dev libavformat0d (*)
          +

          + Debian has not provided deb packages for ffmpeg due patent issues. However this is about to change so checkout for availability of newer versions of debian ffmpeg debs. You can build yourself from source or from Christian Marillat website or apt repository. +

          +@@ -457,41 +422,17 @@ apt-get update ; apt-get -y install liba
          + 
          +

          + For logging in MySQL you need this library: +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
          Library RPM Packages Debian Packages
          libmysqlclient mysql and mysql-devel libmysqlclient15-off and libmysqlclient15-dev
          ++ ++ ++
          Library RPM Packages Debian Packages
          libmysqlclient mysql and mysql-devel libmysqlclient15-off and libmysqlclient15-dev
          +

          + For logging in PostgreSQL you need this library: +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
          Library RPM Packages Debian Packages
          libpq postgresql-libs and postgresql-devel libpq-dev and libpq4
          ++ ++ ++
          Library RPM Packages Debian Packages
          libpq postgresql-libs and postgresql-devel libpq-dev and libpq4
          +

          +

          +-

          Configure Script

          ++

          Configure Script

          + Configure is script that you run to setup the build environment for the C-compiler. It generates the "Makefile" which the program "make" uses to compile and install the software. +

          + To run configure your current directory must be the motion directory. You type +@@ -503,238 +444,61 @@ You can add the parameter ./config + This is walk through of the options. +

          + +-

          +-
          ++ ++
          + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
          Option Description
          Defaults for the options
          are specified in brackets [ ]
          Editors comment
          -h, --help display this help and exit  
          --help=short display options specific to this package This command shows the options special to motion. Recommended
          --help=recursive display the short help of all the included packages  
          -V, --version display version information and exit Gives no useful information
          -q, --quiet, --silent do not print `checking...' messages Not very useful. Output to screen is only a few lines anyway.
          --cache-file=FILE cache test results in FILE. [disabled] No function
          -C, --config-cach alias for `--cache-file=config.cache' No function
          -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk
          --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory.
          Installation directories:    
          --prefix=PREFIX install architecture-independent files in PREFIX
          [/usr/local]
          The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
          If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
          This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
          If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
          Example: --prefix=$HOME
          --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
          [PREFIX]
          If you set this it only defines an alternative installation directory for the executable binary.
          Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
          Editor recommends leaving this as default (i.e. not setting it).
          --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control.
          --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it.
          --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it.
          --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it.
          --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
          Motion searches for the configuration file "motion.conf" in the following order:

            1. Current directory from where motion was invoked
            2. $HOME/.motion
            3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/

          Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again.
          --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it.
          --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it.
          --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it.
          --includedir=DIR C header files [PREFIX/include] Not used by motion. Ignore it.
          --oldincludedir=DIR C header files for non-gcc [/usr/include] Not used by motion. Ignore it.
          --infodir=DIR info documentation [PREFIX/info] Not used by motion. Ignore it.
          --mandir=DIR man documentation [PREFIX/man] Editor recommends the default.
          Optional Packages:    
          --with-linuxthreads Use linuxthreads in BSD instead of native phtreads Only relevant for BSD. In Linux we always use this per default.
          --with-pwcbsd Use pwcbsd based webcams ( only BSD ) This option allow to build motion to support V4L/V4L2 in BSD.
          HowtoMotionPwcFreeBSD
          --without-bktr Exclude to use bktr subsystem , that usually useful for devices as network cameras ONLY used in *BSD
          --without-v4l Exclude using v4l (video4linux) subsystem. Makes Motion so it only supports network cameras. Can be used if you do not need V4L support and maybe lack some of the libraries for it.
          --with-jpeg-mmx=DIR Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling (optional). If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. Considered experimental
          --with-ffmpeg=DIR Specify the path for the directory prefix in which the library and headers are installed.
          If not specified configure will search in /usr/ and /usr/local/
          DIR is the directory PREFIX in which the ffmpeg shared libraries and their headers are installed.
          If you install ffmpeg from sources and use the default directories or if ffmpeg is installed as a binary package (RPM or deb) you do not need to specify the directory prefix. Configure will find the libraries automatically. If you installed ffmpeg from sources and specified a different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR).
          For more information on FFmpeg see the FFmpeg project home page.
          FFmpeg is a package that enables streamed video mpeg signal from your web camera to a browser.
          Editor recommends installing ffmpeg from source and in the directory /usr/local/ffmpeg and build ffmpeg with ./configure --enable-shared.
          This places libraries in /usr/local/lib and headers in /usr/local/include.
          --without-ffmpeg Do not compile with ffmpeg Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg.
          --with-mysql-lib=DIR Lib directory of MySQL Normally, configure will scan all possible default installation paths for MySQL libs. When its fail, use this command to tell configure where MySQL libs installation root directory is.
          --with-mysql-include=DIR Include directory with headers for MySQL Normally, configure will scan all possible default installation paths for MySQL include. When its fail, use this command to tell configure where MySQL include installation directory is. This is the directory with the MySQL header files.
          --without-mysql Do not compile with MySQL support Use this if you do not want to include MySQL support in the package.
          This can also be useful if you get compilation errors related to MySQL and you actually do not need the feature anyway.
          --without-pgsql Do not compile with PostgreSQL support Use this if you do not want to include PostgreSQL support in the package.
          This can also be useful if you get compilation errors related to PostgreSQL and you actually do not need the feature anyway.
          --with-pgsql-include=DIR Normally, configure will scan all possible default installation paths for pgsql include. When it fails, use this command to tell configure where pgsql include installation root directory is.  
          --with-pgsql-lib=DIR Normally, configure will scan all possible default installation paths for pgsql libs. When it fails, use
          this command to tell configure where pgsql libs installation root directory is.
           
          --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. Use this if the optimization causes problems. Typically if you build on some non X386 compatible CPU.
          Developers options    
          --with-developer-flags Add additional warning flags for the compiler. This option is for developers only. It produces a flood of warnings that helps the developer to write more robust code. These warnings are normally harmless but can sometimes be a latent defect.
          For more information about these flags, see CompileWithDeveloperFlags
          +- +- +- +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
          Option Description
          Defaults for the options
          are specified in brackets [ ]
          Editors comment
          -h, --help display this help and exit  
          --help=short display options specific to this package This command shows the options special to motion. Recommended
          --help=recursive display the short help of all the included packages  
          -V, --version display version information and exit Gives no useful information
          -q, --quiet, --silent do not print `checking...' messages Not very useful. Output to screen is only a few lines anyway.
          --cache-file=FILE cache test results in FILE. [disabled] No function
          -C, --config-cach alias for `--cache-file=config.cache' No function
          -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk
          --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory.
          Installation directories:    
          --prefix=PREFIX install architecture-independent files in PREFIX
          [/usr/local]
          The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
          If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
          This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
          If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
          Example: --prefix=$HOME
          --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
          [PREFIX]
          If you set this it only defines an alternative installation directory for the executable binary.
          Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
          Editor recommends leaving this as default (i.e. not setting it).
          --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control.
          --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it.
          --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it.
          --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it.
          --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
          Motion searches for the configuration file "motion.conf" in the following order:

            1. Current directory from where motion was invoked
            2. $HOME/.motion
            3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/

          Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again.
          --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it.
          --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it.
          --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it.
          --includedir=DIR C header files [PREFIX/include] Not used by motion. Ignore it.
          --oldincludedir=DIR C header files for non-gcc [/usr/include] Not used by motion. Ignore it.
          --infodir=DIR info documentation [PREFIX/info] Not used by motion. Ignore it.
          --mandir=DIR man documentation [PREFIX/man] Editor recommends the default.
          Optional Packages:    
          --with-ffmpeg=DIR Specify the path for the directory prefix in which the library and headers are installed.
          If not specified configure will search in /usr/ and /usr/local/
          DIR is the directory PREFIX in which the ffmpeg shared libraries and their headers are installed.
          If you install ffmpeg from sources and use the default directories or if ffmpeg is installed as a binary package (RPM or deb) you do not need to specify the directory prefix. Configure will find the libraries automatically. If you installed ffmpeg from sources and specified a different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR).
          For more information on FFmpeg see the FFmpeg project home page.
          FFmpeg is a package that enables streamed video mpeg signal from your web camera to a browser.
          Editor recommends installing ffmpeg from source and in the directory /usr/local/ffmpeg and build ffmpeg with ./configure --enable-shared.
          This places libraries in /usr/local/lib and headers in /usr/local/include.
          --without-ffmpeg Do not compile with ffmpeg Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg.
          --with-mysql-lib=DIR Lib directory of MySQL Normally, configure will scan all possible default installation paths for MySQL libs. When its fail, use this command to tell configure where MySQL libs installation root directory is.
          --with-mysql-include=DIR Include directory with headers for MySQL Normally, configure will scan all possible default installation paths for MySQL include. When its fail, use this command to tell configure where MySQL include installation directory is. This is the directory with the MySQL header files.
          --without-mysql Do not compile with MySQL support Use this if you do not want to include MySQL support in the package.
          This can also be useful if you get compilation errors related to MySQL and you actually do not need the feature anyway.
          --with-pgsql=DIR Include PostgreSQL support. DIR is the PostgreSQL base install directory, defaults to /usr/local/pgsql.
          Set DIR to "shared" to build as a dynamic library, or "shared,DIR" to build as a dynamic library and still specify DIR.
          Default is that make searches in the normal installation directories of most distributions.
          See section later about PostgreSQL about potential problem during compilation. There is an easy workaround for it.
          --without-pgsql Do not compile with PostgreSQL support Use this if you do not want to include PostgreSQL support in the package.
          This can also be useful if you get compilation errors related to PostgreSQL and you actually do not need the feature anyway.
          --without-v4l Exclude using v4l (video4linux) subsystem. Makes Motion so it only supports network cameras. Can be used if you do not need V4L support and maybe lack some of the libraries for it.
          --with-linuxthreads Use linuxthreads in BSD instead of native phtreads Only relevant for BSD. In Linux we always use this per default.
          --without-bktr Exclude to use bktr subsystem , that usually useful for devices as network cameras ONLY used in *BSD
          --with-jpeg-mmx=DIR Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling (optional). If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. Considered experimental
          --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. Use this if the optimization causes problems. Typically if you build on some non X386 compatible CPU.
          Developers options    
          --with-developer-flags Add additional warning flags for the compiler. This option is for developers only. It produces a flood of warnings that helps the developer to write more robust code. These warnings are normally harmless but can sometimes be a latent defect.
          For more information about these flags, see CompileWithDeveloperFlags
          ++ ++ +
          +

          +-

          +-

          Make

          ++

          Make

          + When you run make, all the C-source files are automatically compiled and linked. Just look out for error messages. +

          + Make uses a file called "Makefile" which is generated by the "configure" script you just ran. If you have special needs you can manually edit this file. Next time you run configure a new Makefile will be generated and your changes are lost. +

          +-ALERT! Attention! ++ALERT! Attention! +

          + If you have run make before, you should run a make clean before running make again. This cleans out all the object files that were generated the previous time you ran make. If you do not run make clean first before you rebuild Motion you may not get the additional feature included. For example: If you built Motion without ffmpeg support and then add it later - and rebuild Motion without running make clean first - the ffmpeg feature does not get compiled into the Motion binary. +

          +@@ -775,8 +539,9 @@ The make command can be run with several + +

          +

          +-

          Upgrading From Older Version

          +- If you are upgrading from motion 3.0.X or from an older version of 3.1.X you should note that many options have been removed from version 3.1.13 and forward and many new have arrived. You still have most of the old features. The options have been changed for two reasons. New more flexible features and to simplify getting started with Motion. With 3.2.1 the changes are significant. You should also note these major differences.
            ++

            Upgrading From Older Version

            ++If you are upgrading from motion 3.0.X or from an older version of 3.1.X you should note that many options have been removed from version 3.1.13 and forward and many new have arrived. You still have most of the old features. The options have been changed for two reasons. New more flexible features and to simplify getting started with Motion. With 3.2.1 the changes are significant. ++You should also note these major differences.
              +
            • The use of thread files has completely changed. Read the section "The Config Files" carefully. +
            • The mask file format has changed. Read the section about "Mask File" +
            • Pre_capture feature introduced in 3.1.12 +@@ -807,213 +572,67 @@ The make command can be run with several +
            • New feature: ffmpeg_deinterlace which can de-interlace using the ffmpeg libs (3.2.5) +
            • New feature: minimum_frame_time which enables Motion to run at frame rates below 2. minimum_gap feature was removed since this was useless and the new minimum_frame_time feature replaces it with much better function. (3.2.7) +
            • New feature: process_id_file which writes a PID file when started and removes it when stopped (3.2.7) +-
            • V4L2 support with many new supported palettes : V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_UYVY (3.2.8) ++
            • V4L2 support with many new supported palettes : V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_UYVY (3.2.8) +
            • ffmpeg_video_codec allow swf (3.2.8) +-
            • V4L2 fix support for : V4L2_PIX_FMT_MJPEG (3.2.9) ++
            • V4L2 fix support for : V4L2_PIX_FMT_MJPEG (3.2.9) +
            • ffmpeg_video_codec allow flv and ffv1(3.2.9) +-
            • v4l2_palette: allow to choose preferable palette to be use by motion to capture from those supported by your videodevice. +-
            • netcam_http: setup keep_alive , 1.1 or 1.0 http method to be used by netcam. +-
            • on_camera_lost: Command to be executed when a camera can't be opened or if it is lost. +-
            • AreaDetect, on_area_detected: Command to be executed by area_detect trigger. +-
            • ConfigOptionNetcamTolerantCheck , netcam_tolerant_check less strict jpeg checks for network cameras with a poor/buggy firmware ( 3.2.11 ). +
            +

            +-The table below shows the new options in the left column, and obsolete options in the right column. If the there are options on both sides in a row it means that the options in the left column replaced the options in the right column. +

            ++The table below shows the new options in the left column, and obsolete options in the right column. If the there are options on both sides in a row it means that the options in the left column replaced the options in the right column. +

            +-

            +-
            ++ ++
            + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
            New Options Obsolete Options
            text_left (3.1.13)
            text_right (3.1.13)
            text_changes (3.1.13)
            drawtext_user (3.1.13)
            drawtext_shots (3.1.13)
            drawtext_changes (3.1.13)
            jpeg_filename (3.1.13)
            ffmpeg_filename (3.1.13)
            snapshot_filename (3.1.13)
            timelapse_filename (3.1.13)
            predict_filename (3.1.13)
            (predict_filename removed in 3.1.18)
            oldlayout (3.1.13)
            snapshots_overwrite (3.1.13)
            snapshot_interval (3.1.13) snapshots (3.1.13)
              realmotion (3.1.13)
            despeckle (3.1.13)  
            pre_capture (3.1.12)  
            ffmpeg_timelapse (v. 3.1.14) ffmpeg_timelaps (renamed v 3.1.14)
            ffmpeg_timelapse_mode (3.1.14)  
            sql_log_image (3.1.14)
            sql_log_snapshot (3.1.14)
            sql_log_mpeg (3.1.14)
            sql_log_timelapse (3.1.14)
            sql_log_prediction (3.1.14)
             
            minimum_motion_frames (3.1.14)  
            rotate (3.1.15)  
            ffmpeg_variable_bitrate (3.1.15)
            ffmpeg_video_codec (3.1.15)
             
              berkeley_single_directory (3.1.18)
            mpeg_encode (3.1.18)
            mpeg_encode_bin (3.1.18)
            adjust_rate off (3.1.18)
            jpg_cleanup (3.1.18)
              predict_filename (3.1.18)
            predict_enable (3.1.18)
            predict_threshold (3.1.18)
            predict_description (3.1.18)
            sql_log_prediction (3.1.18)
            brightness (3.1.18)
            contrast (3.1.18)
            saturation (3.1.18)
            hue (3.1.18)
             
            smart_mask_speed (3.1.18)  
            output_normal
            valid values are now "on", "off", "first" (3.1.18) and "best" (3.2.1)
             
            setup_mode (3.2.1) always_changes (3.2.1)
            locate
            valid values are now "on", "off", "preview" (3.2.1)
             
            jpeg_filename
            Besides normal path names the value "preview" has speciel meaning together with output_normal = "best" (3.2.1)
             
            control_html_output (3.2.1)  
            on_event_start (3.2.1) execute (3.2.1)
            sms (3.2.1)
            mail (3.2.1)
            on_event_end (3.2.1)  
            on_motion_detected (3.2.1)  
            on_picture_save (3.2.1) onsave (3.2.1)
            on_movie_start (3.2.1)
            on_movie_end (3.2.1)
            onmpeg (3.2.1)
            onffmpegclose (introduced 3.1.13)(renamed to on_movie_end 3.2.1)
            netcam_proxy (3.2.2)  
            text_double (3.2.2)  
            webcam_motion
            Feature has been heavily improved so it is actually usefull now (3.2.2).
             
            netcam_url
            Now also supports fetching single frame jpeg pictures via ftp using ftp:// syntax (3.2.4)
             
            track_step_angle_x (3.2.4)
            track_step_angle_y (3.2.4)
            Add better configuration of auto tracking with a Logitech Sphere/Orbit camera.
             
            track_move_wait (3.2.4)
            track_auto (3.2.4)
            Adds better configuration of auto tracking feature
             
            sql_query (3.2.4)
            Adds full flexibility of defining fields when using the SQL database features.
             
            track_maxy (3.2.5)
            track_motory (3.2.5)
             
            movie_filename (3.2.5) ffmpeg_filename (3.2.5)
            ffmpeg_deinterlace (3.2.5)  
            minimum_frame_time (3.2.7) minimum_gap (3.2.7)
            process_id_file (3.2.7)  
            ffmpeg_video_codec allow swf (3.2.8)  
            ffmpeg_video_codec allow flv and ffv1 (3.2.9)  
            v4l2_palette (3.2.10)
            netcam_http (3.2.10)
            on_camera_lost (3.2.10)
            area_detect, on_area_detected(3.2.10)
            ffmpeg_video_codec mov(3.2.10)
            output_normal center(3.2.10)
             
              night_compensate (3.2.10)
            low_cpu (3.2.10)
            netcam_tolerant_check (3.2.11)  
            +- +- +- +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
            New Options Obsolete Options
            text_left (3.1.13)
            text_right (3.1.13)
            text_changes (3.1.13)
            drawtext_user (3.1.13)
            drawtext_shots (3.1.13)
            drawtext_changes (3.1.13)
            jpeg_filename (3.1.13)
            ffmpeg_filename (3.1.13)
            snapshot_filename (3.1.13)
            timelapse_filename (3.1.13)
            predict_filename (3.1.13)
            (predict_filename removed in 3.1.18)
            oldlayout (3.1.13)
            snapshots_overwrite (3.1.13)
            snapshot_interval (3.1.13) snapshots (3.1.13)
              realmotion (3.1.13)
            despeckle (3.1.13)  
            pre_capture (3.1.12)  
            ffmpeg_timelapse (v. 3.1.14) ffmpeg_timelaps (renamed v 3.1.14)
            ffmpeg_timelapse_mode (3.1.14)  
            sql_log_image (3.1.14)
            sql_log_snapshot (3.1.14)
            sql_log_mpeg (3.1.14)
            sql_log_timelapse (3.1.14)
            sql_log_prediction (3.1.14)
             
            minimum_motion_frames (3.1.14)  
            rotate (3.1.15)  
            ffmpeg_variable_bitrate (3.1.15)
            ffmpeg_video_codec (3.1.15)
             
              berkeley_single_directory (3.1.18)
            mpeg_encode (3.1.18)
            mpeg_encode_bin (3.1.18)
            adjust_rate off (3.1.18)
            jpg_cleanup (3.1.18)
              predict_filename (3.1.18)
            predict_enable (3.1.18)
            predict_threshold (3.1.18)
            predict_description (3.1.18)
            sql_log_prediction (3.1.18)
            brightness (3.1.18)
            contrast (3.1.18)
            saturation (3.1.18)
            hue (3.1.18)
             
            smart_mask_speed (3.1.18)  
            output_normal
            valid values are now "on", "off", "first" (3.1.18) and "best" (3.2.1)
             
            setup_mode (3.2.1) always_changes (3.2.1)
            locate
            valid values are now "on", "off", "preview" (3.2.1)
             
            jpeg_filename
            Besides normal path names the value "preview" has speciel meaning together with output_normal = "best" (3.2.1)
             
            control_html_output (3.2.1)  
            on_event_start (3.2.1)
            execute (3.2.1)
            sms (3.2.1)
            mail (3.2.1)
            on_event_end (3.2.1)
             
            on_motion_detected (3.2.1)
             
            on_picture_save (3.2.1)
            onsave (3.2.1)
            on_movie_start (3.2.1)
            on_movie_end (3.2.1)
            onmpeg (3.2.1)
            onffmpegclose (introduced 3.1.13)(renamed to on_movie_end 3.2.1)
            netcam_proxy (3.2.2)  
            text_double (3.2.2)  
            webcam_motion
            Feature has been heavily improved so it is actually usefull now (3.2.2).
             
            netcam_url
            Now also supports fetching single frame jpeg pictures via ftp using ftp:// syntax (3.2.4)
             
            track_step_angle_x (3.2.4)
            track_step_angle_y (3.2.4)
            Add better configuration of auto tracking with a Logitech Sphere/Orbit camera.
             
            track_move_wait (3.2.4)
            track_auto (3.2.4)
            Adds better configuration of auto tracking feature
             
            sql_query (3.2.4)
            Adds full flexibility of defining fields when using the SQL database features.
             
            track_maxy (3.2.5)
            track_motory (3.2.5)
             
            movie_filename (3.2.5) ffmpeg_filename (3.2.5)
            ffmpeg_deinterlace (3.2.5)  
            minimum_frame_time (3.2.7) minimum_gap (3.2.7)
            process_id_file (3.2.7)  
            ffmpeg_video_codec allow swf (3.2.8)  
            ffmpeg_video_codec allow flv and ffv1 (3.2.9)  
              night_compensate (3.2.10)
            low_cpu (3.2.10)
            ++ ++ +
            +

            +-

            +-

            Running Motion

            ++

            Running Motion

            +

            +

            Important Definitions

            + Motion is invoked from the command line. It has no GUI. Everything is controlled from config files. From version 3.2 the command line is only used to define location of config file and a few special runtime modes (setup and non-daemon). +@@ -1063,75 +682,40 @@ Motion reads its configuration parameter + + So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. +

            +-Nearly all config options can be unique for a specific camera and placed in a thread config file. There are a few options that must be in motion.conf and cannot be in a thread config file: control_authentication, control_html_output, control_localhost, control_port, daemon, and thread. ++Nearly all config options can be unique for a specific camera and placed in a thread config file. There are a few options that must be in motion.conf and cannot be in a thread config file: control_authentication, control_html_output, control_localhost, control_port, daemon, and thread. +

            + If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. +

            + If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. +

            +

            +-

            Command Line Options

            ++

            Command Line Options

            +

            +-ALERT! In Motion 3.2.1 and forward most command line options have been removed and replaced them by an option to specify location to motion.conf and a few options related to setting up motion. There are now only few command line options left and they are basically all new. ++ALERT! In Motion 3.2.1 and forward most command line options have been removed and replaced them by an option to specify location to motion.conf and a few options related to setting up motion. There are now only few command line options left and they are basically all new. +

            + SYNOPSIS +

            +-motion [ -hns ] [ -c config file path ] [ -d level ]  [ -p process_id_file ]
            ++motion [ -hns ] [ -c config file path]
            + 
            +

            +-

            +-
            ++ ++
            + + +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
            Option Description Editors comment
            -n Run in non-daemon mode. Instead of running Motion in the background Motion runs in the terminal window writing messages when things happen. If you have problems getting Motion to start or work, run Motion in this mode to get more messages that can help you solve the problem.
            -s Run in setup mode. Also forces non-daemon mode
            -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default
            -h Show help screen.  
            -d level Debugging mode This mode is used for developers to enable debug messages. Normal users will not need to use this mode unless a developer request to get additional information in the attempt to resolve a bug. Mainly the netcam code has debugging features. The level defines how much debugging info you get. A high number displays all debugging.
            -p process_id_file Full path of process ID file Full path and filename of process id file (PID file). This is optional. If none is given as command line option or in motion.conf (process_id_file) Motion will not create a PID file.
            +- +- +- +- ++ ++ ++ ++ ++ ++ ++ ++
            Option Description Editors comment
            -n Run in non-daemon mode. Instead of running Motion in the background Motion runs in the terminal window writing messages when things happen. If you have problems getting Motion to start or work, run Motion in this mode to get more messages that can help you solve the problem.
            -s Run in setup mode. Also forces non-daemon mode
            -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default
            -h Show help screen.  
            -d level Debugging mode This mode is used for developers to enable debug messages. Normal users will not need to use this mode unless a developer request to get additional information in the attempt to resolve a bug. Mainly the netcam code has debugging features. The level defines how much debugging info you get. A high number displays all debugging.
            -p process_id_file Full path of process ID file Full path and filename of process id file (PID file). This is optional. If none is given as command line option or in motion.conf (process_id_file) Motion will not create a PID file.
            ++ ++ +
            +

            +

            +-

            +-

            Config File Options

            ++

            Config File Options

            + These are the options that can be used in the config file. +

            + All number values are integer numbers (no decimals allowed). Boolean options can be on or off. +@@ -1150,663 +734,138 @@ FFMPEG (libavcodec)

              +
            • ffmpeg_cap_new, ffmpeg_cap_motion, ffmpeg_filename, ffmpeg_timelapse, ffmpeg_timelapse_mode, ffmpeg_bps, ffmpeg_variable_bitrate, ffmpeg_video_codec +
            +

            +-

            Options in Alphabetical Order.

            ++

            Options in Alphabetical Order.

            +

            + The table below lists all the Motion options in alphabetical order. Click on the option name to see a longer description of each. +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
            Option Range/Values
            Default
            Description
            area_detect Values: 1 - 999999999
            Default: Not defined
            Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area.
            auto_brightness Values: on, off
            Default: off
            Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness
            brightness Values: 0 - 255
            Default: 0 (disabled)
            The brightness level for the video device.
            contrast Values: 0 - 255
            Default: 0 (disabled)
            The contrast level for the video device.
            control_authentication Values: Max 4096 characters
            Default: Not defined
            To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file.
            control_html_output Values: on, off
            Default: on
            Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file.
            control_localhost Values: on, off
            Default: on
            Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file.
            control_port Values: 0 - 65535
            Default: 0 (disabled)
            Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file.
            daemon Values: on, off
            Default: off
            Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file.
            despeckle Values: EedDl
            Default: Not defined
            Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling.
            ffmpeg_bps Values: 0 - 9999999
            Default: 400000
            Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed.
            ffmpeg_cap_motion Values: on, off
            Default: off
            Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes.
            ffmpeg_cap_new Values: on, off
            Default: off
            Use ffmpeg libraries to encode mpeg movies in realtime.
            ffmpeg_deinterlace Values: on, off
            Default: off
            Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures.
            ffmpeg_filename (now called movie_filename) Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S
            File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution.
            ffmpeg_timelapse Values: 0 - 2147483647
            Default: 0 (disabled)
            Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
            ffmpeg_timelapse_mode Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual
            Default: daily
            The file rollover mode of the timelapse video.
            ffmpeg_variable_bitrate Values: 0, 2 - 31
            Default: 0 (disabled)
            Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst.
            ffmpeg_video_codec Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1, mov
            Default: mpeg4
            Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option.
            framerate Values: 2 - 100
            Default: 100 (no limit)
            Maximum number of frames to be captured from the camera per second.
            frequency Values: 0 - 999999
            Default: 0 (Not set)
            The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it)
            gap Values: 0 - 2147483647
            Default: 60
            Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe.
            height Values: Device Dependent
            Default: 288
            The height of each frame in pixels.
            hue Values: 0 - 255
            Default: 0 (disabled)
            The hue level for the video device.
            input Values: 0 - 7, 8 = disabled
            Default: 8 (disabled)
            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.
            jpeg_filename Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S-%q
            File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file.
            lightswitch Values: 0 - 100
            Default: 0 (disabled)
            Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity.
            locate Values: on, off, preview
            Default: off
            Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie.
            mask_file Values: Max 4095 characters
            Default: Not defined
            PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format.
            max_mpeg_time Values: 0 (infinite) - 2147483647
            Default: 3600
            The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length.
            minimum_frame_time Values: 0 - 2147483647
            Default: 0
            Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate.
            minimum_motion_frames Values: 1 - 1000s
            Default: 1
            Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5.
            motion_video_pipe Values: Max 4095 characters
            Default: Not defined
            The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set
            movie_filename Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S
            File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename.
            mysql_db Values: Max 4095 characters
            Default: Not defined
            Name of the MySQL database.
            mysql_host Values: Max 4095 characters
            Default: localhost
            IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server.
            mysql_password Values: Max 4095 characters
            Default: Not defined
            The MySQL password.
            mysql_user Values: Max 4095 characters
            Default: Not defined
            The MySQL user name.
            netcam_http Values: 1.0, keep_alive, 1.1
            Default: 1.0
            The setting for keep-alive of network socket, should improve performance on compatible net cameras. ( new in 3.2.10 )
            netcam_proxy Values: Max 4095 characters
            Default: Not defined
            URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber
            netcam_tolerant_check Values: on, off
            Default: off
            Set less strict jpeg checks for network cameras with a poor/buggy firmware.
            netcam_url Values: Max 4095 characters
            Default: Not defined
            Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera.
            netcam_userpass Values: Max 4095 characters
            Default: Not defined
            For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication.
            noise_level Values: 1 - 255
            Default: 32
            The noise level is used as a threshold for distinguishing between noise and motion.
            noise_tune Values: on, off
            Default: on
            Activates the automatic tuning of noise level.
            norm Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour)
            Default: 0 (PAL)
            Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
            on_area_detected Values: Max 4095 characters
            Default: Not defined
            Command to be executed when motion in a predefined area is detected. Check option area_detect.
            on_camera_lost Values: Max 4095 characters
            Default: Not defined
            Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10)
            on_event_end Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.
            on_event_start Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command.
            on_motion_detected Values: Max 4095 characters
            Default: Not defined
            Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command.
            on_movie_end Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
            on_movie_start Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
            on_picture_save Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
            output_all Values: on, off
            Default: off
            Picture are saved continuously as if motion was detected all the time.
            output_motion Values: on, off
            Default: off
            Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red.
            output_normal Values: on, off, first, best, center (since 3.2.10)
            Default: on
            Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored.
            pgsql_db Values: Max 4095 characters
            Default: Not defined
            Name of the PostgreSQL database.
            pgsql_host Values: Max 4095 characters
            Default: localhost
            IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server.
            pgsql_password Values: Max 4095 characters
            Default: Not defined
            The PostgreSQL password.
            pgsql_port Values: 0 - 65535
            Default: 5432
            The PostgreSQL server port number.
            pgsql_user Values: Max 4095 characters
            Default: Not defined
            The PostgreSQL user name.
            post_capture Values: 0 - 2147483647
            Default: 0 (disabled)
            Specifies the number of frames to be captured after motion has been detected.
            ppm Values: on, off
            Default: off
            Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg.
            pre_capture Values: 0 - 100s
            Default: 0 (disabled)
            Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.
            process_id_file Values: Max 4095 characters
            Default: Not defined
            File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid
            quality Values: 1 - 100
            Default: 75
            The quality for the jpeg images in percent.
            quiet Values: on, off
            Default: off
            Be quiet, don't output beeps when detecting motion.
            rotate Values: 0, 90, 180, 270
            Default: 0 (not rotated)
            Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies.
            roundrobin_frames Values: 1 - 2147483647
            Default: 1
            Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible.
            roundrobin_skip Values: 1 - 2147483647
            Default: 1
            Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe).
            saturation Values: 0 - 255
            Default: 0 (disabled)
            The colour saturation level for the video device.
            setup_mode Values: on, off
            Default: off
            Run Motion in setup mode.
            smart_mask_speed Values: 0 - 10
            Default: 0 (disabled)
            Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast.
            snapshot_filename Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S-snapshot
            File path for snapshots (jpeg or ppm) relative to target_dir.
            snapshot_interval Values: 0 - 2147483647
            Default: 0 (disabled)
            Make automated snapshots every 'snapshot_interval' seconds.
            sql_log_image Values: on, off
            Default: on
            Log to the database when creating motion triggered image file.
            sql_log_mpeg Values: on, off
            Default: off
            Log to the database when creating motion triggered mpeg file.
            sql_log_snapshot Values: on, off
            Default: on
            Log to the database when creating a snapshot image file.
            sql_log_timelapse Values: on, off
            Default: off
            Log to the database when creating timelapse mpeg file
            sql_query Values: Max 4095 characters
            Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
            SQL query string that is sent to the database. The values for each field are given by using convertion specifiers
            switchfilter Values: on, off
            Default: off
            Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection.
            target_dir Values: Max 4095 characters
            Default: Not defined = current working directory
            Target directory for picture and movie files.
            text_changes Values: on, off
            Default: off
            Turns the text showing changed pixels on/off.
            text_double Values: on, off
            Default: off
            Draw characters at twice normal size on images.
            text_event Values: Max 4095 characters
            Default: %Y%m%d%H%M%S
            This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event.
            text_left Values: Max 4095 characters
            Default: Not defined
            User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %).
            text_right Values: Max 4095 characters
            Default: %Y-%m-%d\n%T
            User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
            thread Values: Max 4095 characters
            Default: Not defined
            Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file.
            threshold Values: 1 - 2147483647
            Default: 1500
            Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling.
            threshold_tune Values: on, off
            Default: off
            Activates the automatic tuning of threshold level. ( It's broken )
            timelapse_filename Values: Max 4095 characters
            Default: %v-%Y%m%d-timelapse
            File path for timelapse mpegs relative to target_dir (ffmpeg only).
            track_auto Values: on, off
            Default: off
            Enable auto tracking
            track_iomojo_id Values: 0 - 65535
            Default: 0
            Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller.
            track_maxx Values: 0 - 65535
            Default: 0
            The maximum position for servo x.
            track_maxy Values: 0 - 65535
            Default: 0
            The maximum position for servo y.
            track_motorx Values: 0 - 65535
            Default: 0
            The motor number that is used for controlling the x-axis.
            track_motory Values: 0 - 65535
            Default: 0
            The motor number that is used for controlling the y-axis.
            track_move_wait Values: 0 - 65535
            Default: 10
            Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames.
            track_port Values: Max 4095 characters
            Default: Not defined
            This is the device name of the serial port to which the stepper motor interface is connected.
            track_speed Values: 0 - 255
            Default: 255
            Speed to set the motor to.
            track_step_angle_x Values: 0-90
            Default: 10
            Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras.
            track_step_angle_y Values: 0-40
            Default: 10
            Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras.
            track_stepsize Values: 0 - 255
            Default: 40
            Number of steps to make.
            track_type Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo)
            Default: 0 (None)
            Type of tracker.
            tunerdevice Values: Max 4095 characters
            Default: /dev/tuner0
            The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD.
            v4l2_palette Values: 0 - 8
            Default: 8
            Allow to choose preferable palette to be use by motion
            to capture from those supported by your videodevice. ( new in 3.2.10 )
            video_pipe Values: Max 4095 characters
            Default: Not defined
            The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe.
            videodevice Values: Max 4095 characters
            Default: /dev/video0 (FreeBSD: /dev/bktr0)
            The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0.
            webcam_limit Values: 0 - 2147483647
            Default: 0 (unlimited)
            Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited.
            webcam_localhost Values: on, off
            Default: on
            Limits the access to the webcam to the localhost.
            webcam_maxrate Values: 1 - 100
            Default: 1
            Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited.
            webcam_motion Values: on, off
            Default: off
            If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate.
            webcam_port Values: 0 - 65535
            Default: 0 (disabled)
            TCP port on which motion will listen for incoming connects with its webcam server.
            webcam_quality Values: 1 - 100
            Default: 50
            Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth.
            width Values: Device Dependent
            Default: 352
            The width in pixels of each frame. Valid range is camera dependent.
            +-

            +-

            Obsolete Options

            +-

            +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
            Option Range/Values
            Default
            Description
            low_cpu Values: 0 - 100
            Default: 0 (disabled)
            When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. ( DEPRECATED )
            minimum_gap Values: 0 - 2147483647
            Default: 0 (no minimum)
            The minimum time between two shots in seconds. ( DEPRECATED )
            night_compensate Values: on, off
            Default: off
            When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. ( DEPRECATED )
            +-

            +-

            ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
            Option Range/Values
            Default
            Description
            auto_brightness Values: on, off
            Default: off
            Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness
            brightness Values: 0 - 255
            Default: 0 (disabled)
            The brightness level for the video device.
            contrast Values: 0 - 255
            Default: 0 (disabled)
            The contrast level for the video device.
            control_authentication Values: Max 4096 characters
            Default: Not defined
            To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file.
            control_html_output Values: on, off
            Default: on
            Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file.
            control_localhost Values: on, off
            Default: on
            Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file.
            control_port Values: 0 - 65535
            Default: 0 (disabled)
            Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file.
            daemon Values: on, off
            Default: off
            Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file.
            despeckle Values: EedDl
            Default: Not defined
            Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling.
            ffmpeg_bps Values: 0 - 9999999
            Default: 400000
            Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed.
            ffmpeg_cap_motion Values: on, off
            Default: off
            Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes.
            ffmpeg_cap_new Values: on, off
            Default: off
            Use ffmpeg libraries to encode mpeg movies in realtime.
            ffmpeg_deinterlace Values: on, off
            Default: off
            Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures.
            ffmpeg_filename (now called movie_filename) Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S
            File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution.
            ffmpeg_timelapse Values: 0 - 2147483647
            Default: 0 (disabled)
            Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
            ffmpeg_timelapse_mode Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual
            Default: daily
            The file rollover mode of the timelapse video.
            ffmpeg_variable_bitrate Values: 0, 2 - 31
            Default: 0 (disabled)
            Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst.
            ffmpeg_video_codec Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1
            Default: mpeg4
            Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option.
            framerate Values: 2 - 100
            Default: 100 (no limit)
            Maximum number of frames to be captured from the camera per second.
            frequency Values: 0 - 999999
            Default: 0 (Not set)
            The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it)
            gap Values: 0 - 2147483647
            Default: 60
            Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe.
            height Values: Device Dependent
            Default: 288
            The height of each frame in pixels.
            hue Values: 0 - 255
            Default: 0 (disabled)
            The hue level for the video device.
            input Values: 0 - 7, 8 = disabled
            Default: 8 (disabled)
            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.
            jpeg_filename Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S-%q
            File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file.
            lightswitch Values: 0 - 100
            Default: 0 (disabled)
            Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity.
            locate Values: on, off, preview
            Default: off
            Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie.
            low_cpu Values: 0 - 100
            Default: 0 (disabled)
            When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled.
            mask_file Values: Max 4095 characters
            Default: Not defined
            PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format.
            max_mpeg_time Values: 0 (infinite) - 2147483647
            Default: 3600
            The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length.
            minimum_frame_time Values: 0 - 2147483647
            Default: 0
            Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate.
            minimum_gap Values: 0 - 2147483647
            Default: 0 (no minimum)
            The minimum time between two shots in seconds.
            minimum_motion_frames Values: 1 - 1000s
            Default: 1
            Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5.
            motion_video_pipe Values: Max 4095 characters
            Default: Not defined
            The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set
            movie_filename Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S
            File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename.
            mysql_db Values: Max 4095 characters
            Default: Not defined
            Name of the MySQL database.
            mysql_host Values: Max 4095 characters
            Default: localhost
            IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server.
            mysql_password Values: Max 4095 characters
            Default: Not defined
            The MySQL password.
            mysql_user Values: Max 4095 characters
            Default: Not defined
            The MySQL user name.
            netcam_proxy Values: Max 4095 characters
            Default: Not defined
            URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber
            netcam_url Values: Max 4095 characters
            Default: Not defined
            Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera.
            netcam_userpass Values: Max 4095 characters
            Default: Not defined
            For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication.
            night_compensate Values: on, off
            Default: off
            When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise.
            noise_level Values: 1 - 255
            Default: 32
            The noise level is used as a threshold for distinguishing between noise and motion.
            noise_tune Values: on, off
            Default: on
            Activates the automatic tuning of noise level.
            norm Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour)
            Default: 0 (PAL)
            Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
            on_event_end Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.
            on_event_start Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command.
            on_motion_detected Values: Max 4095 characters
            Default: Not defined
            Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command.
            on_movie_end Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
            on_movie_start Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
            on_picture_save Values: Max 4095 characters
            Default: Not defined
            Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
            output_all Values: on, off
            Default: off
            Picture are saved continuously as if motion was detected all the time.
            output_motion Values: on, off
            Default: off
            Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red.
            output_normal Values: on, off, first, best
            Default: on
            Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored.
            pgsql_db Values: Max 4095 characters
            Default: Not defined
            Name of the PostgreSQL database.
            pgsql_host Values: Max 4095 characters
            Default: localhost
            IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server.
            pgsql_password Values: Max 4095 characters
            Default: Not defined
            The PostgreSQL password.
            pgsql_port Values: 0 - 65535
            Default: 5432
            The PostgreSQL server port number.
            pgsql_user Values: Max 4095 characters
            Default: Not defined
            The PostgreSQL user name.
            post_capture Values: 0 - 2147483647
            Default: 0 (disabled)
            Specifies the number of frames to be captured after motion has been detected.
            ppm Values: on, off
            Default: off
            Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg.
            pre_capture Values: 0 - 100s
            Default: 0 (disabled)
            Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.
            process_id_file Values: Max 4095 characters
            Default: Not defined
            File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid
            quality Values: 1 - 100
            Default: 75
            The quality for the jpeg images in percent.
            quiet Values: on, off
            Default: off
            Be quiet, don't output beeps when detecting motion.
            rotate Values: 0, 90, 180, 270
            Default: 0 (not rotated)
            Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies.
            roundrobin_frames Values: 1 - 2147483647
            Default: 1
            Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible.
            roundrobin_skip Values: 1 - 2147483647
            Default: 1
            Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe).
            saturation Values: 0 - 255
            Default: 0 (disabled)
            The colour saturation level for the video device.
            setup_mode Values: on, off
            Default: off
            Run Motion in setup mode.
            smart_mask_speed Values: 0 - 10
            Default: 0 (disabled)
            Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast.
            snapshot_filename Values: Max 4095 characters
            Default: %v-%Y%m%d%H%M%S-snapshot
            File path for snapshots (jpeg or ppm) relative to target_dir.
            snapshot_interval Values: 0 - 2147483647
            Default: 0 (disabled)
            Make automated snapshots every 'snapshot_interval' seconds.
            sql_log_image Values: on, off
            Default: on
            Log to the database when creating motion triggered image file.
            sql_log_mpeg Values: on, off
            Default: off
            Log to the database when creating motion triggered mpeg file.
            sql_log_snapshot Values: on, off
            Default: on
            Log to the database when creating a snapshot image file.
            sql_log_timelapse Values: on, off
            Default: off
            Log to the database when creating timelapse mpeg file
            sql_query Values: Max 4095 characters
            Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
            SQL query string that is sent to the database. The values for each field are given by using convertion specifiers
            switchfilter Values: on, off
            Default: off
            Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection.
            target_dir Values: Max 4095 characters
            Default: Not defined = current working directory
            Target directory for picture and movie files.
            text_changes Values: on, off
            Default: off
            Turns the text showing changed pixels on/off.
            text_double Values: on, off
            Default: off
            Draw characters at twice normal size on images.
            text_event Values: Max 4095 characters
            Default: %Y%m%d%H%M%S
            This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event.
            text_left Values: Max 4095 characters
            Default: Not defined
            User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers (codes starting by a %).
            text_right Values: Max 4095 characters
            Default: %Y-%m-%d\n%T
            User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
            thread Values: Max 4095 characters
            Default: Not defined
            Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file.
            threshold Values: 1 - 2147483647
            Default: 1500
            Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling.
            threshold_tune Values: on, off
            Default: off
            Activates the automatic tuning of threshold level.
            timelapse_filename Values: Max 4095 characters
            Default: %v-%Y%m%d-timelapse
            File path for timelapse mpegs relative to target_dir (ffmpeg only).
            track_auto Values: on, off
            Default: off
            Enable auto tracking
            track_iomojo_id Values: 0 - 2147483647
            Default: 0
            Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller.
            track_maxx Values: 0 - 2147483647
            Default: 0
            The maximum position for servo x.
            track_maxy Values: 0 - 2147483647
            Default: 0
            The maximum position for servo y.
            track_motorx Values: -1 - 2147483647
            Default: -1
            The motor number that is used for controlling the x-axis.
            track_motory Values: -1 - 2147483647
            Default: -1
            The motor number that is used for controlling the y-axis.
            track_move_wait Values: 0 - 2147483647
            Default: 10
            Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames.
            track_port Values: Max 4095 characters
            Default: Not defined
            This is the device name of the serial port to which the stepper motor interface is connected.
            track_speed Values: 0 - 255
            Default: 255
            Speed to set the motor to.
            track_step_angle_x Values: 0-90
            Default: 10
            Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras.
            track_step_angle_y Values: 0-40
            Default: 10
            Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras.
            track_stepsize Values: 0 - 255
            Default: 40
            Number of steps to make.
            track_type Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo)
            Default: 0 (None)
            Type of tracker.
            tunerdevice Values: Max 4095 characters
            Default: /dev/tuner0
            The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD.
            video_pipe Values: Max 4095 characters
            Default: Not defined
            The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe.
            videodevice Values: Max 4095 characters
            Default: /dev/video0 (FreeBSD: /dev/bktr0)
            The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0.
            webcam_limit Values: 0 - 2147483647
            Default: 0 (unlimited)
            Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited.
            webcam_localhost Values: on, off
            Default: on
            Limits the access to the webcam to the localhost.
            webcam_maxrate Values: 1 - 100
            Default: 1
            Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited.
            webcam_motion Values: on, off
            Default: off
            If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate.
            webcam_port Values: 0 - 65535
            Default: 0 (disabled)
            TCP port on which motion will listen for incoming connects with its webcam server.
            webcam_quality Values: 1 - 100
            Default: 50
            Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth.
            width Values: Device Dependent
            Default: 352
            The width in pixels of each frame. Valid range is camera dependent.
            +

            +

            +-

            Signals (sent with e.g. kill command)

            ++

            Signals (sent with e.g. kill command)

            + A signal can be sent from the command line by typing e.g. kill -s SIGHUP pid, where the last parameter is the process ID which you get by typing ps -ef ¦ grep motion. The PID is the first on the list which is the parent process for the threads. + Motion responds to the following signals: +

            +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
            Signal Description Editors comment
            SIGHUP The config file will be reread. This is a very useful signal when you experiment with settings in the config file.
            SIGTERM If needed motion will create an mpeg file of the last event and exit  
            SIGUSR1 Motion will create an mpeg file of the current event.  
            ++ ++ ++ ++ ++
            Signal Description Editors comment
            SIGHUP The config file will be reread. This is a very useful signal when you experiment with settings in the config file.
            SIGTERM If needed motion will create an mpeg file of the last event and exit  
            SIGUSR1 Motion will create an mpeg file of the current event.  
            +

            +

            +-

            Error Logging

            ++

            Error Logging

            + Motion reports errors to the console when it runs in non-daemon mode. And it outputs even more information when run in setup mode. +

            + Error logging has been implemented so that errors during daemon (background) mode are logged in the syslog. +@@ -1816,76 +875,70 @@ The syslog is in most Linux systems the +

            +

            Motion Guide - Basic Features

            +

            +-

            Capture Device Options - The Basic Setup

            ++

            Capture Device Options - The Basic Setup

            + Before you can start using motion you need to know some basics about your camera. + Either you have a camera connected directly to your computer. In this case it is a video4linux type of camera. Or you connect to a network camera using a normal web URL. +

            +-

            video4linux (V4L) devices

            ++

            video4linux (V4L) devices

            + You need to install your camera with the right driver. It is out of scope of this document to tell you how to do this and it depends on which type of camera. +

            + Once installed the camera(s) will have the device names /dev/video0, /dev/video1, /dev/video2... +

            + FreeBSD has a different naming of devices. When you build Motion for FreeBSD the default device name is /dev/bktr0. Under FreeBSD a TV card has a special device for controlling the tuner (e.g. /dev/tuner0). The option tunerdevice is only valid when Motion is built and running under FreeBSD. For Linux do not include this option in the config file (remove or comment out). +

            +-USB cameras take a lot of bandwidth. A USB camera connected to a USB 1.1 port or hub consumes all the bandwidth. Even with a small framesize and low framerate you should not expect to have more than one camera per USB 1.1 controller. If you need more than 1 USB camera add extra USB PCI cards to your computer. There exists cards that have 4 inputs each with their own controller and with full bandwidth. Many 4-input cards only have 1 controller. USB cameras do not have the feature of selecting input channels. To disable the input selection the option input must be set to the value 8 for USB cameras. ++USB cameras take a lot of bandwidth. A USB camera connected to a USB 1.1 port or hub consumes all the bandwidth. Even with a small framesize and low framerate you should not expect to have more than one camera per USB 1.1 controller. If you need more than 1 USB camera add extra USB PCI cards to your computer. There exists cards that have 4 inputs each with their own controller and with full bandwidth. Many 4-input cards only have 1 controller. USB cameras do not have the feature of selecting input channels. To disable the input selection the option input must be set to the value 8 for USB cameras. +

            + Composite video cards are normally made with a chip called BT878 (older cards have a BT848). They all use the Linux driver called 'bttv'. +

            +-There are cards with more then one video input but still only one BT878 chip. They have a video multiplexer which input is selected with the config option input. Input channel numbers start at 0 (which is why the value 8 and not 0 disables input selection). There are video capture cards available with 4 or 8 inputs but only one chip. They present themselves as one single video device and you select input using the 'input' option. If you define e.g. 4 thread config files with the same videodevice name but different input numbers Motion automatically goes into round robin mode. See the round robin section for more information. Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. For video capture cards input 1 is normally the composite video input. ++There are cards with more then one video input but still only one BT878 chip. They have a video multiplexer which input is selected with the config option input. Input channel numbers start at 0 (which is why the value 8 and not 0 disables input selection). There are video capture cards available with 4 or 8 inputs but only one chip. They present themselves as one single video device and you select input using the 'input' option. If you define e.g. 4 thread config files with the same videodevice name but different input numbers Motion automatically goes into round robin mode. See the round robin section for more information. Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. For video capture cards input 1 is normally the composite video input. +

            + Some capture cards are specially made for surveillance with for example 4 inputs. Others have a TV tuner, a composite input (phono socket) and perhaps also a S-VHS input. For all these cards the inputs are numbered. The numbering varies from card to card so the easiest is to experiment for 5 minutes with a program that can show the videostream. Use a program such as Camstream or xawtv to experiment with the values. +

            +-If you use the TV tuner input you also need to set the frequency of the TV channel using the option frequency. Otherwise set 'frequency' to 0. ++If you use the TV tuner input you also need to set the frequency of the TV channel using the option frequency. Otherwise set 'frequency' to 0. +

            + Finally you need to set the TV norm. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default is 0 (PAL). If your camera is a PAL black and white you may get a better result with norm=3 (PAL no colour). +

            +-If the netcam_url option is defined all the video4linux options are ignored so make sure the netcam_url option is commented out if you do not need it. ++If the netcam_url option is defined all the video4linux options are ignored so make sure the netcam_url option is commented out if you do not need it. +

            + These are the parameters used for video4linux devices +

            +

            +-

            +

            auto_brightness

            +

            +

            + Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness +

            + Motion will try to adjust the brightness of the video device if the images captured are too dark or too light. This option will be most useful for video devices like web cams, which sometimes don't have such an option in hardware. +

            +-The auto_brightness feature will adjust the brightness of the device up or down until the value defined by the option brightness is reached (1 = dark, 255 = bright). If brightness is zero auto_brightness will try to adjust to the average brightness level 128. ++The auto_brightness feature will adjust the brightness of the device up or down until the value defined by the option brightness is reached (1 = dark, 255 = bright). If brightness is zero auto_brightness will try to adjust to the average brightness level 128. +

            + You need to know if the camera supports auto brightness. Most cameras have auto everything. If your video device already does this for you this option might cause oscillations. If you do not know assume that it has and do not use the Motion auto brightness feature. At least not to start with. +

            +

            +-

            +-

            +-

            +

            brightness

            +

            + The brightness level for the video device. +

            + Value 0 means that Motion does not set the brightness value but leaves it unchanged. +

            +-If this setting is used in conjunction with the auto_brightness feature then this setting is the average brightness level in the range 1 (dark) to 255 (bright) that the auto_brightness feature will try to achieve by adjusting the device brightness up and down. +-

            +-

            ++If this setting is used in conjunction with the auto_brightness feature then this setting is the average brightness level in the range 1 (dark) to 255 (bright) that the auto_brightness feature will try to achieve by adjusting the device brightness up and down. +

            +

            +

            contrast

            +

            + The contrast level for the video device. +@@ -1893,14 +946,12 @@ The contrast level for the video device. + Disabled (Value 0) means that Motion does not set the contrast value. +

            +

            +-

            +-

            +

            framerate

            +

            +

            + Maximum number of frames to be captured from the camera per second. +@@ -1914,14 +965,12 @@ Set this parameter to the maximum number + To set intervals longer than one second use the 'minimum_gap' option instead. +

            +

            +-

            +-

            +

            frequency

            +

            +

            + The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) +@@ -1929,14 +978,12 @@ The frequency to set the tuner to (kHz). + This option is only relevant if you have a TV tuner card where you can select the tuner frequency. Your tuner card must support this feature. +

            +

            +-

            +-

            +

            height

            +

            +

            + The height of each frame in pixels. +@@ -1952,14 +999,12 @@ For some device drivers like pwc (driver + Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. +

            +

            +-

            +-

            +

            hue

            +

            +

            + The hue level for the video device. +@@ -1967,14 +1012,12 @@ The hue level for the video device. + Normally only relevant for NTSC cameras. +

            +

            +-

            +-

            +

            input

            +

            +

            + 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. +@@ -1985,9 +1028,7 @@ However if you set the input number to e +

            + If you have a video capture card you can define the channel to tune to using this option. If you are using a USB device, network camera or a capture card without tuner you should set the value to the default 8. +

            +-Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. It is recommended to set the parameter to 8 for USB cameras as your first try. For video capture cards input 1 is normally the composite video input. +-

            +-

            ++Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. It is recommended to set the parameter to 8 for USB cameras as your first try. For video capture cards input 1 is normally the composite video input. +

            +

            +

            minimum_frame_time

            +@@ -1995,7 +1036,7 @@ Many TV tuner cards have the input chann +
          • Type: Integer +
          • Range / Valid values: 0 - 2147483647 +
          • Default: 0 +-
          • Option Topic ++
          • Option Topic +
          +

          + Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. +@@ -2004,21 +1045,19 @@ This option is used when you want to cap +

          + When this is enabled the framerate option is used only to set the pace the Motion service the webcam port etc. Running Motion at framerate 2 is normally fine. +

          +-ALERT! This feature is introduced in Motion 3.2.7 ++ALERT! This feature is introduced in Motion 3.2.7 +

          + +

          +

          +-

          +-

          +

          norm

          +

            +
          • Type: Discrete Strings +
          • Range / Valid values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) +
          • Default: 0 (PAL) +-
          • Option Topic ++
          • Option Topic +
          +

          + Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) +@@ -2026,14 +1065,12 @@ Select the norm of the video device. Val + This value is only used for capture cards using the BTTV driver. +

          +

          +-

          +-

          +

          rotate

          +

            +
          • Type: Discrete Strings +
          • Range / Valid values: 0, 90, 180, 270 +
          • Default: 0 (not rotated) +-
          • Option Topic ++
          • Option Topic +
          +

          + Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. +@@ -2043,91 +1080,49 @@ The rotation feature is used when the ca + Note that the CPU load increases when using this feature with a value other than 0. Also note that Motion automatically swaps width and height if you rotate 90 or 270 degrees, so you don't have to touch these options. +

          +

          +-

          +-

          +

          saturation

          +

          +

          + The colour saturation level for the video device. +

          +

          +-

          +-

          +-

          +-

          +

          tunerdevice

          +

          +

          +-The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. ++The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. +

          + Make sure to remove or comment out this option when running Motion under Linux. +

          +

          +-

          +-

          +-

          v4l2_palette

          +-

            +-
          • Type: Integer +-
          • Range / Valid values: 0 - 8 +-
          • Default: 8 +-
          • Option Topic +-
          +-

          +-Allow to choose preferable palette to be use by motion +- to capture from those supported by your videodevice. ( new in 3.2.10 ) +-

          +- +-

          +-i.ex if your videodevice supports V4L2 _PIX_FMT_SBGGR8 and V4L2 _PIX_FMT_MJPEG by default motion will use V4L2 _PIX_FMT_MJPEG so set v4l2_palette 1 to force motion use V4L2 _PIX_FMT_SBGGR8 instead. +-

          +-Values : +-

          V4L2_PIX_FMT_SN9C10X : 0 'S910'
          +-V4L2_PIX_FMT_SBGGR8 : 1 'BA81'
          +-V4L2_PIX_FMT_MJPEG : 2 'MJPEG'
          +-V4L2_PIX_FMT_JPEG : 3 'JPEG'
          +-V4L2_PIX_FMT_RGB24 : 4 'RGB3'
          +-V4L2_PIX_FMT_UYVY : 5 'UYVY'
          +-V4L2_PIX_FMT_YUYV : 6 'YUYV'
          +-V4L2_PIX_FMT_YUV422P : 7 '422P'
          +-V4L2_PIX_FMT_YUV420 : 8 'YU12'
          +-
          +-

          +-

          +-

          +-

          +

          videodevice

          +

          +

          +-The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. ++The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. +

          + This is the video4linux device name. Ignore this for net cameras. +

          +

          +-

          +-

          +

          width

          +

          +

          + The width in pixels of each frame. Valid range is camera dependent. +@@ -2145,7 +1140,6 @@ For some device drivers like pwc (driver + Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. +

          +

          +-

          +

          Network Cameras

          + Motion can connect to a network camera through a normal TCP socket. All you need to give it is the URL. The URL given must return either one single jpeg picture or an mjpeg stream. For the time being Motion cannot connect to a video stream such a mpeg, mpeg4, divx. The URL must return one single jpeg image or an mjpeg stream! You can connect through a proxy server. +

          +@@ -2157,31 +1151,7 @@ If the connection to a network camera is +

          + Note that Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. But if you intend to monitor a network camera which is saving jpeg images you may have to pay attention to the dimensions of the picture. +

          +-The network camera feature has been completely re-written in Motion 3.2.2. We believe the netcam feature is much more stable now that it was in previous versions. Motion tries to reconnect to the camera if the connection is lost. There is no official standard for mjpeg and we know that there are probably still some cameras that are not yet supported. If you run into a problem please file a Bug Report with as much information about the format as possible. A binary raw dump of the first 2-3 frames with headers and boundary strings is very useful. You can see how to make it on the special topic NetcamMjpegStreamDumps. When you have the file you can upload it to the same topic. +-

          +-

          +-

          +-

          netcam_http

          +-

            +-
          • Type: Discrete Strings +-
          • Range / Valid values: 1.0, keep_alive, 1.1 +-
          • Default: 1.0 +-
          • Option Topic +-
          +-

          +-The setting for keep-alive of network socket, should improve performance on compatible net cameras. ( new in 3.2.10 ) +-

          +-

            +-
          • 1.0: the historical implementation using HTTP/1.0, closing the socket after each http request. +-
          • keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +-
          • 1.1: Use HTTP/1.1 requests that support keep alive as default. +-
          +-

          +- +-

          +-

          ++The network camera feature has been completely re-written in Motion 3.2.2. We believe the netcam feature is much more stable now that it was in previous versions. Motion tries to reconnect to the camera if the connection is lost. There is no official standard for mjpeg and we know that there are probably still some cameras that are not yet supported. If you run into a problem please file a Bug Report with as much information about the format as possible. A binary raw dump of the first 2-3 frames with headers and boundary strings is very useful. You can see how to make it on the special topic NetcamMjpegStreamDumps. When you have the file you can upload it to the same topic. +

          +

          +

          netcam_proxy

          +@@ -2189,7 +1159,7 @@ Add Additional Description Below +
        • Type: String +
        • Range / Valid values: Max 4095 characters +
        • Default: Not defined +-
        • Option Topic ++
        • Option Topic +
        +

        + URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber +@@ -2203,32 +1173,14 @@ If the proxy port number is 80 you can o + Leave this option undefined if you do not use a proxy server. +

        +

        +-

        +-

        +-

        netcam_tolerant_check

        +-

          +-
        • Type: Boolean +-
        • Range / Valid values: on, off +-
        • Default: off +-
        • Option Topic +-
        +-

        +-Set less strict jpeg checks for network cameras with a poor/buggy firmware. +-

        +- +-

        +-

        +-

        +-

        +

        netcam_url

        +

        ++

        + Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. +

        + Example of URL: http://www.gate.com/pe1rxq/jeroen.jpg. +@@ -2242,14 +1194,12 @@ When the netcam_url is defined all the v + Motion can also fetch jpeg pictures via ftp. You then use the ftp:// syntax instead. +

        +

        +-

        +-

        +

        netcam_userpass

        +

        +

        + For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. +@@ -2258,30 +1208,28 @@ To use no authentication simply remove t +

        +

        +

        +-

        + +

        Round Robin feature

        +-This feature is automatically activated where multiple threads are sharing the same video device (for example /dev/video0). Each thread can then set different input channels to change camera with the input option or by tuning the tuner with frequency option. ++This feature is automatically activated where multiple threads are sharing the same video device (for example /dev/video0). Each thread can then set different input channels to change camera with the input option or by tuning the tuner with frequency option. +

        +-ALERT! Round Robin is not relevant for Network cameras or standard USB web cameras. The Round Robin feature is used with video capture cards which have multiple inputs per video chip. ++ALERT! Round Robin is not relevant for Network cameras or standard USB web cameras. The Round Robin feature is used with video capture cards which have multiple inputs per video chip. +

        +-ALERT! Note that round robin is not the ideal way to run multiple cameras. When the capture card changes input it takes a little while before the decoder chip has syncronized to the new camera. You can improve this if you have expensive cameras with a syncronize input. Only one camera can be decoded at a time so if you have 4 cameras connected 3 of the camera threads will need to wait for their turn. The fact that cameras have to take turns and the fact that you have to skip a few frames after each turn dramatically lowers the possible framerate. You can get a high framerate by viewing each camera for a long time. But then you may miss the action on one of the inactive cameras. If you can affort it avoid Round Robin and buy the more expensive type of capture cards that has one decoder chip per input. If you only need 2 or 3 cameras you can also simply put 2 or 3 cheap TV cards in the computer. Linux has no problem working with multiple TV cards. ++ALERT! Note that round robin is not the ideal way to run multiple cameras. When the capture card changes input it takes a little while before the decoder chip has syncronized to the new camera. You can improve this if you have expensive cameras with a syncronize input. Only one camera can be decoded at a time so if you have 4 cameras connected 3 of the camera threads will need to wait for their turn. The fact that cameras have to take turns and the fact that you have to skip a few frames after each turn dramatically lowers the possible framerate. You can get a high framerate by viewing each camera for a long time. But then you may miss the action on one of the inactive cameras. If you can affort it avoid Round Robin and buy the more expensive type of capture cards that has one decoder chip per input. If you only need 2 or 3 cameras you can also simply put 2 or 3 cheap TV cards in the computer. Linux has no problem working with multiple TV cards. +

          +-
        • If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. +-
        • When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. +-
        • The last option switch_filter is supposed to prevent the change of camera from being detected as Motion. Its function is not perfect and sometimes prevents detection of real motion. You should start with having the option disabled and then try with the option enabled to see if you can skip less frames without loosing the detection of the type of motion you normally want to detect. ++
        • If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. ++
        • When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. ++
        • The last option switch_filter is supposed to prevent the change of camera from being detected as Motion. Its function is not perfect and sometimes prevents detection of real motion. You should start with having the option disabled and then try with the option enabled to see if you can skip less frames without loosing the detection of the type of motion you normally want to detect. +
        +

        + These are the special Round Robin options +

        +

        +-

        +

        roundrobin_frames

        +

        +

        + Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. +@@ -2291,14 +1239,12 @@ The Round Robin feature is automatically + If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. +

        +

        +-

        +-

        +

        roundrobin_skip

        +

        +

        + Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). +@@ -2308,65 +1254,31 @@ The Round Robin feature is automatically + When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. +

        +

        +-

        +-

        +

        switchfilter

        +

        +

        + Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. +

        + This is a round robin related feature used when you have a capture card with multiple inputs (controlled by the 'input' option) on the same videodevice. +

        +-ALERT! This feature was seriously broken until Motion 3.2.4 ++ALERT! This feature was seriously broken until Motion 3.2.4 +

        +

        +-

        +-

        +-

        +-

        Motion Detection Settings

        ++

        Motion Detection Settings

        + These are the options that controls the detection of motion. Further details follows after. +

        +

        +-

        +-

        area_detect

        +-

          +-
        • Type: String +-
        • Range / Valid values: 1 - 999999999 +-
        • Default: Not defined +-
        • Option Topic +-
        +-

        +-Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. +-

        +- +-

        +-Areas are numbered like that: +-

        +-

              1    2    3
        +-      4    5    6
        +-      7    8    9
        +-
        +-

        +- One or more areas can be specified with this option. +-

        +-Example: You want to monitor if the center of motion occurrs in the lower third of the image - that is area 7, 8 and 9. Simply set 'area_detect' to '789' and 'on_area_detect' will be executed as soon as the center of motion was detected in area 7, 8 or 9. If you want to monitor area 2, 3, 5 and 6, set '2356'. +-

        +-

        +-

        +-

        +

        despeckle

        +

        +

        + Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. +@@ -2385,14 +1297,12 @@ If you have very few problems with false + A very detailed technical explanation of the despeckle part can be found at the webpage of the author of this feature Ian McConnell's Webcam: Motion Web Page +

        +

        +-

        +-

        +

        gap

        +

        +

        + Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. +@@ -2426,15 +1336,14 @@ The gap value impacts many functions in + Note that 'gap' and 'minimum_gap' have nothing to do with each other. +

        +

        +-

        +-

        +

        lightswitch

        +

        ++

        + Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. +

        + Experiment to see what works best for your application. +@@ -2444,6 +1353,17 @@ Note: From version 3.1.17 (snap release + The value defines the picture areas in percent that will trigger the lightswitch condition. When lightswitch is detected motion detection is disabled for 5 picture frames. This is to avoid false detection when light conditions change and when a camera changes sensitivity at low light. +

        +

        ++

        low_cpu

        ++

          ++
        • Type: Integer ++
        • Range / Valid values: 0 - 100 ++
        • Default: 0 (disabled) ++
        • Option Topic ++
        ++

        ++When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. ++

        ++This is smart for running a server that also does other tasks such as running Apache, MySQL etc. Motion grabs this lower number of frames per second until it detects motion. Then it speeds up to normal speed and take pictures as set by the option "framerate". +

        +

        +

        mask_file

        +@@ -2451,7 +1371,7 @@ The value defines the picture areas in p +
      • Type: String +
      • Range / Valid values: Max 4095 characters +
      • Default: Not defined +-
      • Option Topic ++
      • Option Topic +
      +

      + PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. +@@ -2486,18 +1406,12 @@ Below are an example of a webcam picture +

      + Normal picture. Notice the street is visible through the hedge. +

      +-normal.jpg ++normal.jpg +

      + Mask file (converted to png format so it can be shown by your web browser) +

      +- +- +- +- +- +-
      mask1.png
      +-

      +-

      ++ ++
      mask1.png
      +

      +

      +

      max_mpeg_time

      +@@ -2505,7 +1419,7 @@ Mask file (converted to png format so it +
    • Type: Integer +
    • Range / Valid values: 0 (infinite) - 2147483647 +
    • Default: 3600 +-
    • Option Topic ++
    • Option Topic +
    +

    + The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. +@@ -2517,6 +1431,23 @@ Add Additional Description Below + --> +

    +

    ++

    minimum_gap

    ++

      ++
    • Type: Integer ++
    • Range / Valid values: 0 - 2147483647 ++
    • Default: 0 (no minimum) ++
    • Option Topic ++
    ++

    ++The minimum time between two shots in seconds. ++

    ++This is the minimum gap between the storing pictures while detecting motion. ++

    ++The value zero means that pictures can be stored almost at the framerate of the camera. Normally you will set this to 0 ++

    ++This option has nothing to do with the 'gap' option. ++

    ++ALERT! From motion 3.2.7 this feature has been removed because it was in practical a useless feature. It prevented saving more than one picture per minimum_gap seconds but the capturing and motion detect was still run at full framerate loading the CPU heavily. From 3.2.7 a new feature called minimum_frame_time has been introduced which lower the capture rate. So it gives the same effect as minimum_gap did but additionally lower the CPU load significantly. +

    +

    +

    minimum_motion_frames

    +@@ -2524,7 +1455,7 @@ Add Additional Description Below +
  • Type: Boolean +
  • Range / Valid values: 1 - 1000s +
  • Default: 1 +-
  • Option Topic ++
  • Option Topic +
+

+ Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. +@@ -2536,6 +1467,17 @@ The feature is used when you get many fa + Experiment for best setting. Even though Motion accepts large values you should set this to a relatively low number (below 10). For each step larger than 1 Motion reserves space in RAM for the picture frame buffer. If you have a large value Motion will miss many frames from the camera while it is processing the all the pictures in the buffer. +

+

++

night_compensate

++

    ++
  • Type: Boolean ++
  • Range / Valid values: on, off ++
  • Default: off ++
  • Option Topic ++
++

++When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. ++

++It has normally been the advice not to use this with 'noise_tune' turned on. However the latest experience is that with the new improved noise_tune algorithm it actually works fine in combination with 'night_compensate'. +

+

+

noise_level

+@@ -2543,7 +1485,7 @@ Experiment for best setting. Even though +
  • Type: Integer +
  • Range / Valid values: 1 - 255 +
  • Default: 32 +-
  • Option Topic ++
  • Option Topic +
  • +

    + The noise level is used as a threshold for distinguishing between noise and motion. +@@ -2551,14 +1493,12 @@ The noise level is used as a threshold f + This is different from the threshold parameter. This is changes at pixel level. The purpose is to eliminate the changes generated by electric noise in the camera. Especially in complete darkness you can see the noise as small grey dots that come randomly in the picture. This noise can create false motion detection. What this parameter means is that the intensity of a pixel must change more than +/- the noise threshold parameter to be counted. +

    +

    +-

    +-

    +

    noise_tune

    +

    +

    + Activates the automatic tuning of noise level. +@@ -2566,14 +1506,12 @@ Activates the automatic tuning of noise + This feature makes Motion continuously adjust the noise threshold for distinguishing between noise and motion. The 'noise_level' setting is ignored when activating this feature. This is a new feature and new algorithm. It may give different results depending on camera and light conditions. Report your experience with it on the Motion mailing list. If it does not work well, deactivate the 'noise_tune' option and use the manual setting of 'noise_level' instead. +

    +

    +-

    +-

    +

    output_all

    +

    +

    + Picture are saved continuously as if motion was detected all the time. +@@ -2587,14 +1525,12 @@ It does all the normal actions that are + The idea of this feature is that you can turn the feature on and off for a short period of time to test or to generate continuous mpeg films when needed. +

    +

    +-

    +-

    +

    post_capture

    +

    +

    + Specifies the number of frames to be captured after motion has been detected. +@@ -2606,14 +1542,12 @@ This option is the preferred way to crea + If you only store mpegs movies and do not have output_normal on, then the recommended post_capture value is what is equivalent to 1-5 seconds of movie. +

    +

    +-

    +-

    +

    pre_capture

    +

    +

    + Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. +@@ -2630,9 +1564,7 @@ Motion will not grab another image until +

    + If you wish to create smooth mpegs during events using large pre_capture values will do the opposite! It will create a long pause where a lot of action is missed. +

    +-To get a smooth mpeg use a large value for post_capture which does not cost any performance hit or RAM space. +-

    +-

    ++To get a smooth mpeg use a large value for post_capture which does not cost any performance hit or RAM space. +

    +

    +

    smart_mask_speed

    +@@ -2640,7 +1572,7 @@ To get a smooth mpeg use a large value f +
  • Type: Integer +
  • Range / Valid values: 0 - 10 +
  • Default: 0 (disabled) +-
  • Option Topic ++
  • Option Topic +
  • +

    + Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. +@@ -2649,11 +1581,11 @@ Smartmask is a dynamic, self-learning ma +

    + smart_mask_speed - tunes the slugginess of the mask. It accepts values from 0 (turned off) to 10 (fast). Fast means here that the mask is built quick, but it is also not staying very long with no more motion. Slow means that it takes a while until the mask is built but it also stays longer. A good start value for smart_mask_speed is 5. This setting is independent from the framerate. The attack and decay time is constant over all available framerates. +

    +-When smartmask is enabled and motion is also configured to either write motion-images or motion-mpegs, the current smartmask is copied as an overlay into the black/white motion-pictures/mpegs in red colour. Same thing happens to the webcam stream when Motion runs in setup_mode. That way you can easily adjust smart_mask_speed. ++When smartmask is enabled and motion is also configured to either write motion-images or motion-mpegs, the current smartmask is copied as an overlay into the black/white motion-pictures/mpegs in red colour. Same thing happens to the webcam stream when Motion runs in setup_mode. That way you can easily adjust smart_mask_speed. +

    + Detailed Description +

    +-The mask_file option provides a static mask to turn off sensitivity in certain areas. This is very usefull to mask a street with cars passing by all day long etc... ++The mask_file option provides a static mask to turn off sensitivity in certain areas. This is very usefull to mask a street with cars passing by all day long etc... +

    + But imagine a scenario with large bushes and big trees where all the leaves are moving in the wind also triggering motion from time to time even with despeckle turned on. Of course you can also define a static mask here, but what if the bushes are growing during spring and summer? Well, you have to adapt the mask from time to time. What if the camera position moves slightly? What if someone grows new plants in your garden? You always have to setup a new static mask. +

    +@@ -2662,15 +1594,12 @@ The answer to this problem is the smart + Smart mask will disable sensitivity in areas with frequent motion (like trees in the wind). Sensitivity is turned on again after some time of no more motion in this area. The built mask is a bit larger at the borders than the actual motion. This way smartmask works more reliably when sudden moves occur under windy conditions. +

    +

    +-

    +-

    +-

    +

    threshold

    +

    +

    + Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. +@@ -2680,37 +1609,31 @@ The 'threshold' option is the most impor + Use the -s (setup mode) command line option and/or the text_changes config file option to experiment to find the right threshold value. If you do not get small movements detected (see the mouse on the kitchen floor) lower the value. If motion detects too many birds or moving trees, increase the number. Practical values would be from a few hundred to 2000 indoors and 1000-10000 outdoors. +

    +

    +-

    +-

    +

    threshold_tune

    +

    +

    +-Activates the automatic tuning of threshold level. ( It's broken ) ++Activates the automatic tuning of threshold level. +

    + This feature makes Motion continuously adjust the threshold for declaring motion. +

    +-The threshold setting is ignored when activating this feature. It may give different results depending on your camera, light conditions, indoor/outdoor, the motion to be detected etc. If it does not work well, deactivate the 'threshold_tune' option and use the manual setting of threshold instead. +-

    +-

    ++The threshold setting is ignored when activating this feature. It may give different results depending on your camera, light conditions, indoor/outdoor, the motion to be detected etc. If it does not work well, deactivate the 'threshold_tune' option and use the manual setting of threshold instead. +

    +

    +-

    +-

    Image File Output

    ++

    Image File Output

    + The following options controls how Motion generates images when detection motion. +

    +

    +-

    +

    output_motion

    +

    +

    + Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. +@@ -2720,14 +1643,12 @@ Motion images shows the motion content o + Default is not to store motion images. Motion pictures are stored the same place and with the same filename as normal motion triggered pictures except they have an "m" appended at the end of the filename before the .jpg or .ppm. E.g. the name can be 01-20020424232936-00m.jpg. +

    +

    +-

    +-

    +

    output_normal

    +

      +
    • Type: Discrete Strings +-
    • Range / Valid values: on, off, first, best, center (since 3.2.10) ++
    • Range / Valid values: on, off, first, best +
    • Default: on +-
    • Option Topic ++
    • Option Topic +
    +

    + Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. +@@ -2736,11 +1657,7 @@ If you set the value to 'first' Motion s +

    + If you set it to "best" Motion saves the picture with most changed pixels during the event. This is useful if you store mpegs on a webserver and want to present a jpeg to show the content of the mpeg on a webpage. "best" requires a little more CPU power and resources compared to "first". +

    +-Picture with motion nearest center of picture is saved when set to 'center' (since 3.2.10). +-

    +-Set to 'off' to not write pictures (jpeg or ppm). +-

    +-

    ++Set to 'off' to don't write pictures ( jpeg or ppm ). +

    +

    +

    ppm

    +@@ -2748,7 +1665,7 @@ Set to 'off' to not write pictures (jpeg +
  • Type: Boolean +
  • Range / Valid values: on, off +
  • Default: off +-
  • Option Topic ++
  • Option Topic +
  • +

    + Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. +@@ -2756,14 +1673,12 @@ Output ppm images instead of jpeg. This + The recommendation is to always use jpg except if you have a specific need to store high quality pictures without any quality loss. For web cameras you should always choose jpg. Note that the built in webcam server requires that this parameter is set to off. +

    +

    +-

    +-

    +

    quality

    +

    +

    + The quality for the jpeg images in percent. +@@ -2771,11 +1686,7 @@ The quality for the jpeg images in perce + 100 means hardly compressed. A small number means a much smaller file size but also a less nice quality image to look at. 50 is a good compromise for most. +

    +

    +-

    +-

    +-

    +-

    +-

    Tuning Motion

    ++

    Tuning Motion

    +

    + Motion 3.2 introduces a new feature Setup Mode. This is a great new feature with really make tuning all the settings of Motion much more easy and transparent. In setup mode two things happen: +

      +@@ -2801,26 +1712,26 @@ In normal mode you can use the same sett + From the web interface you can ask Motion to write all your changes back to the config files (motion.conf and thread config files). It will even tidy them up for you so they look nice. +

      + There are two sets of options to adjust.

      +

      +


      +

      + Normal picture frame +

      +-outputnormal1.jpg ++outputnormal1.jpg +

      +


      + Motion type picture frame with despeckle. Note that the largest area is blue and only this is counted as Motion. +

      + The Motion image shows how Motion maintains a "reference frame" which is not just the last picture frame but a matematical calculation of the past images. This enlarges real Motion and ensures that it is not easy to sneak in slowly. +

      +-outputmotion1.jpg ++outputmotion1.jpg +


      +

      +

      +-

      Generating MPEG films with ffmpeg

      ++

      Generating MPEG films with ffmpeg

      + The ffmpeg option can generate mpeg films very fast and "on the fly". This means that the mpeg film is growing each time motion is detected. +

      + Some people on the Motion mailing list have had trouble building the ffmpeg package because they did not have the NASM assembler package installed. So pay attention to this if you run into problems. +@@ -2835,14 +1746,14 @@ Motion works with the following versions +

    1. ffmpeg-0.4.8. With this release Motion supports mpeg1, mpeg4 and msmpeg4. Lately newer distributions have problems building this 2003 release of ffmpeg so many of you no longer have this option. +
    2. ffmpeg-0.4.9pre1. Is supported starting from Motion version 3.1.18. With this release Motion supports mpeg4 and msmpeg4 but not mpeg1. The reason is that the ffmpeg team has decided no longer to support non-standard framerates in their mpeg1 encoder library. Also ffmpeg-0.4.9pre1 gives people problems on newer distributions. +
    3. ffmpeg from CVS. This may work. We cannot continuously monitor and try every time a new source file is checked into ffmpeg. You will have to try. +-
    4. ffmpeg RPMs. Currently each Motion release is tested with the current Livna ffmpeg rpm package for Fedora. See the Download Files page for direct links to the version which has been certified with the latest Motion release. ++
    5. ffmpeg RPMs. Currently each Motion release is tested with the current Livna ffmpeg rpm package for Fedora. See the Download Files page for direct links to the version which has been certified with the latest Motion release. +
    6. ffmpeg debian binaries. Latest versions from the debian repository for Debian Sarge works fine with Motion. +
    7. Certified ffmpeg CVS snapshot for latest Motion release is available from the Motion Sourceforge Related Projects file area +
    8. +

      + The timelapse feature always runs mpeg1 with both ffmpeg 0.4.8 and 0.4.9 and newer. Motion simply creates the timelapse film with a standard mpeg1 framerate. Note : maximum size for timelapse files is 2GB. +

      +-In principle Motion can be made to support many other formats. It requires additional coding in Motion. You are welcome to submit patches. All ffmpeg related code is in the source file ffmpeg.c. It is not trivial to do because the ffmpeg libraries not documented at all. All you have is a couple of code examples. ++In principle Motion can be made to support many other formats. It requires additional coding in Motion. You are welcome to submit patches. All ffmpeg related code is in the source file ffmpeg.c. It is not trivial to do because the ffmpeg libraries not documented at all. All you have is a couple of code examples. +

      + To build ffpmeg from source follow these steps: +

      +@@ -2881,13 +1792,12 @@ Note that if you install ffmpeg from sou + These are the config file options related to ffmpeg. +

      +

      +-

      +

      ffmpeg_bps

      +

      +

      + Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. +@@ -2897,14 +1807,12 @@ To use this feature you need to install + Experiment to get the desired quality. The better quality the bigger files. This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled). +

      +

      +-

      +-

      +

      ffmpeg_cap_motion

      +

      +

      + Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. +@@ -2916,14 +1824,12 @@ This feature generates the special motio + To use this feature you need to install the FFmpeg Streaming Multimedia System +

      +

      +-

      +-

      +

      ffmpeg_cap_new

      +

      +

      + Use ffmpeg libraries to encode mpeg movies in realtime. +@@ -2935,14 +1841,12 @@ To use this feature you need to install + Must not be included in config file without having ffmpeg installed. +

      +

      +-

      +-

      +

      ffmpeg_deinterlace

      +

      +

      + Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. +@@ -2957,14 +1861,12 @@ Add Additional Description Below + --> +

      +

      +-

      +-

      +

      ffmpeg_timelapse

      +

      +

      + Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. +@@ -2980,14 +1882,12 @@ To use this feature you need to install + (renamed from ffmpeg_timelaps to ffmpeg_timelapse in 3.1.14) +

      +

      +-

      +-

      +

      ffmpeg_timelapse_mode

      +

        +
      • Type: Discrete Strings +
      • Range / Valid values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual +
      • Default: daily +-
      • Option Topic ++
      • Option Topic +
      +

      + The file rollover mode of the timelapse video. +@@ -2997,14 +1897,12 @@ Note that it is important that you use t + The value 'Manual' means that Motion does not automatically rollover to a new filename. You can do it manually using the http control interface by setting the option 'ffmpeg_timelapse' to 0 and then back to your chosen value. Value 'hourly' rolls over on the full hour. Value 'daily' which is the default rolls over at midnight. There are two weekly options because depending on where you come from a week may either start on Sunday or Monday. And 'monthly' naturally rolls over on the 1st of the month. +

      +

      +-

      +-

      +

      ffmpeg_variable_bitrate

      +

      +

      + Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. +@@ -3012,63 +1910,61 @@ Enables and defines variable bitrate for + Experiment for the value that gives you the desired compromise between size and quality. +

      +

      +-

      +-

      +

      ffmpeg_video_codec

      +

        +
      • Type: Discrete Strings +-
      • Range / Valid values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1, mov ++
      • Range / Valid values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1 +
      • Default: mpeg4 +-
      • Option Topic ++
      • Option Topic +
      +

      + Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. +-

        +-
      • mpeg1 - gives you mpeg1 files with extension .mpg. It is only supported by the old ffmpeg version 0.4.8. The ffmpeg team decided no longer to support non-standard framerates for mpeg1 from ffmpeg version 0.4.9pre1. +-
      • mpeg4 - gives you mpeg4 files with extension .avi +-
      • msmpeg4 - also gives you mpeg4 files. It is s recommended for use with Windows Media Player because it requires with no installation of codec on the Windows client. +-
      • swf - gives you a flash film with extension .swf +-
      • flv - gives you a flash video with extension .flv +-
      • ffv1 - FF video codec 1 for Lossless Encoding (experimental) +-
      • mov - QuickTime (since 3.2.10). +-
      +

      +-This option does not affect the timelapse feature. Timelapse is always recorded in mpeg1 format because we need to be able to append to an existing file. mpeg4 does not easily allow this. ++mpeg1 gives you files with extension .mpg. It is only supported by the old ffmpeg version 0.4.8. The ffmpeg team decided no longer to support non-standard framerates for mpeg1 from ffmpeg version 0.4.9pre1. ++

      ++mpeg4 or msmpeg4 give you files with extension .avi ++

      ++msmpeg4 is recommended for use with Windows Media Player because it requires with no installation of codec on the Windows client. ++

      ++swf gives you a flash film with extension .swf +

      ++flv gives you a flash video with extension .flv ++

      ++ffv1 , FF video codec 1 for Lossless Encoding ( experimental ) ++

      ++This option does not affect the timelapse feature. Timelapse is always recorded in mpeg1 format because we need to be able to append to an existing file. mpeg4 does not easily allow this. +

      +

      +


      +

      +-See also the section Advanced Filenames where the two additional options ffmpeg_filename and timelapse_filename are defined. ++See also the section Advanced Filenames where the two additional options ffmpeg_filename and timelapse_filename are defined. +

      + If you want to use this feature you can read about the FFmpeg Streaming Multimedia System +

      +

      +-

      Snapshots - The Traditional Periodic Web Camera

      ++

      Snapshots - The Traditional Periodic Web Camera

      + Motion can also act like a traditional web camera. +

      +

      +-

      +

      snapshot_interval

      +

      +

      + Make automated snapshots every 'snapshot_interval' seconds. +

      +-The snapshots are stored in the target directory + the directory/filename specified by the snapshot_filename option. ++The snapshots are stored in the target directory + the directory/filename specified by the snapshot_filename option. +

      + This is the traditional web camera feature where a picture is taken at a regular interval independently of motion in the picture. +

      +

      +-

      +-See the also snapshot_filename option in the section Advanced Filenames. ++See the also snapshot_filename option in the section Advanced Filenames. +

      +

      +-

      Text Features

      ++

      Text Features

      + Text features are highly flexible. You can taylor the text displayed on the images and films to your taste and you can add your own user defined text. +

      + This is how the overlayed text is located. +@@ -3105,13 +2001,12 @@ Below are the options that controls the + The text_event feature is special in that it defines the conversion specifier %C which can be used both for text display and for filenames. +

      +

      +-

      +

      locate

      +

      +

      + Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. +@@ -3119,14 +2014,12 @@ Locate and draw a box around the moving + The value 'preview' only works when 'output_normal' is set to either 'first' or 'best'. +

      +

      +-

      +-

      +

      text_changes

      +

      +

      + Turns the text showing changed pixels on/off. +@@ -3134,8 +2027,6 @@ Turns the text showing changed pixels on + By setting this option to 'on' the number of pixels that changed compared to the reference frame is displayed in the upper right corner of the pictures. This is good for calibration and test. Maybe not so interesting for a greater public. Set it to your personal taste. +

      +

      +-

      +-

      +

      text_double

      +

        +
      • Type: Boolean +@@ -3152,14 +2043,12 @@ Add Additional Description Below + --> +

        +

        +-

        +-

        +

        text_event

        +

        +

        + This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. +@@ -3169,17 +2058,15 @@ The idea is that %C can be used filename + Option text_event defines the value %C which then can be used in filenames and text_right/text_left. The text_event/%C uses the time stamp for the first image detected in a new event. %C is an empty string when no event is in progress (gap period expired). Pre_captured and minimum_motion_frames images are time stamped before the event happens so %C in text_left/right does not have any effect on those images. +

        +

        +-

        +-

        +

        text_left

        +

        +

        +-User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). ++User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers (codes starting by a %). +

        + text_left is displayed in the lower left corner of the pictures. If the option is not defined no text is displayed at this position. +

        +@@ -3187,7 +2074,7 @@ You can place the text in quotation mark +

        + Detailed Description +

        +-A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

          ++A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
            +
          • %Y = year +
          • %m = month as two digits +
          • %d = date +@@ -3212,10 +2099,7 @@ These are unique to motion
              +

              + With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. +

              +-For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. +-

              +-

              +-

              ++For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. +

              +

              +

              text_right

              +@@ -3223,10 +2107,10 @@ For a full list of conversion specifiers +
            • Type: String +
            • Range / Valid values: Max 4095 characters +
            • Default: %Y-%m-%d\n%T +-
            • Option Topic ++
            • Option Topic +
            +

            +-User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock ++User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +

            + text_right is displayed in the lower right corner of the pictures. If the option is not defined no text is displayed at this position. +

            +@@ -3236,7 +2120,7 @@ A major difference from text_left is tha +

            + Detailed Description +

            +-A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

              ++A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                +
              • %Y = year +
              • %m = month as two digits +
              • %d = date +@@ -3261,22 +2145,19 @@ These are unique to motion
                  +

                  + With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. +

                  +-For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. +-

                  ++For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. +

                  +

                  +-

                  +-

                  +-

                  Advanced Filenames

                  ++

                  Advanced Filenames

                  + Motion has a very advanced and flexible automated filenaming feature. +

                  +-By using conversion specifiers (codes that consist of a '%' followed by a letter) you can build up the filenames including sub directories for pictures and movies using any combination of letters, numbers and conversion specifiers which are codes that represents time, date, event number and frame numbers. ++By using conversion specifiers (codes that consist of a '%' followed by a letter) you can build up the filenames including sub directories for pictures and movies using any combination of letters, numbers and conversion specifiers which are codes that represents time, date, event number and frame numbers. +

                  + The option target_dir is the target directory for all snapshots, motion images and normal images. The default is the current working directory (current working directory of the terminal from which motion was started). You will normally always want to specify this parameter. +

                  + Note that the options snapshot_filename, jpeg_filename, ffmpeg_filename, and timelapse_filename all allow specifying directories by using '/' in the filename. These will all be relative to target_dir. This means in principle that you can specify target_dir as '/' and be 100% flexible. It also means that Motion can write files all over your harddisk if you make a mistake. It is recommended to specify the target_dir as deep or detailed as possible for this reason. And note that targer_dir does not allow conversion specifiers. +

                  +-The conversion specifier %C which is defined by the option text_event is interesting in connection with filenames because it can be used to create files and directories for each event in a very flexible way. ++The conversion specifier %C which is defined by the option text_event is interesting in connection with filenames because it can be used to create files and directories for each event in a very flexible way. +

                  + The convertion specifier %t (thread/camera number) is also very useful. Here is an example of filename definitions in motion.conf: +

                  +@@ -3292,7 +2173,7 @@ The smart thing is that this defines the +

                  + NOTE: Unless you use the minimum_gap option to limit the number of shots to less then one per second - you must use the frame modifier %q as part of the jpeg_filename. Otherwise the pictures saved within the same second will overwrite each other. The %q in jpeg_filename ensures that each jpeg (or ppm) picture saved gets a unique filename. +

                  +-ALERT! Security Warning! Note that the flexibility of this feature also means you have to pay attention to the following.

                    ++ALERT! Security Warning! Note that the flexibility of this feature also means you have to pay attention to the following.
                      +
                    • Anyone with access to the remote control port (http) can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. +
                    • Anyone with local access to the computer and edit rights to the motion.conf file can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Make sure the motion.conf file is maximum readonly to anyone else but the user running Motion. +
                    • It is a good idea to run Motion as a harmless user. Not as root. +@@ -3301,15 +2182,14 @@ NOTE: Unless you use the minimum_g + These are the advanced filename options in motion.conf +

                      +

                      +-

                      +

                      ffmpeg_filename (now called movie_filename)

                      +

                      +-ALERT! This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. ++ALERT! This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. +

                        +
                      • Type: String +
                      • Range / Valid values: Max 4095 characters +
                      • Default: %v-%Y%m%d%H%M%S +-
                      • Option Topic ++
                      • Option Topic +
                      +

                      + File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. +@@ -3319,7 +2199,7 @@ For Motion 3.0 compatible mode (director +

                      + File extension .mpg or .avi is automatically added so do not include this. +

                      +-This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                        ++This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                          +
                        • %Y = year +
                        • %m = month as two digits +
                        • %d = date +@@ -3345,21 +2225,19 @@ These are unique to motion
                            + If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and %Y/%m/%d/%H%M%S for 'oldlayout off'. +

                            +

                            +-

                            +-

                            +

                            jpeg_filename

                            +

                              +
                            • Type: String +
                            • Range / Valid values: Max 4095 characters +
                            • Default: %v-%Y%m%d%H%M%S-%q +-
                            • Option Topic ++
                            • Option Topic +
                            +

                            + File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. +

                            + Default value is equivalent to legacy 'oldlayout' option. For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H/%M/%S-%q +

                            +-This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                              ++This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                +
                              • %Y = year +
                              • %m = month as two digits +
                              • %d = date +@@ -3387,26 +2265,24 @@ If you are happy with the directory stru + The value 'preview' only works when 'output_normal' is set to 'best'. It makes Motion name the best preview jpeg file (image with most changed pixels during the event) with the same body name as the mpeg movie created during the same event. The purpose is to create a good single image that represents the saved mpeg moview so you can decide if you want to see it and spend time downloading it from a web page. +

                                +

                                +-

                                +-

                                +

                                movie_filename

                                +

                                  +
                                • Type: String +
                                • Range / Valid values: Max 4095 characters +
                                • Default: %v-%Y%m%d%H%M%S +-
                                • Option Topic ++
                                • Option Topic +
                                +

                                + File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. +

                                +-ALERT! This option was renamed from ffmpeg_filename to movie_filename in Motion 3.2.5. ++ALERT! This option was renamed from ffmpeg_filename to movie_filename in Motion 3.2.5. +

                                + Default value is equivalent to legacy 'oldlayout' option + For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H%M%S +

                                + File extension .mpg or .avi is automatically added so do not include this. +

                                +-This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                  ++This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                    +
                                  • %Y = year +
                                  • %m = month as two digits +
                                  • %d = date +@@ -3432,14 +2308,12 @@ These are unique to motion
                                      + If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and %Y/%m/%d/%H%M%S for 'oldlayout off'. +

                                      +

                                      +-

                                      +-

                                      +

                                      snapshot_filename

                                      +

                                        +
                                      • Type: String +
                                      • Range / Valid values: Max 4095 characters +
                                      • Default: %v-%Y%m%d%H%M%S-snapshot +-
                                      • Option Topic ++
                                      • Option Topic +
                                      +

                                      + File path for snapshots (jpeg or ppm) relative to target_dir. +@@ -3449,7 +2323,7 @@ Default value is equivalent to legacy 'o + File extension .jpg or .ppm is automatically added so do not include this + A symbolic link called lastsnap.jpg (or lastsnap.ppm) created in the target_dir will always point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +

                                      +-This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                        ++This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                          +
                                        • %Y = year +
                                        • %m = month as two digits +
                                        • %d = date +@@ -3477,14 +2351,12 @@ If you are happy with the directory stru + For the equivalent of the now obsolete option 'snap_overwrite' use the value 'lastsnap'. +

                                          +

                                          +-

                                          +-

                                          +

                                          target_dir

                                          +

                                            +
                                          • Type: String +
                                          • Range / Valid values: Max 4095 characters +
                                          • Default: Not defined = current working directory +-
                                          • Option Topic ++
                                          • Option Topic +
                                          +

                                          + Target directory for picture and movie files. +@@ -3494,14 +2366,12 @@ This is the target directory for all sna + Note that the options snapshot_filename, jpeg_filename, ffmpeg_filename, and timelapse_filename all allows specifying directories. These will all be relative to 'target_dir'. This means in principle that you can specify target_dir as '/' and be 100% flexible. It also means that Motion can write files all over your harddisk if you make a mistake. It is recommended to specify the target_dir as deep or detailed as possible for this reason. +

                                          +

                                          +-

                                          +-

                                          +

                                          timelapse_filename

                                          +

                                            +
                                          • Type: String +
                                          • Range / Valid values: Max 4095 characters +
                                          • Default: %v-%Y%m%d-timelapse +-
                                          • Option Topic ++
                                          • Option Topic +
                                          +

                                          + File path for timelapse mpegs relative to target_dir (ffmpeg only). +@@ -3512,7 +2382,7 @@ For Motion 3.0 compatible mode (director +

                                          + File extension .mpg is automatically added so do not include this. +

                                          +-This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                            ++This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                              +
                                            • %Y = year +
                                            • %m = month as two digits +
                                            • %d = date +@@ -3538,219 +2408,68 @@ These are unique to motion
                                                + If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d-timelapse for 'oldlayout on' and %Y/%m/%d-timelapse for 'oldlayout off'. +

                                                +

                                                +-

                                                +-

                                                +-

                                                +-

                                                Conversion Specifiers for Advanced Filename and Text Features

                                                ++

                                                Conversion Specifiers for Advanced Filename and Text Features

                                                + The table below shows all the supported Conversion Specifiers you can use in the options text_event, text_left, text_right, sql_query, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. +

                                                + In text_left and text_right you can additionally use '\n' for new line. +

                                                +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
                                                Conversion Specifier Description
                                                %a The abbreviated weekday name according to the current locale.
                                                %A The full weekday name according to the current locale.
                                                %b The abbreviated month name according to the current locale.
                                                %B The full month name according to the current locale.
                                                %c The preferred date and time representation for the current locale.
                                                %C Text defined by the text_event feature
                                                %d The day of the month as a decimal number (range 01 to 31).
                                                %D Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area.
                                                %E Modifier: use alternative format, see below.
                                                %f File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %F Equivalent to %Y-%m-%d (the ISO 8601 date format).
                                                %H The hour as a decimal number using a 24-hour clock (range 00 to 23).
                                                %i Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %I The hour as a decimal number using a 12-hour clock (range 01 to 12).
                                                %j The day of the year as a decimal number (range 001 to 366).
                                                %J Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.)
                                                %K X coordinate in pixels of the center point of motion. Origin is upper left corner.
                                                %l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.)
                                                %L Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon).
                                                %m The month as a decimal number (range 01 to 12).
                                                %M The minute as a decimal number (range 00 to 59).
                                                %n Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %N Noise level.
                                                %o Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold.
                                                %p Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'.
                                                %P Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
                                                %q Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs.
                                                %Q Number of detected labels found by the despeckle feature
                                                %r The time in a.m. or p.m. notation.
                                                %R The time in 24-hour notation (%H:%M).
                                                %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
                                                %S The second as a decimal number (range 00 to 61).
                                                %t Thread number (camera number)
                                                %T The time in 24-hour notation (%H:%M:%S).
                                                %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
                                                %U The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
                                                %v Event number. An event is a series of motion detections happening with less than 'gap' seconds between them.
                                                %V The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W.
                                                %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
                                                %W The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
                                                %x The preferred date representation for the current locale without the time.
                                                %X The preferred time representation for the current locale without the date.
                                                %y The year as a decimal number without a century (range 00 to 99).
                                                %Y The year as a decimal number including the century.
                                                %z The time-zone as hour offset from GMT.
                                                %Z The time zone or name or abbreviation.
                                                ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
                                                Conversion Specifier Description
                                                %a The abbreviated weekday name according to the current locale.
                                                %A The full weekday name according to the current locale.
                                                %b The abbreviated month name according to the current locale.
                                                %B The full month name according to the current locale.
                                                %c The preferred date and time representation for the current locale.
                                                %C Text defined by the text_event feature
                                                %d The day of the month as a decimal number (range 01 to 31).
                                                %D Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area.
                                                %E Modifier: use alternative format, see below.
                                                %f File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %F Equivalent to %Y-%m-%d (the ISO 8601 date format).
                                                %H The hour as a decimal number using a 24-hour clock (range 00 to 23).
                                                %i Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %I The hour as a decimal number using a 12-hour clock (range 01 to 12).
                                                %j The day of the year as a decimal number (range 001 to 366).
                                                %J Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.)
                                                %K X coordinate in pixels of the center point of motion. Origin is upper left corner.
                                                %l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.)
                                                %L Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon).
                                                %m The month as a decimal number (range 01 to 12).
                                                %M The minute as a decimal number (range 00 to 59).
                                                %n Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %N Noise level.
                                                %o Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold.
                                                %p Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'.
                                                %P Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
                                                %q Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs.
                                                %Q Number of detected labels found by the despeckle feature
                                                %r The time in a.m. or p.m. notation.
                                                %R The time in 24-hour notation (%H:%M).
                                                %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
                                                %S The second as a decimal number (range 00 to 61).
                                                %t Thread number (camera number)
                                                %T The time in 24-hour notation (%H:%M:%S).
                                                %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
                                                %U The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
                                                %v Event number. An event is a series of motion detections happening with less than 'gap' seconds between them.
                                                %V The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W.
                                                %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
                                                %W The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
                                                %x The preferred date representation for the current locale without the time.
                                                %X The preferred time representation for the current locale without the date.
                                                %y The year as a decimal number without a century (range 00 to 99).
                                                %Y The year as a decimal number including the century.
                                                %z The time-zone as hour offset from GMT.
                                                %Z The time zone or name or abbreviation.
                                                +

                                                +

                                                +-

                                                Webcam Server

                                                ++

                                                Webcam Server

                                                + Motion has simple webcam server built in. The video stream is in mjpeg format. +

                                                + Each thread can have its own webcam server. If you enable the webcam server (option webcam_port to a number different from 0) and you have more than one camera, you must make sure to include webcam_port in each thread config file and set webcam_port to different and unique port numbers or zero (disable). Otherwise each webcam server will use the setting from the motion.conf file and try to bind to the same port. If the webcam_port numbers are not different from each other Motion will disable the webcam feature. +

                                                +-Note: The webcam server feature requires that the option ppm is set to off. ++Note: The webcam server feature requires that the option ppm is set to off. (I.e. saved images are jpeg images). +

                                                + The webcam_maxrate and webcam_quality options are important to limit the load on your server and link. Don't set them too high unless you only use it on the localhost or on an internal LAN. The option webcam_quality is equivalent to the quality level for jpeg pictures. +

                                                +@@ -3790,20 +2509,17 @@ Note that the stream.mjpg p + These are the special webcam parameters. +

                                                +

                                                +-

                                                +

                                                webcam_limit

                                                +

                                                +

                                                + Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. +

                                                +-Number can be defined by multiplying actual webcam rate by desired number of seconds. Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate. +-

                                                +-

                                                ++Number can be defined by multiplying actual webcam rate by desired number of seconds. Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate. +

                                                +

                                                +

                                                webcam_localhost

                                                +@@ -3811,7 +2527,7 @@ Number can be defined by multiplying act +
                                              • Type: Boolean +
                                              • Range / Valid values: on, off +
                                              • Default: on +-
                                              • Option Topic ++
                                              • Option Topic +
                                              +

                                              + Limits the access to the webcam to the localhost. +@@ -3819,14 +2535,12 @@ Limits the access to the webcam to the l + By setting this to on, the webcam can only be accessed on the same machine on which Motion is running. +

                                              +

                                              +-

                                              +-

                                              +

                                              webcam_maxrate

                                              +

                                              +

                                              + Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. +@@ -3834,14 +2548,12 @@ Limit the framerate of the webcam in fra + Don't set 'webcam_maxrate' too high unless you only use it on the localhost or on an internal LAN. +

                                              +

                                              +-

                                              +-

                                              +

                                              webcam_motion

                                              +

                                              +

                                              + If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. +@@ -3852,13 +2564,12 @@ Note that this feature was greatly impro +

                                              +

                                              +

                                              +-

                                              +

                                              webcam_port

                                              +

                                              +

                                              + TCP port on which motion will listen for incoming connects with its webcam server. +@@ -3868,23 +2579,19 @@ Note that each camera thread must have i + A good value to select is 8081 for camera 1, 8082 for camera 2, 8083 for camera 3 etc etc. +

                                              +

                                              +-

                                              +-

                                              +

                                              webcam_quality

                                              +

                                              +

                                              + Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. +

                                              + The mjpeg stream consists of a header followed by jpeg frames separated by content-length and boundary string. The quality level defines the size of the individual jpeg pictures in the mjpeg stream. If you set it too high you need quite a high bandwidth to view the stream. +

                                              +-

                                              +-

                                              +-

                                              Remote Control with http

                                              ++

                                              Remote Control with http

                                              +

                                              + Motion can be remote controlled via a simple http interface. http is the language a normal web browser talks when it requests a web page. The web server answers back with some simple http headers followed by a webpage coded in HTML. +

                                              +@@ -3892,9 +2599,9 @@ Most Motion config options can be change +

                                              + So the most obvious tool to use to remote control Motion is any web browser. All commands are sent using the http GET method which simply means that the information is sent via the URL and maybe a query string. You can use any browser (Firefox, Mozilla, Internet Explorer, Konquerer, Opera etc). You can also use the text based browser lynx to control Motion from a console. It navigates fine through the very simple and minimalistic http control interface of Motion. +

                                              +-The details about how to control Motion via the URL is described in detail in the Motion http API topic. ++The details about how to control Motion via the URL is described in detail in the Motion http API topic. +

                                              +-But it is probably simpler to connect to the control port with a browser, navigate to the function you want, and copy the URL from the browser URL entry line. If your control_port is 8080 and you browse from the same machine on which Motion runs simply look up http://localhost:8080/ and navigate around. Connecting from a remote machine is done by using a domain name (example http://mydomain.com:8080/) or the IP address of the machine (example http://192.168.1.4:8080/). The option control_localhost must be off to allow connection from a remote machine. ++But it is probably simpler to connect to the control port with a browser, navigate to the function you want, and copy the URL from the browser URL entry line. If your control_port is 8080 and you browse from the same machine on which Motion runs simply look up http://localhost:8080/ and navigate around. Connecting from a remote machine is done by using a domain name (example http://mydomain.com:8080/) or the IP address of the machine (example http://192.168.1.4:8080/). The option control_localhost must be off to allow connection from a remote machine. +

                                              + If you want to use a script or cron to automatically change Motion settings while Motion runs you use a program that can fetch a webpage. We simply just throw away the html page that Motion returns. Programs commonly available on Linux machines are wget and lwp-request. Here is an example of how to start and stop motion detection via cron. These two lines are added to /etc/crontab. +

                                              +@@ -3913,7 +2620,7 @@ What happened to XMLRPC? +

                                              + XMLRPC is replaced by a simpler http remote control interface. It is still being worked on but it is absolutely useable now and much nicer to work with than xmlrpc. Another advantage is that you do not need to install xmlrpc libraries. It is all written in standard C. +

                                              +-ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.

                                                ++ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.
                                                  +
                                                • Anyone with access to the remote control port (http) can alter the values of any options and save files anywhere on your server with the same privileges as the user running Motion. They can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. +
                                                • If you limit control port to localhost you still need to take care of any user logging into the server with any kind of terminal session. +
                                                • It is a good idea to run Motion as a harmless user. Not as root!! +@@ -3924,13 +2631,12 @@ XMLRPC is replaced by a simpler http rem + These must be placed in motion.conf and not in a thread config file. +

                                                  +

                                                  +-

                                                  +

                                                  control_authentication

                                                  +

                                                  +

                                                  + To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. +@@ -3944,14 +2650,12 @@ Add Additional Description Below + --> +

                                                  +

                                                  +-

                                                  +-

                                                  +

                                                  control_html_output

                                                  +

                                                  +

                                                  + Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. +@@ -3959,14 +2663,12 @@ Enable HTML in the answer sent back to a + The recommended value for most is "on" which means that you can navigate and control Motion with a normal browser. By setting this option to "off" the replies are in plain text which may be easier to parse for 3rd party programs that control Motion. +

                                                  +

                                                  +-

                                                  +-

                                                  +

                                                  control_localhost

                                                  +

                                                  +

                                                  + Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. +@@ -3974,14 +2676,12 @@ Limits the http (html) control to the lo + By setting this to on, the control using http (browser) can only be accessed on the same machine on which Motion is running. +

                                                  +

                                                  +-

                                                  +-

                                                  +

                                                  control_port

                                                  +

                                                  +

                                                  + Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. +@@ -3990,68 +2690,29 @@ This sets the TCP/IP port number to be u +

                                                  +

                                                  +

                                                  ++-- KennethLavrsen - 12 Apr 2005 +

                                                  +--- KennethLavrsen - 12 Apr 2005 +

                                                  +-

                                                  External Commands

                                                  ++

                                                  External Commands

                                                  + Motion can execute external commands based on the motion detection and related events. They are all described in this section. The option quiet is also included in this section. +

                                                  + A redesign of the external commands was due. They were not very easy to understand, not all were flexible enough and some were missing. So a new external command feature set was made for 3.2.1 and on. +

                                                  + This is how the new script commands look like: +

                                                  +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
                                                  Function Old Option New Option Argument Appended
                                                  Start of event (first motion) execute on_event_start None
                                                  End of event (no motion for gap seconds) New! on_event_end None
                                                  Picture saved (jpg or ppm) onsave on_picture_save Filename of picture
                                                  Movie starts (mpeg file opened) onmpeg on_movie_start Filename of movie
                                                  Movie ends (mpeg file closed) onffmpegclose on_movie_end Filename of movie
                                                  Motion detected (each single frame with Motion detected) New! on_motion_detected None
                                                  ++ ++ ++ ++ ++ ++ ++ ++
                                                  Function Old Option New Option Argument Appended
                                                  Start of event (first motion) execute on_event_start None
                                                  End of event (no motion for gap seconds) New! on_event_end None
                                                  Picture saved (jpg or ppm) onsave on_picture_save Filename of picture
                                                  Movie starts (mpeg file opened) onmpeg on_movie_start Filename of movie
                                                  Movie ends (mpeg file closed) onffmpegclose on_movie_end Filename of movie
                                                  Motion detected (each single frame with Motion detected) New! on_motion_detected None
                                                  +

                                                  +-Mail and sms has been removed because they were not configurable. If you want to send event-based mails or sms, just use one of those commands above and send the mail from that script. See What happened to mail and sms? ++Mail and sms has been removed because they were not configurable. If you want to send event-based mails or sms, just use one of those commands above and send the mail from that script. See What happened to mail and sms? +

                                                  +

                                                  +-ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.

                                                    ++ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.
                                                      +
                                                    • Anyone with access to the remote control port (http) can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. +
                                                    • If you limit control port to localhost you still need to take care of any user logging into the server with any kind of GUI or terminal session. All it takes is a browser or single command line execution to change settings in Motion. +
                                                    • It is a good idea to run Motion as a harmless user. Not as root!! +@@ -4060,52 +2721,15 @@ Mail and sms has been removed because th + These are the options +

                                                      +

                                                      +-

                                                      +-

                                                      on_area_detected

                                                      +-

                                                        +-
                                                      • Type: String +-
                                                      • Range / Valid values: Max 4095 characters +-
                                                      • Default: Not defined +-
                                                      • Option Topic +-
                                                      +-

                                                      +-Command to be executed when motion in a predefined area is detected. Check option area_detect. +-

                                                      +- +-

                                                      +-

                                                      +-

                                                      +-

                                                      +-

                                                      on_camera_lost

                                                      +-

                                                        +-
                                                      • Type: String +-
                                                      • Range / Valid values: Max 4095 characters +-
                                                      • Default: Not defined +-
                                                      • Option Topic +-
                                                      +-

                                                      +-Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10) +-

                                                      +- +-

                                                      +-NOTE: There is situations when motion don't detect a lost camera!
                                                      It depends on the driver, some drivers dosn't detect a lost camera at all
                                                      Some hangs the motion thread. Some even hangs the PC! +-

                                                      +-

                                                      +-

                                                      +-

                                                      +

                                                      on_event_end

                                                      +

                                                      +

                                                      +-Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. ++Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. +

                                                      + Full path name of the program/script. +

                                                      +@@ -4114,17 +2738,15 @@ This can be any type of program or scrip + The command is run when an event is over. I.e. the number of seconds defined by the time 'gap' has passed since the last detection of motion and motion closes the mpeg file. +

                                                      +

                                                      +-

                                                      +-

                                                      +

                                                      on_event_start

                                                      +

                                                      +

                                                      +-Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. ++Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. +

                                                      + Full path name of the program/script. +

                                                      +@@ -4135,31 +2757,28 @@ The command is run when an event starts. + This option replaces the former options 'mail', 'sms' and 'execute'. +

                                                      +

                                                      +-

                                                      +-

                                                      +

                                                      on_motion_detected

                                                      +

                                                      +

                                                      +-Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. ++Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. +

                                                      + Do not write "none" if you do not want to execute commands. Simply do not include the option in the file or comment it out by placing a "#" or ";" as the first character on the line before the execute command. +

                                                      +

                                                      +-

                                                      +

                                                      on_movie_end

                                                      +

                                                      +

                                                      +-Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. ++Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. +

                                                      + Full path name of the program/script. +

                                                      +@@ -4171,7 +2790,7 @@ This option was previously called onffmp +

                                                      + Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. +

                                                      +-Most common conversion specifiers ++Most common conversion specifiers +

                                                        +
                                                      • %Y = year, %m = month, %d = date +
                                                      • %H = hour, %M = minute, %S = second +@@ -4188,28 +2807,25 @@ Most common on_movie_start +

                                                        +

                                                        +-Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. ++Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. +

                                                        + Full path name of the program/script. +

                                                        +-This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. When you use ffmpeg the film is generated on the fly and on_movie_start then runs when the new mpeg file is created. Often you will want to use the on_movie_end option which runs when the mpeg file is closed and the event is over. ++This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. When you use ffmpeg the film is generated on the fly and on_movie_start then runs when the new mpeg file is created. Often you will want to use the on_movie_end option which runs when the mpeg file is closed and the event is over. +

                                                        + This option was previously called onmpeg. +

                                                        + Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. +

                                                        +-Most common conversion specifiers ++Most common conversion specifiers +

                                                          +
                                                        • %Y = year, %m = month, %d = date +
                                                        • %H = hour, %M = minute, %S = second +@@ -4226,18 +2842,15 @@ Most common on_picture_save +

                                                          +

                                                          +-Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. ++Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. +

                                                          + Full path name of the program/script. +

                                                          +@@ -4245,7 +2858,7 @@ This can be any type of program or scrip +

                                                          + Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. +

                                                          +-Most common conversion specifiers ++Most common conversion specifiers +

                                                            +
                                                          • %Y = year, %m = month, %d = date +
                                                          • %H = hour, %M = minute, %S = second +@@ -4262,15 +2875,12 @@ Most common quiet +

                                                            +

                                                            + Be quiet, don't output beeps when detecting motion. +@@ -4279,15 +2889,14 @@ Only works in non-daemon mode. +

                                                            +

                                                            +

                                                            +-

                                                            + +-

                                                            What happened to mail and sms?

                                                            ++

                                                            What happened to mail and sms?

                                                            + The 6 new on_xxxxx options replace the former execute, mail and sms options. +

                                                            + They are quite generic and flexible. These small bash scripts gives to the same functionality as mail and sms BUT you have all the flexibility you want to extend the messages, change the 'from' email address etc. +

                                                            +

                                                            Sending email at start of event

                                                            +-Script written by JoergWeber ++Script written by JoergWeber +
                                                            + #!/bin/sh
                                                            + 
                                                            +@@ -4309,7 +2918,7 @@ echo -e "This is an automated messag
                                                            + 
                                                            +

                                                            +

                                                            Sending SMS at start of event

                                                            +-Script written by JoergWeber ++Script written by JoergWeber +

                                                            + If you uncomment the line #/usr/local/bin/send_mail $1 you can combine both sending email and sms. +

                                                            +@@ -4337,28 +2946,26 @@ $SMS_CLIENT $TO "Motion detected
                                                            + 
                                                            +

                                                            +

                                                            +-

                                                            +

                                                            Motion Guide - Special Features

                                                            +

                                                            +-

                                                            Tracking Control

                                                            +-This is still at the experimental stage. Read more about it motion tracking page. ++

                                                            Tracking Control

                                                            ++This is still at the experimental stage. Read more about it motion tracking page. +

                                                            +

                                                            Tracking Feature with Logitech Quickcam Sphere/Orbit

                                                            + Motion supports controlling the pan and tilt feature of a Logitech Quickcam Sphere/Orbit. +

                                                            +-Motion can move the camera to a fixed position given in degrees pan (left-right) and tilt (down-up). Movement can be set with absolute coordinates or relative to current position. There is also an auto tracking feature for the Logitech Quickcam Sphere/Orbit but it is not very mature. It is fun to play with but not very useful yet. See this topic of how KennethLavrsen controls his Sphere: LogitechSphereControl. ++Motion can move the camera to a fixed position given in degrees pan (left-right) and tilt (down-up). Movement can be set with absolute coordinates or relative to current position. There is also an auto tracking feature for the Logitech Quickcam Sphere/Orbit but it is not very mature. It is fun to play with but not very useful yet. See this topic of how KennethLavrsen controls his Sphere: LogitechSphereControl. +

                                                            +-For a detailed description of http remote control see the section Remote Control with http. ++For a detailed description of http remote control see the section Remote Control with http. +

                                                            + List of tracking options +

                                                            +-

                                                            +

                                                            track_auto

                                                            +

                                                            +

                                                            + Enable auto tracking +@@ -4366,14 +2973,12 @@ Enable auto tracking + Requires a tracking camera type supported by Motion. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_iomojo_id

                                                            +

                                                              +
                                                            • Type: Integer +-
                                                            • Range / Valid values: 0 - 65535 ++
                                                            • Range / Valid values: 0 - 2147483647 +
                                                            • Default: 0 +-
                                                            • Option Topic ++
                                                            • Option Topic +
                                                            +

                                                            + Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. +@@ -4381,14 +2986,12 @@ Use this option if you have an iomojo sm + Only used for iomojo camera. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_maxx

                                                            +

                                                              +
                                                            • Type: Integer +-
                                                            • Range / Valid values: 0 - 65535 +-
                                                            • Default: 0 +-
                                                            • Option Topic ++
                                                            • Range / Valid values: 0 - 2147483647 ++
                                                            • Default: 0 ++
                                                            • Option Topic +
                                                            +

                                                            + The maximum position for servo x. +@@ -4396,14 +2999,12 @@ The maximum position for servo x. + Only used for stepper motor tracking. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_maxy

                                                            +

                                                              +
                                                            • Type: Integer +-
                                                            • Range / Valid values: 0 - 65535 ++
                                                            • Range / Valid values: 0 - 2147483647 +
                                                            • Default: 0 +-
                                                            • Option Topic ++
                                                            • Option Topic +
                                                            +

                                                            + The maximum position for servo y. +@@ -4415,14 +3016,12 @@ Add Additional Description Below + --> +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_motorx

                                                            +

                                                              +
                                                            • Type: Integer +-
                                                            • Range / Valid values: 0 - 65535 +-
                                                            • Default: 0 +-
                                                            • Option Topic ++
                                                            • Range / Valid values: -1 - 2147483647 ++
                                                            • Default: -1 ++
                                                            • Option Topic +
                                                            +

                                                            + The motor number that is used for controlling the x-axis. +@@ -4430,14 +3029,12 @@ The motor number that is used for contro + Only used for stepper motor tracking. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_motory

                                                            +

                                                              +
                                                            • Type: Integer +-
                                                            • Range / Valid values: 0 - 65535 +-
                                                            • Default: 0 +-
                                                            • Option Topic ++
                                                            • Range / Valid values: -1 - 2147483647 ++
                                                            • Default: -1 ++
                                                            • Option Topic +
                                                            +

                                                            + The motor number that is used for controlling the y-axis. +@@ -4449,14 +3046,12 @@ Add Additional Description Below + --> +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_move_wait

                                                            +

                                                              +
                                                            • Type: Integer +-
                                                            • Range / Valid values: 0 - 65535 ++
                                                            • Range / Valid values: 0 - 2147483647 +
                                                            • Default: 10 +-
                                                            • Option Topic ++
                                                            • Option Topic +
                                                            +

                                                            + Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. +@@ -4464,14 +3059,12 @@ Delay during which tracking is disabled + The actual delay is depending on the chosen framerate. If you want the camera to move maximum once every 2 seconds and the framerate is 10 then you need to set the track_move_wait value to 2 * 10 = 20. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_port

                                                            +

                                                            +

                                                            + This is the device name of the serial port to which the stepper motor interface is connected. +@@ -4479,14 +3072,12 @@ This is the device name of the serial po + Only used for stepper motor tracking. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_speed

                                                            +

                                                            +

                                                            + Speed to set the motor to. +@@ -4494,14 +3085,12 @@ Speed to set the motor to. + Only used for stepper motor tracking. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_step_angle_x

                                                            +

                                                            +

                                                            + Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. +@@ -4509,14 +3098,12 @@ Angle in degrees the camera moves per st + Requires a tracking camera type pwc. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_step_angle_y

                                                            +

                                                            +

                                                            + Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. +@@ -4528,14 +3115,12 @@ Add Additional Description Below + --> +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_stepsize

                                                            +

                                                            +

                                                            + Number of steps to make. +@@ -4543,52 +3128,45 @@ Number of steps to make. + Only used for stepper motor tracking. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            track_type

                                                            +

                                                              +
                                                            • Type: Discrete Strings +
                                                            • Range / Valid values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) +
                                                            • Default: 0 (None) +-
                                                            • Option Topic ++
                                                            • Option Topic +
                                                            +

                                                            + Type of tracker. +

                                                            +-Motion has special tracking options which use either a serial stepper motor controller, an iomojo smile cam or a Philips WebCam driver compatible pan/tilt camera such as the Logitech Quickcam Sphere or Orbit. ++Motion has special tracking options which use either a serial stepper motor controller, an iomojo smile cam or a Philips WebCam driver compatible pan/tilt camera such as the Logitech Quickcam Sphere or Orbit. +

                                                            + To disable tracking, set this to 0 and the other track options are ignored. +

                                                            +-Value 1 is for the special Motion Tracking project using a stepper motor and a home made controller. ++Value 1 is for the special Motion Tracking project using a stepper motor and a home made controller. +

                                                            + Value 2 is for the iomojo smilecam +

                                                            +-Value 3 is for pwc type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit which is driven by the pwc (Philips WebCam) driver. To use this camera your version of pwc must be at least 8.12. ++Value 3 is for pwc type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit which is driven by the pwc (Philips WebCam) driver. To use this camera your version of pwc must be at least 8.12. +

                                                            + Value 4 is the generic track type. Currently it has no other function than enabling some of the internal Motion features related to tracking. Eventually more functionality will be implemented for this type. +

                                                            + Value 5 is for uvcvideo type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit MP (new Model) which is driven by the uvcvideo driver. This option was added in Motion 3.2.8. +

                                                            +

                                                            +-

                                                            +-

                                                            +-

                                                            +-

                                                            +-

                                                            Using Databases

                                                            +-Motion can be compiled with both MySQL and PostgreSQL database support. When enabled Motion adds a record to a table in the database as specified by the sql_query. The query contains the fields that are used and the value are given by using conversion specifiers for dynamic data like filename, time, number of detected pixels etc. Motion does not place any binary images in the database and it cannot remove old records. ++

                                                            Using Databases

                                                            ++Motion can be compiled with both MySQL and PostgreSQL database support. When enabled Motion adds a record to a table in the database as specified by the sql_query. The query contains the fields that are used and the value are given by using conversion specifiers for dynamic data like filename, time, number of detected pixels etc. Motion does not place any binary images in the database and it cannot remove old records. +

                                                            + Motion only adds records to the database when files are created. The database contains records of saved files which means to get a record in the database the feature that enables for example motion detection, timelapse, snapshots etc must be enabled. The sql_log options defines which types of files are logged in the database. +

                                                            + The following sql_log options are common to both MySQL and PostgreSQL. +

                                                            +

                                                            +-

                                                            +

                                                            sql_log_image

                                                            +

                                                            +

                                                            + Log to the database when creating motion triggered image file. +@@ -4596,14 +3174,12 @@ Log to the database when creating motion + Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            sql_log_mpeg

                                                            +

                                                            +

                                                            + Log to the database when creating motion triggered mpeg file. +@@ -4611,14 +3187,12 @@ Log to the database when creating motion + Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            sql_log_snapshot

                                                            +

                                                            +

                                                            + Log to the database when creating a snapshot image file. +@@ -4626,14 +3200,12 @@ Log to the database when creating a snap + Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            sql_log_timelapse

                                                            +

                                                            +

                                                            + Log to the database when creating timelapse mpeg file +@@ -4641,19 +3213,17 @@ Log to the database when creating timela + Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. +

                                                            +

                                                            +-

                                                            +-

                                                            +

                                                            sql_query

                                                            +

                                                              +
                                                            • Type: String +
                                                            • Range / Valid values: Max 4095 characters +
                                                            • Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') +-
                                                            • Option Topic ++
                                                            • Option Topic +
                                                            +

                                                            +-SQL query string that is sent to the database. The values for each field are given by using convertion specifiers ++SQL query string that is sent to the database. The values for each field are given by using convertion specifiers +

                                                            +-Most common conversion specifiers ++Most common conversion specifiers +

                                                              +
                                                            • %Y = year, %m = month, %d = date +
                                                            • %H = hour, %M = minute, %S = second +@@ -4670,13 +3240,12 @@ Most common +-

                                                              MySQL

                                                              ++

                                                              MySQL

                                                              + You can use the MySQL database to register each file that is stored by motion. +

                                                              +-You need to generate a new database with a name of your own choice. You must enter this name in the config file (mysql_db option). The default value for the option sql_query requires that you create a new database in MySQL with a new table called "security" with the following fields: ++You need to generate a new database with a name of your own choice. You must enter this name in the config file (mysql_db option). The default value for the option sql_query requires that you create a new database in MySQL with a new table called "security" with the following fields: +

                                                              + insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') +

                                                                +@@ -4688,37 +3257,17 @@ insert into security(camera, filename, f +
                                                              • text_event (timestamp) - The text from the text_event option which by default is compatible with timestamps in SQL. +
                                                              +

                                                              +-Note from version 3.2.4 the introduction of sql_query completely redefines the way you setup the SQL feature. It is now 100% flexible and can easily be made compatible with your existing Motion database from earlier versions of Motion. ++Note from version 3.2.4 the introduction of sql_query completely redefines the way you setup the SQL feature. It is now 100% flexible and can easily be made compatible with your existing Motion database from earlier versions of Motion. +

                                                              + These are the file type descriptions and the file type numbers stored in the database. +

                                                              +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +-
                                                              Normal image 1
                                                              Snapshot image 2
                                                              Motion image (showing only pixels defined as motion) 4
                                                              Normal mpeg image 8
                                                              Motion mpeg (showing only pixels defined as motion) 16
                                                              Timelapse mpeg 32
                                                              ++ ++ ++ ++ ++ ++ ++
                                                              Normal image 1
                                                              Snapshot image 2
                                                              Motion image (showing only pixels defined as motion) 4
                                                              Normal mpeg image 8
                                                              Motion mpeg (showing only pixels defined as motion) 16
                                                              Timelapse mpeg 32
                                                              +

                                                              + You can create the table using the following SQL statement. +

                                                              +@@ -4742,13 +3291,12 @@ The The options for MySQL +

                                                              +

                                                              +-

                                                              +

                                                              mysql_db

                                                              +

                                                              +

                                                              + Name of the MySQL database. +@@ -4758,14 +3306,12 @@ MySQL CONFIG FILE OPTION. Motion must be + If you compiled motion with MySQL support you will need to set the mysql options if you want motion to log events to the database. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              mysql_host

                                                              +

                                                              +

                                                              + IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. +@@ -4773,14 +3319,12 @@ IP address or domain name for the MySQL + MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              mysql_password

                                                              +

                                                              +

                                                              + The MySQL password. +@@ -4788,14 +3332,12 @@ The MySQL password. + MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              mysql_user

                                                              +

                                                              +

                                                              + The MySQL user name. +@@ -4804,20 +3346,18 @@ MySQL CONFIG FILE OPTION. Motion must be +

                                                              +

                                                              +

                                                              +-

                                                              +-

                                                              PostgreSQL

                                                              ++

                                                              PostgreSQL

                                                              + Same/similar as for MySQL above. +

                                                              + The options for PostgreSQL +

                                                              +

                                                              +-

                                                              +

                                                              pgsql_db

                                                              +

                                                              +

                                                              + Name of the PostgreSQL database. +@@ -4827,14 +3367,12 @@ PostgreSQL CONFIG FILE OPTION. Motion mu + If you compiled motion with PostgreSQL support you will need to set all the pgsql_ options if you want motion to log events to the database. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              pgsql_host

                                                              +

                                                              +

                                                              + IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. +@@ -4842,14 +3380,12 @@ IP address or domain name for the Postgr + PostgreSQL CONFIG FILE OPTION. Motion must be built with pgsql_db libraries to use this feature. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              pgsql_password

                                                              +

                                                              +

                                                              + The PostgreSQL password. +@@ -4857,14 +3393,12 @@ The PostgreSQL password. + PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              pgsql_port

                                                              +

                                                              +

                                                              + The PostgreSQL server port number. +@@ -4872,14 +3406,12 @@ The PostgreSQL server port number. + PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. +

                                                              +

                                                              +-

                                                              +-

                                                              +

                                                              pgsql_user

                                                              +

                                                              +

                                                              + The PostgreSQL user name. +@@ -4887,12 +3419,8 @@ The PostgreSQL user name. + PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. +

                                                              +

                                                              +-

                                                              +-

                                                              +-

                                                              +-

                                                              +-

                                                              Video4Linux Loopback Device

                                                              +-You can use this driver for looking at motion in realtime. The video4linux driver is written by the same author that first created Motion. You can find the source and a brief description at the video4linux loopback device web page. ++

                                                              Video4Linux Loopback Device

                                                              ++You can use this driver for looking at motion in realtime. The video4linux driver is written by the same author that first created Motion. You can find the source and a brief description at the video4linux loopback device web page. +

                                                              + The video4linux device is a Kernel module which installs itself as a video pipe. It has an input and an output. The module simply takes anything that comes on its input and send it out at the output. The purpose of this is to create a standard video4linux type video device that other programs can then use. You may now ask: "What do I need that for?". +

                                                              +@@ -4925,7 +3453,7 @@ You may need to set the ownership and pe +

                                                              + Now you need to install the video loopback device. +

                                                              +-Download the latest video4linux loopback device . Place the file in a place of your own choice. ++Download the latest video4linux loopback device . Place the file in a place of your own choice. +

                                                              + Untar and uncompress the file to the place you want the program installed. Editor recommends /usr/local/vloopback. +

                                                              +@@ -4979,13 +3507,12 @@ De-activating should be done with this c + Description of the motion.conf options related to video loopback device. +

                                                              +

                                                              +-

                                                              +

                                                              motion_video_pipe

                                                              +

                                                              +

                                                              + The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set +@@ -4995,15 +3522,12 @@ Using this you can view the results in r + Disable this option by not having it in the config file (or comment it out with "#" or ";"). +

                                                              +

                                                              +-

                                                              +-

                                                              +-

                                                              +

                                                              video_pipe

                                                              +

                                                              +

                                                              + The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. +@@ -5015,7 +3539,4 @@ Disable this option by not having it in +

                                                              +

                                                              +

                                                              +-

                                                              +-

                                                              +-

                                                              +--- KennethLavrsen - 13 Apr 2005 +\ No newline at end of file ++-- KennethLavrsen - 13 Apr 2005 +\ No newline at end of file +--- motion-3.2.12.orig/netcam.c ++++ motion-3.2.12/netcam.c +@@ -41,46 +41,38 @@ + + #include + #include +-#include /* For parsing of the URL */ ++#include /* For parsing of the URL */ + #include + + #include "netcam_ftp.h" ++#include "netcam_rtsp.h" + +-#define CONNECT_TIMEOUT 10 /* timeout on remote connection attempt */ +-#define READ_TIMEOUT 5 /* default timeout on recv requests */ +-#define POLLING_TIMEOUT READ_TIMEOUT /* file polling timeout [s] */ +-#define POLLING_TIME 500*1000*1000 /* file polling time quantum [ns] (500ms) */ +-#define MAX_HEADER_RETRIES 5 /* Max tries to find a header record */ ++#define CONNECT_TIMEOUT 10 /* Timeout on remote connection attempt */ ++#define READ_TIMEOUT 5 /* Default timeout on recv requests */ ++#define POLLING_TIMEOUT READ_TIMEOUT /* File polling timeout [s] */ ++#define POLLING_TIME 500*1000*1000 /* File polling time quantum [ns] (500ms) */ ++#define MAX_HEADER_RETRIES 5 /* Max tries to find a header record */ + #define MINVAL(x, y) ((x) < (y) ? (x) : (y)) + +-/* +- * The macro NETCAM_DEBUG is for development testing of this module. +- * The macro SETUP is to assure that "configuration-setup" type messages +- * are also printed when NETCAM_DEBUG is set. Set the following #if to +- * 1 to enable it, or 0 (normal setting) to disable it. +- */ +-#define SETUP ((cnt->conf.setup_mode) || (debug_level >= CAMERA_INFO)) +- +- + tfile_context *file_new_context(void); + void file_free_context(tfile_context* ctxt); + +-/* These strings are used for the HTTP connection */ +-static const char *connect_req; ++/* These strings are used for the HTTP connection. */ ++static const char *connect_req; + +-static const char *connect_req_http10 = "GET %s HTTP/1.0\r\n" +- "Host: %s\r\n" +- "User-Agent: Motion-netcam/" VERSION "\r\n"; ++static const char *connect_req_http10 = "GET %s HTTP/1.0\r\n" ++ "Host: %s\r\n" ++ "User-Agent: Motion-netcam/" VERSION "\r\n"; + +-static const char *connect_req_http11 = "GET %s HTTP/1.1\r\n" +- "Host: %s\r\n" +- "User-Agent: Motion-netcam/" VERSION "\r\n"; ++static const char *connect_req_http11 = "GET %s HTTP/1.1\r\n" ++ "Host: %s\r\n" ++ "User-Agent: Motion-netcam/" VERSION "\r\n"; + +-static const char *connect_req_close = "Connection: close\r\n"; ++static const char *connect_req_close = "Connection: close\r\n"; + +-static const char *connect_req_keepalive = "Connection: Keep-Alive\r\n"; ++static const char *connect_req_keepalive = "Connection: Keep-Alive\r\n"; + +-static const char *connect_auth_req = "Authorization: Basic %s\r\n"; ++static const char *connect_auth_req = "Authorization: Basic %s\r\n"; + + /* + * The following three routines (netcam_url_match, netcam_url_parse and +@@ -129,7 +121,7 @@ static char *netcam_url_match(regmatch_t + if (m.rm_so != -1) { + len = m.rm_eo - m.rm_so; + +- if ((match = (char *) malloc(len + 1)) != NULL) { ++ if ((match = (char *) mymalloc(len + 1)) != NULL) { + strncpy(match, input + m.rm_so, len); + match[len] = '\0'; + } +@@ -155,17 +147,18 @@ static void netcam_url_parse(struct url_ + { + char *s; + int i; +- const char *re = "(http|ftp)://(((.*):(.*))@)?" ++ ++ const char *re = "(http|ftp|mjpg|mjpeg|rtsp)://(((.*):(.*))@)?" + "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; + regex_t pattbuf; + regmatch_t matches[10]; + +- if (!strncmp( text_url, "file", 4 ) ) ++ if (!strncmp(text_url, "file", 4)) + re = "(file)://(((.*):(.*))@)?" + "([^/:]|[-.a-z0-9]*)(:([0-9]*))?($|(/[^:][/-_.a-z0-9]+))"; + +- if (debug_level > CAMERA_DEBUG) +- motion_log(-1, 0, "Entry netcam_url_parse data %s", text_url ); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Entry netcam_url_parse data %s", ++ text_url); + + memset(parse_url, 0, sizeof(struct url_t)); + /* +@@ -173,14 +166,14 @@ static void netcam_url_parse(struct url_ + * suitable for regexec searches + * regexec matches the URL string against the regular expression + * and returns an array of pointers to strings matching each match +- * within (). The results that we need are finally placed in parse_url ++ * within (). The results that we need are finally placed in parse_url. + */ + if (!regcomp(&pattbuf, re, REG_EXTENDED | REG_ICASE)) { + if (regexec(&pattbuf, text_url, 10, matches, 0) != REG_NOMATCH) { + for (i = 0; i < 10; i++) { + if ((s = netcam_url_match(matches[i], text_url)) != NULL) { +- if (debug_level > CAMERA_DEBUG) +- motion_log(-1, 0, "Parse case %d data %s", i, s ); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Parse case %d" ++ " data %s", i, s); + switch (i) { + case 1: + parse_url->service = s; +@@ -198,7 +191,7 @@ static void netcam_url_parse(struct url_ + case 9: + parse_url->path = s; + break; +- /* other components ignored */ ++ /* Other components ignored */ + default: + free(s); + break; +@@ -207,11 +200,13 @@ static void netcam_url_parse(struct url_ + } + } + } +- if ((!parse_url->port) && (parse_url->service)){ ++ if ((!parse_url->port) && (parse_url->service)) { + if (!strcmp(parse_url->service, "http")) + parse_url->port = 80; + else if (!strcmp(parse_url->service, "ftp")) + parse_url->port = 21; ++ else if (!strcmp(parse_url->service, "rtsp") && parse_url->port == 0) ++ parse_url->port = 554; + } + + regfree(&pattbuf); +@@ -224,12 +219,12 @@ static void netcam_url_parse(struct url_ + * + * Parameters: + * +- * parse_url Structure containing the parsed data ++ * parse_url Structure containing the parsed data. + * + * Returns: Nothing + * + */ +-static void netcam_url_free(struct url_t *parse_url) ++void netcam_url_free(struct url_t *parse_url) + { + if (parse_url->service) { + free(parse_url->service); +@@ -260,9 +255,9 @@ static void netcam_url_free(struct url_t + * + * Parameters: + * +- * str Pointer to a string ++ * str Pointer to a string. + * +- * Returns: Nothing, but updates the target if necessary ++ * Returns: Nothing, but updates the target if necessary. + * + */ + static void check_quote(char *str) +@@ -284,20 +279,20 @@ static void check_quote(char *str) + /** + * netcam_check_content_length + * +- * Analyse an HTTP-header line to see if it is a Content-length ++ * Analyse an HTTP-header line to see if it is a Content-length. + * + * Parameters: + * +- * header Pointer to a string containing the header line ++ * header Pointer to a string containing the header line. + * + * Returns: +- * -1 Not a Content-length line +- * >=0 Value of Content-length field ++ * -1 Not a Content-length line. ++ * >=0 Value of Content-length field. + * + */ + static long netcam_check_content_length(char *header) + { +- long length = -1; /* note this is a long, not an int */ ++ long length = -1; /* Note this is a long, not an int. */ + + if (!header_process(header, "Content-Length", header_extract_number, &length)) { + /* +@@ -306,10 +301,13 @@ static long netcam_check_content_length( + * number we might as well try to use it. + */ + if (length > 0) +- return length; +- return -1; ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: malformed token" ++ " Content-Length but value %ld", length); + } + ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length %ld", ++ length); ++ + return length; + } + +@@ -320,11 +318,11 @@ static long netcam_check_content_length( + * + * Parameters: + * +- * header Pointer to a string containing the header line ++ * header Pointer to a string containing the header line. + * + * Returns: +- * -1 Not a Keep-Alive line +- * 1 Is a Keep-Alive line ++ * -1 Not a Keep-Alive line. ++ * 1 Is a Keep-Alive line. + * + */ + static int netcam_check_keepalive(char *header) +@@ -335,7 +333,6 @@ static int netcam_check_keepalive(char * + return -1; + + /* We do not detect the second field or other case mixes at present. */ +- + if (content_type) + free(content_type); + +@@ -345,15 +342,15 @@ static int netcam_check_keepalive(char * + /** + * netcam_check_close + * +- * Analyse an HTTP-header line to see if it is a Connection: close ++ * Analyse an HTTP-header line to see if it is a Connection: close. + * + * Parameters: + * +- * header Pointer to a string containing the header line ++ * header Pointer to a string containing the header line. + * + * Returns: +- * -1 Not a Connection: close +- * 1 Is a Connection: close ++ * -1 Not a Connection: close. ++ * 1 Is a Connection: close. + * + */ + static int netcam_check_close(char *header) +@@ -364,7 +361,7 @@ static int netcam_check_close(char *head + if (!header_process(header, "Connection", http_process_type, &type)) + return -1; + +- if (!strcmp(type, "close")) /* strcmp returns 0 for match */ ++ if (!strcmp(type, "close")) /* strcmp returns 0 for match. */ + ret = 1; + + if (type) +@@ -376,17 +373,18 @@ static int netcam_check_close(char *head + /** + * netcam_check_content_type + * +- * Analyse an HTTP-header line to see if it is a Content-type ++ * Analyse an HTTP-header line to see if it is a Content-type. + * + * Parameters: + * +- * header Pointer to a string containing the header line ++ * header Pointer to a string containing the header line. + * + * Returns: + * -1 Not a Content-type line + * 0 Content-type not recognized + * 1 image/jpeg + * 2 multipart/x-mixed-replace or multipart/mixed ++ * 3 application/octet-stream (used by WVC200 Linksys IP Camera) + * + */ + static int netcam_check_content_type(char *header) +@@ -397,15 +395,20 @@ static int netcam_check_content_type(cha + if (!header_process(header, "Content-type", http_process_type, &content_type)) + return -1; + ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-type %s", ++ content_type); ++ + if (!strcmp(content_type, "image/jpeg")) { + ret = 1; + } else if (!strcmp(content_type, "multipart/x-mixed-replace") || + !strcmp(content_type, "multipart/mixed")) { + ret = 2; ++ } else if (!strcmp(content_type, "application/octet-stream")) { ++ ret = 3; + } else { + ret = 0; + } +- ++ + if (content_type) + free(content_type); + +@@ -420,9 +423,9 @@ static int netcam_check_content_type(cha + * + * Parameters + * +- * netcam pointer to a netcam_context ++ * netcam pointer to a netcam_context. + * +- * Returns: 0 for success, -1 if any error ++ * Returns: 0 for success, -1 if any error. + * + */ + static int netcam_read_next_header(netcam_context_ptr netcam) +@@ -430,9 +433,7 @@ static int netcam_read_next_header(netca + int retval; + char *header; + +- /* +- * return if not connected +- */ ++ /* Return if not connected */ + if (netcam->sock == -1) + return -1; + /* +@@ -444,25 +445,26 @@ static int netcam_read_next_header(netca + * + */ + netcam->caps.content_length = 0; ++ + /* + * If this is a "streaming" camera, the stream header must be +- * preceded by a "boundary" string ++ * preceded by a "boundary" string. + */ +- if (netcam->caps.streaming) { ++ if (netcam->caps.streaming == NCS_MULTIPART) { + while (1) { + retval = header_get(netcam, &header, HG_NONE); + + if (retval != HG_OK) { +- /* Header reported as not-OK, check to see if it's null */ ++ /* Header reported as not-OK, check to see if it's null. */ + if (strlen(header) == 0) { +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "Error reading image header, streaming mode (1). Null header."); ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " ++ "streaming mode (1). Null header."); + } else { + /* Header is not null. Output it in case it's a new camera with unknown headers. */ +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_ERR, 0, "Error reading image header, streaming mode (1). " +- "Unknown header '%s'", header ); +- } ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " ++ "streaming mode (1). Unknown header '%s'", ++ header); ++ } + + free(header); + return -1; +@@ -480,7 +482,7 @@ static int netcam_read_next_header(netca + retval = header_get(netcam, &header, HG_NONE); + + if (retval != HG_OK) { +- motion_log(LOG_ERR, 0, "Error reading image header (2)"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header (2)"); + free(header); + return -1; + } +@@ -490,22 +492,28 @@ static int netcam_read_next_header(netca + + if ((retval = netcam_check_content_type(header)) >= 0) { + if (retval != 1) { +- motion_log(LOG_ERR, 0, "Header not JPEG"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Header not JPEG"); + free(header); + return -1; + } + } + +- if ((retval = (int) netcam_check_content_length(header)) > 0) { +- netcam->caps.content_length = 1; /* set flag */ +- netcam->receiving->content_length = (int) retval; +- } ++ if ((retval = (int) netcam_check_content_length(header)) >= 0) { ++ if (retval > 0) { ++ netcam->caps.content_length = 1; /* Set flag */ ++ netcam->receiving->content_length = retval; ++ } else { ++ netcam->receiving->content_length = 0; ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length 0"); ++ free(header); ++ return -1; ++ } ++ } + + free(header); + } + +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "Found image header record"); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Found image header record"); + + free(header); + return 0; +@@ -528,26 +536,26 @@ static int netcam_read_next_header(netca + * After this processing, the routine returns to the caller. + * + * Parameters: +- * netcam Pointer to the netcam_context structure ++ * netcam Pointer to the netcam_context structure. + * + * Returns: Content-type code if successful, -1 if not +- * ++ * -2 if Content-length = 0 + */ + static int netcam_read_first_header(netcam_context_ptr netcam) + { +- int retval = -2; /* "Unknown err" */ ++ int retval = -3; /* "Unknown err" */ + int ret; + int firstflag = 1; +- int aliveflag = 0; /* If we have seen a Keep-Alive header from cam */ +- int closeflag = 0; /* If we have seen a Connection: close header from cam */ ++ int aliveflag = 0; /* If we have seen a Keep-Alive header from cam. */ ++ int closeflag = 0; /* If we have seen a Connection: close header from cam. */ + char *header; + char *boundary; +- struct context *cnt = netcam->cnt; /* for conf debug_level */ + +- /* Send the initial command to the camera */ ++ /* Send the initial command to the camera. */ + if (send(netcam->sock, netcam->connect_request, + strlen(netcam->connect_request), 0) < 0) { +- motion_log(LOG_ERR, 1, "Error sending 'connect' request"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: Error sending" ++ " 'connect' request"); + return -1; + } + +@@ -573,47 +581,49 @@ static int netcam_read_first_header(netc + * there may be a Content-length. + * + */ +- while (1) { /* 'Do forever' */ ++ while (1) { /* 'Do forever' */ + ret = header_get(netcam, &header, HG_NONE); + +- if (debug_level > CAMERA_INFO) /* Changed criterion and moved up from below to catch headers that cause returns */ +- motion_log(LOG_DEBUG, 0, "Received first header ('%s')", header); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received first header ('%s')", ++ header); + + if (ret != HG_OK) { +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_ERR, 0, "Error reading first header (%s)", header); ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header (%s)", ++ header); + free(header); + return -1; + } + + if (firstflag) { + if ((ret = http_result_code(header)) != 200) { +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "HTTP Result code %d", ret); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: HTTP Result code %d", ++ ret); + + free(header); +- + if (netcam->connect_keepalive) { +- /* Cannot unset netcam->cnt->conf.netcam_http as it is assigned const */ +- /* But we do unset the netcam keepalive flag which was set in netcam_start */ +- /* This message is logged as Information as it would be useful to know */ +- /* if your netcam often returns bad HTTP result codes */ +- netcam->connect_keepalive = 0; +- motion_log(LOG_INFO, 0, "Removed netcam Keep-Alive flag" +- "due to apparent closed HTTP connection."); ++ /* ++ * Cannot unset netcam->cnt->conf.netcam_keepalive as it is assigned const ++ * But we do unset the netcam keepalive flag which was set in netcam_start ++ * This message is logged as Information as it would be useful to know ++ * if your netcam often returns bad HTTP result codes. ++ */ ++ netcam->connect_keepalive = FALSE; ++ free((void *)netcam->cnt->conf.netcam_keepalive); ++ netcam->cnt->conf.netcam_keepalive = strdup("off"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag" ++ "due to apparent closed HTTP connection."); + } + return ret; + } +- + firstflag = 0; + free(header); + continue; + } + +- if (*header == 0) /* blank line received */ ++ if (*header == 0) /* Blank line received */ + break; + +- /* Check if this line is the content type */ ++ /* Check if this line is the content type. */ + if ((ret = netcam_check_content_type(header)) >= 0) { + retval = ret; + /* +@@ -624,113 +634,144 @@ static int netcam_read_first_header(netc + * camera which provides a single frame only. + */ + switch (ret) { +- case 1: /* not streaming */ +- if (SETUP) { +- if (netcam->connect_keepalive) +- motion_log(LOG_DEBUG, 0, "Non-streaming camera (keep-alive set)"); +- else +- motion_log(LOG_DEBUG, 0, "Non-streaming camera (keep-alive not set)"); +- } +- netcam->caps.streaming = 0; ++ case 1: /* Not streaming */ ++ if (netcam->connect_keepalive) ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " ++ "(keep-alive set)"); ++ else ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " ++ "(keep-alive not set)"); ++ ++ netcam->caps.streaming = NCS_UNSUPPORTED; + break; + +- case 2: /* streaming */ +- if (SETUP) +- motion_log(LOG_DEBUG, 0, "Streaming camera"); ++ case 2: /* Streaming */ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera"); + +- netcam->caps.streaming = 1; ++ netcam->caps.streaming = NCS_MULTIPART; + + if ((boundary = strstr(header, "boundary="))) { +- /* +- * on error recovery this +- * may already be set +- * */ ++ /* On error recovery this may already be set. */ + if (netcam->boundary) + free(netcam->boundary); + +- netcam->boundary = strdup(boundary + 9); ++ netcam->boundary = mystrdup(boundary + 9); + /* + * HTTP protocol apparently permits the boundary string + * to be quoted (the Lumenera does this, which caused + * trouble) so we need to get rid of any surrounding +- * quotes ++ * quotes. + */ +- check_quote(netcam->boundary); +- netcam->boundary_length = strlen(netcam->boundary); ++ check_quote(netcam->boundary); ++ netcam->boundary_length = strlen(netcam->boundary); + +- if (SETUP) +- motion_log(LOG_DEBUG, 0, "Boundary string [%s]", +- netcam->boundary); +- +- } ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Boundary string [%s]", ++ netcam->boundary); ++ } ++ break; ++ case 3: /* MJPG-Block style streaming. */ ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera probably using MJPG-blocks," ++ " consider using mjpg:// netcam_url."); + break; + +- default: /* error */ +- motion_log(LOG_ERR, 0, "Unrecognized content type"); ++ default: ++ /* Error */ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized content type"); + free(header); + return -1; + + } + } else if ((ret = (int) netcam_check_content_length(header)) >= 0) { +- if (SETUP) +- motion_log(LOG_DEBUG, 0, "Content-length present"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Content-length present"); + +- netcam->caps.content_length = 1; /* set flag */ +- netcam->receiving->content_length = ret; ++ if (ret > 0) { ++ netcam->caps.content_length = 1; /* Set flag */ ++ netcam->receiving->content_length = ret; ++ } else { ++ netcam->receiving->content_length = 0; ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-length 0"); ++ retval = -2; ++ } + } else if (netcam_check_keepalive(header) == TRUE) { +- /* Note that we have received a Keep-Alive header, and thus the socket can be left open */ +- aliveflag=TRUE; ++ /* Note that we have received a Keep-Alive header, and thus the socket can be left open. */ ++ aliveflag = TRUE; + netcam->keepalive_thisconn = TRUE; +- /* This flag will not be set when a Streaming cam is in use, but that */ +- /* does not matter as the test below looks at Streaming state also. */ ++ /* ++ * This flag will not be set when a Streaming cam is in use, but that ++ * does not matter as the test below looks at Streaming state also. ++ */ + } else if (netcam_check_close(header) == TRUE) { +- /* Note that we have received a Connection: close header */ +- closeflag=TRUE; +- /* This flag is acted upon below */ +- if (debug_level > CAMERA_INFO) /* Changed criterion and moved up from below to catch headers that cause returns */ +- motion_log(LOG_DEBUG, 0, "Found Conn:close header ('%s')", header); ++ /* Note that we have received a Connection: close header. */ ++ closeflag = TRUE; ++ /* ++ * This flag is acted upon below. ++ * Changed criterion and moved up from below to catch headers that cause returns. ++ */ ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Found Conn: close header ('%s')", ++ header); + } + free(header); + } + free(header); + +- if (!netcam->caps.streaming && netcam->connect_keepalive) { ++ if (netcam->caps.streaming == NCS_UNSUPPORTED && netcam->connect_keepalive) { + +- /* +- * If we are a non-streaming (ie. Jpeg) netcam and keepalive is configured +- */ ++ /* If we are a non-streaming (ie. Jpeg) netcam and keepalive is configured. */ + + if (aliveflag) { + if (closeflag) { ++ netcam->warning_count++; ++ if (netcam->warning_count > 3) { ++ netcam->warning_count = 0; ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Both 'Connection: Keep-Alive' and " ++ "'Connection: close' header received. Motion removes keepalive."); ++ netcam->connect_keepalive = FALSE; ++ free((void *)netcam->cnt->conf.netcam_keepalive); ++ netcam->cnt->conf.netcam_keepalive = strdup("off"); ++ } else { + /* + * If not a streaming cam, and keepalive is set, and the flag shows we + * did not see a Keep-Alive field returned from netcam and a Close field. + * Not quite sure what the correct course of action is here. In for testing. + */ +- motion_log(LOG_INFO, 0, "Info: Both 'Connection: Keep-Alive' and 'Connection: close' " +- "header received. Motion continues unchanged."); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Both 'Connection: Keep-Alive' and " ++ "'Connection: close' header received. Motion continues unchanged."); ++ } + } else { +- /* aliveflag && !closeflag +- * +- * If not a streaming cam, and keepalive is set, and the flag shows we +- * just got a Keep-Alive field returned from netcam and no Close field. +- * No action, as this is the normal case. In debug we print a notification. +- */ ++ /* ++ * aliveflag && !closeflag ++ * ++ * If not a streaming cam, and keepalive is set, and the flag shows we ++ * just got a Keep-Alive field returned from netcam and no Close field. ++ * No action, as this is the normal case. In debug we print a notification. ++ */ + +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_INFO, 0, "Info: Received a Keep-Alive field in this set of headers."); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received a Keep-Alive field in this" ++ "set of headers."); + } + } else { /* !aliveflag */ + if (!closeflag) { ++ netcam->warning_count++; ++ ++ if (netcam->warning_count > 3) { ++ netcam->warning_count = 0; ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: No 'Connection: Keep-Alive' nor 'Connection: close'" ++ " header received.\n Motion removes keepalive."); ++ netcam->connect_keepalive = FALSE; ++ free((void *)netcam->cnt->conf.netcam_keepalive); ++ netcam->cnt->conf.netcam_keepalive = strdup("off"); ++ } else { + /* + * If not a streaming cam, and keepalive is set, and the flag shows we + * did not see a Keep-Alive field returned from netcam nor a Close field. + * Not quite sure what the correct course of action is here. In for testing. + */ +- motion_log(LOG_INFO, 0, "Info: No 'Connection: Keep-Alive' nor 'Connection: close' " +- "header received. Motion continues unchanged."); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: No 'Connection: Keep-Alive' nor 'Connection: close'" ++ " header received.\n Motion continues unchanged."); ++ } + } else { +- /* !aliveflag & closeflag ++ /* ++ * !aliveflag & closeflag + * If not a streaming cam, and keepalive is set, and the flag shows we + * received a 'Connection: close' field returned from netcam. It is not likely + * we will get a Keep-Alive and Close header together - this is picked up by +@@ -753,13 +794,15 @@ static int netcam_read_first_header(netc + */ + if (!netcam->keepalive_thisconn) { + netcam->connect_keepalive = FALSE; /* No further attempts at keep-alive */ +- motion_log(LOG_INFO, 0, "Removed netcam Keep-Alive flag because 'Connection: close' " +- "header received. Netcam does not support Keep-Alive. Motion " +- "continues in non-Keep-Alive."); ++ free((void *)netcam->cnt->conf.netcam_keepalive); ++ netcam->cnt->conf.netcam_keepalive = strdup("off"); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag because" ++ " 'Connection: close' header received.\n Netcam does not support " ++ "Keep-Alive. Motion continues in non-Keep-Alive."); + } else { + netcam->keepalive_timeup = TRUE; /* We will close and re-open keep-alive */ +- motion_log(LOG_INFO, 0, "Keep-Alive has reached end of valid period. Motion will close " +- "netcam, then resume Keep-Alive with a new socket."); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "Keep-Alive has reached end of valid period.\n" ++ "Motion will close netcam, then resume Keep-Alive with a new socket."); + } + } + } +@@ -784,7 +827,7 @@ static void netcam_disconnect(netcam_con + { + if (netcam->sock > 0) { + if (close(netcam->sock) < 0) +- motion_log(LOG_ERR, 1, "netcam_disconnect"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: netcam_disconnect"); + + netcam->sock = -1; + } +@@ -809,93 +852,88 @@ static void netcam_disconnect(netcam_con + */ + static int netcam_connect(netcam_context_ptr netcam, int err_flag) + { +- struct sockaddr_in server; /* for connect */ +- struct addrinfo *res; /* for getaddrinfo */ ++ struct sockaddr_in server; /* For connect */ ++ struct addrinfo *res; /* For getaddrinfo */ + int ret; + int saveflags; + int back_err; + int optval; +- socklen_t optlen=sizeof(optval); ++ socklen_t optlen = sizeof(optval); + socklen_t len; + fd_set fd_w; + struct timeval selecttime; + +- /* Assure any previous connection has been closed - IF we are not in keepalive */ ++ /* Assure any previous connection has been closed - IF we are not in keepalive. */ + if (!netcam->connect_keepalive) { +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_connect, disconnecting netcam since keep-alive not set." ); +- ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam " ++ "since keep-alive not set."); ++ + netcam_disconnect(netcam); + +- /* create a new socket */ ++ /* Create a new socket. */ + if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { +- motion_log(LOG_ERR, 1, "netcam_connect with no keepalive, attempt to create socket failed."); ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with no keepalive, attempt " ++ "to create socket failed."); + return -1; + } + +- if (debug_level > CAMERA_INFO ) +- motion_log(LOG_DEBUG, 0, "netcam_connect with no keepalive, new socket created fd %d", netcam->sock); +- +- } else { /* We are in keepalive mode, check for invalid socket */ +- if (netcam->sock == -1) { +- /* Must be first time, or closed, create a new socket */ +- if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { +- motion_log(LOG_ERR, 1, "netcam_connect with keepalive set, invalid socket." +- "This could be the first time. Creating a new one failed."); +- return -1; +- } ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: with no keepalive, " ++ "new socket created fd %d", netcam->sock); + +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_connect with keepalive set, invalid socket." +- "This could be first time, created a new one with fd %d", netcam->sock); +- +- /* Record that this connection has not yet received a Keep-Alive header */ +- netcam->keepalive_thisconn = FALSE; +- +- /* Check the socket status for the keepalive option */ +- if (getsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen) < 0) { +- motion_log(LOG_ERR, 1, "netcam_connect : getsockopt()"); +- return -1; +- } ++ } else if (netcam->sock == -1) { /* We are in keepalive mode, check for invalid socket. */ ++ /* Must be first time, or closed, create a new socket. */ ++ if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with keepalive set, invalid socket." ++ "This could be the first time. Creating a new one failed."); ++ return -1; ++ } + +- if (debug_level > CAMERA_INFO) { +- if (optval == 1) +- motion_log(LOG_DEBUG, 0, "netcam_connect: SO_KEEPALIVE is ON"); +- else +- motion_log(LOG_DEBUG, 0, "netcam_connect: SO_KEEPALIVE is OFF"); +- } +- +- /* Set the option active */ +- optval = 1; +- optlen = sizeof(optval); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: with keepalive set, invalid socket." ++ "This could be first time, created a new one with fd %d", ++ netcam->sock); ++ ++ /* Record that this connection has not yet received a Keep-Alive header. */ ++ netcam->keepalive_thisconn = FALSE; ++ ++ /* Check the socket status for the keepalive option. */ ++ if (getsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen) < 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: getsockopt()"); ++ return -1; ++ } + +- if (setsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) { +- motion_log(LOG_ERR, 1, "netcam_connect : setsockopt()"); +- return -1; +- } ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE is %s", ++ optval ? "ON":"OFF"); + +- if (debug_level > CAMERA_INFO ) +- motion_log(LOG_DEBUG, 0, "netcam_connect: SO_KEEPALIVE set on socket."); ++ /* Set the option active. */ ++ optval = 1; ++ optlen = sizeof(optval); + +- } else if (debug_level > CAMERA_INFO) { +- motion_log(LOG_DEBUG, 0, "netcam_connect re-using socket %d since keepalive is set.", netcam->sock); ++ if (setsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: setsockopt()"); ++ return -1; + } +- } + +- /* lookup the hostname given in the netcam URL */ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE set on socket."); ++ } ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: re-using socket %d since keepalive is set.", ++ netcam->sock); ++ ++ /* Lookup the hostname given in the netcam URL. */ + if ((ret = getaddrinfo(netcam->connect_host, NULL, NULL, &res)) != 0) { + if (!err_flag) +- motion_log(LOG_ERR, 0, "getaddrinfo() failed (%s): %s", ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: getaddrinfo() failed (%s): %s", + netcam->connect_host, gai_strerror(ret)); +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (1)"); ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (1)"); ++ + netcam_disconnect(netcam); + return -1; + } + + /* + * Fill the hostname details into the 'server' structure and +- * attempt to connect to the remote server ++ * attempt to connect to the remote server. + */ + memset(&server, 0, sizeof(server)); + memcpy(&server, res->ai_addr, sizeof(server)); +@@ -910,49 +948,48 @@ static int netcam_connect(netcam_context + */ + + if ((saveflags = fcntl(netcam->sock, F_GETFL, 0)) < 0) { +- motion_log(LOG_ERR, 1, "fcntl(1) on socket"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: fcntl(1) on socket"); + netcam_disconnect(netcam); + return -1; + } + +- /* Set the socket non-blocking */ ++ /* Set the socket non-blocking. */ + if (fcntl(netcam->sock, F_SETFL, saveflags | O_NONBLOCK) < 0) { +- motion_log(LOG_ERR, 1, "fcntl(2) on socket"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: fcntl(2) on socket"); + netcam_disconnect(netcam); + return -1; + } + +- /* Now the connect call will return immediately */ ++ /* Now the connect call will return immediately. */ + ret = connect(netcam->sock, (struct sockaddr *) &server, + sizeof(server)); +- back_err = errno; /* save the errno from connect */ ++ back_err = errno; /* Save the errno from connect */ + +- /* If the connect failed with anything except EINPROGRESS, error */ ++ /* If the connect failed with anything except EINPROGRESS, error. */ + if ((ret < 0) && (back_err != EINPROGRESS)) { + if (!err_flag) +- motion_log(LOG_ERR, 1, "connect() failed (%d)", back_err); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect() failed (%d)", ++ back_err); + +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (4)"); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (4)"); + + netcam_disconnect(netcam); + return -1; + } + +- /* Now we do a 'select' with timeout to wait for the connect */ ++ /* Now we do a 'select' with timeout to wait for the connect. */ + FD_ZERO(&fd_w); + FD_SET(netcam->sock, &fd_w); + selecttime.tv_sec = CONNECT_TIMEOUT; + selecttime.tv_usec = 0; + ret = select(FD_SETSIZE, NULL, &fd_w, NULL, &selecttime); + +- if (ret == 0) { /* 0 means timeout */ ++ if (ret == 0) { /* 0 means timeout. */ + if (!err_flag) +- motion_log(LOG_ERR, 0, "timeout on connect()"); +- +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (2)"); +- ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: timeout on connect()"); ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (2)"); ++ + netcam_disconnect(netcam); + return -1; + } +@@ -965,25 +1002,26 @@ static int netcam_connect(netcam_context + len = sizeof(ret); + + if (getsockopt(netcam->sock, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) { +- motion_log(LOG_ERR, 0, "getsockopt after connect"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: getsockopt after connect"); + netcam_disconnect(netcam); + return -1; + } + +- /* If the return code is anything except 0, error on connect */ ++ /* If the return code is anything except 0, error on connect. */ + if (ret) { + if (!err_flag) +- motion_log(LOG_ERR, 1, "connect returned error"); +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (3)"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect returned error"); ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (3)"); ++ + netcam_disconnect(netcam); + return -1; + } + +- /* The socket info is stored in the rbuf structure of our context */ ++ /* The socket info is stored in the rbuf structure of our context. */ + rbuf_initialize(netcam); + +- return 0; /* success */ ++ return 0; /* Success */ + } + + +@@ -995,23 +1033,35 @@ static int netcam_connect(netcam_context + * the buffer and adjust it's size. + * + * Parameters: +- * buff Pointer to a netcam_image_buffer structure +- * numbytes The number of bytes to be copied ++ * buff Pointer to a netcam_image_buffer structure. ++ * numbytes The number of bytes to be copied. + * + * Returns: Nothing + */ + static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) + { ++ int min_size_to_alloc; ++ int real_alloc; ++ int new_size; ++ + if ((buff->size - buff->used) >= numbytes) + return; + +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "expanding buffer from %d to %d bytes", +- (int) buff->size, (int) buff->size + NETCAM_BUFFSIZE); ++ min_size_to_alloc = numbytes - (buff->size - buff->used); ++ real_alloc = ((min_size_to_alloc / NETCAM_BUFFSIZE) * NETCAM_BUFFSIZE); ++ ++ if ((min_size_to_alloc - real_alloc) > 0) ++ real_alloc += NETCAM_BUFFSIZE; ++ ++ new_size = buff->size + real_alloc; ++ ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", ++ (int) buff->used, (int) buff->size, ++ (int) buff->used, new_size); + +- buff->ptr = myrealloc(buff->ptr, buff->size + NETCAM_BUFFSIZE, ++ buff->ptr = myrealloc(buff->ptr, new_size, + "netcam_check_buf_size"); +- buff->size += NETCAM_BUFFSIZE; ++ buff->size = new_size; + } + + /** +@@ -1042,6 +1092,8 @@ static void netcam_check_buffsize(netcam + * 1) If a Content-Length is present, set the variable "remaining" + * to be equal to that value, else set it to a "very large" + * number. ++ * WARNING !!! Content-Length *must* to be greater than 0, even more ++ * a jpeg image cannot be less than 300 bytes or so. + * 2) While there is more data available from the camera: + * a) If there is a "boundary string" specified (from the initial + * header): +@@ -1074,27 +1126,27 @@ static int netcam_read_html_jpeg(netcam_ + netcam_buff_ptr buffer; + size_t remaining; /* # characters to read */ + size_t maxflush; /* # chars before boundary */ +- size_t rem, rlen, ix; /* working vars */ ++ size_t rem, rlen, ix; /* Working vars */ + int retval; + char *ptr, *bptr, *rptr; + netcam_buff *xchg; + struct timeval curtime; + /* + * Initialisation - set our local pointers to the context +- * information ++ * information. + */ + buffer = netcam->receiving; +- /* Assure the target buffer is empty */ ++ /* Assure the target buffer is empty. */ + buffer->used = 0; +- /* Prepare for read loop */ ++ /* Prepare for read loop. */ + if (buffer->content_length != 0) + remaining = buffer->content_length; + else + remaining = 999999; + +- /* Now read in the data */ ++ /* Now read in the data. */ + while (remaining) { +- /* Assure data in input buffer */ ++ /* Assure data in input buffer. */ + if (netcam->response->buffer_left <= 0) { + retval = rbuf_read_bufferful(netcam); + +@@ -1105,14 +1157,14 @@ static int netcam_read_html_jpeg(netcam_ + netcam->response->buffer_pos = netcam->response->buffer; + } + +- /* If a boundary string is present, take it into account */ ++ /* If a boundary string is present, take it into account. */ + bptr = netcam->boundary; + + if (bptr) { + rptr = netcam->response->buffer_pos; + rlen = netcam->response->buffer_left; + +- /* Loop through buffer looking for start of boundary */ ++ /* Loop through buffer looking for start of boundary. */ + while (1) { + /* + * Logic gets a little complicated here. The +@@ -1130,11 +1182,11 @@ static int netcam_read_html_jpeg(netcam_ + break; + + if ((ptr = memchr(rptr, *bptr, rlen)) == NULL) +- /* boundary not here (normal path) */ ++ /* Boundary not here (normal path) */ + break; + /* + * At least the first char was found in the +- * buffer - check for the rest ++ * buffer - check for the rest. + */ + rem = rlen - (ptr - rptr); + for (ix = 1; (ix < rem) && (ix < netcam->boundary_length); ix++) { +@@ -1145,19 +1197,18 @@ static int netcam_read_html_jpeg(netcam_ + if ((ix != netcam->boundary_length) && (ix != rem)) { + /* + * Not pointing at a boundary string - +- * step along input ++ * step along input. + */ + ix = ptr - rptr + 1; + rptr += ix; + rlen -= ix; + + if (rlen <= 0) +- /* boundary not in buffer - go copy out +- */ ++ /* boundary not in buffer - go copy out */ + break; + /* +- * not yet decided - continue +- * through input ++ * Not yet decided - continue ++ * through input. + */ + continue; + } +@@ -1172,7 +1223,7 @@ static int netcam_read_html_jpeg(netcam_ + if ((ptr - netcam->response->buffer) < (int) remaining) + remaining = ptr - netcam->response->buffer; + +- /* go copy everything up to boundary */ ++ /* Go copy everything up to boundary. */ + break; + } + +@@ -1183,7 +1234,7 @@ static int netcam_read_html_jpeg(netcam_ + * problem mentioned above. + * + * Assure there is data before potential +- * boundary string ++ * boundary string. + */ + if (ptr != netcam->response->buffer) { + /* +@@ -1195,7 +1246,7 @@ static int netcam_read_html_jpeg(netcam_ + * beginning and get some more input + * data. First we flush the input + * buffer up to the beginning of the +- * (potential) boundary string ++ * (potential) boundary string. + */ + ix = ptr - netcam->response->buffer_pos; + netcam_check_buffsize(buffer, ix); +@@ -1211,45 +1262,43 @@ static int netcam_read_html_jpeg(netcam_ + * module netcam_wget.c to do this job! + */ + +- if (debug_level > CAMERA_INFO) { +- motion_log(-1, 0, +- "Potential split boundary - " +- "%d chars flushed, %d " +- "re-positioned", ix, +- (int) netcam->response->buffer_left); +- } ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, ++ "%s: Potential split boundary - " ++ "%d chars flushed, %d " ++ "re-positioned", ix, ++ (int) netcam->response->buffer_left); + + memmove(netcam->response->buffer, ptr, + netcam->response->buffer_left); +- } /* end of boundary split over buffer */ ++ } /* End of boundary split over buffer. */ + + retval = netcam_recv(netcam, netcam->response->buffer + + netcam->response->buffer_left, + sizeof(netcam->response->buffer) - + netcam->response->buffer_left); + +- if (retval <= 0) { /* this is a fatal error */ +- motion_log(LOG_ERR, 1, "recv() fail after boundary string"); ++ if (retval <= 0) { /* This is a fatal error. */ ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: recv() fail after boundary string"); + return -1; + } + +- /* Reset the input buffer pointers */ ++ /* Reset the input buffer pointers. */ + netcam->response->buffer_left = retval + netcam->response->buffer_left; + netcam->response->buffer_pos = netcam->response->buffer; + +- /* This will cause a 'continue' of the main loop */ ++ /* This will cause a 'continue' of the main loop. */ + bptr = NULL; + +- /* Return to do the boundary compare from the start */ ++ /* Return to do the boundary compare from the start. */ + break; +- } /* end of while(1) input buffer search */ ++ } /* End of while(1) input buffer search. */ + +- /* !bptr shows we're processing split boundary */ ++ /* !bptr shows we're processing split boundary. */ + if (!bptr) + continue; +- } /* end of if (bptr) */ ++ } /* end of if (bptr) */ + +- /* boundary string not present, so just write out as much data as possible */ ++ /* boundary string not present, so just write out as much data as possible. */ + if (remaining) { + maxflush = MINVAL(netcam->response->buffer_left, remaining); + netcam_check_buffsize(buffer, maxflush); +@@ -1260,14 +1309,13 @@ static int netcam_read_html_jpeg(netcam_ + } + + /* +- * read is complete - set the current 'receiving' buffer atomically ++ * Read is complete - set the current 'receiving' buffer atomically + * as 'latest', and make the buffer previously in 'latest' become +- * the new 'receiving' ++ * the new 'receiving'. + */ + if (gettimeofday(&curtime, NULL) < 0) +- motion_log(LOG_ERR, 1, "gettimeofday in netcam_read_jpeg"); ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); + +- + netcam->receiving->image_time = curtime; + + /* +@@ -1280,8 +1328,8 @@ static int netcam_read_html_jpeg(netcam_ + 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + + (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; + +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "Calculated frame time %f", netcam->av_frame_time); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", ++ netcam->av_frame_time); + } + netcam->last_image = curtime; + +@@ -1300,20 +1348,290 @@ static int netcam_read_html_jpeg(netcam_ + + pthread_mutex_unlock(&netcam->mutex); + +- if (!netcam->caps.streaming) { ++ if (netcam->caps.streaming == NCS_UNSUPPORTED) { + if (!netcam->connect_keepalive) { +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "netcam_read_html_jpeg disconnecting netcam since keep-alive not set." ); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting " ++ "netcam since keep-alive not set."); ++ + netcam_disconnect(netcam); +- } else if (debug_level > CAMERA_INFO) { +- motion_log(LOG_DEBUG, 0, "netcam_read_html_jpeg leaving netcam connected." ); ++ } ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: leaving netcam connected."); ++ } ++ ++ return 0; ++} ++ ++/** ++ * netcam_http_request ++ * ++ * This routine initiates a connection on the specified netcam, ++ * for which every parameter has already been set (url, etc). ++ * It uses the HTTP protocol, which is what many IP cameras use. ++ * If this function succeeds, the HTTP response along with the ++ * headers are already processed, and you can start reading contents ++ * from here. ++ * ++ * Parameters: ++ * netcam Pointer to a netcam_context structure ++ * ++ * Returns: 0 on success, -1 if an error occurs. ++ */ ++static int netcam_http_request(netcam_context_ptr netcam) ++{ ++ int ix; ++ ++ /* ++ * Our basic initialisation has been completed. Now we will attempt ++ * to connect with the camera so that we can then get a "header" ++ * in order to find out what kind of camera we are dealing with, ++ * as well as what are the picture dimensions. Note that for ++ * this initial connection, any failure will cause an error ++ * return from netcam_start (unlike later possible attempts at ++ * re-connecting, if the network connection is later interrupted). ++ */ ++ for (ix = 0; ix < MAX_HEADER_RETRIES; ix++) { ++ /* ++ * netcam_connect does an automatic netcam_close, so it's ++ * safe to include it as part of this loop ++ * (Not always true now Keep-Alive is implemented). ++ */ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: about to try to connect, time #%d", ++ ix); ++ ++ if (netcam_connect(netcam, 0) != 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "Failed to open camera - check your config " ++ "and that netcamera is online"); ++ ++ /* Fatal error on startup */ ++ ix = MAX_HEADER_RETRIES; ++ break;; + } ++ ++ if (netcam_read_first_header(netcam) >= 0) ++ break; ++ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header - re-trying"); ++ } ++ ++ if (ix == MAX_HEADER_RETRIES) { ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first camera header " ++ "- giving up for now"); ++ return -1; + } + + return 0; + } + + /** ++ * netcam_mjpg_buffer_refill ++ * ++ * This routing reads content from the MJPG-camera until the response ++ * buffer of the specified netcam_context is full. If the connection is ++ * lost during this operation, it tries to re-connect. ++ * ++ * Parameters: ++ * netcam Pointer to a netcam_context structure ++ * ++ * Returns: The number of read bytes, ++ * or -1 if an fatal connection error occurs. ++ */ ++static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) ++{ ++ int retval; ++ ++ if (netcam->response->buffer_left > 0) ++ return netcam->response->buffer_left; ++ ++ while (1) { ++ retval = rbuf_read_bufferful(netcam); ++ if (retval <= 0) { /* If we got 0, we timeoutted. */ ++ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Read error," ++ " trying to reconnect.."); ++ /* We may have lost the connexion */ ++ if (netcam_http_request(netcam) < 0) { ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: lost the cam."); ++ return -1; /* We REALLY lost the cam... bail out for now. */ ++ } ++ } ++ ++ if (retval > 0) ++ break; ++ } ++ ++ netcam->response->buffer_left = retval; ++ netcam->response->buffer_pos = netcam->response->buffer; ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Refilled buffer with [%d]" ++ " bytes from the network.", retval); ++ ++ return retval; ++} ++ ++/** ++ * netcam_read_mjpg_jpeg ++ * ++ * This routine reads from a netcam using a MJPG-chunk based ++ * protocol, used by Linksys WVC200 for example. ++ * This implementation has been made by reverse-engineering ++ * the protocol, so it may contain bugs and should be considered as ++ * experimental. ++ * ++ * Protocol explanation: ++ * ++ * The stream consists of JPG pictures, spanned across multiple ++ * MJPG chunks (in general 3 chunks, altough that's not guaranteed). ++ * ++ * Each data chunk can range from 1 to 65535 bytes + a header, altough ++ * i have not seen anything bigger than 20000 bytes + a header. ++ * ++ * One MJPG chunk is constituted by a header plus the chunk data. ++ * The chunk header is of fixed size, and the following data size ++ * and position in the frame is specified in the chunk header. ++ * ++ * From what i have seen on WVC200 cameras, the stream always begins ++ * on JPG frame boundary, so you don't have to worry about beginning ++ * in the middle of a frame. ++ * ++ * See netcam.h for the mjpg_header structure and more details. ++ * ++ * Parameters: ++ * netcam Pointer to a netcam_context structure ++ * ++ * Returns: 0 if an image was obtained from the camera, ++ * or -1 if an error occurred. ++ */ ++static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) ++{ ++ netcam_buff_ptr buffer; ++ netcam_buff *xchg; ++ struct timeval curtime; ++ mjpg_header mh; ++ size_t read_bytes; ++ int retval; ++ ++ /* ++ * Initialisation - set our local pointers to the context ++ * information. ++ */ ++ buffer = netcam->receiving; ++ /* Assure the target buffer is empty. */ ++ buffer->used = 0; ++ ++ if (netcam_mjpg_buffer_refill(netcam) < 0) ++ return -1; ++ ++ /* Loop until we have a complete JPG. */ ++ while (1) { ++ read_bytes = 0; ++ while (read_bytes < sizeof(mh)) { ++ ++ /* Transfer what we have in buffer in the header structure. */ ++ retval = rbuf_flush(netcam, ((char *)&mh) + read_bytes, sizeof(mh) - read_bytes); ++ ++ read_bytes += retval; ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] header bytes.", ++ read_bytes, sizeof(mh)); ++ ++ /* If we don't have received a full header, refill our buffer. */ ++ if (read_bytes < sizeof(mh)) { ++ if (netcam_mjpg_buffer_refill(netcam) < 0) ++ return -1; ++ } ++ } ++ ++ /* Now check the validity of our header. */ ++ if (strncmp(mh.mh_magic, MJPG_MH_MAGIC, MJPG_MH_MAGIC_SIZE)) { ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Invalid header received," ++ " reconnecting"); ++ /* ++ * We shall reconnect to restart the stream, and get a chance ++ * to resync. ++ */ ++ if (netcam_http_request(netcam) < 0) ++ return -1; /* We lost the cam... bail out. */ ++ /* Even there, we need to resync. */ ++ buffer->used = 0; ++ continue ; ++ } ++ ++ /* Make room for the chunk. */ ++ netcam_check_buffsize(buffer, (int) mh.mh_chunksize); ++ ++ read_bytes = 0; ++ while (read_bytes < mh.mh_chunksize) { ++ retval = rbuf_flush(netcam, buffer->ptr + buffer->used + read_bytes, ++ mh.mh_chunksize - read_bytes); ++ read_bytes += retval; ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] chunk bytes," ++ " [%d/%d] total", read_bytes, mh.mh_chunksize, ++ buffer->used + read_bytes, mh.mh_framesize); ++ ++ if (retval < (int) (mh.mh_chunksize - read_bytes)) { ++ /* MOTION_LOG(EMG, TYPE_NETCAM, NO_ERRNO, "Chunk incomplete, going to refill."); */ ++ if (netcam_mjpg_buffer_refill(netcam) < 0) ++ return -1; ++ ++ } ++ } ++ buffer->used += read_bytes; ++ ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Chunk complete," ++ " buffer used [%d] bytes.", buffer->used); ++ ++ /* Is our JPG image complete ? */ ++ if (mh.mh_framesize == buffer->used) { ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Image complete," ++ " buffer used [%d] bytes.", buffer->used); ++ break; ++ } ++ /* MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Rlen now at [%d] bytes", rlen); */ ++ } ++ ++ /* ++ * read is complete - set the current 'receiving' buffer atomically ++ * as 'latest', and make the buffer previously in 'latest' become ++ * the new 'receiving'. ++ */ ++ if (gettimeofday(&curtime, NULL) < 0) ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); ++ ++ netcam->receiving->image_time = curtime; ++ ++ /* ++ * Calculate our "running average" time for this netcam's ++ * frame transmissions (except for the first time). ++ * Note that the average frame time is held in microseconds. ++ */ ++ if (netcam->last_image.tv_sec) { ++ netcam->av_frame_time = (9.0 * netcam->av_frame_time + ++ 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + ++ (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; ++ ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", ++ netcam->av_frame_time); ++ } ++ netcam->last_image = curtime; ++ ++ pthread_mutex_lock(&netcam->mutex); ++ ++ xchg = netcam->latest; ++ netcam->latest = netcam->receiving; ++ netcam->receiving = xchg; ++ netcam->imgcnt++; ++ /* ++ * We have a new frame ready. We send a signal so that ++ * any thread (e.g. the motion main loop) waiting for the ++ * next frame to become available may proceed. ++ */ ++ pthread_cond_signal(&netcam->pic_ready); ++ ++ pthread_mutex_unlock(&netcam->mutex); ++ ++ return 0; ++} ++ ++/** + * netcam_read_ftp_jpeg + * + * This routine reads from a netcam using the FTP protocol. +@@ -1328,19 +1646,19 @@ static int netcam_read_ftp_jpeg(netcam_c + netcam_buff *xchg; + struct timeval curtime; + +- /* Point to our working buffer */ ++ /* Point to our working buffer. */ + buffer = netcam->receiving; + buffer->used = 0; + +- /* Request the image from the remote server */ ++ /* Request the image from the remote server. */ + if (ftp_get_socket(netcam->ftp) <= 0) { +- motion_log(LOG_ERR, 0, "ftp_get_socket failed in netcam_read_jpeg"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: ftp_get_socket failed"); + return -1; + } + +- /* Now fetch the image using ftp_read. Note this is a blocking call */ ++ /* Now fetch the image using ftp_read. Note this is a blocking call. */ + do { +- /* Assure there's enough room in the buffer */ ++ /* Assure there's enough room in the buffer. */ + netcam_check_buffsize(buffer, FTP_BUF_SIZE); + + /* Do the read */ +@@ -1351,9 +1669,8 @@ static int netcam_read_ftp_jpeg(netcam_c + } while (len > 0); + + if (gettimeofday(&curtime, NULL) < 0) +- motion_log(LOG_ERR, 1, "gettimeofday in netcam_read_jpeg"); ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); + +- + netcam->receiving->image_time = curtime; + /* + * Calculate our "running average" time for this netcam's +@@ -1361,13 +1678,12 @@ static int netcam_read_ftp_jpeg(netcam_c + * Note that the average frame time is held in microseconds. + */ + if (netcam->last_image.tv_sec) { +- netcam->av_frame_time = +- ((9.0 * netcam->av_frame_time) + 1000000.0 * +- (curtime.tv_sec - netcam->last_image.tv_sec) + +- (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; ++ netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * ++ (curtime.tv_sec - netcam->last_image.tv_sec) + ++ (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; + +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "Calculated frame time %f", netcam->av_frame_time); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", ++ netcam->av_frame_time); + } + + netcam->last_image = curtime; +@@ -1375,7 +1691,7 @@ static int netcam_read_ftp_jpeg(netcam_c + /* + * read is complete - set the current 'receiving' buffer atomically + * as 'latest', and make the buffer previously in 'latest' become +- * the new 'receiving' ++ * the new 'receiving'. + */ + pthread_mutex_lock(&netcam->mutex); + +@@ -1390,6 +1706,7 @@ static int netcam_read_ftp_jpeg(netcam_c + * next frame to become available may proceed. + */ + pthread_cond_signal(&netcam->pic_ready); ++ + pthread_mutex_unlock(&netcam->mutex); + + return 0; +@@ -1406,77 +1723,80 @@ static int netcam_read_ftp_jpeg(netcam_c + */ + static int netcam_read_file_jpeg(netcam_context_ptr netcam) + { +- int loop_counter=0; ++ int loop_counter = 0; ++ ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Begin"); + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(-1,0,"Begin %s", __FUNCTION__); +- + netcam_buff_ptr buffer; + int len; + netcam_buff *xchg; + struct timeval curtime; + struct stat statbuf; + +- /* Point to our working buffer */ ++ /* Point to our working buffer. */ + buffer = netcam->receiving; + buffer->used = 0; + + /*int fstat(int filedes, struct stat *buf);*/ + do { +- +- if (stat( netcam->file->path, &statbuf)) { +- motion_log(-1, 0, "stat(%s) error", netcam->file->path ); ++ if (stat(netcam->file->path, &statbuf)) { ++ MOTION_LOG(CRT, TYPE_NETCAM, SHOW_ERRNO, "%s: stat(%s) error", ++ netcam->file->path); + return -1; + } + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(-1, 0, "statbuf.st_mtime[%d] != last_st_mtime[%d]", statbuf.st_mtime, netcam->file->last_st_mtime); +- +- if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { //its waits POLLING_TIMEOUT +- motion_log(-1, 0, "waiting new file image timeout" ); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: statbuf.st_mtime[%d]" ++ " != last_st_mtime[%d]", statbuf.st_mtime, ++ netcam->file->last_st_mtime); ++ ++ /* its waits POLLING_TIMEOUT */ ++ if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: waiting new file image" ++ " timeout"); + return -1; + } + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(-1, 0, "delay waiting new file image "); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: delay waiting new" ++ " file image "); + +- //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000 ); //its waits 5seconds - READ_TIMEOUT +- SLEEP( 0, POLLING_TIME ); // its waits 500ms ++ //its waits 5seconds - READ_TIMEOUT ++ //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000); ++ SLEEP(0, POLLING_TIME); // its waits 500ms + /*return -1;*/ + loop_counter++; + +- } while (statbuf.st_mtime==netcam->file->last_st_mtime); ++ } while (statbuf.st_mtime == netcam->file->last_st_mtime); + + netcam->file->last_st_mtime = statbuf.st_mtime; +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_INFO, 0, "processing new file image - st_mtime " +- "%d", netcam->file->last_st_mtime ); + +- +- /* Assure there's enough room in the buffer */ +- while (buffer->size < (size_t)statbuf.st_size) ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: processing new file image -" ++ " st_mtime %d", netcam->file->last_st_mtime); ++ ++ /* Assure there's enough room in the buffer. */ ++ while (buffer->size < (size_t)statbuf.st_size) + netcam_check_buffsize(buffer, statbuf.st_size); + + + /* Do the read */ +- netcam->file->control_file_desc = open( netcam->file->path, O_RDONLY); +- ++ netcam->file->control_file_desc = open(netcam->file->path, O_RDONLY); + if (netcam->file->control_file_desc < 0) { +- motion_log(-1, 0, "open(%s) error:%d", netcam->file->path, netcam->file->control_file_desc); ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: open(%s) error: %d", ++ netcam->file->path, netcam->file->control_file_desc); + return -1; + } + +- if ((len = read(netcam->file->control_file_desc, buffer->ptr + buffer->used, statbuf.st_size)) < 0) { +- motion_log(-1, 0, "read(%s) error:%d", netcam->file->control_file_desc, len ); ++ if ((len = read(netcam->file->control_file_desc, ++ buffer->ptr + buffer->used, statbuf.st_size)) < 0) { ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: read(%s) error: %d", ++ netcam->file->control_file_desc, len); + return -1; + } + + buffer->used += len; ++ close(netcam->file->control_file_desc); + +- close( netcam->file->control_file_desc ); +- +- if (gettimeofday(&curtime, NULL) < 0) +- motion_log(LOG_ERR, 1, "gettimeofday in netcam_read_jpeg"); ++ if (gettimeofday(&curtime, NULL) < 0) ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); + + netcam->receiving->image_time = curtime; + /* +@@ -1485,13 +1805,12 @@ static int netcam_read_file_jpeg(netcam_ + * Note that the average frame time is held in microseconds. + */ + if (netcam->last_image.tv_sec) { +- netcam->av_frame_time = +- ((9.0 * netcam->av_frame_time) + 1000000.0 * +- (curtime.tv_sec - netcam->last_image.tv_sec) + +- (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; ++ netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * ++ (curtime.tv_sec - netcam->last_image.tv_sec) + ++ (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; + +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "Calculated frame time %f", netcam->av_frame_time); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", ++ netcam->av_frame_time); + } + + netcam->last_image = curtime; +@@ -1499,7 +1818,7 @@ static int netcam_read_file_jpeg(netcam_ + /* + * read is complete - set the current 'receiving' buffer atomically + * as 'latest', and make the buffer previously in 'latest' become +- * the new 'receiving' ++ * the new 'receiving'. + */ + pthread_mutex_lock(&netcam->mutex); + +@@ -1514,11 +1833,9 @@ static int netcam_read_file_jpeg(netcam_ + * next frame to become available may proceed. + */ + pthread_cond_signal(&netcam->pic_ready); +- + pthread_mutex_unlock(&netcam->mutex); + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(-1,0,"End %s", __FUNCTION__); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: End"); + + return 0; + } +@@ -1528,7 +1845,7 @@ tfile_context *file_new_context(void) + { + tfile_context *ret; + +- /* note that mymalloc will exit on any problem */ ++ /* Note that mymalloc will exit on any problem. */ + ret = mymalloc(sizeof(tfile_context)); + if (!ret) + return ret; +@@ -1537,7 +1854,8 @@ tfile_context *file_new_context(void) + return ret; + } + +-void file_free_context(tfile_context* ctxt) { ++void file_free_context(tfile_context* ctxt) ++{ + if (ctxt == NULL) + return; + +@@ -1562,8 +1880,8 @@ static int netcam_setup_file(netcam_cont + netcam->file->path = url->path; + url->path = NULL; + +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_INFO, 0, "netcam_setup_file: netcam->file->path %s",netcam->file->path); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->file->path %s", ++ netcam->file->path); + + netcam_url_free(url); + +@@ -1579,7 +1897,7 @@ static int netcam_setup_file(netcam_cont + * + * Parameters + * +- * arg Pointer to the motion context for this camera ++ * arg Pointer to the motion context for this camera. + * + * Returns: NULL pointer + * +@@ -1589,16 +1907,15 @@ static void *netcam_handler_loop(void *a + int retval; + int open_error = 0; + netcam_context_ptr netcam = arg; +- struct context *cnt = netcam->cnt; /* needed for the SETUP macro :-( */ ++ struct context *cnt = netcam->cnt; /* Needed for the SETUP macro :-( */ + + /* Store the corresponding motion thread number in TLS also for this +- * thread (necessary for 'motion_log' to function properly). ++ * thread (necessary for 'MOTION_LOG' to function properly). + */ + pthread_setspecific(tls_key_threadnr, (void *)((unsigned long)cnt->threadnr)); + +- if (SETUP) +- motion_log(LOG_INFO, 0, "Camera handler thread [%d] started", netcam->threadnr); +- ++ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Camera handler thread [%d]" ++ " started", netcam->threadnr); + /* + * The logic of our loop is very simple. If this is a non- + * streaming camera, we re-establish connection with the camera +@@ -1611,97 +1928,137 @@ static void *netcam_handler_loop(void *a + */ + + while (!netcam->finish) { +- if (netcam->response) { /* if html input */ +- if (!netcam->caps.streaming) { ++ if (netcam->response) { /* If html input */ ++ if (netcam->caps.streaming == NCS_UNSUPPORTED) { + /* Non-streaming ie. jpeg */ +- if (!netcam->connect_keepalive || (netcam->connect_keepalive && netcam->keepalive_timeup)) { +- /* If keepalive flag set but time up, time to close this socket */ ++ if (!netcam->connect_keepalive || ++ (netcam->connect_keepalive && netcam->keepalive_timeup)) { ++ /* If keepalive flag set but time up, time to close this socket. */ + if (netcam->connect_keepalive && netcam->keepalive_timeup) { +- motion_log(LOG_INFO, 0, "Closing netcam socket as Keep-Alive time is up " +- "(camera sent Close field). A reconnect should happen."); ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Closing netcam socket" ++ " as Keep-Alive time is up (camera sent Close field). A reconnect" ++ " should happen."); + netcam_disconnect(netcam); + netcam->keepalive_timeup = FALSE; + } + +- /* And the netcam_connect call below will open a new one */ ++ /* And the netcam_connect call below will open a new one. */ + if (netcam_connect(netcam, open_error) < 0) { +- if (!open_error) { /* log first error */ +- motion_log(LOG_ERR, 0, +- "re-opening camera (non-streaming)"); ++ if (!open_error) { /* Log first error. */ ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, ++ "%s: re-opening camera (non-streaming)"); + open_error = 1; + } +- /* need to have a dynamic delay here */ +- SLEEP(5,0); ++ /* Need to have a dynamic delay here. */ ++ SLEEP(5, 0); + continue; + } + +- if (open_error) { /* log re-connection */ +- motion_log(LOG_ERR, 0, "camera re-connected"); ++ if (open_error) { /* Log re-connection */ ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, ++ "%s: camera re-connected"); + open_error = 0; + } + } +- /* Send our request and look at the response */ ++ /* Send our request and look at the response. */ + if ((retval = netcam_read_first_header(netcam)) != 1) { + if (retval > 0) { +- motion_log(LOG_ERR, 0, "Unrecognized image header (%d)", retval); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized image" ++ " header (%d)", retval); + } else if (retval != -1) { +- motion_log(LOG_ERR, 0, "Error in header (%d)", retval); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error in header (%d)", ++ retval); + } +- /* need to have a dynamic delay here */ ++ /* Need to have a dynamic delay here. */ + continue; + } +- } else { /* Streaming */ ++ } else if (netcam->caps.streaming == NCS_MULTIPART) { /* Multipart Streaming */ + if (netcam_read_next_header(netcam) < 0) { + if (netcam_connect(netcam, open_error) < 0) { +- if (!open_error) { /* log first error */ +- motion_log(LOG_ERR, 0, "re-opening camera (streaming)"); ++ if (!open_error) { /* Log first error */ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, ++ "%s: re-opening camera (streaming)"); + open_error = 1; + } +- SLEEP(5,0); ++ SLEEP(5, 0); + continue; + } + + if ((retval = netcam_read_first_header(netcam) != 2)) { + if (retval > 0) { +- motion_log(LOG_ERR, 0, "Unrecognized image header (%d)", retval); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, ++ "%s: Unrecognized image header (%d)", ++ retval); + } else if (retval != -1) { +- motion_log(LOG_ERR, 0, "Error in header (%d)", retval); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, ++ "%s: Error in header (%d)", retval); + } +- /* FIXME need some limit */ ++ /* FIXME need some limit. */ + continue; + } + } +- if (open_error) { /* log re-connection */ +- motion_log(LOG_ERR, 0, "camera re-connected"); ++ if (open_error) { /* Log re-connection */ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, ++ "%s: camera re-connected"); + open_error = 0; + } ++ } else if (netcam->caps.streaming == NCS_BLOCK) { /* MJPG-Block streaming */ ++ /* ++ * Since we cannot move in the stream here, because we will read past the ++ * MJPG-block-header, error handling is done while reading MJPG blocks. ++ */ + } + } +- if (netcam->get_image(netcam) < 0) { +- motion_log(LOG_ERR, 0, "Error getting jpeg image"); +- /* if FTP connection, attempt to re-connect to server */ +- if (netcam->ftp) { +- close(netcam->ftp->control_file_desc); +- if (ftp_connect(netcam) < 0) +- motion_log(LOG_ERR, 0, "Trying to re-connect"); +- ++ ++ if (netcam->caps.streaming == NCS_RTSP) { ++ if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect ++ if (netcam->rtsp->status == RTSP_CONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Reconnecting with camera...."); ++ } ++ netcam->rtsp->status = RTSP_RECONNECTING; ++ netcam_connect_rtsp(netcam); ++ continue; ++ } else { ++ // We think we are connected... ++ if (netcam->get_image(netcam) < 0) { ++ if (netcam->rtsp->status == RTSP_CONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image. Reconnecting with camera...."); ++ } ++ //Nope. We are not or got bad image. Reconnect ++ netcam->rtsp->status = RTSP_RECONNECTING; ++ netcam_connect_rtsp(netcam); ++ continue; ++ } ++ } ++ } ++ ++ if (netcam->caps.streaming != NCS_RTSP) { ++ if (netcam->get_image(netcam) < 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error getting jpeg image"); ++ /* If FTP connection, attempt to re-connect to server. */ ++ if (netcam->ftp) { ++ close(netcam->ftp->control_file_desc); ++ if (ftp_connect(netcam) < 0) ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Trying to re-connect"); ++ } ++ continue; + } +- continue; + } ++ + /* + * FIXME + * Need to check whether the image was received / decoded +- * satisfactorily ++ * satisfactorily. + */ + + /* + * If non-streaming, want to synchronize our thread with the + * motion main-loop. + */ +- if (!netcam->caps.streaming) { ++ if (netcam->caps.streaming == NCS_UNSUPPORTED) { + pthread_mutex_lock(&netcam->mutex); + +- /* before anything else, check for system shutdown */ ++ /* Before anything else, check for system shutdown. */ + if (netcam->finish) { + pthread_mutex_unlock(&netcam->mutex); + break; +@@ -1722,21 +2079,22 @@ static void *netcam_handler_loop(void *a + + pthread_mutex_unlock(&netcam->mutex); + } +- /* the loop continues forever, or until motion shutdown */ ++ /* The loop continues forever, or until motion shutdown. */ + } + +- /* our thread is finished - decrement motion's thread count */ ++ /* Our thread is finished - decrement motion's thread count. */ + pthread_mutex_lock(&global_lock); + threads_running--; + pthread_mutex_unlock(&global_lock); + +- /* log out a termination message */ +- motion_log(LOG_INFO, 0, "netcam camera handler: finish set, exiting"); ++ /* Log out a termination message. */ ++ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: netcam camera handler:" ++ " finish set, exiting"); + +- /* setting netcam->thread_id to zero shows netcam_cleanup we're done */ ++ /* Setting netcam->thread_id to zero shows netcam_cleanup we're done. */ + netcam->thread_id = 0; + +- /* signal netcam_cleanup that we're all done */ ++ /* Signal netcam_cleanup that we're all done. */ + pthread_mutex_lock(&netcam->mutex); + pthread_cond_signal(&netcam->exiting); + pthread_mutex_unlock(&netcam->mutex); +@@ -1745,22 +2103,38 @@ static void *netcam_handler_loop(void *a + pthread_exit(NULL); + } + +-static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) { ++/** ++ * netcam_http_build_url ++ * ++ * This routing takes care of the url-processing part of the http protocol. ++ * This includes url scheme and parsing, proxy handling, http-authentication ++ * preparation, response buffer allocation and so on. At the end of this ++ * routine, we are ready to call netcam_http_request(). ++ * ++ * Parameters: ++ * netcam Pointer to a netcam_context structure ++ * url Pointer to a netcam url structure ++ * ++ * Returns: 0 on success, ++ * or -1 if an fatal error occurs. ++ */ ++static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) ++{ + struct context *cnt = netcam->cnt; +- const char *ptr; /* working var */ +- char *userpass; /* temp pointer to config value */ +- char *encuserpass; /* temp storage for encoded ver */ +- char *request_pass = NULL; /* temp storage for base64 conv */ ++ const char *ptr; /* Working var */ ++ char *userpass; /* Temp pointer to config value */ ++ char *encuserpass; /* Temp storage for encoded ver */ ++ char *request_pass = NULL; /* Temp storage for base64 conv */ + int ix; + +- /* First the http context structure */ ++ /* First the http context structure. */ + netcam->response = (struct rbuf *) mymalloc(sizeof(struct rbuf)); + memset(netcam->response, 0, sizeof(struct rbuf)); + +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_INFO, 0, "netcam_setup_html: Netcam has flags: HTTP1.0: %s HTTP1.1: %s Keep-Alive %s.", +- netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", +- netcam->connect_keepalive ? "ON":"OFF"); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam has flags:" ++ " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", ++ netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", ++ netcam->connect_keepalive ? "ON":"OFF"); + + /* + * The network camera may require a username and password. If +@@ -1775,11 +2149,11 @@ static int netcam_setup_html(netcam_cont + else + ptr = url->userpass; + +- /* base64_encode needs up to 3 additional chars */ ++ /* base64_encode needs up to 3 additional chars. */ + if (ptr) { + userpass = mymalloc(strlen(ptr) + 3); + strcpy(userpass, ptr); +- } else { ++ } else { + userpass = NULL; + } + +@@ -1792,20 +2166,21 @@ static int netcam_setup_html(netcam_cont + * concatenate it with the request. + * + */ +- /* space for final \r\n plus string terminator */ ++ ++ /* Space for final \r\n plus string terminator. */ + ix = 3; + +- /* See if username / password is required */ +- if (userpass) { /* if either of the above are non-NULL */ +- /* Allocate space for the base64-encoded string */ ++ /* See if username / password is required. */ ++ if (userpass) { /* If either of the above are non-NULL. */ ++ /* Allocate space for the base64-encoded string. */ + encuserpass = mymalloc(BASE64_LENGTH(strlen(userpass)) + 1); +- /* Fill in the value */ ++ /* Fill in the value. */ + base64_encode(userpass, encuserpass, strlen(userpass)); +- /* Now create the last part (authorization) of the request */ ++ /* Now create the last part (authorization) of the request. */ + request_pass = mymalloc(strlen(connect_auth_req) + + strlen(encuserpass) + 1); + ix += sprintf(request_pass, connect_auth_req, encuserpass); +- /* free the working variables */ ++ /* Free the working variables. */ + free(encuserpass); + } + +@@ -1831,16 +2206,19 @@ static int netcam_setup_html(netcam_cont + ptr = mymalloc(strlen(url->service) + strlen(url->host) + + strlen(url->path) + 4); + sprintf((char *)ptr, "http://%s%s", url->host, url->path); +- netcam->connect_keepalive=0; /* Disable Keepalive if proxy */ +- +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_DEBUG, 0, "Removed netcam_keepalive flag due to proxy set." +- "Proxy is incompatible with Keep-Alive."); ++ ++ netcam->connect_keepalive = FALSE; /* Disable Keepalive if proxy */ ++ free((void *)netcam->cnt->conf.netcam_keepalive); ++ netcam->cnt->conf.netcam_keepalive = strdup("off"); ++ ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: " ++ "Removed netcam_keepalive flag due to proxy set." ++ "Proxy is incompatible with Keep-Alive."); + } else { +- /* if no proxy, set as netcam_url path */ ++ /* If no proxy, set as netcam_url path. */ + ptr = url->path; + /* +- * after generating the connect message the string ++ * After generating the connect message the string + * will be freed, so we don't want netcam_url_free + * to free it as well. + */ +@@ -1849,21 +2227,25 @@ static int netcam_setup_html(netcam_cont + + ix += strlen(ptr); + +- /* Now add the required number of characters for the close header +- * or Keep-Alive header. We test the flag which can be unset if +- * there is a problem (rather than the flag in the conf structure +- * which is read-only. +- */ ++ /* ++ * Now add the required number of characters for the close header ++ * or Keep-Alive header. We test the flag which can be unset if ++ * there is a problem (rather than the flag in the conf structure ++ * which is read-only. ++ */ + +- if (netcam->connect_keepalive) ++ if (netcam->connect_keepalive) + ix += strlen(connect_req_keepalive); +- else ++ else + ix += strlen(connect_req_close); + +- /* Point to either the HTTP 1.0 or 1.1 request header set */ +- /* If the configuration is anything other than 1.1, use 1.0 */ +- /* as a default. This avoids a chance of being left with none */ +- if (netcam->connect_http_11==TRUE) ++ ++ /* ++ * Point to either the HTTP 1.0 or 1.1 request header set ++ * If the configuration is anything other than 1.1, use 1.0 ++ * as a default. This avoids a chance of being left with none. ++ */ ++ if (netcam->connect_http_11 == TRUE) + connect_req = connect_req_http11; + else + connect_req = connect_req_http10; +@@ -1875,7 +2257,7 @@ static int netcam_setup_html(netcam_cont + netcam->connect_request = mymalloc(strlen(connect_req) + ix + + strlen(netcam->connect_host)); + +- /* Now create the request string with an sprintf */ ++ /* Now create the request string with an sprintf. */ + sprintf(netcam->connect_request, connect_req, ptr, + netcam->connect_host); + +@@ -1891,73 +2273,110 @@ static int netcam_setup_html(netcam_cont + free(userpass); + } + +- /* put on the final CRLF onto the request */ ++ /* Put on the final CRLF onto the request. */ + strcat(netcam->connect_request, "\r\n"); + free((void *)ptr); +- netcam_url_free(url); /* Cleanup the url data */ ++ netcam_url_free(url); /* Cleanup the url data. */ + +- if (debug_level > CAMERA_INFO) { +- motion_log(-1, 0, "Camera connect string is ''%s''", netcam->connect_request); +- motion_log(-1, 0, "End of camera connect string."); +- } ++ MOTION_LOG(INF , TYPE_NETCAM, NO_ERRNO, "%s: Camera connect" ++ " string is ''%s'' End of camera connect string.", ++ netcam->connect_request); ++ return 0; ++} + ++/** ++ * netcam_setup_html ++ * This function will parse the netcam url, connect to the camera, ++ * set its type to jpeg-based, detect multipart and keep-alive, ++ * and the get_image method accordingly. The cam can be non-streaming ++ * or multipart-streaming. ++ * ++ * Parameters ++ * ++ * netcam Pointer to the netcam_context for the camera ++ * url Pointer to the url of the camera ++ * ++ * Returns: 0 on success (camera link ok) or -1 if an error occurred. ++ * ++ */ ++static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) ++{ + /* +- * Our basic initialisation has been completed. Now we will attempt +- * to connect with the camera so that we can then get a "header" +- * in order to find out what kind of camera we are dealing with, +- * as well as what are the picture dimensions. Note that for +- * this initial connection, any failure will cause an error +- * return from netcam_start (unlike later possible attempts at +- * re-connecting, if the network connection is later interrupted). ++ * This netcam is http-based, so build the required URL and ++ * structures, like the connection-string and so on. + */ +- for (ix = 0; ix < MAX_HEADER_RETRIES; ix++) { +- /* +- * netcam_connect does an automatic netcam_close, so it's +- * safe to include it as part of this loop +- * (Not always true now Keep-Alive is implemented) +- */ +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "netcam_setup_html: about to try to connect, time #%d", ix); +- +- if (netcam_connect(netcam, 0) != 0) { +- motion_log(LOG_ERR, 0,"Failed to open camera - check your config and that netcamera is online"); +- +- /* Fatal error on startup */ +- ix = MAX_HEADER_RETRIES; +- break;; +- } +- +- if (netcam_read_first_header(netcam) >= 0) +- break; +- +- motion_log(LOG_ERR, 0, "Error reading first header - re-trying"); +- } +- +- if (ix == MAX_HEADER_RETRIES) { +- motion_log(LOG_ERR, 0, "Failed to read first camera header - giving up for now"); ++ if (netcam_http_build_url(netcam, url) < 0) + return -1; +- } ++ ++ /* ++ * Then we will send our http request and get headers. ++ */ ++ if (netcam_http_request(netcam) < 0) ++ return -1; + + /* + * If this is a streaming camera, we need to position just +- * past the boundary string and read the image header ++ * past the boundary string and read the image header. + */ +- if (netcam->caps.streaming) { ++ if (netcam->caps.streaming == NCS_MULTIPART) { + if (netcam_read_next_header(netcam) < 0) { +- motion_log(LOG_ERR, 0, +- "Failed to read first stream header - giving up for now"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed " ++ "to read first stream header - " ++ "giving up for now"); + return -1; + } + } + +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "netcam_setup_html: connected, going on to read image.", ix ); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: connected," ++ " going on to read image."); + + netcam->get_image = netcam_read_html_jpeg; + return 0; + } + +-static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) { ++/** ++ * netcam_setup_mjpg ++ * This function will parse the netcam url, connect to the camera, ++ * set its type to MJPG-Streaming, and the get_image method accordingly. ++ * ++ * Parameters ++ * ++ * netcam Pointer to the netcam_context for the camera ++ * url Pointer to the url of the camera ++ * ++ * Returns: 0 on success (camera link ok) or -1 if an error occurred. ++ * ++ */ ++static int netcam_setup_mjpg(netcam_context_ptr netcam, struct url_t *url) ++{ ++ /* ++ * This netcam is http-based, so build the required URL and ++ * structures, like the connection-string and so on. ++ */ ++ if (netcam_http_build_url(netcam, url) != 0) ++ return -1; ++ ++ /* Then we will send our http request and get headers. */ ++ if (netcam_http_request(netcam) < 0) ++ return -1; ++ ++ /* We have a special type of streaming camera. */ ++ netcam->caps.streaming = NCS_BLOCK; ++ ++ /* ++ * We are positionned right just at the start of the first MJPG ++ * header, so don't move anymore, initialization complete. ++ */ ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: connected," ++ " going on to read and decode MJPG chunks."); ++ ++ netcam->get_image = netcam_read_mjpg_jpeg; ++ ++ return 0; ++} ++ ++static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) ++{ + struct context *cnt = netcam->cnt; + const char *ptr; + +@@ -1972,21 +2391,21 @@ static int netcam_setup_ftp(netcam_conte + netcam->ftp->path = url->path; + url->path = NULL; + +- if (cnt->conf.netcam_userpass != NULL) ++ if (cnt->conf.netcam_userpass != NULL) { + ptr = cnt->conf.netcam_userpass; +- else +- ptr = url->userpass; /* don't set this one NULL, gets freed */ +- ++ } else { ++ ptr = url->userpass; /* Don't set this one NULL, gets freed. */ ++ } + + if (ptr != NULL) { + char *cptr; + + if ((cptr = strchr(ptr, ':')) == NULL) { +- netcam->ftp->user = strdup(ptr); ++ netcam->ftp->user = mystrdup(ptr); + } else { + netcam->ftp->user = mymalloc((cptr - ptr)); +- memcpy(netcam->ftp->user,ptr,(cptr - ptr)); +- netcam->ftp->passwd = strdup(cptr + 1); ++ memcpy(netcam->ftp->user, ptr,(cptr - ptr)); ++ netcam->ftp->passwd = mystrdup(cptr + 1); + } + } + +@@ -2002,7 +2421,8 @@ static int netcam_setup_ftp(netcam_conte + } + + if (ftp_send_type(netcam->ftp, 'I') < 0) { +- motion_log(LOG_ERR, 0, "Error sending TYPE I to ftp server"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error sending" ++ " TYPE I to ftp server"); + return -1; + } + +@@ -2028,19 +2448,23 @@ static int netcam_setup_ftp(netcam_conte + * error reply from the system call. + * + */ +-ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) { ++ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) ++{ + ssize_t retval; + fd_set fd_r; + struct timeval selecttime; + ++ if (netcam->sock < 0) ++ return -1; /* We are not connected, it's impossible to receive data. */ ++ + FD_ZERO(&fd_r); + FD_SET(netcam->sock, &fd_r); + selecttime = netcam->timeout; + + retval = select(FD_SETSIZE, &fd_r, NULL, NULL, &selecttime); +- if (retval == 0) /* 0 means timeout */ ++ if (retval == 0) /* 0 means timeout */ + return -1; +- ++ + return recv(netcam->sock, buffptr, buffsize, 0); + } + +@@ -2081,12 +2505,12 @@ void netcam_cleanup(netcam_context_ptr n + */ + pthread_mutex_lock(&netcam->mutex); + +- if (netcam->cnt->netcam == NULL) ++ if (netcam->cnt->netcam == NULL) + return; +- ++ + /* + * We set the netcam_context pointer in the motion main-loop context +- * to be NULL, so that this routine won't be called a second time ++ * to be NULL, so that this routine won't be called a second time. + */ + netcam->cnt->netcam = NULL; + +@@ -2103,9 +2527,10 @@ void netcam_cleanup(netcam_context_ptr n + * netcam->mutex locked. + */ + +- if (!netcam->caps.streaming) ++ if (netcam->caps.streaming == NCS_UNSUPPORTED) + pthread_cond_signal(&netcam->cap_cond); + ++ + /* + * Once the camera-handler gets to the end of it's loop (probably as + * soon as we release netcam->mutex), because netcam->finish has been +@@ -2131,28 +2556,30 @@ void netcam_cleanup(netcam_context_ptr n + pthread_cond_timedwait(&netcam->exiting, &netcam->mutex, &waittime) != 0) { + /* + * Although this shouldn't happen, if it *does* happen we will +- * log it (just for the programmer's information) ++ * log it (just for the programmer's information). + */ +- motion_log(-1, 0, "No response from camera " +- "handler - it must have already died"); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: No response from camera " ++ "handler - it must have already died"); + pthread_mutex_lock(&global_lock); + threads_running--; + pthread_mutex_unlock(&global_lock); + } + +- /* we don't need any lock anymore, so release it */ ++ /* We don't need any lock anymore, so release it. */ + pthread_mutex_unlock(&netcam->mutex); + +- /* and cleanup the rest of the netcam_context structure */ ++ /* and cleanup the rest of the netcam_context structure. */ + if (netcam->connect_host != NULL) + free(netcam->connect_host); +- ++ + if (netcam->connect_request != NULL) + free(netcam->connect_request); + ++ + if (netcam->boundary != NULL) + free(netcam->boundary); + ++ + if (netcam->latest != NULL) { + if (netcam->latest->ptr != NULL) + free(netcam->latest->ptr); +@@ -2170,7 +2597,7 @@ void netcam_cleanup(netcam_context_ptr n + if (netcam->jpegbuf != NULL) { + if (netcam->jpegbuf->ptr != NULL) + free(netcam->jpegbuf->ptr); +- ++ + free(netcam->jpegbuf); + } + +@@ -2179,9 +2606,14 @@ void netcam_cleanup(netcam_context_ptr n + else + netcam_disconnect(netcam); + ++ + if (netcam->response != NULL) + free(netcam->response); +- ++ ++ ++ if (netcam->caps.streaming == NCS_RTSP) ++ netcam_shutdown_rtsp(netcam); ++ + pthread_mutex_destroy(&netcam->mutex); + pthread_cond_destroy(&netcam->cap_cond); + pthread_cond_destroy(&netcam->pic_ready); +@@ -2216,9 +2648,7 @@ int netcam_next(struct context *cnt, uns + netcam = cnt->netcam; + + if (!netcam->latest->used) { +- if (debug_level) +- motion_log(LOG_INFO, 0, "netcam_next called with no data in buffer"); +- ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: called with no data in buffer"); + return NETCAM_NOTHING_NEW_ERROR; + } + +@@ -2227,23 +2657,34 @@ int netcam_next(struct context *cnt, uns + * motion main-loop with the camera-handling thread through a signal, + * together with a flag to say "start your next capture". + */ +- if (!netcam->caps.streaming) { ++ if (netcam->caps.streaming == NCS_UNSUPPORTED) { + pthread_mutex_lock(&netcam->mutex); + netcam->start_capture = 1; + pthread_cond_signal(&netcam->cap_cond); + pthread_mutex_unlock(&netcam->mutex); + } + ++ if (netcam->caps.streaming == NCS_RTSP) { ++ ++ if (netcam->rtsp->status == RTSP_RECONNECTING) ++ return NETCAM_NOTHING_NEW_ERROR; ++ ++ if (netcam_next_rtsp(image , netcam) < 0) ++ return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; ++ ++ return 0; ++ } ++ + /* + * If an error occurs in the JPEG decompression which follows this, + * jpeglib will return to the code within this 'if'. Basically, our + * approach is to just return a NULL (failed) to the caller (an +- * error message has already been produced by the libjpeg routines) ++ * error message has already been produced by the libjpeg routines). + */ + if (setjmp(netcam->setjmp_buffer)) + return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; + +- /* If there was no error, process the latest image buffer */ ++ /* If there was no error, process the latest image buffer. */ + return netcam_proc_jpeg(netcam, image); + } + +@@ -2258,25 +2699,24 @@ int netcam_next(struct context *cnt, uns + * + * Parameters: + * +- * cnt Pointer to the motion context structure for this device ++ * cnt Pointer to the motion context structure for this device. + * +- * Returns: 0 on success, -1 on any failure ++ * Returns: 0 on success ++ * -1 on any failure ++ * -3 image dimensions are not modulo 16 + */ + + int netcam_start(struct context *cnt) + { +- netcam_context_ptr netcam; /* local pointer to our context */ +- pthread_attr_t handler_attribute; /* attributes of our handler thread */ +- int retval; /* working var */ +- struct url_t url; /* for parsing netcam URL */ +- +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "entered netcam_start()"); ++ netcam_context_ptr netcam; /* Local pointer to our context. */ ++ pthread_attr_t handler_attribute; /* Attributes of our handler thread. */ ++ int retval; /* Working var. */ ++ struct url_t url; /* For parsing netcam URL. */ + + memset(&url, 0, sizeof(url)); +- if (SETUP) +- motion_log(LOG_INFO, 0, "Camera thread starting..."); + ++ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Network Camera thread" ++ " starting... for url (%s)", cnt->conf.netcam_url); + /* + * Create a new netcam_context for this camera + * and clear all the entries. +@@ -2284,8 +2724,8 @@ int netcam_start(struct context *cnt) + cnt->netcam = (struct netcam_context *) + mymalloc(sizeof(struct netcam_context)); + memset(cnt->netcam, 0, sizeof(struct netcam_context)); +- netcam = cnt->netcam; /* Just for clarity in remaining code */ +- netcam->cnt = cnt; /* Fill in the "parent" info */ ++ netcam = cnt->netcam; /* Just for clarity in remaining code. */ ++ netcam->cnt = cnt; /* Fill in the "parent" info. */ + + /* + * Fill in our new netcam context with all known initial +@@ -2312,24 +2752,23 @@ int netcam_start(struct context *cnt) + pthread_cond_init(&netcam->pic_ready, NULL); + pthread_cond_init(&netcam->exiting, NULL); + +- /* Initialise the average frame time to the user's value */ ++ /* Initialise the average frame time to the user's value. */ + netcam->av_frame_time = 1000000.0 / cnt->conf.frame_limit; + +- /* +- * If a proxy has been specified, parse that URL. +- */ ++ /* If a proxy has been specified, parse that URL. */ + if (cnt->conf.netcam_proxy) { + netcam_url_parse(&url, cnt->conf.netcam_proxy); + + if (!url.host) { +- motion_log(LOG_ERR, 0, "Invalid netcam_proxy (%s)", ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_proxy (%s)", + cnt->conf.netcam_proxy); + netcam_url_free(&url); + return -1; + } + + if (url.userpass) { +- motion_log(LOG_ERR, 0, "Username/password not allowed on a proxy URL"); ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Username/password" ++ " not allowed on a proxy URL"); + netcam_url_free(&url); + return -1; + } +@@ -2345,13 +2784,12 @@ int netcam_start(struct context *cnt) + netcam_url_free(&url); /* Finished with proxy */ + } + +- /* +- * Parse the URL from the configuration data +- */ ++ /* Parse the URL from the configuration data */ + netcam_url_parse(&url, cnt->conf.netcam_url); + + if (!url.host) { +- motion_log(LOG_ERR, 0, "Invalid netcam_url (%s)", cnt->conf.netcam_url); ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", ++ cnt->conf.netcam_url); + netcam_url_free(&url); + return -1; + } +@@ -2362,7 +2800,7 @@ int netcam_start(struct context *cnt) + netcam->connect_port = url.port; + } + +- /* Get HTTP Mode (1.0 default, 1.0 Keep-Alive, 1.1) flag from config ++ /* Get HTTP Mode (1.0 default, 1.0 Keep-Alive, 1.1) flag from config + * and report its stata for debug reasons. + * The flags in the conf structure is read only and cannot be + * unset if the Keep-Alive needs to be switched off (ie. netcam does +@@ -2370,43 +2808,64 @@ int netcam_start(struct context *cnt) + * in the context structures (cnt->...) only. + */ + +- if (!strcmp(cnt->conf.netcam_http,"keep_alive")) { ++ if (!strcmp(cnt->conf.netcam_keepalive, "force")) { + netcam->connect_http_10 = TRUE; + netcam->connect_http_11 = FALSE; + netcam->connect_keepalive = TRUE; +- } else if (!strcmp(cnt->conf.netcam_http,"1.0") || !strcmp(cnt->conf.netcam_http,"1.0")) { ++ } else if (!strcmp(cnt->conf.netcam_keepalive, "off")) { + netcam->connect_http_10 = TRUE; + netcam->connect_http_11 = FALSE; + netcam->connect_keepalive = FALSE; +- } else if (!strcmp(cnt->conf.netcam_http,"1.1")) { ++ } else if (!strcmp(cnt->conf.netcam_keepalive, "on")) { + netcam->connect_http_10 = FALSE; + netcam->connect_http_11 = TRUE; +- netcam->connect_keepalive = TRUE; /* HTTP 1.1 has keepalive by default */ ++ netcam->connect_keepalive = TRUE; /* HTTP 1.1 has keepalive by default. */ + } +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_INFO, 0, "netcam_start: Netcam_http parameter '%s' converts to flags: HTTP1.0:" +- "%s HTTP1.1: %s Keep-Alive %s.", cnt->conf.netcam_http, +- netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", +- netcam->connect_keepalive ? "ON":"OFF"); + +- /* Initialise the netcam socket to -1 to trigger a connection by the keep-alive logic */ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam_http parameter '%s'" ++ " converts to flags: HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", ++ cnt->conf.netcam_keepalive, ++ netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", ++ netcam->connect_keepalive ? "ON":"OFF"); ++ ++ /* Initialise the netcam socket to -1 to trigger a connection by the keep-alive logic. */ + netcam->sock = -1; + +- if ((url.service) && (!strcmp(url.service, "http")) ){ +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "netcam_start: now calling netcam_setup_html()"); ++ if ((url.service) && (!strcmp(url.service, "http"))) { ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" ++ " netcam_setup_html()"); ++ + retval = netcam_setup_html(netcam, &url); +- } else if ((url.service) && (!strcmp(url.service, "ftp")) ){ +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "netcam_start: now calling netcam_setup_ftp"); ++ } else if ((url.service) && (!strcmp(url.service, "ftp"))) { ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" ++ " netcam_setup_ftp"); ++ + retval = netcam_setup_ftp(netcam, &url); +- } else if ((url.service) && (!strcmp(url.service, "file")) ){ +- if (debug_level > CAMERA_INFO) +- motion_log(-1, 0, "netcam_start: now calling netcam_setup_file()"); ++ } else if ((url.service) && (!strcmp(url.service, "file"))) { ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" ++ " netcam_setup_file()"); ++ + retval = netcam_setup_file(netcam, &url); ++ } else if ((url.service) && (!strcmp(url.service, "mjpg"))) { ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" ++ " netcam_setup_mjpg()"); ++ ++ strcpy(url.service, "http"); /* Put back a real URL service. */ ++ retval = netcam_setup_mjpg(netcam, &url); ++ } else if ((url.service) && (!strcmp(url.service, "mjpeg"))) { ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" ++ " netcam_setup_mjpeg()"); ++ ++ strcpy(url.service, "http"); /* Put back a real URL service. */ ++ retval = netcam_setup_rtsp(netcam, &url); ++ } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" ++ " netcam_setup_rtsp()"); ++ ++ retval = netcam_setup_rtsp(netcam, &url); + } else { +- motion_log(LOG_ERR, 0, "Invalid netcam service '%s' - " +- "must be http or ftp", url.service); ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam service '%s' - " ++ "must be http, ftp, mjpg, mjpeg or file.", url.service); + netcam_url_free(&url); + return -1; + } +@@ -2422,41 +2881,48 @@ int netcam_start(struct context *cnt) + * these to set the required image buffer(s) in our netcam_struct. + */ + if ((retval = netcam->get_image(netcam)) != 0) { +- motion_log(LOG_ERR, 0, "Failed trying to read first image - retval:%d", retval ); ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Failed trying to " ++ "read first image - retval:%d", retval); ++ netcam->rtsp->status = RTSP_NOTCONNECTED; + return -1; + } + +- /* +- * If an error occurs in the JPEG decompression which follows this, +- * jpeglib will return to the code within this 'if'. If such an error +- * occurs during startup, we will just abandon this attempt. +- */ +- if (setjmp(netcam->setjmp_buffer)) { +- motion_log(LOG_ERR, 0, "libjpeg decompression failure " +- "on first frame - giving up!"); +- return -1; +- } + +- netcam->netcam_tolerant_check = cnt->conf.netcam_tolerant_check; +- netcam->JFIF_marker = 0; +- netcam_get_dimensions(netcam); ++ if (netcam->caps.streaming != NCS_RTSP) { + +- /* Motion currently requires that image height and width is a +- * multiple of 16. So we check for this. +- */ ++ /* ++ * If an error occurs in the JPEG decompression which follows this, ++ * jpeglib will return to the code within this 'if'. If such an error ++ * occurs during startup, we will just abandon this attempt. ++ */ ++ if (setjmp(netcam->setjmp_buffer)) { ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: libjpeg decompression failure " ++ "on first frame - giving up!"); ++ return -1; ++ } ++ ++ netcam->netcam_tolerant_check = cnt->conf.netcam_tolerant_check; ++ netcam->JFIF_marker = 0; ++ netcam_get_dimensions(netcam); ++ } ++ /* ++ * Motion currently requires that image height and width is a ++ * multiple of 16. So we check for this. ++ */ + if (netcam->width % 16) { +- motion_log(LOG_ERR, 0, "netcam image width (%d) is not modulo 16", +- netcam->width); +- return -1; ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" ++ " is not modulo 16", netcam->width); ++ return -3; + } + + if (netcam->height % 16) { +- motion_log(LOG_ERR, 0, "netcam image height (%d) is not modulo 16", +- netcam->height); +- return -1; ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" ++ " is not modulo 16", netcam->height); ++ return -3; + } ++ + +- /* Fill in camera details into context structure */ ++ /* Fill in camera details into context structure. */ + cnt->imgs.width = netcam->width; + cnt->imgs.height = netcam->height; + cnt->imgs.size = (netcam->width * netcam->height * 3) / 2; +@@ -2475,7 +2941,8 @@ int netcam_start(struct context *cnt) + + if ((retval = pthread_create(&netcam->thread_id, &handler_attribute, + &netcam_handler_loop, netcam)) < 0) { +- motion_log(LOG_ERR, 1, "Starting camera handler thread [%d]", netcam->threadnr); ++ MOTION_LOG(ALR, TYPE_NETCAM, SHOW_ERRNO, "%s: Starting camera" ++ " handler thread [%d]", netcam->threadnr); + return -1; + } + +--- motion-3.2.12.orig/netcam.h ++++ motion-3.2.12/netcam.h +@@ -102,6 +102,16 @@ typedef struct file_context { + time_t last_st_mtime; /* time this image was modified */ + } tfile_context; + ++#define NCS_UNSUPPORTED 0 /* streaming is not supported */ ++#define NCS_MULTIPART 1 /* streaming is done via multipart */ ++#define NCS_BLOCK 2 /* streaming is done via MJPG-block */ ++#define NCS_RTSP 3 /* streaming is done via RTSP */ ++ ++ ++#define RTSP_NOTCONNECTED 0 /* The camera has never connected */ ++#define RTSP_CONNECTED 1 /* The camera is currently connected */ ++#define RTSP_RECONNECTING 2 /* The camera is trying to reconnect*/ ++ + /* + * struct netcam_context contains all the structures and other data + * for an individual netcam. +@@ -154,13 +164,15 @@ typedef struct netcam_context { + specified as something else by + the user */ + +- int connect_http_10; /* set to TRUE if HTTP 1.0 connection */ ++ int connect_http_10; /* set to TRUE if HTTP 1.0 connection ++ (netcam_keepalive off) */ + +- int connect_http_11; /* set to TRUE if HTTP 1.1 connection */ ++ int connect_http_11; /* set to TRUE if HTTP 1.1 connection ++ (netcam_keepalive on) */ + +- int connect_keepalive; /* set to TRUE if connection maintained +- after a request, otherwise FALSE to +- close down the socket each time */ ++ int connect_keepalive; /* set to TRUE if connection maintained after ++ a request, otherwise FALSE to close down ++ the socket each time (netcam_keealive force) */ + + int keepalive_thisconn; /* set to TRUE if cam has sent 'Keep-Alive' in this connection */ + +@@ -193,6 +205,9 @@ typedef struct netcam_context { + struct file_context *file; /* this structure contains the + context for FILE connection */ + ++ struct rtsp_context *rtsp; /* this structure contains the ++ context for RTSP connection */ ++ + int (*get_image)(netcam_context_ptr); + /* Function to fetch the image from + the netcam. It is initialised in +@@ -202,7 +217,7 @@ typedef struct netcam_context { + + + struct netcam_caps { /* netcam capabilities: */ +- unsigned char streaming; /* 1 - supported */ ++ unsigned char streaming; /* See the NCS_* defines */ + unsigned char content_length; /* 0 - unsupported */ + } caps; + +@@ -229,6 +244,9 @@ typedef struct netcam_context { + int imgcnt_last; /* remember last count to check if a new + image arrived */ + ++ int warning_count; /* simple count of number of warnings ++ since last good frame was received */ ++ + int error_count; /* simple count of number of errors since + last good frame was received */ + +@@ -251,8 +269,29 @@ typedef struct netcam_context { + occurred during decompression*/ + } netcam_context; + ++#define MJPG_MH_MAGIC "MJPG" ++#define MJPG_MH_MAGIC_SIZE 4 + + /* ++ * MJPG Chunk header for MJPG streaming. ++ * Little-endian data is read from the network. ++ */ ++typedef struct { ++ char mh_magic[MJPG_MH_MAGIC_SIZE]; /* must contain the string MJP ++ not null-terminated. */ ++ unsigned int mh_framesize; /* Total size of the current ++ frame in bytes (~45kb on WVC200) */ ++ unsigned short mh_framewidth; /* Frame width in pixels */ ++ unsigned short mh_frameheight; /* Frame height in pixels */ ++ unsigned int mh_frameoffset; /* Offset of this chunk relative ++ to the beginning of frame. */ ++ unsigned short mh_chunksize; /* The size of the chunk data ++ following this header. */ ++ char mh_reserved[30]; /* Unknown data, seems to be ++ constant between all headers */ ++} mjpg_header; ++ ++/* + * Declare prototypes for our external entry points + */ + /* Within netcam_jpeg.c */ +@@ -263,5 +302,6 @@ int netcam_start (struct context *); + int netcam_next (struct context *, unsigned char *); + void netcam_cleanup (struct netcam_context *, int); + ssize_t netcam_recv(netcam_context_ptr, void *, size_t); ++void netcam_url_free(struct url_t *parse_url); + + #endif +--- motion-3.2.12.orig/netcam_ftp.c ++++ motion-3.2.12/netcam_ftp.c +@@ -1,56 +1,53 @@ +-/** +-* Much of the FTP code was inspired by the nanoftp.c module from +-* libxml2 (Copyright Daniel Veillard, 2003). The routines have been +-* modified to fit the needs of the Motion project. +-* +-* Copyright 2005, William M. Brack +-* This software is distributed under the GNU Public license Version 2. +-* See also the file 'COPYING'. +-* +-*/ +-#include "motion.h" /* needs to come first, because _GNU_SOURCE_ set there */ ++/* ++ * Much of the FTP code was inspired by the nanoftp.c module from ++ * libxml2 (Copyright Daniel Veillard, 2003). The routines have been ++ * modified to fit the needs of the Motion project. ++ * ++ * Copyright 2005, William M. Brack ++ * This software is distributed under the GNU Public license Version 2. ++ * See also the file 'COPYING'. ++ * ++ */ ++#include "motion.h" /* Needs to come first, because _GNU_SOURCE_ set there. */ + + #include + #include +-#include +-#include + #include +- + #include "netcam_ftp.h" + + /** + * ftp_new_context + * +-* Create a new FTP context structure ++* Create a new FTP context structure. + * + * Parameters + * + * None + * +-* Returns: Pointer to the newly-created structure, NULL if error ++* Returns: Pointer to the newly-created structure, NULL if error. + * + */ + ftp_context_pointer ftp_new_context(void) + { + ftp_context_pointer ret; + +- /* note that mymalloc will exit on any problem */ ++ /* Note that mymalloc will exit on any problem. */ + ret = mymalloc(sizeof(ftp_context)); + + memset(ret, 0, sizeof(ftp_context)); +- ret->control_file_desc = -1; /* no control connection yet */ +- ret->data_file_desc = -1; /* no data connection yet */ ++ ret->control_file_desc = -1; /* No control connection yet. */ ++ ret->data_file_desc = -1; /* No data connection yet. */ + return ret; + } + + /** + * ftp_free_context + * +-* Free the resources allocated for this context ++* Free the resources allocated for this context. + * + * Parameters + * +-* ctxt Pointer to the ftp_context structure ++* ctxt Pointer to the ftp_context structure. + * + * Returns: Nothing + * +@@ -82,15 +79,16 @@ void ftp_free_context(ftp_context_pointe + * + * Parameters: + * +-* buf the buffer containing the response +-* len the buffer length ++* buf the buffer containing the response. ++* len the buffer length. + * + * Returns: + * 0 for errors + * +XXX for last line of response + * -XXX for response to be continued + */ +-static int ftp_parse_response(char *buf, int len) { ++static int ftp_parse_response(char *buf, int len) ++{ + int val = 0; + + if (len < 3) +@@ -126,19 +124,20 @@ static int ftp_parse_response(char *buf, + /** + * ftp_get_more + * +-* Read more information from the FTP control connection ++* Read more information from the FTP control connection. + * + * Parameters: + * +-* ctxt pointer to an FTP context ++* ctxt pointer to an FTP context. + * + * Returns the number of bytes read, < 0 indicates an error + */ +-static int ftp_get_more(ftp_context_pointer ctxt) { ++static int ftp_get_more(ftp_context_pointer ctxt) ++{ + int len; + int size; + +- /* Validate that our context structure is valid */ ++ /* Validate that our context structure is valid. */ + if ((ctxt == NULL) || (ctxt->control_file_desc < 0)) + return -1; + +@@ -151,29 +150,24 @@ static int ftp_get_more(ftp_context_poin + if (ctxt->control_buffer_index > ctxt->control_buffer_used) + return -1; + +- /* +- * First pack the control buffer +- */ ++ /* First pack the control buffer. */ + if (ctxt->control_buffer_index > 0) { + memmove(&ctxt->control_buffer[0], +- &ctxt->control_buffer[ctxt->control_buffer_index], +- ctxt->control_buffer_used - ctxt->control_buffer_index); +- ++ &ctxt->control_buffer[ctxt->control_buffer_index], ++ ctxt->control_buffer_used - ctxt->control_buffer_index); + ctxt->control_buffer_used -= ctxt->control_buffer_index; + ctxt->control_buffer_index = 0; + } ++ + size = FTP_BUF_SIZE - ctxt->control_buffer_used; + +- if (size == 0) ++ if (size == 0) + return 0; +- + +- /* +- * Read the amount left on the control connection +- */ ++ /* Read the amount left on the control connection. */ + if ((len = recv(ctxt->control_file_desc, +- &ctxt->control_buffer[ctxt->control_buffer_index], size, 0)) < 0) { +- motion_log(LOG_ERR, 1, "recv failed in ftp_get_more"); ++ &ctxt->control_buffer[ctxt->control_buffer_index], size, 0)) < 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: recv failed in ftp_get_more"); + close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; + return -1; +@@ -196,7 +190,8 @@ static int ftp_get_more(ftp_context_poin + * + * Returns the code number + */ +-static int ftp_get_response(ftp_context_pointer ctxt) { ++static int ftp_get_response(ftp_context_pointer ctxt) ++{ + char *ptr, *end; + int len; + int res = -1, cur = -1; +@@ -206,17 +201,19 @@ static int ftp_get_response(ftp_context_ + + get_more: + /* +- * Assumes everything up to control_buffer[control_buffer_index] has been read +- * and analyzed. +- */ ++ * Assumes everything up to control_buffer[control_buffer_index] ++ * has been read and analyzed. ++ */ + len = ftp_get_more(ctxt); + +- if (len < 0) ++ if (len < 0) + return -1; +- +- if ((ctxt->control_buffer_used == 0) && (len == 0)) ++ ++ ++ if ((ctxt->control_buffer_used == 0) && (len == 0)) + return -1; +- ++ ++ + ptr = &ctxt->control_buffer[ctxt->control_buffer_index]; + end = &ctxt->control_buffer[ctxt->control_buffer_used]; + +@@ -224,23 +221,22 @@ static int ftp_get_response(ftp_context_ + cur = ftp_parse_response(ptr, end - ptr); + if (cur > 0) { + /* +- * Successfully scanned the control code, skip +- * till the end of the line, but keep the index to be +- * able to analyze the result if needed. +- */ ++ * Successfully scanned the control code, skip ++ * till the end of the line, but keep the index to be ++ * able to analyze the result if needed. ++ */ + res = cur; + ptr += 3; + ctxt->control_buffer_answer = ptr - ctxt->control_buffer; +- +- while ((ptr < end) && (*ptr != '\n')) ++ while ((ptr < end) && (*ptr != '\n')) + ptr++; +- +- if (*ptr == '\n') ++ ++ if (*ptr == '\n') + ptr++; +- +- if (*ptr == '\r') ++ ++ if (*ptr == '\r') + ptr++; +- ++ + break; + } + +@@ -252,7 +248,7 @@ static int ftp_get_response(ftp_context_ + goto get_more; + } + +- if (*ptr != '\r') ++ if (*ptr != '\r') + ptr++; + } + +@@ -265,10 +261,11 @@ static int ftp_get_response(ftp_context_ + } + + /** +-* Send the user authentication ++* ftp_send_user ++* Sends the user authentication. + */ +- +-static int ftp_send_user(ftp_context_pointer ctxt) { ++static int ftp_send_user(ftp_context_pointer ctxt) ++{ + char buf[200]; + int len; + int res; +@@ -281,20 +278,20 @@ static int ftp_send_user(ftp_context_poi + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); + res = send(ctxt->control_file_desc, buf, len, 0); +- ++ + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_send_user"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_send_user"); + return res; + } +- + return 0; + } + + /** +-* Send the password authentication ++* ftp_send_passwd ++* Sends the password authentication. + */ +- +-static int ftp_send_passwd(ftp_context_pointer ctxt) { ++static int ftp_send_passwd(ftp_context_pointer ctxt) ++{ + char buf[200]; + int len; + int res; +@@ -303,13 +300,13 @@ static int ftp_send_passwd(ftp_context_p + snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); + else + snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); +- ++ + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); + res = send(ctxt->control_file_desc, buf, len, 0); +- ++ + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_send_passwd"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_send_passwd"); + return res; + } + +@@ -327,9 +324,8 @@ static int ftp_send_passwd(ftp_context_p + * + * Returns -1 in case of error, 0 otherwise + */ +- +- +-static int ftp_quit(ftp_context_pointer ctxt) { ++static int ftp_quit(ftp_context_pointer ctxt) ++{ + char buf[200]; + int len, res; + +@@ -341,7 +337,7 @@ static int ftp_quit(ftp_context_pointer + res = send(ctxt->control_file_desc, buf, len, 0); + + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_quit"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_quit"); + return res; + } + +@@ -351,16 +347,16 @@ static int ftp_quit(ftp_context_pointer + /** + * ftp_connect + * +-* Tries to open a control connection ++* Tries to open a control connection. + * + * Parameters: + * + * ctxt an FTP context + * +-* Returns -1 in case of error, 0 otherwise ++* Returns -1 in case of error, 0 otherwise. + */ +- +-int ftp_connect(netcam_context_ptr netcam) { ++int ftp_connect(netcam_context_ptr netcam) ++{ + ftp_context_pointer ctxt; + struct hostent *hp; + int port; +@@ -378,11 +374,9 @@ int ftp_connect(netcam_context_ptr netca + if (netcam->connect_host == NULL) + return -1; + +- /* +- * do the blocking DNS query. +- */ ++ /* Do the blocking DNS query. */ + port = netcam->connect_port; +- ++ + if (port == 0) + port = 21; + +@@ -391,48 +385,39 @@ int ftp_connect(netcam_context_ptr netca + hp = gethostbyname (netcam->connect_host); + + if (hp == NULL) { +- motion_log(LOG_ERR, 1, "gethostbyname failed in ftp_connect"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gethostbyname failed in ftp_connect"); + return -1; + } + + if ((unsigned int) hp->h_length > +- sizeof(((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr)) { +- motion_log(LOG_ERR, 1, "gethostbyname address mismatch " +- "in ftp_connect"); ++ sizeof(((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr)) { ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gethostbyname address mismatch " ++ "in ftp_connect"); + return -1; + } + +- /* +- * Prepare the socket +- */ ++ /* Prepare the socket */ + ((struct sockaddr_in *)&ctxt->ftp_address)->sin_family = AF_INET; +- memcpy (&((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr, +- hp->h_addr_list[0], hp->h_length); +- +- ((struct sockaddr_in *)&ctxt->ftp_address)->sin_port = +- (u_short)htons ((unsigned short)port); ++ memcpy (&((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr, hp->h_addr_list[0], hp->h_length); ++ ((struct sockaddr_in *)&ctxt->ftp_address)->sin_port = (u_short)htons ((unsigned short)port); + ctxt->control_file_desc = socket (AF_INET, SOCK_STREAM, 0); + addrlen = sizeof (struct sockaddr_in); + + if (ctxt->control_file_desc < 0) { +- motion_log(LOG_ERR, 1, "socket failed"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: socket failed"); + return -1; + } + +- /* +- * Do the connect. +- */ ++ /* Do the connect. */ + if (connect(ctxt->control_file_desc, (struct sockaddr *) &ctxt->ftp_address, + addrlen) < 0) { +- motion_log(LOG_ERR, 1, "Failed to create a connection"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: Failed to create a connection"); + close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; + return -1; + } + +- /* +- * Wait for the HELLO from the server. +- */ ++ /* Wait for the HELLO from the server. */ + res = ftp_get_response(ctxt); + + if (res != 2) { +@@ -441,10 +426,9 @@ int ftp_connect(netcam_context_ptr netca + return -1; + } + +- /* +- * Do the authentication +- */ ++ /* Do the authentication */ + res = ftp_send_user(ctxt); ++ + if (res < 0) { + close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; +@@ -469,7 +453,7 @@ int ftp_connect(netcam_context_ptr netca + } + + res = ftp_send_passwd(ctxt); +- ++ + if (res < 0) { + close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; +@@ -477,20 +461,20 @@ int ftp_connect(netcam_context_ptr netca + } + + res = ftp_get_response(ctxt); +- + switch (res) { + case 2: + break; + case 3: +- motion_log(LOG_ERR, 0, "FTP server asking for ACCT on anonymous"); ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: FTP server asking for ACCT on anonymous"); + case 1: + case 4: + case 5: + case -1: + default: +- close(ctxt->control_file_desc); ctxt->control_file_desc = -1; ++ close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; +- return -1; ++ ctxt->control_file_desc = -1; ++ return-1; + } + + return 0; +@@ -503,12 +487,12 @@ int ftp_connect(netcam_context_ptr netca + * + * Parameters: + * +-* ctxt pointer to an FTP context ++* ctxt pointer to an FTP context. + * + * Returns -1 in case of error, 0 otherwise + */ +- +-static int ftp_get_connection(ftp_context_pointer ctxt) { ++static int ftp_get_connection(ftp_context_pointer ctxt) ++{ + char buf[200], *cur; + int len, i; + int res; +@@ -519,16 +503,17 @@ static int ftp_get_connection(ftp_contex + unsigned int data_address_length; + + if (ctxt == NULL) +- return -1; ++ return -1; + +- /* set up a socket for our data address */ ++ /* Set up a socket for our data address. */ + if (ctxt->data_file_desc != -1) +- close(ctxt->data_file_desc); ++ close(ctxt->data_file_desc); ++ + memset (&data_address, 0, sizeof(data_address)); + ctxt->data_file_desc = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); +- ++ + if (ctxt->data_file_desc < 0) { +- motion_log(LOG_ERR, 1, "socket failed"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: socket failed"); + return -1; + } + +@@ -536,7 +521,7 @@ static int ftp_get_connection(ftp_contex + + if (setsockopt(ctxt->data_file_desc, SOL_SOCKET, SO_REUSEADDR, + (char *)&on, sizeof(on)) < 0) { +- motion_log(LOG_ERR, 1, "setting socket option SO_REUSEADDR"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: setting socket option SO_REUSEADDR"); + return -1; + } + +@@ -544,19 +529,18 @@ static int ftp_get_connection(ftp_contex + data_address_length = sizeof (struct sockaddr_in); + + if (ctxt->passive) { +- /* send PASV command over control channel */ ++ /* Send PASV command over control channel. */ + snprintf (buf, sizeof(buf), "PASV\r\n"); + len = strlen (buf); + res = send(ctxt->control_file_desc, buf, len, 0); +- ++ + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_get_connection"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_connection"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return res; + } +- +- /* check server's answer */ ++ /* Check server's answer */ + res = ftp_get_response(ctxt); + + if (res != 2) { +@@ -565,93 +549,89 @@ static int ftp_get_connection(ftp_contex + ctxt->data_file_desc = -1; + return -1; + } else { +- /* +- * retry with an active connection +- */ ++ /* Retry with an active connection. */ + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + ctxt->passive = 0; + } + } +- /* parse the IP address and port supplied by the server */ ++ /* Parse the IP address and port supplied by the server. */ + cur = &ctxt->control_buffer[ctxt->control_buffer_answer]; ++ + while (((*cur < '0') || (*cur > '9')) && *cur != '\0') + cur++; + +- if (sscanf (cur, "%u,%u,%u,%u,%u,%u", &temp[0], &temp[1], &temp[2], ++ if (sscanf(cur, "%u,%u,%u,%u,%u,%u", &temp[0], &temp[1], &temp[2], + &temp[3], &temp[4], &temp[5]) != 6) { +- motion_log(LOG_ERR, 0, "Invalid answer to PASV"); +- ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Invalid answer to PASV"); + if (ctxt->data_file_desc != -1) { + close (ctxt->data_file_desc); + ctxt->data_file_desc = -1; + } +- + return -1; + } + +- for (i=0; i<6; i++) ++ for (i = 0; i < 6; i++) + ad[i] = (unsigned char) (temp[i] & 0xff) ; + + memcpy (&((struct sockaddr_in *)&data_address)->sin_addr, &ad[0], 4); + memcpy (&((struct sockaddr_in *)&data_address)->sin_port, &ad[4], 2); + +- /* Now try to connect to the data port */ ++ /* Now try to connect to the data port. */ + if (connect(ctxt->data_file_desc, (struct sockaddr *) &data_address, + data_address_length) < 0) { +- motion_log(LOG_ERR, 1, "Failed to create a data connection"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: Failed to create a data connection"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return -1; + } +- + } else { + /* +- * We want to bind to a port to receive the data. To do this, +- * we need the address of our host. One easy way to get it is +- * to get the info from the control connection that we have +- * with the remote server +- */ ++ * We want to bind to a port to receive the data. To do this, ++ * we need the address of our host. One easy way to get it is ++ * to get the info from the control connection that we have ++ * with the remote server. ++ */ + getsockname(ctxt->control_file_desc, (struct sockaddr *)&data_address, + &data_address_length); + ((struct sockaddr_in *)&data_address)->sin_port = 0; + +- /* bind to the socket - should give us a unique port */ ++ /* Bind to the socket - should give us a unique port. */ + if (bind(ctxt->data_file_desc, (struct sockaddr *) &data_address, + data_address_length) < 0) { +- motion_log(LOG_ERR, 1, "bind failed"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: bind failed"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return -1; + } + +- /* we get the port number by reading back in the sockaddr */ ++ /* We get the port number by reading back in the sockaddr. */ + getsockname(ctxt->data_file_desc, (struct sockaddr *)&data_address, + &data_address_length); + +- /* set up a 'listen' on the port to get the server's connection */ ++ /* Set up a 'listen' on the port to get the server's connection. */ + if (listen(ctxt->data_file_desc, 1) < 0) { +- motion_log(LOG_ERR, 1, "listen failed"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: listen failed"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return -1; + } + +- /* now generate the PORT command */ ++ /* Now generate the PORT command. */ + adp = (unsigned char *) &((struct sockaddr_in *)&data_address)->sin_addr; + portp = (unsigned char *) &((struct sockaddr_in *)&data_address)->sin_port; +- snprintf (buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", +- adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, +- portp[0] & 0xff, portp[1] & 0xff); ++ snprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", ++ adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, ++ portp[0] & 0xff, portp[1] & 0xff); + + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); + +- /* send the PORT command to the server */ ++ /* Send the PORT command to the server. */ + res = send(ctxt->control_file_desc, buf, len, 0); + + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_get_connection"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_connection"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return res; +@@ -672,16 +652,16 @@ static int ftp_get_connection(ftp_contex + /** + * ftp_close_connection + * +-* Close the data connection from the server ++* Close the data connection from the server. + * + * Parameters: + * +-* ctxt Pointer to an FTP context ++* ctxt Pointer to an FTP context. + * + * Returns -1 in case of error, 0 otherwise + */ +- +-static int ftp_close_connection(ftp_context_pointer ctxt) { ++static int ftp_close_connection(ftp_context_pointer ctxt) ++{ + int res; + fd_set rfd, efd; + struct timeval tv; +@@ -692,7 +672,7 @@ static int ftp_close_connection(ftp_cont + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + +- /* Check for data on the control channel */ ++ /* Check for data on the control channel. */ + tv.tv_sec = 15; + tv.tv_usec = 0; + FD_ZERO(&rfd); +@@ -707,13 +687,13 @@ static int ftp_close_connection(ftp_cont + return -1; + } + +- if (res == 0) { /* timeout */ ++ if (res == 0) { /* Timeout */ + close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; +- } else { /* read the response */ ++ } else { /* Read the response */ + res = ftp_get_response(ctxt); + +- if (res != 2) { /* should be positive completion (2) */ ++ if (res != 2) { /* Should be positive completion (2) */ + close(ctxt->control_file_desc); + ctxt->control_file_desc = -1; + return -1; +@@ -734,9 +714,8 @@ static int ftp_close_connection(ftp_cont + * + * Returns the socket for the data connection, or <0 in case of error + */ +- +- +-int ftp_get_socket(ftp_context_pointer ctxt) { ++int ftp_get_socket(ftp_context_pointer ctxt) ++{ + char buf[300]; + int res, len; + int acfd; +@@ -744,28 +723,28 @@ int ftp_get_socket(ftp_context_pointer c + if ((ctxt == NULL) || (ctxt->path == NULL)) + return -1; + +- /* Set up the data connection */ ++ /* Set up the data connection. */ + ctxt->data_file_desc = ftp_get_connection(ctxt); + + if (ctxt->data_file_desc == -1) + return -1; + +- /* generate a "retrieve" command for the file */ ++ /* Generate a "retrieve" command for the file. */ + snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path); + buf[sizeof(buf) - 1] = 0; + len = strlen(buf); + +- /* send it to the server */ ++ /* Send it to the server. */ + res = send(ctxt->control_file_desc, buf, len, 0); + + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_get_socket"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_socket"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return res; + } + +- /* check the answer */ ++ /* Check the answer */ + res = ftp_get_response(ctxt); + + if (res != 1) { +@@ -775,16 +754,16 @@ int ftp_get_socket(ftp_context_pointer c + } + + /* +- * if not a passive connection, need to do an accept to get the +- * connection from the server +- */ ++ * If not a passive connection, need to do an accept to get the ++ * connection from the server. ++ */ + if (!ctxt->passive) { + struct sockaddr_in data_address; + unsigned int data_address_length = sizeof(struct sockaddr_in); + + if ((acfd = accept(ctxt->data_file_desc, (struct sockaddr *)&data_address, + &data_address_length)) < 0) { +- motion_log(LOG_ERR, 1, "accept in ftp_get_socket"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: accept in ftp_get_socket"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return -1; +@@ -799,28 +778,29 @@ int ftp_get_socket(ftp_context_pointer c + /** + * ftp_send_type + * +-* Send a TYPE (either 'I' or 'A') command to the server ++* Send a TYPE (either 'I' or 'A') command to the server. + * + * Parameters + * + * ctxt pointer to the ftp_context + * type ascii character ('I' or 'A') + * +-* Returns 0 for success, negative error code for failure ++* Returns 0 for success, negative error code for failure. + * + */ +-int ftp_send_type(ftp_context_pointer ctxt, char type) { +- char buf[100], utype; ++int ftp_send_type(ftp_context_pointer ctxt, char type) ++{ ++ char buf[100]; + int len, res; + +- utype = toupper(type); +- /* Assure transfer will be in "image" mode */ ++ toupper(type); ++ /* Assure transfer will be in "image" mode. */ + snprintf(buf, sizeof(buf), "TYPE I\r\n"); + len = strlen(buf); + res = send(ctxt->control_file_desc, buf, len, 0); + + if (res < 0) { +- motion_log(LOG_ERR, 1, "send failed in ftp_get_socket"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_socket"); + close(ctxt->data_file_desc); + ctxt->data_file_desc = -1; + return res; +@@ -852,7 +832,8 @@ int ftp_send_type(ftp_context_pointer ct + * 0 is an indication of an end of connection. + * -1 indicates a parameter error. + */ +-int ftp_read(ftp_context_pointer ctxt, void *dest, int len) { ++int ftp_read(ftp_context_pointer ctxt, void *dest, int len) ++{ + if (ctxt == NULL) + return -1; + +@@ -869,7 +850,7 @@ int ftp_read(ftp_context_pointer ctxt, v + + if (len <= 0) { + if (len < 0) +- motion_log(LOG_ERR, 1, "recv failed in ftp_read"); ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: recv failed in ftp_read"); + ftp_close_connection(ctxt); + } + +@@ -880,15 +861,16 @@ int ftp_read(ftp_context_pointer ctxt, v + /** + * ftp_close + * +-* Close the connection and both control and transport ++* Close the connection and both control and transport. + * + * Parameters: + * +-* ctxt Pointer to an FTP context ++* ctxt Pointer to an FTP context. + * +-* Returns -1 in case of error, 0 otherwise ++* Returns -1 in case of error, 0 otherwise. + */ +-int ftp_close(ftp_context_pointer ctxt) { ++int ftp_close(ftp_context_pointer ctxt) ++{ + if (ctxt == NULL) + return -1; + +@@ -904,6 +886,5 @@ int ftp_close(ftp_context_pointer ctxt) + } + + ftp_free_context(ctxt); +- + return 0; + } +--- motion-3.2.12.orig/netcam_ftp.h ++++ motion-3.2.12/netcam_ftp.h +@@ -1,5 +1,4 @@ +- +-/** ++/* + * Much of the FTP routines was inspired by the nanoftp.c module from + * libxml2 (Copyright Daniel Veillard, 2003). The routines have been + * modified to fit the needs of the Motion project. +@@ -7,7 +6,7 @@ + * Copyright 2005, William M. Brack + * This software is distributed under the GNU Public license Version 2. + * See also the file 'COPYING'. +- * ++ * + */ + #ifndef _INCLUDE_NETCAM_FTP_H + #define _INCLUDE_NETCAM_FTP_H +--- motion-3.2.12.orig/netcam_jpeg.c ++++ motion-3.2.12/netcam_jpeg.c +@@ -13,14 +13,13 @@ + */ + + #include "rotate.h" /* already includes motion.h */ +- + #include + #include + + /* + * netcam_source_mgr is a locally-defined structure to contain elements + * which are not present in the standard libjpeg (the element 'pub' is a +- * pointer to the standard information) ++ * pointer to the standard information). + */ + typedef struct { + struct jpeg_source_mgr pub; +@@ -48,13 +47,11 @@ static void netcam_error_exit(j_comm + + static void netcam_init_source(j_decompress_ptr cinfo) + { +- /* +- * Get our "private" structure from the libjpeg structure +- */ ++ /* Get our "private" structure from the libjpeg structure. */ + netcam_src_ptr src = (netcam_src_ptr) cinfo->src; + /* + * Set the 'start_of_file' flag in our private structure +- * (used by my_fill_input_buffer) ++ * (used by my_fill_input_buffer). + */ + src->start_of_file = TRUE; + } +@@ -84,8 +81,7 @@ static boolean netcam_fill_input_buffer( + src->buffer = (JOCTET *) src->data; + } else { + /* Insert a fake EOI marker - as per jpeglib recommendation */ +- if (debug_level > CAMERA_VERBOSE) +- motion_log(LOG_INFO, 0, "%s: **fake EOI inserted**", __FUNCTION__); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: **fake EOI inserted**"); + src->buffer[0] = (JOCTET) 0xFF; + src->buffer[1] = (JOCTET) JPEG_EOI; /* 0xD9 */ + nbytes = 2; +@@ -123,23 +119,23 @@ static void netcam_term_source(j_decompr + * JPEG library decompression routine. + * + * Parameters: +- * cinfo pointer to the jpeg decompression object +- * data pointer to the image data received from a netcam +- * length total size of the image ++ * cinfo pointer to the jpeg decompression object. ++ * data pointer to the image data received from a netcam. ++ * length total size of the image. + * + * Returns: Nothing +- * ++ * + */ + static void netcam_memory_src(j_decompress_ptr cinfo, char *data, int length) + { + netcam_src_ptr src; + +- if (cinfo->src == NULL) { ++ if (cinfo->src == NULL) + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) + ((j_common_ptr) cinfo, JPOOL_PERMANENT, + sizeof (netcam_source_mgr)); +- } ++ + + src = (netcam_src_ptr)cinfo->src; + src->data = data; +@@ -162,28 +158,27 @@ static void netcam_memory_src(j_decompre + * + * Parameters + * +- * cinfo pointer to the decompression control structure ++ * cinfo pointer to the decompression control structure. + * + * Returns: does an (ugly) longjmp to get back to netcam_jpeg +- * code ++ * code. + * + */ + static void netcam_error_exit(j_common_ptr cinfo) + { +- /* fetch our pre-stored pointer to the netcam context */ ++ /* Fetch our pre-stored pointer to the netcam context. */ + netcam_context_ptr netcam = cinfo->client_data; +- /* output the message associated with the error */ ++ /* Output the message associated with the error. */ + (*cinfo->err->output_message)(cinfo); +- /* set flag to show the decompression had errors */ ++ /* Set flag to show the decompression had errors. */ + netcam->jpeg_error |= 1; +- /* need to "cleanup" the aborted decompression */ ++ /* Need to "cleanup" the aborted decompression. */ + jpeg_destroy (cinfo); + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(LOG_ERR, 0, "%s: netcam->jpeg_error %d", +- __FUNCTION__, netcam->jpeg_error); +- +- /* jump back to wherever we started */ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->jpeg_error %d", ++ netcam->jpeg_error); ++ ++ /* Jump back to wherever we started. */ + longjmp(netcam->setjmp_buffer, 1); + } + +@@ -196,7 +191,7 @@ static void netcam_error_exit(j_common_p + * + * Parameters + * +- * cinfo pointer to the decompression control structure ++ * cinfo pointer to the decompression control structure. + * + * Returns Nothing + * +@@ -204,8 +199,8 @@ static void netcam_error_exit(j_common_p + static void netcam_output_message(j_common_ptr cinfo) + { + char buffer[JMSG_LENGTH_MAX]; +- +- /* fetch our pre-stored pointer to the netcam context */ ++ ++ /* Fetch our pre-stored pointer to the netcam context. */ + netcam_context_ptr netcam = cinfo->client_data; + + /* +@@ -213,30 +208,23 @@ static void netcam_output_message(j_comm + * that the jpeg data produced by the camera caused warning + * messages from libjpeg (JWRN_EXTRANEOUS_DATA). The following + * code is to assure that specific warning is ignored. +- * ++ * + * NOTE: It's likely that we will discover other error message + * codes which we want to ignore. In that case, we should have + * some sort of table-lookup to decide which messages we really + * care about. + */ +- if ((cinfo->err->msg_code != JWRN_EXTRANEOUS_DATA) && +- (cinfo->err->msg_code == JWRN_NOT_SEQUENTIAL) && (!netcam->netcam_tolerant_check)) ++ if ((cinfo->err->msg_code != JWRN_EXTRANEOUS_DATA) && ++ (cinfo->err->msg_code == JWRN_NOT_SEQUENTIAL) && (!netcam->netcam_tolerant_check)) + netcam->jpeg_error |= 2; /* Set flag to show problem */ ++ + /* +- * We only display and log errors when debug_level +- * is non-zero. The reasoning here is that these kinds +- * of errors are only produced when the input data is +- * wrong, and that indicates a network problem rather +- * than a problem with the content. ++ * Format the message according to library standards. ++ * Write it out to the motion log. + */ +- if (debug_level > CAMERA_VERBOSE) { +- /* +- * Format the message according to library standards. +- * Write it out to the motion log. +- */ +- (*cinfo->err->format_message)(cinfo, buffer); +- motion_log(LOG_ERR, 0, "%s: %s", __FUNCTION__, buffer); +- } ++ (*cinfo->err->format_message)(cinfo, buffer); ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: %s", buffer); ++ + } + + /** +@@ -246,10 +234,10 @@ static void netcam_output_message(j_comm + * decompression. + * + * Parameters: +- * netcam pointer to netcam_context +- * cinfo pointer to JPEG decompression context ++ * netcam pointer to netcam_context. ++ * cinfo pointer to JPEG decompression context. + * +- * Returns: Error code ++ * Returns: Error code. + */ + static int netcam_init_jpeg(netcam_context_ptr netcam, j_decompress_ptr cinfo) + { +@@ -263,11 +251,11 @@ static int netcam_init_jpeg(netcam_conte + */ + pthread_mutex_lock(&netcam->mutex); + +- if (netcam->imgcnt_last == netcam->imgcnt) { /* need to wait */ ++ if (netcam->imgcnt_last == netcam->imgcnt) { /* Need to wait */ + struct timespec waittime; + struct timeval curtime; + int retcode; +- ++ + /* + * We calculate the delay time (representing the desired frame + * rate). This delay time is in *nanoseconds*. +@@ -282,109 +270,121 @@ static int netcam_init_jpeg(netcam_conte + curtime.tv_usec -= 1000000; + curtime.tv_sec++; + } +- ++ + waittime.tv_sec = curtime.tv_sec; + waittime.tv_nsec = 1000L * curtime.tv_usec; +- ++ + do { + retcode = pthread_cond_timedwait(&netcam->pic_ready, +- &netcam->mutex, &waittime); ++ &netcam->mutex, &waittime); + } while (retcode == EINTR); +- +- if (retcode) { /* we assume a non-zero reply is ETIMEOUT */ ++ ++ if (retcode) { /* We assume a non-zero reply is ETIMEOUT */ + pthread_mutex_unlock(&netcam->mutex); +- +- if (debug_level > CAMERA_WARNINGS) +- motion_log(-1, 0, "%s: no new pic, no signal rcvd", __FUNCTION__); +- ++ ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, ++ "%s: no new pic, no signal rcvd"); ++ + return NETCAM_GENERAL_ERROR | NETCAM_NOTHING_NEW_ERROR; + } +- +- if (debug_level > CAMERA_VERBOSE) +- motion_log(-1, 0, "%s: ***new pic delay successful***", __FUNCTION__); ++ ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, ++ "%s: ***new pic delay successful***"); + } +- ++ + netcam->imgcnt_last = netcam->imgcnt; + +- /* set latest buffer as "current" */ ++ /* Set latest buffer as "current". */ + buff = netcam->latest; + netcam->latest = netcam->jpegbuf; + netcam->jpegbuf = buff; + pthread_mutex_unlock(&netcam->mutex); + +- /* clear any error flag from previous work */ ++ /* Clear any error flag from previous work. */ + netcam->jpeg_error = 0; +- ++ + buff = netcam->jpegbuf; +- /* prepare for the decompression */ +- /* Initialize the JPEG decompression object */ ++ /* ++ * Prepare for the decompression. ++ * Initialize the JPEG decompression object. ++ */ + jpeg_create_decompress(cinfo); + +- /* Set up own error exit routine */ ++ /* Set up own error exit routine. */ + cinfo->err = jpeg_std_error(&netcam->jerr); + cinfo->client_data = netcam; + netcam->jerr.error_exit = netcam_error_exit; + netcam->jerr.output_message = netcam_output_message; + +- /* Specify the data source as our own routine */ ++ /* Specify the data source as our own routine. */ + netcam_memory_src(cinfo, buff->ptr, buff->used); + +- /* Read file parameters (rejecting tables-only) */ ++ /* Read file parameters (rejecting tables-only). */ + jpeg_read_header(cinfo, TRUE); + +- /* Override the desired colour space */ ++ /* Override the desired colour space. */ + cinfo->out_color_space = JCS_YCbCr; + +- /* Start the decompressor */ ++ /* Start the decompressor. */ + jpeg_start_decompress(cinfo); + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(LOG_INFO, 0, "%s: jpeg_error %d", __FUNCTION__, netcam->jpeg_error); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: jpeg_error %d", ++ netcam->jpeg_error); + + return netcam->jpeg_error; + } + ++/** ++ * netcam_image_conv ++ * ++ * Parameters: ++ * netcam pointer to netcam_context ++ * cinfo pointer to JPEG decompression context ++ * image pointer to buffer of destination image (yuv420) ++ * ++ * Returns : netcam->jpeg_error ++ */ + static int netcam_image_conv(netcam_context_ptr netcam, +- struct jpeg_decompress_struct *cinfo, +- unsigned char *image) ++ struct jpeg_decompress_struct *cinfo, ++ unsigned char *image) + { +- JSAMPARRAY line; /* array of decomp data lines */ +- unsigned char *wline; /* will point to line[0] */ +-/* Working variables */ ++ JSAMPARRAY line; /* Array of decomp data lines */ ++ unsigned char *wline; /* Will point to line[0] */ ++ /* Working variables */ + int linesize, i; + unsigned char *upic, *vpic; + unsigned char *pic = image; +- unsigned char y; /* switch for decoding YUV data */ ++ unsigned char y; /* Switch for decoding YUV data */ + unsigned int width, height; + + width = cinfo->output_width; + height = cinfo->output_height; + + if (width && ((width != netcam->width) || (height != netcam->height))) { +- motion_log(LOG_ERR, 0, ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, + "%s: JPEG image size %dx%d, JPEG was %dx%d", +- __FUNCTION__, netcam->width, netcam->height, width, height); +- jpeg_destroy_decompress (cinfo); ++ netcam->width, netcam->height, width, height); ++ jpeg_destroy_decompress(cinfo); + netcam->jpeg_error |= 4; + return netcam->jpeg_error; + } +- /* Set the output pointers (these come from YUV411P definition */ ++ /* Set the output pointers (these come from YUV411P definition. */ + upic = pic + width * height; + vpic = upic + (width * height) / 4; + + +- /* YCbCr format will give us one byte each for YUV */ ++ /* YCbCr format will give us one byte each for YUV. */ + linesize = cinfo->output_width * 3; + +- /* Allocate space for one line */ ++ /* Allocate space for one line. */ + line = (cinfo->mem->alloc_sarray)((j_common_ptr) cinfo, JPOOL_IMAGE, +- cinfo->output_width * cinfo->output_components, 1); ++ cinfo->output_width * cinfo->output_components, 1); + + wline = line[0]; + y = 0; + + while (cinfo->output_scanline < height) { +- jpeg_read_scanlines (cinfo, line, 1); ++ jpeg_read_scanlines(cinfo, line, 1); + + for (i = 0; i < linesize; i += 3) { + pic[i / 3] = wline[i]; +@@ -393,25 +393,25 @@ static int netcam_image_conv(netcam_cont + vpic[(i / 3) / 2] = wline[i + 2]; + } + } ++ + pic += linesize / 3; ++ + if (y++ & 1) { + upic += width / 2; + vpic += width / 2; + } + } + +- jpeg_finish_decompress (cinfo); +- jpeg_destroy_decompress (cinfo); ++ jpeg_finish_decompress(cinfo); ++ jpeg_destroy_decompress(cinfo); + +- /* rotate as specified */ +- if (netcam->cnt->rotate_data.degrees > 0) ++ if (netcam->cnt->rotate_data.degrees > 0) ++ /* Rotate as specified */ + rotate_map(netcam->cnt, image); +- + +- if (debug_level > CAMERA_VERBOSE) +- motion_log(LOG_INFO, 0, "%s: jpeg_error %d", +- __FUNCTION__, netcam->jpeg_error); +- ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: jpeg_error %d", ++ netcam->jpeg_error); ++ + return netcam->jpeg_error; + } + +@@ -422,10 +422,10 @@ static int netcam_image_conv(netcam_cont + * suitable for processing by motion. + * + * Parameters: +- * netcam pointer to the netcam_context structure +- * image Pointer to a buffer for the returned image ++ * netcam pointer to the netcam_context structure. ++ * image pointer to a buffer for the returned image. + * +- * Returns: ++ * Returns: + * + * 0 Success + * non-zero error code from other routines +@@ -434,55 +434,52 @@ static int netcam_image_conv(netcam_cont + */ + int netcam_proc_jpeg(netcam_context_ptr netcam, unsigned char *image) + { +- struct jpeg_decompress_struct cinfo; /* decompression control struct */ +- int retval = 0; /* value returned to caller */ +- int ret; /* working var */ ++ struct jpeg_decompress_struct cinfo; /* Decompression control struct. */ ++ int retval = 0; /* Value returned to caller. */ ++ int ret; /* Working var. */ + + /* + * This routine is only called from the main thread. + * We need to "protect" the "latest" image while we + * decompress it. netcam_init_jpeg uses +- * netcam->mutex to do this; ++ * netcam->mutex to do this. + */ +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_INFO, 0, "%s: processing jpeg image - content length " +- "%d", __FUNCTION__, netcam->latest->content_length); +- ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: processing jpeg image" ++ " - content length %d", netcam->latest->content_length); ++ + ret = netcam_init_jpeg(netcam, &cinfo); +- ++ + if (ret != 0) { +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_ERR, 0, "%s: ret %d", __FUNCTION__, ret); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: ret %d", ret); + return ret; +- } ++ } + +- /* Do a sanity check on dimensions ++ /* ++ * Do a sanity check on dimensions + * If dimensions have changed we throw an + * error message that will cause +- * restart of Motion ++ * restart of Motion. + */ + if (netcam->width) { /* 0 means not yet init'ed */ + if ((cinfo.output_width != netcam->width) || + (cinfo.output_height != netcam->height)) { + retval = NETCAM_RESTART_ERROR; +- motion_log(LOG_ERR, 0, +- "%s: Camera width/height mismatch " ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Camera width/height mismatch " + "with JPEG image - expected %dx%d, JPEG %dx%d", +- " retval %d", __FUNCTION__, netcam->width, netcam->height, ++ " retval %d", netcam->width, netcam->height, + cinfo.output_width, cinfo.output_height, retval); +- return retval; ++ return retval; + } + } + +- /* do the conversion */ ++ /* Do the conversion */ + ret = netcam_image_conv(netcam, &cinfo, image); +- ++ + if (ret != 0) { + retval |= NETCAM_JPEG_CONV_ERROR; +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_ERR, 0, "%s: ret %d retval %d", __FUNCTION__, +- ret, retval); +- } ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: ret %d retval %d", ++ ret, retval); ++ } + + return retval; + } +@@ -491,18 +488,18 @@ int netcam_proc_jpeg(netcam_context_ptr + * netcam_get_dimensions + * + * This function gets the height and width of the JPEG image +- * located in the supplied netcam_image_buffer ++ * located in the supplied netcam_image_buffer. + * + * Parameters + * +- * netcam pointer to the netcam context ++ * netcam pointer to the netcam context. + * +- * Returns: Nothing, but fills in width and height into context ++ * Returns: Nothing, but fills in width and height into context. + * + */ + void netcam_get_dimensions(netcam_context_ptr netcam) + { +- struct jpeg_decompress_struct cinfo; /* decompression control struct */ ++ struct jpeg_decompress_struct cinfo; /* Decompression control struct. */ + int ret; + + ret = netcam_init_jpeg(netcam, &cinfo); +@@ -513,7 +510,6 @@ void netcam_get_dimensions(netcam_contex + + jpeg_destroy_decompress(&cinfo); + +- if (debug_level > CAMERA_INFO) +- motion_log(LOG_ERR, 0, "%s: JFIF_marker %s PRESENT ret %d", +- __FUNCTION__, netcam->JFIF_marker ? "IS" : "NOT", ret); ++ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: JFIF_marker %s PRESENT ret %d", ++ netcam->JFIF_marker ? "IS" : "NOT", ret); + } +--- /dev/null ++++ motion-3.2.12/netcam_rtsp.c +@@ -0,0 +1,926 @@ ++/*********************************************************** ++ * In the top section are the functions that are used ++ * when processing the RTSP camera feed. Since these functions ++ * are internal to the RTSP module, and many require FFmpeg ++ * structures in their declarations, they are within the ++ * HAVE_FFMPEG block that eliminates them entirely when ++ * FFmpeg is not present. ++ * ++ * The functions: ++ * netcam_setup_rtsp ++ * netcam_connect_rtsp ++ * netcam_shutdown_rtsp ++ * netcam_next_rtsp ++ * are called from netcam.c therefore must be defined even ++ * if FFmpeg is not present. They must also not have FFmpeg ++ * structures in the declarations. Simple error ++ * messages are raised if called when no FFmpeg is found. ++ * ++ ***********************************************************/ ++ ++#include ++#include "netcam_rtsp.h" ++#include "rotate.h" /* already includes motion.h */ ++ ++#ifdef HAVE_FFMPEG ++ ++#include "ffmpeg.h" ++ ++/** ++ * netcam_check_pixfmt ++ * ++ * Determine whether pix_format is YUV420P ++ */ ++int netcam_check_pixfmt(netcam_context_ptr netcam){ ++ int retcd; ++ ++ retcd = -1; ++ ++ if ((netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUV420P) || ++ (netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUVJ420P)) retcd = 0; ++ ++ return retcd; ++ ++} ++/** ++ * netcam_rtsp_null_context ++ * ++ * Null all the context ++ */ ++void netcam_rtsp_null_context(netcam_context_ptr netcam){ ++ ++ netcam->rtsp->swsctx = NULL; ++ netcam->rtsp->swsframe_in = NULL; ++ netcam->rtsp->swsframe_out = NULL; ++ netcam->rtsp->frame = NULL; ++ netcam->rtsp->codec_context = NULL; ++ netcam->rtsp->format_context = NULL; ++ ++} ++/** ++ * netcam_rtsp_close_context ++ * ++ * Close all the context that could be open ++ */ ++void netcam_rtsp_close_context(netcam_context_ptr netcam){ ++ ++ if (netcam->rtsp->swsctx != NULL) sws_freeContext(netcam->rtsp->swsctx); ++ if (netcam->rtsp->swsframe_in != NULL) my_frame_free(netcam->rtsp->swsframe_in); ++ if (netcam->rtsp->swsframe_out != NULL) my_frame_free(netcam->rtsp->swsframe_out); ++ if (netcam->rtsp->frame != NULL) my_frame_free(netcam->rtsp->frame); ++ if (netcam->rtsp->codec_context != NULL) avcodec_close(netcam->rtsp->codec_context); ++ if (netcam->rtsp->format_context != NULL) avformat_close_input(&netcam->rtsp->format_context); ++ ++ netcam_rtsp_null_context(netcam); ++} ++ ++/** ++ * netcam_buffsize_rtsp ++ * ++ * This routine checks whether there is enough room in a buffer to copy ++ * some additional data. If there is not enough room, it will re-allocate ++ * the buffer and adjust it's size. ++ * ++ * Parameters: ++ * buff Pointer to a netcam_image_buffer structure. ++ * numbytes The number of bytes to be copied. ++ * ++ * Returns: Nothing ++ */ ++static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ ++ ++ int min_size_to_alloc; ++ int real_alloc; ++ int new_size; ++ ++ if ((buff->size - buff->used) >= numbytes) ++ return; ++ ++ min_size_to_alloc = numbytes - (buff->size - buff->used); ++ real_alloc = ((min_size_to_alloc / NETCAM_BUFFSIZE) * NETCAM_BUFFSIZE); ++ ++ if ((min_size_to_alloc - real_alloc) > 0) ++ real_alloc += NETCAM_BUFFSIZE; ++ ++ new_size = buff->size + real_alloc; ++ ++ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", ++ (int) buff->used, (int) buff->size, ++ (int) buff->used, new_size); ++ ++ buff->ptr = myrealloc(buff->ptr, new_size, ++ "netcam_check_buf_size"); ++ buff->size = new_size; ++} ++ ++/** ++ * decode_packet ++ * ++ * This routine takes in the packet from the read and decodes it into ++ * the frame. It then takes the frame and copies it into the netcam ++ * buffer ++ * ++ * Parameters: ++ * packet The packet that was read from av_read ++ * buffer The buffer that is the final destination ++ * frame The frame into which we decode the packet ++ * ++ * ++ * Returns: ++ * Failure 0(zero) ++ * Success The size of the frame decoded ++ */ ++static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ ++ int check = 0; ++ int frame_size = 0; ++ int ret = 0; ++ ++ ret = avcodec_decode_video2(cc, frame, &check, packet); ++ if (ret < 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); ++ return 0; ++ } ++ ++ if (check == 0) { ++ return 0; ++ } ++ ++ frame_size = avpicture_get_size(cc->pix_fmt, cc->width, cc->height); ++ ++ netcam_buffsize_rtsp(buffer, frame_size); ++ ++ avpicture_layout((const AVPicture*)frame,cc->pix_fmt,cc->width,cc->height ++ ,(unsigned char *)buffer->ptr,frame_size ); ++ ++ buffer->used = frame_size; ++ ++ return frame_size; ++} ++ ++/** ++ * netcam_open_codec ++ * ++ * This routine opens the codec context for the indicated stream ++ * ++ * Parameters: ++ * stream_idx The index of the stream that was found as "best" ++ * fmt_ctx The format context that was created upon opening the stream ++ * type The type of media type (This is a constant) ++ * ++ * ++ * Returns: ++ * Failure Error code from FFmpeg (Negative number) ++ * Success 0(Zero) ++ */ ++static int netcam_open_codec(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ ++ int ret; ++ char errstr[128]; ++ AVStream *st; ++ AVCodecContext *dec_ctx = NULL; ++ AVCodec *dec = NULL; ++ ++ ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); ++ if (ret < 0) { ++ av_strerror(ret, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream in input!: %s",errstr); ++ return ret; ++ } ++ ++ *stream_idx = ret; ++ st = fmt_ctx->streams[*stream_idx]; ++ ++ /* find decoder for the stream */ ++ dec_ctx = st->codec; ++ dec = avcodec_find_decoder(dec_ctx->codec_id); ++ if (dec == NULL) { ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find codec!"); ++ return -1; ++ } ++ ++ /* Open the codec */ ++ ret = avcodec_open2(dec_ctx, dec, NULL); ++ if (ret < 0) { ++ av_strerror(ret, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++/** ++* rtsp_new_context ++* ++* Create a new RTSP context structure. ++* ++* Parameters ++* ++* None ++* ++* Returns: Pointer to the newly-created structure, NULL if error. ++* ++*/ ++struct rtsp_context *rtsp_new_context(void){ ++ struct rtsp_context *ret; ++ ++ /* Note that mymalloc will exit on any problem. */ ++ ret = mymalloc(sizeof(struct rtsp_context)); ++ ++ memset(ret, 0, sizeof(struct rtsp_context)); ++ ++ return ret; ++} ++/** ++* netcam_interrupt_rtsp ++* ++* This function is called during the FFmpeg blocking functions. ++* These include the opening of the format context as well as the ++* reading of the packets from the stream. Since this is called ++* during all blocking functions, the process uses the readingframe ++* flag to determine whether to timeout the process. ++* ++* Parameters ++* ++* ctx We pass in the rtsp context to use it to look for the ++* readingframe flag as well as the time that we started ++* the read attempt. ++* ++* Returns: ++* Failure -1(which triggers an interupt) ++* Success 0(zero which indicates to let process continue) ++* ++*/ ++static int netcam_interrupt_rtsp(void *ctx){ ++ struct rtsp_context *rtsp = (struct rtsp_context *)ctx; ++ ++ if (rtsp->readingframe != 1) { ++ return 0; ++ } else { ++ struct timeval interrupttime; ++ if (gettimeofday(&interrupttime, NULL) < 0) { ++ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time failed"); ++ } ++ if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){ ++ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Reading picture timed out for %s",rtsp->path); ++ return 1; ++ } else{ ++ return 0; ++ } ++ } ++ ++ //should not be possible to get here ++ return 0; ++} ++/** ++* netcam_read_rtsp_image ++* ++* This function reads the packet from the camera. ++* It is called extensively so only absolutely essential ++* functions and allocations are performed. ++* ++* Parameters ++* ++* netcam The netcam context to read from ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_read_rtsp_image(netcam_context_ptr netcam){ ++ struct timeval curtime; ++ netcam_buff_ptr buffer; ++ AVPacket packet; ++ int size_decoded; ++ ++ /* Point to our working buffer. */ ++ buffer = netcam->receiving; ++ buffer->used = 0; ++ ++ av_init_packet(&packet); ++ packet.data = NULL; ++ packet.size = 0; ++ ++ size_decoded = 0; ++ ++ if (gettimeofday(&curtime, NULL) < 0) { ++ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); ++ } ++ netcam->rtsp->startreadtime = curtime; ++ ++ netcam->rtsp->readingframe = 1; ++ while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { ++ if(packet.stream_index != netcam->rtsp->video_stream_index) { ++ av_free_packet(&packet); ++ av_init_packet(&packet); ++ packet.data = NULL; ++ packet.size = 0; ++ // not our packet, skip ++ continue; ++ } ++ size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); ++ ++ av_free_packet(&packet); ++ av_init_packet(&packet); ++ packet.data = NULL; ++ packet.size = 0; ++ } ++ netcam->rtsp->readingframe = 0; ++ ++ // at this point, we are finished with the packet ++ av_free_packet(&packet); ++ ++ if (size_decoded == 0) { ++ // something went wrong, end of stream? Interupted? ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ /* ++ * read is complete - set the current 'receiving' buffer atomically ++ * as 'latest', and make the buffer previously in 'latest' become ++ * the new 'receiving' and signal pic_ready. ++ */ ++ netcam->receiving->image_time = curtime; ++ netcam->last_image = curtime; ++ netcam_buff *xchg; ++ ++ pthread_mutex_lock(&netcam->mutex); ++ xchg = netcam->latest; ++ netcam->latest = netcam->receiving; ++ netcam->receiving = xchg; ++ netcam->imgcnt++; ++ pthread_cond_signal(&netcam->pic_ready); ++ pthread_mutex_unlock(&netcam->mutex); ++ ++ return 0; ++} ++/** ++* netcam_rtsp_resize_ntc ++* ++* This function notifies the user of the need to transcode ++* the netcam image which uses a lot of CPU resources ++* ++* Parameters ++* ++* netcam The netcam context to read from ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_rtsp_resize_ntc(netcam_context_ptr netcam){ ++ ++ if ((netcam->width != netcam->rtsp->codec_context->width) || ++ (netcam->height != netcam->rtsp->codec_context->height) || ++ (netcam_check_pixfmt(netcam) != 0) ){ ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: "); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: ****************************************************************"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: The network camera is sending pictures in a different"); ++ if ((netcam->width != netcam->rtsp->codec_context->width) || ++ (netcam->height != netcam->rtsp->codec_context->height)) { ++ if (netcam_check_pixfmt(netcam) != 0) { ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: size than specified in the config and also a "); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: different picture format. The picture is being"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: transcoded to YUV420P and into the size requested"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: in the config file. If possible change netcam to"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: be in YUV420P format and the size requested in the"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: config to possibly lower CPU usage."); ++ } else { ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: size than specified in the configuration file."); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: The picture is being transcoded into the size "); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: requested in the configuration. If possible change"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: netcam or configuration to indicate the same size"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: to possibly lower CPU usage."); ++ } ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Netcam: %d x %d => Config: %d x %d" ++ ,netcam->rtsp->codec_context->width,netcam->rtsp->codec_context->height ++ ,netcam->width,netcam->height); ++ } else { ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: format than YUV420P. The image sent is being "); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: trancoded to YUV420P. If possible change netcam "); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: picture format to YUV420P to possibly lower CPU usage."); ++ } ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: ****************************************************************"); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: "); ++ } ++ ++ return 0; ++ ++} ++/** ++* netcam_rtsp_open_context ++* ++* This function opens the format context for the camera. ++* ++* Parameters ++* ++* netcam The netcam context to read from ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_rtsp_open_context(netcam_context_ptr netcam){ ++ ++ int retcd; ++ char errstr[128]; ++ ++ if (netcam->rtsp->path == NULL) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); ++ } ++ return -1; ++ } ++ ++ // open the network connection ++ AVDictionary *opts = 0; ++ netcam->rtsp->format_context = avformat_alloc_context(); ++ netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; ++ netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; ++ ++ if (strncmp(netcam->rtsp->path, "http", 4) == 0 ){ ++ netcam->rtsp->format_context->iformat = av_find_input_format("mjpeg"); ++ } else { ++ if (netcam->cnt->conf.rtsp_uses_tcp) { ++ av_dict_set(&opts, "rtsp_transport", "tcp", 0); ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED) ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using tcp transport"); ++ } else { ++ av_dict_set(&opts, "rtsp_transport", "udp", 0); ++ av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED) ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using udp transport"); ++ } ++ } ++ ++ retcd = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); ++ } ++ av_dict_free(&opts); ++ //The format context gets freed upon any error from open_input. ++ return retcd; ++ } ++ av_dict_free(&opts); ++ ++ // fill out stream information ++ retcd = avformat_find_stream_info(netcam->rtsp->format_context, NULL); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %s", errstr); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ retcd = netcam_open_codec(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; ++ ++ netcam->rtsp->frame = my_frame_alloc(); ++ if (netcam->rtsp->frame == NULL) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ /* ++ * Validate that the previous steps opened the camera ++ */ ++ retcd = netcam_read_rtsp_image(netcam); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first image"); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ return 0; ++ ++} ++/** ++* netcam_rtsp_open_sws ++* ++* This function opens the rescaling context components. ++* ++* Parameters ++* ++* netcam The netcam context to read from ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_rtsp_open_sws(netcam_context_ptr netcam){ ++ ++ netcam->width = ((netcam->cnt->conf.width / 8) * 8); ++ netcam->height = ((netcam->cnt->conf.height / 8) * 8); ++ ++ ++ netcam->rtsp->swsframe_in = my_frame_alloc(); ++ if (netcam->rtsp->swsframe_in == NULL) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ netcam->rtsp->swsframe_out = my_frame_alloc(); ++ if (netcam->rtsp->swsframe_out == NULL) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ /* ++ * The scaling context is used to change dimensions to config file and ++ * also if the format sent by the camera is not YUV420. ++ */ ++ netcam->rtsp->swsctx = sws_getContext( ++ netcam->rtsp->codec_context->width ++ ,netcam->rtsp->codec_context->height ++ ,netcam->rtsp->codec_context->pix_fmt ++ ,netcam->width ++ ,netcam->height ++ ,PIX_FMT_YUV420P ++ ,SWS_BICUBIC,NULL,NULL,NULL); ++ if (netcam->rtsp->swsctx == NULL) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate scaling context. Fatal error. Check FFmpeg/Libav configuration"); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ netcam->rtsp->swsframe_size = avpicture_get_size( ++ PIX_FMT_YUV420P ++ ,netcam->width ++ ,netcam->height); ++ if (netcam->rtsp->swsframe_size <= 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error determining size of frame out"); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ return 0; ++ ++} ++/** ++* netcam_rtsp_resize ++* ++* This function reencodes the image to yuv420p with the desired size ++* ++* Parameters ++* ++* netcam The netcam context to read from ++* image The destination image. ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ ++ ++ int retcd; ++ char errstr[128]; ++ uint8_t *buffer_out; ++ ++ retcd = avpicture_fill( ++ (AVPicture*)netcam->rtsp->swsframe_in ++ ,(uint8_t*)netcam->latest->ptr ++ ,netcam->rtsp->codec_context->pix_fmt ++ ,netcam->rtsp->codec_context->width ++ ,netcam->rtsp->codec_context->height); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error allocating picture in: %s", errstr); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ ++ buffer_out=(uint8_t *)av_malloc(netcam->rtsp->swsframe_size*sizeof(uint8_t)); ++ ++ retcd = avpicture_fill( ++ (AVPicture*)netcam->rtsp->swsframe_out ++ ,buffer_out ++ ,PIX_FMT_YUV420P ++ ,netcam->width ++ ,netcam->height); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error allocating picture out: %s", errstr); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ retcd = sws_scale( ++ netcam->rtsp->swsctx ++ ,(const uint8_t* const *)netcam->rtsp->swsframe_in->data ++ ,netcam->rtsp->swsframe_in->linesize ++ ,0 ++ ,netcam->rtsp->codec_context->height ++ ,netcam->rtsp->swsframe_out->data ++ ,netcam->rtsp->swsframe_out->linesize); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error resizing/reformatting: %s", errstr); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ retcd = avpicture_layout( ++ (const AVPicture*)netcam->rtsp->swsframe_out ++ ,PIX_FMT_YUV420P ++ ,netcam->width ++ ,netcam->height ++ ,(unsigned char *)image ++ ,netcam->rtsp->swsframe_size ); ++ if (retcd < 0) { ++ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ ++ av_strerror(retcd, errstr, sizeof(errstr)); ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error putting frame into output buffer: %s", errstr); ++ } ++ netcam_rtsp_close_context(netcam); ++ return -1; ++ } ++ ++ av_free(buffer_out); ++ ++ return 0; ++ ++} ++/********************************************************* ++ * This ends the section of functions that rely upon FFmpeg ++ ***********************************************************/ ++#endif /* End HAVE_FFMPEG */ ++ ++/** ++* netcam_connect_rtsp ++* ++* This function initiates the connection to the rtsp camera. ++* ++* Parameters ++* ++* netcam The netcam context to open. ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_connect_rtsp(netcam_context_ptr netcam){ ++#ifdef HAVE_FFMPEG ++ ++ if (netcam_rtsp_open_context(netcam) < 0) return -1; ++ ++ if (netcam_rtsp_open_sws(netcam) < 0) return -1; ++ ++ if (netcam_rtsp_resize_ntc(netcam) < 0 ) return -1; ++ ++ if (netcam_read_rtsp_image(netcam) < 0) return -1; ++ ++ netcam->rtsp->status = RTSP_CONNECTED; ++ ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Camera connected"); ++ ++ return 0; ++ ++#else /* No FFmpeg/Libav */ ++ netcam->rtsp->status = RTSP_NOTCONNECTED; ++ netcam->rtsp->format_context = NULL; ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); ++ return -1; ++#endif /* End #ifdef HAVE_FFMPEG */ ++} ++ ++/** ++* netcam_shutdown_rtsp ++* ++* This function closes and frees all the items for rtsp ++* ++* Parameters ++* ++* netcam The netcam context to free. ++* ++* Returns: ++* Failure nothing ++* Success nothing ++* ++*/ ++void netcam_shutdown_rtsp(netcam_context_ptr netcam){ ++#ifdef HAVE_FFMPEG ++ ++ if (netcam->rtsp->status == RTSP_CONNECTED) { ++ netcam_rtsp_close_context(netcam); ++ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: netcam shut down"); ++ } ++ ++ if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); ++ if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); ++ if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); ++ ++ free(netcam->rtsp); ++ netcam->rtsp = NULL; ++ ++#else /* No FFmpeg/Libav */ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); ++#endif /* End #ifdef HAVE_FFMPEG */ ++} ++ ++/** ++* netcam_setup_rtsp ++* ++* This function sets up all the necessary items for the ++* rtsp camera. ++* ++* Parameters ++* ++* netcam The netcam context to free. ++* url The URL of the camera ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ ++#ifdef HAVE_FFMPEG ++ ++ struct context *cnt = netcam->cnt; ++ const char *ptr; ++ int ret = -1; ++ ++ netcam->caps.streaming = NCS_RTSP; ++ ++ netcam->rtsp = rtsp_new_context(); ++ ++ netcam_rtsp_null_context(netcam); ++ ++ if (netcam->rtsp == NULL) { ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); ++ netcam_shutdown_rtsp(netcam); ++ return -1; ++ } ++ ++ /* ++ * Allocate space for a working string to contain the path. ++ * The extra 5 is for "://", ":" and string terminator. ++ */ ++ ++ // force port to a sane value ++ if (netcam->connect_port > 65536) { ++ netcam->connect_port = 65536; ++ } else if (netcam->connect_port < 0) { ++ netcam->connect_port = 0; ++ } ++ ++ if (cnt->conf.netcam_userpass != NULL) { ++ ptr = cnt->conf.netcam_userpass; ++ } else { ++ ptr = url->userpass; /* Don't set this one NULL, gets freed. */ ++ } ++ ++ if (ptr != NULL) { ++ char *cptr; ++ if ((cptr = strchr(ptr, ':')) == NULL) { ++ netcam->rtsp->user = mystrdup(ptr); ++ } else { ++ netcam->rtsp->user = mymalloc((cptr - ptr)+2); //+2 for string terminator ++ memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); ++ netcam->rtsp->pass = mystrdup(cptr + 1); ++ } ++ } ++ ++ /* ++ * Need a method to query the path and ++ * determine the authentication type ++ */ ++ if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { ++ ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) ++ + 5 + strlen(url->path) + 5 ++ + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 4 ); ++ sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", ++ url->service,netcam->rtsp->user,netcam->rtsp->pass, ++ netcam->connect_host, netcam->connect_port, url->path); ++ } ++ else { ++ ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) ++ + 5 + strlen(url->path) + 5); ++ sprintf((char *)ptr, "%s://%s:%d%s", url->service, ++ netcam->connect_host, netcam->connect_port, url->path); ++ } ++ netcam->rtsp->path = (char *)ptr; ++ ++ netcam_url_free(url); ++ ++ /* ++ * Now we need to set some flags ++ */ ++ netcam->rtsp->readingframe = 0; ++ netcam->rtsp->status = RTSP_NOTCONNECTED; ++ ++ /* ++ * Warn and fix dimensions as needed. ++ */ ++ if (netcam->cnt->conf.width % 16) { ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image width (%d) requested is not modulo 16.", netcam->cnt->conf.width); ++ netcam->cnt->conf.width = netcam->cnt->conf.width - (netcam->cnt->conf.width % 16) + 16; ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting width to next higher multiple of 16 (%d).", netcam->cnt->conf.width); ++ } ++ if (netcam->cnt->conf.height % 16) { ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image height (%d) requested is not modulo 16.", netcam->cnt->conf.height); ++ netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 16) + 16; ++ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 16 (%d).", netcam->cnt->conf.height); ++ } ++ ++ av_register_all(); ++ avformat_network_init(); ++ avcodec_register_all(); ++ ++ /* ++ * The RTSP context should be all ready to attempt a connection with ++ * the server, so we try .... ++ */ ++ ret = netcam_connect_rtsp(netcam); ++ if (ret < 0){ ++ return ret; ++ } ++ ++ netcam->get_image = netcam_read_rtsp_image; ++ ++ return 0; ++ ++#else /* No FFmpeg/Libav */ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); ++ return -1; ++#endif /* End #ifdef HAVE_FFMPEG */ ++} ++ ++/** ++* netcam_next_rtsp ++* ++* This function moves the picture to the image buffer. ++* If the picture is not in the correct format for size ++* it will put it into the requested format ++* ++* Parameters ++* ++* netcam The netcam context to free. ++* url The URL of the camera ++* ++* Returns: ++* Failure -1 ++* Success 0(zero) ++* ++*/ ++int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam){ ++#ifdef HAVE_FFMPEG ++ ++ if ((netcam->width != netcam->rtsp->codec_context->width) || ++ (netcam->height != netcam->rtsp->codec_context->height) || ++ (netcam_check_pixfmt(netcam) != 0) ){ ++ netcam_rtsp_resize(image ,netcam); ++ } else { ++ memcpy(image, netcam->latest->ptr, netcam->latest->used); ++ } ++ if (netcam->cnt->rotate_data.degrees > 0) ++ /* Rotate as specified */ ++ rotate_map(netcam->cnt, image); ++ ++ return 0; ++#else /* No FFmpeg/Libav */ ++ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); ++ return -1; ++#endif /* End #ifdef HAVE_FFMPEG */ ++} +--- /dev/null ++++ motion-3.2.12/netcam_rtsp.h +@@ -0,0 +1,43 @@ ++#include "netcam.h" ++ ++#ifdef HAVE_FFMPEG ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#endif /* end HAVE_FFMPEG */ ++ ++struct rtsp_context { ++#ifdef HAVE_FFMPEG ++ AVFormatContext* format_context; ++ AVCodecContext* codec_context; ++ AVFrame* frame; ++ AVFrame* swsframe_in; ++ AVFrame* swsframe_out; ++ int swsframe_size; ++ int video_stream_index; ++ char* path; ++ char* user; ++ char* pass; ++ int readingframe; ++ int status; ++ struct timeval startreadtime; ++ struct SwsContext* swsctx; ++ ++#else /* Do not have FFmpeg */ ++ int* format_context; ++ int readingframe; ++ int status; ++#endif /* end HAVE_FFMPEG */ ++}; ++ ++struct rtsp_context *rtsp_new_context(void); ++void netcam_shutdown_rtsp(netcam_context_ptr netcam); ++int netcam_connect_rtsp(netcam_context_ptr netcam); ++int netcam_read_rtsp_image(netcam_context_ptr netcam); ++int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); ++int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam); +--- motion-3.2.12.orig/netcam_wget.c ++++ motion-3.2.12/netcam_wget.c +@@ -63,14 +63,15 @@ Foundation, Inc., 675 Mass Ave, Cambridg + `:', thus you can use it to retrieve, say, HTTP status line. + + All trailing whitespace is stripped from the header, and it is +- zero-terminated. */ +- ++ zero-terminated. ++ */ + int header_get(netcam_context_ptr netcam, char **hdr, enum header_get_flags flags) + { + int i; + int bufsize = 80; + + *hdr = (char *)mymalloc(bufsize); ++ + for (i = 0; 1; i++) { + int res; + /* #### Use DO_REALLOC? */ +@@ -84,9 +85,11 @@ int header_get(netcam_context_ptr netcam + if (!((flags & HG_NO_CONTINUATIONS) || i == 0 + || (i == 1 && (*hdr)[0] == '\r'))) { + char next; +- /* If the header is non-empty, we need to check if +- it continues on to the other line. We do that by +- peeking at the next character. */ ++ /* ++ * If the header is non-empty, we need to check if ++ * it continues on to the other line. We do that by ++ * peeking at the next character. ++ */ + res = rbuf_peek(netcam, &next); + + if (res == 0) { +@@ -96,24 +99,23 @@ int header_get(netcam_context_ptr netcam + (*hdr)[i] = '\0'; + return HG_ERROR; + } +- /* If the next character is HT or SP, just continue. */ +- ++ /* If the next character is HT or SP, just continue. */ + if (next == '\t' || next == ' ') + continue; + } + +- /* Strip trailing whitespace. (*hdr)[i] is the newline; +- decrement I until it points to the last available +- whitespace. */ ++ /* ++ * Strip trailing whitespace. (*hdr)[i] is the newline; ++ * decrement I until it points to the last available ++ * whitespace. ++ */ + while (i > 0 && isspace((*hdr)[i - 1])) + --i; + + (*hdr)[i] = '\0'; + break; + } +- + } else if (res == 0) { +- + (*hdr)[i] = '\0'; + return HG_EOF; + } else { +@@ -125,14 +127,17 @@ int header_get(netcam_context_ptr netcam + return HG_OK; + } + +-/* Check whether HEADER begins with NAME and, if yes, skip the `:' and +- the whitespace, and call PROCFUN with the arguments of HEADER's +- contents (after the `:' and space) and ARG. Otherwise, return 0. */ +-int header_process (const char *header, const char *name, +- int (*procfun)(const char *, void *), +- void *arg) ++/** ++ * header_process ++ * ++ * Check whether HEADER begins with NAME and, if yes, skip the `:' and ++ * the whitespace, and call PROCFUN with the arguments of HEADER's ++ * contents (after the `:' and space) and ARG. Otherwise, return 0. ++ */ ++int header_process(const char *header, const char *name, ++ int (*procfun)(const char *, void *), void *arg) + { +- /* Check whether HEADER matches NAME. */ ++ /* Check whether HEADER matches NAME. */ + while (*name && (tolower (*name) == tolower (*header))) + ++name, ++header; + +@@ -143,10 +148,14 @@ int header_process (const char *header, + return ((*procfun) (header, arg)); + } + +-/* Helper functions for use with header_process(). */ ++/* Helper functions for use with header_process(). */ + +-/* Extract a long integer from HEADER and store it to CLOSURE. If an +- error is encountered, return 0, else 1. */ ++/** ++ * header_extract_number ++ * ++ * Extract a long integer from HEADER and store it to CLOSURE. If an ++ * error is encountered, return 0, else 1. ++ */ + int header_extract_number(const char *header, void *closure) + { + const char *p = header; +@@ -162,7 +171,7 @@ int header_extract_number(const char *he + /* Skip trailing whitespace. */ + p += skip_lws (p); + +- /* We return the value, even if a format error follows */ ++ /* We return the value, even if a format error follows. */ + *(long *)closure = result; + + /* Indicate failure if trailing garbage is present. */ +@@ -172,16 +181,23 @@ int header_extract_number(const char *he + return 1; + } + +-/* Strdup HEADER, and place the pointer to CLOSURE. */ ++/** ++ * header_strdup ++ * ++ * Strdup HEADER, and place the pointer to CLOSURE. ++ */ + int header_strdup(const char *header, void *closure) + { +- *(char **)closure = strdup(header); ++ *(char **)closure = mystrdup(header); + return 1; + } + + +-/* Skip LWS (linear white space), if present. Returns number of +- characters to skip. */ ++/** ++ * skip_lws ++ * Skip LWS (linear white space), if present. Returns number of ++ * characters to skip. ++ */ + int skip_lws(const char *string) + { + const char *p = string; +@@ -193,11 +209,13 @@ int skip_lws(const char *string) + } + + +-/* +- Encode the string S of length LENGTH to base64 format and place it +- to STORE. STORE will be 0-terminated, and must point to a writable +- buffer of at least 1+BASE64_LENGTH(length) bytes. +-*/ ++/** ++ * base64_encode ++ * ++ * Encode the string S of length LENGTH to base64 format and place it ++ * to STORE. STORE will be 0-terminated, and must point to a writable ++ * buffer of at least 1+BASE64_LENGTH(length) bytes. ++ */ + void base64_encode(const char *s, char *store, int length) + { + /* Conversion table. */ +@@ -215,7 +233,7 @@ void base64_encode(const char *s, char * + int i; + unsigned char *p = (unsigned char *)store; + +- /* Transform the 3x8 bits to 4x6 bits, as required by base64. */ ++ /* Transform the 3x8 bits to 4x6 bits, as required by base64. */ + for (i = 0; i < length; i += 3) { + *p++ = tbl[s[0] >> 2]; + *p++ = tbl[((s[0] & 3) << 4) + (s[1] >> 4)]; +@@ -224,7 +242,7 @@ void base64_encode(const char *s, char * + s += 3; + } + +- /* Pad the result if necessary... */ ++ /* Pad the result if necessary... */ + if (i == length + 1) + *(p - 1) = '='; + else if (i == length + 2) +@@ -234,6 +252,9 @@ void base64_encode(const char *s, char * + *p = '\0'; + } + ++/** ++ * strdupdelim ++ */ + char *strdupdelim(const char *beg, const char *end) + { + char *res = (char *)mymalloc(end - beg + 1); +@@ -243,6 +264,9 @@ char *strdupdelim(const char *beg, const + return res; + } + ++/** ++ * http_process_type ++ */ + int http_process_type(const char *hdr, void *arg) + { + char **result = (char **)arg; +@@ -259,8 +283,11 @@ int http_process_type(const char *hdr, v + return 1; + } + +-/* This is a simple implementation of buffering IO-read functions. */ +- ++/** ++ * rbuf_initialize ++ * ++ * This is a simple implementation of buffering IO-read functions. ++ */ + void rbuf_initialize(netcam_context_ptr netcam) + { + netcam->response->buffer_pos = netcam->response->buffer; +@@ -273,7 +300,11 @@ int rbuf_read_bufferful(netcam_context_p + sizeof (netcam->response->buffer)); + } + +-/* Like rbuf_readchar(), only don't move the buffer position. */ ++/** ++ * rbuf_peek ++ * ++ * Like rbuf_readchar(), only don't move the buffer position. ++ */ + int rbuf_peek(netcam_context_ptr netcam, char *store) + { + if (!netcam->response->buffer_left) { +@@ -282,8 +313,10 @@ int rbuf_peek(netcam_context_ptr netcam, + res = netcam_recv (netcam, netcam->response->buffer, + sizeof (netcam->response->buffer)); + +- if (res <= 0) ++ if (res <= 0) { ++ *store = '\0'; + return res; ++ } + + netcam->response->buffer_left = res; + } +@@ -292,11 +325,13 @@ int rbuf_peek(netcam_context_ptr netcam, + return 1; + } + +-/* +- Flush RBUF's buffer to WHERE. Flush MAXSIZE bytes at most. +- Returns the number of bytes actually copied. If the buffer is +- empty, 0 is returned. +-*/ ++/** ++ * rbuf_flush ++ * ++ * Flush RBUF's buffer to WHERE. Flush MAXSIZE bytes at most. ++ * Returns the number of bytes actually copied. If the buffer is ++ * empty, 0 is returned. ++ */ + int rbuf_flush(netcam_context_ptr netcam, char *where, int maxsize) + { + if (!netcam->response->buffer_left) { +@@ -313,16 +348,20 @@ int rbuf_flush(netcam_context_ptr netcam + } + } + +-/* Get the HTTP result code */ ++/** ++ * http_result_code ++ * ++ * Get the HTTP result code ++ */ + int http_result_code(const char *header) + { + char *cptr; + +- /* assure the header starts out right */ ++ /* Assure the header starts out right. */ + if (strncmp(header, "HTTP", 4)) + return -1; + +- /* find the space following the HTTP/1.x */ ++ /* Find the space following the HTTP/1.x */ + if ((cptr = strchr(header+4, ' ')) == NULL) + return -1; + +--- motion-3.2.12.orig/netcam_wget.h ++++ motion-3.2.12/netcam_wget.h +@@ -76,15 +76,15 @@ void base64_encode(const char *, char *, + char *strdupdelim(const char *, const char *); + int http_process_type(const char *, void *); + +-enum { ++enum { + HG_OK, + HG_ERROR, + HG_EOF + }; + +-enum header_get_flags { ++enum header_get_flags{ + HG_NONE = 0, +- HG_NO_CONTINUATIONS = 0x2 ++ HG_NO_CONTINUATIONS = 0x2 + }; + + int header_get (netcam_context_ptr, char **, enum header_get_flags); +--- motion-3.2.12.orig/picture.c ++++ motion-3.2.12/picture.c +@@ -3,6 +3,7 @@ + * Various funtions for saving/loading pictures. + * Copyright 2002 by Jeroen Vreeken (pe1rxq@amsat.org) + * Portions of this file are Copyright by Lionnel Maugis ++ * Portions of this file are Copyright 2010 by Wim Lewis (wiml@hhhh.org) + * This software is distributed under the GNU public license version 2 + * See also the file 'COPYING'. + * +@@ -11,12 +12,15 @@ + #include "picture.h" + #include "event.h" + ++#include ++ + #undef HAVE_STDLIB_H + #include + #include + +-/* The following declarations and 5 functions are jpeg related +- * functions used by put_jpeg_grey_memory and put_jpeg_yuv420p_memory ++/* ++ * The following declarations and 5 functions are jpeg related ++ * functions used by put_jpeg_grey_memory and put_jpeg_yuv420p_memory. + */ + typedef struct { + struct jpeg_destination_mgr pub; +@@ -59,7 +63,7 @@ static GLOBAL(void) _jpeg_mem_dest(j_com + if (cinfo->dest == NULL) { + cinfo->dest = (struct jpeg_destination_mgr *) + (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_PERMANENT, +- sizeof(mem_destination_mgr)); ++ sizeof(mem_destination_mgr)); + } + + dest = (mem_dest_ptr) cinfo->dest; +@@ -79,20 +83,340 @@ static GLOBAL(int) _jpeg_mem_size(j_comp + return dest->jpegsize; + } + ++/* EXIF image data is always in TIFF format, even if embedded in another ++ * file type. This consists of a constant header (TIFF file header, ++ * IFD header) followed by the tags in the IFD and then the data ++ * from any tags which do not fit inline in the IFD. ++ * ++ * The tags we write in the main IFD are: ++ * 0x010E Image description ++ * 0x8769 Exif sub-IFD ++ * 0x882A Time zone of time stamps ++ * and in the Exif sub-IFD: ++ * 0x9000 Exif version ++ * 0x9003 File date and time ++ * 0x9291 File date and time subsecond info ++ * But we omit any empty IFDs. ++ */ ++ ++#define TIFF_TAG_IMAGE_DESCRIPTION 0x010E ++#define TIFF_TAG_DATETIME 0x0132 ++#define TIFF_TAG_EXIF_IFD 0x8769 ++#define TIFF_TAG_TZ_OFFSET 0x882A ++ ++#define EXIF_TAG_EXIF_VERSION 0x9000 ++#define EXIF_TAG_ORIGINAL_DATETIME 0x9003 ++#define EXIF_TAG_SUBJECT_AREA 0x9214 ++#define EXIF_TAG_TIFF_DATETIME_SS 0x9290 ++#define EXIF_TAG_ORIGINAL_DATETIME_SS 0x9291 ++ ++#define TIFF_TYPE_ASCII 2 /* ASCII text */ ++#define TIFF_TYPE_USHORT 3 /* Unsigned 16-bit int */ ++#define TIFF_TYPE_LONG 4 /* Unsigned 32-bit int */ ++#define TIFF_TYPE_UNDEF 7 /* Byte blob */ ++#define TIFF_TYPE_SSHORT 8 /* Signed 16-bit int */ ++ ++static const char exif_marker_start[14] = { ++ 'E', 'x', 'i', 'f', 0, 0, /* EXIF marker signature */ ++ 'M', 'M', 0, 42, /* TIFF file header (big-endian) */ ++ 0, 0, 0, 8, /* Offset to first toplevel IFD */ ++}; ++ ++static const char exif_version_tag[12] = { ++ 0x90, 0x00, /* EXIF version tag, 0x9000 */ ++ 0x00, 0x07, /* Data type 7 = "unknown" (raw byte blob) */ ++ 0x00, 0x00, 0x00, 0x04, /* Data length */ ++ 0x30, 0x32, 0x32, 0x30 /* Inline data, EXIF version 2.2 */ ++}; ++ ++static const char exif_subifd_tag[8] = { ++ 0x87, 0x69, /* EXIF Sub-IFD tag */ ++ 0x00, 0x04, /* Data type 4 = uint32 */ ++ 0x00, 0x00, 0x00, 0x01, /* Number of values */ ++}; ++ ++static const char exif_tzoffset_tag[12] = { ++ 0x88, 0x2A, /* TIFF/EP time zone offset tag */ ++ 0x00, 0x08, /* Data type 8 = sint16 */ ++ 0x00, 0x00, 0x00, 0x01, /* Number of values */ ++ 0, 0, 0, 0 /* Dummy data */ ++}; ++ ++static void put_uint16(JOCTET *buf, unsigned value) ++{ ++ buf[0] = ( value & 0xFF00 ) >> 8; ++ buf[1] = ( value & 0x00FF ); ++} ++ ++static void put_sint16(JOCTET *buf, int value) ++{ ++ buf[0] = ( value & 0xFF00 ) >> 8; ++ buf[1] = ( value & 0x00FF ); ++} ++ ++static void put_uint32(JOCTET *buf, unsigned value) ++{ ++ buf[0] = ( value & 0xFF000000 ) >> 24; ++ buf[1] = ( value & 0x00FF0000 ) >> 16; ++ buf[2] = ( value & 0x0000FF00 ) >> 8; ++ buf[3] = ( value & 0x000000FF ); ++} ++ ++struct tiff_writing { ++ JOCTET * const base; ++ JOCTET *buf; ++ unsigned data_offset; ++}; ++ ++static void put_direntry(struct tiff_writing *into, const char *data, unsigned length) ++{ ++ if (length <= 4) { ++ /* Entries that fit in the directory entry are stored there */ ++ memset(into->buf, 0, 4); ++ memcpy(into->buf, data, length); ++ } else { ++ /* Longer entries are stored out-of-line */ ++ unsigned offset = into->data_offset; ++ ++ while ((offset & 0x03) != 0) { /* Alignment */ ++ into->base[offset] = 0; ++ offset ++; ++ } ++ ++ put_uint32(into->buf, offset); ++ memcpy(into->base + offset, data, length); ++ into->data_offset = offset + length; ++ } ++} ++ ++static void put_stringentry(struct tiff_writing *into, unsigned tag, const char *str, int with_nul) ++{ ++ unsigned stringlength = strlen(str) + (with_nul?1:0); ++ ++ put_uint16(into->buf, tag); ++ put_uint16(into->buf + 2, TIFF_TYPE_ASCII); ++ put_uint32(into->buf + 4, stringlength); ++ into->buf += 8; ++ put_direntry(into, str, stringlength); ++ into->buf += 4; ++} ++ ++static void put_subjectarea(struct tiff_writing *into, const struct coord *box) ++{ ++ put_uint16(into->buf , EXIF_TAG_SUBJECT_AREA); ++ put_uint16(into->buf + 2, TIFF_TYPE_USHORT); ++ put_uint32(into->buf + 4, 4 /* Four USHORTs */); ++ put_uint32(into->buf + 8, into->data_offset); ++ into->buf += 12; ++ JOCTET *ool = into->base + into->data_offset; ++ put_uint16(ool , box->x); /* Center.x */ ++ put_uint16(ool+2, box->y); /* Center.y */ ++ put_uint16(ool+4, box->width); ++ put_uint16(ool+6, box->height); ++ into->data_offset += 8; ++} ++ ++/* ++ * put_jpeg_exif writes the EXIF APP1 chunk to the jpeg file. ++ * It must be called after jpeg_start_compress() but before ++ * any image data is written by jpeg_write_scanlines(). ++ */ ++static void put_jpeg_exif(j_compress_ptr cinfo, ++ const struct context *cnt, ++ const struct tm *timestamp, ++ const struct coord *box) ++{ ++ /* description, datetime, and subtime are the values that are actually ++ * put into the EXIF data ++ */ ++ char *description, *datetime, *subtime; ++ char datetime_buf[22]; ++ ++ if (timestamp) { ++ /* Exif requires this exact format */ ++ snprintf(datetime_buf, 21, "%04d:%02d:%02d %02d:%02d:%02d", ++ timestamp->tm_year + 1900, ++ timestamp->tm_mon + 1, ++ timestamp->tm_mday, ++ timestamp->tm_hour, ++ timestamp->tm_min, ++ timestamp->tm_sec); ++ datetime = datetime_buf; ++ } else { ++ datetime = NULL; ++ } ++ ++ // TODO: Extract subsecond timestamp from somewhere, but only ++ // use as much of it as is indicated by conf->frame_limit ++ subtime = NULL; ++ ++ if (cnt->conf.exif_text) { ++ description = malloc(PATH_MAX); ++ mystrftime(cnt, description, PATH_MAX-1, ++ cnt->conf.exif_text, ++ timestamp, NULL, 0); ++ } else { ++ description = NULL; ++ } ++ ++ /* Calculate an upper bound on the size of the APP1 marker so ++ * we can allocate a buffer for it. ++ */ ++ ++ /* Count up the number of tags and max amount of OOL data */ ++ int ifd0_tagcount = 0; ++ int ifd1_tagcount = 0; ++ unsigned datasize = 0; ++ ++ if (description) { ++ ifd0_tagcount ++; ++ datasize += 5 + strlen(description); /* Add 5 for NUL and alignment */ ++ } ++ ++ if (datetime) { ++ /* We write this to both the TIFF datetime tag (which most programs ++ * treat as "last-modified-date") and the EXIF "time of creation of ++ * original image" tag (which many programs ignore). This is ++ * redundant but seems to be the thing to do. ++ */ ++ ifd0_tagcount++; ++ ifd1_tagcount++; ++ /* We also write the timezone-offset tag in IFD0 */ ++ ifd0_tagcount++; ++ /* It would be nice to use the same offset for both tags' values, ++ * but I don't want to write the bookkeeping for that right now */ ++ datasize += 2 * (5 + strlen(datetime)); ++ } ++ ++ if (subtime) { ++ ifd1_tagcount++; ++ datasize += 5 + strlen(subtime); ++ } ++ ++ if (box) { ++ ifd1_tagcount++; ++ datasize += 2 * 4; /* Four 16-bit ints */ ++ } ++ ++ if (ifd1_tagcount > 0) { ++ /* If we're writing the Exif sub-IFD, account for the ++ * two tags that requires */ ++ ifd0_tagcount ++; /* The tag in IFD0 that points to IFD1 */ ++ ifd1_tagcount ++; /* The EXIF version tag */ ++ } ++ ++ /* Each IFD takes 12 bytes per tag, plus six more (the tag count and the ++ * pointer to the next IFD, always zero in our case) ++ */ ++ unsigned int ifds_size = ++ ( ifd1_tagcount > 0 ? ( 12 * ifd1_tagcount + 6 ) : 0 ) + ++ ( ifd0_tagcount > 0 ? ( 12 * ifd0_tagcount + 6 ) : 0 ); ++ ++ if (ifds_size == 0) { ++ /* We're not actually going to write any information. */ ++ return; ++ } ++ ++ unsigned int buffer_size = 6 /* EXIF marker signature */ + ++ 8 /* TIFF file header */ + ++ ifds_size /* the tag directories */ + ++ datasize; ++ ++ JOCTET *marker = malloc(buffer_size); ++ memcpy(marker, exif_marker_start, 14); /* EXIF and TIFF headers */ ++ ++ struct tiff_writing writing = (struct tiff_writing) { ++ .base = marker + 6, /* base address for intra-TIFF offsets */ ++ .buf = marker + 14, /* current write position */ ++ .data_offset = 8 + ifds_size, /* where to start storing data */ ++ }; ++ ++ /* Write IFD 0 */ ++ /* Note that tags are stored in numerical order */ ++ put_uint16(writing.buf, ifd0_tagcount); ++ writing.buf += 2; ++ ++ if (description) ++ put_stringentry(&writing, TIFF_TAG_IMAGE_DESCRIPTION, description, 0); ++ ++ if (datetime) ++ put_stringentry(&writing, TIFF_TAG_DATETIME, datetime, 1); ++ ++ if (ifd1_tagcount > 0) { ++ /* Offset of IFD1 - TIFF header + IFD0 size. */ ++ unsigned ifd1_offset = 8 + 6 + ( 12 * ifd0_tagcount ); ++ memcpy(writing.buf, exif_subifd_tag, 8); ++ put_uint32(writing.buf + 8, ifd1_offset); ++ writing.buf += 12; ++ } ++ ++ if (datetime) { ++ memcpy(writing.buf, exif_tzoffset_tag, 12); ++ put_sint16(writing.buf+8, timestamp->tm_gmtoff / 3600); ++ writing.buf += 12; ++ } ++ ++ put_uint32(writing.buf, 0); /* Next IFD offset = 0 (no next IFD) */ ++ writing.buf += 4; ++ ++ /* Write IFD 1 */ ++ if (ifd1_tagcount > 0) { ++ /* (remember that the tags in any IFD must be in numerical order ++ * by tag) */ ++ put_uint16(writing.buf, ifd1_tagcount); ++ memcpy(writing.buf + 2, exif_version_tag, 12); /* tag 0x9000 */ ++ writing.buf += 14; ++ ++ if (datetime) ++ put_stringentry(&writing, EXIF_TAG_ORIGINAL_DATETIME, datetime, 1); ++ ++ if (box) ++ put_subjectarea(&writing, box); ++ ++ if (subtime) ++ put_stringentry(&writing, EXIF_TAG_ORIGINAL_DATETIME_SS, subtime, 0); + +-/* put_jpeg_yuv420p_memory converts an input image in the YUV420P format into a jpeg image and puts +- * it in a memory buffer. ++ put_uint32(writing.buf, 0); /* Next IFD = 0 (no next IFD) */ ++ writing.buf += 4; ++ } ++ ++ /* We should have met up with the OOL data */ ++ assert( (writing.buf - writing.base) == 8 + ifds_size ); ++ ++ /* The buffer is complete; write it out */ ++ unsigned marker_len = 6 + writing.data_offset; ++ ++ /* assert we didn't underestimate the original buffer size */ ++ assert(marker_len <= buffer_size); ++ ++ /* EXIF data lives in a JPEG APP1 marker */ ++ jpeg_write_marker(cinfo, JPEG_APP0 + 1, marker, marker_len); ++ ++ if (description) ++ free(description); ++ ++ free(marker); ++} ++ ++/** ++ * put_jpeg_yuv420p_memory ++ * Converts an input image in the YUV420P format into a jpeg image and puts ++ * it in a memory buffer. + * Inputs: + * - image_size is the size of the input image buffer. + * - input_image is the image in YUV420P format. + * - width and height are the dimensions of the image + * - quality is the jpeg encoding quality 0-100% ++ * + * Output: + * - dest_image is a pointer to the jpeg image buffer +- * Returns buffer size of jpeg image ++ * ++ * Returns buffer size of jpeg image + */ + static int put_jpeg_yuv420p_memory(unsigned char *dest_image, int image_size, +- unsigned char *input_image, int width, int height, int quality) ++ unsigned char *input_image, int width, int height, int quality, ++ struct context *cnt, struct tm *tm, struct coord *box) ++ + { + int i, j, jpeg_image_size; + +@@ -106,21 +430,20 @@ static int put_jpeg_yuv420p_memory(unsig + data[1] = cb; + data[2] = cr; + +- cinfo.err = jpeg_std_error(&jerr); // errors get written to stderr +- ++ cinfo.err = jpeg_std_error(&jerr); // Errors get written to stderr ++ + jpeg_create_compress(&cinfo); + cinfo.image_width = width; + cinfo.image_height = height; + cinfo.input_components = 3; +- jpeg_set_defaults (&cinfo); ++ jpeg_set_defaults(&cinfo); + + jpeg_set_colorspace(&cinfo, JCS_YCbCr); + +- cinfo.raw_data_in = TRUE; // supply downsampled data ++ cinfo.raw_data_in = TRUE; // Supply downsampled data + #if JPEG_LIB_VERSION >= 70 +-#warning using JPEG_LIB_VERSION >= 70 +- cinfo.do_fancy_downsampling = FALSE; // fix segfaulst with v7 +-#endif ++ cinfo.do_fancy_downsampling = FALSE; // Fix segfault with v7 ++#endif + cinfo.comp_info[0].h_samp_factor = 2; + cinfo.comp_info[0].v_samp_factor = 2; + cinfo.comp_info[1].h_samp_factor = 1; +@@ -131,16 +454,19 @@ static int put_jpeg_yuv420p_memory(unsig + jpeg_set_quality(&cinfo, quality, TRUE); + cinfo.dct_method = JDCT_FASTEST; + +- _jpeg_mem_dest(&cinfo, dest_image, image_size); // data written to mem +- +- jpeg_start_compress (&cinfo, TRUE); ++ _jpeg_mem_dest(&cinfo, dest_image, image_size); // Data written to mem ++ ++ jpeg_start_compress(&cinfo, TRUE); ++ ++ put_jpeg_exif(&cinfo, cnt, tm, box); + + for (j = 0; j < height; j += 16) { + for (i = 0; i < 16; i++) { + y[i] = input_image + width * (i + j); +- if (i%2 == 0) { +- cb[i/2] = input_image + width * height + width / 2 * ((i + j) / 2); +- cr[i/2] = input_image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); ++ ++ if (i % 2 == 0) { ++ cb[i / 2] = input_image + width * height + width / 2 * ((i + j) /2); ++ cr[i / 2] = input_image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); + } + } + jpeg_write_raw_data(&cinfo, data, 16); +@@ -149,22 +475,26 @@ static int put_jpeg_yuv420p_memory(unsig + jpeg_finish_compress(&cinfo); + jpeg_image_size = _jpeg_mem_size(&cinfo); + jpeg_destroy_compress(&cinfo); +- ++ + return jpeg_image_size; + } + +-/* put_jpeg_grey_memory converts an input image in the grayscale format into a jpeg image ++/** ++ * put_jpeg_grey_memory ++ * Converts an input image in the grayscale format into a jpeg image. ++ * + * Inputs: + * - image_size is the size of the input image buffer. + * - input_image is the image in grayscale format. + * - width and height are the dimensions of the image + * - quality is the jpeg encoding quality 0-100% ++ * + * Output: + * - dest_image is a pointer to the jpeg image buffer +- * Returns buffer size of jpeg image ++ * ++ * Returns buffer size of jpeg image. + */ +-static int put_jpeg_grey_memory(unsigned char *dest_image, int image_size, +- unsigned char *input_image, int width, int height, int quality) ++static int put_jpeg_grey_memory(unsigned char *dest_image, int image_size, unsigned char *input_image, int width, int height, int quality) + { + int y, dest_image_size; + JSAMPROW row_ptr[1]; +@@ -175,24 +505,26 @@ static int put_jpeg_grey_memory(unsigned + jpeg_create_compress(&cjpeg); + cjpeg.image_width = width; + cjpeg.image_height = height; +- cjpeg.input_components = 1; /* one colour component */ ++ cjpeg.input_components = 1; /* One colour component */ + cjpeg.in_color_space = JCS_GRAYSCALE; + + jpeg_set_defaults(&cjpeg); + + jpeg_set_quality(&cjpeg, quality, TRUE); + cjpeg.dct_method = JDCT_FASTEST; +- _jpeg_mem_dest(&cjpeg, dest_image, image_size); // data written to mem ++ _jpeg_mem_dest(&cjpeg, dest_image, image_size); // Data written to mem + + jpeg_start_compress (&cjpeg, TRUE); + ++ put_jpeg_exif(&cjpeg, NULL, NULL, NULL); ++ + row_ptr[0] = input_image; +- ++ + for (y = 0; y < height; y++) { + jpeg_write_scanlines(&cjpeg, row_ptr, 1); + row_ptr[0] += width; + } +- ++ + jpeg_finish_compress(&cjpeg); + dest_image_size = _jpeg_mem_size(&cjpeg); + jpeg_destroy_compress(&cjpeg); +@@ -200,20 +532,27 @@ static int put_jpeg_grey_memory(unsigned + return dest_image_size; + } + +-/* put_jpeg_yuv420p_file converts an YUV420P coded image to a jpeg image and writes +- * it to an already open file. ++/** ++ * put_jpeg_yuv420p_file ++ * Converts an YUV420P coded image to a jpeg image and writes ++ * it to an already open file. ++ * + * Inputs: + * - image is the image in YUV420P format. + * - width and height are the dimensions of the image + * - quality is the jpeg encoding quality 0-100% ++ * + * Output: + * - The jpeg is written directly to the file given by the file pointer fp ++ * + * Returns nothing + */ +-static void put_jpeg_yuv420p_file(FILE *fp, unsigned char *image, int width, +- int height, int quality) ++static void put_jpeg_yuv420p_file(FILE *fp, ++ unsigned char *image, int width, int height, ++ int quality, ++ struct context *cnt, struct tm *tm, struct coord *box) + { +- int i,j; ++ int i, j; + + JSAMPROW y[16],cb[16],cr[16]; // y[2][5] = color sample of row 2 and pixel column 5; (one plane) + JSAMPARRAY data[3]; // t[0][2][5] = color sample 0 of row 2 and column 5 +@@ -225,8 +564,8 @@ static void put_jpeg_yuv420p_file(FILE * + data[1] = cb; + data[2] = cr; + +- cinfo.err = jpeg_std_error(&jerr); // errors get written to stderr +- ++ cinfo.err = jpeg_std_error(&jerr); // Errors get written to stderr ++ + jpeg_create_compress(&cinfo); + cinfo.image_width = width; + cinfo.image_height = height; +@@ -235,11 +574,10 @@ static void put_jpeg_yuv420p_file(FILE * + + jpeg_set_colorspace(&cinfo, JCS_YCbCr); + +- cinfo.raw_data_in = TRUE; // supply downsampled data ++ cinfo.raw_data_in = TRUE; // Supply downsampled data + #if JPEG_LIB_VERSION >= 70 +-#warning using JPEG_LIB_VERSION >= 70 +- cinfo.do_fancy_downsampling = FALSE; // fix segfaulst with v7 +-#endif ++ cinfo.do_fancy_downsampling = FALSE; // Fix segfault with v7 ++#endif + cinfo.comp_info[0].h_samp_factor = 2; + cinfo.comp_info[0].v_samp_factor = 2; + cinfo.comp_info[1].h_samp_factor = 1; +@@ -250,15 +588,17 @@ static void put_jpeg_yuv420p_file(FILE * + jpeg_set_quality(&cinfo, quality, TRUE); + cinfo.dct_method = JDCT_FASTEST; + +- jpeg_stdio_dest(&cinfo, fp); // data written to file ++ jpeg_stdio_dest(&cinfo, fp); // Data written to file + jpeg_start_compress(&cinfo, TRUE); + ++ put_jpeg_exif(&cinfo, cnt, tm, box); ++ + for (j = 0; j < height; j += 16) { + for (i = 0; i < 16; i++) { + y[i] = image + width * (i + j); + if (i % 2 == 0) { + cb[i / 2] = image + width * height + width / 2 * ((i + j) / 2); +- cr[i / 2] = image + width * height + width * height / 4 + width / 2 * ((i + j) /2); ++ cr[i / 2] = image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); + } + } + jpeg_write_raw_data(&cinfo, data, 16); +@@ -269,14 +609,18 @@ static void put_jpeg_yuv420p_file(FILE * + } + + +-/* put_jpeg_grey_file converts an greyscale image to a jpeg image and writes +- * it to an already open file. ++/** ++ * put_jpeg_grey_file ++ * Converts an greyscale image to a jpeg image and writes ++ * it to an already open file. ++ * + * Inputs: + * - image is the image in greyscale format. + * - width and height are the dimensions of the image + * - quality is the jpeg encoding quality 0-100% + * Output: + * - The jpeg is written directly to the file given by the file pointer fp ++ * + * Returns nothing + */ + static void put_jpeg_grey_file(FILE *picture, unsigned char *image, int width, int height, int quality) +@@ -290,7 +634,7 @@ static void put_jpeg_grey_file(FILE *pic + jpeg_create_compress(&cjpeg); + cjpeg.image_width = width; + cjpeg.image_height = height; +- cjpeg.input_components = 1; /* one colour component */ ++ cjpeg.input_components = 1; /* One colour component */ + cjpeg.in_color_space = JCS_GRAYSCALE; + + jpeg_set_defaults(&cjpeg); +@@ -301,6 +645,8 @@ static void put_jpeg_grey_file(FILE *pic + + jpeg_start_compress(&cjpeg, TRUE); + ++ put_jpeg_exif(&cjpeg, NULL, NULL, NULL); ++ + row_ptr[0] = image; + + for (y = 0; y < height; y++) { +@@ -313,13 +659,17 @@ static void put_jpeg_grey_file(FILE *pic + } + + +-/* put_ppm_bgr24_file converts an greyscale image to a PPM image and writes +- * it to an already open file. ++/** ++ * put_ppm_bgr24_file ++ * Converts an greyscale image to a PPM image and writes ++ * it to an already open file. + * Inputs: + * - image is the image in YUV420P format. + * - width and height are the dimensions of the image ++ * + * Output: + * - The PPM is written directly to the file given by the file pointer fp ++ * + * Returns nothing + */ + static void put_ppm_bgr24_file(FILE *picture, unsigned char *image, int width, int height) +@@ -329,25 +679,25 @@ static void put_ppm_bgr24_file(FILE *pic + unsigned char *u = image + width * height; + unsigned char *v = u + (width * height) / 4; + int r, g, b; +- int warningkiller; + unsigned char rgb[3]; +- +- /* ppm header +- * width height +- * maxval ++ ++ /* ++ * ppm header ++ * width height ++ * maxval + */ + fprintf(picture, "P6\n"); + fprintf(picture, "%d %d\n", width, height); + fprintf(picture, "%d\n", 255); + for (y = 0; y < height; y++) { +- ++ + for (x = 0; x < width; x++) { +- r = 76283* (((int)*l) - 16) + 104595 * (((int)*u) - 128); +- g = 76283* (((int)*l) - 16)- 53281 * (((int)*u) - 128)-25625*(((int)*v)-128); +- b = 76283* (((int)*l) - 16) + 132252 * (((int)*v) - 128); +- r = r>>16; +- g = g>>16; +- b = b>>16; ++ r = 76283 * (((int)*l) - 16)+104595*(((int)*u) - 128); ++ g = 76283 * (((int)*l) - 16)- 53281*(((int)*u) - 128) - 25625 * (((int)*v) - 128); ++ b = 76283 * (((int)*l) - 16) + 132252 * (((int)*v) - 128); ++ r = r >> 16; ++ g = g >> 16; ++ b = b >> 16; + if (r < 0) + r = 0; + else if (r > 255) +@@ -371,7 +721,7 @@ static void put_ppm_bgr24_file(FILE *pic + v++; + } + /* ppm is rgb not bgr */ +- warningkiller = fwrite(rgb, 1, 3, picture); ++ fwrite(rgb, 1, 3, picture); + } + if (y & 1) { + u -= width / 2; +@@ -380,97 +730,131 @@ static void put_ppm_bgr24_file(FILE *pic + } + } + +-/* copy smartmask as an overlay into motion images and movies */ ++/** ++ * overlay_smartmask ++ * Copies smartmask as an overlay into motion images and movies. ++ * ++ * Returns nothing. ++ */ + void overlay_smartmask(struct context *cnt, unsigned char *out) + { + int i, x, v, width, height, line; + struct images *imgs = &cnt->imgs; + unsigned char *smartmask = imgs->smartmask_final; + unsigned char *out_y, *out_u, *out_v; +- ++ + i = imgs->motionsize; + v = i + ((imgs->motionsize) / 4); + width = imgs->width; + height = imgs->height; + +- /* set V to 255 to make smartmask appear red */ ++ /* Set V to 255 to make smartmask appear red. */ + out_v = out + v; + out_u = out + i; +- for (i = 0; i < height; i += 2){ ++ for (i = 0; i < height; i += 2) { + line = i * width; +- for (x = 0; x < width; x += 2){ +- if (smartmask[line + x] == 0 || +- smartmask[line + x + 1] == 0 || ++ for (x = 0; x < width; x += 2) { ++ if (smartmask[line + x] == 0 || smartmask[line + x + 1] == 0 || + smartmask[line + width + x] == 0 || +- smartmask[line + width + x + 1] == 0){ +- *out_v = 255; +- *out_u = 128; ++ smartmask[line + width + x + 1] == 0) { ++ ++ *out_v = 255; ++ *out_u = 128; + } + out_v++; + out_u++; + } + } + out_y = out; +- /* set colour intensity for smartmask */ +- for (i = 0; i < imgs->motionsize; i++){ ++ /* Set colour intensity for smartmask. */ ++ for (i = 0; i < imgs->motionsize; i++) { + if (smartmask[i] == 0) + *out_y = 0; + out_y++; + } + } + +-/* copy fixed mask as an overlay into motion images and movies */ ++/** ++ * overlay_fixed_mask ++ * Copies fixed mask as green overlay into motion images and movies. ++ * ++ * Returns nothing. ++ */ + void overlay_fixed_mask(struct context *cnt, unsigned char *out) + { +- int i; ++ int i, x, v, width, height, line; + struct images *imgs = &cnt->imgs; +- unsigned char *motion_img = imgs->out; + unsigned char *mask = imgs->mask; +- int pixel; +- +- /* set y to mask + motion-pixel to keep motion pixels visible on grey background*/ +- for (i = 0; i < imgs->motionsize; i++){ +- pixel = 255 - mask[i] + motion_img[i]; +- if (pixel > 255) +- *out = 255; +- else +- *out = pixel; +- out++; ++ unsigned char *out_y, *out_u, *out_v; ++ ++ i = imgs->motionsize; ++ v = i + ((imgs->motionsize) / 4); ++ width = imgs->width; ++ height = imgs->height; ++ ++ /* Set U and V to 0 to make fixed mask appear green. */ ++ out_v = out + v; ++ out_u = out + i; ++ for (i = 0; i < height; i += 2) { ++ line = i * width; ++ for (x = 0; x < width; x += 2) { ++ if (mask[line + x] == 0 || mask[line + x + 1] == 0 || ++ mask[line + width + x] == 0 || ++ mask[line + width + x + 1] == 0) { ++ ++ *out_v = 0; ++ *out_u = 0; ++ } ++ out_v++; ++ out_u++; ++ } ++ } ++ out_y = out; ++ /* Set colour intensity for mask. */ ++ for (i = 0; i < imgs->motionsize; i++) { ++ if (mask[i] == 0) ++ *out_y = 0; ++ out_y++; + } + } + +-/* copy largest label as an overlay into motion images and movies */ ++/** ++ * overlay_largest_label ++ * Copies largest label as an overlay into motion images and movies. ++ * ++ * Returns nothing. ++ */ + void overlay_largest_label(struct context *cnt, unsigned char *out) + { + int i, x, v, width, height, line; + struct images *imgs = &cnt->imgs; + int *labels = imgs->labels; + unsigned char *out_y, *out_u, *out_v; +- ++ + i = imgs->motionsize; + v = i + ((imgs->motionsize) / 4); + width = imgs->width; + height = imgs->height; + +- /* set U to 255 to make label appear blue */ ++ /* Set U to 255 to make label appear blue. */ + out_u = out + i; + out_v = out + v; +- for (i = 0; i < height; i += 2){ ++ for (i = 0; i < height; i += 2) { + line = i * width; +- for (x = 0; x < width; x += 2){ +- if (labels[line + x] & 32768 || +- labels[line + x + 1] & 32768 || ++ for (x = 0; x < width; x += 2) { ++ if (labels[line + x] & 32768 || labels[line + x + 1] & 32768 || + labels[line + width + x] & 32768 || + labels[line + width + x + 1] & 32768) { +- *out_u = 255; +- *out_v = 128; ++ ++ *out_u = 255; ++ *out_v = 128; + } + out_u++; + out_v++; + } + } + out_y = out; +- /* set intensity for coloured label to have better visibility */ ++ /* Set intensity for coloured label to have better visibility. */ + for (i = 0; i < imgs->motionsize; i++) { + if (*labels++ & 32768) + *out_y = 0; +@@ -478,30 +862,35 @@ void overlay_largest_label(struct contex + } + } + +-/* put_picture_mem is used for the webcam feature. Depending on the image type +- * (colour YUV420P or greyscale) the corresponding put_jpeg_X_memory function is called. ++/** ++ * put_picture_mem ++ * Is used for the webcam feature. Depending on the image type ++ * (colour YUV420P or greyscale) the corresponding put_jpeg_X_memory function is called. + * Inputs: + * - cnt is the global context struct and only cnt->imgs.type is used. + * - image_size is the size of the input image buffer + * - *image points to the image buffer that contains the YUV420P or Grayscale image about to be put + * - quality is the jpeg quality setting from the config file. ++ * + * Output: + * - **dest_image is a pointer to a pointer that points to the destination buffer in which the + * converted image it put +- * Function returns the dest_image_size if successful. Otherwise 0. +- */ ++ * ++ * Returns the dest_image_size if successful. Otherwise 0. ++ */ + int put_picture_memory(struct context *cnt, unsigned char* dest_image, int image_size, + unsigned char *image, int quality) + { + switch (cnt->imgs.type) { + case VIDEO_PALETTE_YUV420P: + return put_jpeg_yuv420p_memory(dest_image, image_size, image, +- cnt->imgs.width, cnt->imgs.height, quality); ++ cnt->imgs.width, cnt->imgs.height, quality, cnt, &(cnt->current_image->timestamp_tm), &(cnt->current_image->location)); + case VIDEO_PALETTE_GREY: + return put_jpeg_grey_memory(dest_image, image_size, image, + cnt->imgs.width, cnt->imgs.height, quality); + default: +- motion_log(LOG_ERR, 0, "Unknow image type %d", cnt->imgs.type); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknow image type %d", ++ cnt->imgs.type); + } + + return 0; +@@ -509,18 +898,19 @@ int put_picture_memory(struct context *c + + void put_picture_fd(struct context *cnt, FILE *picture, unsigned char *image, int quality) + { +- if (cnt->conf.ppm) { ++ if (cnt->imgs.picture_type == IMAGE_TYPE_PPM) { + put_ppm_bgr24_file(picture, image, cnt->imgs.width, cnt->imgs.height); + } else { + switch (cnt->imgs.type) { + case VIDEO_PALETTE_YUV420P: +- put_jpeg_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); ++ put_jpeg_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality, cnt, &(cnt->current_image->timestamp_tm), &(cnt->current_image->location)); + break; + case VIDEO_PALETTE_GREY: + put_jpeg_grey_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); + break; +- default : +- motion_log(LOG_ERR, 0, "Unknow image type %d", cnt->imgs.type); ++ default: ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknow image type %d", ++ cnt->imgs.type); + } + } + } +@@ -530,61 +920,67 @@ void put_picture(struct context *cnt, ch + { + FILE *picture; + +- picture = myfopen(file, "w"); ++ picture = myfopen(file, "w", BUFSIZE_1MEG); + if (!picture) { +- /* Report to syslog - suggest solution if the problem is access rights to target dir */ ++ /* Report to syslog - suggest solution if the problem is access rights to target dir. */ + if (errno == EACCES) { +- motion_log(LOG_ERR, 1, +- "Can't write picture to file %s - check access rights to target directory", file); +- motion_log(LOG_ERR, 1, "Thread is going to finish due to this fatal error"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, ++ "%s: Can't write picture to file %s - check access rights to target directory\n" ++ "Thread is going to finish due to this fatal error", file); + cnt->finish = 1; + cnt->restart = 0; + return; + } else { +- /* If target dir is temporarily unavailable we may survive */ +- motion_log(LOG_ERR, 1, "Can't write picture to file %s", file); ++ /* If target dir is temporarily unavailable we may survive. */ ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Can't write picture to file %s", file); + return; + } + } + + put_picture_fd(cnt, picture, image, cnt->conf.quality); +- fclose(picture); ++ myfclose(picture); + event(cnt, EVENT_FILECREATE, NULL, file, (void *)(unsigned long)ftype, NULL); + } + +-/* Get the pgm file used as fixed mask */ ++/** ++ * get_pgm ++ * Get the pgm file used as fixed mask ++ * ++ */ + unsigned char *get_pgm(FILE *picture, int width, int height) + { +- int x = 0 ,y = 0, maxval; ++ int x = 0 , y = 0, maxval; + char line[256]; + unsigned char *image; + +- line[255]=0; +- ++ line[255] = 0; ++ + if (!fgets(line, 255, picture)) { +- motion_log(LOG_ERR, 1, "Could not read from ppm file"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not read from ppm file"); + return NULL; + } +- ++ + if (strncmp(line, "P5", 2)) { +- motion_log(LOG_ERR, 1, "This is not a ppm file, starts with '%s'", line); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: This is not a ppm file, starts with '%s'", ++ line); + return NULL; + } +- +- /* skip comment */ ++ ++ /* Skip comment */ + line[0] = '#'; + while (line[0] == '#') + if (!fgets(line, 255, picture)) + return NULL; + +- /* check size */ ++ /* Check size */ + if (sscanf(line, "%d %d", &x, &y) != 2) { +- motion_log(LOG_ERR, 1, "Failed reading size in pgm file"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading size in pgm file"); + return NULL; + } +- ++ + if (x != width || y != height) { +- motion_log(LOG_ERR, 1, "Wrong image size %dx%d should be %dx%d", x, y, width, height); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Wrong image size %dx%d should be %dx%d", ++ x, y, width, height); + return NULL; + } + +@@ -593,119 +989,137 @@ unsigned char *get_pgm(FILE *picture, in + while (line[0] == '#') + if (!fgets(line, 255, picture)) + return NULL; +- ++ + if (sscanf(line, "%d", &maxval) != 1) { +- motion_log(LOG_ERR, 1, "Failed reading maximum value in pgm file"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading maximum value in pgm file"); + return NULL; + } +- +- /* read data */ +- ++ ++ /* Read data */ ++ + image = mymalloc(width * height); +- ++ + for (y = 0; y < height; y++) { + if ((int)fread(&image[y * width], 1, width, picture) != width) +- motion_log(LOG_ERR, 1, "Failed reading image data from pgm file"); +- ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading image data from pgm file"); ++ + for (x = 0; x < width; x++) + image[y * width + x] = (int)image[y * width + x] * 255 / maxval; +- +- } ++ ++ } + + return image; + } + +-/* If a mask file is asked for but does not exist this function +- * creates an empty mask file in the right binary pgm format and +- * and the right size - easy to edit with Gimp or similar tool. ++/** ++ * put_fixed_mask ++ * If a mask file is asked for but does not exist this function ++ * creates an empty mask file in the right binary pgm format and ++ * and the right size - easy to edit with Gimp or similar tool. ++ * ++ * Returns nothing. + */ + void put_fixed_mask(struct context *cnt, const char *file) + { + FILE *picture; + +- picture = myfopen(file, "w"); +- ++ picture = myfopen(file, "w", BUFSIZE_1MEG); + if (!picture) { +- /* Report to syslog - suggest solution if the problem is access rights to target dir */ ++ /* Report to syslog - suggest solution if the problem is access rights to target dir. */ + if (errno == EACCES) { +- motion_log(LOG_ERR, 1, +- "can't write mask file %s - check access rights to target directory", file); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, ++ "%s: can't write mask file %s - check access rights to target directory", ++ file); + } else { +- /* If target dir is temporarily unavailable we may survive */ +- motion_log(LOG_ERR, 1, "can't write mask file %s", file); ++ /* If target dir is temporarily unavailable we may survive. */ ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: can't write mask file %s", file); + } + return; + } ++ memset(cnt->imgs.out, 255, cnt->imgs.motionsize); /* Initialize to unset */ + +- memset(cnt->imgs.out, 255, cnt->imgs.motionsize); /* initialize to unset */ +- +- /* Write pgm-header */ ++ /* Write pgm-header. */ + fprintf(picture, "P5\n"); + fprintf(picture, "%d %d\n", cnt->conf.width, cnt->conf.height); + fprintf(picture, "%d\n", 255); +- +- /* write pgm image data at once */ ++ ++ /* Write pgm image data at once. */ + if ((int)fwrite(cnt->imgs.out, cnt->conf.width, cnt->conf.height, picture) != cnt->conf.height) { +- motion_log(LOG_ERR, 1, "Failed writing default mask as pgm file"); ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed writing default mask as pgm file"); + return; + } +- +- fclose(picture); + +- motion_log(LOG_ERR, 0, "Creating empty mask %s",cnt->conf.mask_file); +- motion_log(LOG_ERR, 0, "Please edit this file and re-run motion to enable mask feature"); ++ myfclose(picture); ++ ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Creating empty mask %s\nPlease edit this file and " ++ "re-run motion to enable mask feature", cnt->conf.mask_file); + } + +-/* save preview_shot */ ++/** ++ * preview_save ++ * save preview_shot ++ * ++ * Returns nothing. ++ */ + void preview_save(struct context *cnt) + { +-#ifdef HAVE_FFMPEG +- int use_jpegpath; ++ int use_imagepath; + int basename_len; +-#endif /* HAVE_FFMPEG */ +- const char *jpegpath; ++ const char *imagepath; + char previewname[PATH_MAX]; + char filename[PATH_MAX]; + struct image_data *saved_current_image; + + if (cnt->imgs.preview_image.diffs) { +- /* Save current global context */ ++ /* Save current global context. */ + saved_current_image = cnt->current_image; +- /* Set global context to the image we are processing */ ++ /* Set global context to the image we are processing. */ + cnt->current_image = &cnt->imgs.preview_image; + ++ /* Use filename of movie i.o. jpeg_filename when set to 'preview'. */ ++ use_imagepath = strcmp(cnt->conf.imagepath, "preview"); ++ + #ifdef HAVE_FFMPEG +- /* Use filename of movie i.o. jpeg_filename when set to 'preview' */ +- use_jpegpath = strcmp(cnt->conf.jpegpath, "preview"); +- +- if (cnt->ffmpeg_new && !use_jpegpath) { +- /* 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) { ++#else ++ if ((cnt->conf.useextpipe && cnt->extpipe) && !use_imagepath) { ++#endif ++ 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 */ +- { +- /* Save best preview-shot also when no movies are recorded or jpegpath +- * is used. Filename has to be generated - nothing available to reuse! */ +- //printf("preview_shot: different filename or picture only!\n"); +- +- /* conf.jpegpath would normally be defined but if someone deleted it by control interface +- * it is better to revert to the default than fail */ +- if (cnt->conf.jpegpath) +- jpegpath = cnt->conf.jpegpath; ++ } else { ++ /* ++ * Save best preview-shot also when no movies are recorded or imagepath ++ * is used. Filename has to be generated - nothing available to reuse! ++ */ ++ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: different filename or picture only!"); ++ /* ++ * conf.imagepath would normally be defined but if someone deleted it by ++ * control interface it is better to revert to the default than fail. ++ */ ++ if (cnt->conf.imagepath) ++ imagepath = cnt->conf.imagepath; + else +- jpegpath = (char *)DEF_JPEGPATH; +- +- mystrftime(cnt, filename, sizeof(filename), jpegpath, &cnt->imgs.preview_image.timestamp_tm, NULL, 0); ++ imagepath = (char *)DEF_IMAGEPATH; ++ ++ mystrftime(cnt, filename, sizeof(filename), imagepath, &cnt->imgs.preview_image.timestamp_tm, NULL, 0); + snprintf(previewname, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filename, imageext(cnt)); + + put_picture(cnt, previewname, cnt->imgs.preview_image.image, FTYPE_IMAGE); + } + +- /* restore global context values */ ++ /* Restore global context values. */ + cnt->current_image = saved_current_image; + } + } +--- motion-3.2.12.orig/picture.h ++++ motion-3.2.12/picture.h +@@ -18,7 +18,7 @@ void put_fixed_mask(struct context *, co + void overlay_largest_label(struct context *, unsigned char *); + void put_picture_fd(struct context *, FILE *, unsigned char *, int); + int put_picture_memory(struct context *, unsigned char*, int, unsigned char *, int); +-void put_picture(struct context *, char *, unsigned char *, int ); ++void put_picture(struct context *, char *, unsigned char *, int); + unsigned char *get_pgm(FILE *, int, int); + void preview_save(struct context *); + +--- motion-3.2.12.orig/pwc-ioctl.h ++++ motion-3.2.12/pwc-ioctl.h +@@ -45,11 +45,11 @@ + specified in the Video4Linux API. + + The #define names are built up like follows: +- VIDIOC VIDeo IOCtl prefix +- PWC Philps WebCam ++ VIDIOC VIDeo IOCtl prefix ++ PWC Philps WebCam + G optional: Get + S optional: Set +- ... the function ++ ... the function + */ + + #if (!defined(BSD)) +@@ -64,13 +64,13 @@ typedef __u16 __le16; + #endif /* ( !BSD ) */ + + /* Enumeration of image sizes */ +-#define PSZ_SQCIF 0x00 +-#define PSZ_QSIF 0x01 +-#define PSZ_QCIF 0x02 +-#define PSZ_SIF 0x03 +-#define PSZ_CIF 0x04 +-#define PSZ_VGA 0x05 +-#define PSZ_MAX 6 ++#define PSZ_SQCIF 0x00 ++#define PSZ_QSIF 0x01 ++#define PSZ_QCIF 0x02 ++#define PSZ_SIF 0x03 ++#define PSZ_CIF 0x04 ++#define PSZ_VGA 0x05 ++#define PSZ_MAX 6 + + + /* The frame rate is encoded in the video_window.flags parameter using +@@ -82,40 +82,40 @@ typedef __u16 __le16; + In 'Snapshot' mode the camera freezes its automatic exposure and colour + balance controls. + */ +-#define PWC_FPS_SHIFT 16 +-#define PWC_FPS_MASK 0x00FF0000 +-#define PWC_FPS_FRMASK 0x003F0000 +-#define PWC_FPS_SNAPSHOT 0x00400000 +-#define PWC_QLT_MASK 0x03000000 +-#define PWC_QLT_SHIFT 24 ++#define PWC_FPS_SHIFT 16 ++#define PWC_FPS_MASK 0x00FF0000 ++#define PWC_FPS_FRMASK 0x003F0000 ++#define PWC_FPS_SNAPSHOT 0x00400000 ++#define PWC_QLT_MASK 0x03000000 ++#define PWC_QLT_SHIFT 24 + + + /* structure for transferring x & y coordinates */ + struct pwc_coord + { +- int x, y; /* guess what */ +- int size; /* size, or offset */ ++ int x, y; /* guess what */ ++ int size; /* size, or offset */ + }; + + + /* Used with VIDIOCPWCPROBE */ + struct pwc_probe + { +- char name[32]; +- int type; ++ char name[32]; ++ int type; + }; + + struct pwc_serial + { +- char serial[30]; /* String with serial number. Contains terminating 0 */ ++ char serial[30]; /* String with serial number. Contains terminating 0 */ + }; +- ++ + /* pwc_whitebalance.mode values */ +-#define PWC_WB_INDOOR 0 +-#define PWC_WB_OUTDOOR 1 +-#define PWC_WB_FL 2 +-#define PWC_WB_MANUAL 3 +-#define PWC_WB_AUTO 4 ++#define PWC_WB_INDOOR 0 ++#define PWC_WB_OUTDOOR 1 ++#define PWC_WB_FL 2 ++#define PWC_WB_MANUAL 3 ++#define PWC_WB_AUTO 4 + + /* Used with VIDIOCPWC[SG]AWB (Auto White Balance). + Set mode to one of the PWC_WB_* values above. +@@ -127,9 +127,9 @@ struct pwc_serial + */ + struct pwc_whitebalance + { +- int mode; +- int manual_red, manual_blue; /* R/W */ +- int read_red, read_blue; /* R/O */ ++ int mode; ++ int manual_red, manual_blue; /* R/W */ ++ int read_red, read_blue; /* R/O */ + }; + + /* +@@ -139,29 +139,29 @@ struct pwc_whitebalance + */ + struct pwc_wb_speed + { +- int control_speed; +- int control_delay; ++ int control_speed; ++ int control_delay; + + }; + + /* Used with VIDIOCPWC[SG]LED */ + struct pwc_leds + { +- int led_on; /* Led on-time; range = 0..25000 */ +- int led_off; /* Led off-time; range = 0..25000 */ ++ int led_on; /* Led on-time; range = 0..25000 */ ++ int led_off; /* Led off-time; range = 0..25000 */ + }; + + /* Image size (used with GREALSIZE) */ + struct pwc_imagesize + { +- int width; +- int height; ++ int width; ++ int height; + }; + + /* Defines and structures for Motorized Pan & Tilt */ +-#define PWC_MPT_PAN 0x01 +-#define PWC_MPT_TILT 0x02 +-#define PWC_MPT_TIMEOUT 0x04 /* for status */ ++#define PWC_MPT_PAN 0x01 ++#define PWC_MPT_TILT 0x02 ++#define PWC_MPT_TIMEOUT 0x04 /* for status */ + + /* Set angles; when absolute != 0, the angle is absolute and the + driver calculates the relative offset for you. This can only +@@ -170,24 +170,24 @@ struct pwc_imagesize + */ + struct pwc_mpt_angles + { +- int absolute; /* write-only */ +- int pan; /* degrees * 100 */ +- int tilt; /* degress * 100 */ ++ int absolute; /* write-only */ ++ int pan; /* degrees * 100 */ ++ int tilt; /* degress * 100 */ + }; + + /* Range of angles of the camera, both horizontally and vertically. + */ + struct pwc_mpt_range + { +- int pan_min, pan_max; /* degrees * 100 */ +- int tilt_min, tilt_max; ++ int pan_min, pan_max; /* degrees * 100 */ ++ int tilt_min, tilt_max; + }; + + struct pwc_mpt_status + { +- int status; +- int time_pan; +- int time_tilt; ++ int status; ++ int time_pan; ++ int time_tilt; + }; + + +@@ -197,30 +197,30 @@ struct pwc_mpt_status + */ + struct pwc_video_command + { +- int type; /* camera type (645, 675, 730, etc.) */ +- int release; /* release number */ ++ int type; /* camera type (645, 675, 730, etc.) */ ++ int release; /* release number */ + +- int size; /* one of PSZ_* */ +- int alternate; +- int command_len; /* length of USB video command */ +- unsigned char command_buf[13]; /* Actual USB video command */ +- int bandlength; /* >0 = compressed */ +- int frame_size; /* Size of one (un)compressed frame */ ++ int size; /* one of PSZ_* */ ++ int alternate; ++ int command_len; /* length of USB video command */ ++ unsigned char command_buf[13]; /* Actual USB video command */ ++ int bandlength; /* >0 = compressed */ ++ int frame_size; /* Size of one (un)compressed frame */ + }; + + /* Flags for PWCX subroutines. Not all modules honour all flags. */ +-#define PWCX_FLAG_PLANAR 0x0001 +-#define PWCX_FLAG_BAYER 0x0008 ++#define PWCX_FLAG_PLANAR 0x0001 ++#define PWCX_FLAG_BAYER 0x0008 + + + /* IOCTL definitions */ + + /* Restore user settings */ +-#define VIDIOCPWCRUSER _IO('v', 192) ++#define VIDIOCPWCRUSER _IO('v', 192) + /* Save user settings */ +-#define VIDIOCPWCSUSER _IO('v', 193) ++#define VIDIOCPWCSUSER _IO('v', 193) + /* Restore factory settings */ +-#define VIDIOCPWCFACTORY _IO('v', 194) ++#define VIDIOCPWCFACTORY _IO('v', 194) + + /* You can manipulate the compression factor. A compression preference of 0 + means use uncompressed modes when available; 1 is low compression, 2 is +@@ -230,13 +230,13 @@ struct pwc_video_command + the preferred mode is not available. + */ + /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ +-#define VIDIOCPWCSCQUAL _IOW('v', 195, int) ++#define VIDIOCPWCSCQUAL _IOW('v', 195, int) + /* Get preferred compression quality */ +-#define VIDIOCPWCGCQUAL _IOR('v', 195, int) ++#define VIDIOCPWCGCQUAL _IOR('v', 195, int) + + + /* Retrieve serial number of camera */ +-#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) ++#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) + + /* This is a probe function; since so many devices are supported, it + becomes difficult to include all the names in programs that want to +@@ -248,61 +248,60 @@ struct pwc_video_command + same. If so, you can be assured it is a Philips (OEM) cam and the type + is valid. + */ +-#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) ++#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) + + /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ +-#define VIDIOCPWCSAGC _IOW('v', 200, int) ++#define VIDIOCPWCSAGC _IOW('v', 200, int) + /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ +-#define VIDIOCPWCGAGC _IOR('v', 200, int) ++#define VIDIOCPWCGAGC _IOR('v', 200, int) + /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ +-#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) ++#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) + + /* Color compensation (Auto White Balance) */ +-#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) +-#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) ++#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) ++#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) + + /* Auto WB speed */ +-#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) +-#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) ++#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) ++#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) + + /* LEDs on/off/blink; int range 0..65535 */ +-#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) +-#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) ++#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) ++#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) + + /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ +-#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) +-#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) ++#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) ++#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) + + /* Backlight compensation; 0 = off, otherwise on */ +-#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) +-#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) ++#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) ++#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) + + /* Flickerless mode; = 0 off, otherwise on */ +-#define VIDIOCPWCSFLICKER _IOW('v', 208, int) +-#define VIDIOCPWCGFLICKER _IOR('v', 208, int) ++#define VIDIOCPWCSFLICKER _IOW('v', 208, int) ++#define VIDIOCPWCGFLICKER _IOR('v', 208, int) + + /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ +-#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) +-#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) ++#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) ++#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) + + /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ +-#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) ++#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) + + /* Motorized pan & tilt functions */ +-#define VIDIOCPWCMPTRESET _IOW('v', 211, int) +-#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) +-#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) +-#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) +-#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) ++#define VIDIOCPWCMPTRESET _IOW('v', 211, int) ++#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) ++#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) ++#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) ++#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) + + /* Get the USB set-video command; needed for initializing libpwcx */ +-#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) ++#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) + struct pwc_table_init_buffer { + int len; + char *buffer; +- + }; +-#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) ++#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) + + /* + * This is private command used when communicating with v4l2. +@@ -323,13 +322,13 @@ struct pwc_table_init_buffer { + #define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8) + + struct pwc_raw_frame { +- __le16 type; /* type of the webcam */ +- __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ +- __u8 cmd[4]; /* the four byte of the command (in case of nala, +- only the first 3 bytes is filled) */ +- __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ ++ __le16 type; /* type of the webcam */ ++ __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ ++ __u8 cmd[4]; /* the four byte of the command (in case of nala, ++ only the first 3 bytes is filled) */ ++ __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ + } __attribute__ ((packed)); + +-#endif /* MOTION_V4L2 && (! BSD ) */ ++#endif /* MOTION_V4L2 && (! BSD ) */ + + #endif +--- motion-3.2.12.orig/pwc-ioctl.h-10.0.10 ++++ motion-3.2.12/pwc-ioctl.h-10.0.10 +@@ -45,13 +45,14 @@ + specified in the Video4Linux API. + + The #define names are built up like follows: +- VIDIOC VIDeo IOCtl prefix +- PWC Philps WebCam ++ VIDIOC VIDeo IOCtl prefix ++ PWC Philps WebCam + G optional: Get + S optional: Set +- ... the function ++ ... the function + */ + ++#if (!defined(BSD)) + #include + #include + +@@ -60,14 +61,16 @@ + typedef __u16 __le16; + #endif + ++#endif /* ( !BSD ) */ ++ + /* Enumeration of image sizes */ +-#define PSZ_SQCIF 0x00 +-#define PSZ_QSIF 0x01 +-#define PSZ_QCIF 0x02 +-#define PSZ_SIF 0x03 +-#define PSZ_CIF 0x04 +-#define PSZ_VGA 0x05 +-#define PSZ_MAX 6 ++#define PSZ_SQCIF 0x00 ++#define PSZ_QSIF 0x01 ++#define PSZ_QCIF 0x02 ++#define PSZ_SIF 0x03 ++#define PSZ_CIF 0x04 ++#define PSZ_VGA 0x05 ++#define PSZ_MAX 6 + + + /* The frame rate is encoded in the video_window.flags parameter using +@@ -79,40 +82,40 @@ typedef __u16 __le16; + In 'Snapshot' mode the camera freezes its automatic exposure and colour + balance controls. + */ +-#define PWC_FPS_SHIFT 16 +-#define PWC_FPS_MASK 0x00FF0000 +-#define PWC_FPS_FRMASK 0x003F0000 +-#define PWC_FPS_SNAPSHOT 0x00400000 +-#define PWC_QLT_MASK 0x03000000 +-#define PWC_QLT_SHIFT 24 ++#define PWC_FPS_SHIFT 16 ++#define PWC_FPS_MASK 0x00FF0000 ++#define PWC_FPS_FRMASK 0x003F0000 ++#define PWC_FPS_SNAPSHOT 0x00400000 ++#define PWC_QLT_MASK 0x03000000 ++#define PWC_QLT_SHIFT 24 + + + /* structure for transferring x & y coordinates */ + struct pwc_coord + { +- int x, y; /* guess what */ +- int size; /* size, or offset */ ++ int x, y; /* guess what */ ++ int size; /* size, or offset */ + }; + + + /* Used with VIDIOCPWCPROBE */ + struct pwc_probe + { +- char name[32]; +- int type; ++ char name[32]; ++ int type; + }; + + struct pwc_serial + { +- char serial[30]; /* String with serial number. Contains terminating 0 */ ++ char serial[30]; /* String with serial number. Contains terminating 0 */ + }; +- ++ + /* pwc_whitebalance.mode values */ +-#define PWC_WB_INDOOR 0 +-#define PWC_WB_OUTDOOR 1 +-#define PWC_WB_FL 2 +-#define PWC_WB_MANUAL 3 +-#define PWC_WB_AUTO 4 ++#define PWC_WB_INDOOR 0 ++#define PWC_WB_OUTDOOR 1 ++#define PWC_WB_FL 2 ++#define PWC_WB_MANUAL 3 ++#define PWC_WB_AUTO 4 + + /* Used with VIDIOCPWC[SG]AWB (Auto White Balance). + Set mode to one of the PWC_WB_* values above. +@@ -124,9 +127,9 @@ struct pwc_serial + */ + struct pwc_whitebalance + { +- int mode; +- int manual_red, manual_blue; /* R/W */ +- int read_red, read_blue; /* R/O */ ++ int mode; ++ int manual_red, manual_blue; /* R/W */ ++ int read_red, read_blue; /* R/O */ + }; + + /* +@@ -136,29 +139,29 @@ struct pwc_whitebalance + */ + struct pwc_wb_speed + { +- int control_speed; +- int control_delay; ++ int control_speed; ++ int control_delay; + + }; + + /* Used with VIDIOCPWC[SG]LED */ + struct pwc_leds + { +- int led_on; /* Led on-time; range = 0..25000 */ +- int led_off; /* Led off-time; range = 0..25000 */ ++ int led_on; /* Led on-time; range = 0..25000 */ ++ int led_off; /* Led off-time; range = 0..25000 */ + }; + + /* Image size (used with GREALSIZE) */ + struct pwc_imagesize + { +- int width; +- int height; ++ int width; ++ int height; + }; + + /* Defines and structures for Motorized Pan & Tilt */ +-#define PWC_MPT_PAN 0x01 +-#define PWC_MPT_TILT 0x02 +-#define PWC_MPT_TIMEOUT 0x04 /* for status */ ++#define PWC_MPT_PAN 0x01 ++#define PWC_MPT_TILT 0x02 ++#define PWC_MPT_TIMEOUT 0x04 /* for status */ + + /* Set angles; when absolute != 0, the angle is absolute and the + driver calculates the relative offset for you. This can only +@@ -167,24 +170,24 @@ struct pwc_imagesize + */ + struct pwc_mpt_angles + { +- int absolute; /* write-only */ +- int pan; /* degrees * 100 */ +- int tilt; /* degress * 100 */ ++ int absolute; /* write-only */ ++ int pan; /* degrees * 100 */ ++ int tilt; /* degress * 100 */ + }; + + /* Range of angles of the camera, both horizontally and vertically. + */ + struct pwc_mpt_range + { +- int pan_min, pan_max; /* degrees * 100 */ +- int tilt_min, tilt_max; ++ int pan_min, pan_max; /* degrees * 100 */ ++ int tilt_min, tilt_max; + }; + + struct pwc_mpt_status + { +- int status; +- int time_pan; +- int time_tilt; ++ int status; ++ int time_pan; ++ int time_tilt; + }; + + +@@ -194,30 +197,30 @@ struct pwc_mpt_status + */ + struct pwc_video_command + { +- int type; /* camera type (645, 675, 730, etc.) */ +- int release; /* release number */ ++ int type; /* camera type (645, 675, 730, etc.) */ ++ int release; /* release number */ + +- int size; /* one of PSZ_* */ +- int alternate; +- int command_len; /* length of USB video command */ +- unsigned char command_buf[13]; /* Actual USB video command */ +- int bandlength; /* >0 = compressed */ +- int frame_size; /* Size of one (un)compressed frame */ ++ int size; /* one of PSZ_* */ ++ int alternate; ++ int command_len; /* length of USB video command */ ++ unsigned char command_buf[13]; /* Actual USB video command */ ++ int bandlength; /* >0 = compressed */ ++ int frame_size; /* Size of one (un)compressed frame */ + }; + + /* Flags for PWCX subroutines. Not all modules honour all flags. */ +-#define PWCX_FLAG_PLANAR 0x0001 +-#define PWCX_FLAG_BAYER 0x0008 ++#define PWCX_FLAG_PLANAR 0x0001 ++#define PWCX_FLAG_BAYER 0x0008 + + + /* IOCTL definitions */ + + /* Restore user settings */ +-#define VIDIOCPWCRUSER _IO('v', 192) ++#define VIDIOCPWCRUSER _IO('v', 192) + /* Save user settings */ +-#define VIDIOCPWCSUSER _IO('v', 193) ++#define VIDIOCPWCSUSER _IO('v', 193) + /* Restore factory settings */ +-#define VIDIOCPWCFACTORY _IO('v', 194) ++#define VIDIOCPWCFACTORY _IO('v', 194) + + /* You can manipulate the compression factor. A compression preference of 0 + means use uncompressed modes when available; 1 is low compression, 2 is +@@ -227,13 +230,13 @@ struct pwc_video_command + the preferred mode is not available. + */ + /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ +-#define VIDIOCPWCSCQUAL _IOW('v', 195, int) ++#define VIDIOCPWCSCQUAL _IOW('v', 195, int) + /* Get preferred compression quality */ +-#define VIDIOCPWCGCQUAL _IOR('v', 195, int) ++#define VIDIOCPWCGCQUAL _IOR('v', 195, int) + + + /* Retrieve serial number of camera */ +-#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) ++#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) + + /* This is a probe function; since so many devices are supported, it + becomes difficult to include all the names in programs that want to +@@ -245,61 +248,60 @@ struct pwc_video_command + same. If so, you can be assured it is a Philips (OEM) cam and the type + is valid. + */ +-#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) ++#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) + + /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ +-#define VIDIOCPWCSAGC _IOW('v', 200, int) ++#define VIDIOCPWCSAGC _IOW('v', 200, int) + /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ +-#define VIDIOCPWCGAGC _IOR('v', 200, int) ++#define VIDIOCPWCGAGC _IOR('v', 200, int) + /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ +-#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) ++#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) + + /* Color compensation (Auto White Balance) */ +-#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) +-#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) ++#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) ++#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) + + /* Auto WB speed */ +-#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) +-#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) ++#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) ++#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) + + /* LEDs on/off/blink; int range 0..65535 */ +-#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) +-#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) ++#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) ++#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) + + /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ +-#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) +-#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) ++#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) ++#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) + + /* Backlight compensation; 0 = off, otherwise on */ +-#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) +-#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) ++#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) ++#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) + + /* Flickerless mode; = 0 off, otherwise on */ +-#define VIDIOCPWCSFLICKER _IOW('v', 208, int) +-#define VIDIOCPWCGFLICKER _IOR('v', 208, int) ++#define VIDIOCPWCSFLICKER _IOW('v', 208, int) ++#define VIDIOCPWCGFLICKER _IOR('v', 208, int) + + /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ +-#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) +-#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) ++#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) ++#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) + + /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ +-#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) ++#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) + + /* Motorized pan & tilt functions */ +-#define VIDIOCPWCMPTRESET _IOW('v', 211, int) +-#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) +-#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) +-#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) +-#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) ++#define VIDIOCPWCMPTRESET _IOW('v', 211, int) ++#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) ++#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) ++#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) ++#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) + + /* Get the USB set-video command; needed for initializing libpwcx */ +-#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) ++#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) + struct pwc_table_init_buffer { + int len; + char *buffer; +- + }; +-#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) ++#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) + + /* + * This is private command used when communicating with v4l2. +@@ -307,6 +309,8 @@ struct pwc_table_init_buffer { + * use interface offer by v4l2. + */ + ++#if (defined(MOTION_V4L2)) && (!defined(BSD)) ++ + #define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0) + #define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1) + #define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2) +@@ -318,12 +322,13 @@ struct pwc_table_init_buffer { + #define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8) + + struct pwc_raw_frame { +- __le16 type; /* type of the webcam */ +- __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ +- __u8 cmd[4]; /* the four byte of the command (in case of nala, +- only the first 3 bytes is filled) */ +- __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ ++ __le16 type; /* type of the webcam */ ++ __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ ++ __u8 cmd[4]; /* the four byte of the command (in case of nala, ++ only the first 3 bytes is filled) */ ++ __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ + } __attribute__ ((packed)); + ++#endif /* MOTION_V4L2 && (! BSD ) */ + + #endif +--- motion-3.2.12.orig/rotate.c ++++ motion-3.2.12/rotate.c +@@ -4,13 +4,13 @@ + * Module for handling image rotation. + * + * Copyright 2004-2005, Per Jonsson (per@pjd.nu) +- * ++ * + * This software is distributed under the GNU Public license + * Version 2. See also the file 'COPYING'. + * + * Image rotation is a feature of Motion that can be used when the + * camera is mounted upside-down or on the side. The module only +- * supports rotation in multiples of 90 degrees. Using rotation ++ * supports rotation in multiples of 90 degrees. Using rotation + * increases the Motion CPU usage slightly. + * + * Version history: +@@ -21,8 +21,8 @@ + * - fix for __bswap_32 macro collision + * - fixed bug where initialization would be + * incomplete for invalid degrees of rotation +- * - now uses motion_log for error reporting +- * v4 (26-Oct-2004) - new fix for width/height from imgs/conf due to ++ * - now uses MOTION_LOG for error reporting ++ * v4 (26-Oct-2004) - new fix for width/height from imgs/conf due to + * earlier misinterpretation + * v3 (11-Oct-2004) - cleanup of width/height from imgs/conf + * v2 (26-Sep-2004) - separation of capture/internal dimensions +@@ -49,30 +49,30 @@ typedef unsigned TYPE_32BIT __uint32; + + /** + * The code below is copied (with modification) from bits/byteswap.h. It provides +- * a macro/function named rot__bswap_32 that swaps the bytes in a 32-bit integer, ++ * a macro/function named rot__bswap_32 that swaps the bytes in a 32-bit integer, + * preferably using the bswap assembler instruction if configure found support + * for it. + * + * It would be neater to simply include byteswap.h and use the bswap_32 macro + * defined there, but the problem is that the bswap asm instruction would then +- * only be used for certain processor architectures, excluding athlon (and ++ * only be used for certain processor architectures, excluding athlon (and + * probably athlon64 as well). Moreover, byteswap.h doesn't seem to exist on + * FreeBSD. So, we rely on the HAVE_BSWAP macro defined by configure instead. + * +- * Note that the macro names have been prefixed with "rot" in order to avoid +- * collision since we have the include chain rotate.h -> motion.h -> netcam.h -> ++ * Note that the macro names have been prefixed with "rot" in order to avoid ++ * collision since we have the include chain rotate.h -> motion.h -> netcam.h -> + * netinet/in.h -> ... -> byteswap.h -> bits/byteswap.h. + */ + + /* Swap bytes in 32 bit value. This is used as a fallback and for constants. */ +-#define rot__bswap_constant_32(x) \ +- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ ++#define rot__bswap_constant_32(x) \ ++ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) + + #ifdef __GNUC__ + # if (__GNUC__ >= 2) && (i386 || __i386 || __i386__) +-/* We're on an Intel-compatible platform, so we can use inline Intel assembler +- * for the swapping. ++/* We're on an Intel-compatible platform, so we can use inline Intel assembler ++ * for the swapping. + */ + # ifndef HAVE_BSWAP + /* Bswap is not available, we have to use three instructions instead. */ +@@ -108,7 +108,7 @@ typedef unsigned TYPE_32BIT __uint32; + # endif + #else + /* Not a GNU compiler. */ +-static inline __uint32 rot__bswap_32(__uint32 __bsx) ++static inline __uint32 rot__bswap_32(__uint32 __bsx) + { + return __bswap_constant_32 (__bsx); + } +@@ -123,18 +123,18 @@ static inline __uint32 rot__bswap_32(__u + + /** + * reverse_inplace_quad +- * ++ * + * Reverses a block of memory in-place, 4 bytes at a time. This function + * requires the __uint32 type, which is 32 bits wide. + * + * Parameters: +- * ++ * + * src - the memory block to reverse + * size - the size (in bytes) of the memory block + * + * Returns: nothing + */ +-static void reverse_inplace_quad(unsigned char *src, int size) ++static void reverse_inplace_quad(unsigned char *src, int size) + { + __uint32 *nsrc = (__uint32 *)src; /* first quad */ + __uint32 *ndst = (__uint32 *)(src + size - 4); /* last quad */ +@@ -149,13 +149,13 @@ static void reverse_inplace_quad(unsigne + + /** + * rot90cw +- * +- * Performs a 90 degrees clockwise rotation of the memory block pointed to +- * by src. The rotation is NOT performed in-place; dst must point to a ++ * ++ * Performs a 90 degrees clockwise rotation of the memory block pointed to ++ * by src. The rotation is NOT performed in-place; dst must point to a + * receiving memory block the same size as src. + * + * Parameters: +- * ++ * + * src - pointer to the memory block (image) to rotate clockwise + * dst - where to put the rotated memory block + * size - the size (in bytes) of the memory blocks (both src and dst) +@@ -165,7 +165,7 @@ static void reverse_inplace_quad(unsigne + * Returns: nothing + */ + static void rot90cw(unsigned char *src, register unsigned char *dst, int size, +- int width, int height) ++ int width, int height) + { + unsigned char *endp; + register unsigned char *base; +@@ -174,21 +174,21 @@ static void rot90cw(unsigned char *src, + endp = src + size; + for (base = endp - width; base < endp; base++) { + src = base; +- for (j = 0; j < height; j++, src -= width) ++ for (j = 0; j < height; j++, src -= width) + *dst++ = *src; +- ++ + } + } + + /** + * rot90ccw +- * ++ * + * Performs a 90 degrees counterclockwise rotation of the memory block pointed +- * to by src. The rotation is not performed in-place; dst must point to a +- * receiving memory block the same size as src. ++ * to by src. The rotation is not performed in-place; dst must point to a ++ * receiving memory block the same size as src. + * + * Parameters: +- * ++ * + * src - pointer to the memory block (image) to rotate counterclockwise + * dst - where to put the rotated memory block + * size - the size (in bytes) of the memory blocks (both src and dst) +@@ -198,7 +198,7 @@ static void rot90cw(unsigned char *src, + * Returns: nothing + */ + static inline void rot90ccw(unsigned char *src, register unsigned char *dst, +- int size, int width, int height) ++ int size, int width, int height) + { + unsigned char *endp; + register unsigned char *base; +@@ -206,48 +206,50 @@ static inline void rot90ccw(unsigned cha + + endp = src + size; + dst = dst + size - 1; +- for(base = endp - width; base < endp; base++) { ++ for (base = endp - width; base < endp; base++) { + src = base; +- for(j = 0; j < height; j++, src -= width) ++ for (j = 0; j < height; j++, src -= width) + *dst-- = *src; +- ++ + } + } + + /** + * rotate_init +- * ++ * + * Initializes rotation data - allocates memory and determines which function + * to use for 180 degrees rotation. + * + * Parameters: +- * ++ * + * cnt - the current thread's context structure + * + * Returns: nothing + */ +-void rotate_init(struct context *cnt) ++void rotate_init(struct context *cnt) + { + int size; +- ++ + /* Make sure temp_buf isn't freed if it hasn't been allocated. */ + cnt->rotate_data.temp_buf = NULL; + +- /* Assign the value in conf.rotate_deg to rotate_data.degrees. This way, ++ /* ++ * Assign the value in conf.rotate_deg to rotate_data.degrees. This way, + * we have a value that is safe from changes caused by motion-control. + */ + if ((cnt->conf.rotate_deg % 90) > 0) { +- motion_log(LOG_ERR, 0, "Config option \"rotate\" not a multiple of 90: %d", ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Config option \"rotate\" not a multiple of 90: %d", + cnt->conf.rotate_deg); +- cnt->conf.rotate_deg = 0; /* disable rotation */ +- cnt->rotate_data.degrees = 0; /* force return below */ ++ cnt->conf.rotate_deg = 0; /* Disable rotation. */ ++ cnt->rotate_data.degrees = 0; /* Force return below. */ + } else { +- cnt->rotate_data.degrees = cnt->conf.rotate_deg % 360; /* range: 0..359 */ ++ cnt->rotate_data.degrees = cnt->conf.rotate_deg % 360; /* Range: 0..359 */ + } + +- /* Upon entrance to this function, imgs.width and imgs.height contain the +- * capture dimensions (as set in the configuration file, or read from a +- * netcam source). ++ /* ++ * Upon entrance to this function, imgs.width and imgs.height contain the ++ * capture dimensions (as set in the configuration file, or read from a ++ * netcam source). + * + * If rotating 90 or 270 degrees, the capture dimensions and output dimensions + * are not the same. Capture dimensions will be contained in cap_width and +@@ -265,86 +267,88 @@ void rotate_init(struct context *cnt) + cnt->imgs.height = cnt->rotate_data.cap_width; + } + +- /* If we're not rotating, let's exit once we have setup the capture dimensions ++ /* ++ * If we're not rotating, let's exit once we have setup the capture dimensions + * and output dimensions properly. + */ +- if (cnt->rotate_data.degrees == 0) ++ if (cnt->rotate_data.degrees == 0) + return; +- + +- switch(cnt->imgs.type) { ++ switch (cnt->imgs.type) { + case VIDEO_PALETTE_YUV420P: +- /* For YUV 4:2:0 planar, the memory block used for 90/270 degrees +- * rotation needs to be width x height x 1.5 bytes large. ++ /* ++ * For YUV 4:2:0 planar, the memory block used for 90/270 degrees ++ * rotation needs to be width x height x 1.5 bytes large. + */ + size = cnt->imgs.width * cnt->imgs.height * 3 / 2; + break; + case VIDEO_PALETTE_GREY: +- /* For greyscale, the memory block used for 90/270 degrees rotation ++ /* ++ * For greyscale, the memory block used for 90/270 degrees rotation + * needs to be width x height bytes large. + */ + size = cnt->imgs.width * cnt->imgs.height; + break; + default: + cnt->rotate_data.degrees = 0; +- motion_log(LOG_ERR, 0, "Unsupported palette (%d), rotation is disabled", +- cnt->imgs.type); ++ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unsupported palette (%d), rotation is disabled", ++ cnt->imgs.type); + return; + } + +- /* Allocate memory if rotating 90 or 270 degrees, because those rotations ++ /* ++ * Allocate memory if rotating 90 or 270 degrees, because those rotations + * cannot be performed in-place (they can, but it would be too slow). + */ +- if ((cnt->rotate_data.degrees == 90) || (cnt->rotate_data.degrees == 270)) ++ if ((cnt->rotate_data.degrees == 90) || (cnt->rotate_data.degrees == 270)) + cnt->rotate_data.temp_buf = mymalloc(size); +- + } + +-/** ++/** + * rotate_deinit +- * +- * Frees resources previously allocated by rotate_init. ++ * ++ * Frees resources previously allocated by rotate_init. + * + * Parameters: +- * ++ * + * cnt - the current thread's context structure + * + * Returns: nothing + */ +-void rotate_deinit(struct context *cnt) ++void rotate_deinit(struct context *cnt) + { +- if (cnt->rotate_data.temp_buf) ++ if (cnt->rotate_data.temp_buf) + free(cnt->rotate_data.temp_buf); +- + } + + /** + * rotate_map +- * ++ * + * Main entry point for rotation. This is the function that is called from + * video.c/video_freebsd.c to perform the rotation. + * + * Parameters: +- * ++ * + * map - pointer to the image/data to rotate + * cnt - the current thread's context structure + * +- * Returns: +- * ++ * Returns: ++ * + * 0 - success + * -1 - failure (shouldn't happen) + */ + int rotate_map(struct context *cnt, unsigned char *map) + { +- /* The image format is either YUV 4:2:0 planar, in which case the pixel ++ /* ++ * The image format is either YUV 4:2:0 planar, in which case the pixel + * data is divided in three parts: + * Y - width x height bytes + * U - width x height / 4 bytes + * V - as U +- * or, it is in greyscale, in which case the pixel data simply consists ++ * or, it is in greyscale, in which case the pixel data simply consists + * of width x height bytes. + */ +- int wh, wh4 = 0, w2 = 0, h2 = 0; /* width*height, width*height/4 etc. */ ++ int wh, wh4 = 0, w2 = 0, h2 = 0; /* width * height, width * height / 4 etc. */ + int size, deg; + int width, height; + +@@ -352,7 +356,8 @@ int rotate_map(struct context *cnt, unsi + width = cnt->rotate_data.cap_width; + height = cnt->rotate_data.cap_height; + +- /* Pre-calculate some stuff: ++ /* ++ * Pre-calculate some stuff: + * wh - size of the Y plane, or the entire greyscale image + * size - size of the entire memory block + * wh4 - size of the U plane, and the V plane +@@ -360,7 +365,6 @@ int rotate_map(struct context *cnt, unsi + * h2 - as w2, but height instead + */ + wh = width * height; +- + if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { + size = wh * 3 / 2; + wh4 = wh / 4; +@@ -372,26 +376,25 @@ int rotate_map(struct context *cnt, unsi + + switch (deg) { + case 90: +- /* first do the Y part */ ++ /* First do the Y part */ + rot90cw(map, cnt->rotate_data.temp_buf, wh, width, height); +- + if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { +- /* then do U and V */ ++ /* Then do U and V */ + rot90cw(map + wh, cnt->rotate_data.temp_buf + wh, wh4, w2, h2); + rot90cw(map + wh + wh4, cnt->rotate_data.temp_buf + wh + wh4, + wh4, w2, h2); + } +- +- /* then copy back from the temp buffer to map */ ++ ++ /* Then copy back from the temp buffer to map. */ + memcpy(map, cnt->rotate_data.temp_buf, size); + break; +- ++ + case 180: +- /* 180 degrees is easy - just reverse the data within ++ /* ++ * 180 degrees is easy - just reverse the data within + * Y, U and V. + */ + reverse_inplace_quad(map, wh); +- + if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { + reverse_inplace_quad(map + wh, wh4); + reverse_inplace_quad(map + wh + wh4, wh4); +@@ -399,25 +402,25 @@ int rotate_map(struct context *cnt, unsi + break; + + case 270: +- /* first do the Y part */ +- rot90ccw(map, cnt->rotate_data.temp_buf, wh, width, height); + ++ /* First do the Y part */ ++ rot90ccw(map, cnt->rotate_data.temp_buf, wh, width, height); + if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { +- /* then do U and V */ ++ /* Then do U and V */ + rot90ccw(map + wh, cnt->rotate_data.temp_buf + wh, wh4, w2, h2); +- rot90ccw(map + wh + wh4, cnt->rotate_data.temp_buf + wh + wh4, ++ rot90ccw(map + wh + wh4, cnt->rotate_data.temp_buf + wh + wh4, + wh4, w2, h2); + } +- +- /* then copy back from the temp buffer to map */ ++ ++ /* Then copy back from the temp buffer to map. */ + memcpy(map, cnt->rotate_data.temp_buf, size); + break; +- ++ + default: +- /* invalid */ ++ /* Invalid */ + return -1; + } +- ++ + return 0; + } + +--- /dev/null ++++ motion-3.2.12/sdl.c +@@ -0,0 +1,181 @@ ++/* ++ * sdl.c ++ * ++ * sdl functions for motion. ++ * Copyright 2009 by Peter Holik (peter@holik.at) ++ * This software is distributed under the GNU public license version 2 ++ * See also the file 'COPYING'. ++ */ ++#include "sdl.h" ++#include ++ ++static int cur_width; ++static int cur_height; ++static int is_full_screen; ++static int fs_screen_width; ++static int fs_screen_height; ++ ++static SDL_Surface *screen; ++static SDL_Overlay *overlay; ++ ++static int sdl_video_open(int width, int height) ++{ ++ int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; ++ int w,h; ++ ++ if (is_full_screen) flags |= SDL_FULLSCREEN; ++ else flags |= SDL_RESIZABLE; ++ ++ if (is_full_screen && fs_screen_width) { ++ w = fs_screen_width; ++ h = fs_screen_height; ++ } else if (width > fs_screen_width || height > fs_screen_height) { ++ w = fs_screen_width; ++ h = fs_screen_height; ++ } else { ++ w = width; ++ h = height; ++ } ++ /* 32 because framebuffer is usually initalized to 8 and ++ you have to use fbset with -depth to make it working */ ++ screen = SDL_SetVideoMode(w, h, 32, flags); ++ ++ if (!screen) { ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO,"%s: Unable to set video mode: %s", ++ SDL_GetError()); ++ return -1; ++ } ++ ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL dimension %d x %d fullscreen %d BytesPerPixel %d", ++ screen->w, screen->h, is_full_screen, ++ screen->format->BytesPerPixel); ++ ++ SDL_WM_SetCaption("motion", "motion"); ++ SDL_ShowCursor(SDL_DISABLE); ++ ++ if (cur_width != width || cur_height != height) { ++ cur_width = width; ++ cur_height = height; ++ ++ if (overlay) SDL_FreeYUVOverlay(overlay); ++ ++ overlay = SDL_CreateYUVOverlay(cur_width, cur_height, ++ SDL_YV12_OVERLAY, screen); ++ if (!overlay) { ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not create overlay: %s", ++ SDL_GetError()); ++ sdl_stop(); ++ } else ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL created %dx%dx%d %s overlay", ++ overlay->w,overlay->h,overlay->planes, ++ overlay->hw_overlay?"hardware":"software"); ++ } ++ return overlay == NULL; ++} ++ ++int sdl_start(int width, int height) ++{ ++ //putenv("SDL_NOMOUSE=1"); ++ setenv("SDL_NOMOUSE", "1", 1); ++ ++ if (screen) return 0; ++ ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL start"); ++ ++ if (SDL_Init(SDL_INIT_VIDEO)) { ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not initialize SDL - %s", ++ SDL_GetError()); ++ return -1; ++ } ++ const SDL_VideoInfo *vi = SDL_GetVideoInfo(); ++ fs_screen_width = vi->current_w; ++ fs_screen_height = vi->current_h; ++ ++ if (sdl_video_open(width, height)) return -1; ++ ++ SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); ++ SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); ++ SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); ++ SDL_EventState(SDL_USEREVENT, SDL_IGNORE); ++ SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); ++ SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); ++ SDL_EventState(SDL_KEYUP, SDL_IGNORE); ++ SDL_EventState(SDL_JOYBUTTONDOWN, SDL_IGNORE); ++ SDL_EventState(SDL_JOYBUTTONUP, SDL_IGNORE); ++ SDL_EventState(SDL_JOYAXISMOTION, SDL_IGNORE); ++ SDL_EventState(SDL_JOYBALLMOTION, SDL_IGNORE); ++ SDL_EventState(SDL_JOYHATMOTION, SDL_IGNORE); ++ SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE); ++ ++ return 0; ++} ++ ++void sdl_put(unsigned char *image, int width, int height) ++{ ++ SDL_Event event; ++ ++ if (screen && overlay) { ++ SDL_Rect rect; ++ float aspect_ratio = (float)width / height; ++ int pic_width, pic_height; ++ ++ if (width != cur_width || height != cur_height) ++ sdl_video_open(width, height); ++ ++ if (SDL_MUSTLOCK(screen)) ++ if (SDL_LockSurface(screen) < 0) return; ++ ++ SDL_LockYUVOverlay(overlay); ++ memcpy(overlay->pixels[0], image, width * height); ++ memcpy(overlay->pixels[2], image + (width * height), (width * height / 4)); ++ memcpy(overlay->pixels[1], image + (width * height * 5 / 4), (width * height / 4)); ++ SDL_UnlockYUVOverlay(overlay); ++ ++ if (SDL_MUSTLOCK(screen)) ++ SDL_UnlockSurface(screen); ++ ++ pic_height = screen->h; ++ pic_width = pic_height * aspect_ratio; ++ if (pic_width > screen->w) { ++ pic_width = screen->w; ++ pic_height = pic_width / aspect_ratio; ++ } ++ rect.x = (screen->w - pic_width) / 2; ++ rect.y = (screen->h - pic_height) / 2; ++ rect.w = pic_width; ++ rect.h = pic_height; ++ ++ if (SDL_DisplayYUVOverlay(overlay, &rect)) ++ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: SDL_DisplayYUVOverlay: %s", ++ SDL_GetError()); ++ ++ if (SDL_PollEvent(&event)) { ++ if ((event.type == SDL_QUIT || ++ (event.type == SDL_KEYDOWN && ++ event.key.keysym.sym == SDLK_ESCAPE))) ++ sdl_stop(); ++ else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_f) { ++ is_full_screen = !is_full_screen; ++ sdl_video_open(width, height); ++ } ++ else if (event.type == SDL_VIDEORESIZE) ++ screen = SDL_SetVideoMode(event.resize.w, event.resize.h, ++ screen->format->BitsPerPixel, ++ screen->flags); ++ } ++ } ++} ++ ++void sdl_stop(void) ++{ ++ if (screen) { ++ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL quit"); ++ SDL_ShowCursor(SDL_ENABLE); ++ if (overlay) { ++ SDL_FreeYUVOverlay(overlay); ++ overlay = NULL; ++ } ++ SDL_Quit(); ++ screen = NULL; ++ } ++} +--- /dev/null ++++ motion-3.2.12/sdl.h +@@ -0,0 +1,17 @@ ++/* sdl.h ++ * ++ * Include file for sdl.c ++ * Copyright 2009 by Peter Holik (peter@holik.at) ++ * This software is distributed under the GNU public license version 2 ++ * See also the file 'COPYING'. ++ */ ++#ifndef _INCLUDE_SDL_H ++#define _INCLUDE_SDL_H ++ ++#include "motion.h" ++ ++int sdl_start(int width, int height); ++void sdl_put(unsigned char *image, int width, int height); ++void sdl_stop(void); ++ ++#endif +--- /dev/null ++++ motion-3.2.12/stream.c +@@ -0,0 +1,1221 @@ ++/* ++ * stream.c (based in webcam.c) ++ * Streaming using jpeg images over a multipart/x-mixed-replace stream ++ * Copyright (C) 2002 Jeroen Vreeken (pe1rxq@amsat.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++ ++#include "md5.h" ++#include "picture.h" ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define STREAM_REALM "Motion Stream Security Access" ++#define KEEP_ALIVE_TIMEOUT 100 ++ ++typedef void* (*auth_handler)(void*); ++struct auth_param { ++ struct context *cnt; ++ int sock; ++ int sock_flags; ++ int* thread_count; ++ struct config *conf; ++}; ++ ++pthread_mutex_t stream_auth_mutex; ++ ++/** ++ * set_sock_timeout ++ * ++ * Returns : 0 or 1 on timeout ++ */ ++static int set_sock_timeout(int sock, int sec) ++{ ++ struct timeval tv; ++ ++ tv.tv_sec = sec; ++ tv.tv_usec = 0; ++ ++ if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*) &tv, sizeof(tv))) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: set socket timeout failed"); ++ return 1; ++ } ++ return 0; ++} ++ ++/** ++ * read_http_request ++ * ++ * ++ * Returns : 1 on success or 0 if any error happens ++ */ ++static int read_http_request(int sock, char* buffer, int buflen, char* uri, int uri_len) ++{ ++ int nread = 0; ++ int ret,readb = 1; ++ char method[10] = {'\0'}; ++ char url[512] = {'\0'}; ++ char protocol[10] = {'\0'}; ++ ++ static const char *bad_request_response_raw = ++ "HTTP/1.0 400 Bad Request\r\n" ++ "Content-type: text/plain\r\n\r\n" ++ "Bad Request\n"; ++ ++ static const char *bad_method_response_template_raw = ++ "HTTP/1.0 501 Method Not Implemented\r\n" ++ "Content-type: text/plain\r\n\r\n" ++ "Method Not Implemented\n"; ++ ++ static const char *timeout_response_template_raw = ++ "HTTP/1.0 408 Request Timeout\r\n" ++ "Content-type: text/plain\r\n\r\n" ++ "Request Timeout\n"; ++ ++ buffer[0] = '\0'; ++ ++ while ((strstr(buffer, "\r\n\r\n") == NULL) && (readb != 0) && (nread < buflen)) { ++ ++ readb = read(sock, buffer+nread, buflen - nread); ++ ++ if (readb == -1) { ++ nread = -1; ++ break; ++ } ++ ++ nread += readb; ++ ++ if (nread > buflen) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream End buffer reached" ++ " waiting for buffer ending"); ++ break; ++ } ++ ++ buffer[nread] = '\0'; ++ } ++ ++ /* ++ * Make sure the last read didn't fail. If it did, there's a ++ * problem with the connection, so give up. ++ */ ++ if (nread == -1) { ++ if(errno == EAGAIN) { // Timeout ++ ret = write(sock, timeout_response_template_raw, strlen(timeout_response_template_raw)); ++ return 0; ++ } ++ ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream READ give up!"); ++ return 0; ++ } ++ ++ ret = sscanf(buffer, "%9s %511s %9s", method, url, protocol); ++ ++ if (ret != 3) { ++ ret = write(sock, bad_request_response_raw, sizeof(bad_request_response_raw)); ++ return 0; ++ } ++ ++ /* Check Protocol */ ++ if (strcmp(protocol, "HTTP/1.0") && strcmp (protocol, "HTTP/1.1")) { ++ /* We don't understand this protocol. Report a bad response. */ ++ ret = write(sock, bad_request_response_raw, sizeof(bad_request_response_raw)); ++ return 0; ++ } ++ ++ if (strcmp(method, "GET")) { ++ /* ++ * This server only implements the GET method. If client ++ * uses other method, report the failure. ++ */ ++ char response[1024]; ++ snprintf(response, sizeof(response), bad_method_response_template_raw, method); ++ ret = write(sock, response, strlen (response)); ++ ++ return 0; ++ } ++ ++ if(uri) ++ strncpy(uri, url, uri_len); ++ ++ return 1; ++} ++ ++static void stream_add_client(struct stream *list, int sc); ++ ++/** ++ * handle_basic_auth ++ * ++ * ++ */ ++static void* handle_basic_auth(void* param) ++{ ++ struct auth_param *p = (struct auth_param*)param; ++ char buffer[1024] = {'\0'}; ++ ssize_t length = 1023; ++ char *auth, *h, *authentication; ++ static const char *request_auth_response_template= ++ "HTTP/1.0 401 Authorization Required\r\n" ++ "Server: Motion/"VERSION"\r\n" ++ "Max-Age: 0\r\n" ++ "Expires: 0\r\n" ++ "Cache-Control: no-cache, private\r\n" ++ "Pragma: no-cache\r\n" ++ "WWW-Authenticate: Basic realm=\""STREAM_REALM"\"\r\n\r\n"; ++ ++ pthread_mutex_lock(&stream_auth_mutex); ++ p->thread_count++; ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ if (!read_http_request(p->sock,buffer, length, NULL, 0)) ++ goto Invalid_Request; ++ ++ ++ auth = strstr(buffer, "Authorization: Basic"); ++ ++ if (!auth) ++ goto Error; ++ ++ auth += sizeof("Authorization: Basic"); ++ h = strstr(auth, "\r\n"); ++ ++ if(!h) ++ goto Error; ++ ++ *h='\0'; ++ ++ if (p->conf->stream_authentication != NULL) { ++ ++ char *userpass = NULL; ++ size_t auth_size = strlen(p->conf->stream_authentication); ++ ++ authentication = (char *) mymalloc(BASE64_LENGTH(auth_size) + 1); ++ userpass = mymalloc(auth_size + 4); ++ /* base64_encode can read 3 bytes after the end of the string, initialize it. */ ++ memset(userpass, 0, auth_size + 4); ++ strcpy(userpass, p->conf->stream_authentication); ++ base64_encode(userpass, authentication, auth_size); ++ free(userpass); ++ ++ if (strcmp(auth, authentication)) { ++ free(authentication); ++ goto Error; ++ } ++ free(authentication); ++ } ++ ++ // OK - Access ++ ++ /* Set socket to non blocking */ ++ if (fcntl(p->sock, F_SETFL, p->sock_flags) < 0) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); ++ goto Error; ++ } ++ ++ /* Lock the mutex */ ++ pthread_mutex_lock(&stream_auth_mutex); ++ ++ stream_add_client(&p->cnt->stream, p->sock); ++ p->cnt->stream_count++; ++ p->thread_count--; ++ ++ /* Unlock the mutex */ ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ free(p); ++ pthread_exit(NULL); ++ ++Error: ++ if (write(p->sock, request_auth_response_template, strlen (request_auth_response_template)) < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 1:handle_basic_auth"); ++ ++Invalid_Request: ++ close(p->sock); ++ ++ pthread_mutex_lock(&stream_auth_mutex); ++ p->thread_count--; ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ free(p); ++ pthread_exit(NULL); ++} ++ ++ ++#define HASHLEN 16 ++typedef char HASH[HASHLEN]; ++#define HASHHEXLEN 32 ++typedef char HASHHEX[HASHHEXLEN+1]; ++#define IN ++#define OUT ++/** ++ * CvtHex ++ * Calculates H(A1) as per HTTP Digest spec -- taken from RFC 2617. ++ */ ++static void CvtHex(IN HASH Bin, OUT HASHHEX Hex) ++{ ++ unsigned short i; ++ unsigned char j; ++ ++ for (i = 0; i < HASHLEN; i++) { ++ j = (Bin[i] >> 4) & 0xf; ++ if (j <= 9) ++ Hex[i*2] = (j + '0'); ++ else ++ Hex[i*2] = (j + 'a' - 10); ++ j = Bin[i] & 0xf; ++ if (j <= 9) ++ Hex[i*2+1] = (j + '0'); ++ else ++ Hex[i*2+1] = (j + 'a' - 10); ++ }; ++ Hex[HASHHEXLEN] = '\0'; ++}; ++ ++/** ++ * DigestCalcHA1 ++ * Calculates H(A1) as per spec. ++ */ ++static void DigestCalcHA1( ++ IN char * pszAlg, ++ IN char * pszUserName, ++ IN char * pszRealm, ++ IN char * pszPassword, ++ IN char * pszNonce, ++ IN char * pszCNonce, ++ OUT HASHHEX SessionKey ++ ) ++{ ++ MD5_CTX Md5Ctx; ++ HASH HA1; ++ ++ MD5Init(&Md5Ctx); ++ MD5Update(&Md5Ctx, (unsigned char *)pszUserName, strlen(pszUserName)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszRealm, strlen(pszRealm)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszPassword, strlen(pszPassword)); ++ MD5Final((unsigned char *)HA1, &Md5Ctx); ++ ++ if (strcmp(pszAlg, "md5-sess") == 0) { ++ MD5Init(&Md5Ctx); ++ MD5Update(&Md5Ctx, (unsigned char *)HA1, HASHLEN); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszNonce, strlen(pszNonce)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszCNonce, strlen(pszCNonce)); ++ MD5Final((unsigned char *)HA1, &Md5Ctx); ++ }; ++ CvtHex(HA1, SessionKey); ++}; ++ ++/** ++ * DigestCalcResponse ++ * Calculates request-digest/response-digest as per HTTP Digest spec. ++ */ ++static void DigestCalcResponse( ++ IN HASHHEX HA1, /* H(A1) */ ++ IN char * pszNonce, /* nonce from server */ ++ IN char * pszNonceCount, /* 8 hex digits */ ++ IN char * pszCNonce, /* client nonce */ ++ IN char * pszQop, /* qop-value: "", "auth", "auth-int" */ ++ IN char * pszMethod, /* method from the request */ ++ IN char * pszDigestUri, /* requested URL */ ++ IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */ ++ OUT HASHHEX Response /* request-digest or response-digest */ ++ ) ++{ ++ MD5_CTX Md5Ctx; ++ HASH HA2; ++ HASH RespHash; ++ HASHHEX HA2Hex; ++ ++ // Calculate H(A2) ++ MD5Init(&Md5Ctx); ++ MD5Update(&Md5Ctx, (unsigned char *)pszMethod, strlen(pszMethod)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszDigestUri, strlen(pszDigestUri)); ++ ++ if (strcmp(pszQop, "auth-int") == 0) { ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)HEntity, HASHHEXLEN); ++ } ++ MD5Final((unsigned char *)HA2, &Md5Ctx); ++ CvtHex(HA2, HA2Hex); ++ ++ // Calculate response ++ MD5Init(&Md5Ctx); ++ MD5Update(&Md5Ctx, (unsigned char *)HA1, HASHHEXLEN); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszNonce, strlen(pszNonce)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ ++ if (*pszQop) { ++ MD5Update(&Md5Ctx, (unsigned char *)pszNonceCount, strlen(pszNonceCount)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszCNonce, strlen(pszCNonce)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ MD5Update(&Md5Ctx, (unsigned char *)pszQop, strlen(pszQop)); ++ MD5Update(&Md5Ctx, (unsigned char *)":", 1); ++ } ++ MD5Update(&Md5Ctx, (unsigned char *)HA2Hex, HASHHEXLEN); ++ MD5Final((unsigned char *)RespHash, &Md5Ctx); ++ CvtHex(RespHash, Response); ++}; ++ ++ ++/** ++ * handle_md5_digest ++ * ++ * ++ */ ++static void* handle_md5_digest(void* param) ++{ ++ struct auth_param *p = (struct auth_param*)param; ++ char buffer[1024] = {'\0'}; ++ ssize_t length = 1023; ++ char *auth, *h, *username, *realm, *uri, *nonce, *response; ++ int username_len, realm_len, uri_len, nonce_len, response_len; ++#define SERVER_NONCE_LEN 17 ++ char server_nonce[SERVER_NONCE_LEN]; ++#define SERVER_URI_LEN 512 ++ char server_uri[SERVER_URI_LEN]; ++ char* server_user = NULL, *server_pass = NULL; ++ unsigned int rand1,rand2; ++ HASHHEX HA1; ++ HASHHEX HA2 = ""; ++ HASHHEX server_response; ++ static const char *request_auth_response_template= ++ "HTTP/1.0 401 Authorization Required\r\n" ++ "Server: Motion/"VERSION"\r\n" ++ "Max-Age: 0\r\n" ++ "Expires: 0\r\n" ++ "Cache-Control: no-cache, private\r\n" ++ "Pragma: no-cache\r\n" ++ "WWW-Authenticate: Digest"; ++ static const char *auth_failed_html_template= ++ "\r\n" ++ "\r\n" ++ "401 Authorization Required\r\n" ++ "\r\n" ++ "

                                                              Authorization Required

                                                              \r\n" ++ "This server could not verify that you are authorized to access the document " ++ "requested. Either you supplied the wrong credentials (e.g., bad password), " ++ "or your browser doesn't understand how to supply the credentials required.\r\n" ++ "\r\n"; ++ static const char *internal_error_template= ++ "HTTP/1.0 500 Internal Server Error\r\n" ++ "Server: Motion/"VERSION"\r\n" ++ "Content-Type: text/html\r\n" ++ "Connection: Close\r\n\r\n" ++ "\r\n" ++ "\r\n" ++ "500 Internal Server Error\r\n" ++ "\r\n" ++ "

                                                              500 Internal Server Error

                                                              \r\n" ++ "\r\n"; ++ ++ pthread_mutex_lock(&stream_auth_mutex); ++ p->thread_count++; ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ set_sock_timeout(p->sock, KEEP_ALIVE_TIMEOUT); ++ srand(time(NULL)); ++ rand1 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); ++ rand2 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); ++ snprintf(server_nonce, SERVER_NONCE_LEN, "%08x%08x", rand1, rand2); ++ ++ if (!p->conf->stream_authentication) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error no authentication data"); ++ goto InternalError; ++ } ++ h = strstr(p->conf->stream_authentication, ":"); ++ ++ if (!h) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error no authentication data (no ':' found)"); ++ goto InternalError; ++ } ++ ++ server_user = (char*)malloc((h - p->conf->stream_authentication) + 1); ++ server_pass = (char*)malloc(strlen(h) + 1); ++ ++ if (!server_user || !server_pass) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error malloc failed"); ++ goto InternalError; ++ } ++ ++ strncpy(server_user, p->conf->stream_authentication, h-p->conf->stream_authentication); ++ server_user[h - p->conf->stream_authentication] = '\0'; ++ strncpy(server_pass, h + 1, strlen(h + 1)); ++ server_pass[strlen(h + 1)] = '\0'; ++ ++ while(1) { ++ if(!read_http_request(p->sock, buffer, length, server_uri, SERVER_URI_LEN - 1)) ++ goto Invalid_Request; ++ ++ auth = strstr(buffer, "Authorization: Digest"); ++ if(!auth) ++ goto Error; ++ ++ auth += sizeof("Authorization: Digest"); ++ h = strstr(auth, "\r\n"); ++ ++ if (!h) ++ goto Error; ++ *h = '\0'; ++ ++ // Username ++ h=strstr(auth, "username=\""); ++ ++ if (!h) ++ goto Error; ++ ++ username = h + 10; ++ h = strstr(username + 1, "\""); ++ ++ if (!h) ++ goto Error; ++ ++ username_len = h - username; ++ ++ // Realm ++ h = strstr(auth, "realm=\""); ++ if (!h) ++ goto Error; ++ ++ realm = h + 7; ++ h = strstr(realm + 1, "\""); ++ ++ if (!h) ++ goto Error; ++ ++ realm_len = h - realm; ++ ++ // URI ++ h = strstr(auth, "uri=\""); ++ ++ if (!h) ++ goto Error; ++ ++ uri = h + 5; ++ h = strstr(uri + 1, "\""); ++ ++ if (!h) ++ goto Error; ++ ++ uri_len = h - uri; ++ ++ // Nonce ++ h = strstr(auth, "nonce=\""); ++ ++ if (!h) ++ goto Error; ++ ++ nonce = h + 7; ++ h = strstr(nonce + 1, "\""); ++ ++ if (!h) ++ goto Error; ++ ++ nonce_len = h - nonce; ++ ++ // Response ++ h = strstr(auth, "response=\""); ++ ++ if (!h) ++ goto Error; ++ ++ response = h + 10; ++ h = strstr(response + 1, "\""); ++ ++ if (!h) ++ goto Error; ++ ++ response_len = h - response; ++ ++ username[username_len] = '\0'; ++ realm[realm_len] = '\0'; ++ uri[uri_len] = '\0'; ++ nonce[nonce_len] = '\0'; ++ response[response_len] = '\0'; ++ ++ DigestCalcHA1((char*)"md5", server_user, (char*)STREAM_REALM, server_pass, (char*)server_nonce, (char*)NULL, HA1); ++ DigestCalcResponse(HA1, server_nonce, NULL, NULL, (char*)"", (char*)"GET", server_uri, HA2, server_response); ++ ++ if (strcmp(server_response, response) == 0) ++ break; ++Error: ++ rand1 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); ++ rand2 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); ++ snprintf(server_nonce, SERVER_NONCE_LEN, "%08x%08x", rand1, rand2); ++ snprintf(buffer, length, "%s realm=\""STREAM_REALM"\", nonce=\"%s\"\r\n" ++ "Content-Type: text/html\r\n" ++ "Keep-Alive: timeout=%i\r\n" ++ "Connection: keep-alive\r\n" ++ "Content-Length: %Zu\r\n\r\n", ++ request_auth_response_template, server_nonce, ++ KEEP_ALIVE_TIMEOUT, strlen(auth_failed_html_template)); ++ if (write(p->sock, buffer, strlen(buffer)) < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 1:handle_md5_digest"); ++ if (write(p->sock, auth_failed_html_template, strlen(auth_failed_html_template)) < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 2:handle_md5_digest"); ++ } ++ ++ // OK - Access ++ ++ /* Set socket to non blocking */ ++ if (fcntl(p->sock, F_SETFL, p->sock_flags) < 0) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); ++ goto Error; ++ } ++ ++ if(server_user) ++ free(server_user); ++ ++ if(server_pass) ++ free(server_pass); ++ ++ /* Lock the mutex */ ++ pthread_mutex_lock(&stream_auth_mutex); ++ ++ stream_add_client(&p->cnt->stream, p->sock); ++ p->cnt->stream_count++; ++ ++ p->thread_count--; ++ /* Unlock the mutex */ ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ free(p); ++ pthread_exit(NULL); ++ ++InternalError: ++ if(server_user) ++ free(server_user); ++ ++ if(server_pass) ++ free(server_pass); ++ ++ if (write(p->sock, internal_error_template, strlen(internal_error_template)) < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 3:handle_md5_digest"); ++ ++Invalid_Request: ++ close(p->sock); ++ ++ pthread_mutex_lock(&stream_auth_mutex); ++ p->thread_count--; ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ free(p); ++ pthread_exit(NULL); ++} ++ ++/** ++ * do_client_auth ++ * ++ * ++ */ ++static void do_client_auth(struct context *cnt, int sc) ++{ ++ pthread_t thread_id; ++ pthread_attr_t attr; ++ auth_handler handle_func; ++ struct auth_param* handle_param = NULL; ++ int flags; ++ static int first_call = 0; ++ static int thread_count = 0; ++ ++ if(first_call == 0) { ++ first_call = 1; ++ /* Initialize the mutex */ ++ pthread_mutex_init(&stream_auth_mutex, NULL); ++ } ++ ++ switch(cnt->conf.stream_auth_method) ++ { ++ case 1: // Basic ++ handle_func = handle_basic_auth; ++ break; ++ case 2: // MD5 Digest ++ handle_func = handle_md5_digest; ++ break; ++ default: ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error unknown stream authentication method"); ++ goto Error; ++ break; ++ } ++ ++ handle_param = mymalloc(sizeof(struct auth_param)); ++ handle_param->cnt = cnt; ++ handle_param->sock = sc; ++ handle_param->conf = &cnt->conf; ++ handle_param->thread_count = &thread_count; ++ ++ /* Set socket to blocking */ ++ if ((flags = fcntl(sc, F_GETFL, 0)) < 0) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); ++ goto Error; ++ } ++ handle_param->sock_flags = flags; ++ ++ if (fcntl(sc, F_SETFL, flags & (~O_NONBLOCK)) < 0) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); ++ goto Error; ++ } ++ ++ if (thread_count >= DEF_MAXSTREAMS) ++ goto Error; ++ ++ if (pthread_attr_init(&attr)) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error pthread_attr_init"); ++ goto Error; ++ } ++ ++ if (pthread_create(&thread_id, &attr, handle_func, handle_param)) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error pthread_create"); ++ goto Error; ++ } ++ pthread_detach(thread_id); ++ ++ if (pthread_attr_destroy(&attr)) ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error pthread_attr_destroy"); ++ ++ return; ++ ++Error: ++ close(sc); ++ if(handle_param) ++ free(handle_param); ++} ++ ++/** ++ * http_bindsock ++ * Sets up a TCP/IP socket for incoming requests. It is called only during ++ * initialisation of Motion from the function stream_init ++ * The function sets up a a socket on the port number given by _port_. ++ * If the parameter _local_ is not zero the socket is setup to only accept connects from localhost. ++ * Otherwise any client IP address is accepted. The function returns an integer representing the socket. ++ * ++ * Returns: socket descriptor or -1 if any error happens ++ */ ++int http_bindsock(int port, int local, int ipv6_enabled) ++{ ++ int sl = -1, optval; ++ struct addrinfo hints, *res = NULL, *ressave = NULL; ++ char portnumber[10], hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; ++ ++ snprintf(portnumber, sizeof(portnumber), "%u", port); ++ memset(&hints, 0, sizeof(struct addrinfo)); ++ ++ /* Use the AI_PASSIVE flag, which indicates we are using this address for a listen() */ ++ hints.ai_flags = AI_PASSIVE; ++#if defined(BSD) ++ hints.ai_family = AF_INET; ++#else ++ if (!ipv6_enabled) ++ hints.ai_family = AF_INET; ++ else ++ hints.ai_family = AF_UNSPEC; ++#endif ++ hints.ai_socktype = SOCK_STREAM; ++ ++ optval = getaddrinfo(local ? "localhost" : NULL, portnumber, &hints, &res); ++ ++ if (optval != 0) { ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: getaddrinfo() for motion-stream socket failed: %s", ++ gai_strerror(optval)); ++ ++ if (res != NULL) ++ freeaddrinfo(res); ++ return -1; ++ } ++ ++ ressave = res; ++ ++ while (res) { ++ /* Create socket */ ++ sl = socket(res->ai_family, res->ai_socktype, res->ai_protocol); ++ ++ getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, ++ sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV); ++ ++ if (sl >= 0) { ++ optval = 1; ++ /* Reuse Address */ ++ setsockopt(sl, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)); ++ ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-stream testing : %s addr: %s port: %s", ++ res->ai_family == AF_INET ? "IPV4":"IPV6", hbuf, sbuf); ++ ++ if (bind(sl, res->ai_addr, res->ai_addrlen) == 0) { ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-stream Bound : %s addr: %s port: %s", ++ res->ai_family == AF_INET ? "IPV4":"IPV6", hbuf, sbuf); ++ break; ++ } ++ ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream bind() failed, retrying"); ++ close(sl); ++ sl = -1; ++ } ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream socket failed, retrying"); ++ res = res->ai_next; ++ } ++ ++ freeaddrinfo(ressave); ++ ++ if (sl < 0) { ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream creating socket/bind ERROR"); ++ return -1; ++ } ++ ++ ++ if (listen(sl, DEF_MAXWEBQUEUE) == -1) { ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream listen() ERROR"); ++ close(sl); ++ sl = -1; ++ } ++ ++ return sl; ++} ++ ++/** ++ * http_acceptsock ++ * ++ * ++ * Returns: socket descriptor or -1 if any error happens. ++ */ ++static int http_acceptsock(int sl) ++{ ++ int sc; ++ unsigned long i; ++ struct sockaddr_storage sin; ++ socklen_t addrlen = sizeof(sin); ++ ++ if ((sc = accept(sl, (struct sockaddr *)&sin, &addrlen)) >= 0) { ++ i = 1; ++ ioctl(sc, FIONBIO, &i); ++ return sc; ++ } ++ ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream accept()"); ++ ++ return -1; ++} ++ ++ ++/** ++ * stream_flush ++ * Sends any outstanding data to all connected clients. ++ * It continuously goes through the client list until no data is able ++ * to be sent (either because there isn't any, or because the clients ++ * are not able to accept it). ++ */ ++static void stream_flush(struct stream *list, int *stream_count, int lim) ++{ ++ int written; /* The number of bytes actually written. */ ++ struct stream *client; /* Pointer to the client being served. */ ++ int workdone = 0; /* Flag set any time data is successfully ++ written. */ ++ ++ client = list->next; ++ ++ while (client) { ++ ++ /* If data waiting for client, try to send it. */ ++ if (client->tmpbuffer) { ++ ++ /* ++ * We expect that list->filepos < list->tmpbuffer->size ++ * should always be true. The check is more for safety, ++ * in case of trouble is some other part of the code. ++ * Note that if it is false, the following section will ++ * clean up. ++ */ ++ if (client->filepos < client->tmpbuffer->size) { ++ ++ /* ++ * Here we are finally ready to write out the ++ * data. Remember that (because the socket ++ * has been set non-blocking) we may only ++ * write out part of the buffer. The var ++ * 'filepos' contains how much of the buffer ++ * has already been written. ++ */ ++ written = write(client->socket, ++ client->tmpbuffer->ptr + client->filepos, ++ client->tmpbuffer->size - client->filepos); ++ ++ /* ++ * If any data has been written, update the ++ * data pointer and set the workdone flag. ++ */ ++ if (written > 0) { ++ client->filepos += written; ++ workdone = 1; ++ } ++ } else ++ written = 0; ++ ++ /* ++ * If we have written the entire buffer to the socket, ++ * or if there was some error (other than EAGAIN, which ++ * means the system couldn't take it), this request is ++ * finished. ++ */ ++ if ((client->filepos >= client->tmpbuffer->size) || ++ (written < 0 && errno != EAGAIN)) { ++ /* If no other clients need this buffer, free it. */ ++ if (--client->tmpbuffer->ref <= 0) { ++ free(client->tmpbuffer->ptr); ++ free(client->tmpbuffer); ++ } ++ ++ /* Mark this client's buffer as empty. */ ++ client->tmpbuffer = NULL; ++ client->nr++; ++ } ++ ++ /* ++ * If the client is no longer connected, or the total ++ * number of frames already sent to this client is ++ * greater than our configuration limit, disconnect ++ * the client and free the stream struct. ++ */ ++ if ((written < 0 && errno != EAGAIN) || ++ (lim && !client->tmpbuffer && client->nr > lim)) { ++ void *tmp; ++ ++ close(client->socket); ++ ++ if (client->next) ++ client->next->prev = client->prev; ++ ++ client->prev->next = client->next; ++ tmp = client; ++ client = client->prev; ++ free(tmp); ++ (*stream_count)--; ++ } ++ } /* End if (client->tmpbuffer) */ ++ ++ /* ++ * Step the the next client in the list. If we get to the ++ * end of the list, check if anything was written during ++ * that loop; (if so) reset the 'workdone' flag and go back ++ * to the beginning. ++ */ ++ client = client->next; ++ ++ if (!client && workdone) { ++ client = list->next; ++ workdone = 0; ++ } ++ } /* End while (client) */ ++} ++ ++/** ++ * stream_tmpbuffer ++ * Routine to create a new "tmpbuffer", which is a common ++ * object used by all clients connected to a single camera. ++ * ++ * Returns: new allocated stream_buffer. ++ */ ++static struct stream_buffer *stream_tmpbuffer(int size) ++{ ++ struct stream_buffer *tmpbuffer = mymalloc(sizeof(struct stream_buffer)); ++ tmpbuffer->ref = 0; ++ tmpbuffer->ptr = mymalloc(size); ++ ++ return tmpbuffer; ++} ++ ++/** ++ * stream_add_client ++ * ++ * ++ */ ++static void stream_add_client(struct stream *list, int sc) ++{ ++ struct stream *new = mymalloc(sizeof(struct stream)); ++ static const char header[] = "HTTP/1.0 200 OK\r\n" ++ "Server: Motion/"VERSION"\r\n" ++ "Connection: close\r\n" ++ "Max-Age: 0\r\n" ++ "Expires: 0\r\n" ++ "Cache-Control: no-cache, private\r\n" ++ "Pragma: no-cache\r\n" ++ "Content-Type: multipart/x-mixed-replace; " ++ "boundary=BoundaryString\r\n\r\n"; ++ ++ memset(new, 0, sizeof(struct stream)); ++ new->socket = sc; ++ ++ if ((new->tmpbuffer = stream_tmpbuffer(sizeof(header))) == NULL) { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error creating tmpbuffer in stream_add_client"); ++ } else { ++ memcpy(new->tmpbuffer->ptr, header, sizeof(header)-1); ++ new->tmpbuffer->size = sizeof(header)-1; ++ } ++ ++ new->prev = list; ++ new->next = list->next; ++ ++ if (new->next) ++ new->next->prev = new; ++ ++ list->next = new; ++} ++ ++/** ++ * stream_add_write ++ * ++ * ++ */ ++static void stream_add_write(struct stream *list, struct stream_buffer *tmpbuffer, unsigned int fps) ++{ ++ struct timeval curtimeval; ++ unsigned long int curtime; ++ ++ gettimeofday(&curtimeval, NULL); ++ curtime = curtimeval.tv_usec + 1000000L * curtimeval.tv_sec; ++ ++ while (list->next) { ++ list = list->next; ++ ++ if (list->tmpbuffer == NULL && ((curtime - list->last) >= 1000000L / fps)) { ++ list->last = curtime; ++ list->tmpbuffer = tmpbuffer; ++ tmpbuffer->ref++; ++ list->filepos = 0; ++ } ++ } ++ ++ if (tmpbuffer->ref <= 0) { ++ free(tmpbuffer->ptr); ++ free(tmpbuffer); ++ } ++} ++ ++ ++/** ++ * stream_check_write ++ * We walk through the chain of stream structs until we reach the end. ++ * Here we check if the tmpbuffer points to NULL. ++ * We return 1 if it finds a list->tmpbuffer which is a NULL pointer which would ++ * be the next client ready to be sent a new image. If not a 0 is returned. ++ * ++ * Returns: ++ */ ++static int stream_check_write(struct stream *list) ++{ ++ while (list->next) { ++ list = list->next; ++ ++ if (list->tmpbuffer == NULL) ++ return 1; ++ } ++ return 0; ++} ++ ++ ++/** ++ * stream_init ++ * This function is called from motion.c for each motion thread starting up. ++ * The function setup the incoming tcp socket that the clients connect to. ++ * The function returns an integer representing the socket. ++ * ++ * Returns: stream socket descriptor. ++ */ ++int stream_init(struct context *cnt) ++{ ++ cnt->stream.socket = http_bindsock(cnt->conf.stream_port, cnt->conf.stream_localhost, ++ cnt->conf.ipv6_enabled); ++ cnt->stream.next = NULL; ++ cnt->stream.prev = NULL; ++ return cnt->stream.socket; ++} ++ ++/** ++ * stream_stop ++ * This function is called from the motion_loop when it ends ++ * and motion is terminated or restarted. ++ */ ++void stream_stop(struct context *cnt) ++{ ++ struct stream *list; ++ struct stream *next = cnt->stream.next; ++ ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: Closing motion-stream listen socket" ++ " & active motion-stream sockets"); ++ ++ close(cnt->stream.socket); ++ cnt->stream.socket = -1; ++ ++ while (next) { ++ list = next; ++ next = list->next; ++ ++ if (list->tmpbuffer) { ++ free(list->tmpbuffer->ptr); ++ free(list->tmpbuffer); ++ } ++ ++ close(list->socket); ++ free(list); ++ } ++ ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: Closed motion-stream listen socket" ++ " & active motion-stream sockets"); ++} ++ ++/* ++ * stream_put ++ * Is the starting point of the stream loop. It is called from ++ * the motion_loop with the argument 'image' pointing to the latest frame. ++ * If config option 'stream_motion' is 'on' this function is called once ++ * per second (frame 0) and when Motion is detected excl pre_capture. ++ * If config option 'stream_motion' is 'off' this function is called once ++ * per captured picture frame. ++ * It is always run in setup mode for each picture frame captured and with ++ * the special setup image. ++ * The function does two things: ++ * It looks for possible waiting new clients and adds them. ++ * It sends latest picture frame to all connected clients. ++ * Note: Clients that have disconnected are handled in the stream_flush() ++ * function. ++ */ ++void stream_put(struct context *cnt, unsigned char *image) ++{ ++ struct timeval timeout; ++ struct stream_buffer *tmpbuffer; ++ fd_set fdread; ++ int sl = cnt->stream.socket; ++ int sc; ++ /* Tthe following string has an extra 16 chars at end for length. */ ++ const char jpeghead[] = "--BoundaryString\r\n" ++ "Content-type: image/jpeg\r\n" ++ "Content-Length: "; ++ int headlength = sizeof(jpeghead) - 1; /* Don't include terminator. */ ++ char len[20]; /* Will be used for sprintf, must be >= 16 */ ++ ++ /* ++ * Timeout struct used to timeout the time we wait for a client ++ * and we do not wait at all. ++ */ ++ timeout.tv_sec = 0; ++ timeout.tv_usec = 0; ++ FD_ZERO(&fdread); ++ FD_SET(cnt->stream.socket, &fdread); ++ ++ /* ++ * If we have not reached the max number of allowed clients per ++ * thread we will check to see if new clients are waiting to connect. ++ * If this is the case we add the client as a new stream struct and ++ * add this to the end of the chain of stream structs that are linked ++ * to each other. ++ */ ++ if ((cnt->stream_count < DEF_MAXSTREAMS) && ++ (select(sl + 1, &fdread, NULL, NULL, &timeout) > 0)) { ++ sc = http_acceptsock(sl); ++ if (cnt->conf.stream_auth_method == 0) { ++ stream_add_client(&cnt->stream, sc); ++ cnt->stream_count++; ++ } else { ++ do_client_auth(cnt, sc); ++ } ++ } ++ ++ /* Lock the mutex */ ++ if (cnt->conf.stream_auth_method != 0) ++ pthread_mutex_lock(&stream_auth_mutex); ++ ++ ++ /* Call flush to send any previous partial-sends which are waiting. */ ++ stream_flush(&cnt->stream, &cnt->stream_count, cnt->conf.stream_limit); ++ ++ /* Check if any clients have available buffers. */ ++ if (stream_check_write(&cnt->stream)) { ++ /* ++ * Yes - create a new tmpbuffer for current image. ++ * Note that this should create a buffer which is *much* larger ++ * than necessary, but it is difficult to estimate the ++ * minimum size actually required. ++ */ ++ tmpbuffer = stream_tmpbuffer(cnt->imgs.size); ++ ++ /* Check if allocation was ok. */ ++ if (tmpbuffer) { ++ int imgsize; ++ ++ /* ++ * We need a pointer that points to the picture buffer ++ * just after the mjpeg header. We create a working pointer wptr ++ * to be used in the call to put_picture_memory which we can change ++ * and leave tmpbuffer->ptr intact. ++ */ ++ unsigned char *wptr = tmpbuffer->ptr; ++ ++ /* ++ * For web protocol, our image needs to be preceded ++ * with a little HTTP, so we put that into the buffer ++ * first. ++ */ ++ memcpy(wptr, jpeghead, headlength); ++ ++ /* Update our working pointer to point past header. */ ++ wptr += headlength; ++ ++ /* Create a jpeg image and place into tmpbuffer. */ ++ tmpbuffer->size = put_picture_memory(cnt, wptr, cnt->imgs.size, image, ++ cnt->conf.stream_quality); ++ ++ /* Fill in the image length into the header. */ ++ imgsize = sprintf(len, "%9ld\r\n\r\n", tmpbuffer->size); ++ memcpy(wptr - imgsize, len, imgsize); ++ ++ /* Append a CRLF for good measure. */ ++ memcpy(wptr + tmpbuffer->size, "\r\n", 2); ++ ++ /* ++ * Now adjust tmpbuffer->size to reflect the ++ * header at the beginning and the extra CRLF ++ * at the end. ++ */ ++ tmpbuffer->size += headlength + 2; ++ ++ /* ++ * And finally put this buffer to all clients with ++ * no outstanding data from previous frames. ++ */ ++ stream_add_write(&cnt->stream, tmpbuffer, cnt->conf.stream_maxrate); ++ } else { ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error creating tmpbuffer"); ++ } ++ } ++ ++ /* ++ * Now we call flush again. This time (assuming some clients were ++ * ready for the new frame) the new data will be written out. ++ */ ++ stream_flush(&cnt->stream, &cnt->stream_count, cnt->conf.stream_limit); ++ ++ /* Unlock the mutex */ ++ if (cnt->conf.stream_auth_method != 0) ++ pthread_mutex_unlock(&stream_auth_mutex); ++ ++ return; ++} +--- /dev/null ++++ motion-3.2.12/stream.h +@@ -0,0 +1,45 @@ ++/* ++ * stream.h ++ * ++ * Include file for stream.c ++ * Copyright (C) 2002 Jeroen Vreeken (pe1rxq@amsat.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ++ */ ++#ifndef _INCLUDE_STREAM_H_ ++#define _INCLUDE_STREAM_H_ ++ ++struct stream_buffer { ++ unsigned char *ptr; ++ int ref; ++ long size; ++}; ++ ++struct stream { ++ int socket; ++ FILE *fwrite; ++ struct stream_buffer *tmpbuffer; ++ long filepos; ++ int nr; ++ unsigned long int last; ++ struct stream *prev; ++ struct stream *next; ++}; ++ ++int stream_init(struct context *); ++void stream_put(struct context *, unsigned char *); ++void stream_stop(struct context *); ++ ++#endif /* _INCLUDE_STREAM_H_ */ +--- /dev/null ++++ motion-3.2.12/thread1.conf +@@ -0,0 +1,57 @@ ++# /usr/local/etc/thread1.conf ++# ++# This config file was generated by motion 3.2.12-4ppa01 ++ ++ ++ ++########################################################### ++# Capture device options ++############################################################ ++ ++# Videodevice to be used for capturing (default /dev/video0) ++# for FreeBSD default is /dev/bktr0 ++videodevice /dev/video0 ++ ++# 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 ++# Text is placed in lower left corner ++text_left CAMERA 1 ++ ++ ++############################################################ ++# Target Directories and filenames For Images And Films ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename ++# you can use conversion specifiers ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event ++# Quotation marks round string are allowed. ++############################################################ ++ ++# Target base directory for pictures and films ++# Recommended to use absolute patch. (Default: current working directory) ++target_dir /usr/local/apache2/htdocs/cam1 ++ ++ ++############################################################ ++# Live Stream Server ++############################################################ ++ ++# The mini-http server listens to this port for requests (default: 0 = disabled) ++stream_port 8081 ++ ++# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) ++# The filename of the picture is appended as an argument for the command. ++on_picture_save /usr/local/motion-extras/camparse1.pl ++ ++# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) ++# Filename of movie is appended as an argument for the command. ++on_movie_end /usr/local/motion-extras/mpegparse1.pl +--- motion-3.2.12.orig/thread1.conf.in ++++ motion-3.2.12/thread1.conf.in +@@ -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 +@@ -24,7 +24,7 @@ text_left CAMERA 1 + + ############################################################ + # Target Directories and filenames For Images And Films +-# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename + # you can use conversion specifiers + # %Y = year, %m = month, %d = date, + # %H = hour, %M = minute, %S = second, +@@ -42,11 +42,11 @@ target_dir /usr/local/apache2/htdocs/cam + + + ############################################################ +-# Live Webcam Server ++# Live Stream Server + ############################################################ + + # The mini-http server listens to this port for requests (default: 0 = disabled) +-webcam_port 8081 ++stream_port 8081 + + # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) + # The filename of the picture is appended as an argument for the command. +--- /dev/null ++++ motion-3.2.12/thread2.conf +@@ -0,0 +1,58 @@ ++# /usr/local/etc/thread2.conf ++# ++# This config file was generated by motion 3.2.12-4ppa01 ++ ++ ++ ++########################################################### ++# Capture device options ++############################################################ ++ ++# Videodevice to be used for capturing (default /dev/video0) ++# for FreeBSD default is /dev/bktr0 ++videodevice /dev/video1 ++ ++# 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 ++# Text is placed in lower left corner ++text_left CAMERA 2 ++ ++ ++############################################################ ++# Target Directories and filenames For Images And Films ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename ++# you can use conversion specifiers ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event ++# Quotation marks round string are allowed. ++############################################################ ++ ++# Target base directory for pictures and films ++# Recommended to use absolute patch. (Default: current working directory) ++target_dir /usr/local/apache2/htdocs/cam2 ++ ++ ++############################################################ ++# Live Stream Server ++############################################################ ++ ++# The mini-http server listens to this port for requests (default: 0 = disabled) ++stream_port 8082 ++ ++# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) ++# The filename of the picture is appended as an argument for the command. ++on_picture_save /usr/local/motion-extras/camparse2.pl ++ ++# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) ++# Filename of movie is appended as an argument for the command. ++on_movie_end /usr/local/motion-extras/mpegparse2.pl ++ +--- motion-3.2.12.orig/thread2.conf.in ++++ motion-3.2.12/thread2.conf.in +@@ -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) +@@ -24,7 +24,7 @@ text_left CAMERA 2 + + ############################################################ + # Target Directories and filenames For Images And Films +-# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename + # you can use conversion specifiers + # %Y = year, %m = month, %d = date, + # %H = hour, %M = minute, %S = second, +@@ -42,11 +42,11 @@ target_dir /usr/local/apache2/htdocs/cam + + + ############################################################ +-# Live Webcam Server ++# Live Stream Server + ############################################################ + + # The mini-http server listens to this port for requests (default: 0 = disabled) +-webcam_port 8082 ++stream_port 8082 + + # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) + # The filename of the picture is appended as an argument for the command. +--- /dev/null ++++ motion-3.2.12/thread3.conf +@@ -0,0 +1,60 @@ ++# /usr/local/etc/thread3.conf ++# ++# This config file was generated by motion 3.2.12-4ppa01 ++ ++ ++ ++########################################################### ++# Capture device options ++############################################################ ++ ++# Videodevice to be used for capturing (default /dev/video0) ++# for FreeBSD default is /dev/bktr0 ++videodevice /dev/video2 ++ ++# 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 ++# Text is placed in lower left corner ++text_left CAMERA 3 ++ ++ ++############################################################ ++# Target Directories and filenames For Images And Films ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename ++# you can use conversion specifiers ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event ++# Quotation marks round string are allowed. ++############################################################ ++ ++# Target base directory for pictures and films ++# Recommended to use absolute patch. (Default: current working directory) ++target_dir /usr/local/apache2/htdocs/cam3 ++ ++ ++############################################################ ++# Live Stream Server ++############################################################ ++ ++# The mini-http server listens to this port for requests (default: 0 = disabled) ++stream_port 8083 ++ ++# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) ++# The filename of the picture is appended as an argument for the command. ++on_picture_save /usr/local/motion-extras/camparse3.pl ++ ++# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) ++# Filename of movie is appended as an argument for the command. ++on_movie_end /usr/local/motion-extras/mpegparse3.pl ++ ++ ++ +--- motion-3.2.12.orig/thread3.conf.in ++++ motion-3.2.12/thread3.conf.in +@@ -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 +@@ -24,7 +24,7 @@ text_left CAMERA 3 + + ############################################################ + # Target Directories and filenames For Images And Films +-# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename + # you can use conversion specifiers + # %Y = year, %m = month, %d = date, + # %H = hour, %M = minute, %S = second, +@@ -42,11 +42,11 @@ target_dir /usr/local/apache2/htdocs/cam + + + ############################################################ +-# Live Webcam Server ++# Live Stream Server + ############################################################ + + # The mini-http server listens to this port for requests (default: 0 = disabled) +-webcam_port 8083 ++stream_port 8083 + + # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) + # The filename of the picture is appended as an argument for the command. +--- /dev/null ++++ motion-3.2.12/thread4.conf +@@ -0,0 +1,62 @@ ++# /usr/local/etc/thread4.conf ++# ++# This config file was generated by motion 3.2.12-4ppa01 ++ ++########################################################### ++# Capture device options ++############################################################ ++ ++# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) ++# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined ++netcam_url http://192.168.1.6:8093/ ++ ++# The setting for keep-alive of network socket, should improve performance on compatible net cameras. ++# off: The historical implementation using HTTP/1.0, closing the socket after each http request. ++# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. ++# on: Use HTTP/1.1 requests that support keep alive as default. ++# Default: off ++netcam_keepalive force ++ ++# Set less strict jpeg checks for network cameras with a poor/buggy firmware. ++# Default: off ++netcam_tolerant_check on ++ ++# Draw a user defined text on the images using same options as C function strftime(3) ++# Default: Not defined = no text ++# Text is placed in lower left corner ++text_left CAMERA 4 ++ ++############################################################ ++# Target Directories and filenames For Images And Films ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename ++# you can use conversion specifiers ++# %Y = year, %m = month, %d = date, ++# %H = hour, %M = minute, %S = second, ++# %v = event, %q = frame number, %t = thread (camera) number, ++# %D = changed pixels, %N = noise level, ++# %i and %J = width and height of motion area, ++# %K and %L = X and Y coordinates of motion center ++# %C = value defined by text_event ++# Quotation marks round string are allowed. ++############################################################ ++ ++# Target base directory for pictures and films ++# Recommended to use absolute patch. (Default: current working directory) ++target_dir /usr/local/apache2/htdocs/cam4 ++ ++ ++############################################################ ++# Live Stream Server ++############################################################ ++ ++# The mini-http server listens to this port for requests (default: 0 = disabled) ++stream_port 8084 ++ ++# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) ++# The filename of the picture is appended as an argument for the command. ++on_picture_save /usr/local/motion-extras/camparse4.pl ++ ++# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) ++# Filename of movie is appended as an argument for the command. ++on_movie_end /usr/local/motion-extras/mpegparse4.pl ++ +--- motion-3.2.12.orig/thread4.conf.in ++++ motion-3.2.12/thread4.conf.in +@@ -11,11 +11,11 @@ + netcam_url http://192.168.1.6:8093/ + + # The setting for keep-alive of network socket, should improve performance on compatible net cameras. +-# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request. +-# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +-# 1.1: Use HTTP/1.1 requests that support keep alive as default. +-# Default: 1.0 +-netcam_http keep_alive ++# off: The historical implementation using HTTP/1.0, closing the socket after each http request. ++# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. ++# on: Use HTTP/1.1 requests that support keep alive as default. ++# Default: off ++netcam_keepalive force + + # Set less strict jpeg checks for network cameras with a poor/buggy firmware. + # Default: off +@@ -26,10 +26,9 @@ netcam_tolerant_check on + # Text is placed in lower left corner + text_left CAMERA 4 + +- + ############################################################ + # Target Directories and filenames For Images And Films +-# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename ++# For the options snapshot_, picture_, mpeg_ and timelapse_filename + # you can use conversion specifiers + # %Y = year, %m = month, %d = date, + # %H = hour, %M = minute, %S = second, +@@ -47,11 +46,11 @@ target_dir /usr/local/apache2/htdocs/cam + + + ############################################################ +-# Live Webcam Server ++# Live Stream Server + ############################################################ + + # The mini-http server listens to this port for requests (default: 0 = disabled) +-webcam_port 8084 ++stream_port 8084 + + # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) + # The filename of the picture is appended as an argument for the command. +--- motion-3.2.12.orig/track.c ++++ motion-3.2.12/track.c +@@ -7,10 +7,9 @@ + */ + + #include +-#include + #include "motion.h" + +-#ifndef WITHOUT_V4L ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) + #include "pwc-ioctl.h" + #endif + +@@ -22,50 +21,67 @@ struct trackoptions track_template = { + motory: 0, /* int motory */ + maxx: 0, /* int maxx; */ + maxy: 0, /* int maxy; */ ++ minx: 0, /* int minx; */ ++ miny: 0, /* int miny; */ ++ homex: 128, /* int homex; */ ++ homey: 128, /* int homey; */ ++ motorx_reverse: 0, /* int reversed x servo; */ ++ motory_reverse: 0, /* int reversed y servo; */ + speed: TRACK_SPEED, /* speed */ + stepsize: TRACK_STEPSIZE, /* stepsize */ + active: 0, /* auto tracking active */ + minmaxfound: 0, /* flag for minmax values stored for pwc based camera */ +- step_angle_x: 10, /* step angle in degrees X-axis that camera moves during auto tracking */ +- step_angle_y: 10, /* step angle in degrees Y-axis that camera moves during auto tracking */ ++ step_angle_x: 10, /* UVC step angle in degrees X-axis that camera moves during auto tracking */ ++ step_angle_y: 10, /* UVC step angle in degrees Y-axis that camera moves during auto tracking */ + move_wait: 10 /* number of frames to disable motion detection after camera moving */ + }; + + ++ ++ + /* Add your own center and move functions here: */ +-static unsigned short int stepper_center(struct context *, int xoff, int yoff ATTRIBUTE_UNUSED); +-static unsigned short int stepper_move(struct context *, struct coord *, struct images *); +-static unsigned short int iomojo_center(struct context *, int xoff, int yoff); +-static unsigned short int iomojo_move(struct context *, int dev, struct coord *, struct images *); +-#ifndef WITHOUT_V4L +-static unsigned short int lqos_center(struct context *, int dev, int xoff, int yoff); +-static unsigned short int lqos_move(struct context *, int dev, struct coord *, struct images *, +- unsigned short int); ++ ++static unsigned int servo_position(struct context *cnt, unsigned int motor); ++ ++static unsigned int servo_center(struct context *cnt, int xoff, int yoff ATTRIBUTE_UNUSED); ++static unsigned int stepper_center(struct context *cnt, int xoff, int yoff ATTRIBUTE_UNUSED); ++static unsigned int iomojo_center(struct context *cnt, int xoff, int yoff); ++ ++static unsigned int stepper_move(struct context *cnt, struct coord *cent, struct images *imgs); ++static unsigned int servo_move(struct context *cnt, struct coord *cent, ++ struct images *imgs, unsigned int manual); ++static unsigned int iomojo_move(struct context *cnt, int dev, struct coord *cent, struct images *imgs); ++ ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) ++static unsigned int lqos_center(struct context *cnt, int dev, int xoff, int yoff); ++static unsigned int lqos_move(struct context *cnt, int dev, struct coord *cent, ++ struct images *imgs, unsigned int manual); + #ifdef MOTION_V4L2 +-static unsigned short int uvc_center(struct context *, int dev, int xoff, int yoff); +-static unsigned short int uvc_move(struct context *, int dev, struct coord *, struct images *, +- unsigned short int); ++static unsigned int uvc_center(struct context *cnt, int dev, int xoff, int yoff); ++static unsigned int uvc_move(struct context *cnt, int dev, struct coord *cent, ++ struct images *imgs, unsigned int manual); + #endif /* MOTION_V4L2 */ + #endif /* WITHOUT_V4L */ + + /* Add a call to your functions here: */ +-unsigned short int track_center(struct context *cnt, int dev ATTRIBUTE_UNUSED, +- unsigned short int manual, int xoff, int yoff) ++unsigned int track_center(struct context *cnt, int dev ATTRIBUTE_UNUSED, ++ unsigned int manual, int xoff, int yoff) + { + if (!manual && !cnt->track.active) + return 0; + + if (cnt->track.type == TRACK_TYPE_STEPPER) { +- unsigned short int ret; ++ unsigned int ret; + ret = stepper_center(cnt, xoff, yoff); + if (!ret) { +- motion_log(LOG_ERR, 1, "track_center: internal error (stepper_center)"); +- return 0; +- } else { +- return ret; +- } ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: internal error"); ++ return 0; ++ } ++ else return ret; ++ } else if (cnt->track.type == TRACK_TYPE_SERVO) { ++ return servo_center(cnt, xoff, yoff); + } +-#ifndef WITHOUT_V4L ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) + else if (cnt->track.type == TRACK_TYPE_PWC) + return lqos_center(cnt, dev, xoff, yoff); + #ifdef MOTION_V4L2 +@@ -78,22 +94,25 @@ unsigned short int track_center(struct c + else if (cnt->track.type == TRACK_TYPE_GENERIC) + return 10; // FIX ME. I chose to return something reasonable. + +- motion_log(LOG_ERR, 1, "track_center: internal error, %hu is not a known track-type", ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: internal error, %hu is not a known track-type", + cnt->track.type); + + return 0; + } + + /* Add a call to your functions here: */ +-unsigned short int track_move(struct context *cnt, int dev, struct coord *cent, +- struct images *imgs, unsigned short int manual) ++unsigned int track_move(struct context *cnt, int dev, struct coord *cent, struct images *imgs, ++ unsigned int manual) + { ++ + if (!manual && !cnt->track.active) + return 0; + + if (cnt->track.type == TRACK_TYPE_STEPPER) + return stepper_move(cnt, cent, imgs); +-#ifndef WITHOUT_V4L ++ else if (cnt->track.type == TRACK_TYPE_SERVO) ++ return servo_move(cnt, cent, imgs, manual); ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) + else if (cnt->track.type == TRACK_TYPE_PWC) + return lqos_move(cnt, dev, cent, imgs, manual); + #ifdef MOTION_V4L2 +@@ -106,22 +125,20 @@ unsigned short int track_move(struct con + else if (cnt->track.type == TRACK_TYPE_GENERIC) + return cnt->track.move_wait; // FIX ME. I chose to return something reasonable. + +- motion_log(LOG_ERR, 1, "track_move: internal error, %hu is not a known track-type", ++ MOTION_LOG(WRN, TYPE_TRACK, SHOW_ERRNO, "%s: internal error, %hu is not a known track-type", + cnt->track.type); + + return 0; + } + +- + /****************************************************************************** + Stepper motor on serial port +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionTracking +- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionTrackerAPI ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTracking ++ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTrackerAPI + ******************************************************************************/ + +- +-static unsigned short int stepper_command(struct context *cnt, unsigned short int motor, +- unsigned short int command, unsigned short int data) ++static unsigned int stepper_command(struct context *cnt, unsigned int motor, ++ unsigned int command, unsigned int data) + { + char buffer[3]; + time_t timeout = time(NULL); +@@ -131,15 +148,15 @@ static unsigned short int stepper_comman + buffer[2] = data; + + if (write(cnt->track.dev, buffer, 3) != 3) { +- motion_log(LOG_ERR, 1, "stepper_command port %s dev fd %i, motor %hu command %hu data %hu", +- cnt->track.port, cnt->track.dev, motor, command, data); ++ MOTION_LOG(NTC, TYPE_TRACK, SHOW_ERRNO, "%s: port %s dev fd %i, motor %hu command %hu data %hu", ++ cnt->track.port, cnt->track.dev, motor, command, data); + return 0; + } + + while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 1); + + if (time(NULL) >= timeout + 2) { +- motion_log(LOG_ERR, 1, "Status byte timeout!"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Status byte timeout!"); + return 0; + } + +@@ -147,43 +164,46 @@ static unsigned short int stepper_comman + } + + +-static unsigned short int stepper_status(struct context *cnt, unsigned short int motor) ++static unsigned int stepper_status(struct context *cnt, unsigned int motor) + { + return stepper_command(cnt, motor, STEPPER_COMMAND_STATUS, 0); + } + + +-static unsigned short int stepper_center(struct context *cnt, int x_offset, int y_offset) ++static unsigned int stepper_center(struct context *cnt, int x_offset, int y_offset) + { + struct termios adtio; + + if (cnt->track.dev < 0) { +- motion_log(LOG_INFO, 0, "Try to open serial device %s", cnt->track.port); +- +- if ((cnt->track.dev=open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { +- motion_log(LOG_ERR, 1, "Unable to open serial device %s", cnt->track.port); ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Try to open serial device %s", cnt->track.port); ++ ++ if ((cnt->track.dev = open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to open serial device %s", ++ cnt->track.port); + return 0; + } + + bzero (&adtio, sizeof(adtio)); +- adtio.c_cflag = STEPPER_BAUDRATE | CS8 | CLOCAL | CREAD; +- adtio.c_iflag = IGNPAR; +- adtio.c_oflag = 0; +- adtio.c_lflag = 0; /* non-canon, no echo */ ++ adtio.c_cflag= STEPPER_BAUDRATE | CS8 | CLOCAL | CREAD; ++ adtio.c_iflag= IGNPAR; ++ adtio.c_oflag= 0; ++ adtio.c_lflag= 0; /* non-canon, no echo */ + adtio.c_cc[VTIME] = 0; /* timer unused */ + adtio.c_cc[VMIN] = 0; /* blocking read until 1 char */ + tcflush (cnt->track.dev, TCIFLUSH); + + if (tcsetattr(cnt->track.dev, TCSANOW, &adtio) < 0) { +- motion_log(LOG_ERR, 1, "Unable to initialize serial device %s", cnt->track.port); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to initialize serial device %s", ++ cnt->track.port); ++ cnt->track.dev = -1; + return 0; + } +- motion_log(LOG_INFO, 0, "Opened serial device %s and initialize, fd %i", ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Opened serial device %s and initialize, fd %i", + cnt->track.port, cnt->track.dev); + } + + /* x-axis */ +- ++ + stepper_command(cnt, cnt->track.motorx, STEPPER_COMMAND_SPEED, cnt->track.speed); + stepper_command(cnt, cnt->track.motorx, STEPPER_COMMAND_LEFT_N, cnt->track.maxx); + +@@ -200,33 +220,36 @@ static unsigned short int stepper_center + stepper_command(cnt, cnt->track.motory, STEPPER_COMMAND_UP_N, cnt->track.maxy); + + while (stepper_status(cnt, cnt->track.motory) & STEPPER_STATUS_UP) +- ++ + stepper_command(cnt, cnt->track.motory, STEPPER_COMMAND_DOWN_N, + cnt->track.maxy / 2 + y_offset * cnt->track.stepsize); +- ++ + while (stepper_status(cnt, cnt->track.motory) & STEPPER_STATUS_DOWN); +- ++ + return cnt->track.move_wait; + } + +-static unsigned short int stepper_move(struct context *cnt, struct coord *cent, +- struct images *imgs) ++static unsigned int stepper_move(struct context *cnt, ++ struct coord *cent, struct images *imgs) + { +- unsigned short int command = 0, data = 0; ++ unsigned int command = 0, data = 0; + + if (cnt->track.dev < 0) { +- motion_log(LOG_INFO, 0, "No device %s started yet , trying stepper_center()", cnt->track.port); +- if (!stepper_center(cnt, 0, 0)){ +- motion_log(LOG_ERR, 1, "Stepper_center() failed to initialize stepper device on %s , fd [%i].", +- cnt->track.port, cnt->track.dev); ++ MOTION_LOG(WRN, TYPE_TRACK, NO_ERRNO, "%s: No device %s started yet , trying stepper_center()", ++ cnt->track.port); ++ ++ if (!stepper_center(cnt, 0, 0)) { ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: failed to initialize stepper device on %s , fd [%i].", ++ cnt->track.port, cnt->track.dev); + return 0; + } +- motion_log(LOG_INFO, 0, "stepper_center() succeed , device started %s , fd [%i]", +- cnt->track.port, cnt->track.dev); ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: succeed , device started %s , fd [%i]", ++ cnt->track.port, cnt->track.dev); + } + + /* x-axis */ +- ++ + if (cent->x < imgs->width / 2) { + command = STEPPER_COMMAND_LEFT_N; + data = imgs->width / 2 - cent->x; +@@ -239,8 +262,7 @@ static unsigned short int stepper_move(s + + data = data * cnt->track.stepsize / imgs->width; + +- if (data) +- stepper_command(cnt, cnt->track.motorx, command, data); ++ if (data) stepper_command(cnt, cnt->track.motorx, command, data); + + /* y-axis */ + +@@ -253,24 +275,347 @@ static unsigned short int stepper_move(s + command = STEPPER_COMMAND_DOWN_N; + data = cent->y - imgs->height / 2; + } +- ++ + data = data * cnt->track.stepsize / imgs->height; + +- if (data) +- stepper_command(cnt, cnt->track.motory, command, data); +- +- ++ if (data) ++ stepper_command(cnt, cnt->track.motory, command, data); ++ ++ ++ return cnt->track.move_wait; ++} ++ ++/****************************************************************************** ++ * Servo motor on serial port ++ * http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTracking ++ * http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTrackerServoAPI ++ ******************************************************************************/ ++ ++static int servo_open(struct context *cnt) ++{ ++ struct termios adtio; ++ ++ if ((cnt->track.dev = open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to open serial device %s", ++ cnt->track.port); ++ return 0; ++ } ++ ++ bzero (&adtio, sizeof(adtio)); ++ adtio.c_cflag= SERVO_BAUDRATE | CS8 | CLOCAL | CREAD; ++ adtio.c_iflag= IGNPAR; ++ adtio.c_oflag= 0; ++ adtio.c_lflag= 0; /* non-canon, no echo */ ++ adtio.c_cc[VTIME] = 0; /* timer unused */ ++ adtio.c_cc[VMIN] = 0; /* blocking read until 1 char */ ++ tcflush (cnt->track.dev, TCIFLUSH); ++ ++ if (tcsetattr(cnt->track.dev, TCSANOW, &adtio) < 0) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Unable to initialize serial device %s", ++ cnt->track.port); ++ cnt->track.dev = -1; ++ return 0; ++ } ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Opened serial device %s and initialize, fd %i", ++ cnt->track.port, cnt->track.dev); ++ ++ return 1; ++} ++ ++ ++static unsigned int servo_command(struct context *cnt, unsigned int motor, ++ unsigned int command, unsigned int data) ++{ ++ unsigned char buffer[3]; ++ time_t timeout = time(NULL); ++ ++ buffer[0] = motor; ++ buffer[1] = command; ++ buffer[2] = data; ++ ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: SENDS port %s dev fd %i, motor %hu command %hu data %hu", ++ cnt->track.port, cnt->track.dev, buffer[0], buffer[1], buffer[2]); ++ ++ if (write(cnt->track.dev, buffer, 3) != 3) { ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: port %s dev fd %i, motor %hu command %hu data %hu", ++ cnt->track.port, cnt->track.dev, motor, command, data); ++ return 0; ++ } ++ ++ while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 1); ++ ++ if (time(NULL) >= timeout + 2) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Status byte timeout!"); ++ return 0; ++ } ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Command return %d", buffer[0]); ++ ++ ++ return buffer[0]; ++} ++ ++ ++static unsigned int servo_position(struct context *cnt, unsigned int motor) ++{ ++ unsigned int ret = 0; ++ ++ ret = servo_command(cnt, motor, SERVO_COMMAND_POSITION, 0); ++ ++ return ret; ++} ++ ++ ++/** ++ * servo_move ++ * Does relative movements to current position. ++ * ++ */ ++static unsigned int servo_move(struct context *cnt, struct coord *cent, ++ struct images *imgs, unsigned int manual) ++{ ++ unsigned int command = 0; ++ unsigned int data = 0; ++ unsigned int position; ++ ++ /* If device is not open yet , open and center */ ++ if (cnt->track.dev < 0) { ++ if (!servo_center(cnt, 0, 0)) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Problem opening servo!"); ++ return 0; ++ } ++ } ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: cent->x %d, cent->y %d, reversex %d," ++ "reversey %d manual %d", cent->x , cent->y, ++ cnt->track.motorx_reverse, cnt->track.motory_reverse, manual); ++ ++ if (manual) { ++ int offset; ++ ++ if (cent->x) { ++ position = servo_position(cnt, cnt->track.motorx); ++ offset = cent->x * cnt->track.stepsize; ++ ++ ++ if ((cnt->track.motorx_reverse && (offset > 0)) || ++ (!cnt->track.motorx_reverse && (offset < 0))) ++ command = SERVO_COMMAND_LEFT_N; ++ else ++ command = SERVO_COMMAND_RIGHT_N; ++ ++ data = abs(offset); ++ ++ if ((data + position > (unsigned)cnt->track.maxx) || ++ (position - offset < (unsigned)cnt->track.minx)) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: x %d value out of range! (%d - %d)", ++ data, cnt->track.minx, cnt->track.maxx); ++ return 0; ++ } ++ ++ /* Set Speed , TODO : it should be done only when speed changes */ ++ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); ++ servo_command(cnt, cnt->track.motorx, command, data); ++ } ++ ++ ++ if (cent->y) { ++ position = servo_position(cnt, cnt->track.motory); ++ offset = cent->y * cnt->track.stepsize; ++ ++ if ((cnt->track.motory_reverse && (offset > 0)) || ++ (!cnt->track.motory_reverse && (offset < 0))) ++ command = SERVO_COMMAND_UP_N; ++ else ++ command = SERVO_COMMAND_DOWN_N; ++ ++ data = abs(offset); ++ ++ if ((data + position > (unsigned)cnt->track.maxy) || ++ (position - offset < (unsigned)cnt->track.miny)) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: y %d value out of range! (%d - %d)", ++ data, cnt->track.miny, cnt->track.maxy); ++ return 0; ++ } ++ ++ /* Set Speed , TODO : it should be done only when speed changes */ ++ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); ++ servo_command(cnt, cnt->track.motory, command, data); ++ } ++ ++ } else { ++ /***** x-axis *****/ ++ ++ /* Move left */ ++ if (cent->x < imgs->width / 2) { ++ if (cnt->track.motorx_reverse) ++ command = SERVO_COMMAND_RIGHT_N; ++ else ++ command = SERVO_COMMAND_LEFT_N; ++ data = imgs->width / 2 - cent->x; ++ } ++ ++ /* Move right */ ++ if (cent->x > imgs->width / 2) { ++ if (cnt->track.motorx_reverse) ++ command = SERVO_COMMAND_LEFT_N; ++ else ++ command = SERVO_COMMAND_RIGHT_N; ++ data = cent->x - imgs->width / 2; ++ } ++ ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: X offset %d", data); ++ ++ data = data * cnt->track.stepsize / imgs->width; ++ ++ if (data && command) { ++ ++ // TODO: need to get position to avoid overflow limits ++ position = servo_position(cnt, cnt->track.motorx); ++ ++ if ((position + data > (unsigned)cnt->track.maxx) || ++ (position - data < (unsigned)cnt->track.minx)) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: x %d value out of range! (%d - %d)", ++ data, cnt->track.minx, cnt->track.maxx); ++ return 0; ++ } ++ ++ /* Set Speed , TODO : it should be done only when speed changes */ ++ ++ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); ++ servo_command(cnt, cnt->track.motorx, command, data); ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: X cent->x %d, cent->y %d, reversex %d," ++ "reversey %d motorx %d data %d command %d", ++ cent->x, cent->y, cnt->track.motorx_reverse, ++ cnt->track.motory_reverse, cnt->track.motorx, data, command); ++ } ++ ++ /***** y-axis *****/ ++ ++ /* Move down */ ++ if (cent->y < imgs->height / 2) { ++ if (cnt->track.motory_reverse) ++ command = SERVO_COMMAND_UP_N; ++ else ++ command = SERVO_COMMAND_DOWN_N; ++ data = imgs->height / 2 - cent->y; ++ } ++ ++ /* Move up */ ++ if (cent->y > imgs->height / 2) { ++ if (cnt->track.motory_reverse) ++ command = SERVO_COMMAND_DOWN_N; ++ else ++ command = SERVO_COMMAND_UP_N; ++ data = cent->y - imgs->height / 2; ++ } ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Y offset %d", data); ++ ++ data = data * cnt->track.stepsize / imgs->height; ++ ++ if (data && command) { ++ ++ // TODO: need to get position to avoid overflow limits ++ position = servo_position(cnt, cnt->track.motory); ++ ++ if ((position + data > (unsigned)cnt->track.maxy) || ++ (position - data < (unsigned)cnt->track.miny)) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: y %d value out of range! (%d - %d)", ++ data, cnt->track.miny, cnt->track.maxy); ++ return 0; ++ } ++ ++ /* Set Speed , TODO : it should be done only when speed changes */ ++ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); ++ servo_command(cnt, cnt->track.motory, command, data); ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Y cent->x %d, cent->y %d, reversex %d," ++ "reversey %d motory %d data %d command %d", ++ cent->x, cent->y, cnt->track.motorx_reverse, ++ cnt->track.motory_reverse, cnt->track.motory, command); ++ } ++ } ++ + return cnt->track.move_wait; + } + ++#if 0 ++static unsigned int servo_status(struct context *cnt, unsigned int motor) ++{ ++ return servo_command(cnt, motor, SERVO_COMMAND_STATUS, 0); ++} ++#endif ++ ++/** ++ * servo_center ++ * Moves servo to home position. ++ * Does absolute movements ( offsets relative to home position ). ++ * ++ * Note : Using Clockwise as a convention for right , left , up , down ++ * so left minx , right maxx , down miny , up maxy ++ * ++ */ ++ ++static unsigned int servo_center(struct context *cnt, int x_offset, int y_offset) ++{ ++ int x_offset_abs; ++ int y_offset_abs; ++ ++ /* If device is not open yet */ ++ if (cnt->track.dev < 0) { ++ if (!servo_open(cnt)) { ++ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Problem opening servo!"); ++ return 0; ++ } ++ } ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: X-offset %d, Y-offset %d, x-position %d. y-position %d," ++ "reversex %d, reversey %d , stepsize %d", x_offset, y_offset, ++ cnt->track.homex + (x_offset * cnt->track.stepsize), ++ cnt->track.homey + (y_offset * cnt->track.stepsize), ++ cnt->track.motorx_reverse, cnt->track.motory_reverse, ++ cnt->track.stepsize); ++ ++ /* x-axis */ ++ if (cnt->track.motorx_reverse) ++ x_offset_abs = (128 - cnt->track.homex) - (x_offset * cnt->track.stepsize) + 128; ++ else ++ x_offset_abs = cnt->track.homex + (x_offset * cnt->track.stepsize); ++ ++ if (x_offset_abs <= cnt->track.maxx && x_offset_abs >= cnt->track.minx) { ++ /* Set Speed , TODO : it should be done only when speed changes */ ++ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); ++ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_ABSOLUTE, x_offset_abs); ++ } ++ ++ /* y-axis */ ++ if (cnt->track.motory_reverse) ++ y_offset_abs = (128 - cnt->track.homey) - (y_offset * cnt->track.stepsize) + 128; ++ else ++ y_offset_abs = cnt->track.homey + (y_offset * cnt->track.stepsize); ++ ++ if (y_offset_abs <= cnt->track.maxy && y_offset_abs >= cnt->track.minx) { ++ /* Set Speed , TODO : it should be done only when speed changes */ ++ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); ++ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_ABSOLUTE, y_offset_abs); ++ } ++ ++ return cnt->track.move_wait; ++} ++ ++ + /****************************************************************************** + + Iomojo Smilecam on serial port + + ******************************************************************************/ + +-static char iomojo_command(struct context *cnt, char *command, +- unsigned short int len, unsigned short int ret) ++static char iomojo_command(struct context *cnt, char *command, int len, unsigned int ret) + { + char buffer[1]; + time_t timeout = time(NULL); +@@ -280,9 +625,9 @@ static char iomojo_command(struct contex + + if (ret) { + while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 2); +- ++ + if (time(NULL) >= timeout + 2) { +- motion_log(LOG_ERR, 1, "Return byte timeout!"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Return byte timeout!"); + return 0; + } + } +@@ -290,36 +635,37 @@ static char iomojo_command(struct contex + return buffer[0]; + } + +-static void iomojo_setspeed(struct context *cnt, unsigned short int speed) ++static void iomojo_setspeed(struct context *cnt, unsigned int speed) + { + char command[3]; +- ++ + command[0] = IOMOJO_SETSPEED_CMD; + command[1] = cnt->track.iomojo_id; + command[2] = speed; +- ++ + if (iomojo_command(cnt, command, 3, 1) != IOMOJO_SETSPEED_RET) +- motion_log(LOG_ERR, 1, "Unable to set camera speed"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to set camera speed"); + } + + static void iomojo_movehome(struct context *cnt) + { + char command[2]; +- ++ + command[0] = IOMOJO_MOVEHOME; + command[1] = cnt->track.iomojo_id; + + iomojo_command(cnt, command, 2, 0); + } + +-static unsigned short int iomojo_center(struct context *cnt, int x_offset, int y_offset) ++static unsigned int iomojo_center(struct context *cnt, int x_offset, int y_offset) + { + struct termios adtio; + char command[5], direction = 0; + +- if (cnt->track.dev<0) { +- if ((cnt->track.dev=open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { +- motion_log(LOG_ERR, 1, "Unable to open serial device %s", cnt->track.port); ++ if (cnt->track.dev < 0) { ++ if ((cnt->track.dev = open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to open serial device %s", ++ cnt->track.port); + return 0; + } + +@@ -332,7 +678,8 @@ static unsigned short int iomojo_center( + adtio.c_cc[VMIN] = 0; /* blocking read until 1 char */ + tcflush(cnt->track.dev, TCIFLUSH); + if (tcsetattr(cnt->track.dev, TCSANOW, &adtio) < 0) { +- motion_log(LOG_ERR, 1, "Unable to initialize serial device %s", cnt->track.port); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to initialize serial device %s", ++ cnt->track.port); + return 0; + } + } +@@ -341,16 +688,16 @@ static unsigned short int iomojo_center( + iomojo_movehome(cnt); + + if (x_offset || y_offset) { +- if (x_offset > 0) ++ if (x_offset > 0) { + direction |= IOMOJO_DIRECTION_RIGHT; +- else { ++ } else { + direction |= IOMOJO_DIRECTION_LEFT; + x_offset *= -1; + } + +- if (y_offset > 0) ++ if (y_offset > 0) { + direction |= IOMOJO_DIRECTION_UP; +- else { ++ } else { + direction |= IOMOJO_DIRECTION_DOWN; + y_offset *= -1; + } +@@ -369,19 +716,19 @@ static unsigned short int iomojo_center( + iomojo_command(cnt, command, 5, 0); + } + +- motion_log(LOG_INFO, 0, "iomojo_center() succeed"); ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: succeed"); + + return cnt->track.move_wait; + } + +-static unsigned short int iomojo_move(struct context *cnt, int dev, +- struct coord *cent, struct images *imgs) ++static unsigned int iomojo_move(struct context *cnt, int dev, struct coord *cent, ++ struct images *imgs) + { + char command[5]; + int direction = 0; + int nx = 0, ny = 0; + int i; +- ++ + if (dev < 0) + if (!iomojo_center(cnt, 0, 0)) + return 0; +@@ -428,7 +775,6 @@ static unsigned short int iomojo_move(st + i = 25 * ny / 90; + else + i = 25 * nx / 90; +- + return i; + } + +@@ -440,8 +786,8 @@ static unsigned short int iomojo_move(st + Logitech QuickCam Orbit camera tracking code by folkert@vanheusden.com + + ******************************************************************************/ +-#ifndef WITHOUT_V4L +-static unsigned short int lqos_center(struct context *cnt, int dev, int x_angle, int y_angle) ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) ++static unsigned int lqos_center(struct context *cnt, int dev, int x_angle, int y_angle) + { + int reset = 3; + struct pwc_mpt_angles pma; +@@ -450,48 +796,48 @@ static unsigned short int lqos_center(st + if (cnt->track.dev == -1) { + + if (ioctl(dev, VIDIOCPWCMPTRESET, &reset) == -1) { +- motion_log(LOG_ERR, 1, "Failed to reset pwc camera to starting position! Reason"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to reset pwc camera to starting position! Reason"); + return 0; + } + +- SLEEP(6,0) ++ SLEEP(6, 0); + + if (ioctl(dev, VIDIOCPWCMPTGRANGE, &pmr) == -1) { +- motion_log(LOG_ERR, 1, "failed VIDIOCPWCMPTGRANGE"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: failed VIDIOCPWCMPTGRANGE"); + return 0; + } + + cnt->track.dev = dev; + cnt->track.minmaxfound = 1; +- cnt->track.panmin = pmr.pan_min; +- cnt->track.panmax = pmr.pan_max; +- cnt->track.tiltmin = pmr.tilt_min; +- cnt->track.tiltmax = pmr.tilt_max; ++ cnt->track.minx = pmr.pan_min; ++ cnt->track.maxx = pmr.pan_max; ++ cnt->track.miny = pmr.tilt_min; ++ cnt->track.maxy = pmr.tilt_max; + } + + if (ioctl(dev, VIDIOCPWCMPTGANGLE, &pma) == -1) +- motion_log(LOG_ERR, 1, "ioctl VIDIOCPWCMPTGANGLE"); +- ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: ioctl VIDIOCPWCMPTGANGLE"); ++ + pma.absolute = 1; + +- if (x_angle * 100 < cnt->track.panmax && x_angle * 100 > cnt->track.panmin) ++ if (x_angle * 100 < cnt->track.maxx && x_angle * 100 > cnt->track.minx) + pma.pan = x_angle * 100; + +- if (y_angle * 100 < cnt->track.tiltmax && y_angle * 100 > cnt->track.tiltmin) ++ if (y_angle * 100 < cnt->track.maxy && y_angle * 100 > cnt->track.miny) + pma.tilt = y_angle * 100; + + if (ioctl(dev, VIDIOCPWCMPTSANGLE, &pma) == -1) { +- motion_log(LOG_ERR, 1, "Failed to pan/tilt pwc camera! Reason"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to pan/tilt pwc camera! Reason"); + return 0; + } + +- motion_log(LOG_INFO, 0, "lqos_center succeed"); ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: succeed"); + + return cnt->track.move_wait; + } + +-static unsigned short int lqos_move(struct context *cnt, int dev, struct coord *cent, +- struct images *imgs, unsigned short int manual) ++static unsigned int lqos_move(struct context *cnt, int dev, struct coord *cent, ++ struct images *imgs, unsigned int manual) + { + int delta_x = cent->x - (imgs->width / 2); + int delta_y = cent->y - (imgs->height / 2); +@@ -501,9 +847,9 @@ static unsigned short int lqos_move(stru + + /* If we are on auto track we calculate delta, otherwise we use user input in degrees times 100 */ + if (!manual) { +- if (delta_x > imgs->width * 3 / 8 && delta_x < imgs->width * 5 / 8) ++ if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8) + return 0; +- if (delta_y > imgs->height * 3 / 8 && delta_y < imgs->height * 5 / 8) ++ if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8) + return 0; + + move_x_degrees = delta_x * cnt->track.step_angle_x * 100 / (imgs->width / 2); +@@ -512,46 +858,48 @@ static unsigned short int lqos_move(stru + move_x_degrees = cent->x * 100; + move_y_degrees = cent->y * 100; + } +- ++ + /* If we never checked for the min/max values for pan/tilt we do it now */ + if (cnt->track.minmaxfound == 0) { + if (ioctl(dev, VIDIOCPWCMPTGRANGE, &pmr) == -1) { +- motion_log(LOG_ERR, 1, "failed VIDIOCPWCMPTGRANGE"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: failed VIDIOCPWCMPTGRANGE"); + return 0; + } + cnt->track.minmaxfound = 1; +- cnt->track.panmin = pmr.pan_min; +- cnt->track.panmax = pmr.pan_max; +- cnt->track.tiltmin = pmr.tilt_min; +- cnt->track.tiltmax = pmr.tilt_max; ++ cnt->track.minx = pmr.pan_min; ++ cnt->track.maxx = pmr.pan_max; ++ cnt->track.miny = pmr.tilt_min; ++ cnt->track.maxy = pmr.tilt_max; + } + + /* Get current camera position */ + if (ioctl(dev, VIDIOCPWCMPTGANGLE, &pma) == -1) +- motion_log(LOG_ERR, 1, "ioctl VIDIOCPWCMPTGANGLE"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: ioctl VIDIOCPWCMPTGANGLE"); ++ + ++ /* ++ * Check current position of camera and see if we need to adjust ++ * values down to what is left to move ++ */ ++ if (move_x_degrees < 0 && (cnt->track.minx - pma.pan) > move_x_degrees) ++ move_x_degrees = (cnt->track.minx - pma.pan); + +- /* Check current position of camera and see if we need to adjust +- values down to what is left to move */ +- if (move_x_degrees<0 && (cnt->track.panmin - pma.pan) > move_x_degrees) +- move_x_degrees = (cnt->track.panmin - pma.pan); ++ if (move_x_degrees > 0 && (cnt->track.maxx - pma.pan) < move_x_degrees) ++ move_x_degrees = (cnt->track.maxx - pma.pan); + +- if (move_x_degrees>0 && (cnt->track.panmax - pma.pan) < move_x_degrees) +- move_x_degrees = (cnt->track.panmax - pma.pan); ++ if (move_y_degrees < 0 && (cnt->track.miny - pma.tilt) > move_y_degrees) ++ move_y_degrees = (cnt->track.miny - pma.tilt); + +- if (move_y_degrees<0 && (cnt->track.tiltmin - pma.tilt) > move_y_degrees) +- move_y_degrees = (cnt->track.tiltmin - pma.tilt); ++ if (move_y_degrees > 0 && (cnt->track.maxy - pma.tilt) < move_y_degrees) ++ move_y_degrees = (cnt->track.maxy - pma.tilt); + +- if (move_y_degrees>0 && (cnt->track.tiltmax - pma.tilt) < move_y_degrees) +- move_y_degrees = (cnt->track.tiltmax - pma.tilt); +- + /* Move camera relative to current position */ + pma.absolute = 0; + pma.pan = move_x_degrees; + pma.tilt = move_y_degrees; + + if (ioctl(dev, VIDIOCPWCMPTSANGLE, &pma) == -1) { +- motion_log(LOG_ERR, 1, "Failed to pan/tilt pwc camera! Reason"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to pan/tilt pwc camera! Reason"); + return 0; + } + +@@ -560,14 +908,14 @@ static unsigned short int lqos_move(stru + /****************************************************************************** + + Logitech QuickCam Sphere camera tracking code by oBi +- +- Modify by Dirk Wesenberg(Munich) 30.03.07 +- - for new API in uvcvideo ++ ++ Modify by Dirk Wesenberg(Munich) 30.03.07 ++ - for new API in uvcvideo + - add Trace-steps for investigation + ******************************************************************************/ + #ifdef MOTION_V4L2 + +-static unsigned short int uvc_center(struct context *cnt, int dev, int x_angle, int y_angle) ++static unsigned int uvc_center(struct context *cnt, int dev, int x_angle, int y_angle) + { + /* CALC ABSOLUTE MOVING : Act.Position +/- delta to request X and Y */ + int move_x_degrees = 0, move_y_degrees = 0; +@@ -590,41 +938,40 @@ static unsigned short int uvc_center(str + control_s.value = (unsigned char) reset; + + if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { +- motion_log(LOG_ERR, 1, "Failed to reset UVC camera to starting position! Reason"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to reset UVC camera to starting position! Reason"); + return 0; + } +- motion_log(LOG_DEBUG, 0, "Reseting UVC camera to starting position"); + +- SLEEP(8, 0) ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Reseting UVC camera to starting position"); ++ ++ SLEEP(8, 0); + + /* Get camera range */ + struct v4l2_queryctrl queryctrl; +- + queryctrl.id = V4L2_CID_PAN_RELATIVE; + + if (ioctl(dev, VIDIOC_QUERYCTRL, &queryctrl) < 0) { +- motion_log(LOG_ERR, 1, "ioctl querycontrol"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: ioctl querycontrol"); + return 0; + } + +- motion_log(LOG_DEBUG, 0, "Getting camera range"); +- ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Getting camera range"); + +- /* DWe 30.03.07 The orig request failed : +- * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual +- * Range X = -70 to +70 degrees +- * Y = -30 to +30 degrees +- */ +- +-// //get mininum +-// pan.value = queryctrl.minimum; +- +- cnt->track.panmin = -4480 / INCPANTILT; +- cnt->track.tiltmin = -1920 / INCPANTILT; +-// //get maximum +- cnt->track.panmax = 4480 / INCPANTILT; +- cnt->track.tiltmax = 1920 / INCPANTILT; +-// pan.value = queryctrl.maximum; ++ /* DWe 30.03.07 The orig request failed : ++ * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual ++ * Range X = -70 to +70 degrees ++ * Y = -30 to +30 degrees ++ */ ++ ++ //get mininum ++ //pan.value = queryctrl.minimum; ++ ++ cnt->track.minx = -4480 / INCPANTILT; ++ cnt->track.miny = -1920 / INCPANTILT; ++ //get maximum ++ cnt->track.maxx = 4480 / INCPANTILT; ++ cnt->track.maxy = 1920 / INCPANTILT; ++ //pan.value = queryctrl.maximum; + + cnt->track.dev = dev; + cnt->track.pan_angle = 0; +@@ -635,130 +982,139 @@ static unsigned short int uvc_center(str + + struct v4l2_control control_s; + +- motion_log(LOG_DEBUG, 0, "INPUT_PARAM_ABS pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ", +- cnt->track.panmin, cnt->track.panmax, cnt->track.tiltmin, cnt->track.tiltmax ); +- motion_log(LOG_DEBUG, 0, "INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ", x_angle, y_angle); ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: INPUT_PARAM_ABS pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ", ++ cnt->track.minx, cnt->track.maxx, cnt->track.miny, cnt->track.maxy); ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ", ++ x_angle, y_angle); + +- if (x_angle <= cnt->track.panmax && x_angle >= cnt->track.panmin) ++ if (x_angle <= cnt->track.maxx && x_angle >= cnt->track.minx) + move_x_degrees = x_angle - (cnt->track.pan_angle); + +- if (y_angle <= cnt->track.tiltmax && y_angle >= cnt->track.tiltmin) ++ if (y_angle <= cnt->track.maxy && y_angle >= cnt->track.miny) + move_y_degrees = y_angle - (cnt->track.tilt_angle); +- ++ + + /* +- tilt up: - value +- tilt down: + value +- pan left: - value +- pan right: + value +- */ ++ * tilt up: - value ++ * tilt down: + value ++ * pan left: - value ++ * pan right: + value ++ */ + pan.s16.pan = -move_x_degrees * INCPANTILT; + pan.s16.tilt = -move_y_degrees * INCPANTILT; +- +- motion_log(LOG_DEBUG, 0, "For_SET_ABS move_X %d,move_Y %d", move_x_degrees, move_y_degrees); +- +- /* DWe 30.03.07 Must be broken in diff calls, because +- - one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS +- - The Webcam or uvcvideo does not like a call with a zero-move +- */ +- ++ ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: For_SET_ABS move_X %d,move_Y %d", ++ move_x_degrees, move_y_degrees); ++ ++ /* DWe 30.03.07 Must be broken in diff calls, because ++ * one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS ++ * The Webcam or uvcvideo does not like a call with a zero-move ++ */ ++ + if (move_x_degrees != 0) { + control_s.id = V4L2_CID_PAN_RELATIVE; +- // control_s.value = pan.value; ++ //control_s.value = pan.value; + control_s.value = pan.s16.pan; ++ + if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { +- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); + return 0; + } + } + +- /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ +- if ((move_x_degrees != 0) && (move_y_degrees != 0)) +- SLEEP (1,0); +- +- ++ /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ ++ if ((move_x_degrees != 0) && (move_y_degrees != 0)) ++ SLEEP(1, 0); ++ + if (move_y_degrees != 0) { + control_s.id = V4L2_CID_TILT_RELATIVE; +- // control_s.value = pan.value; ++ //control_s.value = pan.value; + control_s.value = pan.s16.tilt; ++ + if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { +- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); + return 0; +- } +- ++ } + } + +- motion_log(LOG_DEBUG, 0,"Found MINMAX = %d", cnt->track.minmaxfound); ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Found MINMAX = %d", ++ cnt->track.minmaxfound); + + if (cnt->track.dev != -1) { +- motion_log(LOG_DEBUG, 0," Before_ABS_Y_Angel : x= %d , Y= %d , ", +- cnt->track.pan_angle, cnt->track.tilt_angle ); +- if (move_x_degrees != -1) ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: Before_ABS_Y_Angel : x= %d , Y= %d, ", ++ cnt->track.pan_angle, cnt->track.tilt_angle); ++ ++ if (move_x_degrees != -1) { + cnt->track.pan_angle += move_x_degrees; +- +- if (move_x_degrees != -1) ++ } ++ ++ if (move_x_degrees != -1) { + cnt->track.tilt_angle += move_y_degrees; +- +- motion_log(LOG_DEBUG, 0," After_ABS_Y_Angel : x= %d , Y= %d , ", +- cnt->track.pan_angle, cnt->track.tilt_angle ); ++ } ++ ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: After_ABS_Y_Angel : x= %d , Y= %d", ++ cnt->track.pan_angle, cnt->track.tilt_angle); + } + + return cnt->track.move_wait; + } + +-static unsigned short int uvc_move(struct context *cnt, int dev, struct coord *cent, +- struct images *imgs, unsigned short int manual) ++static unsigned int uvc_move(struct context *cnt, int dev, struct coord *cent, ++ struct images *imgs, unsigned int manual) + { + /* RELATIVE MOVING : Act.Position +/- X and Y */ +- ++ + int delta_x = cent->x - (imgs->width / 2); + int delta_y = cent->y - (imgs->height / 2); + int move_x_degrees, move_y_degrees; +- +- /* DWe 30.03.07 Does the request of act.position from WebCam work ? luvcview shows at every position 180 :( */ +- /* Now we init the Web by call Reset, so we can sure, that we are at x/y = 0,0 */ +- /* Don't worry, if the WebCam make a sound - over End at PAN - hmmm, should it be normal ...? */ +- /* PAN Value 7777 in relative will init also a want reset for CAM - it will be "0" after that */ ++ ++ /* ++ * DWe 30.03.07 Does the request of act.position from WebCam work ? luvcview shows at every position 180 :( ++ * Now we init the Web by call Reset, so we can sure, that we are at x/y = 0,0 ++ * Don't worry, if the WebCam make a sound - over End at PAN - hmmm, should it be normal ...? ++ * PAN Value 7777 in relative will init also a want reset for CAM - it will be "0" after that ++ */ + if ((cnt->track.minmaxfound != 1) || (cent->x == 7777)) { +- unsigned short int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt ++ unsigned int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt + struct v4l2_control control_s; + + control_s.id = V4L2_CID_PANTILT_RESET; + control_s.value = (unsigned char) reset; + + if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { +- motion_log(LOG_ERR, 1, "Failed to reset UVC camera to starting position! Reason"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to reset UVC camera to starting position! Reason"); + return 0; + } + +- motion_log(LOG_DEBUG, 0, "Reseting UVC camera to starting position"); +- ++ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Reseting UVC camera to starting position"); ++ + /* set the "helpvalue" back to null because after reset CAM should be in x=0 and not 70 */ + cent->x = 0; +- SLEEP(8,0); +- +- /* DWe 30.03.07 The orig request failed : +- * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual +- * Range X = -70 to +70 degrees +- * Y = -30 to +30 degrees +- */ +- +- cnt->track.panmin = -4480 / INCPANTILT; +- cnt->track.tiltmin = -1920 / INCPANTILT; +- cnt->track.panmax = 4480 / INCPANTILT; +- cnt->track.tiltmax = 1920 / INCPANTILT; ++ SLEEP(8, 0); ++ ++ /* ++ * DWe 30.03.07 The orig request failed : ++ * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual ++ * Range X = -70 to +70 degrees ++ * Y = -30 to +30 degrees ++ */ ++ ++ cnt->track.minx = -4480 / INCPANTILT; ++ cnt->track.miny = -1920 / INCPANTILT; ++ cnt->track.maxx = 4480 / INCPANTILT; ++ cnt->track.maxy = 1920 / INCPANTILT; + cnt->track.dev = dev; + cnt->track.pan_angle = 0; + cnt->track.tilt_angle = 0; + cnt->track.minmaxfound = 1; + } + +- ++ + /* If we are on auto track we calculate delta, otherwise we use user input in degrees */ + if (!manual) { +- if (delta_x > imgs->width * 3 / 8 && delta_x < imgs->width * 5 / 8) ++ if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8) + return 0; +- if (delta_y > imgs->height * 3 / 8 && delta_y < imgs->height * 5 / 8) ++ if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8) + return 0; + + move_x_degrees = delta_x * cnt->track.step_angle_x / (imgs->width / 2); +@@ -780,91 +1136,92 @@ static unsigned short int uvc_move(struc + union pantilt pan; + + if (cnt->track.minmaxfound == 1) { +- /* Check current position of camera and see if we need to adjust +- values down to what is left to move */ +- if (move_x_degrees<0 && (cnt->track.panmin - cnt->track.pan_angle) > move_x_degrees) +- move_x_degrees = (cnt->track.panmin - cnt->track.pan_angle); +- +- if (move_x_degrees>0 && (cnt->track.panmax - cnt->track.pan_angle) < move_x_degrees) +- move_x_degrees = (cnt->track.panmax - cnt->track.pan_angle); +- +- if (move_y_degrees<0 && (cnt->track.tiltmin - cnt->track.tilt_angle) > move_y_degrees) +- move_y_degrees = (cnt->track.tiltmin - cnt->track.tilt_angle); +- +- if (move_y_degrees>0 && (cnt->track.tiltmax - cnt->track.tilt_angle) < move_y_degrees) +- move_y_degrees = (cnt->track.tiltmax - cnt->track.tilt_angle); +- } +- ++ /* ++ * Check current position of camera and see if we need to adjust ++ * values down to what is left to move ++ */ ++ if (move_x_degrees < 0 && (cnt->track.minx - cnt->track.pan_angle) > move_x_degrees) ++ move_x_degrees = cnt->track.minx - cnt->track.pan_angle; ++ ++ if (move_x_degrees > 0 && (cnt->track.maxx - cnt->track.pan_angle) < move_x_degrees) ++ move_x_degrees = cnt->track.maxx - cnt->track.pan_angle; ++ ++ if (move_y_degrees < 0 && (cnt->track.miny - cnt->track.tilt_angle) > move_y_degrees) ++ move_y_degrees = cnt->track.miny - cnt->track.tilt_angle; ++ ++ if (move_y_degrees > 0 && (cnt->track.maxy - cnt->track.tilt_angle) < move_y_degrees) ++ move_y_degrees = cnt->track.maxy - cnt->track.tilt_angle; ++ } ++ ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "For_SET_REL pan_min %d,pan_max %d,tilt_min %d,tilt_max %d", ++ cnt->track.minx, cnt->track.maxx, cnt->track.miny, cnt->track.maxy); ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "For_SET_REL track_pan_Angel %d, track_tilt_Angel %d", ++ cnt->track.pan_angle, cnt->track.tilt_angle); ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "For_SET_REL move_X %d,move_Y %d", move_x_degrees, move_y_degrees); + +- motion_log(LOG_DEBUG, 0, "For_SET_REL pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ", +- cnt->track.panmin, cnt->track.panmax, cnt->track.tiltmin, cnt->track.tiltmax ); +- motion_log(LOG_DEBUG, 0, "For_SET_REL track_pan_Angel %d, track_tilt_Angel %d ", +- cnt->track.pan_angle, cnt->track.tilt_angle); +- motion_log(LOG_DEBUG, 0, "For_SET_REL move_X %d,move_Y %d", +- move_x_degrees, move_y_degrees); + /* +- tilt up: - value +- tilt down: + value +- pan left: - value +- pan right: + value +- */ ++ * tilt up: - value ++ * tilt down: + value ++ * pan left: - value ++ * pan right: + value ++ */ + + pan.s16.pan = -move_x_degrees * INCPANTILT; + pan.s16.tilt = -move_y_degrees * INCPANTILT; +- +- /* DWe 30.03.07 Must be broken in diff calls, because +- - one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS +- - The Webcam or uvcvideo does not like a call with a zero-move +- */ ++ ++ /* DWe 30.03.07 Must be broken in diff calls, because ++ * one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS ++ * The Webcam or uvcvideo does not like a call with a zero-move ++ */ + + if (move_x_degrees != 0) { + + control_s.id = V4L2_CID_PAN_RELATIVE; + + control_s.value = pan.s16.pan; +- motion_log(LOG_DEBUG, 0," dev %d,addr= %d, control_S= %d,Wert= %d,", +- dev,VIDIOC_S_CTRL, &control_s, pan.s16.pan ); ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, " dev %d, addr= %d, control_S= %d, Wert= %d", ++ dev, VIDIOC_S_CTRL, &control_s, pan.s16.pan); + +- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { +- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); ++ if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); + return 0; + } + } +- +- /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ +- if ((move_x_degrees != 0) && (move_y_degrees != 0)) +- SLEEP (1,0); +- ++ ++ /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ ++ if ((move_x_degrees != 0) && (move_y_degrees != 0)) ++ SLEEP (1, 0); + + + if (move_y_degrees != 0) { + + control_s.id = V4L2_CID_TILT_RELATIVE; ++ + control_s.value = pan.s16.tilt; +- motion_log(LOG_DEBUG, 0," dev %d,addr= %d, control_S= %d, Wert= %d, ", +- dev,VIDIOC_S_CTRL, &control_s, pan.s16.tilt); ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, " dev %d,addr= %d, control_S= %d, Wert= %d", ++ dev, VIDIOC_S_CTRL, &control_s, pan.s16.tilt); + + if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { +- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); ++ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); + return 0; + } + } +- +- +- motion_log(LOG_DEBUG, 0,"Found MINMAX = %d", cnt->track.minmaxfound); +- ++ ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: Found MINMAX = %d", ++ cnt->track.minmaxfound); ++ + if (cnt->track.minmaxfound == 1) { +- motion_log(LOG_DEBUG, 0," Before_REL_Y_Angel : x= %d , Y= %d", ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "Before_REL_Y_Angel : x= %d , Y= %d", + cnt->track.pan_angle, cnt->track.tilt_angle); +- +- if (move_x_degrees != 0) ++ ++ if (move_x_degrees != 0) + cnt->track.pan_angle += -pan.s16.pan / INCPANTILT; +- ++ + if (move_y_degrees != 0) + cnt->track.tilt_angle += -pan.s16.tilt / INCPANTILT; +- +- motion_log(LOG_DEBUG, 0," After_REL_Y_Angel : x= %d , Y= %d", +- cnt->track.pan_angle, cnt->track.tilt_angle); ++ ++ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "After_REL_Y_Angel : x= %d , Y= %d", ++ cnt->track.pan_angle, cnt->track.tilt_angle); + } + + return cnt->track.move_wait; +--- motion-3.2.12.orig/track.h ++++ motion-3.2.12/track.h +@@ -10,40 +10,43 @@ + #define _INCLUDE_TRACK_H + + #include "alg.h" ++#include + + struct trackoptions { + int dev; + /* Config options: */ +- unsigned short int type; ++ unsigned int type; + char *port; +- unsigned short int motorx; +- unsigned short int motory; +- unsigned short int maxx; +- unsigned short int maxy; +- unsigned short int stepsize; +- unsigned short int speed; +- unsigned short int iomojo_id; +- unsigned short int active; +- int panmin; +- int panmax; +- int tiltmin; +- int tiltmax; +- unsigned short int minmaxfound; +- unsigned short int step_angle_x; +- unsigned short int step_angle_y; +- unsigned short int move_wait; +- // UVC ++ unsigned int motorx; ++ unsigned int motory; ++ int maxx; ++ int maxy; ++ int minx; ++ int miny; ++ unsigned int stepsize; ++ unsigned int speed; ++ unsigned int homex; ++ unsigned int homey; ++ unsigned int iomojo_id; ++ unsigned int active; ++ unsigned int motorx_reverse; ++ unsigned int motory_reverse; ++ unsigned int minmaxfound; ++ unsigned int step_angle_x; ++ unsigned int step_angle_y; ++ unsigned int move_wait; ++ /* UVC */ + int pan_angle; // degrees + int tilt_angle; // degrees + }; + + extern struct trackoptions track_template; + +-unsigned short int track_center(struct context *, int, unsigned short int, int, int); +-unsigned short int track_move(struct context *, int, struct coord *, struct images *, unsigned short int); ++unsigned int track_center(struct context *, int, unsigned int, int, int); ++unsigned int track_move(struct context *, int, struct coord *, struct images *, unsigned int); + + /* +- Some default values: ++ * Some default values: + */ + #define TRACK_SPEED 255 + #define TRACK_STEPSIZE 40 +@@ -53,9 +56,10 @@ unsigned short int track_move(struct con + #define TRACK_TYPE_PWC 3 + #define TRACK_TYPE_GENERIC 4 + #define TRACK_TYPE_UVC 5 ++#define TRACK_TYPE_SERVO 6 + + /* +- Some defines for the Serial stepper motor: ++ * Some defines for the Serial stepper motor: + */ + + #define STEPPER_BAUDRATE B9600 +@@ -87,8 +91,53 @@ unsigned short int track_move(struct con + #define STEPPER_COMMAND_DOWN 4 + + ++ + /* +- Some defines for the Iomojo Smilecam: ++ * Some defines for the Serial servo motor: ++ */ ++ ++/* ++ * Controlling: ++ * Three bytes are sent to the servo - BYTE1=SERVO_COMMAND BYTE2=COMMAND BYTE3=DATA ++ * eg, sending the command 01 02 08 would Command SERVO_COMMAND1 to move LEFT a total of 8 STEPS ++ * ++ * An extra command 0x08 has been added but here is the basic command set. ++ * ++ * 0x00 STATUS - Current status byte will be returned, data byte ignored ++ * 0x01 LEFT_N - Servo will take N Steps to the Left until it reaches the Servos safety limit ++ * 0x02 RIGHT_N - Servo will take N Steps to the Right until it reaches the Servos safety limit ++ * 0x03 LEFT - Servo will move to Left most position, data byte ignored. ++ * 0x04 RIGHT - Servo will move to Right most position, data byte ignored. ++ * 0x05 SWEEP - Servo will sweep between its extremes, data byte ignored. ++ * 0x06 STOP - Servo will Stop, data byte ignored ++ * 0x07 SPEED - Set servos speed between 0 and 255. ++ * 0x08 ABSOLUTE - Set servo to absolute position between 0 and 255 ++ * 0x09 POSITION - Get servo to absolute position between 0 and 255 ++ * */ ++ ++#define SERVO_BAUDRATE B9600 ++ ++#define SERVO_COMMAND_STATUS 0 ++#define SERVO_COMMAND_LEFT_N 1 ++#define SERVO_COMMAND_RIGHT_N 2 ++#define SERVO_COMMAND_LEFT 3 ++#define SERVO_COMMAND_RIGHT 4 ++#define SERVO_COMMAND_SWEEP 5 ++#define SERVO_COMMAND_STOP 6 ++#define SERVO_COMMAND_SPEED 7 ++#define SERVO_COMMAND_ABSOLUTE 8 ++#define SERVO_COMMAND_POSITION 9 ++ ++ ++#define SERVO_COMMAND_UP_N 1 ++#define SERVO_COMMAND_DOWN_N 2 ++#define SERVO_COMMAND_UP 3 ++#define SERVO_COMMAND_DOWN 4 ++ ++ ++ ++/* ++ * Some defines for the Iomojo Smilecam: + */ + + #define IOMOJO_BAUDRATE B19200 +@@ -109,14 +158,14 @@ unsigned short int track_move(struct con + #ifndef WITHOUT_V4L + + /* +- Defines for the Logitech QuickCam Orbit/Sphere USB webcam +-*/ ++ * Defines for the Logitech QuickCam Orbit/Sphere USB webcam ++ */ + + #define LQOS_VERTICAL_DEGREES 180 + #define LQOS_HORIZONAL_DEGREES 120 + + /* +- * UVC ++ * UVC + */ + + #ifdef MOTION_V4L2 +--- motion-3.2.12.orig/version.sh ++++ motion-3.2.12/version.sh +@@ -3,4 +3,6 @@ + SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` + test $SNV_VERSION || SNV_VERSION=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` + test $SNV_VERSION || SNV_VERSION=UNKNOWN +-echo -n "3.2.12" ++SNV_VERSION=`git show -s --format=%h` ++echo -n "3.2.12-4ppa01" ++ +--- motion-3.2.12.orig/video.c ++++ motion-3.2.12/video.c +@@ -1,4 +1,5 @@ +-/* video.c ++/* ++ * video.c + * + * Video stream functions for motion. + * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) +@@ -6,20 +7,15 @@ + * See also the file 'COPYING'. + * + */ +-#ifndef WITHOUT_V4L +- + /* Common stuff: */ + #include "rotate.h" /* already includes motion.h */ + #include "video.h" + ++#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) + +-/* for the v4l stuff: */ +-#include +-#include +-#include +-#include +- +- ++/** ++ * v4l_picture_controls ++ */ + static void v4l_picture_controls(struct context *cnt, struct video_dev *viddev) + { + int dev = viddev->fd; +@@ -29,7 +25,7 @@ static void v4l_picture_controls(struct + if (cnt->conf.contrast && cnt->conf.contrast != viddev->contrast) { + + if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); + + make_change = 1; + vid_pic.contrast = cnt->conf.contrast * 256; +@@ -39,8 +35,8 @@ static void v4l_picture_controls(struct + if (cnt->conf.saturation && cnt->conf.saturation != viddev->saturation) { + + if (!make_change) { +- if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); ++ if (ioctl(dev, VIDIOCGPICT, &vid_pic)==-1) ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); + } + + make_change = 1; +@@ -52,7 +48,7 @@ static void v4l_picture_controls(struct + + if (!make_change) { + if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); + } + + make_change = 1; +@@ -67,71 +63,72 @@ static void v4l_picture_controls(struct + int fps; + + if (ioctl(dev, VIDIOCGWIN, &vw) == -1) { +- motion_log(LOG_ERR, 1, "%s: ioctl VIDIOCGWIN", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl VIDIOCGWIN"); + } else { + fps = vw.flags >> PWC_FPS_SHIFT; +- motion_log(LOG_DEBUG, 0, "%s: Get Current framerate %d .. trying %d", +- __FUNCTION__, fps, cnt->conf.frame_limit); ++ MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: Get Current framerate %d .. trying %d", ++ fps, cnt->conf.frame_limit); + } + + fps = cnt->conf.frame_limit; + vw.flags = fps << PWC_FPS_SHIFT; +- ++ + if (ioctl(dev, VIDIOCSWIN, &vw) == -1) { +- motion_log(LOG_ERR, 1, "%s: ioctl VIDIOCSWIN", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl VIDIOCSWIN"); + } else if (ioctl(dev, VIDIOCGWIN, &vw) == -1) { +- motion_log(LOG_ERR, 1, "%s: ioctl VIDIOCGWIN", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl VIDIOCGWIN"); + } else { + fps = vw.flags >> PWC_FPS_SHIFT; +- motion_log(LOG_DEBUG, 0, "%s: Set new framerate %d", __FUNCTION__, fps); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set new framerate %d", fps); + } + + viddev->fps = fps; + } + #endif + +- + if (cnt->conf.autobright) { + + if (vid_do_autobright(cnt, viddev)) { +- /* If we already read the VIDIOGPICT - we should not do it again */ ++ /* If we already read the VIDIOGPICT - we should not do it again. */ + if (!make_change) { + if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); + } + + vid_pic.brightness = viddev->brightness * 256; + make_change = 1; + } + +- } else { +- if (cnt->conf.brightness && cnt->conf.brightness != viddev->brightness) { +- if (!make_change) { +- if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); +- } +- +- make_change = 1; +- vid_pic.brightness = cnt->conf.brightness * 256; +- viddev->brightness = cnt->conf.brightness; +- } ++ } else if (cnt->conf.brightness && cnt->conf.brightness != viddev->brightness) { ++ ++ if ((!make_change) && (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1)) ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); ++ ++ make_change = 1; ++ vid_pic.brightness = cnt->conf.brightness * 256; ++ viddev->brightness = cnt->conf.brightness; + } + + if (make_change) { + if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSPICT)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSPICT)"); + } + } + +- +- +-/******************************************************************************************* ++/******************************************************************************* + Video4linux capture routines +-*/ ++********************************************************************************/ + +- +-unsigned char *v4l_start(struct context *cnt, struct video_dev *viddev, int width, int height, +- int input, int norm, unsigned long freq, int tuner_number) ++/** ++ * v4l_start ++ * Initialize video device to start capturing and allocates memory map ++ * for video device. ++ * ++ * Returns mmapped buffer for video device or NULL if any error happens. ++ * ++ */ ++unsigned char *v4l_start(struct video_dev *viddev, int width, int height,int input, ++ int norm, unsigned long freq, int tuner_number) + { + int dev = viddev->fd; + struct video_capability vid_caps; +@@ -142,7 +139,7 @@ unsigned char *v4l_start(struct context + void *map; + + if (ioctl (dev, VIDIOCGCAP, &vid_caps) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGCAP)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGCAP)"); + return NULL; + } + +@@ -154,12 +151,14 @@ unsigned char *v4l_start(struct context + vid_chnl.channel = input; + + if (ioctl (dev, VIDIOCGCHAN, &vid_chnl) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGCHAN)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGCHAN) Input %d", ++ input); + } else { + vid_chnl.channel = input; + vid_chnl.norm = norm; + if (ioctl (dev, VIDIOCSCHAN, &vid_chnl) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSCHAN)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSCHAN) Input %d" ++ " Standard method %d", input, norm); + return NULL; + } + } +@@ -169,28 +168,29 @@ unsigned char *v4l_start(struct context + memset(&vid_tuner, 0, sizeof(struct video_tuner)); + vid_tuner.tuner = tuner_number; + if (ioctl (dev, VIDIOCGTUNER, &vid_tuner) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGTUNER)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGTUNER) tuner %d", ++ tuner_number); + } else { +- if (vid_tuner.flags & VIDEO_TUNER_LOW) { ++ if (vid_tuner.flags & VIDEO_TUNER_LOW) + freq = freq * 16; /* steps of 1/16 KHz */ +- } else { +- freq = (freq * 10) / 625; +- } +- ++ else ++ freq = freq * 10 / 625; ++ + if (ioctl(dev, VIDIOCSFREQ, &freq) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSFREQ)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSFREQ)" ++ " Frequency %ul", freq); + return NULL; + } + +- if (cnt->conf.setup_mode) +- motion_log(-1, 0, "Frequency set"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Tuner to %d Frequency set to %ul", ++ tuner_number, freq); + } + } + + if (ioctl (dev, VIDIOCGMBUF, &vid_buf) == -1) { +- motion_log(LOG_ERR, 0, "ioctl(VIDIOCGMBUF) - Error device does not support memory map"); +- motion_log(LOG_ERR, 0, "V4L capturing using read is deprecated!"); +- motion_log(LOG_ERR, 0, "Motion only supports mmap."); ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: ioctl(VIDIOCGMBUF) - Error device" ++ " does not support memory map\n V4L capturing using read is deprecated!\n" ++ "Motion only supports mmap."); + return NULL; + } else { + map = mmap(0, vid_buf.size, PROT_READ|PROT_WRITE, MAP_SHARED, dev, 0); +@@ -206,7 +206,7 @@ unsigned char *v4l_start(struct context + } + + if (MAP_FAILED == map) { +- motion_log(LOG_ERR,1,"MAP_FAILED"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: MAP_FAILED"); + return NULL; + } + +@@ -215,32 +215,35 @@ unsigned char *v4l_start(struct context + vid_mmap.frame = viddev->v4l_curbuffer; + vid_mmap.width = width; + vid_mmap.height = height; ++ + if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { +- motion_log(LOG_DEBUG, 1, "Failed with YUV420P, trying YUV422 palette"); ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with YUV420P, " ++ "trying YUV422 palette"); + viddev->v4l_fmt = VIDEO_PALETTE_YUV422; + vid_mmap.format = viddev->v4l_fmt; +- + /* Try again... */ + if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { +- motion_log(LOG_DEBUG, 1, "Failed with YUV422, trying YUYV palette"); ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with YUV422," ++ " trying YUYV palette"); + viddev->v4l_fmt = VIDEO_PALETTE_YUYV; + vid_mmap.format = viddev->v4l_fmt; + + if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { +- motion_log(LOG_DEBUG, 1, "Failed with YUYV, trying RGB24 palette"); ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with YUYV, trying RGB24 palette"); + viddev->v4l_fmt = VIDEO_PALETTE_RGB24; + vid_mmap.format = viddev->v4l_fmt; +- + /* Try again... */ ++ + if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { +- motion_log(LOG_DEBUG, 1, "Failed with RGB24, trying GREYSCALE palette"); ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with RGB24, trying" ++ "GREYSCALE palette"); + viddev->v4l_fmt = VIDEO_PALETTE_GREY; + vid_mmap.format = viddev->v4l_fmt; + + /* Try one last time... */ + if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { +- motion_log(LOG_ERR, 1, "Failed with all supported palettes " +- "- giving up"); ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with all supported palettes " ++ "- giving up"); + return NULL; + } + } +@@ -252,23 +255,23 @@ unsigned char *v4l_start(struct context + switch (viddev->v4l_fmt) { + case VIDEO_PALETTE_YUV420P: + viddev->v4l_bufsize = (width * height * 3) / 2; +- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_YUV420P palette"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_YUV420P palette"); + break; + case VIDEO_PALETTE_YUV422: + viddev->v4l_bufsize = (width * height * 2); +- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_YUV422 palette"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_YUV422 palette"); + break; + case VIDEO_PALETTE_YUYV: + viddev->v4l_bufsize = (width * height * 2); +- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_YUYV palette"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_YUYV palette"); + break; + case VIDEO_PALETTE_RGB24: + viddev->v4l_bufsize = (width * height * 3); +- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_RGB24 palette"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_RGB24 palette"); + break; + case VIDEO_PALETTE_GREY: + viddev->v4l_bufsize = width * height; +- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_GREY palette"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_GREY palette"); + break; + } + +@@ -278,7 +281,7 @@ unsigned char *v4l_start(struct context + + /** + * v4l_next +- * v4l_next fetches a video frame from a v4l device ++ * Fetches a video frame from a v4l device + * + * Parameters: + * viddev Pointer to struct containing video device handle amd device parameters +@@ -299,7 +302,7 @@ int v4l_next(struct video_dev *viddev, u + struct video_mmap vid_mmap; + unsigned char *cap_map; + +- sigset_t set, old; ++ sigset_t set, old; + + /* MMAP method is used */ + vid_mmap.format = viddev->v4l_fmt; +@@ -324,7 +327,8 @@ int v4l_next(struct video_dev *viddev, u + vid_mmap.frame = viddev->v4l_curbuffer; + + if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { +- motion_log(LOG_ERR, 1, "mcapture error in proc %d", getpid()); ++ MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO, "%s: mcapture error in proc %d", ++ getpid()); + sigprocmask (SIG_UNBLOCK, &old, NULL); + return V4L_FATAL_ERROR; + } +@@ -332,11 +336,12 @@ int v4l_next(struct video_dev *viddev, u + vid_mmap.frame = frame; + + if (ioctl(dev, VIDIOCSYNC, &vid_mmap.frame) == -1) { +- motion_log(LOG_ERR, 1, "sync error in proc %d", getpid()); ++ MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO, "%s: sync error in proc %d", ++ getpid()); + sigprocmask (SIG_UNBLOCK, &old, NULL); + } + +- pthread_sigmask (SIG_UNBLOCK, &old, NULL); /*undo the signal blocking*/ ++ pthread_sigmask (SIG_UNBLOCK, &old, NULL); /*undo the signal blocking*/ + + switch (viddev->v4l_fmt) { + case VIDEO_PALETTE_RGB24: +@@ -353,35 +358,59 @@ int v4l_next(struct video_dev *viddev, u + return 0; + } + +-void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, +- int height, int input, int norm, int skip, unsigned long freq, int tuner_number) ++/** ++ * v4l_set_input ++ * Sets input for video device, adjust picture controls. ++ * If needed skip frames for round robin. ++ * ++ * Parameters: ++ * cnt Pointer to context struct ++ * viddev Pointer to struct containing video device handle amd device parameters ++ * map Pointer to the buffer in which the function puts the new image ++ * width Width of image in pixels ++ * height Height of image in pixels ++ * conf Pointer to config struct ++ * ++ * Returns nothing ++ */ ++void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, ++ int width, int height, struct config *conf) + { + int dev = viddev->fd; +- int i; + struct video_channel vid_chnl; + struct video_tuner vid_tuner; +- unsigned long frequnits = freq; ++ unsigned long frequnits , freq; ++ int input = conf->input; ++ int norm = conf->norm; ++ int tuner_number = conf->tuner_number; + +- if (input != viddev->input || width != viddev->width || height != viddev->height || +- freq != viddev->freq || tuner_number != viddev->tuner_number) { ++ frequnits = freq = conf->frequency; + ++ if (input != viddev->input || width != viddev->width || height != viddev->height || ++ freq != viddev->freq || tuner_number != viddev->tuner_number || norm != viddev->norm) { ++ unsigned int skip = conf->roundrobin_skip, i; ++ + if (freq) { + memset(&vid_tuner, 0, sizeof(struct video_tuner)); +- + vid_tuner.tuner = tuner_number; ++ + if (ioctl (dev, VIDIOCGTUNER, &vid_tuner) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGTUNER)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGTUNER) tuner number %d", ++ tuner_number); + } else { + if (vid_tuner.flags & VIDEO_TUNER_LOW) + frequnits = freq * 16; /* steps of 1/16 KHz */ + else + frequnits = (freq * 10) / 625; + +- + if (ioctl(dev, VIDIOCSFREQ, &frequnits) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSFREQ)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSFREQ) Frequency %ul", ++ frequnits); + return; + } ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Tuner to %d Frequency to %ul", ++ tuner_number, frequnits); + } + } + +@@ -389,233 +418,35 @@ void v4l_set_input(struct context *cnt, + vid_chnl.channel = input; + + if (ioctl (dev, VIDIOCGCHAN, &vid_chnl) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGCHAN)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGCHAN) Input %d", ++ input); + } else { + vid_chnl.channel = input; + vid_chnl.norm = norm; ++ + if (ioctl (dev, VIDIOCSCHAN, &vid_chnl) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSCHAN)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSCHAN) Input %d" ++ " Standard method %d", input, norm); + return; +- } ++ } ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Input to %d Standard method to %d", ++ input, norm); + } + + v4l_picture_controls(cnt, viddev); +- viddev->input = input; +- viddev->width = width; +- viddev->height = height; +- viddev->freq =freq; +- viddev->tuner_number = tuner_number; ++ conf->input = viddev->input = input; ++ conf->width = viddev->width = width; ++ conf->height = viddev->height = height; ++ conf->frequency = viddev->freq = freq; ++ conf->tuner_number = viddev->tuner_number = tuner_number; ++ conf->norm = viddev->norm = norm; + /* skip a few frames if needed */ + for (i = 0; i < skip; i++) + v4l_next(viddev, map, width, height); +- + } else { + /* No round robin - we only adjust picture controls */ + v4l_picture_controls(cnt, viddev); + } + } +- +-static int v4l_open_vidpipe(void) +-{ +- int pipe_fd = -1; +- char pipepath[255]; +- char buffer[255]; +- char *major; +- char *minor; +- struct utsname uts; +- +- if (uname(&uts) < 0) { +- motion_log(LOG_ERR, 1, "Unable to execute uname"); +- return -1; +- } +- major = strtok(uts.release, "."); +- minor = strtok(NULL, "."); +- +- if ((major == NULL) || (minor == NULL) || (strcmp(major, "2"))) { +- motion_log(LOG_ERR, 1, "Unable to decipher OS version"); +- return -1; +- } +- +- if (strcmp(minor, "5") < 0) { +- FILE *vloopbacks; +- char *loop; +- char *input; +- char *istatus; +- char *output; +- char *ostatus; +- +- vloopbacks = fopen("/proc/video/vloopback/vloopbacks", "r"); +- +- if (!vloopbacks) { +- motion_log(LOG_ERR, 1, "Failed to open '/proc/video/vloopback/vloopbacks'"); +- return -1; +- } +- +- /* Read vloopback version*/ +- if (!fgets(buffer, 255, vloopbacks)) { +- motion_log(LOG_ERR, 1, "Unable to read vloopback version"); +- return -1; +- } +- +- fprintf(stderr,"\t%s", buffer); +- +- /* Read explanation line */ +- +- if (!fgets(buffer, 255, vloopbacks)) { +- motion_log(LOG_ERR, 1, "Unable to read vloopback explanation line"); +- return -1; +- } +- +- while (fgets(buffer, 255, vloopbacks)) { +- if (strlen(buffer) > 1) { +- buffer[strlen(buffer)-1] = 0; +- loop=strtok(buffer, "\t"); +- input=strtok(NULL, "\t"); +- istatus=strtok(NULL, "\t"); +- output=strtok(NULL, "\t"); +- ostatus=strtok(NULL, "\t"); +- if (istatus[0] == '-') { +- snprintf(pipepath, 255, "/dev/%s", input); +- pipe_fd = open(pipepath, O_RDWR); +- if (pipe_fd >= 0) { +- motion_log(-1, 0, "\tInput: /dev/%s", input); +- motion_log(-1, 0, "\tOutput: /dev/%s", output); +- break; +- } +- } +- } +- } +- fclose(vloopbacks); +- } else { +- DIR *dir; +- struct dirent *dirp; +- const char prefix[] = "/sys/class/video4linux/"; +- char *ptr, *io; +- int fd; +- int low = 9999; +- int tfd; +- int tnum; +- +- if ((dir=opendir(prefix)) == NULL) { +- motion_log(LOG_ERR, 1, "Failed to open '%s'", prefix); +- return -1; +- } +- +- while ((dirp=readdir(dir)) != NULL) { +- if (!strncmp(dirp->d_name, "video", 5)) { +- strncpy(buffer, prefix, sizeof(buffer)); +- strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); +- strncat(buffer, "/name", sizeof(buffer) - strlen(buffer)); +- if ((fd = open(buffer, O_RDONLY)) >= 0) { +- if ((read(fd, buffer, sizeof(buffer)-1)) < 0) { +- close(fd); +- continue; +- } +- +- ptr = strtok(buffer, " "); +- +- if (strcmp(ptr,"Video")) { +- close(fd); +- continue; +- } +- +- major = strtok(NULL, " "); +- minor = strtok(NULL, " "); +- io = strtok(NULL, " \n"); +- +- if (strcmp(major, "loopback") || strcmp(io, "input")) { +- close(fd); +- continue; +- } +- +- if ((ptr=strtok(buffer, " ")) == NULL) { +- close(fd); +- continue; +- } +- +- tnum = atoi(minor); +- +- if (tnum < low) { +- strcpy(buffer, "/dev/"); +- strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); +- if ((tfd=open(buffer, O_RDWR)) >= 0) { +- strncpy(pipepath, buffer, sizeof(pipepath)); +- +- if (pipe_fd >= 0) +- close(pipe_fd); +- +- pipe_fd = tfd; +- low = tnum; +- } +- } +- close(fd); +- } +- } +- } +- closedir(dir); +- +- if (pipe_fd >= 0) +- motion_log(-1, 0, "Opened input of %s", pipepath); +- } +- +- return pipe_fd; +-} +- +-static int v4l_startpipe(const char *dev_name, int width, int height, int type) +-{ +- int dev; +- struct video_picture vid_pic; +- struct video_window vid_win; +- +- if (!strcmp(dev_name, "-")) +- dev = v4l_open_vidpipe(); +- else +- dev = open(dev_name, O_RDWR); +- +- if (dev < 0) +- return -1; +- +- if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); +- return -1; +- } +- +- vid_pic.palette = type; +- +- if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSPICT)"); +- return -1; +- } +- +- if (ioctl(dev, VIDIOCGWIN, &vid_win) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGWIN)"); +- return -1; +- } +- +- vid_win.height = height; +- vid_win.width = width; +- +- if (ioctl(dev, VIDIOCSWIN, &vid_win) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSWIN)"); +- return -1; +- } +- +- return dev; +-} +- +-static int v4l_putpipe (int dev, unsigned char *image, int size) +-{ +- return write(dev, image, size); +-} +- +- +-int vid_startpipe(const char *dev_name, int width, int height, int type) +-{ +- return v4l_startpipe(dev_name, width, height, type); +-} +- +-int vid_putpipe (int dev, unsigned char *image, int size) +-{ +- return v4l_putpipe(dev, image, size); +-} +-#endif /*WITHOUT_V4L*/ ++#endif /* !WITHOUT_V4L */ +--- motion-3.2.12.orig/video.h ++++ motion-3.2.12/video.h +@@ -1,6 +1,6 @@ +-/* video.h ++/* video.h + * +- * Include file for video.c ++ * Include file for video.c + * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) + * This software is distributed under the GNU public license version 2 + * See also the file 'COPYING'. +@@ -11,30 +11,42 @@ + #define _INCLUDE_VIDEO_H + + #define _LINUX_TIME_H 1 +-#ifndef WITHOUT_V4L +-#include + #include ++ ++ ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) ++#include ++#include "vloopback_motion.h" + #include "pwc-ioctl.h" + #endif + + /* video4linux stuff */ +-#define NORM_DEFAULT 0 +-#define NORM_PAL 0 +-#define NORM_NTSC 1 +-#define NORM_SECAM 2 +-#define NORM_PAL_NC 3 +-#define IN_DEFAULT 8 +-#define IN_TV 0 +-#define IN_COMPOSITE 1 +-#define IN_COMPOSITE2 2 +-#define IN_SVIDEO 3 ++#define NORM_DEFAULT 0 ++#define NORM_PAL 0 ++#define NORM_NTSC 1 ++#define NORM_SECAM 2 ++#define NORM_PAL_NC 3 ++#define IN_DEFAULT -1 ++#define IN_TV 0 ++#define IN_COMPOSITE 1 ++#define IN_COMPOSITE2 2 ++#define IN_SVIDEO 3 + + /* video4linux error codes */ +-#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ +-#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ +-#define V4L_FATAL_ERROR -1 ++#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ ++#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ ++#define V4L_FATAL_ERROR -1 ++ ++#define VIDEO_DEVICE "/dev/video0" ++ ++typedef struct video_image_buff { ++ unsigned char *ptr; ++ int content_length; ++ size_t size; /* total allocated size */ ++ size_t used; /* bytes already used */ ++ struct timeval image_time; /* time this image was received */ ++} video_buff; + +-#define VIDEO_DEVICE "/dev/video0" + + struct video_dev { + struct video_dev *next; +@@ -42,6 +54,7 @@ struct video_dev { + int fd; + const char *video_device; + int input; ++ int norm; + int width; + int height; + int brightness; +@@ -62,7 +75,7 @@ struct video_dev { + /* v4l */ + int v4l2; + void *v4l2_private; +- ++ + int size_map; + int v4l_fmt; + unsigned char *v4l_buffers[2]; +@@ -73,39 +86,35 @@ struct video_dev { + }; + + /* video functions, video_common.c */ +-int vid_start(struct context *); +-int vid_next(struct context *, unsigned char *map); ++int vid_start(struct context *cnt); ++int vid_next(struct context *cnt, unsigned char *map); + void vid_close(struct context *cnt); + void vid_cleanup(void); + void vid_init(void); + void conv_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height); + void conv_uyvyto420p(unsigned char *map, unsigned char *cap_map, unsigned int width, unsigned int height); + void conv_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height); +-int conv_jpeg2yuv420(struct context *cnt, unsigned char *dst, netcam_buff * buff, int width, int height); +-int sonix_decompress(unsigned char *outp, unsigned char *inp,int width, int height); ++int sonix_decompress(unsigned char *outp, unsigned char *inp, int width, int height); + void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height); + int vid_do_autobright(struct context *cnt, struct video_dev *viddev); + int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size); + + #ifndef WITHOUT_V4L + /* video functions, video.c */ +-int vid_startpipe(const char *dev_name, int width, int height, int); +-int vid_putpipe(int dev, unsigned char *image, int); +-unsigned char *v4l_start(struct context *cnt, struct video_dev *viddev, int width, int height, ++unsigned char *v4l_start(struct video_dev *viddev, int width, int height, + int input, int norm, unsigned long freq, int tuner_number); +-void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, +- int height, int input, int norm, int skip, unsigned long freq, int tuner_number); ++void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, ++ struct config *conf); + int v4l_next(struct video_dev *viddev, unsigned char *map, int width, int height); + + /* video2.c */ + unsigned char *v4l2_start(struct context *cnt, struct video_dev *viddev, int width, int height, + int input, int norm, unsigned long freq, int tuner_number); +-void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, +- int height, struct config *conf); ++void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, ++ struct config *conf); + int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height); + void v4l2_close(struct video_dev *viddev); + void v4l2_cleanup(struct video_dev *viddev); +- + #endif /* WITHOUT_V4L */ + +-#endif /* _INCLUDE_VIDEO_H */ ++#endif /* _INCLUDE_VIDEO_H */ +--- motion-3.2.12.orig/video2.c ++++ motion-3.2.12/video2.c +@@ -3,35 +3,57 @@ + * + * V4L2 interface with basically JPEG decompression support and even more ... + * Copyright 2006 Krzysztof Blaszkowski (kb@sysmikro.com.pl) +- * 2007 Angel Carpintero (ack@telefonica.net) +- ++ * 2007 Angel Carpintero (motiondevelop@gmail.com) ++ + * Supported features and TODO +- * - preferred palette is JPEG which seems to be very popular for many 640x480 usb cams +- * - other supported palettes (NOT TESTED) +- * V4L2_PIX_FMT_SBGGR8 (sonix) +- * V4L2_PIX_FMT_SN9C10X (sonix) +- * V4L2_PIX_FMT_MJPEG, (tested) +- * V4L2_PIX_FMT_JPEG, (tested) +- V4L2_PIX_FMT_RGB24, +- V4L2_PIX_FMT_UYVY, (tested) +- V4L2_PIX_FMT_YUV422P, +- V4L2_PIX_FMT_YUV420, (tested) +- V4L2_PIX_FMT_YUYV (tested) +- +- * - setting tuner - NOT TESTED ++ - preferred palette is JPEG which seems to be very popular for many 640x480 usb cams ++ - other supported palettes (NOT TESTED) ++ V4L2_PIX_FMT_SN9C10X (sonix) ++ V4L2_PIX_FMT_SBGGR16, ++ V4L2_PIX_FMT_SBGGR8, (sonix) ++ V4L2_PIX_FMT_SPCA561, ++ V4L2_PIX_FMT_SGBRG8, ++ V4L2_PIX_FMT_SGRBG8, ++ V4L2_PIX_FMT_PAC207, ++ V4L2_PIX_FMT_PJPG, ++ V4L2_PIX_FMT_MJPEG, (tested) ++ V4L2_PIX_FMT_JPEG, (tested) ++ V4L2_PIX_FMT_RGB24, ++ V4L2_PIX_FMT_SPCA501, ++ V4L2_PIX_FMT_SPCA505, ++ V4L2_PIX_FMT_SPCA508, ++ V4L2_PIX_FMT_UYVY, (tested) ++ V4L2_PIX_FMT_YUV422P, ++ V4L2_PIX_FMT_YUV420, (tested) ++ V4L2_PIX_FMT_YUYV (tested) ++ ++ * - setting tuner - NOT TESTED + * - access to V4L2 device controls is missing. Partially added but requires some improvements likely. +- * - changing resolution at run-time may not work. +- * - ucvideo svn r75 or above to work with MJPEG ( i.ex Logitech 5000 pro ) +- ++ * - changing resolution at run-time may not work. ++ * - ucvideo svn r75 or above to work with MJPEG ( e.g. Logitech 5000 pro ) ++ + * This work is inspired by fswebcam and current design of motion. + * This interface has been tested with ZC0301 driver from kernel 2.6.17.3 and Labtec's usb camera (PAS202 sensor) +- +- * I'm very pleased by achieved image quality and cpu usage comparing to junky v4l1 spca5xx driver with ++ ++ * I'm very pleased by achieved image quality and cpu usage comparing to junky v4l1 spca5xx driver with + * it nonsensical kernel messy jpeg decompressor. + * Default sensor settings used by ZC0301 driver are very reasonable choosen. + * apparently brigthness should be controlled automatically by motion still for light compensation. + * it can be done by adjusting ADC gain and also exposure time. +- ++ ++ * Kernel 2.6.27 ++ ++ V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') YUYV per line ++ V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') YYUV per line ++ V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') YUVY per line ++ V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') 8 GBGB.. RGRG.. ++ V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') 8 GRGR.. BGBG.. ++ V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') 16 BGBG.. GRGR.. ++ V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') compressed GBRG bayer ++ V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') Pixart 73xx JPEG ++ V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') compressed BGGR bayer ++ ++ + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the +@@ -46,11 +68,9 @@ + let's go :) + */ + +-#ifndef WITHOUT_V4L +-#ifdef MOTION_V4L2 ++#if !defined(WITHOUT_V4L) && defined(MOTION_V4L2) + + #include "motion.h" +-#include "netcam.h" + #include "video.h" + + #ifdef MOTION_V4L2_OLD +@@ -64,24 +84,60 @@ + #define u32 unsigned int + #define s32 signed int + +-#define MMAP_BUFFERS 4 +-#define MIN_MMAP_BUFFERS 2 ++#define MMAP_BUFFERS 4 ++#define MIN_MMAP_BUFFERS 2 + + #ifndef V4L2_PIX_FMT_SBGGR8 + /* see http://www.siliconimaging.com/RGB%20Bayer.htm */ +-#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ ++#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ + #endif + + #ifndef V4L2_PIX_FMT_MJPEG +-#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ ++#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ + #endif + + #ifndef V4L2_PIX_FMT_SN9C10X +-#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ ++#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_SGBRG8 ++#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_SGRBG8 ++#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_SBGGR16 ++#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ + #endif + +-#define ZC301_V4L2_CID_DAC_MAGN V4L2_CID_PRIVATE_BASE +-#define ZC301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE+1) ++#ifndef V4L2_PIX_FMT_SPCA561 ++#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_PJPG ++#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_PAC207 ++#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_SPCA501 ++#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_SPCA505 ++#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */ ++#endif ++ ++#ifndef V4L2_PIX_FMT_SPCA508 ++#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */ ++#endif ++ ++#define ZC301_V4L2_CID_DAC_MAGN V4L2_CID_PRIVATE_BASE ++#define ZC301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE+1) + + static const u32 queried_ctrls[] = { + V4L2_CID_BRIGHTNESS, +@@ -103,15 +159,15 @@ static const u32 queried_ctrls[] = { + + typedef struct { + int fd; +- char map; + u32 fps; + + struct v4l2_capability cap; +- struct v4l2_format fmt; ++ struct v4l2_format src_fmt; ++ struct v4l2_format dst_fmt; + struct v4l2_requestbuffers req; + struct v4l2_buffer buf; + +- netcam_buff *buffers; ++ video_buff *buffers; + + s32 pframe; + +@@ -120,121 +176,130 @@ typedef struct { + + } src_v4l2_t; + ++/** ++ * xioctl ++ */ + static int xioctl(int fd, int request, void *arg) + { +- int r; ++ int ret; + + do +- r = ioctl(fd, request, arg); +- while (-1 == r && EINTR == errno); ++ ret = ioctl(fd, request, arg); ++ while (-1 == ret && EINTR == errno); + +- return r; ++ return ret; + } + +-static int v4l2_get_capability(src_v4l2_t * s) ++/** ++ * v4l2_get_capability ++ */ ++static int v4l2_get_capability(src_v4l2_t * vid_source) + { +- if (xioctl(s->fd, VIDIOC_QUERYCAP, &s->cap) < 0) { +- motion_log(LOG_ERR, 0, "Not a V4L2 device?"); ++ if (xioctl(vid_source->fd, VIDIOC_QUERYCAP, &vid_source->cap) < 0) { ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Not a V4L2 device?"); + return -1; + } + +- motion_log(LOG_INFO, 0, "cap.driver: \"%s\"", s->cap.driver); +- motion_log(LOG_INFO, 0, "cap.card: \"%s\"", s->cap.card); +- motion_log(LOG_INFO, 0, "cap.bus_info: \"%s\"", s->cap.bus_info); +- motion_log(LOG_INFO, 0, "cap.capabilities=0x%08X", s->cap.capabilities); +- +- if (s->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) +- motion_log(LOG_INFO, 0, "- VIDEO_CAPTURE"); +- +- if (s->cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) +- motion_log(LOG_INFO, 0, "- VIDEO_OUTPUT"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \n------------------------\n" ++ "cap.driver: \"%s\"\n" ++ "cap.card: \"%s\"\n" ++ "cap.bus_info: \"%s\"\n" ++ "cap.capabilities=0x%08X\n------------------------", ++ vid_source->cap.driver, vid_source->cap.card, vid_source->cap.bus_info, ++ vid_source->cap.capabilities); ++ ++ if (vid_source->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VIDEO_CAPTURE"); ++ if (vid_source->cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VIDEO_OUTPUT"); ++ if (vid_source->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VIDEO_OVERLAY"); ++ if (vid_source->cap.capabilities & V4L2_CAP_VBI_CAPTURE) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VBI_CAPTURE"); ++ if (vid_source->cap.capabilities & V4L2_CAP_VBI_OUTPUT) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VBI_OUTPUT"); ++ if (vid_source->cap.capabilities & V4L2_CAP_RDS_CAPTURE) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - RDS_CAPTURE"); ++ if (vid_source->cap.capabilities & V4L2_CAP_TUNER) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - TUNER"); ++ if (vid_source->cap.capabilities & V4L2_CAP_AUDIO) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - AUDIO"); ++ if (vid_source->cap.capabilities & V4L2_CAP_READWRITE) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - READWRITE"); ++ if (vid_source->cap.capabilities & V4L2_CAP_ASYNCIO) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - ASYNCIO"); ++ if (vid_source->cap.capabilities & V4L2_CAP_STREAMING) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - STREAMING"); ++ if (vid_source->cap.capabilities & V4L2_CAP_TIMEPERFRAME) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - TIMEPERFRAME"); + +- if (s->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) +- motion_log(LOG_INFO, 0, "- VIDEO_OVERLAY"); +- +- if (s->cap.capabilities & V4L2_CAP_VBI_CAPTURE) +- motion_log(LOG_INFO, 0, "- VBI_CAPTURE"); +- +- if (s->cap.capabilities & V4L2_CAP_VBI_OUTPUT) +- motion_log(LOG_INFO, 0, "- VBI_OUTPUT"); +- +- if (s->cap.capabilities & V4L2_CAP_RDS_CAPTURE) +- motion_log(LOG_INFO, 0, "- RDS_CAPTURE"); +- +- if (s->cap.capabilities & V4L2_CAP_TUNER) +- motion_log(LOG_INFO, 0, "- TUNER"); +- +- if (s->cap.capabilities & V4L2_CAP_AUDIO) +- motion_log(LOG_INFO, 0, "- AUDIO"); +- +- if (s->cap.capabilities & V4L2_CAP_READWRITE) +- motion_log(LOG_INFO, 0, "- READWRITE"); +- +- if (s->cap.capabilities & V4L2_CAP_ASYNCIO) +- motion_log(LOG_INFO, 0, "- ASYNCIO"); +- +- if (s->cap.capabilities & V4L2_CAP_STREAMING) +- motion_log(LOG_INFO, 0, "- STREAMING"); +- +- if (s->cap.capabilities & V4L2_CAP_TIMEPERFRAME) +- motion_log(LOG_INFO, 0, "- TIMEPERFRAME"); +- +- if (!(s->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { +- motion_log(LOG_ERR, 0, "Device does not support capturing."); ++ if (!(vid_source->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Device does not support capturing."); + return -1; + } + + return 0; + } + +-static int v4l2_select_input(src_v4l2_t * s, int in, int norm, unsigned long freq_, int tuner_number ATTRIBUTE_UNUSED) ++/** ++ * v4l2_select_input ++ */ ++static int v4l2_select_input(struct config *conf, struct video_dev *viddev, ++ src_v4l2_t * vid_source, int in, int norm, ++ unsigned long freq_, int tuner_number ATTRIBUTE_UNUSED) + { + struct v4l2_input input; + struct v4l2_standard standard; + v4l2_std_id std_id; + +- if (in == 8) +- in = 0; +- + /* Set the input. */ +- memset (&input, 0, sizeof (input)); +- input.index = in; +- +- if (xioctl(s->fd, VIDIOC_ENUMINPUT, &input) == -1) { +- motion_log(LOG_ERR, 1, "Unable to query input %d VIDIOC_ENUMINPUT", in); ++ memset(&input, 0, sizeof (input)); ++ if (in == IN_DEFAULT) ++ input.index = IN_TV; ++ else input.index = in; ++ ++ if (xioctl(vid_source->fd, VIDIOC_ENUMINPUT, &input) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to query input %d." ++ " VIDIOC_ENUMINPUT, if you use a WEBCAM change input value in conf by -1", ++ input.index); + return -1; + } + +- if (debug_level > CAMERA_VIDEO) +- motion_log(LOG_INFO, 0, "%s: name = \"%s\", type 0x%08X, status %08x", __FUNCTION__, input.name, +- input.type, input.status); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: name = \"%s\", type 0x%08X," ++ " status %08x", input.name, input.type, input.status); + +- if ((input.type & V4L2_INPUT_TYPE_TUNER) && (debug_level > CAMERA_VIDEO)) +- motion_log(LOG_INFO, 0, "- TUNER"); ++ if (input.type & V4L2_INPUT_TYPE_TUNER) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - TUNER"); + +- if ((input.type & V4L2_INPUT_TYPE_CAMERA) && (debug_level > CAMERA_VIDEO)) +- motion_log(LOG_INFO, 0, "- CAMERA"); ++ if (input.type & V4L2_INPUT_TYPE_CAMERA) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - CAMERA"); + +- if (xioctl(s->fd, VIDIOC_S_INPUT, &in) == -1) { +- motion_log(LOG_ERR, 1, "Error selecting input %d VIDIOC_S_INPUT", in); ++ if (xioctl(vid_source->fd, VIDIOC_S_INPUT, &input.index) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error selecting input %d" ++ " VIDIOC_S_INPUT", input.index); + return -1; + } + +- /* Set video standard usually webcams doesn't support the ioctl or return V4L2_STD_UNKNOWN */ +- if (xioctl(s->fd, VIDIOC_G_STD, &std_id) == -1) { +- if (debug_level > CAMERA_VIDEO) +- motion_log(LOG_INFO, 0, "Device doesn't support VIDIOC_G_STD"); +- std_id = 0; // V4L2_STD_UNKNOWN = 0 ++ viddev->input = conf->input = in; ++ ++ /* ++ * Set video standard usually webcams doesn't support the ioctl or ++ * return V4L2_STD_UNKNOWN ++ */ ++ if (xioctl(vid_source->fd, VIDIOC_G_STD, &std_id) == -1) { ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Device doesn't support VIDIOC_G_STD"); ++ norm = std_id = 0; // V4L2_STD_UNKNOWN = 0 + } + + if (std_id) { + memset(&standard, 0, sizeof(standard)); + standard.index = 0; + +- while (xioctl(s->fd, VIDIOC_ENUMSTD, &standard) == 0) { +- if ((standard.id & std_id) && (debug_level > CAMERA_VIDEO)) +- motion_log(LOG_INFO, 0, "- video standard %s", standard.name); +- ++ while (xioctl(vid_source->fd, VIDIOC_ENUMSTD, &standard) == 0) { ++ if (standard.id & std_id) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - video standard %s", ++ standard.name); ++ + standard.index++; + } + +@@ -249,11 +314,16 @@ static int v4l2_select_input(src_v4l2_t + std_id = V4L2_STD_PAL; + } + +- if (xioctl(s->fd, VIDIOC_S_STD, &std_id) == -1) +- motion_log(LOG_ERR, 1, "Error selecting standard method %d VIDIOC_S_STD", std_id); +- ++ if (xioctl(vid_source->fd, VIDIOC_S_STD, &std_id) == -1) ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error selecting standard" ++ " method %d VIDIOC_S_STD", (int)std_id); ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set standard method %d", ++ (int)std_id); + } + ++ viddev->norm = conf->norm = norm; ++ + /* If this input is attached to a tuner, set the frequency. */ + if (input.type & V4L2_INPUT_TYPE_TUNER) { + struct v4l2_tuner tuner; +@@ -264,34 +334,47 @@ static int v4l2_select_input(src_v4l2_t + memset(&tuner, 0, sizeof(struct v4l2_tuner)); + tuner.index = input.tuner; + +- if (xioctl(s->fd, VIDIOC_G_TUNER, &tuner) == -1) { +- motion_log(LOG_ERR, 1, "tuner %d VIDIOC_G_TUNER", tuner.index); ++ if (xioctl(vid_source->fd, VIDIOC_G_TUNER, &tuner) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: tuner %d VIDIOC_G_TUNER", ++ tuner.index); + return 0; + } + ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set tuner %d", ++ tuner.index); ++ + /* Set the frequency. */ + memset(&freq, 0, sizeof(struct v4l2_frequency)); + freq.tuner = input.tuner; + freq.type = V4L2_TUNER_ANALOG_TV; + freq.frequency = (freq_ / 1000) * 16; + +- if (xioctl(s->fd, VIDIOC_S_FREQUENCY, &freq) == -1) { +- motion_log(LOG_ERR, 1, "freq %lu VIDIOC_S_FREQUENCY", freq.frequency); ++ if (xioctl(vid_source->fd, VIDIOC_S_FREQUENCY, &freq) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: freq %ul VIDIOC_S_FREQUENCY", ++ freq.frequency); + return 0; + } ++ ++ viddev->freq = conf->frequency = freq_; ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Frequency to %ul", ++ freq.frequency); ++ } else { ++ viddev->freq = conf->frequency = 0; + } + + return 0; + } + ++ + /* * + * v4l2_do_set_pix_format +- * ++ * + * This routine does the actual request to the driver +- * ++ * + * Returns: 0 Ok + * -1 Problems setting palette or not supported +- * ++ * + * Our algorithm for setting the picture format for the data which the + * driver returns to us will be as follows: + * +@@ -308,71 +391,95 @@ static int v4l2_select_input(src_v4l2_t + * We then request the driver to set the format we have chosen. That request + * should never fail, so if it does we log the fact and give up. + */ +-static int v4l2_do_set_pix_format(u32 pixformat, src_v4l2_t * s, +- int *width, int *height) ++static int v4l2_do_set_pix_format(u32 pixformat, src_v4l2_t * vid_source, ++ int *width, int *height) + { +- memset(&s->fmt, 0, sizeof(struct v4l2_format)); +- s->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- s->fmt.fmt.pix.width = *width; +- s->fmt.fmt.pix.height = *height; +- s->fmt.fmt.pix.pixelformat = pixformat; +- s->fmt.fmt.pix.field = V4L2_FIELD_ANY; +- +- if (xioctl(s->fd, VIDIOC_TRY_FMT, &s->fmt) != -1 && +- s->fmt.fmt.pix.pixelformat == pixformat) { +- motion_log(LOG_INFO, 0, "Test palette %c%c%c%c (%dx%d)", +- pixformat >> 0, pixformat >> 8, pixformat >> 16, +- pixformat >> 24, *width, *height); +- +- if (s->fmt.fmt.pix.width != (unsigned int) *width || +- s->fmt.fmt.pix.height != (unsigned int) *height) { +- motion_log(LOG_INFO, 0, "Adjusting resolution from %ix%i to %ix%i.", +- *width, *height, s->fmt.fmt.pix.width, +- s->fmt.fmt.pix.height); +- *width = s->fmt.fmt.pix.width; +- *height = s->fmt.fmt.pix.height; ++ CLEAR(vid_source->dst_fmt); ++ vid_source->dst_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ vid_source->dst_fmt.fmt.pix.width = *width; ++ vid_source->dst_fmt.fmt.pix.height = *height; ++ vid_source->dst_fmt.fmt.pix.pixelformat = pixformat; ++ vid_source->dst_fmt.fmt.pix.field = V4L2_FIELD_ANY; ++ ++ if (xioctl(vid_source->fd, VIDIOC_TRY_FMT, &vid_source->dst_fmt) != -1 && ++ vid_source->dst_fmt.fmt.pix.pixelformat == pixformat) { ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Testing palette %c%c%c%c (%dx%d)", ++ pixformat >> 0, pixformat >> 8, ++ pixformat >> 16, pixformat >> 24, *width, *height); ++ ++ if (vid_source->dst_fmt.fmt.pix.width != (unsigned int) *width || ++ vid_source->dst_fmt.fmt.pix.height != (unsigned int) *height) { ++ ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Adjusting resolution " ++ "from %ix%i to %ix%i.", ++ *width, *height, vid_source->dst_fmt.fmt.pix.width, ++ vid_source->dst_fmt.fmt.pix.height); ++ ++ *width = vid_source->dst_fmt.fmt.pix.width; ++ *height = vid_source->dst_fmt.fmt.pix.height; + } + +- if (xioctl(s->fd, VIDIOC_S_FMT, &s->fmt) == -1) { +- motion_log(LOG_ERR, 1, "Error setting pixel format VIDIOC_S_FMT"); ++ if (xioctl(vid_source->fd, VIDIOC_S_FMT, &vid_source->dst_fmt) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error setting pixel " ++ "format.\nVIDIOC_S_FMT: "); + return -1; + } + +- motion_log(LOG_INFO, 0, "Using palette %c%c%c%c (%dx%d) bytesperlines " +- "%d sizeimage %d colorspace %08x", pixformat >> 0, +- pixformat >> 8, pixformat >> 16, pixformat >> 24, +- *width, *height, s->fmt.fmt.pix.bytesperline, +- s->fmt.fmt.pix.sizeimage, s->fmt.fmt.pix.colorspace); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using palette %c%c%c%c (%dx%d)" ++ " bytesperlines %d sizeimage %d colorspace %08x", pixformat >> 0, ++ pixformat >> 8, pixformat >> 16, pixformat >> 24, *width, ++ *height, vid_source->dst_fmt.fmt.pix.bytesperline, ++ vid_source->dst_fmt.fmt.pix.sizeimage, ++ vid_source->dst_fmt.fmt.pix.colorspace); ++ + return 0; + } ++ + return -1; + } + +-/* This routine is called by the startup code to do the format setting */ +-static int v4l2_set_pix_format(struct context *cnt, src_v4l2_t * s, +- int *width, int *height) ++/** ++ * v4l2_set_pix_format ++ * ++ * Returns: 0 Ok ++ * -1 Problems setting palette or not supported ++ */ ++static int v4l2_set_pix_format(struct context *cnt, src_v4l2_t * vid_source, ++ int *width, int *height) + { +- struct v4l2_fmtdesc fmt; +- short int v4l2_pal; ++ struct v4l2_fmtdesc fmtd; ++ int v4l2_pal; + +- /* ++ /* + * Note that this array MUST exactly match the config file list. +- * A higher index means better chance to be used ++ * A higher index means better chance to be used + */ + static const u32 supported_formats[] = { + V4L2_PIX_FMT_SN9C10X, ++ V4L2_PIX_FMT_SBGGR16, + V4L2_PIX_FMT_SBGGR8, ++ V4L2_PIX_FMT_SPCA561, ++ V4L2_PIX_FMT_SGBRG8, ++ V4L2_PIX_FMT_SGRBG8, ++ V4L2_PIX_FMT_PAC207, ++ V4L2_PIX_FMT_PJPG, + V4L2_PIX_FMT_MJPEG, + V4L2_PIX_FMT_JPEG, + V4L2_PIX_FMT_RGB24, ++ V4L2_PIX_FMT_SPCA501, ++ V4L2_PIX_FMT_SPCA505, ++ V4L2_PIX_FMT_SPCA508, + V4L2_PIX_FMT_UYVY, + V4L2_PIX_FMT_YUYV, + V4L2_PIX_FMT_YUV422P, +- V4L2_PIX_FMT_YUV420 /* most efficient for motion */ ++ V4L2_PIX_FMT_YUV420 /* most efficient for motion */ + }; +- ++ + int array_size = sizeof(supported_formats) / sizeof(supported_formats[0]); +- short int index_format = -1; /* -1 says not yet chosen */ ++ int index_format = -1; /* -1 says not yet chosen */ ++ CLEAR(fmtd); ++ fmtd.index = v4l2_pal = 0; ++ fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + /* First we try a shortcut of just setting the config file value */ + if (cnt->conf.v4l2_palette >= 0) { +@@ -380,38 +487,37 @@ static int v4l2_set_pix_format(struct co + supported_formats[cnt->conf.v4l2_palette] >> 8, + supported_formats[cnt->conf.v4l2_palette] >> 16, + supported_formats[cnt->conf.v4l2_palette] >> 24, 0}; +- ++ + if (v4l2_do_set_pix_format(supported_formats[cnt->conf.v4l2_palette], +- s, width, height) >= 0) ++ vid_source, width, height) >= 0) + return 0; +- +- motion_log(LOG_INFO, 0, "Config palette index %d (%s) doesn't work.", +- cnt->conf.v4l2_palette, name); +- } +- /* Well, that didn't work, so we enumerate what the driver can offer */ +- +- memset(&fmt, 0, sizeof(struct v4l2_fmtdesc)); +- fmt.index = v4l2_pal = 0; +- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- +- motion_log(LOG_INFO, 0, "Supported palettes:"); +- +- while (xioctl(s->fd, VIDIOC_ENUM_FMT, &fmt) != -1) { +- short int i; +- +- motion_log(LOG_INFO, 0, "%i: %c%c%c%c (%s)", v4l2_pal, +- fmt.pixelformat >> 0, fmt.pixelformat >> 8, +- fmt.pixelformat >> 16, fmt.pixelformat >> 24, +- fmt.description); + +- /* adjust index_format if larger value found */ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Config palette index %d (%s)" ++ " doesn't work.", cnt->conf.v4l2_palette, name); ++ } ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Supported palettes:"); ++ ++ while (xioctl(vid_source->fd, VIDIOC_ENUM_FMT, &fmtd) != -1) { ++ ++ int i; ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: (%i) %c%c%c%c (%s)", ++ v4l2_pal, fmtd.pixelformat >> 0, ++ fmtd.pixelformat >> 8, fmtd.pixelformat >> 16, ++ fmtd.pixelformat >> 24, fmtd.description); ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: %d - %s (compressed : %d) (%#x)", ++ fmtd.index, fmtd.description, fmtd.flags, fmtd.pixelformat); ++ ++ /* Adjust index_format if larger value found */ + for (i = index_format + 1; i < array_size; i++) +- if (supported_formats[i] == fmt.pixelformat) ++ if (supported_formats[i] == fmtd.pixelformat) + index_format = i; + +- memset(&fmt, 0, sizeof(struct v4l2_fmtdesc)); +- fmt.index = ++v4l2_pal; +- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ CLEAR(fmtd); ++ fmtd.index = ++v4l2_pal; ++ fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + } + + if (index_format >= 0) { +@@ -419,123 +525,140 @@ static int v4l2_set_pix_format(struct co + supported_formats[index_format] >> 8, + supported_formats[index_format] >> 16, + supported_formats[index_format] >> 24, 0}; +- +- motion_log(LOG_INFO, 0, "Selected palette %s", name); +- ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s Selected palette %s", name); ++ + if (v4l2_do_set_pix_format(supported_formats[index_format], +- s, width, height) >= 0) ++ vid_source, width, height) >= 0) + return 0; +- motion_log(LOG_ERR, 1, "VIDIOC_TRY_FMT failed for format %s", name); ++ ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "VIDIOC_TRY_FMT failed for " ++ "format %s", name); + } + +- motion_log(LOG_ERR, 0, "Unable to find a compatible palette format."); ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Unable to find a compatible" ++ " palette format."); ++ + return -1; + } + + #if 0 +-static void v4l2_set_fps(src_v4l2_t * s){ ++static void v4l2_set_fps(src_v4l2_t * vid_source) { + struct v4l2_streamparm* setfps; + +- setfps=(struct v4l2_streamparm *) calloc(1, sizeof(struct v4l2_streamparm)); ++ setfps = (struct v4l2_streamparm *) calloc(1, sizeof(struct v4l2_streamparm)); + memset(setfps, 0, sizeof(struct v4l2_streamparm)); +- setfps->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- setfps->parm.capture.timeperframe.numerator=1; +- setfps->parm.capture.timeperframe.denominator=s->fps; ++ setfpvid_source->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ setfpvid_source->parm.capture.timeperframe.numerator = 1; ++ setfpvid_source->parm.capture.timeperframe.denominator = vid_source->fps; ++ ++ if (xioctl(vid_source->fd, VIDIOC_S_PARM, setfps) == -1) ++ MOTION_LOG(ERR, 1, "%s: v4l2_set_fps VIDIOC_S_PARM"); + +- if (xioctl(s->fd, VIDIOC_S_PARM, setfps) == -1) +- motion_log(LOG_ERR, 1, "v4l2_set_fps VIDIOC_S_PARM"); +- + + } + #endif + +-static int v4l2_set_mmap(src_v4l2_t * s) ++/** ++ * v4l2_set_mmap ++ */ ++static int v4l2_set_mmap(src_v4l2_t * vid_source) + { + enum v4l2_buf_type type; +- u32 b; ++ u32 buffer_index; + + /* Does the device support streaming? */ +- if (!(s->cap.capabilities & V4L2_CAP_STREAMING)) ++ if (!(vid_source->cap.capabilities & V4L2_CAP_STREAMING)) + return -1; + +- memset(&s->req, 0, sizeof(struct v4l2_requestbuffers)); +- +- s->req.count = MMAP_BUFFERS; +- s->req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- s->req.memory = V4L2_MEMORY_MMAP; ++ memset(&vid_source->req, 0, sizeof(struct v4l2_requestbuffers)); + +- if (xioctl(s->fd, VIDIOC_REQBUFS, &s->req) == -1) { +- motion_log(LOG_ERR, 1, "Error requesting buffers %d for memory map. VIDIOC_REQBUFS", s->req.count); ++ vid_source->req.count = MMAP_BUFFERS; ++ vid_source->req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ vid_source->req.memory = V4L2_MEMORY_MMAP; ++ ++ if (xioctl(vid_source->fd, VIDIOC_REQBUFS, &vid_source->req) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error requesting buffers" ++ " %d for memory map. VIDIOC_REQBUFS", ++ vid_source->req.count); + return -1; + } + +- motion_log(LOG_DEBUG, 0, "mmap information:"); +- motion_log(LOG_DEBUG, 0, "frames=%d", s->req.count); ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: mmap information: frames=%d", ++ vid_source->req.count); + +- if (s->req.count < MIN_MMAP_BUFFERS) { +- motion_log(LOG_ERR, 0, "Insufficient buffer memory."); ++ if (vid_source->req.count < MIN_MMAP_BUFFERS) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Insufficient buffer memory" ++ " %d < MIN_MMAP_BUFFERS.", vid_source->req.count); + return -1; + } + +- s->buffers = calloc(s->req.count, sizeof(netcam_buff)); +- if (!s->buffers) { +- motion_log(LOG_ERR, 1, "%s: Out of memory.", __FUNCTION__); ++ vid_source->buffers = calloc(vid_source->req.count, sizeof(video_buff)); ++ ++ if (!vid_source->buffers) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Out of memory."); + return -1; + } + +- for (b = 0; b < s->req.count; b++) { ++ for (buffer_index = 0; buffer_index < vid_source->req.count; buffer_index++) { + struct v4l2_buffer buf; + + memset(&buf, 0, sizeof(struct v4l2_buffer)); + + buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + buf.memory = V4L2_MEMORY_MMAP; +- buf.index = b; ++ buf.index = buffer_index; + +- if (xioctl(s->fd, VIDIOC_QUERYBUF, &buf) == -1) { +- motion_log(LOG_ERR, 0, "Error querying buffer %d VIDIOC_QUERYBUF", b); +- free(s->buffers); ++ if (xioctl(vid_source->fd, VIDIOC_QUERYBUF, &buf) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error querying buffer" ++ " %i\nVIDIOC_QUERYBUF: ", buffer_index); ++ free(vid_source->buffers); + return -1; + } + +- s->buffers[b].size = buf.length; +- s->buffers[b].ptr = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, buf.m.offset); +- +- if (s->buffers[b].ptr == MAP_FAILED) { +- motion_log(LOG_ERR, 1, "Error mapping buffer %i mmap", b); +- free(s->buffers); ++ vid_source->buffers[buffer_index].size = buf.length; ++ vid_source->buffers[buffer_index].ptr = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, ++ MAP_SHARED, vid_source->fd, buf.m.offset); ++ ++ if (vid_source->buffers[buffer_index].ptr == MAP_FAILED) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error mapping buffer %i mmap", ++ buffer_index); ++ free(vid_source->buffers); + return -1; + } + +- motion_log(LOG_DEBUG, 0, "%i length=%d", b, buf.length); ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: %i length=%d Address (%x)", ++ buffer_index, buf.length, vid_source->buffers[buffer_index].ptr); + } + +- s->map = -1; ++ for (buffer_index = 0; buffer_index < vid_source->req.count; buffer_index++) { ++ memset(&vid_source->buf, 0, sizeof(struct v4l2_buffer)); + +- for (b = 0; b < s->req.count; b++) { +- memset(&s->buf, 0, sizeof(struct v4l2_buffer)); ++ vid_source->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ vid_source->buf.memory = V4L2_MEMORY_MMAP; ++ vid_source->buf.index = buffer_index; + +- s->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- s->buf.memory = V4L2_MEMORY_MMAP; +- s->buf.index = b; +- +- if (xioctl(s->fd, VIDIOC_QBUF, &s->buf) == -1) { +- motion_log(LOG_ERR, 1, "buffer index %d VIDIOC_QBUF", s->buf.index); ++ if (xioctl(vid_source->fd, VIDIOC_QBUF, &vid_source->buf) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_QBUF"); + return -1; + } + } + + type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + +- if (xioctl(s->fd, VIDIOC_STREAMON, &type) == -1) { +- motion_log(LOG_ERR, 1, "Error starting stream VIDIOC_STREAMON"); ++ if (xioctl(vid_source->fd, VIDIOC_STREAMON, &type) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error starting stream." ++ " VIDIOC_STREAMON"); + return -1; + } + + return 0; + } + +-static int v4l2_scan_controls(src_v4l2_t * s) ++/** ++ * v4l2_scan_controls ++ */ ++static int v4l2_scan_controls(src_v4l2_t * vid_source) + { + int count, i; + struct v4l2_queryctrl queryctrl; +@@ -544,40 +667,42 @@ static int v4l2_scan_controls(src_v4l2_t + + for (i = 0, count = 0; queried_ctrls[i]; i++) { + queryctrl.id = queried_ctrls[i]; +- if (xioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) ++ if (xioctl(vid_source->fd, VIDIOC_QUERYCTRL, &queryctrl)) + continue; + + count++; +- s->ctrl_flags |= 1 << i; ++ vid_source->ctrl_flags |= 1 << i; + } + + if (count) { +- struct v4l2_queryctrl *ctrl = s->controls = calloc(count, sizeof(struct v4l2_queryctrl)); ++ struct v4l2_queryctrl *ctrl = vid_source->controls ++ = calloc(count, sizeof(struct v4l2_queryctrl)); + + if (!ctrl) { +- motion_log(LOG_ERR, 1, "%s: Insufficient buffer memory.", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Insufficient buffer memory."); + return -1; + } + + for (i = 0; queried_ctrls[i]; i++) { +- if (s->ctrl_flags & (1 << i)) { ++ if (vid_source->ctrl_flags & (1 << i)) { + struct v4l2_control control; + + queryctrl.id = queried_ctrls[i]; +- if (xioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) ++ if (xioctl(vid_source->fd, VIDIOC_QUERYCTRL, &queryctrl)) + continue; + + memcpy(ctrl, &queryctrl, sizeof(struct v4l2_queryctrl)); + +- motion_log(LOG_INFO, 0, "found control 0x%08x, \"%s\", range %d,%d %s", ctrl->id, +- ctrl->name, ctrl->minimum, ctrl->maximum, ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: found control 0x%08x, \"%s\"," ++ " range %d,%d %s", ++ ctrl->id, ctrl->name, ctrl->minimum, ctrl->maximum, + ctrl->flags & V4L2_CTRL_FLAG_DISABLED ? "!DISABLED!" : ""); + +- memset (&control, 0, sizeof (control)); ++ memset(&control, 0, sizeof (control)); + control.id = queried_ctrls[i]; +- xioctl(s->fd, VIDIOC_G_CTRL, &control); +- motion_log(LOG_INFO, 0, "\t\"%s\", default %d, current %d", ctrl->name, +- ctrl->default_value, control.value); ++ xioctl(vid_source->fd, VIDIOC_G_CTRL, &control); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \t\"%s\", default %d, current %d", ++ ctrl->name, ctrl->default_value, control.value); + + ctrl++; + } +@@ -587,44 +712,46 @@ static int v4l2_scan_controls(src_v4l2_t + return 0; + } + +-static int v4l2_set_control(src_v4l2_t * s, u32 cid, int value) ++/** ++ * v4l2_set_control ++ */ ++static int v4l2_set_control(src_v4l2_t * vid_source, u32 cid, int value) + { + int i, count; + +- if (!s->controls) ++ if (!vid_source->controls) + return -1; + + for (i = 0, count = 0; queried_ctrls[i]; i++) { +- if (s->ctrl_flags & (1 << i)) { ++ if (vid_source->ctrl_flags & (1 << i)) { + if (cid == queried_ctrls[i]) { +- struct v4l2_queryctrl *ctrl = s->controls + count; ++ struct v4l2_queryctrl *ctrl = vid_source->controls + count; + struct v4l2_control control; + int ret; + +- memset (&control, 0, sizeof (control)); ++ memset(&control, 0, sizeof (control)); + control.id = queried_ctrls[i]; + + switch (ctrl->type) { + case V4L2_CTRL_TYPE_INTEGER: + value = control.value = + (value * (ctrl->maximum - ctrl->minimum) / 256) + ctrl->minimum; +- ret = xioctl(s->fd, VIDIOC_S_CTRL, &control); ++ ret = xioctl(vid_source->fd, VIDIOC_S_CTRL, &control); + break; + + case V4L2_CTRL_TYPE_BOOLEAN: + value = control.value = value ? 1 : 0; +- ret = xioctl(s->fd, VIDIOC_S_CTRL, &control); ++ ret = xioctl(vid_source->fd, VIDIOC_S_CTRL, &control); + break; + + default: +- motion_log(LOG_ERR, 0, "%s: control type not supported yet"); ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: control type not supported yet"); + return -1; + } + +- if (debug_level > CAMERA_VIDEO) +- motion_log(LOG_INFO, 0, "setting control \"%s\" to %d (ret %d %s) %s", ctrl->name, +- value, ret, ret ? strerror(errno) : "", +- ctrl->flags & V4L2_CTRL_FLAG_DISABLED ? "Control is DISABLED!" : ""); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setting control \"%s\" to %d" ++ " (ret %d %s) %s", ctrl->name, value, ret, ret ? strerror(errno) : "", ++ ctrl->flags & V4L2_CTRL_FLAG_DISABLED ? "Control is DISABLED!" : ""); + + return 0; + } +@@ -635,76 +762,82 @@ static int v4l2_set_control(src_v4l2_t * + return -1; + } + ++/** ++ * v4l2_picture_controls ++ */ + static void v4l2_picture_controls(struct context *cnt, struct video_dev *viddev) + { +- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; ++ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; + + if (cnt->conf.contrast && cnt->conf.contrast != viddev->contrast) { + viddev->contrast = cnt->conf.contrast; +- v4l2_set_control(s, V4L2_CID_CONTRAST, viddev->contrast); ++ v4l2_set_control(vid_source, V4L2_CID_CONTRAST, viddev->contrast); + } + + if (cnt->conf.saturation && cnt->conf.saturation != viddev->saturation) { + viddev->saturation = cnt->conf.saturation; +- v4l2_set_control(s, V4L2_CID_SATURATION, viddev->saturation); ++ v4l2_set_control(vid_source, V4L2_CID_SATURATION, viddev->saturation); + } + + if (cnt->conf.hue && cnt->conf.hue != viddev->hue) { + viddev->hue = cnt->conf.hue; +- v4l2_set_control(s, V4L2_CID_HUE, viddev->hue); ++ v4l2_set_control(vid_source, V4L2_CID_HUE, viddev->hue); + } + + if (cnt->conf.autobright) { + if (vid_do_autobright(cnt, viddev)) { +- if (v4l2_set_control(s, V4L2_CID_BRIGHTNESS, viddev->brightness)) +- v4l2_set_control(s, V4L2_CID_GAIN, viddev->brightness); ++ if (v4l2_set_control(vid_source, V4L2_CID_BRIGHTNESS, viddev->brightness)) ++ v4l2_set_control(vid_source, V4L2_CID_GAIN, viddev->brightness); + } + } else { + if (cnt->conf.brightness && cnt->conf.brightness != viddev->brightness) { + viddev->brightness = cnt->conf.brightness; +- if (v4l2_set_control(s, V4L2_CID_BRIGHTNESS, viddev->brightness)) +- v4l2_set_control(s, V4L2_CID_GAIN, viddev->brightness); ++ if (v4l2_set_control(vid_source, V4L2_CID_BRIGHTNESS, viddev->brightness)) ++ v4l2_set_control(vid_source, V4L2_CID_GAIN, viddev->brightness); + } + } + + } + + /* public functions */ +- ++/** ++ * v4l2_start ++ */ + unsigned char *v4l2_start(struct context *cnt, struct video_dev *viddev, int width, int height, + int input, int norm, unsigned long freq, int tuner_number) + { +- src_v4l2_t *s; ++ src_v4l2_t *vid_source; + + /* Allocate memory for the state structure. */ +- if (!(s = calloc(sizeof(src_v4l2_t), 1))) { +- motion_log(LOG_ERR, 1, "%s: Out of memory.", __FUNCTION__); ++ if (!(vid_source = calloc(sizeof(src_v4l2_t), 1))) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Out of memory."); + goto err; + } + +- viddev->v4l2_private = s; +- s->fd = viddev->fd; +- s->fps = cnt->conf.frame_limit; +- s->pframe = -1; ++ viddev->v4l2_private = vid_source; ++ vid_source->fd = viddev->fd; ++ vid_source->fps = cnt->conf.frame_limit; ++ vid_source->pframe = -1; ++ struct config *conf = &cnt->conf; + +- if (v4l2_get_capability(s)) ++ if (v4l2_get_capability(vid_source)) + goto err; +- +- if (v4l2_select_input(s, input, norm, freq, tuner_number)) ++ ++ if (v4l2_select_input(conf, viddev, vid_source, input, norm, freq, tuner_number)) + goto err; +- +- if (v4l2_set_pix_format(cnt ,s, &width, &height)) ++ ++ if (v4l2_set_pix_format(cnt, vid_source, &width, &height)) + goto err; +- +- if (v4l2_scan_controls(s)) ++ ++ if (v4l2_scan_controls(vid_source)) + goto err; +- ++ + #if 0 +- v4l2_set_fps(s); ++ v4l2_set_fps(vid_source); + #endif +- if (v4l2_set_mmap(s)) ++ if (v4l2_set_mmap(vid_source)) + goto err; +- ++ + viddev->size_map = 0; + viddev->v4l_buffers[0] = NULL; + viddev->v4l_maxbuffer = 1; +@@ -721,86 +854,101 @@ unsigned char *v4l2_start(struct context + return (void *) 1; + + err: +- if (s) +- free(s); ++ if (vid_source) ++ free(vid_source); + + viddev->v4l2_private = NULL; + viddev->v4l2 = 0; + return NULL; + } + +-void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, +- struct config *conf) ++/** ++ * v4l2_set_input ++ */ ++void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, ++ int width, int height, struct config *conf) + { +- int i; + int input = conf->input; + int norm = conf->norm; +- int skip = conf->roundrobin_skip; + unsigned long freq = conf->frequency; + int tuner_number = conf->tuner_number; + + if (input != viddev->input || width != viddev->width || height != viddev->height || +- freq != viddev->freq || tuner_number != viddev->tuner_number) { ++ freq != viddev->freq || tuner_number != viddev->tuner_number || norm != viddev->norm) { + ++ unsigned int i; + struct timeval switchTime; ++ unsigned int skip = conf->roundrobin_skip; + +- v4l2_select_input((src_v4l2_t *) viddev->v4l2_private, input, norm, freq, tuner_number); ++ if (conf->roundrobin_skip < 0) ++ skip = 1; ++ ++ v4l2_select_input(conf, viddev, (src_v4l2_t *) viddev->v4l2_private, ++ input, norm, freq, tuner_number); + + gettimeofday(&switchTime, NULL); + + v4l2_picture_controls(cnt, viddev); + ++ viddev->width = width; ++ viddev->height = height; ++ ++ /* + viddev->input = input; ++ viddev->norm = norm; + viddev->width = width; + viddev->height = height; + viddev->freq = freq; + viddev->tuner_number = tuner_number; +- ++ */ + + /* Skip all frames captured before switchtime, capture 1 after switchtime */ + { +- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; ++ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; + unsigned int counter = 0; +- if (debug_level > CAMERA_VIDEO) +- motion_log(LOG_DEBUG, 0, "set_input_skip_frame switch_time=%ld:%ld", +- switchTime.tv_sec, switchTime.tv_usec); ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set_input_skip_frame " ++ "switch_time=%ld:%ld", switchTime.tv_sec, switchTime.tv_usec); + + /* Avoid hang using the number of mmap buffers */ +- while(counter < s->req.count) { ++ while(counter < vid_source->req.count) { + counter++; + if (v4l2_next(cnt, viddev, map, width, height)) + break; +- +- if (s->buf.timestamp.tv_sec > switchTime.tv_sec || +- (s->buf.timestamp.tv_sec == switchTime.tv_sec && s->buf.timestamp.tv_usec > +- switchTime.tv_usec)) ++ ++ if (vid_source->buf.timestamp.tv_sec > switchTime.tv_sec || ++ (vid_source->buf.timestamp.tv_sec == switchTime.tv_sec && ++ vid_source->buf.timestamp.tv_usec > switchTime.tv_usec)) + break; + +- if (debug_level > CAMERA_VIDEO) +- motion_log(LOG_DEBUG, 0, "got frame before switch timestamp=%ld:%ld", +- s->buf.timestamp.tv_sec, s->buf.timestamp.tv_usec); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: got frame before " ++ " switch timestamp=%ld:%ld", ++ vid_source->buf.timestamp.tv_sec, ++ vid_source->buf.timestamp.tv_usec); + } + } + + /* skip a few frames if needed */ + for (i = 1; i < skip; i++) + v4l2_next(cnt, viddev, map, width, height); +- + } else { + /* No round robin - we only adjust picture controls */ + v4l2_picture_controls(cnt, viddev); + } + } + +-int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height) ++/** ++ * v4l2_next ++ */ ++int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, ++ int width, int height) + { + sigset_t set, old; +- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; ++ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; + + if (viddev->v4l_fmt != VIDEO_PALETTE_YUV420P) + return V4L_FATAL_ERROR; + +- + /* Block signals during IOCTL */ + sigemptyset(&set); + sigaddset(&set, SIGCHLD); +@@ -810,82 +958,109 @@ int v4l2_next(struct context *cnt, struc + sigaddset(&set, SIGHUP); + pthread_sigmask(SIG_BLOCK, &set, &old); + +- if (s->pframe >= 0) { +- if (xioctl(s->fd, VIDIOC_QBUF, &s->buf) == -1) { +- motion_log(LOG_ERR, 1, "%s: VIDIOC_QBUF", __FUNCTION__); ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: 1) vid_source->pframe %i", ++ vid_source->pframe); ++ ++ if (vid_source->pframe >= 0) { ++ if (xioctl(vid_source->fd, VIDIOC_QBUF, &vid_source->buf) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_QBUF"); ++ pthread_sigmask(SIG_UNBLOCK, &old, NULL); + return -1; + } + } + +- memset(&s->buf, 0, sizeof(struct v4l2_buffer)); ++ memset(&vid_source->buf, 0, sizeof(struct v4l2_buffer)); + +- s->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- s->buf.memory = V4L2_MEMORY_MMAP; ++ vid_source->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ vid_source->buf.memory = V4L2_MEMORY_MMAP; + +- if (xioctl(s->fd, VIDIOC_DQBUF, &s->buf) == -1) { +- +- /* some drivers return EIO when there is no signal, +- driver might dequeue an (empty) buffer despite +- returning an error, or even stop capturing. +- */ ++ if (xioctl(vid_source->fd, VIDIOC_DQBUF, &vid_source->buf) == -1) { ++ int ret; ++ /* ++ * Some drivers return EIO when there is no signal, ++ * driver might dequeue an (empty) buffer despite ++ * returning an error, or even stop capturing. ++ */ + if (errno == EIO) { +- s->pframe++; +- if ((u32)s->pframe >= s->req.count) s->pframe = 0; +- s->buf.index = s->pframe; ++ vid_source->pframe++; + +- motion_log(LOG_ERR, 1, "%s: VIDIOC_DQBUF: EIO (s->pframe %d)", __FUNCTION__, s->pframe); ++ if ((u32)vid_source->pframe >= vid_source->req.count) ++ vid_source->pframe = 0; + +- return 1; ++ vid_source->buf.index = vid_source->pframe; ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_DQBUF: EIO " ++ "(vid_source->pframe %d)", vid_source->pframe); ++ ret = 1; ++ } else if (errno == EAGAIN) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_DQBUF: EAGAIN" ++ " (vid_source->pframe %d)", vid_source->pframe); ++ ret = 1; ++ } else { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_DQBUF"); ++ ret = -1; + } + +- motion_log(LOG_ERR, 1, "%s: VIDIOC_DQBUF", __FUNCTION__); +- +- return -1; ++ pthread_sigmask(SIG_UNBLOCK, &old, NULL); ++ return ret; + } + +- s->pframe = s->buf.index; +- s->buffers[s->buf.index].used = s->buf.bytesused; +- s->buffers[s->buf.index].content_length = s->buf.bytesused; ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: 2) vid_source->pframe %i", ++ vid_source->pframe); ++ ++ vid_source->pframe = vid_source->buf.index; ++ vid_source->buffers[vid_source->buf.index].used = vid_source->buf.bytesused; ++ vid_source->buffers[vid_source->buf.index].content_length = vid_source->buf.bytesused; ++ ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: 3) vid_source->pframe %i " ++ "vid_source->buf.index %i", vid_source->pframe, vid_source->buf.index); ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: vid_source->buf.bytesused %i", ++ vid_source->buf.bytesused); + + pthread_sigmask(SIG_UNBLOCK, &old, NULL); /*undo the signal blocking */ + + { +- netcam_buff *the_buffer = &s->buffers[s->buf.index]; ++ video_buff *the_buffer = &vid_source->buffers[vid_source->buf.index]; + +- switch (s->fmt.fmt.pix.pixelformat) { ++ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: the_buffer index %d Address (%x)", ++ vid_source->buf.index, the_buffer->ptr); ++ ++ switch (vid_source->dst_fmt.fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: +- conv_rgb24toyuv420p(map, (unsigned char *) the_buffer->ptr, width, height); ++ conv_rgb24toyuv420p(map, the_buffer->ptr, width, height); + return 0; + + case V4L2_PIX_FMT_UYVY: +- conv_uyvyto420p(map, (unsigned char *) the_buffer->ptr, (unsigned)width, (unsigned)height); ++ conv_uyvyto420p(map, the_buffer->ptr, (unsigned)width, (unsigned)height); + return 0; + + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YUV422P: +- conv_yuv422to420p(map, (unsigned char *) the_buffer->ptr, width, height); ++ conv_yuv422to420p(map, the_buffer->ptr, width, height); + return 0; + + case V4L2_PIX_FMT_YUV420: + memcpy(map, the_buffer->ptr, viddev->v4l_bufsize); + return 0; + +- case V4L2_PIX_FMT_JPEG: +- case V4L2_PIX_FMT_MJPEG: +- return mjpegtoyuv420p(map, (unsigned char *) the_buffer->ptr, width, height, +- s->buffers[s->buf.index].content_length); +-/* +- return 0; ++ case V4L2_PIX_FMT_PJPG: + case V4L2_PIX_FMT_JPEG: +- return conv_jpeg2yuv420(cnt, map, the_buffer, width, height); +-*/ ++ case V4L2_PIX_FMT_MJPEG: ++ return mjpegtoyuv420p(map, the_buffer->ptr, width, height, ++ vid_source->buffers[vid_source->buf.index].content_length); ++ ++ /* FIXME: quick hack to allow work all bayer formats */ ++ case V4L2_PIX_FMT_SBGGR16: ++ case V4L2_PIX_FMT_SGBRG8: ++ case V4L2_PIX_FMT_SGRBG8: ++ /* case V4L2_PIX_FMT_SPCA561: */ + case V4L2_PIX_FMT_SBGGR8: /* bayer */ +- bayer2rgb24(cnt->imgs.common_buffer, (unsigned char *) the_buffer->ptr, width, height); ++ bayer2rgb24(cnt->imgs.common_buffer, the_buffer->ptr, width, height); + conv_rgb24toyuv420p(map, cnt->imgs.common_buffer, width, height); + return 0; + ++ case V4L2_PIX_FMT_SPCA561: + case V4L2_PIX_FMT_SN9C10X: +- sonix_decompress(map, (unsigned char *) the_buffer->ptr, width, height); ++ sonix_decompress(map, the_buffer->ptr, width, height); + bayer2rgb24(cnt->imgs.common_buffer, map, width, height); + conv_rgb24toyuv420p(map, cnt->imgs.common_buffer, width, height); + return 0; +@@ -895,39 +1070,43 @@ int v4l2_next(struct context *cnt, struc + return 1; + } + ++/** ++ * v4l2_close ++ */ + void v4l2_close(struct video_dev *viddev) + { +- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; ++ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; + enum v4l2_buf_type type; + + type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +- xioctl(s->fd, VIDIOC_STREAMOFF, &type); +- close(s->fd); +- s->fd = -1; ++ xioctl(vid_source->fd, VIDIOC_STREAMOFF, &type); ++ close(vid_source->fd); ++ vid_source->fd = -1; + } + ++/** ++ * v4l2_cleanup ++ */ + void v4l2_cleanup(struct video_dev *viddev) + { +- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; ++ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; + +- if (s->buffers) { ++ if (vid_source->buffers) { + unsigned int i; + +- for (i = 0; i < s->req.count; i++) +- munmap(s->buffers[i].ptr, s->buffers[i].size); ++ for (i = 0; i < vid_source->req.count; i++) ++ munmap(vid_source->buffers[i].ptr, vid_source->buffers[i].size); + +- free(s->buffers); +- s->buffers = NULL; ++ free(vid_source->buffers); ++ vid_source->buffers = NULL; + } + +- if (s->controls) { +- free(s->controls); +- s->controls = NULL; ++ if (vid_source->controls) { ++ free(vid_source->controls); ++ vid_source->controls = NULL; + } + +- free(s); ++ free(vid_source); + viddev->v4l2_private = NULL; + } +- +-#endif +-#endif ++#endif /* !WITHOUT_V4L && MOTION_V4L2 */ +--- motion-3.2.12.orig/video_common.c ++++ motion-3.2.12/video_common.c +@@ -2,19 +2,18 @@ + * + * Video stream functions for motion. + * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) +- * 2006 by Krzysztof Blaszkowski (kb@sysmikro.com.pl) +- * 2007 by Angel Carpinteo (ack@telefonica.net) ++ * 2006 by Krzysztof Blaszkowski (kb@sysmikro.com.pl) ++ * 2007 by Angel Carpintero (motiondevelop@gmail.com) + * This software is distributed under the GNU public license version 2 + * See also the file 'COPYING'. + * + */ + +-/* for rotation */ +-#include "rotate.h" /* already includes motion.h */ ++/* For rotation */ ++#include "rotate.h" /* Already includes motion.h */ + #include "video.h" + #include "jpegutils.h" + +- + typedef unsigned char uint8_t; + typedef unsigned short int uint16_t; + typedef unsigned int uint32_t; +@@ -27,9 +26,8 @@ typedef struct { + int val; + } code_table_t; + +-/* +- * sonix_decompress_init +- * ===================== ++/** ++ * sonix_decompress_init + * pre-calculates a locally stored table for efficient huffman-decoding. + * + * Each entry at index x in the table represents the codeword +@@ -89,10 +87,9 @@ static void sonix_decompress_init(code_t + } + } + +-/* +- * sonix_decompress +- * ================ +- * decompresses an image encoded by a SN9C101 camera controller chip. ++/** ++ * sonix_decompress ++ * Decompresses an image encoded by a SN9C101 camera controller chip. + * + * IN width + * height +@@ -111,14 +108,14 @@ int sonix_decompress(unsigned char *outp + unsigned char code; + unsigned char *addr; + +- /* local storage */ ++ /* Local storage */ + static code_table_t table[256]; + static int init_done = 0; + + if (!init_done) { + init_done = 1; + sonix_decompress_init(table); +- /* do sonix_decompress_init first! */ ++ /* Do sonix_decompress_init first! */ + //return -1; // so it has been done and now fall through + } + +@@ -127,7 +124,7 @@ int sonix_decompress(unsigned char *outp + + col = 0; + +- /* first two pixels in first two rows are stored as raw 8-bit */ ++ /* First two pixels in first two rows are stored as raw 8-bit. */ + if (row < 2) { + addr = inp + (bitpos >> 3); + code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); +@@ -143,30 +140,30 @@ int sonix_decompress(unsigned char *outp + } + + while (col < width) { +- /* get bitcode from bitstream */ ++ /* Get bitcode from bitstream. */ + addr = inp + (bitpos >> 3); + code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); + +- /* update bit position */ ++ /* Update bit position. */ + bitpos += table[code].len; + +- /* calculate pixel value */ ++ /* Calculate pixel value. */ + val = table[code].val; + if (!table[code].is_abs) { +- /* value is relative to top and left pixel */ ++ /* Value is relative to top and left pixel. */ + if (col < 2) { +- /* left column: relative to top pixel */ ++ /* Left column: relative to top pixel. */ + val += outp[-2 * width]; + } else if (row < 2) { +- /* top row: relative to left pixel */ ++ /* Top row: relative to left pixel. */ + val += outp[-2]; + } else { +- /* main area: average of left pixel and top pixel */ ++ /* Main area: average of left pixel and top pixel. */ + val += (outp[-2] + outp[-2 * width]) / 2; + } + } + +- /* store pixel */ ++ /* Store pixel */ + *outp++ = CLAMP(val); + col++; + } +@@ -175,14 +172,14 @@ int sonix_decompress(unsigned char *outp + return 0; + } + +-/* ++/** ++ * bayer2rgb24 + * BAYER2RGB24 ROUTINE TAKEN FROM: + * + * Sonix SN9C10x based webcam basic I/F routines + * Takafumi Mizuno + * + */ +- + void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height) + { + long int i; +@@ -199,12 +196,12 @@ void bayer2rgb24(unsigned char *dst, uns + /* B */ + if ((i > width) && ((i % width) > 0)) { + *scanpt++ = *rawpt; /* B */ +- *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + ++ *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + + *(rawpt + width) + *(rawpt - width)) / 4; /* G */ +- *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + ++ *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + + *(rawpt + width - 1) + *(rawpt + width + 1)) / 4; /* R */ + } else { +- /* first line or left column */ ++ /* First line or left column. */ + *scanpt++ = *rawpt; /* B */ + *scanpt++ = (*(rawpt + 1) + *(rawpt + width)) / 2; /* G */ + *scanpt++ = *(rawpt + width + 1); /* R */ +@@ -216,7 +213,7 @@ void bayer2rgb24(unsigned char *dst, uns + *scanpt++ = *rawpt; /* G */ + *scanpt++ = (*(rawpt + width) + *(rawpt - width)) / 2; /* R */ + } else { +- /* first line or right column */ ++ /* First line or right column. */ + *scanpt++ = *(rawpt - 1); /* B */ + *scanpt++ = *rawpt; /* G */ + *scanpt++ = *(rawpt + width); /* R */ +@@ -230,7 +227,7 @@ void bayer2rgb24(unsigned char *dst, uns + *scanpt++ = *rawpt; /* G */ + *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2; /* R */ + } else { +- /* bottom line or left column */ ++ /* Bottom line or left column. */ + *scanpt++ = *(rawpt - width); /* B */ + *scanpt++ = *rawpt; /* G */ + *scanpt++ = *(rawpt + 1); /* R */ +@@ -238,13 +235,13 @@ void bayer2rgb24(unsigned char *dst, uns + } else { + /* R */ + if (i < (width * (height - 1)) && ((i % width) < (width - 1))) { +- *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + ++ *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + + *(rawpt + width - 1) + *(rawpt + width + 1)) / 4; /* B */ +- *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt - width) + +- *(rawpt + width)) / 4; /* G */ ++ *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + ++ *(rawpt - width) + *(rawpt + width)) / 4; /* G */ + *scanpt++ = *rawpt; /* R */ + } else { +- /* bottom line or right column */ ++ /* Bottom line or right column. */ + *scanpt++ = *(rawpt - width - 1); /* B */ + *scanpt++ = (*(rawpt - 1) + *(rawpt - width)) / 2; /* G */ + *scanpt++ = *rawpt; /* R */ +@@ -256,19 +253,24 @@ void bayer2rgb24(unsigned char *dst, uns + + } + ++/** ++ * conv_yuv422to420p ++ * ++ * ++ */ + void conv_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height) + { + unsigned char *src, *dest, *src2, *dest2; + int i, j; + +- /* Create the Y plane */ ++ /* Create the Y plane. */ + src = cap_map; + dest = map; + for (i = width * height; i > 0; i--) { + *dest++ = *src; + src += 2; + } +- /* Create U and V planes */ ++ /* Create U and V planes. */ + src = cap_map + 1; + src2 = cap_map + width * 2 + 1; + dest = map + width * height; +@@ -289,6 +291,11 @@ void conv_yuv422to420p(unsigned char *ma + } + } + ++/** ++ * conv_uyvyto420p ++ * ++ * ++ */ + void conv_uyvyto420p(unsigned char *map, unsigned char *cap_map, unsigned int width, unsigned int height) + { + uint8_t *pY = map; +@@ -300,26 +307,35 @@ void conv_uyvyto420p(unsigned char *map, + for (ix = 0; ix < height; ix++) { + for (jx = 0; jx < width; jx += 2) { + uint16_t calc; ++ + if ((ix&1) == 0) { + calc = *cap_map; + calc += *(cap_map + uv_offset); + calc /= 2; + *pU++ = (uint8_t) calc; + } ++ + cap_map++; + *pY++ = *cap_map++; ++ + if ((ix&1) == 0) { + calc = *cap_map; + calc += *(cap_map + uv_offset); + calc /= 2; + *pV++ = (uint8_t) calc; + } ++ + cap_map++; + *pY++ = *cap_map++; + } + } + } + ++/** ++ * conv_rgb24toyuv420p ++ * ++ * ++ */ + void conv_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height) + { + unsigned char *y, *u, *v; +@@ -360,67 +376,33 @@ void conv_rgb24toyuv420p(unsigned char * + } + } + +-int conv_jpeg2yuv420(struct context *cnt, unsigned char *dst, netcam_buff * buff, int width, int height) +-{ +- netcam_context netcam; +- +- if (!buff || !dst) +- return 3; +- +- if (!buff->ptr) +- return 2; /* Error decoding MJPEG frame */ +- +- memset(&netcam, 0, sizeof(netcam)); +- netcam.imgcnt_last = 1; +- netcam.latest = buff; +- netcam.width = width; +- netcam.height = height; +- netcam.cnt = cnt; +- +- pthread_mutex_init(&netcam.mutex, NULL); +- pthread_cond_init(&netcam.cap_cond, NULL); +- pthread_cond_init(&netcam.pic_ready, NULL); +- pthread_cond_init(&netcam.exiting, NULL); +- +- if (setjmp(netcam.setjmp_buffer)) +- return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; +- +- +- return netcam_proc_jpeg(&netcam, dst); +-} +- +- +- +-/* ++/** + * mjpegtoyuv420p + * + * Return values + * -1 on fatal error + * 0 on success +- * 2 if jpeg lib threw a "corrupt jpeg data" warning. ++ * 2 if jpeg lib threw a "corrupt jpeg data" warning. + * in this case, "a damaged output image is likely." + */ +- + int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size) + { + uint8_t *yuv[3]; + unsigned char *y, *u, *v; + int loop, ret; + +- yuv[0] = malloc(width * height * sizeof(yuv[0][0])); +- yuv[1] = malloc(width * height / 4 * sizeof(yuv[1][0])); +- yuv[2] = malloc(width * height / 4 * sizeof(yuv[2][0])); ++ yuv[0] = mymalloc(width * height * sizeof(yuv[0][0])); ++ yuv[1] = mymalloc(width * height / 4 * sizeof(yuv[1][0])); ++ yuv[2] = mymalloc(width * height / 4 * sizeof(yuv[2][0])); + + + ret = decode_jpeg_raw(cap_map, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]); +- ++ + if (ret == 1) { +- if (debug_level >= CAMERA_WARNINGS) +- motion_log(LOG_ERR, 0, "%s: Corrupt image ... continue", __FUNCTION__); ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Corrupt image ... continue"); + ret = 2; + } + +- + y = map; + u = y + width * height; + v = u + (width * height) / 4; +@@ -429,13 +411,13 @@ int mjpegtoyuv420p(unsigned char *map, u + memset(v, 0, width * height / 4); + + for(loop = 0; loop < width * height; loop++) +- *map++=yuv[0][loop]; ++ *map++ = yuv[0][loop]; + + for(loop = 0; loop < width * height / 4; loop++) +- *map++=yuv[1][loop]; ++ *map++ = yuv[1][loop]; + + for(loop = 0; loop < width * height / 4; loop++) +- *map++=yuv[2][loop]; ++ *map++ = yuv[2][loop]; + + free(yuv[0]); + free(yuv[1]); +@@ -463,10 +445,13 @@ int mjpegtoyuv420p(unsigned char *map, u + * the camera device. + */ + #define AUTOBRIGHT_HYSTERESIS 10 +-#define AUTOBRIGHT_DAMPER 5 +-#define AUTOBRIGHT_MAX 255 +-#define AUTOBRIGHT_MIN 0 ++#define AUTOBRIGHT_DAMPER 5 ++#define AUTOBRIGHT_MAX 255 ++#define AUTOBRIGHT_MIN 0 + ++/** ++ * vid_do_autobright ++ */ + int vid_do_autobright(struct context *cnt, struct video_dev *viddev) + { + +@@ -492,16 +477,18 @@ int vid_do_autobright(struct context *cn + } + avg = avg / j; + +- /* average is above window - turn down brightness - go for the target */ ++ /* Average is above window - turn down brightness - go for the target. */ + if (avg > brightness_window_high) { + step = MIN2((avg - brightness_target) / AUTOBRIGHT_DAMPER + 1, viddev->brightness - AUTOBRIGHT_MIN); ++ + if (viddev->brightness > step + 1 - AUTOBRIGHT_MIN) { + viddev->brightness -= step; + make_change = 1; + } + } else if (avg < brightness_window_low) { +- /* average is below window - turn up brightness - go for the target */ ++ /* Average is below window - turn up brightness - go for the target. */ + step = MIN2((brightness_target - avg) / AUTOBRIGHT_DAMPER + 1, AUTOBRIGHT_MAX - viddev->brightness); ++ + if (viddev->brightness < AUTOBRIGHT_MAX - step) { + viddev->brightness += step; + make_change = 1; +@@ -516,12 +503,14 @@ int vid_do_autobright(struct context *cn + *****************************************************************************/ + + #ifndef WITHOUT_V4L +-/* big lock for vid_start to ensure exclusive access to viddevs while adding +- * devices during initialization of each thread ++/* ++ * Big lock for vid_start to ensure exclusive access to viddevs while adding ++ * devices during initialization of each thread. + */ + static pthread_mutex_t vid_mutex; + +-/* Here we setup the viddevs structure which is used globally in the vid_* ++/* ++ * Here we setup the viddevs structure which is used globally in the vid_* + * functions. + */ + static struct video_dev *viddevs = NULL; +@@ -530,7 +519,7 @@ static struct video_dev *viddevs = NULL; + * vid_init + * + * Called from motion.c at the very beginning before setting up the threads. +- * Function prepares the vid_mutex ++ * Function prepares the vid_mutex. + */ + void vid_init(void) + { +@@ -540,7 +529,7 @@ void vid_init(void) + /** + * vid_cleanup + * +- * vid_cleanup is called from motion.c when Motion is stopped or restarted ++ * vid_cleanup is called from motion.c when Motion is stopped or restarted. + */ + void vid_cleanup(void) + { +@@ -552,18 +541,18 @@ void vid_cleanup(void) + /** + * vid_close + * +- * vid_close is called from motion.c when a Motion thread is stopped or restarted ++ * vid_close is called from motion.c when a Motion thread is stopped or restarted. + */ + void vid_close(struct context *cnt) + { + #ifndef WITHOUT_V4L + struct video_dev *dev = viddevs; + struct video_dev *prev = NULL; +-#endif /* WITHOUT_V4L */ ++#endif /* WITHOUT_V4L */ + + /* Cleanup the netcam part */ + if (cnt->netcam) { +- motion_log(LOG_DEBUG, 0, "vid_close: calling netcam_cleanup"); ++ MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: calling netcam_cleanup"); + netcam_cleanup(cnt->netcam, 0); + cnt->netcam = NULL; + return; +@@ -581,16 +570,17 @@ void vid_close(struct context *cnt) + } + pthread_mutex_unlock(&vid_mutex); + +- /* Set it as closed in thread context */ ++ /* Set it as closed in thread context. */ + cnt->video_dev = -1; + + if (dev == NULL) { +- motion_log(LOG_ERR, 0, "vid_close: Unable to find video device"); ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Unable to find video device"); + return; + } + + if (--dev->usage_count == 0) { +- motion_log(LOG_INFO, 0, "Closing video device %s", dev->video_device); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Closing video device %s", ++ dev->video_device); + #ifdef MOTION_V4L2 + if (dev->v4l2) { + v4l2_close(dev); +@@ -604,23 +594,22 @@ void vid_close(struct context *cnt) + #endif + dev->fd = -1; + pthread_mutex_lock(&vid_mutex); +- + /* Remove from list */ + if (prev == NULL) + viddevs = dev->next; + else + prev->next = dev->next; +- + pthread_mutex_unlock(&vid_mutex); + + pthread_mutexattr_destroy(&dev->attr); + pthread_mutex_destroy(&dev->mutex); + free(dev); + } else { +- motion_log(LOG_INFO, 0, "Still %d users of video device %s, so we don't close it now", ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Still %d users of video device %s, so we don't close it now", + dev->usage_count, dev->video_device); +- /* There is still at least one thread using this device +- * If we own it, release it ++ /* ++ * There is still at least one thread using this device ++ * If we own it, release it. + */ + if (dev->owner == cnt->threadnr) { + dev->frames = 0; +@@ -628,7 +617,7 @@ void vid_close(struct context *cnt) + pthread_mutex_unlock(&dev->mutex); + } + } +-#endif /* WITHOUT_V4L */ ++#endif /* !WITHOUT_V4L */ + } + + #ifndef WITHOUT_V4L +@@ -638,8 +627,8 @@ void vid_close(struct context *cnt) + * + * Called from vid_start setup the V4L/V4L2 capture device + * The function does the following: +- * +- * - Setup basic V4L/V4L2 properties incl palette incl setting ++ * ++ * - Setup basic V4L/V4L2 properties incl palette incl setting + * - Open the device + * - Returns the device number. + * +@@ -655,6 +644,7 @@ void vid_close(struct context *cnt) + * Returns + * device number + * -1 if failed to open device. ++ * -3 image dimensions are not modulo 8 + */ + static int vid_v4lx_start(struct context *cnt) + { +@@ -665,20 +655,23 @@ static int vid_v4lx_start(struct context + int width, height, input, norm, tuner_number; + unsigned long frequency; + +- /* We use width and height from conf in this function. They will be assigned +- * to width and height in imgs here, and cap_width and cap_height in ++ /* ++ * We use width and height from conf in this function. They will be assigned ++ * to width and height in imgs here, and cap_width and cap_height in + * rotate_data won't be set until in rotate_init. +- * Motion requires that width and height is a multiple of 16 so we check ++ * Motion requires that width and height is a multiple of 8 so we check + * for this first. + */ +- if (conf->width % 16) { +- motion_log(LOG_ERR, 0, "config image width (%d) is not modulo 16", conf->width); +- return -1; ++ if (conf->width % 8) { ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: config image width (%d) is not modulo 8", ++ conf->width); ++ return -3; + } + +- if (conf->height % 16) { +- motion_log(LOG_ERR, 0, "config image height (%d) is not modulo 16", conf->height); +- return -1; ++ if (conf->height % 8) { ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: config image height (%d) is not modulo 8", ++ conf->height); ++ return -3; + } + + width = conf->width; +@@ -690,24 +683,25 @@ static int vid_v4lx_start(struct context + + pthread_mutex_lock(&vid_mutex); + +- /* Transfer width and height from conf to imgs. The imgs values are the ones ++ /* ++ * Transfer width and height from conf to imgs. The imgs values are the ones + * that is used internally in Motion. That way, setting width and height via + * http remote control won't screw things up. + */ + cnt->imgs.width = width; + cnt->imgs.height = height; + +- /* First we walk through the already discovered video devices to see ++ /* ++ * First we walk through the already discovered video devices to see + * if we have already setup the same device before. If this is the case + * the device is a Round Robin device and we set the basic settings +- * and return the file descriptor ++ * and return the file descriptor. + */ + dev = viddevs; + while (dev) { + if (!strcmp(conf->video_device, dev->video_device)) { + dev->usage_count++; + cnt->imgs.type = dev->v4l_fmt; +- + switch (cnt->imgs.type) { + case VIDEO_PALETTE_GREY: + cnt->imgs.motionsize = width * height; +@@ -728,6 +722,9 @@ static int vid_v4lx_start(struct context + dev = dev->next; + } + ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using videodevice %s and input %d", ++ conf->video_device, conf->input); ++ + dev = mymalloc(sizeof(struct video_dev)); + memset(dev, 0, sizeof(struct video_dev)); + +@@ -736,7 +733,8 @@ static int vid_v4lx_start(struct context + fd = open(dev->video_device, O_RDWR); + + if (fd < 0) { +- motion_log(LOG_ERR, 1, "Failed to open video device %s", conf->video_device); ++ MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed to open video device %s", ++ conf->video_device); + free(dev); + pthread_mutex_unlock(&vid_mutex); + return -1; +@@ -748,12 +746,14 @@ static int vid_v4lx_start(struct context + dev->usage_count = 1; + dev->fd = fd; + dev->input = input; ++ dev->norm = norm; + dev->height = height; + dev->width = width; + dev->freq = frequency; + dev->tuner_number = tuner_number; + +- /* We set brightness, contrast, saturation and hue = 0 so that they only get ++ /* ++ * We set brightness, contrast, saturation and hue = 0 so that they only get + * set if the config is not zero. + */ + dev->brightness = 0; +@@ -764,19 +764,21 @@ static int vid_v4lx_start(struct context + dev->v4l_fmt = VIDEO_PALETTE_YUV420P; + dev->fps = 0; + #ifdef MOTION_V4L2 +- /* First lets try V4L2 and if it's not supported V4L1 */ ++ /* First lets try V4L2 and if it's not supported V4L1. */ + + dev->v4l2 = 1; + + if (!v4l2_start(cnt, dev, width, height, input, norm, frequency, tuner_number)) { +- /* restore width & height before test with v4l +- * because could be changed in v4l2_start () ++ /* ++ * Restore width & height before test with v4l ++ * because could be changed in v4l2_start(). + */ + dev->width = width; + dev->height = height; + #endif + +- if (!v4l_start(cnt, dev, width, height, input, norm, frequency, tuner_number)) { ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) ++ if (!v4l_start(dev, width, height, input, norm, frequency, tuner_number)) { + close(dev->fd); + pthread_mutexattr_destroy(&dev->attr); + pthread_mutex_destroy(&dev->mutex); +@@ -785,15 +787,17 @@ static int vid_v4lx_start(struct context + pthread_mutex_unlock(&vid_mutex); + return -1; + } ++#endif ++ + #ifdef MOTION_V4L2 + dev->v4l2 = 0; + } + #endif + if (dev->v4l2 == 0) { +- motion_log(-1, 0, "Using V4L1"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using V4L1"); + } else { +- motion_log(-1, 0, "Using V4L2"); +- /* Update width & height because could be changed in v4l2_start () */ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using V4L2"); ++ /* Update width & height because could be changed in v4l2_start(). */ + width = dev->width; + height = dev->height; + cnt->imgs.width = width; +@@ -817,17 +821,15 @@ static int vid_v4lx_start(struct context + break; + } + +- /* Insert into linked list */ ++ /* Insert into linked list. */ + dev->next = viddevs; + viddevs = dev; + + pthread_mutex_unlock(&vid_mutex); + +-return fd; ++ return fd; + } +-#endif /*WITHOUT_V4L */ +- +- ++#endif /* !WITHOUT_V4L */ + + /** + * vid_start +@@ -835,13 +837,13 @@ return fd; + * vid_start setup the capture device. This will be either a V4L device or a netcam. + * The function does the following: + * - If the camera is a netcam - netcam_start is called and function returns +- * - Width and height are checked for valid value (multiple of 16) ++ * - Width and height are checked for valid value (multiple of 8) + * - Copy the config height and width to the imgs struct. Note that height and width are + * only copied to the from the conf struct to the imgs struct during program startup + * The width and height can no later be changed via http remote control as this would + * require major re-memory allocations of all image buffers. +- * +- * - if the camera is V4L/V4L2 vid_v4lx_start is called ++ * ++ * - if the camera is V4L/V4L2 vid_v4lx_start is called + * + * Parameters: + * cnt Pointer to the context for this thread +@@ -849,8 +851,8 @@ return fd; + * Returns + * device number + * -1 if failed to open device. ++ * -3 image dimensions are not modulo 8 + */ +- + int vid_start(struct context *cnt) + { + struct config *conf = &cnt->conf; +@@ -864,8 +866,8 @@ int vid_start(struct context *cnt) + } + } + #ifdef WITHOUT_V4L +- else +- motion_log(LOG_ERR, 0,"You must setup netcam_url"); ++ else ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: You must setup netcam_url"); + #else + else + dev = vid_v4lx_start(cnt); +@@ -891,7 +893,7 @@ int vid_start(struct context *cnt) + * -1 Fatal V4L error + * -2 Fatal Netcam error + * Positive numbers... +- * with bit 0 set Non fatal V4L error (not implemented) ++ * with bit 0 set Non fatal V4L error (copy grey image and discard this image) + * with bit 1 set Non fatal Netcam error + */ + int vid_next(struct context *cnt, unsigned char *map) +@@ -906,8 +908,9 @@ int vid_next(struct context *cnt, unsign + return netcam_next(cnt, map); + } + #ifndef WITHOUT_V4L +- /* We start a new block so we can make declarations without breaking +- * gcc 2.95 or older ++ /* ++ * We start a new block so we can make declarations without breaking ++ * gcc 2.95 or older. + */ + { + struct video_dev *dev; +@@ -940,10 +943,10 @@ int vid_next(struct context *cnt, unsign + ret = v4l2_next(cnt, dev, map, width, height); + } else { + #endif +- v4l_set_input(cnt, dev, map, width, height, conf->input, conf->norm, +- conf->roundrobin_skip, conf->frequency, conf->tuner_number); +- ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) ++ v4l_set_input(cnt, dev, map, width, height, conf); + ret = v4l_next(dev, map, width, height); ++#endif + #ifdef MOTION_V4L2 + } + #endif +@@ -953,11 +956,11 @@ int vid_next(struct context *cnt, unsign + pthread_mutex_unlock(&dev->mutex); + } + +- /* rotate the image as specified */ ++ /* Rotate the image as specified. */ + if (cnt->rotate_data.degrees > 0) + rotate_map(cnt, map); +- ++ + } +-#endif /*WITHOUT_V4L */ ++#endif /*WITHOUT_V4L */ + return ret; + } +--- motion-3.2.12.orig/video_freebsd.c ++++ motion-3.2.12/video_freebsd.c +@@ -1,23 +1,22 @@ + /* video_freebsd.c + * + * BSD Video stream functions for motion. +- * Copyright 2004 by Angel Carpintero (ack@telefonica.net) ++ * Copyright 2004 by Angel Carpintero (motiondevelop@gmail.com) + * This software is distributed under the GNU public license version 2 + * See also the file 'COPYING'. + * + */ + +-/* for rotation */ +-#include "rotate.h" /* already includes motion.h */ ++/* For rotation */ ++#include "rotate.h" /* Already includes motion.h */ + #include "video_freebsd.h" + + #ifndef WITHOUT_V4L + +-/* for the v4l stuff: */ ++/* For the v4l stuff: */ + #include + + /* Hack from xawtv 4.x */ +- + #define VIDEO_NONE 0 + #define VIDEO_RGB08 1 /* bt848 dithered */ + #define VIDEO_GRAY 2 +@@ -40,7 +39,7 @@ + #define VIDEO_MPEG 19 /* MPEG1/2 */ + #define VIDEO_FMT_COUNT 20 + +-#define array_elem(x) (sizeof(x) / sizeof( (x)[0] )) ++#define array_elem(x) (sizeof(x) / sizeof((x)[0])) + + static const struct camparam_st { + int min, max, range, drv_min, drv_range, def; +@@ -56,7 +55,7 @@ static const struct camparam_st { + BT848_CONTRASTCENTER, }, + { + BT848_CHROMAMIN, (BT848_CHROMAMIN + BT848_CHROMARANGE), BT848_CHROMARANGE, +- BT848_CHROMAREGMIN, (BT848_CHROMAREGMAX - BT848_CHROMAREGMIN + 1 ), ++ BT848_CHROMAREGMIN, (BT848_CHROMAREGMAX - BT848_CHROMAREGMIN + 1), + BT848_CHROMACENTER, }, + }; + +@@ -68,13 +67,11 @@ volatile sig_atomic_t bktr_frame_waiting + + //sigset_t sa_mask; + +- + static void catchsignal(int sig) + { + bktr_frame_waiting++; + } + +- + /* Not tested yet */ + static void yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height) + { +@@ -110,8 +107,10 @@ static void yuv422to420p(unsigned char * + + } + +-/* FIXME seems no work with METEOR_GEO_RGB24 , check BPP as well ? */ +- ++/** ++ * rgb24toyuv420p ++ * FIXME seems no work with METEOR_GEO_RGB24 , check BPP as well ? ++ */ + static void rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height) + { + unsigned char *y, *u, *v; +@@ -160,15 +159,15 @@ static void rgb24toyuv420p(unsigned char + /* NOT TESTED YET FIXME */ + + /* +-static int camparam_normalize(int param, int cfg_value, int *ioctl_val) ++static int camparam_normalize(int param, int cfg_value, int *ioctl_val) + { + int val; + +- cfg_value = MIN(CamParams[ param ].max, MAX( CamParams[ param ].min, cfg_value)); +- val = (cfg_value - CamParams[ param ].min ) / ++ cfg_value = MIN(CamParams[ param ].max, MAX(CamParams[ param ].min, cfg_value)); ++ val = (cfg_value - CamParams[ param ].min) / + (CamParams[ param ].range + 0.01) * CamParams[param].drv_range + CamParams[param].drv_min; +- val = MAX(CamParams[param].min, +- MIN(CamParams[param].drv_min + CamParams[ param ].drv_range-1, val)); ++ val = MAX(CamParams[ param ].min, ++ MIN(CamParams[ param ].drv_min + CamParams[ param ].drv_range-1, val)); + *ioctl_val = val; + return cfg_value; + } +@@ -179,12 +178,12 @@ static int set_hue(int viddev, int new_h + signed char ioctlval = new_hue; + + if (ioctl(viddev, METEORSHUE, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORSHUE Error setting hue [%d]", __FUNCTION__, new_hue); +- return -1; +- } ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSHUE Error setting hue [%d]", ++ new_hue); ++ return -1; ++ } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); + + return ioctlval; + } +@@ -194,29 +193,27 @@ static int get_hue(int viddev , int *hue + signed char ioctlval; + + if (ioctl(viddev, METEORGHUE, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORGHUE Error getting hue", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGHUE Error getting hue"); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); +- +- *hue = ioctlval; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); ++ ++ *hue = ioctlval; + return ioctlval; + } + +-static int set_saturation(int viddev, int new_saturation) ++static int set_saturation(int viddev, int new_saturation) + { + unsigned char ioctlval= new_saturation; + + if (ioctl(viddev, METEORSCSAT, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORSCSAT Error setting saturation [%d]", +- __FUNCTION__, new_saturation); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSCSAT Error setting saturation [%d]", ++ new_saturation); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); + + return ioctlval; + } +@@ -226,30 +223,27 @@ static int get_saturation(int viddev , i + unsigned char ioctlval; + + if (ioctl(viddev, METEORGCSAT, &ioctlval) < 0) { +- +- motion_log(LOG_ERR, 1, "%s: METEORGCSAT Error getting saturation", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGCSAT Error getting saturation"); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); ++ + *saturation = ioctlval; + return ioctlval; + } + +-static int set_contrast(int viddev, int new_contrast) ++static int set_contrast(int viddev, int new_contrast) + { + unsigned char ioctlval = new_contrast; + + if (ioctl(viddev, METEORSCONT, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORSCONT Error setting contrast [%d]", +- __FUNCTION__, new_contrast); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSCONT Error setting contrast [%d]", ++ new_contrast); + return 0; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); + + return ioctlval; + } +@@ -258,15 +252,14 @@ static int get_contrast(int viddev, int + { + unsigned char ioctlval; + +- if (ioctl (viddev, METEORGCONT, &ioctlval ) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORGCONT Error getting contrast", __FUNCTION__); ++ if (ioctl(viddev, METEORGCONT, &ioctlval) < 0) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGCONT Error getting contrast"); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); +- +- *contrast = ioctlval; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); ++ ++ *contrast = ioctlval; + return ioctlval; + } + +@@ -276,13 +269,13 @@ static int set_brightness(int viddev, in + unsigned char ioctlval = new_bright; + + if (ioctl(viddev, METEORSBRIG, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORSBRIG brightness [%d]", __FUNCTION__, new_bright); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSBRIG brightness [%d]", ++ new_bright); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); ++ + return ioctlval; + } + +@@ -292,57 +285,57 @@ static int get_brightness(int viddev, in + unsigned char ioctlval; + + if (ioctl(viddev, METEORGBRIG, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORGBRIG getting brightness", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGBRIG getting brightness"); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); ++ + *brightness = ioctlval; + return ioctlval; + } + +-// Set channel needed ? FIXME ++// Set channel needed ? FIXME + /* +-static int set_channel(struct video_dev *viddev, int new_channel) ++static int set_channel(struct video_dev *viddev, int new_channel) + { + int ioctlval; + + ioctlval = new_channel; + if (ioctl(viddev->fd_tuner, TVTUNER_SETCHNL, &ioctlval) < 0) { +- motion_log(LOG_ERR, 1, "Error channel %d", ioctlval); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error channel %d", ioctlval); + return -1; + } else { +- motion_log(LOG_DEBUG, 0, "channel set to %d", ioctlval); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: channel set to %d", ioctlval); + } + + viddev->channel = new_channel; +- ++ + return 0; + } + */ + +-/* set frequency to tuner */ +- ++/** ++ * set_freq ++ * Sets frequency to tuner ++ */ + static int set_freq(struct video_dev *viddev, unsigned long freq) + { + int tuner_fd = viddev->fd_tuner; + int old_audio; + +- motion_log(LOG_DEBUG, 0, "%s: Not implemented", __FUNCTION__); +- +- return 0; +- +- /* HACK maybe not need it , but seems that is needed to mute before changing frequency */ ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Not implemented"); ++ return 0; + ++ /* HACK maybe not need it , but seems that is needed to mute before changing frequency */ + if (ioctl(tuner_fd, BT848_GAUDIO, &old_audio) < 0) { +- motion_log(LOG_ERR, 1, "%s: BT848_GAUDIO", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848_GAUDIO"); + return -1; + } +- ++ + if (ioctl(tuner_fd, TVTUNER_SETFREQ, &freq) < 0) { +- motion_log(LOG_ERR, 1, "%s: Tuning (TVTUNER_SETFREQ) failed , freq [%lu]", __FUNCTION__, freq); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Tuning (TVTUNER_SETFREQ) failed, ", ++ "freq [%lu]", freq); + return -1; + } + +@@ -350,55 +343,58 @@ static int set_freq(struct video_dev *vi + if (old_audio) { + old_audio = AUDIO_MUTE; + if (ioctl(tuner_fd , BT848_SAUDIO, &old_audio) < 0) { +- motion_log(LOG_ERR, 1, "%s: BT848_SAUDIO %i", __FUNCTION__, old_audio); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848_SAUDIO %i", ++ old_audio); + return -1; + } + } +- ++ + return 0; + } + +-/* +- set the input to capture images , could be tuner (METEOR_INPUT_DEV1) +- or any of others input : +- RCA/COMPOSITE1 (METEOR_INPUT_DEV0) +- COMPOSITE2/S-VIDEO (METEOR_INPUT_DEV2) +- S-VIDEO (METEOR_INPUT_DEV3) +- VBI ?! (METEOR_INPUT_DEV_SVIDEO) +-*/ +- +-static int set_input(struct video_dev *viddev, unsigned short input) ++/** ++ * set_input ++ * Sets the input to capture images , could be tuner (METEOR_INPUT_DEV1) ++ * or any of others input : ++ * RCA/COMPOSITE1 (METEOR_INPUT_DEV0) ++ * COMPOSITE2/S-VIDEO (METEOR_INPUT_DEV2) ++ * S-VIDEO (METEOR_INPUT_DEV3) ++ * VBI ?! (METEOR_INPUT_DEV_SVIDEO) ++ */ ++static int set_input(struct video_dev *viddev, unsigned input) + { + int actport; + int portdata[] = { METEOR_INPUT_DEV0, METEOR_INPUT_DEV1, + METEOR_INPUT_DEV2, METEOR_INPUT_DEV3, +- METEOR_INPUT_DEV_SVIDEO}; ++ METEOR_INPUT_DEV_SVIDEO }; + + if (input >= array_elem(portdata)) { +- motion_log(LOG_INFO, 0, "%s: Channel Port %d out of range (0-4)", __FUNCTION__, input); ++ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Channel Port %d out of range (0-4)", ++ input); + return -1; + } + +- actport = portdata[input]; ++ actport = portdata[ input ]; + if (ioctl(viddev->fd_bktr, METEORSINPUT, &actport) < 0) { + if (input != IN_DEFAULT) { +- motion_log(LOG_INFO, 1, "%s: METEORSINPUT %d invalid - Trying default %d", +- __FUNCTION__, input, IN_DEFAULT); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSINPUT %d invalid -" ++ "Trying default %d", input, IN_DEFAULT); + input = IN_DEFAULT; +- actport = portdata[input]; ++ actport = portdata[ input ]; + if (ioctl(viddev->fd_bktr, METEORSINPUT, &actport) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORSINPUT %d init", __FUNCTION__, input); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSINPUT %d init", ++ input); + return -1; + } + } else { +- motion_log(LOG_ERR, 1, "%s: METEORSINPUT %d init", __FUNCTION__, input); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSINPUT %d init", ++ input); + return -1; + } + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, input); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", input); ++ + return input; + } + +@@ -409,72 +405,70 @@ static int set_geometry(struct video_dev + + geom.columns = width; + geom.rows = height; +- + geom.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12; + +- + switch (viddev->norm) { +- case PAL: +- h_max = PAL_HEIGHT; ++ case PAL: ++ h_max = PAL_HEIGHT; + break; +- case NTSC: +- h_max = NTSC_HEIGHT; ++ case NTSC: ++ h_max = NTSC_HEIGHT; + break; +- case SECAM: ++ case SECAM: + h_max = SECAM_HEIGHT; + break; +- default: ++ default: + h_max = PAL_HEIGHT; + } + +- if (height <= h_max / 2) ++ if (height <= h_max / 2) + geom.oformat |= METEOR_GEO_EVEN_ONLY; + + geom.frames = 1; + + if (ioctl(viddev->fd_bktr, METEORSETGEO, &geom) < 0) { +- motion_log(LOG_ERR, 1, "%s: Couldn't set the geometry", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Couldn't set the geometry"); + return -1; + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to [%d/%d] Norm %d", __FUNCTION__, width, height, viddev->norm); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d/%d] Norm %d", ++ width, height, viddev->norm); ++ + return 0; + } + +-/* +- set input format ( PAL, NTSC, SECAM, etc ... ) +-*/ +- +-static int set_input_format(struct video_dev *viddev, unsigned short newformat) ++/** ++ * set_input_format ++ * Sets input format ( PAL, NTSC, SECAM, etc ... ) ++ */ ++static int set_input_format(struct video_dev *viddev, unsigned newformat) + { + int input_format[] = { NORM_PAL_NEW, NORM_NTSC_NEW, NORM_SECAM_NEW, NORM_DEFAULT_NEW}; + int format; +- +- if (newformat >= array_elem( input_format )) { +- motion_log(LOG_WARNING, 0, "%s: Input format %d out of range (0-2)", __FUNCTION__, newformat); ++ ++ if (newformat >= array_elem(input_format)) { ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Input format %d out of range (0-2)", ++ newformat); + return -1; +- } ++ } + +- format = input_format[newformat]; ++ format = input_format[newformat]; + +- if (ioctl( viddev->fd_bktr, BT848SFMT, &format) < 0) { +- motion_log(LOG_ERR, 1, "%s: BT848SFMT, Couldn't set the input format , try again with default", +- __FUNCTION__); ++ if (ioctl(viddev->fd_bktr, BT848SFMT, &format) < 0) { ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848SFMT, Couldn't set the input format, " ++ "try again with default"); + format = NORM_DEFAULT_NEW; + newformat = 3; +- ++ + if (ioctl(viddev->fd_bktr, BT848SFMT, &format) < 0) { +- motion_log(LOG_ERR, 1, "%s: BT848SFMT, Couldn't set the input format either default", +- __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848SFMT, Couldn't set the input format " ++ "either default"); + return -1; + } + } + +- if (debug_level >= CAMERA_VIDEO) +- motion_log(-1, 0, "%s: to %d", __FUNCTION__, newformat); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to %d", newformat); ++ + return newformat; + } + +@@ -485,73 +479,75 @@ statict int setup_pixelformat(int bktr) + struct meteor_pixfmt p; + int format=-1; + +- for(i = 0; ; i++){ ++ for (i = 0; ; i++) { + p.index = i; +- if (ioctl(bktr, METEORGSUPPIXFMT, &p ) < 0) { ++ if (ioctl(bktr, METEORGSUPPIXFMT, &p) < 0) { + if (errno == EINVAL) + break; +- motion_log(LOG_ERR, 1, "METEORGSUPPIXFMT getting pixformat %d", i); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGSUPPIXFMT getting pixformat %d", i); + return -1; + } + + +- // Hack from xawtv 4.x ++ // Hack from xawtv 4.x + +- switch ( p.type ) { ++ switch (p.type) { + case METEOR_PIXTYPE_RGB: +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB"); +- switch(p.masks[0]) { +- case 31744: // 15 bpp +- format = p.swap_bytes ? VIDEO_RGB15_LE : VIDEO_RGB15_BE; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB15"); +- break; +- case 63488: // 16 bpp +- format = p.swap_bytes ? VIDEO_RGB16_LE : VIDEO_RGB16_BE; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB16"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB"); ++ switch (p.masks[0]) { ++ case 31744: // 15 bpp ++ format = p.swap_bytes ? VIDEO_RGB15_LE : VIDEO_RGB15_BE; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB15"); + break; +- case 16711680: // 24/32 bpp +- if (p.Bpp == 3 && p.swap_bytes == 1) { +- format = VIDEO_BGR24; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR24"); +- } else if (p.Bpp == 4 && p.swap_bytes == 1 && p.swap_shorts == 1) { +- format = VIDEO_BGR32; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR32"); +- } else if (p.Bpp == 4 && p.swap_bytes == 0 && p.swap_shorts == 0) { +- format = VIDEO_RGB32; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB32"); +- } ++ case 63488: // 16 bpp ++ format = p.swap_bytes ? VIDEO_RGB16_LE : VIDEO_RGB16_BE; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB16"); + break; +- case METEOR_PIXTYPE_YUV: +- format = VIDEO_YUV422P; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_YUV"); ++ case 16711680: // 24/32 bpp ++ if (p.Bpp == 3 && p.swap_bytes == 1) { ++ format = VIDEO_BGR24; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR24"); ++ } else if (p.Bpp == 4 && p.swap_bytes == 1 && p.swap_shorts == 1) { ++ format = VIDEO_BGR32; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR32"); ++ } else if (p.Bpp == 4 && p.swap_bytes == 0 && p.swap_shorts == 0) { ++ format = VIDEO_RGB32; ++ MOTION_LOG(EMG, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB32"); ++ } ++ } + break; +- case METEOR_PIXTYPE_YUV_12: +- format = VIDEO_YUV422P; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_YUV_12"); ++ case METEOR_PIXTYPE_YUV: ++ format = VIDEO_YUV422P; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_YUV"); + break; +- case METEOR_PIXTYPE_YUV_PACKED: +- format = VIDEO_YUV422P; +- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_YUV_PACKED"); ++ case METEOR_PIXTYPE_YUV_12: ++ format = VIDEO_YUV422P; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_YUV_12"); ++ break; ++ case METEOR_PIXTYPE_YUV_PACKED: ++ format = VIDEO_YUV422P; ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_YUV_PACKED"); + break; ++ + } + +- if (p.type == METEOR_PIXTYPE_RGB && p.Bpp == 3){ +- // Found a good pixeltype -- set it up +- if (ioctl(bktr, METEORSACTPIXFMT, &i) < 0){ +- motion_log(LOG_WARNING, 1, "METEORSACTPIXFMT etting pixformat METEOR_PIXTYPE_RGB Bpp == 3"); +- // Not immediately fatal ++ if (p.type == METEOR_PIXTYPE_RGB && p.Bpp == 3) { ++ // Found a good pixeltype -- set it up ++ if (ioctl(bktr, METEORSACTPIXFMT, &i) < 0) { ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSACTPIXFMT etting pixformat METEOR_PIXTYPE_RGB Bpp == 3"); ++ // Not immediately fatal + } +- motion_log(LOG_DEBUG, 0, "input format METEOR_PIXTYPE_RGB %i", i); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: input format METEOR_PIXTYPE_RGB %i", i); + format = i; + } + + if (p.type == METEOR_PIXTYPE_YUV_PACKED) { + // Found a good pixeltype -- set it up +- if (ioctl(bktr, METEORSACTPIXFMT, &i ) < 0){ +- motion_log(LOG_WARNING, 1, "METEORSACTPIXFMT setting pixformat METEOR_PIXTYPE_YUV_PACKED"); ++ if (ioctl(bktr, METEORSACTPIXFMT, &i) < 0) { ++ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSACTPIXFMT setting pixformat METEOR_PIXTYPE_YUV_PACKED"); + // Not immediately fatal +- } +- motion_log(LOG_DEBUG, 0, "input format METEOR_PIXTYPE_YUV_PACKED %i", i); ++ } ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: input format METEOR_PIXTYPE_YUV_PACKED %i", i); + format = i; + } + +@@ -566,23 +562,23 @@ static void v4l_picture_controls(struct + { + int dev = viddev->fd_bktr; + +- if ((cnt->conf.contrast) && (cnt->conf.contrast != viddev->contrast)) { ++ if ((cnt->conf.contrast) && (cnt->conf.contrast != viddev->contrast)) { + set_contrast(dev, cnt->conf.contrast); +- viddev->contrast = cnt->conf.contrast; ++ viddev->contrast = cnt->conf.contrast; + } + + if ((cnt->conf.hue) && (cnt->conf.hue != viddev->hue)) { + set_hue(dev, cnt->conf.hue); +- viddev->hue = cnt->conf.hue; ++ viddev->hue = cnt->conf.hue; + } + +- if ((cnt->conf.brightness) && ++ if ((cnt->conf.brightness) && + (cnt->conf.brightness != viddev->brightness)) { + set_brightness(dev, cnt->conf.brightness); +- viddev->brightness = cnt->conf.brightness; ++ viddev->brightness = cnt->conf.brightness; + } + +- if ((cnt->conf.saturation) && ++ if ((cnt->conf.saturation) && + (cnt->conf.saturation != viddev->saturation)) { + set_saturation(dev, cnt->conf.saturation); + viddev->saturation = cnt->conf.saturation; +@@ -597,7 +593,7 @@ static void v4l_picture_controls(struct + - setup_pixelformat + - set_geometry + +- - set_brightness ++ - set_brightness + - set_chroma + - set_contrast + - set_channelset +@@ -605,97 +601,97 @@ static void v4l_picture_controls(struct + - set_capture_mode + + */ +-static unsigned char *v4l_start(struct video_dev *viddev, int width, int height, +- unsigned short input, unsigned short norm, unsigned long freq) ++static unsigned char *v4l_start(struct video_dev *viddev, int width, int height, ++ unsigned input, unsigned norm, unsigned long freq) + { + int dev_bktr = viddev->fd_bktr; + struct sigaction act, old; + //int dev_tunner = viddev->fd_tuner; +- /* to ensure that all device will be support the capture mode ++ /* to ensure that all device will be support the capture mode + _TODO_ : Autodected the best capture mode . + */ + int dummy = 1; +-// int pixelformat = BSD_VIDFMT_I420; ++ // int pixelformat = BSD_VIDFMT_I420; + + void *map; + +- /* if we have choose the tuner is needed to setup the frequency */ ++ /* If we have choose the tuner is needed to setup the frequency. */ + if ((viddev->tuner_device != NULL) && (input == IN_TV)) { + if (!freq) { +- motion_log(LOG_ERR, 0, "%s: Not valid Frequency [%lu] for Source input [%i]", +- __FUNCTION__, freq, input); ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Not valid Frequency [%lu] for " ++ "Source input [%i]", freq, input); + return NULL; + } else if (set_freq(viddev, freq) == -1) { +- motion_log(LOG_ERR, 0, "%s: Frequency [%lu] Source input [%i]", +- __FUNCTION__, freq, input); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Frequency [%lu] Source input [%i]", ++ freq, input); + return NULL; + } + } +- +- /* FIXME if we set as input tuner , we need to set option for tuner not for bktr */ + ++ /* FIXME if we set as input tuner , we need to set option for tuner not for bktr */ + if ((dummy = set_input(viddev, input)) == -1) { +- motion_log(LOG_ERR, 0, "%s: set input [%d]", __FUNCTION__, input); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set input [%d]", input); + return NULL; + } + + viddev->input = dummy; + + if ((dummy = set_input_format(viddev, norm)) == -1) { +- motion_log(LOG_ERR, 0, "%s: set input format [%d]", __FUNCTION__, norm); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set input format [%d]", ++ norm); + return NULL; + } + + viddev->norm = dummy; + + if (set_geometry(viddev, width, height) == -1) { +- motion_log(LOG_ERR, 0, "%s: set geometry [%d]x[%d]", __FUNCTION__, width, height); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set geometry [%d]x[%d]", ++ width, height); + return NULL; + } +-/* ++ ++ /* + if (ioctl(dev_bktr, METEORSACTPIXFMT, &pixelformat) < 0) { +- motion_log(LOG_ERR, 1, "set encoding method BSD_VIDFMT_I420"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: set encoding method BSD_VIDFMT_I420"); + return NULL; + } + +- +- NEEDED !? FIXME ++ NEEDED !? FIXME + + if (setup_pixelformat(viddev) == -1) + return NULL; +-*/ ++ */ + + if (freq) { +- if (debug_level >= CAMERA_DEBUG) +- motion_log(-1, 0, "%s: Frequency set (no implemented yet", __FUNCTION__); ++ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Frequency set (no implemented yet"); + /* + TODO missing implementation + set_channelset(viddev); + set_channel(viddev); +- if (set_freq (viddev, freq) == -1) { ++ if (set_freq (viddev, freq) == -1) + return NULL; +- } + */ +- } +- + +- /* set capture mode and capture buffers */ +- +- /* That is the buffer size for capture images , +- so is dependent of color space of input format / FIXME */ ++ } + ++ /* ++ * Set capture mode and capture buffers ++ * That is the buffer size for capture images , ++ * so is dependent of color space of input format / FIXME ++ */ + viddev->v4l_bufsize = (((width * height * 3 / 2)) * sizeof(unsigned char)); + viddev->v4l_fmt = VIDEO_PALETTE_YUV420P; +- + +- map = mmap((caddr_t)0, viddev->v4l_bufsize, PROT_READ|PROT_WRITE, MAP_SHARED, dev_bktr, (off_t)0); + +- if (map == MAP_FAILED){ +- motion_log(LOG_ERR, 1, "%s: mmap failed", __FUNCTION__); ++ map = mmap((caddr_t)0, viddev->v4l_bufsize, PROT_READ|PROT_WRITE, MAP_SHARED, ++ dev_bktr, (off_t)0); ++ ++ if (map == MAP_FAILED) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: mmap failed"); + return NULL; + } + +- /* FIXME double buffer */ ++ /* FIXME double buffer */ + if (0) { + viddev->v4l_maxbuffer = 2; + viddev->v4l_buffers[0] = map; +@@ -709,55 +705,54 @@ static unsigned char *v4l_start(struct v + viddev->v4l_curbuffer = 0; + + /* Clear the buffer */ +- + if (ioctl(dev_bktr, BT848SCBUF, &dummy) < 0) { +- motion_log(LOG_ERR, 1, "%s: BT848SCBUF", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848SCBUF"); + return NULL; + } + +- /* signal handler to know when data is ready to be read() */ +- ++ /* Signal handler to know when data is ready to be read() */ + memset(&act, 0, sizeof(act)); + sigemptyset(&act.sa_mask); + act.sa_handler = catchsignal; + sigaction(SIGUSR2, &act, &old); +- ++ + dummy = SIGUSR2; + + //viddev->capture_method = METEOR_CAP_CONTINOUS; + //viddev->capture_method = METEOR_CAP_SINGLE; +- +- if ((viddev->capture_method == METEOR_CAP_CONTINOUS) && (ioctl(dev_bktr, METEORSSIGNAL, &dummy) < 0)) { +- motion_log(LOG_ERR, 1, "%s: METEORSSIGNAL", __FUNCTION__); +- motion_log(LOG_INFO, 0 , "%s: METEORSSIGNAL", __FUNCTION__); ++ ++ if ((viddev->capture_method == METEOR_CAP_CONTINOUS) && ++ (ioctl(dev_bktr, METEORSSIGNAL, &dummy) < 0)) { ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORSSIGNAL"); ++ + viddev->capture_method = METEOR_CAP_SINGLE; ++ + if (ioctl(dev_bktr, METEORCAPTUR, &viddev->capture_method) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORCAPTUR using single method " +- "Error capturing", __FUNCTION__); +- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR using single method " +- "Error capturing", __FUNCTION__); +- } ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORCAPTUR using single method " ++ "Error capturing"); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORCAPTUR using single method " ++ "Error capturing"); ++ } + } else { + if (ioctl(dev_bktr, METEORCAPTUR, &viddev->capture_method) < 0) { + viddev->capture_method = METEOR_CAP_SINGLE; ++ + if (ioctl(dev_bktr, METEORCAPTUR, &viddev->capture_method) < 0) { +- motion_log(LOG_ERR, 1, "%s: METEORCAPTUR using single method " +- "Error capturing", __FUNCTION__); +- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR using single method " +- "Error capturing", __FUNCTION__); +- } +- } +- } +- ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORCAPTUR using single method " ++ "Error capturing"); ++ } ++ } ++ } ++ + if (viddev->capture_method == METEOR_CAP_CONTINOUS) +- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR METEOR_CAP_CONTINOUS", __FUNCTION__); +- else +- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR METEOR_CAP_SINGLE", __FUNCTION__); +- ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORCAPTUR METEOR_CAP_CONTINOUS"); ++ else ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORCAPTUR METEOR_CAP_SINGLE"); ++ + // settle , sleep(1) replaced + SLEEP(1, 0); + +- /* FIXME*/ ++ /* FIXME */ + switch (viddev->v4l_fmt) { + case VIDEO_PALETTE_YUV420P: + viddev->v4l_bufsize = (width * height * 3) / 2; +@@ -772,12 +767,16 @@ static unsigned char *v4l_start(struct v + viddev->v4l_bufsize = width * height; + break; + } +- +- motion_log(LOG_INFO, 0, "HUE [%d]", get_hue(dev_bktr, &dummy)); +- motion_log(LOG_INFO, 0, "SATURATION [%d]", get_saturation(dev_bktr, &dummy)); +- motion_log(LOG_INFO, 0, "BRIGHTNESS [%d]", get_brightness(dev_bktr, &dummy)); +- motion_log(LOG_INFO, 0, "CONTRAST [%d]", get_contrast(dev_bktr, &dummy)); +- ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: HUE [%d]", ++ get_hue(dev_bktr, &dummy)); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: SATURATION [%d]", ++ get_saturation(dev_bktr, &dummy)); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: BRIGHTNESS [%d]", ++ get_brightness(dev_bktr, &dummy)); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: CONTRAST [%d]", ++ get_contrast(dev_bktr, &dummy)); ++ + return map; + } + +@@ -805,8 +804,10 @@ static int v4l_next(struct video_dev *vi + + /* ONLY MMAP method is used to Capture */ + +- /* Allocate a new mmap buffer */ +- /* Block signals during IOCTL */ ++ /* ++ * Allocates a new mmap buffer ++ * Block signals during IOCTL ++ */ + sigemptyset (&set); + sigaddset (&set, SIGCHLD); + sigaddset (&set, SIGALRM); +@@ -820,21 +821,21 @@ static int v4l_next(struct video_dev *vi + if (viddev->v4l_curbuffer >= viddev->v4l_maxbuffer) + viddev->v4l_curbuffer = 0; + +- /* capture */ +- ++ /* Capture */ ++ + if (viddev->capture_method == METEOR_CAP_CONTINOUS) { +- if (bktr_frame_waiting) +- bktr_frame_waiting = 0; +- ++ if (bktr_frame_waiting) ++ bktr_frame_waiting = 0; ++ + } else if (ioctl(dev_bktr, METEORCAPTUR, &single) < 0) { +- motion_log(LOG_ERR, 1, "%s: Error capturing using single method", __FUNCTION__); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error capturing using single method"); + sigprocmask(SIG_UNBLOCK, &old, NULL); + return -1; + } + +- /*undo the signal blocking*/ ++ /* Undo the signal blocking */ + pthread_sigmask(SIG_UNBLOCK, &old, NULL); +- ++ + switch (viddev->v4l_fmt) { + case VIDEO_PALETTE_RGB24: + rgb24toyuv420p(map, cap_map, width, height); +@@ -845,33 +846,35 @@ static int v4l_next(struct video_dev *vi + default: + memcpy(map, cap_map, viddev->v4l_bufsize); + } +- ++ + return 0; + } + + +-/* set input & freq if needed FIXME not allowed use Tuner yet */ +- +-static void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, +- unsigned short input, unsigned short norm, int skip, unsigned long freq) ++/** ++ * v4l_set_input ++ * Sets input & freq if needed FIXME not allowed use Tuner yet. ++ */ ++static void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, ++ int height, unsigned input, unsigned norm, int skip, unsigned long freq) + { +- + if (input != viddev->input || norm != viddev->norm || freq != viddev->freq) { + int dummy; + unsigned long frequnits = freq; + +- ++ + if ((dummy = set_input(viddev, input)) == -1) + return; + + viddev->input = dummy; +- ++ + if ((dummy = set_input_format(viddev, norm)) == -1) + return; +- ++ + viddev->norm = dummy; +- +- if ((viddev->tuner_device != NULL) && (viddev->input == IN_TV) && (frequnits > 0)) { ++ ++ if ((viddev->tuner_device != NULL) && (viddev->input == IN_TV) && ++ (frequnits > 0)) { + if (set_freq(viddev, freq) == -1) + return; + } +@@ -879,16 +882,14 @@ static void v4l_set_input(struct context + // FIXME + /* + if (setup_pixelformat(viddev) == -1) { +- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSFREQ)"); ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSFREQ)"); + return + } +- */ + +- /* + if (set_geometry(viddev, width, height) == -1) + return; +- */ +- ++ */ ++ + v4l_picture_controls(cnt, viddev); + + viddev->freq = freq; +@@ -896,7 +897,6 @@ static void v4l_set_input(struct context + /* skip a few frames if needed */ + for (dummy = 0; dummy < skip; dummy++) + v4l_next(viddev, map, width, height); +- + } else { + /* No round robin - we only adjust picture controls */ + v4l_picture_controls(cnt, viddev); +@@ -911,39 +911,39 @@ static void v4l_set_input(struct context + + vid_init - Initi vid_mutex. + vid_start - Setup Device parameters ( device , channel , freq , contrast , hue , saturation , brightness ) and open it. +-vid_next - Capture a frame and set input , contrast , hue , saturation and brightness if necessary. +-vid_close - close devices. ++vid_next - Capture a frame and set input , contrast , hue , saturation and brightness if necessary. ++vid_close - close devices. + vid_cleanup - Destroy vid_mutex. + + */ + +-/* big lock for vid_start to ensure exclusive access to viddevs while adding +- * devices during initialization of each thread ++/* ++ * Big lock for vid_start to ensure exclusive access to viddevs while adding ++ * devices during initialization of each thread. + */ + static pthread_mutex_t vid_mutex; + +- +-/* Here we setup the viddevs structure which is used globally in the vid_* ++/* ++ * Here we setup the viddevs structure which is used globally in the vid_* + * functions. +- */ ++ */ + static struct video_dev *viddevs = NULL; + +- +-/* ++/** + * vid_init + * + * Called from motion.c at the very beginning before setting up the threads. +- * Function prepares the vid_mutex ++ * Function prepares the vid_mutex. + */ + void vid_init(void) + { + pthread_mutex_init(&vid_mutex, NULL); + } +- ++ + /** + * vid_cleanup + * +- * vid_cleanup is called from motion.c when Motion is stopped or restarted ++ * vid_cleanup is called from motion.c when Motion is stopped or restarted. + */ + void vid_cleanup(void) + { +@@ -952,13 +952,12 @@ void vid_cleanup(void) + + #endif /*WITHOUT_V4L*/ + +- + /** + * vid_close + * +- * vid_close is called from motion.c when a Motion thread is stopped or restarted ++ * vid_close is called from motion.c when a Motion thread is stopped or restarted. + */ +-void vid_close(struct context *cnt) ++void vid_close(struct context *cnt) + { + #ifndef WITHOUT_V4L + struct video_dev *dev = viddevs; +@@ -970,79 +969,86 @@ void vid_close(struct context *cnt) + netcam_cleanup(cnt->netcam, 0); + cnt->netcam = NULL; + return; +- } ++ } + + #ifndef WITHOUT_V4L + + /* Cleanup the v4l part */ + pthread_mutex_lock(&vid_mutex); ++ + while (dev) { + if (dev->fd_bktr == cnt->video_dev) + break; +- prev = dev; +- dev = dev->next; +- } +- pthread_mutex_unlock(&vid_mutex); +- +- /* Set it as closed in thread context */ +- cnt->video_dev = -1; +- +- if (dev == NULL) { +- motion_log(LOG_ERR, 0, "%s: Unable to find video device", __FUNCTION__); +- return; +- } ++ prev = dev; ++ dev = dev->next; ++ } + +- if (--dev->usage_count == 0) { +- motion_log(LOG_INFO, 0, "%s: Closing video device %s", +- __FUNCTION__, dev->video_device); +- +- if (dev->fd_tuner > 0) +- close(dev->fd_tuner); +- +- if (dev->fd_bktr > 0) { +- if (dev->capture_method == METEOR_CAP_CONTINOUS) { +- dev->fd_tuner = METEOR_CAP_STOP_CONT; +- ioctl(dev->fd_bktr, METEORCAPTUR, &dev->fd_tuner); +- } +- close(dev->fd_bktr); +- dev->fd_tuner = -1; ++ pthread_mutex_unlock(&vid_mutex); ++ ++ /* Set it as closed in thread context. */ ++ cnt->video_dev = -1; ++ ++ if (dev == NULL) { ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Unable to find video device"); ++ return; ++ } ++ ++ if (--dev->usage_count == 0) { ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Closing video device %s", ++ dev->video_device); ++ ++ if (dev->fd_tuner > 0) ++ close(dev->fd_tuner); ++ ++ if (dev->fd_bktr > 0) { ++ if (dev->capture_method == METEOR_CAP_CONTINOUS) { ++ dev->fd_tuner = METEOR_CAP_STOP_CONT; ++ ioctl(dev->fd_bktr, METEORCAPTUR, &dev->fd_tuner); + } ++ close(dev->fd_bktr); ++ dev->fd_tuner = -1; ++ } + + +- munmap(viddevs->v4l_buffers[0], viddevs->v4l_bufsize); +- viddevs->v4l_buffers[0] = MAP_FAILED; ++ munmap(viddevs->v4l_buffers[0], viddevs->v4l_bufsize); ++ viddevs->v4l_buffers[0] = MAP_FAILED; + +- dev->fd_bktr = -1; +- pthread_mutex_lock(&vid_mutex); +- +- /* Remove from list */ +- if (prev == NULL) +- viddevs = dev->next; +- else +- prev->next = dev->next; +- +- pthread_mutex_unlock(&vid_mutex); ++ dev->fd_bktr = -1; ++ pthread_mutex_lock(&vid_mutex); + +- pthread_mutexattr_destroy(&dev->attr); +- pthread_mutex_destroy(&dev->mutex); +- free(dev); +- } else { +- motion_log(LOG_INFO, 0, "%s: Still %d users of video device %s, so we don't close it now", +- __FUNCTION__, dev->usage_count, dev->video_device); +- /* There is still at least one thread using this device +- * If we own it, release it +- */ +- if (dev->owner == cnt->threadnr) { ++ /* Remove from list */ ++ if (prev == NULL) ++ viddevs = dev->next; ++ else ++ prev->next = dev->next; ++ ++ pthread_mutex_unlock(&vid_mutex); ++ ++ pthread_mutexattr_destroy(&dev->attr); ++ pthread_mutex_destroy(&dev->mutex); ++ free(dev); ++ } else { ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Still %d users of video device %s, " ++ "so we don't close it now", dev->usage_count, ++ dev->video_device); ++ /* ++ * There is still at least one thread using this device ++ * If we own it, release it. ++ */ ++ if (dev->owner == cnt->threadnr) { + dev->frames = 0; + dev->owner = -1; + pthread_mutex_unlock(&dev->mutex); +- } + } +-#endif /* WITHOUT_V4L */ ++ } ++#endif /* !WITHOUT_V4L */ + } + + +- ++/** ++ * vid_start ++ * ++ */ + int vid_start(struct context *cnt) + { + struct config *conf = &cnt->conf; +@@ -1054,36 +1060,39 @@ int vid_start(struct context *cnt) + netcam_cleanup(cnt->netcam, 1); + cnt->netcam = NULL; + } +- } ++ } + #ifdef WITHOUT_V4L +- else +- motion_log(LOG_ERR, 0, "%s: You must setup netcam_url", __FUNCTION__); ++ else ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: You must setup netcam_url"); + #else + else { + struct video_dev *dev; + int fd_tuner = -1; + int width, height, capture_method; +- unsigned short input, norm; ++ unsigned input, norm; + unsigned long frequency; + + +- motion_log(-1, 0, "%s: [%s]", __FUNCTION__, conf->video_device); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: [%s]", ++ conf->video_device); + +- /* We use width and height from conf in this function. They will be assigned +- * to width and height in imgs here, and cap_width and cap_height in ++ /* ++ * We use width and height from conf in this function. They will be assigned ++ * to width and height in imgs here, and cap_width and cap_height in + * rotate_data won't be set until in rotate_init. +- * Motion requires that width and height are multiples of 16 so we check for this ++ * Motion requires that width and height are multiples of 8 so we check for this. + */ +- if (conf->width % 16) { +- motion_log(LOG_ERR, 0, +- "%s: config image width (%d) is not modulo 16", +- __FUNCTION__, conf->width); ++ if (conf->width % 8) { ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, ++ "%s: config image width (%d) is not modulo 8", ++ conf->width); + return -1; + } +- if (conf->height % 16) { +- motion_log(LOG_ERR, 0, +- "%s: config image height (%d) is not modulo 16", +- __FUNCTION__, conf->height); ++ ++ if (conf->height % 8) { ++ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, ++ "%s: config image height (%d) is not modulo 8", ++ conf->height); + return -1; + } + +@@ -1093,39 +1102,41 @@ int vid_start(struct context *cnt) + norm = conf->norm; + frequency = conf->frequency; + capture_method = METEOR_CAP_CONTINOUS; +- ++ + pthread_mutex_lock(&vid_mutex); + +- /* Transfer width and height from conf to imgs. The imgs values are the ones ++ /* ++ * Transfer width and height from conf to imgs. The imgs values are the ones + * that is used internally in Motion. That way, setting width and height via + * http remote control won't screw things up. + */ + cnt->imgs.width = width; + cnt->imgs.height = height; + +- /* First we walk through the already discovered video devices to see ++ /* ++ * First we walk through the already discovered video devices to see + * if we have already setup the same device before. If this is the case + * the device is a Round Robin device and we set the basic settings +- * and return the file descriptor ++ * and return the file descriptor. + */ + dev = viddevs; +- while (dev) { ++ while (dev) { + if (!strcmp(conf->video_device, dev->video_device)) { + int dummy = METEOR_CAP_STOP_CONT; + dev->usage_count++; + cnt->imgs.type = dev->v4l_fmt; + + if (ioctl(dev->fd_bktr, METEORCAPTUR, &dummy) < 0) { +- motion_log(LOG_ERR, 1, "%s Stopping capture", __FUNCTION__); +- return -1; +- } +- +- motion_log(-1, 0, "%s Reusing [%s] inputs [%d,%d] Change capture method " +- "METEOR_CAP_SINGLE", __FUNCTION__, dev->video_device, ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s Stopping capture"); ++ return -1; ++ } ++ ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s Reusing [%s] inputs [%d,%d] Change " ++ "capture method METEOR_CAP_SINGLE", dev->video_device, + dev->input, conf->input); + + dev->capture_method = METEOR_CAP_SINGLE; +- ++ + switch (cnt->imgs.type) { + case VIDEO_PALETTE_GREY: + cnt->imgs.motionsize = width * height; +@@ -1135,13 +1146,13 @@ int vid_start(struct context *cnt) + case VIDEO_PALETTE_YUV422: + cnt->imgs.type = VIDEO_PALETTE_YUV420P; + case VIDEO_PALETTE_YUV420P: +- motion_log(-1, 0, +- "%s VIDEO_PALETTE_YUV420P setting imgs.size " +- "and imgs.motionsize", __FUNCTION__); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s VIDEO_PALETTE_YUV420P setting" ++ " imgs.size and imgs.motionsize"); + cnt->imgs.motionsize = width * height; + cnt->imgs.size = (width * height * 3) / 2; + break; + } ++ + pthread_mutex_unlock(&vid_mutex); + return dev->fd_bktr; // FIXME return fd_tuner ?! + } +@@ -1154,20 +1165,21 @@ int vid_start(struct context *cnt) + + fd_bktr = open(conf->video_device, O_RDWR); + +- if (fd_bktr < 0) { +- motion_log(LOG_ERR, 1, "%s: open video device %s", __FUNCTION__, conf->video_device); ++ if (fd_bktr < 0) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: open video device %s", ++ conf->video_device); + free(dev); + pthread_mutex_unlock(&vid_mutex); + return -1; + } + + +- /* Only open tuner if conf->tuner_device has set , freq and input is 1 */ ++ /* Only open tuner if conf->tuner_device has set , freq and input is 1. */ + if ((conf->tuner_device != NULL) && (frequency > 0) && (input == IN_TV)) { + fd_tuner = open(conf->tuner_device, O_RDWR); +- if (fd_tuner < 0) { +- motion_log(LOG_ERR, 1, "%s: open tuner device %s", +- __FUNCTION__, conf->tuner_device); ++ if (fd_tuner < 0) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: open tuner device %s", ++ conf->tuner_device); + free(dev); + pthread_mutex_unlock(&vid_mutex); + return -1; +@@ -1188,23 +1200,24 @@ int vid_start(struct context *cnt) + dev->freq = frequency; + dev->owner = -1; + dev->capture_method = capture_method; +- +- /* We set brightness, contrast, saturation and hue = 0 so that they only get ++ ++ /* ++ * We set brightness, contrast, saturation and hue = 0 so that they only get + * set if the config is not zero. + */ +- ++ + dev->brightness = 0; + dev->contrast = 0; + dev->saturation = 0; + dev->hue = 0; + dev->owner = -1; + +- /* default palette */ ++ /* Default palette */ + dev->v4l_fmt = VIDEO_PALETTE_YUV420P; + dev->v4l_curbuffer = 0; + dev->v4l_maxbuffer = 1; + +- if (!v4l_start(dev, width, height, input, norm, frequency)) { ++ if (!v4l_start(dev, width, height, input, norm, frequency)) { + close(dev->fd_bktr); + pthread_mutexattr_destroy(&dev->attr); + pthread_mutex_destroy(&dev->mutex); +@@ -1213,10 +1226,10 @@ int vid_start(struct context *cnt) + pthread_mutex_unlock(&vid_mutex); + return -1; + } +- ++ + cnt->imgs.type = dev->v4l_fmt; +- +- switch (cnt->imgs.type) { ++ ++ switch (cnt->imgs.type) { + case VIDEO_PALETTE_GREY: + cnt->imgs.size = width * height; + cnt->imgs.motionsize = width * height; +@@ -1225,19 +1238,19 @@ int vid_start(struct context *cnt) + case VIDEO_PALETTE_YUV422: + cnt->imgs.type = VIDEO_PALETTE_YUV420P; + case VIDEO_PALETTE_YUV420P: +- motion_log(-1, 0, "%s: VIDEO_PALETTE_YUV420P imgs.type", __FUNCTION__); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: VIDEO_PALETTE_YUV420P imgs.type"); + cnt->imgs.size = (width * height * 3) / 2; + cnt->imgs.motionsize = width * height; +- break; ++ break; + } + + /* Insert into linked list */ + dev->next = viddevs; + viddevs = dev; +- ++ + pthread_mutex_unlock(&vid_mutex); + } +-#endif /* WITHOUT_V4L */ ++#endif /* !WITHOUT_V4L */ + + /* FIXME needed tuner device ?! */ + return fd_bktr; +@@ -1272,29 +1285,29 @@ int vid_next(struct context *cnt, unsign + + #ifndef WITHOUT_V4L + +- struct video_dev *dev; ++ struct video_dev *dev; + int width, height; + int dev_bktr = cnt->video_dev; + + /* NOTE: Since this is a capture, we need to use capture dimensions. */ + width = cnt->rotate_data.cap_width; + height = cnt->rotate_data.cap_height; +- ++ + pthread_mutex_lock(&vid_mutex); +- dev = viddevs; ++ dev = viddevs; ++ + while (dev) { + if (dev->fd_bktr == dev_bktr) + break; + dev = dev->next; + } +- ++ + pthread_mutex_unlock(&vid_mutex); + + if (dev == NULL) + return V4L_FATAL_ERROR; +- //return -1; + +- if (dev->owner != cnt->threadnr) { ++ if (dev->owner != cnt->threadnr) { + pthread_mutex_lock(&dev->mutex); + dev->owner = cnt->threadnr; + dev->frames = conf->roundrobin_frames; +@@ -1303,19 +1316,20 @@ int vid_next(struct context *cnt, unsign + + v4l_set_input(cnt, dev, map, width, height, conf->input, conf->norm, + conf->roundrobin_skip, conf->frequency); +- ++ + ret = v4l_next(dev, map, width, height); + +- if (--dev->frames <= 0) { ++ if (--dev->frames <= 0) { + dev->owner = -1; + dev->frames = 0; + pthread_mutex_unlock(&dev->mutex); + } +- +- /* rotate the image as specified */ +- if (cnt->rotate_data.degrees > 0) ++ ++ /* Rotate the image as specified */ ++ if (cnt->rotate_data.degrees > 0) + rotate_map(cnt, map); +- +-#endif /*WITHOUT_V4L*/ ++ ++ ++#endif /* !WITHOUT_V4L */ + return ret; + } +--- motion-3.2.12.orig/video_freebsd.h ++++ motion-3.2.12/video_freebsd.h +@@ -1,9 +1,10 @@ +-/* video_freebsd.h ++/* ++ * video_freebsd.h + * + * Include file for video_freebsd.c +- * Copyright 2004 by Angel Carpintero (ack@telefonica.net) +- * This software is distributed under the GNU public license version 2 +- * See also the file 'COPYING'. ++ * Copyright 2004 by Angel Carpintero (motiondevelop@gmail.com) ++ * This software is distributed under the GNU public license version 2 ++ * See also the file 'COPYING'. + * + */ + +@@ -24,13 +25,13 @@ + #include + #endif + +-#endif ++#endif /* !WITHOUT_V4L */ + + /* bktr (video4linux) stuff FIXME more modes not only these */ + + /* not used yet FIXME ! only needed for tuner use */ + /* +-#define TV_INPUT_NTSCM BT848_IFORM_F_NTSCM ++#define TV_INPUT_NTSCM BT848_IFORM_F_NTSCM + #define TV_INPUT_NTSCJ BT848_IFORM_F_NTSCJ + #define TV_INPUT_PALBDGHI BT848_IFORM_F_PALBDGHI + #define TV_INPUT_PALM BT848_IFORM_F_PALM +@@ -40,26 +41,26 @@ + */ + + /* video4linux error codes */ +-#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ +-#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ ++#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ ++#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ + #define V4L_FATAL_ERROR -1 + +-#define NORM_DEFAULT 0x00800 /* METEOR_FMT_AUTOMODE */ +-#define NORM_PAL 0x00200 /* METEOR_FMT_PAL */ +-#define NORM_NTSC 0x00100 /* METEOR_FMT_NTSC */ +-#define NORM_SECAM 0x00400 /* METEOR_FMT_SECAM */ +-#define NORM_PAL_NC 0x00200 /* METEOR_FMT_PAL */ ++#define NORM_DEFAULT 0x00800 // METEOR_FMT_AUTOMODE ++#define NORM_PAL 0x00200 // METEOR_FMT_PAL ++#define NORM_NTSC 0x00100 // METEOR_FMT_NTSC ++#define NORM_SECAM 0x00400 // METEOR_FMT_SECAM ++#define NORM_PAL_NC 0x00200 // METEOR_FMT_PAL /* Greyscale howto ?! FIXME */ + +-#define NORM_DEFAULT_NEW BT848_IFORM_F_AUTO +-#define NORM_PAL_NEW BT848_IFORM_F_PALBDGHI ++#define NORM_DEFAULT_NEW BT848_IFORM_F_AUTO ++#define NORM_PAL_NEW BT848_IFORM_F_PALBDGHI + #define NORM_NTSC_NEW BT848_IFORM_F_NTSCM +-#define NORM_SECAM_NEW BT848_IFORM_F_SECAM +-#define NORM_PAL_NC_NEW BT848_IFORM_F_AUTO /* FIXME */ ++#define NORM_SECAM_NEW BT848_IFORM_F_SECAM ++#define NORM_PAL_NC_NEW BT848_IFORM_F_AUTO /* FIXME */ + + #define PAL 0 + #define NTSC 1 + #define SECAM 2 +-#define PAL_NC 3 ++#define PAL_NC 3 + + #define PAL_HEIGHT 576 + #define SECAM_HEIGHT 576 +@@ -76,7 +77,7 @@ + #define BSD_VIDFMT_LAST 8 + + +-#define IN_DEFAULT 0 ++#define IN_DEFAULT 0 + #define IN_COMPOSITE 0 + #define IN_TV 1 + #define IN_COMPOSITE2 2 +@@ -95,8 +96,8 @@ struct video_dev { + int fd_tuner; + const char *video_device; + const char *tuner_device; +- unsigned short input; +- unsigned short norm; ++ unsigned input; ++ unsigned norm; + int width; + int height; + int contrast; +@@ -111,10 +112,10 @@ struct video_dev { + pthread_mutexattr_t attr; + int owner; + int frames; +- ++ + /* Device type specific stuff: */ +-#ifndef WITHOUT_V4L +- int capture_method; ++#ifndef WITHOUT_V4L ++ int capture_method; + int v4l_fmt; + unsigned char *v4l_buffers[2]; + int v4l_curbuffer; +--- /dev/null ++++ motion-3.2.12/vloopback_motion.c +@@ -0,0 +1,256 @@ ++/* ++ * vloopback_motion.c ++ * ++ * Video loopback functions for motion. ++ * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) ++ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) ++ * This software is distributed under the GNU public license version 2 ++ * See also the file 'COPYING'. ++ * ++ */ ++#include "vloopback_motion.h" ++#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) && (!defined(BSD)) ++#include ++#include ++ ++/** ++ * v4l_open_vidpipe ++ * ++ */ ++static int v4l_open_vidpipe(void) ++{ ++ int pipe_fd = -1; ++ char pipepath[255]; ++ char buffer[255]; ++ char *major; ++ char *minor; ++ struct utsname uts; ++ ++ if (uname(&uts) < 0) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to execute uname"); ++ return -1; ++ } ++ ++ major = strtok(uts.release, "."); ++ minor = strtok(NULL, "."); ++ ++ if ((major == NULL) || (minor == NULL) || (strcmp(major, "2"))) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to decipher OS version"); ++ return -1; ++ } ++ ++ if (strcmp(minor, "5") < 0) { ++ FILE *vloopbacks; ++ char *loop; ++ char *input; ++ char *istatus; ++ char *output; ++ char *ostatus; ++ ++ vloopbacks = fopen("/proc/video/vloopback/vloopbacks", "r"); ++ ++ if (!vloopbacks) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed to open " ++ "'/proc/video/vloopback/vloopbacks'"); ++ return -1; ++ } ++ ++ /* Read vloopback version*/ ++ if (!fgets(buffer, sizeof(buffer), vloopbacks)) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to read vloopback version"); ++ myfclose(vloopbacks); ++ return -1; ++ } ++ ++ fprintf(stderr, "\t%s", buffer); ++ ++ /* Read explanation line */ ++ ++ if (!fgets(buffer, sizeof(buffer), vloopbacks)) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to read vloopback" ++ " explanation line"); ++ myfclose(vloopbacks); ++ return -1; ++ } ++ ++ while (fgets(buffer, sizeof(buffer), vloopbacks)) { ++ if (strlen(buffer) > 1) { ++ buffer[strlen(buffer)-1] = 0; ++ loop = strtok(buffer, "\t"); ++ input = strtok(NULL, "\t"); ++ istatus = strtok(NULL, "\t"); ++ output = strtok(NULL, "\t"); ++ ostatus = strtok(NULL, "\t"); ++ ++ if (istatus[0] == '-') { ++ snprintf(pipepath, sizeof(pipepath), "/dev/%s", input); ++ pipe_fd = open(pipepath, O_RDWR); ++ ++ if (pipe_fd >= 0) { ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \tInput: /dev/%s " ++ "\tOutput: /dev/%s", input, output); ++ break; ++ } ++ } ++ } ++ } ++ ++ myfclose(vloopbacks); ++ } else { ++ DIR *dir; ++ struct dirent *dirp; ++ const char prefix[] = "/sys/class/video4linux/"; ++ char *ptr, *io; ++ int fd; ++ int low = 9999; ++ int tfd; ++ int tnum; ++ ++ if ((dir = opendir(prefix)) == NULL) { ++ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed to open '%s'", ++ prefix); ++ return -1; ++ } ++ ++ while ((dirp = readdir(dir)) != NULL) { ++ if (!strncmp(dirp->d_name, "video", 5)) { ++ strncpy(buffer, prefix, sizeof(buffer)); ++ strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); ++ strncat(buffer, "/name", sizeof(buffer) - strlen(buffer)); ++ ++ if ((fd = open(buffer, O_RDONLY)) >= 0) { ++ if ((read(fd, buffer, sizeof(buffer)-1)) < 0) { ++ close(fd); ++ continue; ++ } ++ ++ ptr = strtok(buffer, " "); ++ ++ if (strcmp(ptr, "Video")) { ++ close(fd); ++ continue; ++ } ++ ++ major = strtok(NULL, " "); ++ minor = strtok(NULL, " "); ++ io = strtok(NULL, " \n"); ++ ++ if (strcmp(major, "loopback") || strcmp(io, "input")) { ++ close(fd); ++ continue; ++ } ++ ++ if ((ptr = strtok(buffer, " ")) == NULL) { ++ close(fd); ++ continue; ++ } ++ ++ tnum = atoi(minor); ++ ++ if (tnum < low) { ++ mystrcpy(buffer, "/dev/"); ++ strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); ++ if ((tfd = open(buffer, O_RDWR)) >= 0) { ++ strncpy(pipepath, buffer, sizeof(pipepath)); ++ ++ if (pipe_fd >= 0) ++ close(pipe_fd); ++ ++ pipe_fd = tfd; ++ low = tnum; ++ } ++ } ++ close(fd); ++ } ++ } ++ } ++ ++ closedir(dir); ++ ++ if (pipe_fd >= 0) ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Opened %s as input", ++ pipepath); ++ } ++ ++ return pipe_fd; ++} ++ ++/** ++ * v4l_startpipe ++ * ++ */ ++static int v4l_startpipe(const char *dev_name, int width, int height, int type) ++{ ++ int dev; ++ struct video_picture vid_pic; ++ struct video_window vid_win; ++ ++ if (!strcmp(dev_name, "-")) { ++ dev = v4l_open_vidpipe(); ++ } else { ++ dev = open(dev_name, O_RDWR); ++ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Opened %s as input", ++ dev_name); ++ } ++ ++ if (dev < 0) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Opening %s as input failed", ++ dev_name); ++ return -1; ++ } ++ ++ if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); ++ return -1; ++ } ++ ++ vid_pic.palette = type; ++ ++ if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSPICT)"); ++ return -1; ++ } ++ ++ if (ioctl(dev, VIDIOCGWIN, &vid_win) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGWIN)"); ++ return -1; ++ } ++ ++ vid_win.height = height; ++ vid_win.width = width; ++ ++ if (ioctl(dev, VIDIOCSWIN, &vid_win) == -1) { ++ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSWIN)"); ++ return -1; ++ } ++ ++ return dev; ++} ++ ++/** ++ * v4l_putpipe ++ * ++ */ ++static int v4l_putpipe(int dev, unsigned char *image, int size) ++{ ++ return write(dev, image, size); ++} ++ ++/** ++ * vid_startpipe ++ * ++ */ ++int vid_startpipe(const char *dev_name, int width, int height, int type) ++{ ++ return v4l_startpipe(dev_name, width, height, type); ++} ++ ++/** ++ * vid_putpipe ++ * ++ */ ++int vid_putpipe (int dev, unsigned char *image, int size) ++{ ++ return v4l_putpipe(dev, image, size); ++} ++#endif /* !WITHOUT_V4L && !BSD */ +--- /dev/null ++++ motion-3.2.12/vloopback_motion.h +@@ -0,0 +1,17 @@ ++/* vloopback_motion.h ++ * ++ * Include file for vloopback_motion.c ++ * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) ++ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) ++ * This software is distributed under the GNU public license version 2 ++ * See also the file 'COPYING'. ++ * ++ */ ++#ifndef _INCLUDE_VLOOPBACK_MOTION_H ++#define _INCLUDE_VLOOPBACK_MOTION_H ++ ++#include "motion.h" ++ ++int vid_startpipe(const char *dev_name, int width, int height, int); ++int vid_putpipe(int dev, unsigned char *image, int); ++#endif +--- motion-3.2.12.orig/webhttpd.c ++++ motion-3.2.12/webhttpd.c +@@ -3,9 +3,9 @@ + * + * HTTP Control interface for motion. + * +- * Specs : http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpAPI ++ * Specs : http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpAPI + * +- * Copyright 2004-2005 by Angel Carpintero (ack@telefonica.net) ++ * Copyright 2004-2005 by Angel Carpintero (motiondevelop@gmail.com) + * This software is distributed under the GNU Public License Version 2 + * See also the file 'COPYING'. + * +@@ -18,25 +18,26 @@ + + pthread_mutex_t httpd_mutex; + +-int warningkill; // This is a dummy variable use to kill warnings when not checking sscanf and similar functions ++// This is a dummy variable use to kill warnings when not checking sscanf and similar functions ++int warningkill; + +-static const char* ini_template = ++static const char *ini_template = + "Motion "VERSION"\n" + "\n"; + + static const char *set_template = + "\nMotion "VERSION"\n" + "\n"; + +-static const char* end_template = ++static const char *end_template = + "\n" + "\n"; + +-static const char* ok_response = ++static const char *ok_response = + "HTTP/1.1 200 OK\r\n" + "Server: Motion-httpd/"VERSION"\r\n" + "Connection: close\r\n" +@@ -47,7 +48,7 @@ static const char* ok_response = + "Pragma: no-cache\r\n" + "Content-type: text/html\r\n\r\n"; + +-static const char* ok_response_raw = ++static const char *ok_response_raw = + "HTTP/1.1 200 OK\r\n" + "Server: Motion-httpd/"VERSION"\r\n" + "Connection: close\r\n" +@@ -58,8 +59,7 @@ static const char* ok_response_raw = + "Pragma: no-cache\r\n" + "Content-type: text/plain\r\n\r\n"; + +- +-static const char* bad_request_response = ++static const char *bad_request_response = + "HTTP/1.0 400 Bad Request\r\n" + "Content-type: text/html\r\n\r\n" + "\n" +@@ -69,12 +69,12 @@ static const char* bad_request_response + "\n" + "\n"; + +-static const char* bad_request_response_raw = ++static const char *bad_request_response_raw = + "HTTP/1.0 400 Bad Request\r\n" + "Content-type: text/plain\r\n\r\n" + "Bad Request"; + +-static const char* not_found_response_template = ++static const char *not_found_response_template = + "HTTP/1.0 404 Not Found\r\n" + "Content-type: text/html\r\n\r\n" + "\n" +@@ -84,12 +84,12 @@ static const char* not_found_response_te + "\n" + "\n"; + +-static const char* not_found_response_template_raw = ++static const char *not_found_response_template_raw = + "HTTP/1.0 404 Not Found\r\n" + "Content-type: text/plain\r\n\r\n" + "Not Found"; + +-static const char* not_found_response_valid = ++static const char *not_found_response_valid = + "HTTP/1.0 404 Not Valid\r\n" + "Content-type: text/html\r\n\r\n" + "\n" +@@ -99,12 +99,12 @@ static const char* not_found_response_va + "\n" + "\n"; + +-static const char* not_found_response_valid_raw = ++static const char *not_found_response_valid_raw = + "HTTP/1.0 404 Not Valid\r\n" + "Content-type: text/plain\r\n\r\n" + "The requested URL is not valid."; + +-static const char* not_valid_syntax = ++static const char *not_valid_syntax = + "HTTP/1.0 404 Not Valid Syntax\r\n" + "Content-type: text/html\r\n\r\n" + "\n" +@@ -113,48 +113,48 @@ static const char* not_valid_syntax = + "\n" + "\n"; + +-static const char* not_valid_syntax_raw = ++static const char *not_valid_syntax_raw = + "HTTP/1.0 404 Not Valid Syntax\r\n" + "Content-type: text/plain\r\n\r\n" + "Not Valid Syntax\n"; + +-static const char* not_track = ++static const char *not_track = + "HTTP/1.0 200 OK\r\n" + "Content-type: text/html\r\n\r\n" + "\n" + "\n" + "

                                                              Tracking Not Enabled

                                                              \n"; + +-static const char* not_track_raw = ++static const char *not_track_raw = + "HTTP/1.0 200 OK\r\n" + "Content-type: text/plain\r\n\r\n" + "Tracking Not Enabled"; + +-static const char* track_error = ++static const char *track_error = + "HTTP/1.0 200 OK\r\n" + "Content-type: text/html\r\n\r\n" + "\n" + "\n" + "

                                                              Track Error

                                                              \n"; + +-static const char* track_error_raw = ++static const char *track_error_raw = + "HTTP/1.0 200 OK\r\n" + "Content-type: text/plain\r\n\r\n" + "Track Error"; + +-static const char* error_value = ++static const char *error_value = + "HTTP/1.0 200 OK\r\n" + "Content-type: text/html\r\n\r\n" + "\n" + "\n" + "

                                                              Value Error

                                                              \n"; + +-static const char* error_value_raw = ++static const char *error_value_raw = + "HTTP/1.0 200 OK\r\n" + "Content-type: text/plain\r\n\r\n" + "Value Error"; +- +-static const char* not_found_response_valid_command = ++ ++static const char *not_found_response_valid_command = + "HTTP/1.0 404 Not Valid Command\r\n" + "Content-type: text/html\r\n\r\n" + "\n" +@@ -164,12 +164,12 @@ static const char* not_found_response_va + "\n" + "\n"; + +-static const char* not_found_response_valid_command_raw = ++static const char *not_found_response_valid_command_raw = + "HTTP/1.0 404 Not Valid Command\r\n" + "Content-type: text/plain\n\n" + "Not Valid Command\n"; + +-static const char* bad_method_response_template = ++static const char *bad_method_response_template = + "HTTP/1.0 501 Method Not Implemented\r\n" + "Content-type: text/html\r\n\r\n" + "\n" +@@ -179,7 +179,7 @@ static const char* bad_method_response_t + "\n" + "\n"; + +-static const char* bad_method_response_template_raw = ++static const char *bad_method_response_template_raw = + "HTTP/1.0 501 Method Not Implemented\r\n" + "Content-type: text/plain\r\n\r\n" + "Method Not Implemented\n"; +@@ -188,54 +188,134 @@ static const char *request_auth_response + "HTTP/1.0 401 Authorization Required\r\n" + "WWW-Authenticate: Basic realm=\"Motion Security Access\"\r\n"; + +-static void send_template_ini_client(int client_socket, const char* template) ++/** ++ * write_nonblock ++ */ ++static ssize_t write_nonblock(int fd, const void *buf, size_t size) ++{ ++ ssize_t nwrite = -1; ++ struct timeval tm; ++ fd_set fds; ++ ++ tm.tv_sec = 1; /* Timeout in seconds */ ++ tm.tv_usec = 0; ++ FD_ZERO(&fds); ++ FD_SET(fd, &fds); ++ ++ if (select(fd + 1, NULL, &fds, NULL, &tm) > 0) { ++ if (FD_ISSET(fd, &fds)) { ++ if ((nwrite = write(fd , buf, size)) < 0) { ++ if (errno != EWOULDBLOCK) ++ return -1; ++ } ++ } ++ } ++ ++ return nwrite; ++} ++ ++/** ++ * read_nonblock ++ */ ++static ssize_t read_nonblock(int fd ,void *buf, ssize_t size) ++{ ++ ssize_t nread = -1; ++ struct timeval tm; ++ fd_set fds; ++ ++ tm.tv_sec = 1; /* Timeout in seconds */ ++ tm.tv_usec = 0; ++ FD_ZERO(&fds); ++ FD_SET(fd, &fds); ++ ++ if (select(fd + 1, &fds, NULL, NULL, &tm) > 0) { ++ if (FD_ISSET(fd, &fds)) { ++ if ((nread = read(fd , buf, size)) < 0) { ++ if (errno != EWOULDBLOCK) ++ return -1; ++ } ++ } ++ } ++ ++ return nread; ++} ++ ++/** ++ * send_template_ini_client ++ */ ++static void send_template_ini_client(int client_socket, const char *template) + { + ssize_t nwrite = 0; +- nwrite = write(client_socket, ok_response, strlen (ok_response)); +- nwrite += write(client_socket, template, strlen(template)); ++ nwrite = write_nonblock(client_socket, ok_response, strlen(ok_response)); ++ nwrite += write_nonblock(client_socket, template, strlen(template)); + if (nwrite != (ssize_t)(strlen(ok_response) + strlen(template))) +- motion_log(LOG_ERR, 1, "httpd send_template_ini_client"); ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: failure write"); + } + ++/** ++ * send_template_ini_client_raw ++ */ + static void send_template_ini_client_raw(int client_socket) + { + ssize_t nwrite = 0; +- nwrite = write(client_socket, ok_response_raw, strlen (ok_response_raw)); ++ nwrite = write_nonblock(client_socket, ok_response_raw, strlen(ok_response_raw)); + if (nwrite != (ssize_t)strlen(ok_response_raw)) +- motion_log(LOG_ERR, 1, "httpd send_template_ini_client_raw"); ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: failure write"); + } + ++/** ++ * send_template ++ */ + static void send_template(int client_socket, char *res) + { + ssize_t nwrite = 0; +- nwrite = write(client_socket, res, strlen(res)); ++ nwrite = write_nonblock(client_socket, res, strlen(res)); + if (nwrite != (ssize_t)strlen(res)) +- motion_log(LOG_ERR, 1, "httpd send_template failure write"); ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: failure write"); + } + ++/** ++ * send_template_raw ++ */ + static void send_template_raw(int client_socket, char *res) + { + ssize_t nwrite = 0; +- nwrite = write(client_socket, res, strlen(res)); ++ nwrite = write_nonblock(client_socket, res, strlen(res)); ++ if (nwrite < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); + } + ++/** ++ * send_template_end_client ++ */ + static void send_template_end_client(int client_socket) + { + ssize_t nwrite = 0; +- nwrite = write(client_socket, end_template, strlen(end_template)); ++ nwrite = write_nonblock(client_socket, end_template, strlen(end_template)); ++ if (nwrite < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); ++ + } + +-static void response_client(int client_socket, const char* template, char *back) ++/** ++ * response_client ++ */ ++static void response_client(int client_socket, const char *template, char *back) + { + ssize_t nwrite = 0; +- nwrite = write(client_socket, template, strlen(template)); ++ nwrite = write_nonblock(client_socket, template, strlen(template)); + if (back != NULL) { + send_template(client_socket, back); + send_template_end_client(client_socket); + } +-} ++ if (nwrite < 0) ++ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); + ++} + ++/** ++ * replace ++ */ + static char *replace(const char *str, const char *old, const char *new) + { + char *ret, *r; +@@ -248,11 +328,10 @@ static char *replace(const char *str, co + count++; + /* this is undefined if p - str > PTRDIFF_MAX */ + retlen = p - str + strlen(p) + count * (newlen - oldlen); +- } else { ++ } else + retlen = strlen(str); +- } + +- ret = malloc(retlen + 1); ++ ret = mymalloc(retlen + 1); + + for (r = ret, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen) { + /* this is undefined if q - p > PTRDIFF_MAX */ +@@ -265,16 +344,18 @@ static char *replace(const char *str, co + strcpy(r, p); + + return ret; +-} +- +-/* +- This function decode the values from GET request following the http RFC. +-*/ ++} + ++/** ++ * url_decode ++ * This function decode the values from GET request following the http RFC. ++ * ++ * Returns nothing. ++ */ + static void url_decode(char *urlencoded, size_t length) + { +- char *data=urlencoded; +- char *urldecoded=urlencoded; ++ char *data = urlencoded; ++ char *urldecoded = urlencoded; + + while (length > 0) { + if (*data == '%') { +@@ -286,19 +367,23 @@ static void url_decode(char *urlencoded, + length--; + c[1] = *data; + c[2] = 0; ++ + warningkill = sscanf(c, "%x", &i); +- if (i < 128) ++ ++ if (i < 128) { + *urldecoded++ = (char)i; +- else { ++ } else { + *urldecoded++ = '%'; + *urldecoded++ = c[0]; + *urldecoded++ = c[1]; + } +- } else if (*data=='+') { +- *urldecoded++=' '; ++ ++ } else if (*data == '<' || *data == '+' || *data == '>') { ++ *urldecoded++ = ' '; + } else { +- *urldecoded++=*data; ++ *urldecoded++ = *data; + } ++ + data++; + length--; + } +@@ -306,61 +391,62 @@ static void url_decode(char *urlencoded, + } + + +-/* +- This function manages/parses the config action for motion ( set , get , write , list ). +- +- return 1 to exit from function. +-*/ +- +-static unsigned short int config(char *pointer, char *res, unsigned short int length_uri, +- unsigned short int thread, int client_socket, void *userdata) ++/** ++ * config ++ * Manages/parses the config action for motion ( set , get , write , list ). ++ * ++ * Returns 1 to exit from function. ++ */ ++static unsigned int config(char *pointer, char *res, unsigned int length_uri, ++ unsigned int thread, int client_socket, void *userdata) + { +- char question = '\0'; ++ char question='\0'; + char command[256] = {'\0'}; +- unsigned short int i; ++ unsigned int i; + struct context **cnt = userdata; + +- warningkill = sscanf (pointer, "%255[a-z]%c", command , &question); +- if (!strcmp(command,"list")) { ++ warningkill = sscanf(pointer, "%255[a-z]%c", command , &question); ++ if (!strcmp(command, "list")) { + pointer = pointer + 4; + length_uri = length_uri - 4; + if (length_uri == 0) { + const char *value = NULL; + char *retval = NULL; + /*call list*/ +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); +- sprintf(res, "<– back

                                                              \nThread %hu\n
                                                                ", thread, thread); ++ sprintf(res, "<– back

                                                                \nThread %hu\n
                                                                  ", ++ thread, thread); + send_template(client_socket, res); + +- for (i = 0; config_params[i].param_name != NULL; i++) { ++ for (i=0; config_params[i].param_name != NULL; i++) { + +- if ((thread != 0) && (config_params[i].main_thread)) ++ if ((thread != 0) && (config_params[i].main_thread)) + continue; + + value = config_params[i].print(cnt, NULL, i, thread); + + if (value == NULL) { +- retval=NULL; +- +- /* Only get the thread value for main thread */ ++ retval = NULL; ++ ++ /* Only get the thread value for main thread */ + if (thread == 0) + config_params[i].print(cnt, &retval, i, thread); +- ++ + /* thread value*/ +- ++ + if (retval) { +- ++ + if (!strcmp(retval,"")) { + free(retval); +- retval = strdup("No threads"); ++ retval = mystrdup("No threads"); + } else { +- char *temp=retval; ++ char *temp = retval; + size_t retval_miss = 0; + size_t retval_len = strlen(retval); +- unsigned short int ind=0; +- char thread_strings[1024]={'\0'}; +- ++ unsigned int ind = 0; ++ char thread_strings[1024] = {'\0'}; ++ + while (retval_miss != retval_len) { + while (*temp != '\n') { + thread_strings[ind++] = *temp; +@@ -376,16 +462,16 @@ static unsigned short int config(char *p + } + free(retval); + retval = NULL; +- retval = strdup(thread_strings); ++ retval = mystrdup(thread_strings); + } +- ++ + sprintf(res, "
                                                                • %s = %s
                                                                • \n", thread, + config_params[i].param_name, config_params[i].param_name, retval); + free(retval); + } else if (thread != 0) { + /* get the value from main thread for the rest of threads */ + value = config_params[i].print(cnt, NULL, i, 0); +- ++ + sprintf(res, "
                                                                • %s = %s
                                                                • \n", thread, + config_params[i].param_name, config_params[i].param_name, + value ? value : "(not defined)"); +@@ -394,35 +480,35 @@ static unsigned short int config(char *p + config_params[i].param_name, config_params[i].param_name, + "(not defined)"); + } +- ++ + } else { +- sprintf(res, "
                                                                • %s = %s
                                                                • \n",thread, ++ sprintf(res, "
                                                                • %s = %s
                                                                • \n", thread, + config_params[i].param_name, config_params[i].param_name, value); + } + send_template(client_socket, res); + } + +- sprintf(res, "
                                                                <– back",thread); ++ sprintf(res, "
                                                              <– back", thread); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); + for (i=0; config_params[i].param_name != NULL; i++) { +- value=config_params[i].print(cnt, NULL, i, thread); ++ value = config_params[i].print(cnt, NULL, i, thread); + if (value == NULL) +- value=config_params[i].print(cnt, NULL, i, 0); ++ value = config_params[i].print(cnt, NULL, i, 0); + sprintf(res, "%s = %s\n", config_params[i].param_name, value); + send_template_raw(client_socket, res); + } + } + } else { + /*error*/ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"set")) { ++ } else if (!strcmp(command, "set")) { + /* set?param_name=value */ + pointer = pointer + 3; + length_uri = length_uri - 3; +@@ -431,13 +517,13 @@ static unsigned short int config(char *p + length_uri--; + warningkill = sscanf(pointer,"%255[-0-9a-z_]%c", command, &question); + /*check command , question == '=' length_uri too*/ +- if ((question == '=') && (command[0]!='\0')) { ++ if ((question == '=') && (command[0] != '\0')) { + length_uri = length_uri - strlen(command) - 1; + pointer = pointer + strlen(command) + 1; + /* check if command exists and type of command and not end of URI */ +- i = 0; ++ i=0; + while (config_params[i].param_name != NULL) { +- if ((thread != 0) && (config_params[i].main_thread)){ ++ if ((thread != 0) && (config_params[i].main_thread)) { + i++; + continue; + } +@@ -449,24 +535,24 @@ static unsigned short int config(char *p + + if (config_params[i].param_name) { + if (length_uri > 0) { +- char Value[1024]={'\0'}; ++ char Value[1024] = {'\0'}; + warningkill = sscanf(pointer,"%1023s", Value); + length_uri = length_uri - strlen(Value); +- if ((length_uri == 0) && (strlen(Value) > 0) ) { ++ if ((length_uri == 0) && (strlen(Value) > 0)) { + /* FIXME need to assure that is a valid value */ +- url_decode(Value,strlen(Value)); ++ url_decode(Value, strlen(Value)); + conf_cmdparse(cnt + thread, config_params[i].param_name, Value); +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, + "<– back" + "

                                                              \nThread %hu\n" + "
                                                              • %s = %s" + "
                                                              Done", +- thread, thread, thread,config_params[i].param_name, ++ thread, thread, thread, config_params[i].param_name, + config_params[i].param_name, Value); +- ++ + send_template_ini_client(client_socket, ini_template); +- send_template(client_socket,res); ++ send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +@@ -475,50 +561,46 @@ static unsigned short int config(char *p + } + } else { + /*error*/ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + } + } else { + char *type = NULL; +- type = strdup(config_type(&config_params[i])); ++ type = mystrdup(config_type(&config_params[i])); + +- if (!strcmp(type,"string")) { ++ if (!strcmp(type, "string")) { + char *value = NULL; + conf_cmdparse(cnt+thread, config_params[i].param_name, value); + free(type); +- type = strdup("(null)"); +- } else if (!strcmp(type,"int")) { +- free(type); +- type = strdup("0"); +- conf_cmdparse(cnt+thread, config_params[i].param_name, type); +- } else if (!strcmp(type,"short")) { ++ type = mystrdup("(null)"); ++ } else if (!strcmp(type, "int")) { + free(type); +- type = strdup("0"); ++ type = mystrdup("0"); + conf_cmdparse(cnt+thread, config_params[i].param_name, type); +- } else if (!strcmp(type,"bool")) { ++ } else if (!strcmp(type, "bool")) { + free(type); +- type = strdup("off"); ++ type = mystrdup("off"); + conf_cmdparse(cnt+thread, config_params[i].param_name, type); + } else { + free(type); +- type = strdup("unknown"); ++ type = mystrdup("unknown"); + } + +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, + "<– back

                                                              \n" +- "Thread %hu\n
                                                              • %s" +- "= %s

                                                              Done", thread, thread, thread, ++ "Thread %hu\n
                                                              • %s" ++ "= %s

                                                              Done", thread, thread, thread, + config_params[i].param_name, config_params[i].param_name, type); +- ++ + send_template_ini_client(client_socket, ini_template); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +- sprintf(res, "%s = %s\nDone\n", config_params[i].param_name,type); ++ sprintf(res, "%s = %s\nDone\n", config_params[i].param_name, type); + send_template_raw(client_socket, res); + } + free(type); +@@ -526,18 +608,18 @@ static unsigned short int config(char *p + } + } else { + /*error*/ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } else { + /* Show param_name dialogue only for html output */ +- if ((cnt[0]->conf.control_html_output) && (command[0]!='\0') && +- (((length_uri = length_uri - strlen(command)) == 0 )) ) { +- i = 0; ++ if ((cnt[0]->conf.webcontrol_html_output) && (command[0] != '\0') && ++ (((length_uri = length_uri - strlen(command)) == 0))) { ++ i=0; + while (config_params[i].param_name != NULL) { +- if ((thread != 0) && (config_params[i].main_thread)){ ++ if ((thread != 0) && (config_params[i].main_thread)) { + i++; + continue; + } +@@ -548,10 +630,10 @@ static unsigned short int config(char *p + } + /* param_name exists */ + if (config_params[i].param_name) { +- const char *value = NULL; ++ const char *value = NULL; + char *text_help = NULL; + char *sharp = NULL; +- ++ + value = config_params[i].print(cnt, NULL, i, thread); + + sharp = strstr(config_params[i].param_help, "#\n\n#"); +@@ -560,21 +642,21 @@ static unsigned short int config(char *p + sharp++; + + text_help = replace(sharp, "\n#", "
                                                              "); +- ++ + send_template_ini_client(client_socket, ini_template); +- if (!strcmp ("bool",config_type(&config_params[i])) ){ ++ if (!strcmp ("bool", config_type(&config_params[i]))) { + char option[80] = {'\0'}; +- ++ + if ((value == NULL) && (thread != 0)) + value = config_params[i].print(cnt, NULL, i, 0); +- ++ + if (!strcmp ("on", value)) + sprintf(option, "\n" + "\n"); + else + sprintf(option, "\n" + "\n"); +- ++ + sprintf(res, "<– back

                                                              \n" + "Thread %hu\n" + "
                                                              \n" +@@ -585,50 +667,50 @@ static unsigned short int config(char *p + "[help]" + "
                                                              \n
                                                              %s", thread, thread, + config_params[i].param_name, config_params[i].param_name, +- option, FOSWIKI_URL,config_params[i].param_name, text_help); ++ option, TWIKI_URL, config_params[i].param_name, text_help); + } else { +- +- if (value == NULL){ ++ ++ if (value == NULL) { + if (thread != 0) + /* get the value from main thread for the rest of threads */ +- value = config_params[i].print(cnt, NULL, i, 0); ++ value = config_params[i].print(cnt, NULL, i, 0); + if (value == NULL) value = ""; + } + sprintf(res, "<– back

                                                              \n" + "Thread %hu\n
                                                              \n" +- "%s \n" ++ "%s \n" + "\n" + "    " + "[help]" + "
                                                              \n
                                                              %s", thread, thread, + config_params[i].param_name, config_params[i].param_name, +- value, FOSWIKI_URL, config_params[i].param_name, text_help); ++ value, TWIKI_URL, config_params[i].param_name, text_help); + } + + send_template(client_socket, res); + send_template_end_client(client_socket); + free(text_help); + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } + } else if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, set_template); + sprintf(res, "<– back

                                                              \nThread %hu\n" +- "
                                                              \n\n", thread, thread); + + send_template(client_socket, res); +- for (i = 0; config_params[i].param_name != NULL; i++) { ++ for (i=0; config_params[i].param_name != NULL; i++) { + if ((thread != 0) && (config_params[i].main_thread)) + continue; + sprintf(res, "\n", +@@ -650,12 +732,12 @@ static unsigned short int config(char *p + } + } else { + /*error*/ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"get")) { ++ } else if (!strcmp(command, "get")) { + /* get?query=param_name */ + pointer = pointer + 3; + length_uri = length_uri - 3; +@@ -666,18 +748,18 @@ static unsigned short int config(char *p + length_uri--; + warningkill = sscanf(pointer,"%255[-0-9a-z]%c", command, &question); + +- if ((question == '=') && (!strcmp(command,"query")) ) { ++ if ((question == '=') && (!strcmp(command, "query"))) { + pointer = pointer + 6; + length_uri = length_uri - 6; + warningkill = sscanf(pointer, "%255[-0-9a-z_]", command); + /*check if command exist, length_uri too*/ +- length_uri = length_uri-strlen(command); ++ length_uri = length_uri - strlen(command); + + if (length_uri == 0) { + const char *value = NULL; + i = 0; + while (config_params[i].param_name != NULL) { +- if ((thread != 0) && (config_params[i].main_thread)){ ++ if ((thread != 0) && (config_params[i].main_thread)) { + i++; + continue; + } +@@ -686,15 +768,16 @@ static unsigned short int config(char *p + break; + i++; + } +- /* FIXME bool values or commented values maybe that should be +- solved with config_type */ +- ++ /* ++ * FIXME bool values or commented values maybe that should be ++ * solved with config_type ++ */ + if (config_params[i].param_name) { +- const char *type=NULL; ++ const char *type = NULL; + type = config_type(&config_params[i]); +- if (!strcmp(type,"unknown")) { +- /*error doesn't exists this param_name */ +- if (cnt[0]->conf.control_html_output) ++ if (!strcmp(type, "unknown")) { ++ /* error doesn't exists this param_name */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -713,16 +796,15 @@ static unsigned short int config(char *p + text_help = replace(sharp, "\n#", "
                                                              "); + + if (value == NULL) +- value=config_params[i].print(cnt, NULL, i, 0); +- +- if (cnt[0]->conf.control_html_output) { +- send_template_ini_client(client_socket,ini_template); ++ value = config_params[i].print(cnt, NULL, i, 0); ++ if (cnt[0]->conf.webcontrol_html_output) { ++ send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                              \n" + "Thread %hu
                                                              \n
                                                              %s", +- thread, thread, config_params[i].param_name, value, +- FOSWIKI_URL, config_params[i].param_name, text_help); ++ "[help]

                                                            %s", ++ thread, thread, config_params[i].param_name, value, ++ TWIKI_URL, config_params[i].param_name, text_help); + + send_template(client_socket, res); + send_template_end_client(client_socket); +@@ -730,41 +812,39 @@ static unsigned short int config(char *p + free(text_help); + } else { + send_template_ini_client_raw(client_socket); +- sprintf(res, "%s = %s\nDone\n", config_params[i].param_name,value); ++ sprintf(res, "%s = %s\nDone\n", config_params[i].param_name, value); + send_template_raw(client_socket, res); + } + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } + } else if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); +- sprintf(res, "<– back

                                                            \nThread %hu
                                                            \n" ++ sprintf(res, "<– back

                                                            \nThread %hu
                                                            \n" + "\n" + "\n" + "\n" + "\n"); +@@ -776,17 +856,17 @@ static unsigned short int config(char *p + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + } +- } else if (!strcmp(command,"write")) { ++ } else if (!strcmp(command, "write")) { + pointer = pointer + 5; + length_uri = length_uri - 5; + if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Are you sure? Yes\n", thread, thread); +@@ -799,8 +879,8 @@ static unsigned short int config(char *p + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -811,7 +891,7 @@ static unsigned short int config(char *p + length_uri = length_uri - 8; + if (length_uri == 0) { + conf_print(cnt); +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \nThread %hu write done !\n", + thread, thread); +@@ -823,16 +903,16 @@ static unsigned short int config(char *p + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) { + response_client(client_socket, not_found_response_valid_command, NULL); +- } else { ++ } ++ else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +- } + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -842,27 +922,28 @@ static unsigned short int config(char *p + } + + +-/* +- This function manages/parses the actions for motion ( makemovie , snapshot , restart , quit ). +- +- return 0 for restart & quit +- return 1 for makemovie & snaphost +-*/ +- +-static unsigned short int action(char *pointer, char *res, unsigned short int length_uri, +- unsigned short int thread, int client_socket, void *userdata) ++/** ++ * action ++ * manages/parses the actions for motion ( makemovie , snapshot , restart , quit ). ++ * ++ * Returns ++ * 0 for restart & quit ++ * 1 for makemovie & snaphost ++ */ ++static unsigned int action(char *pointer, char *res, unsigned int length_uri, ++ unsigned int thread, int client_socket, void *userdata) + { + /* parse action commands */ + char command[256] = {'\0'}; + struct context **cnt = userdata; +- unsigned short int i = 0; ++ unsigned int i = 0; + +- warningkill = sscanf (pointer, "%255[a-z]" , command); +- if (!strcmp(command,"makemovie")) { ++ warningkill = sscanf(pointer, "%255[a-z]" , command); ++ if (!strcmp(command, "makemovie")) { + pointer = pointer + 9; + length_uri = length_uri - 9; + if (length_uri == 0) { +- /*call makemovie*/ ++ /* call makemovie */ + + if (thread == 0) { + while (cnt[++i]) +@@ -871,7 +952,7 @@ static unsigned short int action(char *p + cnt[thread]->makemovie = 1; + } + +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "makemovie for thread %hu done
                                                            \n", thread, thread); +@@ -883,27 +964,27 @@ static unsigned short int action(char *p + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) +- response_client(client_socket,not_found_response_valid_command,NULL); ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) ++ response_client(client_socket, not_found_response_valid_command, NULL); + else +- response_client(client_socket,not_found_response_valid_command_raw,NULL); ++ response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"snapshot")) { ++ } else if (!strcmp(command, "snapshot")) { + pointer = pointer + 8; + length_uri = length_uri - 8; + if (length_uri == 0) { +- /*call snapshot*/ ++ /* call snapshot */ + + if (thread == 0) { + while (cnt[++i]) +- cnt[i]->snapshot=1; ++ cnt[i]->snapshot = 1; + } else { +- cnt[thread]->snapshot=1; ++ cnt[thread]->snapshot = 1; + } + + cnt[thread]->snapshot = 1; +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "snapshot for thread %hu done
                                                            \n", thread, thread); +@@ -915,8 +996,8 @@ static unsigned short int action(char *p + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -925,12 +1006,12 @@ static unsigned short int action(char *p + pointer = pointer + 7; + length_uri = length_uri - 7; + if (length_uri == 0) { +- /*call restart*/ ++ /* call restart */ + + if (thread == 0) { +- motion_log(LOG_DEBUG, 0, "httpd restart"); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd is going to restart"); + kill(getpid(),SIGHUP); +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "restart in progress ... bye
                                                            \nHome"); + send_template(client_socket, res); +@@ -942,13 +1023,14 @@ static unsigned short int action(char *p + } + return 0; // to restart + } else { +- motion_log(LOG_DEBUG, 0, "httpd restart thread %d", thread); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd is going to restart thread %d", ++ thread); + if (cnt[thread]->running) { +- cnt[thread]->makemovie=1; +- cnt[thread]->finish=1; ++ cnt[thread]->makemovie = 1; ++ cnt[thread]->finish = 1; + } +- cnt[thread]->restart=1; +- if (cnt[0]->conf.control_html_output) { ++ cnt[thread]->restart = 1; ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "restart for thread %hu done
                                                            \n", thread, thread); +@@ -961,21 +1043,21 @@ static unsigned short int action(char *p + } + } + } else { +- if (cnt[0]->conf.control_html_output) +- response_client(client_socket,not_found_response_valid_command,NULL); ++ if (cnt[0]->conf.webcontrol_html_output) ++ response_client(client_socket, not_found_response_valid_command, NULL); + else +- response_client(client_socket,not_found_response_valid_command_raw,NULL); ++ response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"quit")) { ++ } else if (!strcmp(command, "quit")) { + pointer = pointer + 4; + length_uri = length_uri - 4; + if (length_uri == 0) { +- /*call quit*/ ++ /* call quit */ + + if (thread == 0) { +- motion_log(LOG_DEBUG, 0, "httpd quit"); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd quits"); + kill(getpid(),SIGQUIT); +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "quit in progress ... bye"); + send_template(client_socket, res); +@@ -986,14 +1068,14 @@ static unsigned short int action(char *p + send_template_raw(client_socket, res); + } + return 0; // to quit +- + } else { +- motion_log(LOG_DEBUG, 0, "httpd quit thread %d", thread); +- cnt[thread]->restart=0; +- cnt[thread]->makemovie=1; +- cnt[thread]->finish=1; +- cnt[thread]->watchdog=WATCHDOG_OFF; +- if (cnt[0]->conf.control_html_output) { ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd quits thread %d", ++ thread); ++ cnt[thread]->restart = 0; ++ cnt[thread]->makemovie = 1; ++ cnt[thread]->finish = 1; ++ cnt[thread]->watchdog = WATCHDOG_OFF; ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "quit for thread %hu done
                                                            \n", thread, thread); +@@ -1006,14 +1088,14 @@ static unsigned short int action(char *p + } + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -1022,42 +1104,44 @@ static unsigned short int action(char *p + return 1; + } + +-/* +- This function manages/parses the detection actions for motion ( status , start , pause ). +- +- return 1 to exit from function. +-*/ ++/** ++ * detection ++ * manages/parses the detection actions for motion ( status , start , pause ). ++ * ++ * Returns ++ * 1 to exit from function. ++ */ + +-static unsigned short int detection(char *pointer, char *res, unsigned short int length_uri, unsigned short int thread, +- int client_socket, void *userdata) ++static unsigned int detection(char *pointer, char *res, unsigned int length_uri, ++ unsigned int thread, int client_socket, void *userdata) + { +- char command[256]={'\0'}; ++ char command[256] = {'\0'}; + struct context **cnt = userdata; +- unsigned short int i = 0; ++ unsigned int i = 0; + +- warningkill = sscanf (pointer, "%255[a-z]" , command); +- if (!strcmp(command,"status")) { ++ warningkill = sscanf(pointer, "%255[a-z]" , command); ++ if (!strcmp(command, "status")) { + pointer = pointer + 6; + length_uri = length_uri - 6; + if (length_uri == 0) { +- /*call status*/ +- +- if (cnt[0]->conf.control_html_output) { ++ /* call status */ ++ ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); +- sprintf(res, "<– back

                                                            Thread %hu" +- " Detection status %s\n", thread, thread, ++ sprintf(res, "<– back

                                                            Thread %hu" ++ " Detection status %s\n", thread, thread, + (!cnt[thread]->running)? "NOT RUNNING": (cnt[thread]->pause)? "PAUSE":"ACTIVE"); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { +- sprintf(res, "Thread %hu Detection status %s\n",thread, ++ sprintf(res, "Thread %hu Detection status %s\n", thread, + (!cnt[thread]->running)? "NOT RUNNING": (cnt[thread]->pause)? "PAUSE":"ACTIVE"); + send_template_ini_client_raw(client_socket); + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -1066,7 +1150,7 @@ static unsigned short int detection(char + pointer = pointer + 5; + length_uri = length_uri - 5; + if (length_uri == 0) { +- /*call start*/ ++ /* call start */ + + if (thread == 0) { + do { +@@ -1076,9 +1160,9 @@ static unsigned short int detection(char + cnt[thread]->pause = 0; + } + +- if (cnt[0]->conf.control_html_output) { +- send_template_ini_client(client_socket,ini_template); +- sprintf(res, "<– back

                                                            \nThread %hu" ++ if (cnt[0]->conf.webcontrol_html_output) { ++ send_template_ini_client(client_socket, ini_template); ++ sprintf(res, "<– back

                                                            \nThread %hu" + " Detection resumed\n", thread, thread); + send_template(client_socket, res); + send_template_end_client(client_socket); +@@ -1088,17 +1172,17 @@ static unsigned short int detection(char + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"pause")){ ++ } else if (!strcmp(command, "pause")) { + pointer = pointer + 5; + length_uri = length_uri - 5; + if (length_uri == 0) { +- /*call pause*/ ++ /* call pause */ + + if (thread == 0) { + do { +@@ -1107,12 +1191,12 @@ static unsigned short int detection(char + } else { + cnt[thread]->pause = 1; + } +- +- if (cnt[0]->conf.control_html_output) { ++ ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); +- sprintf(res, "<– back

                                                            \nThread %hu" ++ sprintf(res, "<– back

                                                            \nThread %hu" + " Detection paused\n", thread, thread); +- send_template(client_socket,res); ++ send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +@@ -1120,62 +1204,62 @@ static unsigned short int detection(char + send_template_raw(client_socket, res); + } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"connection")){ ++ } else if (!strcmp(command, "connection")) { + pointer = pointer + 10; + length_uri = length_uri - 10; ++ + if (length_uri == 0) { +- +- /*call connection*/ +- if (cnt[0]->conf.control_html_output) { ++ /* call connection */ ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n", thread); +- send_template(client_socket,res); ++ send_template(client_socket, res); + if (thread == 0) { +- do { +- sprintf(res, "Thread %hu %s
                                                            \n",i, +- (!cnt[i]->running)? "NOT RUNNING" : ++ do{ ++ sprintf(res, "Thread %hu %s
                                                            \n", i, ++ (!cnt[i]->running)? "NOT RUNNING" : + (cnt[i]->lost_connection)?CONNECTION_KO:CONNECTION_OK); +- send_template(client_socket,res); ++ send_template(client_socket, res); + } while (cnt[++i]); + } else { + sprintf(res, "Thread %hu %s\n", thread, +- (!cnt[thread]->running)? "NOT RUNNING" : ++ (!cnt[thread]->running)? "NOT RUNNING" : + (cnt[thread]->lost_connection)? CONNECTION_KO: CONNECTION_OK); +- send_template(client_socket,res); +- } ++ send_template(client_socket, res); ++ } + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +- if (thread == 0){ ++ if (thread == 0) { + do { + sprintf(res, "Thread %hu %s\n", i, +- (!cnt[i]->running)? "NOT RUNNING" : ++ (!cnt[i]->running)? "NOT RUNNING" : + (cnt[i]->lost_connection)? CONNECTION_KO: CONNECTION_OK); + send_template_raw(client_socket, res); + } while (cnt[++i]); +- } else { ++ } else { + sprintf(res, "Thread %hu %s\n", thread, +- (!cnt[thread]->running)? "NOT RUNNING" : ++ (!cnt[thread]->running)? "NOT RUNNING" : + (cnt[thread]->lost_connection)? CONNECTION_KO: CONNECTION_OK); + send_template_raw(client_socket, res); +- } +- +- } ++ } ++ ++ } + } else { +- /*error*/ +- if (cnt[0]->conf.control_html_output) ++ /* error */ ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +- } ++ } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -1185,25 +1269,29 @@ static unsigned short int detection(char + } + + +-/* +- This function manages/parses the track action for motion ( set , pan , tilt , auto ). +- +- return 1 to exit from function. +-*/ +- +-static unsigned short int track(char *pointer, char *res, unsigned short int length_uri, unsigned short int thread, +- int client_socket, void *userdata) ++/** ++ * track ++ * manages/parses the track action for motion ( set , pan , tilt , auto ). ++ * ++ * Returns ++ * 1 to exit from function. ++ */ ++static unsigned int track(char *pointer, char *res, unsigned int length_uri, ++ unsigned int thread, int client_socket, void *userdata) + { +- char question = '\0'; ++ char question='\0'; + char command[256] = {'\0'}; + struct context **cnt = userdata; + + warningkill = sscanf(pointer, "%255[a-z]%c", command, &question); + if (!strcmp(command, "set")) { +- pointer=pointer+3;length_uri=length_uri-3; +- /* FIXME need to check each value */ +- /* Relative movement set?pan=0&tilt=0 | set?pan=0 | set?tilt=0*/ +- /* Absolute movement set?x=0&y=0 | set?x=0 | set?y=0 */ ++ pointer = pointer+3; ++ length_uri = length_uri-3; ++ /* ++ * FIXME need to check each value ++ * Relative movement set?pan=0&tilt=0 | set?pan=0 | set?tilt=0 ++ * Absolute movement set?x=0&y=0 | set?x=0 | set?y=0 ++ */ + + if ((question == '?') && (length_uri > 2)) { + char panvalue[12] = {'\0'}, tiltvalue[12] = {'\0'}; +@@ -1213,16 +1301,18 @@ static unsigned short int track(char *po + + pointer++; + length_uri--; +- /* set?pan=value&tilt=value */ +- /* set?x=value&y=value */ +- /* pan= or x= | tilt= or y= */ ++ /* ++ * set?pan=value&tilt=value ++ * set?x=value&y=value ++ * pan= or x= | tilt= or y= ++ */ + +- warningkill = sscanf (pointer, "%255[a-z]%c" , command, &question); ++ warningkill = sscanf(pointer, "%255[a-z]%c" , command, &question); + +- if (( question != '=' ) || (command[0] == '\0')) { ++ if ((question != '=') || (command[0] == '\0')) { + /* no valid syntax */ +- motion_log(LOG_WARNING, 0, "httpd debug race 1"); +- if (cnt[0]->conf.control_html_output) ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 1"); ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); +@@ -1238,7 +1328,7 @@ static unsigned short int track(char *po + pointer = pointer + 3; + length_uri = length_uri - 3; + pan = 1; +- if ((warningkill = sscanf(pointer, "%10[-0-9]", panvalue))){ ++ if ((warningkill = sscanf(pointer, "%10[-0-9]", panvalue))) { + pointer = pointer + strlen(panvalue); + length_uri = length_uri - strlen(panvalue); + } +@@ -1247,7 +1337,7 @@ static unsigned short int track(char *po + pointer = pointer + 4; + length_uri = length_uri - 4; + tilt = 1; +- if ((warningkill = sscanf(pointer, "%10[-0-9]", tiltvalue))){ ++ if ((warningkill = sscanf(pointer, "%10[-0-9]", tiltvalue))) { + pointer = pointer + strlen(tiltvalue); + length_uri = length_uri - strlen(tiltvalue); + } +@@ -1256,7 +1346,7 @@ static unsigned short int track(char *po + pointer++; + length_uri--; + X = 1; +- if ((warningkill = sscanf(pointer, "%10[-0-9]", x_value))){ ++ if ((warningkill = sscanf(pointer, "%10[-0-9]", x_value))) { + pointer = pointer + strlen(x_value); + length_uri = length_uri - strlen(x_value); + } +@@ -1265,36 +1355,32 @@ static unsigned short int track(char *po + pointer++; + length_uri--; + Y = 1; +- if ((warningkill = sscanf (pointer, "%10[-0-9]" , y_value))){ ++ if ((warningkill = sscanf(pointer, "%10[-0-9]" , y_value))) { + pointer = pointer + strlen(y_value); + length_uri = length_uri - strlen(y_value); + } + } else { + /* no valid syntax */ +- motion_log(LOG_WARNING, 0, "httpd debug race 2"); +- if (cnt[0]->conf.control_html_output) ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 2"); ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + return 1; + } + +- + /* first value check for error */ + +- + if (!warningkill) { +- motion_log(LOG_WARNING, 0, "httpd debug race 3"); ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 3"); + /* error value */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, error_value, NULL); + else + response_client(client_socket, error_value_raw, NULL); + return 1; + } + +- +- + /* Only one parameter (pan= ,tilt= ,x= ,y= ) */ + if (length_uri == 0) { + if (pan) { +@@ -1311,11 +1397,11 @@ static unsigned short int track(char *po + // Add the number of frame to skip for motion detection + cnt[thread]->moved = track_move(pancnt, pancnt->video_dev, ¢, &pancnt->imgs, 1); + if (cnt[thread]->moved) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            \n" +- "track set relative pan=%s
                                                            \n", ++ "track set relative pan=%s
                                                            \n", + thread, thread, panvalue); + send_template(client_socket, res); + send_template_end_client(client_socket); +@@ -1325,14 +1411,14 @@ static unsigned short int track(char *po + send_template_raw(client_socket, res); + } + } else { +- /*error in track action*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error in track action */ ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back

                                                            " + "Thread %hu\n", thread, thread); + response_client(client_socket, track_error, res); +- } +- else ++ } else { + response_client(client_socket, track_error_raw, NULL); ++ } + } + } else if (tilt) { + struct coord cent; +@@ -1346,9 +1432,9 @@ static unsigned short int track(char *po + cent.x = 0; + cent.y = atoi(tiltvalue); + // Add the number of frame to skip for motion detection +- cnt[thread]->moved=track_move(tiltcnt, tiltcnt->video_dev, ¢, &tiltcnt->imgs, 1); +- if (cnt[thread]->moved){ +- if (cnt[0]->conf.control_html_output) { ++ cnt[thread]->moved = track_move(tiltcnt, tiltcnt->video_dev, ¢, &tiltcnt->imgs, 1); ++ if (cnt[thread]->moved) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            \n" +@@ -1358,18 +1444,18 @@ static unsigned short int track(char *po + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +- sprintf(res, "track set relative tilt=%s\nDone\n",tiltvalue); ++ sprintf(res, "track set relative tilt=%s\nDone\n", tiltvalue); + send_template_raw(client_socket, res); + } + } else { +- /*error in track action*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error in track action */ ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back

                                                            " + "Thread %hu\n", thread, thread); + response_client(client_socket, track_error, res); +- } +- else ++ } else { + response_client(client_socket, track_error_raw, NULL); ++ } + } + } else if (X) { + /* X */ +@@ -1377,7 +1463,7 @@ static unsigned short int track(char *po + // 1000 is out of range for pwc + cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, atoi(x_value), 1000); + if (cnt[thread]->moved) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            \n" +@@ -1391,14 +1477,14 @@ static unsigned short int track(char *po + send_template_raw(client_socket, res); + } + } else { +- /*error in track action*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error in track action */ ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back

                                                            " + "Thread %hu\n", thread, thread); + response_client(client_socket, track_error, res); +- } +- else ++ } else { + response_client(client_socket, track_error_raw, NULL); ++ } + } + + } else { +@@ -1407,7 +1493,7 @@ static unsigned short int track(char *po + // 1000 is out of range for pwc + cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, 1000, atoi(y_value)); + if (cnt[thread]->moved) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            \n" +@@ -1421,105 +1507,108 @@ static unsigned short int track(char *po + send_template_raw(client_socket, res); + } + } else { +- /*error in track action*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error in track action */ ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back

                                                            " + "Thread %hu\n", thread, thread); + response_client(client_socket, track_error, res); + } else { + response_client(client_socket, track_error_raw, NULL); +- } ++ } + } + } + return 1; + } + +- + /* Check Second parameter */ + +- warningkill = sscanf (pointer, "%c%255[a-z]" ,&question, command); +- if (( question != '&' ) || (command[0] == '\0') ){ +- motion_log(LOG_WARNING, 0, "httpd debug race 4"); +- if (strstr(pointer,"&")){ +- if (cnt[0]->conf.control_html_output) ++ warningkill = sscanf(pointer, "%c%255[a-z]" , &question, command); ++ if ((question != '&') || (command[0] == '\0')) { ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 4"); ++ if (strstr(pointer, "&")) { ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, error_value, NULL); + else + response_client(client_socket, error_value_raw, NULL); +- } else { /* no valid syntax */ +- if (cnt[0]->conf.control_html_output) ++ ++ /* no valid syntax */ ++ } else { ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); +- } ++ } + return 1; + } + + pointer++; + length_uri--; + +- if (!strcmp(command, "pan")){ ++ if (!strcmp(command, "pan")) { + pointer = pointer + 3; + length_uri = length_uri - 3; +- if (pan || !tilt || X || Y ) { +- motion_log(LOG_WARNING, 0, "httpd debug race 5"); ++ if (pan || !tilt || X || Y) { ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 5"); + /* no valid syntax */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + return 1; + } + pan=2; +- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, panvalue); +- } +- else if (!strcmp(command, "tilt")) { ++ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, panvalue); ++ ++ } else if (!strcmp(command, "tilt")) { + pointer = pointer + 4; + length_uri = length_uri - 4; +- + if (tilt || !pan || X || Y) { + /* no valid syntax */ +- motion_log(LOG_WARNING, 0, "httpd debug race 6"); +- if (cnt[0]->conf.control_html_output) ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 6"); ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + return 1; + } + tilt = 2; +- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, tiltvalue); ++ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, tiltvalue); ++ + } else if (!strcmp(command, "x")) { + pointer++; + length_uri--; + if (X || !Y || pan || tilt) { +- motion_log(LOG_WARNING, 0, "httpd debug race 7"); +- ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 7"); ++ + /* no valid syntax */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + return 1; + } + X = 2; +- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, x_value); ++ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, x_value); ++ + } else if (!strcmp(command, "y")) { + pointer++; + length_uri--; +- if (Y || !X || pan || tilt){ +- motion_log(LOG_WARNING, 0, "httpd debug race 8"); ++ if (Y || !X || pan || tilt) { ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 8"); + /* no valid syntax */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + return 1; + } + Y = 2; +- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, y_value); ++ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, y_value); ++ + } else { +- motion_log(LOG_WARNING, 0, "httpd debug race 9"); ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 9"); + /* no valid syntax */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); +@@ -1529,26 +1618,26 @@ static unsigned short int track(char *po + /* Second value check */ + + if ((warningkill < 2) && (question != '=')) { +- motion_log(LOG_WARNING, 0, "httpd debug race 10"); ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 10"); + /* no valid syntax */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_valid_syntax, NULL); + else + response_client(client_socket, not_valid_syntax_raw, NULL); + return 1; +- } else if (( question == '=') && ( warningkill == 1)) { +- motion_log(LOG_WARNING, 0, "httpd debug race 11"); +- if (cnt[0]->conf.control_html_output) ++ } else if ((question == '=') && (warningkill == 1)) { ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 11"); ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, error_value, NULL); + else + response_client(client_socket, error_value_raw, NULL); + return 1; + } +- +- ++ ++ + if (pan == 2) { + pointer = pointer + strlen(panvalue) + 1; +- length_uri = length_uri - strlen(panvalue) - 1; ++ length_uri = length_uri - strlen(panvalue) - 1; + } else if (tilt == 2) { + pointer = pointer + strlen(tiltvalue) + 1; + length_uri = length_uri - strlen(tiltvalue) - 1; +@@ -1558,27 +1647,25 @@ static unsigned short int track(char *po + } else { + pointer = pointer + strlen(y_value) + 1; + length_uri = length_uri - strlen(y_value) - 1; +- } +- +- ++ } ++ + + if (length_uri != 0) { +- motion_log(LOG_WARNING, 0, "httpd debug race 12"); +- if (cnt[0]->conf.control_html_output) ++ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 12"); ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, error_value, NULL); + else + response_client(client_socket, error_value_raw, NULL); + return 1; + } + +- + /* track set absolute ( x , y )*/ + + if (X && Y) { + setcnt = cnt[thread]; + cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, atoi(x_value), atoi(y_value)); + if (cnt[thread]->moved) { +- if (cnt[0]->conf.control_html_output){ ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            \n" +@@ -1592,14 +1679,14 @@ static unsigned short int track(char *po + send_template_raw(client_socket, res); + } + } else { +- /*error in track action*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error in track action */ ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back

                                                            " + "Thread %hu\n", thread, thread); + response_client(client_socket, track_error, res); + } else { + response_client(client_socket, track_error_raw, NULL); +- } ++ } + } + /* track set relative ( pan , tilt )*/ + } else { +@@ -1614,7 +1701,8 @@ static unsigned short int track(char *po + cent.y = 0; + cent.x = atoi(panvalue); + // Add the number of frame to skip for motion detection +- cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ¢, &relativecnt->imgs, 1); ++ cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ++ ¢, &relativecnt->imgs, 1); + + if (cnt[thread]->moved) { + /* move tilt */ +@@ -1623,11 +1711,11 @@ static unsigned short int track(char *po + cent.height = relativecnt->imgs.height; + cent.x = 0; + cent.y = atoi(tiltvalue); +- SLEEP(1,0); +- cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ¢, &relativecnt->imgs, 1); +- ++ // SLEEP(1,0); ++ cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ++ ¢, &relativecnt->imgs, 1); + if (cnt[thread]->moved) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            \n" +@@ -1641,28 +1729,30 @@ static unsigned short int track(char *po + send_template_raw(client_socket, res); + } + return 1; ++ + } else { +- /*error in track tilt*/ +- if (cnt[0]->conf.control_html_output) { ++ /* error in track tilt */ ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back

                                                            " + "Thread %hu\n", thread, thread); + response_client(client_socket, track_error, res); + } else { + response_client(client_socket, track_error_raw, NULL); +- } ++ } + } + } + +- /*error in track pan*/ +- if (cnt[0]->conf.control_html_output) { +- sprintf(res, "<– back

                                                            Thread %hu\n", ++ /* error in track pan */ ++ if (cnt[0]->conf.webcontrol_html_output) { ++ sprintf(res, "<– back

                                                            Thread %hu\n", + thread, thread); + response_client(client_socket, track_error, res); +- } else ++ } else { + response_client(client_socket, track_error_raw, NULL); ++ } + } + } else if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \nThread %hu
                                                            \n" + "
                                                            \n" +@@ -1684,36 +1774,63 @@ static unsigned short int track(char *po + } + } else { + /* error not valid command */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"status")) { ++ } else if (!strcmp(command, "center")) { + pointer = pointer+6; + length_uri = length_uri-6; + if (length_uri==0) { +- if (cnt[0]->conf.control_html_output) { ++ struct context *setcnt; ++ setcnt = cnt[thread]; ++ // 1000 is out of range for pwc ++ cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, 0, 0); ++ ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \nThread %hu" +- "
                                                            track auto %s", thread, thread, ++ "
                                                            track set center", thread, thread); ++ send_template(client_socket, res); ++ send_template_end_client(client_socket); ++ } else { ++ sprintf(res, "Thread %hu\n track set center\nDone\n", thread); ++ send_template_ini_client_raw(client_socket); ++ send_template_raw(client_socket, res); ++ } ++ } else { ++ /* error not valid command */ ++ if (cnt[0]->conf.webcontrol_html_output) ++ response_client(client_socket, not_found_response_valid_command, NULL); ++ else ++ response_client(client_socket, not_found_response_valid_command_raw, NULL); ++ } ++ } else if (!strcmp(command, "status")) { ++ pointer = pointer+6; ++ length_uri = length_uri-6; ++ if (length_uri==0) { ++ if (cnt[0]->conf.webcontrol_html_output) { ++ send_template_ini_client(client_socket, ini_template); ++ sprintf(res, "<– back

                                                            \nThread %hu" ++ "
                                                            track auto %s", thread, thread, + (cnt[thread]->track.active)? "enabled":"disabled"); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { +- sprintf(res, "Thread %hu\n track auto %s\nDone\n",thread, ++ sprintf(res, "Thread %hu\n track auto %s\nDone\n", thread, + (cnt[thread]->track.active)? "enabled":"disabled"); + send_template_ini_client_raw(client_socket); + send_template_raw(client_socket, res); + } + } else { + /* error not valid command */ +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } else if (!strcmp(command,"auto")) { ++ } else if (!strcmp(command, "auto")) { + pointer = pointer + 4; + length_uri = length_uri - 4; + if ((question == '?') && (length_uri > 0)) { +@@ -1722,27 +1839,27 @@ static unsigned short int track(char *po + length_uri--; + /* value= */ + +- warningkill = sscanf (pointer, "%255[a-z]%c",query,&question); +- if ((question == '=') && (!strcmp(query,"value")) ) { ++ warningkill = sscanf(pointer, "%255[a-z]%c", query, &question); ++ if ((question == '=') && (!strcmp(query, "value"))) { + pointer = pointer + 6; + length_uri = length_uri - 6; +- warningkill = sscanf (pointer, "%255[-0-9a-z]" , command); +- if ((command!=NULL) && (strlen(command) > 0)) { ++ warningkill = sscanf(pointer, "%255[-0-9a-z]" , command); ++ if ((command != NULL) && (strlen(command) > 0)) { + struct context *autocnt; + +- /* auto value=0|1|status*/ ++ /* auto value=0|1|status */ + +- if (!strcmp(command,"status")) { +- if (cnt[0]->conf.control_html_output) { ++ if (!strcmp(command, "status")) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu
                                                            " +- "track auto %s", thread, thread, ++ "track auto %s", thread, thread, + (cnt[thread]->track.active)? "enabled":"disabled"); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { +- sprintf(res, "Thread %hu\n track auto %s\nDone\n", thread, ++ sprintf(res, "Thread %hu\n track auto %s\nDone\n", thread, + (cnt[thread]->track.active)? "enabled":"disabled"); + send_template_ini_client_raw(client_socket); + send_template_raw(client_socket, res); +@@ -1754,65 +1871,64 @@ static unsigned short int track(char *po + if (active > -1 && active < 2) { + autocnt = cnt[thread]; + autocnt->track.active = active; +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            " + "Thread %hu" +- "
                                                            track auto %s
                                                            ", thread, thread, ++ "
                                                            track auto %s
                                                            ", thread, thread, + active ? "enabled":"disabled"); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +- sprintf(res, "track auto %s\nDone\n",active ? "enabled":"disabled"); ++ sprintf(res, "track auto %s\nDone\n", active ? "enabled":"disabled"); + send_template_raw(client_socket, res); + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } +- else if (length_uri == 0) { ++ } else if (length_uri == 0) { + +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \nThread %hu\n" + "\n" +- "
                                                            \n",thread, thread, (cnt[thread]->track.active) ? "selected":"", +- (cnt[thread]->track.active) ? "selected":"" ); ++ "\n", thread, thread, (cnt[thread]->track.active) ? "selected":"", ++ (cnt[thread]->track.active) ? "selected":""); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +- sprintf(res, "auto accepts only 0,1 or status as valid value\n"); ++ sprintf(res, "auto accepts only 0,1 or status as valid value\n"); + send_template_raw(client_socket, res); + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); +@@ -1823,34 +1939,35 @@ static unsigned short int track(char *po + + + +-/* +- parses the action requested for motion ( config , action , detection , track ) and call +- to action function if needed. +- +- return 0 on action restart or quit +- return 1 on success +-*/ +- +-static unsigned short int handle_get(int client_socket, const char* url, void *userdata) ++/** ++ * handle_get ++ * parses the action requested for motion ( config , action , detection , track ) ++ * and call to action function if needed. ++ * ++ * Returns ++ * 0 on action restart or quit ++ * 1 on success ++ */ ++static unsigned int handle_get(int client_socket, const char *url, void *userdata) + { +- struct context **cnt=userdata; ++ struct context **cnt = userdata; + +- if (*url == '/' ) { +- unsigned short int i = 0; ++ if (*url == '/') { ++ int i = 0; + char *res=NULL; +- res = malloc(2048); ++ res = mymalloc(2048); + + /* get the number of threads */ + while (cnt[++i]); + /* ROOT_URI -> GET / */ +- if (! (strcmp (url, "/"))) { +- unsigned short int y; +- if (cnt[0]->conf.control_html_output) { +- send_template_ini_client(client_socket,ini_template); ++ if (!strcmp(url, "/")) { ++ int y; ++ if (cnt[0]->conf.webcontrol_html_output) { ++ send_template_ini_client(client_socket, ini_template); + sprintf(res, "Motion "VERSION" Running [%hu] Threads
                                                            \n" + "All
                                                            \n", i); + send_template(client_socket, res); +- for (y=1; yThread %hu
                                                            \n", y, y); + send_template(client_socket, res); + } +@@ -1859,16 +1976,15 @@ static unsigned short int handle_get(int + send_template_ini_client_raw(client_socket); + sprintf(res, "Motion "VERSION" Running [%hu] Threads\n0\n", i); + send_template_raw(client_socket, res); +- for (y=1; y GET /2 */ + pointer++; + length_uri--; +- warningkill = sscanf (pointer, "%hd%c", &thread, &slash); ++ warningkill = sscanf(pointer, "%d%c", &thread, &slash); + + if ((thread != -1) && (thread < i)) { + /* thread_number found */ +@@ -1885,23 +2001,23 @@ static unsigned short int handle_get(int + length_uri = length_uri - 2; + } else { + pointer++; +- length_uri--; ++ length_uri--; + } +- ++ + if (slash == '/') { /* slash found /2/ */ + pointer++; + length_uri--; +- } ++ } + + if (length_uri != 0) { +- warningkill = sscanf (pointer, "%255[a-z]%c" , command , &slash); ++ warningkill = sscanf(pointer, "%255[a-z]%c" , command , &slash); + + /* config */ +- if (!strcmp(command,"config")) { ++ if (!strcmp(command, "config")) { + pointer = pointer + 6; + length_uri = length_uri - 6; + if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "Thread %hd
                                                            \n" +@@ -1918,24 +2034,23 @@ static unsigned short int handle_get(int + send_template_raw(client_socket, res); + } + } else if ((slash == '/') && (length_uri >= 4)) { +- /*call config() */ ++ /* call config() */ + pointer++; + length_uri--; + config(pointer, res, length_uri, thread, client_socket, cnt); + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } +- /* action */ +- else if (!strcmp(command,"action")) { ++ ++ } else if (!strcmp(command, "action")) { /* action */ + pointer = pointer + 6; + length_uri = length_uri - 6; + /* call action() */ + if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "Thread %hd
                                                            \n" +@@ -1943,7 +2058,7 @@ static unsigned short int handle_get(int + "snapshot
                                                            \n" + "restart
                                                            \n" + "quit
                                                            \n", +- thread,thread,thread,thread,thread,thread); ++ thread, thread, thread, thread, thread, thread); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { +@@ -1952,7 +2067,7 @@ static unsigned short int handle_get(int + send_template_raw(client_socket, res); + } + } else if ((slash == '/') && (length_uri > 4)) { +- unsigned short int ret = 1; ++ unsigned int ret = 1; + pointer++; + length_uri--; + ret = action(pointer, res, length_uri, thread, client_socket, cnt); +@@ -1960,18 +2075,16 @@ static unsigned short int handle_get(int + return ret; + + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command,NULL); + else + response_client(client_socket, not_found_response_valid_command_raw,NULL); + } +- } +- /* detection */ +- else if (!strcmp(command,"detection")) { ++ } else if (!strcmp(command, "detection")) { /* detection */ + pointer = pointer + 9; + length_uri = length_uri - 9; + if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "Thread %hd
                                                            \n" +@@ -1993,34 +2106,33 @@ static unsigned short int handle_get(int + /* call detection() */ + detection(pointer, res, length_uri, thread, client_socket, cnt); + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_valid_command, NULL); + else + response_client(client_socket, not_found_response_valid_command_raw, NULL); + } +- } +- /* track */ +- else if (!strcmp(command,"track")) { ++ } else if (!strcmp(command,"track")) { /* track */ + pointer = pointer + 5; + length_uri = length_uri - 5; + if (length_uri == 0) { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \n" + "Thread %hd
                                                            \n" + "track set pan/tilt
                                                            \n" ++ "track center
                                                            \n" + "track auto
                                                            \n" + "track status
                                                            \n", +- thread, thread, thread, thread, thread); ++ thread, thread, thread, thread, thread, thread); + send_template(client_socket, res); + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); +- sprintf(res, "Thread %hd\nset pan/tilt\nauto\nstatus\n", thread); ++ sprintf(res, "Thread %hd\nset pan/tilt\ncenter\nauto\nstatus\n", thread); + send_template_raw(client_socket, res); + } +- } +- else if ((slash == '/') && (length_uri >= 4)) { ++ ++ } else if ((slash == '/') && (length_uri >= 4)) { + pointer++; + length_uri--; + /* call track() */ +@@ -2028,33 +2140,33 @@ static unsigned short int handle_get(int + track(pointer, res, length_uri, thread, client_socket, cnt); + } else { + /* error track not enable */ +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back\n", thread); +- response_client(client_socket, not_track,res); ++ response_client(client_socket, not_track, res); ++ } else { ++ response_client(client_socket, not_track_raw, NULL); + } +- else +- response_client(client_socket, not_track_raw,NULL); + } + } else { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back\n", thread); + response_client(client_socket, not_found_response_valid_command, res); +- } +- else ++ } else { + response_client(client_socket, not_found_response_valid_command_raw, NULL); ++ } + } + } else { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back\n", thread); + response_client(client_socket, not_found_response_valid_command, res); +- } +- else ++ } else { + response_client(client_socket, not_found_response_valid_command_raw, NULL); ++ } + } + } else { + /* /thread_number/ requested */ +- if (cnt[0]->conf.control_html_output) { +- send_template_ini_client(client_socket,ini_template); ++ if (cnt[0]->conf.webcontrol_html_output) { ++ send_template_ini_client(client_socket, ini_template); + sprintf(res, "<– back

                                                            \nThread %hd
                                                            \n" + "config
                                                            \n" + "action
                                                            \n" +@@ -2070,7 +2182,7 @@ static unsigned short int handle_get(int + } + } + } else { +- if (cnt[0]->conf.control_html_output) { ++ if (cnt[0]->conf.webcontrol_html_output) { + sprintf(res, "<– back\n"); + response_client(client_socket, not_found_response_valid, res); + } else { +@@ -2080,7 +2192,7 @@ static unsigned short int handle_get(int + } + free(res); + } else { +- if (cnt[0]->conf.control_html_output) ++ if (cnt[0]->conf.webcontrol_html_output) + response_client(client_socket, not_found_response_template,NULL); + else + response_client(client_socket, not_found_response_template_raw,NULL); +@@ -2090,20 +2202,21 @@ static unsigned short int handle_get(int + } + + +-/* +- -TODO- +- As usually web clients uses nonblocking connect/read +- read_client should handle nonblocking sockets. +- return 0 to quit or restart +- return 1 on success +-*/ +- +-static unsigned short int read_client(int client_socket, void *userdata, char *auth) ++/** ++ * read_client ++ * As usually web clients uses nonblocking connect/read ++ * read_client should handle nonblocking sockets. ++ * ++ * Returns ++ * 0 to quit or restart ++ * 1 on success ++ */ ++static unsigned int read_client(int client_socket, void *userdata, char *auth) + { +- unsigned short int alive = 1; +- unsigned short int ret = 1; ++ unsigned int alive = 1; ++ unsigned int ret = 1; + char buffer[1024] = {'\0'}; +- unsigned short int length = 1023; ++ ssize_t length = 1023; + struct context **cnt = userdata; + + /* lock the mutex */ +@@ -2112,10 +2225,10 @@ static unsigned short int read_client(in + while (alive) { + ssize_t nread = 0, readb = -1; + +- nread = read (client_socket, buffer, length); ++ nread = read_nonblock(client_socket, buffer, length); + + if (nread <= 0) { +- motion_log(LOG_ERR, 1, "httpd First read"); ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd First Read Error"); + pthread_mutex_unlock(&httpd_mutex); + return 1; + } else { +@@ -2126,89 +2239,107 @@ static unsigned short int read_client(in + + buffer[nread] = '\0'; + +- warningkill = sscanf (buffer, "%9s %511s %9s", method, url, protocol); ++ warningkill = sscanf(buffer, "%9s %511s %9s", method, url, protocol); ++ ++ if (warningkill != 3) { ++ if (cnt[0]->conf.webcontrol_html_output) ++ warningkill = write_nonblock(client_socket, bad_request_response, ++ sizeof (bad_request_response)); ++ else ++ warningkill = write_nonblock(client_socket, bad_request_response_raw, ++ sizeof (bad_request_response_raw)); ++ pthread_mutex_unlock(&httpd_mutex); ++ return 1; ++ } + +- while ((strstr (buffer, "\r\n\r\n") == NULL) && (readb != 0) && (nread < length)) { +- readb = read (client_socket, buffer+nread, sizeof (buffer) - nread); ++ while ((strstr(buffer, "\r\n\r\n") == NULL) && (readb != 0) && (nread < length)) { ++ readb = read_nonblock(client_socket, buffer+nread, sizeof (buffer) - nread); + + if (readb == -1) { + nread = -1; + break; + } + +- nread +=readb; +- ++ nread += readb; ++ + if (nread > length) { +- motion_log(LOG_ERR, 1, "httpd End buffer reached waiting for buffer ending"); ++ MOTION_LOG(WRN, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd End buffer" ++ " reached waiting for buffer ending"); + break; + } + buffer[nread] = '\0'; + } + +- /* Make sure the last read didn't fail. If it did, there's a +- problem with the connection, so give up. */ ++ /* ++ * Make sure the last read didn't fail. If it did, there's a ++ * problem with the connection, so give up. ++ */ + if (nread == -1) { +- motion_log(LOG_ERR, 1, "httpd READ"); ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd READ give up!"); + pthread_mutex_unlock(&httpd_mutex); + return 1; + } + alive = 0; + + /* Check Protocol */ +- if (strcmp (protocol, "HTTP/1.0") && strcmp (protocol, "HTTP/1.1")) { ++ if (strcmp(protocol, "HTTP/1.0") && strcmp (protocol, "HTTP/1.1")) { + /* We don't understand this protocol. Report a bad response. */ +- if (cnt[0]->conf.control_html_output) +- warningkill = write (client_socket, bad_request_response, sizeof (bad_request_response)); ++ if (cnt[0]->conf.webcontrol_html_output) ++ warningkill = write_nonblock(client_socket, bad_request_response, ++ sizeof (bad_request_response)); + else +- warningkill = write (client_socket, bad_request_response_raw, sizeof (bad_request_response_raw)); ++ warningkill = write_nonblock(client_socket, bad_request_response_raw, ++ sizeof (bad_request_response_raw)); + + pthread_mutex_unlock(&httpd_mutex); + return 1; + } + + if (strcmp (method, "GET")) { +- /* This server only implements the GET method. If client +- uses other method, report the failure. */ ++ /* ++ * This server only implements the GET method. If client ++ * uses other method, report the failure. ++ */ + char response[1024]; +- if (cnt[0]->conf.control_html_output) +- snprintf (response, sizeof (response),bad_method_response_template, method); ++ if (cnt[0]->conf.webcontrol_html_output) ++ snprintf(response, sizeof (response), bad_method_response_template, method); + else +- snprintf (response, sizeof (response),bad_method_response_template_raw, method); +- warningkill = write (client_socket, response, strlen (response)); ++ snprintf(response, sizeof (response), bad_method_response_template_raw, method); ++ warningkill = write_nonblock(client_socket, response, strlen(response)); + pthread_mutex_unlock(&httpd_mutex); + return 1; + } + + if (auth != NULL) { +- if ((authentication = strstr(buffer,"Basic")) ) { ++ if ((authentication = strstr(buffer,"Basic"))) { + char *end_auth = NULL; + authentication = authentication + 6; + +- if ((end_auth = strstr(authentication,"\r\n")) ) { ++ if ((end_auth = strstr(authentication,"\r\n"))) { + authentication[end_auth - authentication] = '\0'; + } else { + char response[1024]; +- snprintf (response, sizeof (response),request_auth_response_template, method); +- warningkill = write (client_socket, response, strlen (response)); ++ snprintf(response, sizeof (response), request_auth_response_template, method); ++ warningkill = write_nonblock(client_socket, response, strlen(response)); + pthread_mutex_unlock(&httpd_mutex); + return 1; + } + + if (strcmp(auth, authentication)) { +- char response[1024]={'\0'}; ++ char response[1024] = {'\0'}; + snprintf(response, sizeof (response), request_auth_response_template, method); +- warningkill = write (client_socket, response, strlen (response)); ++ warningkill = write_nonblock(client_socket, response, strlen(response)); + pthread_mutex_unlock(&httpd_mutex); + return 1; + } else { +- ret = handle_get (client_socket, url, cnt); ++ ret = handle_get(client_socket, url, cnt); + /* A valid auth request. Process it. */ + } + } else { + // Request Authorization +- char response[1024]={'\0'}; +- snprintf (response, sizeof (response),request_auth_response_template, method); +- warningkill = write (client_socket, response, strlen (response)); ++ char response[1024] = {'\0'}; ++ snprintf(response, sizeof (response), request_auth_response_template, method); ++ warningkill = write_nonblock(client_socket, response, strlen(response)); + pthread_mutex_unlock(&httpd_mutex); + return 1; + } +@@ -2224,126 +2355,171 @@ static unsigned short int read_client(in + } + + +-/* +- acceptnonblocking +- +- This function waits timeout seconds for listen socket. +- Returns : +- -1 if the timeout expires or on accept error. +- curfd (client socket) on accept success. +-*/ +- ++/** ++ * acceptnonblocking ++ * waits timeout seconds for listen socket. ++ * ++ * Returns ++ * -1 if the timeout expires or on accept error. ++ * curfd (client socket) on accept success. ++ */ + static int acceptnonblocking(int serverfd, int timeout) + { + int curfd; +- socklen_t namelen = sizeof(struct sockaddr_in); +- struct sockaddr_in client; ++ struct sockaddr_storage client; ++ socklen_t namelen = sizeof(client); ++ + struct timeval tm; + fd_set fds; + + tm.tv_sec = timeout; /* Timeout in seconds */ + tm.tv_usec = 0; + FD_ZERO(&fds); +- FD_SET(serverfd,&fds); +- +- if (select (serverfd + 1, &fds, NULL, NULL, &tm) > 0) { +- if (FD_ISSET(serverfd, &fds)) { ++ FD_SET(serverfd, &fds); ++ ++ if (select(serverfd + 1, &fds, NULL, NULL, &tm) > 0) { ++ if (FD_ISSET(serverfd, &fds)) { + if ((curfd = accept(serverfd, (struct sockaddr*)&client, &namelen)) > 0) + return curfd; +- } ++ } + } + + return -1; +-} +- ++} + +-/* +- Main function: Create the listening socket and waits client requests. +-*/ + ++/** ++ * httpd_run ++ * Creates the listening socket and waits client requests. ++ */ + void httpd_run(struct context **cnt) + { +- int sd, client_socket_fd, val = 1; +- unsigned short int client_sent_quit_message = 1, closehttpd = 0; +- struct sockaddr_in servAddr; ++ int sd = -1, client_socket_fd, val; ++ unsigned int client_sent_quit_message = 1, closehttpd = 0; ++ struct addrinfo hints, *res = NULL, *ressave = NULL; + struct sigaction act; + char *authentication = NULL; ++ char portnumber[10], hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; + + /* Initialize the mutex */ + pthread_mutex_init(&httpd_mutex, NULL); + +- + /* set signal handlers TO IGNORE */ +- memset(&act,0,sizeof(act)); ++ memset(&act, 0, sizeof(act)); + sigemptyset(&act.sa_mask); + act.sa_handler = SIG_IGN; +- sigaction(SIGPIPE,&act,NULL); +- sigaction(SIGCHLD,&act,NULL); +- +- /* create socket */ +- sd = socket(AF_INET, SOCK_STREAM, 0); ++ sigaction(SIGPIPE, &act, NULL); ++ sigaction(SIGCHLD, &act, NULL); + +- if (sd < 0) { +- motion_log(LOG_ERR, 1, "httpd socket"); ++ memset(&hints, 0, sizeof(struct addrinfo)); ++ /* AI_PASSIVE as we are going to listen */ ++ hints.ai_flags = AI_PASSIVE; ++#if defined(BSD) ++ hints.ai_family = AF_INET; ++#else ++ if (!cnt[0]->conf.ipv6_enabled) ++ hints.ai_family = AF_INET; ++ else ++ hints.ai_family = AF_UNSPEC; ++#endif ++ hints.ai_socktype = SOCK_STREAM; ++ ++ snprintf(portnumber, sizeof(portnumber), "%u", cnt[0]->conf.webcontrol_port); ++ ++ val = getaddrinfo(cnt[0]->conf.webcontrol_localhost ? "localhost" : NULL, portnumber, &hints, &res); ++ ++ /* check != 0 to allow FreeBSD compatibility */ ++ if (val != 0) { ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: getaddrinfo() for httpd socket failed: %s", ++ gai_strerror(val)); ++ if (res) ++ freeaddrinfo(res); + pthread_mutex_destroy(&httpd_mutex); + return; + } + +- /* bind server port */ +- servAddr.sin_family = AF_INET; +- if (cnt[0]->conf.control_localhost) +- servAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); +- else +- servAddr.sin_addr.s_addr = htonl(INADDR_ANY); +- servAddr.sin_port = htons(cnt[0]->conf.control_port); ++ ressave = res; + +- /* Reuse Address */ +- +- setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)) ; ++ while (res) { ++ /* create socket */ ++ sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); ++ ++ getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, ++ sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV); ++ ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd testing : %s addr: %s port: %s", ++ res->ai_family == AF_INET ? "IPV4":"IPV6", hbuf, sbuf); ++ ++ if (sd >= 0) { ++ val = 1; ++ /* Reuse Address */ ++ setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)); ++ ++ if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) { ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd Bound : %s addr: %s" ++ " port: %s", res->ai_family == AF_INET ? "IPV4":"IPV6", ++ hbuf, sbuf); ++ break; ++ } ++ ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd failed bind() interface %s" ++ " / port %s, retrying", hbuf, sbuf); ++ close(sd); ++ sd = -1; ++ } ++ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd socket failed interface %s" ++ " / port %s, retrying", hbuf, sbuf); ++ res = res->ai_next; ++ } + +- if (bind(sd, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) { +- motion_log(LOG_ERR, 1, "httpd bind()"); +- close(sd); ++ freeaddrinfo(ressave); ++ ++ if (sd < 0) { ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd ERROR bind()" ++ " [interface %s port %s]", hbuf, sbuf); + pthread_mutex_destroy(&httpd_mutex); + return; + } + +- if (listen(sd,5) == -1) { +- motion_log(LOG_ERR, 1, "httpd listen()"); ++ if (listen(sd, DEF_MAXWEBQUEUE) == -1) { ++ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd ERROR listen()" ++ " [interface %s port %s]", hbuf, sbuf); + close(sd); + pthread_mutex_destroy(&httpd_mutex); + return; + } + +- motion_log(LOG_DEBUG, 0, "motion-httpd/"VERSION" running, accepting connections"); +- motion_log(LOG_DEBUG, 0, "motion-httpd: waiting for data on port TCP %d", cnt[0]->conf.control_port); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd/"VERSION" running," ++ " accepting connections"); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd: waiting for data" ++ " on %s port TCP %s", hbuf, sbuf); + +- if (cnt[0]->conf.control_authentication != NULL) { ++ if (cnt[0]->conf.webcontrol_authentication != NULL) { + char *userpass = NULL; +- size_t auth_size = strlen(cnt[0]->conf.control_authentication); ++ size_t auth_size = strlen(cnt[0]->conf.webcontrol_authentication); + + authentication = (char *) mymalloc(BASE64_LENGTH(auth_size) + 1); + userpass = mymalloc(auth_size + 4); + /* base64_encode can read 3 bytes after the end of the string, initialize it */ + memset(userpass, 0, auth_size + 4); +- strcpy(userpass, cnt[0]->conf.control_authentication); ++ strcpy(userpass, cnt[0]->conf.webcontrol_authentication); + base64_encode(userpass, authentication, auth_size); + free(userpass); + } + +- while ((client_sent_quit_message) && (!closehttpd)) { ++ while ((client_sent_quit_message) && (!closehttpd)) { + + client_socket_fd = acceptnonblocking(sd, 1); + + if (client_socket_fd < 0) { +- if ((!cnt[0]) || (cnt[0]->finish)){ +- motion_log(-1, 0, "httpd - Finishing"); ++ if ((!cnt[0]) || (cnt[0]->finish)) { ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd - Finishing"); + closehttpd = 1; + } + } else { + /* Get the Client request */ +- client_sent_quit_message = read_client (client_socket_fd, cnt, authentication); +- motion_log(-1, 0, "httpd - Read from client"); ++ client_sent_quit_message = read_client(client_socket_fd, cnt, authentication); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd - Read from client"); + + /* Close Connection */ + if (client_socket_fd) +@@ -2352,17 +2528,21 @@ void httpd_run(struct context **cnt) + + } + +- if (authentication != NULL) ++ if (authentication != NULL) + free(authentication); + close(sd); +- motion_log(LOG_DEBUG, 0, "httpd Closing"); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd Closing"); + pthread_mutex_destroy(&httpd_mutex); + } + ++/** ++ * motion_web_control ++ * Calls main function httpd_run ++ */ + void *motion_web_control(void *arg) + { +- struct context **cnt=arg; ++ struct context **cnt = arg; + httpd_run(cnt); +- motion_log(LOG_DEBUG, 0, "httpd thread exit"); ++ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd thread exit"); + pthread_exit(NULL); + } +--- motion-3.2.12.orig/webhttpd.h ++++ motion-3.2.12/webhttpd.h +@@ -1,11 +1,11 @@ + /* + * webhttpd.h + * +- * Include file for webhttpd.c ++ * Include file for webhttpd.c + * +- * Specs : http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpAPI ++ * Specs : http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpAPI + * +- * Copyright 2004-2005 by Angel Carpintero (ack@telefonica.net) ++ * Copyright 2004-2005 by Angel Carpintero (motiondevelop@gmail.com) + * This software is distributed under the GNU Public License Version 2 + * See also the file 'COPYING'. + * +@@ -15,9 +15,9 @@ + + #include "motion.h" + +-#define FOSWIKI_URL "http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuideAlphabeticalOptionReferenceManual" ++#define TWIKI_URL "http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuideAlphabeticalOptionReferenceManual" + +-void * motion_web_control(void *arg); ++void * motion_web_control(void *arg); + void httpd_run(struct context **); + + #endif diff --git a/debian/patches/series b/debian/patches/series index 7cbb68a..88fa82f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,8 +1 @@ -020101107~5273773.patch -020111022~58627b0.patch -020111022~734155f.patch -020111027~5dd9ed4.patch -01_videodev.h.diff -02_libav_multiarch.patch -use-new-api.patch -copy-old-api.patch +github-changes diff --git a/debian/patches/use-new-api.patch b/debian/patches/use-new-api.patch deleted file mode 100644 index a5f59b4..0000000 --- a/debian/patches/use-new-api.patch +++ /dev/null @@ -1,165 +0,0 @@ -Description: Fix build for newer ffmpeg/libav API - Upgrade to the newer ffmpeg/libav API in current unstable Debian/DMO. This is - a cut-down version of https://github.com/sackmotion/motion/commit/0fb31d#diff-3 - which is a more proper fix (it detects versions correctly) but it does not - apply to the orig tarball in Debian. -Author: Ximin Luo -Forwarded: not-needed - ---- a/ffmpeg.c -+++ b/ffmpeg.c -@@ -89,9 +89,9 @@ - filename = colon + 1; - - -- if (flags & URL_RDWR) { -+ if (flags & AVIO_FLAG_READ_WRITE) { - access_flags = O_CREAT | O_APPEND | O_RDWR; -- } else if (flags & URL_WRONLY) { -+ } else if (flags & AVIO_FLAG_WRITE) { - access_flags = O_CREAT | O_APPEND | O_WRONLY; - } else { - access_flags = O_RDONLY; -@@ -106,10 +106,10 @@ - } - - /* URLProtocol entry for the append file protocol, which we use for mpeg1 videos -- * in order to get append behavior with url_fopen. -+ * in order to get append behavior with avio_open. - * - * Libavformat uses protocols for achieving flexibility when handling files -- * and other resources. A call to url_fopen will eventually be redirected to -+ * and other resources. A call to avio_open will eventually be redirected to - * a protocol-specific open function. - * - * The remaining functions (for writing, seeking etc.) are set in ffmpeg_init. -@@ -139,9 +139,9 @@ - - av_strstart(filename, "file:", &filename); - -- if (flags & URL_RDWR) { -+ if (flags & AVIO_FLAG_READ_WRITE) { - access_flags = O_CREAT | O_TRUNC | O_RDWR; -- } else if (flags & URL_WRONLY) { -+ } else if (flags & AVIO_FLAG_WRITE) { - access_flags = O_CREAT | O_TRUNC | O_WRONLY; - } else { - access_flags = O_RDONLY; -@@ -204,11 +204,11 @@ - static int mpeg1_write_trailer(AVFormatContext *s) - { - #if LIBAVFORMAT_BUILD >= (52<<16) -- put_buffer(s->pb, mpeg1_trailer, 4); -- put_flush_packet(s->pb); -+ avio_write(s->pb, mpeg1_trailer, 4); -+ avio_flush(s->pb); - #else -- put_buffer(&s->pb, mpeg1_trailer, 4); -- put_flush_packet(&s->pb); -+ avio_write(&s->pb, mpeg1_trailer, 4); -+ avio_flush(&s->pb); - #endif /* LIBAVFORMAT_BUILD >= (52<<16) */ - - return 0; /* success */ -@@ -403,9 +403,9 @@ - ffmpeg->video_st = NULL; - - if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { -- ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); -+ ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, 0); - if (!ffmpeg->video_st) { -- motion_log(LOG_ERR, 1, "av_new_stream - could not alloc stream"); -+ motion_log(LOG_ERR, 1, "avformat_new_stream - could not alloc stream"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } -@@ -461,13 +461,6 @@ - c->flags |= CODEC_FLAG_GLOBAL_HEADER; - } - -- /* set the output parameters (must be done even if no parameters). */ -- if (av_set_parameters(ffmpeg->oc, NULL) < 0) { -- motion_log(LOG_ERR, 0, "ffmpeg av_set_parameters error: Invalid output format parameters"); -- ffmpeg_cleanups(ffmpeg); -- return NULL; -- } -- - /* Dump the format settings. This shows how the various streams relate to each other */ - //dump_format(ffmpeg->oc, 0, filename, 1); - -@@ -488,7 +481,7 @@ - pthread_mutex_lock(&global_lock); - - /* open the codec */ -- if (avcodec_open(c, codec) < 0) { -+ if (avcodec_open2(c, codec, NULL) < 0) { - /* Release the lock. */ - pthread_mutex_unlock(&global_lock); - motion_log(LOG_ERR, 1, "avcodec_open - could not open codec"); -@@ -535,7 +528,7 @@ - char file_proto[256]; - - /* Use append file protocol for mpeg1, to get the append behavior from -- * url_fopen, but no protocol (=> default) for other codecs. -+ * avio_open, but no protocol (=> default) for other codecs. - */ - if (is_mpeg1) - snprintf(file_proto, sizeof(file_proto), APPEND_PROTO ":%s", filename); -@@ -543,7 +536,7 @@ - snprintf(file_proto, sizeof(file_proto), "%s", filename); - - -- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -+ if (avio_open(&ffmpeg->oc->pb, file_proto, AVIO_FLAG_WRITE) < 0) { - /* path did not exist? */ - if (errno == ENOENT) { - /* create path for file (don't use file_proto)... */ -@@ -553,15 +546,15 @@ - } - - /* and retry opening the file (use file_proto) */ -- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -- motion_log(LOG_ERR, 1, "url_fopen - error opening file %s",filename); -+ if (avio_open(&ffmpeg->oc->pb, file_proto, AVIO_FLAG_WRITE) < 0) { -+ motion_log(LOG_ERR, 1, "avio_open - error opening file %s",filename); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - /* Permission denied */ - } else if (errno == EACCES) { - motion_log(LOG_ERR, 1, -- "url_fopen - error opening file %s" -+ "avio_open - error opening file %s" - " ... check access rights to target directory", filename); - ffmpeg_cleanups(ffmpeg); - return NULL; -@@ -574,7 +567,7 @@ - } - - /* write the stream header, if any */ -- av_write_header(ffmpeg->oc); -+ avformat_write_header(ffmpeg->oc, NULL); - - return ffmpeg; - } -@@ -605,7 +598,7 @@ - /* - if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { - // close the output file -- if (ffmpeg->oc->pb) url_fclose(&ffmpeg->oc->pb); -+ if (ffmpeg->oc->pb) avio_close(&ffmpeg->oc->pb); - } - */ - /* free the stream */ -@@ -641,9 +634,9 @@ - if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { - /* close the output file */ - #if LIBAVFORMAT_BUILD >= (52<<16) -- url_fclose(ffmpeg->oc->pb); -+ avio_close(ffmpeg->oc->pb); - #else -- url_fclose(&ffmpeg->oc->pb); -+ avio_close(&ffmpeg->oc->pb); - #endif /* LIBAVFORMAT_BUILD >= (52<<16) */ - } - diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 51f4221..5408394 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -8,7 +8,7 @@ ############################################################ # Start in daemon (background) mode and release terminal (default: off) -daemon on +daemon off # File to store the process ID, also called pid file. (default: not defined) process_id_file /var/run/motion/motion.pid @@ -319,7 +319,7 @@ ffmpeg_deinterlace off ############################################################ # Number of motion thread to show in SDL Window (default: 0 = disabled) -sdl_threadnr 0 +#sdl_threadnr 0 ############################################################ # External pipe to video encoder @@ -419,7 +419,7 @@ text_double off # Target base directory for pictures and films # Recommended to use absolute path. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam1 +target_dir /tmp/motion # File path for snapshots (jpeg or ppm) relative to target_dir # Default: %v-%Y%m%d%H%M%S-snapshot From 6ef7c903bff2318a2033ef3fd0ed64697e848417 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 6 Sep 2014 17:24:27 -0700 Subject: [PATCH 045/233] Depoyed to ppa as 3.2.12-4ppa01~trusty --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e9aa3af..113a273 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -motion (3.2.12-4ppa01~precise) precise; urgency=low +motion (3.2.12-4ppa01~trusty) trusty; urgency=low * Nonmaintainer upload * Due to conficts, removed patches (Mr Dave) From 7cfdf13cd63378e45589650f7d20195cb7bf9936 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 9 Sep 2014 20:53:41 -0600 Subject: [PATCH 046/233] Move debian to new repo --- debian/NEWS | 7 - debian/README.Debian | 12 - debian/changelog | 673 - debian/compat | 1 - debian/control | 31 - debian/copyright | 14 - debian/dirs | 6 - debian/docs | 5 - debian/init.d | 111 - debian/motion.1 | 821 - debian/motion.conf | 736 - debian/motion.config | 12 - debian/motion.default | 3 - debian/motion.postinst | 44 - debian/motion.postinst.save | 53 - debian/motion.templates | 11 - debian/patches/github-changes | 48045 -------------------------------- debian/patches/series | 1 - debian/po/POTFILES.in | 1 - debian/po/cs.po | 55 - debian/po/da.po | 61 - debian/po/de.po | 58 - debian/po/es.po | 78 - debian/po/fr.po | 56 - debian/po/gl.po | 48 - debian/po/it.po | 51 - debian/po/ja.po | 47 - debian/po/nl.po | 49 - debian/po/pt.po | 48 - debian/po/pt_BR.po | 48 - debian/po/ru.po | 50 - debian/po/sv.po | 54 - debian/po/templates.pot | 42 - debian/po/vi.po | 42 - debian/postrm | 26 - debian/prerm | 34 - debian/rules | 108 - debian/source/format | 1 - debian/watch | 4 - 39 files changed, 51547 deletions(-) delete mode 100644 debian/NEWS delete mode 100644 debian/README.Debian delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/docs delete mode 100644 debian/init.d delete mode 100644 debian/motion.1 delete mode 100644 debian/motion.conf delete mode 100644 debian/motion.config delete mode 100644 debian/motion.default delete mode 100644 debian/motion.postinst delete mode 100644 debian/motion.postinst.save delete mode 100644 debian/motion.templates delete mode 100644 debian/patches/github-changes delete mode 100644 debian/patches/series delete mode 100644 debian/po/POTFILES.in delete mode 100644 debian/po/cs.po delete mode 100644 debian/po/da.po delete mode 100644 debian/po/de.po delete mode 100644 debian/po/es.po delete mode 100644 debian/po/fr.po delete mode 100644 debian/po/gl.po delete mode 100644 debian/po/it.po delete mode 100644 debian/po/ja.po delete mode 100644 debian/po/nl.po delete mode 100644 debian/po/pt.po delete mode 100644 debian/po/pt_BR.po delete mode 100644 debian/po/ru.po delete mode 100644 debian/po/sv.po delete mode 100644 debian/po/templates.pot delete mode 100644 debian/po/vi.po delete mode 100644 debian/postrm delete mode 100644 debian/prerm delete mode 100755 debian/rules delete mode 100644 debian/source/format delete mode 100644 debian/watch diff --git a/debian/NEWS b/debian/NEWS deleted file mode 100644 index f6d7452..0000000 --- a/debian/NEWS +++ /dev/null @@ -1,7 +0,0 @@ -motion (3.2.9-3) unstable; urgency=low - - The file motion-contro is no longer present in the package motion. If - you want more information about "API for HTTP Interface" can visit the - following URL: http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpAPI - - -- Juan Angulo Moreno Thu, 27 may 2008 20:19:56 -0430 \ No newline at end of file diff --git a/debian/README.Debian b/debian/README.Debian deleted file mode 100644 index 4cd2703..0000000 --- a/debian/README.Debian +++ /dev/null @@ -1,12 +0,0 @@ -Motion for Debian ------------------ - -Motion supports Debian's ffmpeg, but currently it encodes in SWF by -default since the latest versions of ffmpeg stripped support for mpeg1, -mpeg4, and msmpeg4 due to patents. - -You can see more in: http://packages.debian.org/changelogs/pool/main/f/ffmpeg/current/changelog - -Enjoy :) - - -- Juan Angulo Moreno Wed, 14 Nov 2007 diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 113a273..0000000 --- a/debian/changelog +++ /dev/null @@ -1,673 +0,0 @@ -motion (3.2.12-4ppa01~trusty) trusty; urgency=low - - * Nonmaintainer upload - * Due to conficts, removed patches (Mr Dave) - * Revise motion.postinst to put motion.conf at 0644 instead of 0640(Mr Dave) - * Many many changes from github repos of many many developers since 3.2.12 was released. - * - * Features - * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) - * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 - (Jeroen Massar & Angel Carpintero) - * Experimental approach for MJPEG streams (Motion JPEG) for network cameras - http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch ( ... ) - * Add draw a RED box around the movement as default (Joerg Weber) - * Add write/read nonblock functions in webhttpd( timeout on read/write). (Angel Carpintero) - * More changes in option names from http://www.lavrsen.dk/twiki/bin/view/Motion/IntuitiveOptionNamesDiscussion - (Angel Carpintero) - * motion_locate new parameter names : red , center , redcross instead of only on, off. (Angel Carpintero) - * External pipe to allow external video encoders - http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) - * Split locate_motion into separate 'mode' and 'style' option to allow all - possible combinations. (Joerg Weber) - * Implement 'gapless' event mode to allow for recording of movies without 'holes'. (Joerg Weber) - * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. (Joerg Weber) - * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. - http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 - Increased buffer in ffmpeg to allow encoding at 1600x1200 (Angel Carpintero) - * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch (Giacomo Graziosi) - * New RPM SPEC file and startup scripts compliant with Fedora 10 guidelines and above (Steven Moix) - * Increase write buffer size for writing image files and ffmpegs - http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionWriteBuffersPatch (Craig West) - * Fixed mask overlay in setup mode is now green instead of white (Joerg Weber) - * Add new config option 'ipv6_enabled' to enable/disable IPV6 (Angel Carpintero) - * Remove VIDIOC_S_JPEGCOMP support is deprecated. (Angel Carpintero) - * Use static memory allocation in ffmpeg_deinterlace() (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic - * Atom optimizacion in configure.in (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations - * Allow to change Standard method ( PAL / NECAM / SECAM ) (Angel Carpintero) - * Add authentication methods 'Basic Authentication' and 'Digest Authentication' - to the "Live Stream Server". (Michael Finsterbusch) - http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch - * Implemented new logging system - http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero) - * Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero) - * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis) - * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). - * 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) - * Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8. (Jeroen Massar) - * Added codec Ogg/Theora as new output format for regular movies. - http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) - * Added support for ffmpeg 0.11 new API. - * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) - * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) - * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) - * Buffer overflow vulnerabilities (hyperbolic2346) - * Redundand -- boundary prefix (torao) - * Removed compiler warnings: (Mr-Dave) - logger.c,jpegutils.c,netcam_ftp.c,track.c, - picture.c,webhttpd.c,stream.c,ffmpeg.c - * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) - * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) - * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) - * Resolve additional compiler warnings in ffmpeg (Mr-Dave) - * Revised INSTALL with samples(Mr-Dave) - * Revisions for RTSP and code standard.(Mr-Dave) - * Plugged most memory leaks in RTSP. (Mr-Dave) - * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) - * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) - * Regession fix for memory leaks and reconnection (Mr-Dave) - * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) - * Revised RTSP to support version 53 of libavformat (Mr-Dave) - * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) - * Revised INSTALL to have sample PI configure option.(Mr-Dave) - * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) - * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) - * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) - * Clean up the messaging for RTSP. - * Additional validations for RTSP connection and corrected free sequences - * Removed seg fault on failure to open first image, comments, isolation of RTSP - * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. - * Implement inits of AV functions from bcl fork - * Add gray image upon disconnection - * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) - * Revised comments to be in line with application standard. - * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format - * Revise version.sh to put out the git commit. - * Rollback revision to allow for a formal pull request. - * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 - * Implement requirement of modulo 16 to avoid seg fault when opening stream - * Add debian build files from trusty(14.04) - * Revise default values for motion.conf - * Revise CHANGELOG to conform with debian format - - * Bugfixes - * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) - * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 - * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) - * Avoid compile vloopback in BSD (Angel Carpintero) - * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. (Isaac Richter) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 - * 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) - * Fix introduced bug for Content-Lenght = 0 in svn r476. (Angel Carpintero) - * 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 - * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 (Angel Carpintero) - * Fix issue with JPEG , adding dinfo.do_fancy_upsampling = FALSE; - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x08x20x194659 - * Made micro-lightswitch optional (see lightwitch option in motion.conf) - * 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. - * Replace malloc() by calloc(). (Jeroen Massar) - * Free file descriptor buffers on exit. - * Avoid segfault when text_left or text_right uses non supported chars. - * Fixed leak in vloopback. - * Fixed a build of motion for some kernel version with not good videodev.h - * Netcam Modulo 8 - - -- Mr Dave Sat, 06 Sep 2014 14:26:03 -0700 - -motion (3.2.12-4) unstable; urgency=medium - - * New maintainer. - * Update for new libav/ffmpeg API. (Closes: #720814) - - -- Ximin Luo Mon, 10 Mar 2014 02:09:03 +0000 - -motion (3.2.12-3.4) unstable; urgency=low - - * Non-maintainer upload. - * Fix "No longer has support for mysql", step 2: - make build dependency on libmysqlclient-dev versioned; - 5.5.17-4 is the first upload with complete multi-arch support, as needed - by dpkg-architecture in debian/rules. - (Closes: #697221) - - -- gregor herrmann Mon, 25 Mar 2013 20:52:43 +0100 - -motion (3.2.12-3.3) unstable; urgency=low - - * Non-maintainer upload. - * Properly find MySQL in /usr/lib/$(DEB_HOST_MULTIARCH). - + Build-Depend on dpkg-dev >= 1.16 - + Get DEB_HOST_MULTIARCH from dpkg-architecture. - + Pass --with-mysql-dir=/usr/lib/$(DEB_HOST_MULTIARCH) to configure. - Closes: #697221 - - -- Evgeni Golov Thu, 03 Jan 2013 12:00:38 +0100 - -motion (3.2.12-3.2) unstable; urgency=medium - - * Non-maintainer upload. - * debian/control: update Build-Depends for libjpeg transition - - libjpeg62-dev->libjpeg-dev (Closes: #643637) - * Rebuild against current libav version (Closes: #650031) - * debian/rules: - - config.status should not depend on configure since it create it. - - -- Bill Allombert Wed, 06 Jun 2012 11:34:23 +0200 - -motion (3.2.12-3.1) unstable; urgency=low - - * * Non-maintainer upload. - * Autogenerate autotools files. Build-depend on dh-autoreconf (not - autoconf-dev). - * Add patches cherry-picked from upstream VCS and unfuzzed, to fix - linking against recent libav*. - Closes: bug#640562. Thanks to Moritz Muehlenhoff and Stephen Kitt. - * Add patch 02, to autodetect multiarch libavcodec path in autoconf. - Closes: bug#644006. Thanks to Moritz Muehlenhoff and Stephen Kitt. - * Create piddir when started (not when installed). - Closes: bug#631198. Thanks to Ibragimov Rinat. - - -- Jonas Smedegaard Sun, 12 Feb 2012 23:02:18 +0100 - -motion (3.2.12-3) unstable; urgency=low - - * Added: libv4l-dev in debian/control. - * Patch: videodev.h by libv4l1-videodev.h and videodev2.h (new format for - kernels > 2.6.38). (Closes: #621962). - * Bumped Standards-Version to 3.9.2. - * Fixed: debian-rules-missing-recommended-target in debian/rules. - * Fixed: motion creates motion gid with 1000 (Closes: #560539). - Thanks Timo Juhani Lindfors . - - -- Juan Angulo Moreno Tue, 23 Aug 2011 11:01:54 -0430 - -motion (3.2.12-2) unstable; urgency=low - - * Bumped Standards-Version to 3.9.1 - * Fixed: Depends on unversioned libmysqlclient-dev (Closes: #589011). - Thanks Angel Abad. - * Fixed: Wrong implementation of the init-functions (Closes: #580379). - * Fixed: motion randomly segfaults (Closes: #550689). - - -- Juan Angulo Moreno Sun, 08 Aug 2010 17:20:01 -0430 - -motion (3.2.12-1) unstable; urgency=low - - * New upstream version. - - -- Juan Angulo Moreno Tue, 22 Jun 2010 04:42:25 -0430 - -motion (3.2.11.1-1) unstable; urgency=low - - * New upstream version. - * Fixed: motion FTBFS with libjpeg8 (Closes: #565325) - * Fixed: group motion isn't created if user motion alredy exists - (Closes: #557416). Thanks Jean-Baptiste Lallment. - * Debconf template translation: - - Vietnamese: Update. Clytie Siddal. (Closes: #576132) - _ Italian: New. Vicenzo Campanella. (Closes: #575094) - * Fixed: Package seems to use ffmpeg-config. (Closes: #487920) - * Bumped Standards-Version to 3.8.4. - * Switch to dpkg-source 3.0 (quilt) format - - -- Juan Angulo Moreno Sat, 10 Apr 2010 10:21:49 -0430 - -motion (3.2.11-2.1) unstable; urgency=low - - * Non-maintainer upload. - * Add $remote_fs to Required-{Start|Stop} in init script - to guarantee that /usr is mounted when needed to start - and stop the daemon - * Fix pending l10n issues. Debconf translations: - * Russian (Yuri Kozlov). Closes: #538650 - * Vietnamese (Clytie Siddall). Closes: #312968 - - -- Christian Perrier Tue, 23 Mar 2010 04:57:55 +0100 - -motion (3.2.11-2) unstable; urgency=low - - * Fixed: init.d script action reload is wrong (Closes: #535769). - * Fixed: error 'file_seek' undeclared function. (Closes: #517568). - Thanks Cyril Brulebois. - * Fixed: Depends on libavcodec51 which is unavailable (Closes: #519137). - - - -- Juan Angulo Moreno Mon, 13 Jul 2009 10:39:00 -0430 - -motion (3.2.11-1) unstable; urgency=low - - * New uptream version. - * Fixed: "Don't start by default/Allow motion to be disabled" - Thanks Eddy Petrisor. (Closes: #504245). - * Removed old patch (because it is include in new upstream). - - -- Juan Angulo Moreno Thu, 22 Jan 2009 14:43:36 -0430 - -motion (3.2.9-7) unstable; urgency=low - - * Fixed: Can't install without video device present (Closes: #501462). - * Fixed: Can not install motion package (Closes: #501206). - - -- Juan Angulo Moreno Wed, 08 Oct 2008 08:24:08 -0430 - -motion (3.2.9-6) unstable; urgency=low - - * Fixed: FTBFS in MIPS. (Closes: #497634). Thanks Angel Carpintero. - * Added patch for fix V4L2 warning. Thanks Angel Carpintero. - * Fixed: Initscript errors. (Closes: #489528). Thanks Angel Carpintero. - - -- Juan Angulo Moreno Wed, 17 Sep 2008 06:03:44 -0400 - -motion (3.2.9-5) unstable; urgency=low - - * Added chgrp in debian/motion.postinst (Closes: #487568). - - -- Juan Angulo Moreno Sun, 27 Jul 2008 22:01:42 -0430 - -motion (3.2.9-4) unstable; urgency=low - - * Fixed errors in the file debian/rules that affected the non-apply of - two patches (01_ffmpeg_creation_update_API.dpatch and - 02_webhttpd_security_video2_backport.dpatch) (Closes: #484566). - * Bumped Standards-Version to 3.8.0. No changes to package necessary. - - -- Juan Angulo Moreno Tue, 10 Jun 2008 09:15:47 -0430 - -motion (3.2.9-3) unstable; urgency=low - - * Debconf translation: Galician (Closes: #484148). - Thanks Jacobo Tarrio. - * Fixed: Document removal of motion-control (Closes: #419158). - * Fixed: Bashism in debian/rules (Closes: #484410). - * Fixed: Off-by-one in webhttpd.c (Closes: #484572). - Thanks Angel Carpintero. - * Fixed: Motion crashes after some time of running - (Closes: #484566). Thanks Angel Carpintero. - * Fixed: motion.conf world readable and thus writable through web - interface by default (Closes: #484570). - - -- Juan Angulo Moreno Fri, 06 Jun 2008 23:29:02 -0430 - -motion (3.2.9-2) unstable; urgency=low - - * Add debian/prerm and debian/postrm. - * Fixed: init script hangs on startup (Closes: #461763). - * Fixed: group 'motion' already exists (Closes: #463396). - * Minor fix in debian/init.d. - - -- Juan Angulo Moreno Mon, 4 Feb 2008 21:48:32 -0430 - -motion (3.2.9-1) unstable; urgency=low - - * New maintainer. Package was orphaned (Closes: #445750). - * New upstream release (Closes: #385938). - * Add init.d script (Thanks Angel Carpintero) (Closes: #394242). - * Add user/group postinst support (Thanks Angel Carpintero) - (Closes: #328752). - * Fixed store motion-triggered movies (this is not present in the - new upstream) (Closes: #436200). - * Change deps (libavcodec0d to libavcodec-dev) and (libavformat0d - to libavformat-dev) (Closes: #427228). - * Report logs #394196 is not present in motion (See motion FAQs in: - http://www.lavrsen.dk/twiki/bin/view/Motion/FrequentlyAskedQuestions) - (Closes: #394196). - * Fixed segfault motion detection (this is not presente in the new - upstream) (Closes: #285247). - * Fixed Motion crashes/exists frequently (this is not presente in - the new upstream). (Closes: #410074). - * Added README.Debian - * motion.conf: Default ffmpeg_video_code is swf (libavcodec-dev and - libavformat-dev don't have support to mpeg in Debian). See changelog - ffmpeg-free. - * Fixed debian/watch. - * Fixed motion manpage. - * Delete motion.preinst and added motion.config (with debconf rules). - * Debconf translations: - - Brazilian Portuguese (Closes: #447013). - - Portuguese (Closes: #425774). - - Dutch (Closes: #415512). - - -- Juan Angulo Moreno Wed, 14 Nov 2007 15:14:33 -0400 - -motion (3.2.3-2.1) unstable; urgency=low - - * Non-maintainer upload to fix pending l10n issues. - * Debconf translations: - - Spanish. Closes: #404800 - - Japanese. Closes: #413003 - - -- Christian Perrier Thu, 1 Mar 2007 19:43:13 +0100 - -motion (3.2.3-2) unstable; urgency=medium - - * Acknowledgement of patch submitted by Loic Minier - (part of NMU motion 3.2.3-1.1) (Closes: #391069). - * Security: Set parameter target_dir in /etc/motion/motion.conf - to /var/lib/motion/snapshots + make small NOTE in - README.Debian (Closes: #393846). - * Add var/lib/motion/snapshots to debian/motion.dirs file. - * Change build dependency from postgresql-dev (obsolete) - to libpq-dev (Closes: #396566). - * Remove weird/improper character (looks like a pipe, but isn't) in motion - manpage on line 428 and 433. Also add an extra backslash to '\n' on - line 428, 433 and 610 (Closes: #374636). - * Make comment in manpage that when calling motion with -d (for debugging) - -c must also be specified explicitly. - * Add parameters 'threshold' and 'noise_level' to the - default configuration file + add punctuation marks (.) - at the end of all comment lines. - * Bumped Standards-Version to 3.7.2. No changes to package necessary. - - -- Frederik Dannemare Thu, 3 Nov 2006 09:41:23 +0100 - -motion (3.2.3-1.1) unstable; urgency=high - - * Non-maintainer upload. - * Pass -DFFMPEG_AVWRITEFRAME_NEWAPI to CFLAGS. closes: #389304 - - -- Loic Minier Wed, 4 Oct 2006 19:09:45 +0200 - -motion (3.2.3-1) unstable; urgency=low - - * New upstream release (Closes: #341482). - - Build problems regarding non-existent members - of AVCodecContext are fixed (Closes: #323736). - * Enable ffmpeg_video_codec msmpeg4 in motion.conf (Closes: #299953). - * Depend on debconf | debconf-2.0 (not just debconf) (Closes: #332030). - * Adjust minimal configure patch to apply cleanly against new upstream - configure file (include libs -lvorbis -lvorbisenc -ldts -la52). - * Build against libpq4 (Closes: #343209). - * Build against libmysqlclient15-dev (Closes: #343778). - * Remove Build-Depends on libxmlrpc-c3-dev and libcurl3-dev (xmlrpc - is deprecated in 3.x in favor of a new http interface to control motion). - * Remove xmlrpc-api.html from debian/motion.docs. - * Add --without-optimizecpu to configure. - * Include Czech debconf translation - by Miroslav Kure (Closes: #308023). - * Include Swedish debconf translation - by Daniel Nylander (Closes: #330538). - * Include Vietnamese debconf translation - by Clytie Siddall (Closes: #312968). - * Upload sponsored by Ari Pollak . - - -- Frederik Dannemare Wed, 14 Dec 2005 20:24:35 +0100 - -motion (3.1.19-1) unstable; urgency=low - - * New upstream release (Closes: #297671). - * Add support for ffmpeg (add Build-Depends on libavcodec-dev and - libavformat-dev). - * Update debian/README.Debian to mention the new support for ffmpeg. - * Remove debian/motion.menu (didn't make much sense really). - * Get rid of direct patching of upstream sources. Instead, apply - Debian-specific modifications at build-time from patches in debian/patches - with help from dpatch (add Build-Depends on dpatch). - * Remove Suggests on ucbmpeg (Closes: #279385). - * Add Recommends on ffmpeg. - * Include German po-debconf translation by Jens Nachtigall - (Closes: #283017). - * Patch configure to really remove rpath + add -lvorbis -lvorbisenc -ldts - -la52 to LIBS. Thanks to Sam Hocevar (ffmpeg maintainer) for hints on - how to properly build with ffmpeg support. - * Upload sponsored by Ari Pollak . - - -- Frederik Dannemare Wed, 14 Mar 2005 01:03:18 +0100 - -motion (3.1.17-1) unstable; urgency=low - - * New upstream release (Closes: #273652). - * Add motion_guide.html and xmlrpc-api.html to debian/motion.docs. - * Remove debian/motion.postrm, since debhelper automatically - handles the stuff that was in that file. - * Upload sponsored by Ari Pollak . - - -- Frederik Dannemare Fri, 29 Oct 2004 22:56:26 +0200 - -motion (3.1.14-2) unstable; urgency=low - - * Only prompt user with debconf info, if an earlier version of motion has - already been installed (Closes: #263717). - * Include French po-debconf translation by Olivier Trichet - (Closes: #264549). - * Update debian/watch file. - - -- Frederik Dannemare Tue, 10 Aug 2004 21:34:16 +0200 - -motion (3.1.14-1) unstable; urgency=low - - * New upstream release. - * New maintainer. Package was orphaned (Closes: #254336). - * Remove mentioning of included ffmpeg in README.Debian. - * Remove out-of-date debian/TODO file. - * Update debian/control file to reflect new maintainership. - * Update package description in debian/control. - * Remove tar from Build-Depends, since it is already build-essential. - * Add CREDITS to debian/docs. - * Add extra documentation files (listed in debian/motion.docs). - * Add example config files (listed in debian/motion.examples). - * Add manpage for motion-control binary. - * Update debian/rules (working from a much more recent template). - * Use /etc/motion (instead of /etc) af sysconfdir. - * Add use of gettext-based debconf templates. - * Add debconf to Depends in debian/control. - * Add po-debconf to Build-Depends in debian/control. - * Add /etc/motion/motion.conf to debian/motion.conffiles. - * Edit Makefile.in to make files install into their correct locations. - * Edit configure/configure.in to avoid use of rpath. - * Upload sponsored by Matthias Urlichs . - - -- Frederik Dannemare Mon, 29 Jul 2004 21:22:24 +0200 - -motion (3.0.6-0.1) unstable; urgency=low - - * NMU of newer upstream version (closes: Bug#211578). - * Remove all traces of ffmpeg (closes: Bug#215626). - * Remove unused debian/debian/ dir. - * Update copyright and watch file to (only) use new home - http://motion.sourceforge.net/ . - * Build-depend on debhelper >= 3 (as already set in debian/rules - DH_COMPAT) and remove debian/conffiles. This makes lintian - (somewhat) happier. - - -- Jonas Smedegaard Mon, 13 Oct 2003 22:14:51 +0200 - -motion (3.0.4-2) unstable; urgency=low - - * Builing with curl library for axis users - - -- Paul Hedderly Wed, 25 Sep 2002 21:56:47 +0100 - -motion (3.0.4-1) unstable; urgency=low - - * New upstream release - * Removed build-dependancy on libffmpeg - it's included in the - source... (Closes: #152971) - * Installing the "Motion Guide" by Kenneth Lavrsen. - * Added some missed build-depends... - - -- Paul Hedderly Mon, 26 Aug 2002 20:08:24 +0100 - -motion (3.0.3-1) unstable; urgency=low - - * New upstream release - - -- Paul Hedderly Fri, 12 Jul 2002 07:37:49 +0100 - -motion (3.0.2-2) unstable; urgency=low - - * Included ffmpeg-0.4.5 source in the build - provides static library - and motion-ffmpeg and motion-ffserver... this is a stopgap until - proper ffmpeg packages are in Debian. - - -- Paul Hedderly Fri, 5 Jul 2002 12:51:54 +0100 - -motion (3.0.2-1) unstable; urgency=low - - * New upstream release - - -- Paul Hedderly Wed, 3 Jul 2002 20:12:13 +0100 - -motion (3.0.1-1) unstable; urgency=low - - * New upstream release - - -- Paul Hedderly Wed, 3 Jul 2002 20:09:57 +0100 - -motion (3.0.0-3) unstable; urgency=low - - * Fixed some new Makefile tweaks - docs/examples go to the right place - - -- Paul Hedderly Wed, 3 Jul 2002 20:06:28 +0100 - -motion (3.0.0-2) unstable; urgency=low - - * Fixed the default path for mpeg_encode. - - -- Paul Hedderly Sat, 22 Jun 2002 21:17:17 +0100 - -motion (3.0.0-1) unstable; urgency=low - - * New upstream release. - - -- Paul Hedderly Sat, 15 Jun 2002 20:16:56 +0100 - -motion (2.6.3-4) unstable; urgency=low - - * Fixed the menu option - - -- Paul Hedderly Tue, 20 Nov 2001 19:57:07 +0000 - -motion (2.6.3-3) unstable; urgency=low - - * Added a patch to do yuv conversion for VAIO laptops (cheers Joey, - sorry it took so long - and I hope it works...) - Closes #99941 - - -- Paul Hedderly (DH/DSS) Tue, 13 Nov 2001 15:53:43 +0000 - -motion (2.6.3-2) unstable; urgency=low - - * Upgraded the package to be Standards version 3.5.2 compatible and lintian clean - * New version... Closes: #100025,#100658,#113912 - - -- Paul Hedderly (DH/DSS) Tue, 13 Nov 2001 09:26:34 +0000 - -motion (2.6.3-1) unstable; urgency=low - - * New release - actually... several new releases. Sorry for my - non-release: I lost access to any way to use/test this software. - - -- Paul Hedderly (DH/DSS) Mon, 8 Oct 2001 15:01:05 +0100 - -motion (2.3-10) unstable; urgency=low - - * Uploading to debian - (Closes: #77018) - - -- Paul Hedderly (DH/DSS) Thu, 7 Dec 2000 12:45:47 +0000 - -motion (2.3-9) unstable; urgency=low - - * Tidied up some document handling; only need one copy of the changelog - - -- Paul Hedderly (DH/DSS) Thu, 7 Dec 2000 11:36:05 +0000 - -motion (2.3-8) unstable; urgency=low - - * New maintainer address - I'm now a DD. - - -- Paul Hedderly (DH/DSS) Thu, 7 Dec 2000 11:12:13 +0000 - -motion (2.3-7) unstable; urgency=low - - * Removed motion.5 link - It's not needed? - * Remove /usr/sbin from debian/dirs - not needed any more - - Thanks to Paul Slootman, whos nose smells out every smelly - old problem :O) - - -- Paul Hedderly (DH/DSS) Tue, 28 Nov 2000 15:38:27 +0000 - -motion (2.3-6) unstable; urgency=low - - * Added build dependancy on libmysqlclient10-dev. It doesn't actually - depend on that library to build - unless you want all the available - functionality. Motion does not need mysql to run. - * Added binary suggests: mysql-client. - - -- Paul Hedderly (DH/DSS) Fri, 17 Nov 2000 11:32:13 +0000 - -motion (2.3-5) unstable; urgency=low - - * Moved man pages to share - * Added debhelper to build-depends - * Removed *ex* files which were removed from CVS... but oh well - - Thanks to Martin Michlmayr for his hints. - - -- Paul Hedderly (DH/DSS) Thu, 16 Nov 2000 11:40:25 +0000 - -motion (2.3-4) unstable; urgency=low - - * Removed my mods to Makefile.in - rules does some munging... - * Remove .ex files which will not be needed - * Misc doc updates - - -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 22:12:11 +0000 - -motion (2.3-3) unstable; urgency=low - - * Made the Makefile.in install motion.conf in /etc (it is - defined to dpkg as a conffile so should be safe during upgrades) - - -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 15:10:44 +0000 - -motion (2.3-2) unstable; urgency=low - - * Commented out a few dh_* calls from rules which are currently superfluous - * Tidied up Makefiles.in - use what's already there with minor modifications - - -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 14:03:39 +0000 - -motion (2.3-1) unstable; urgency=low - - * New upstream release - - -- Paul Hedderly (DH/DSS) Tue, 14 Nov 2000 11:18:44 +0000 - -motion (2.0-3) unstable; urgency=low - - * Fixed the makefile - put docs in the right place... - - -- Paul Hedderly (DH/DSS) Wed, 20 Sep 2000 13:11:46 +0100 - -motion (2.0-2) unstable; urgency=low - - * Changed Makefile.in to put docs in /usr/share.... - * Created blank contrib directory and dummy to make install happy - - -- Paul Hedderly (DH/DSS) Wed, 20 Sep 2000 13:08:44 +0100 - -motion (2.0-1) unstable; urgency=low - - * Initial Release. - * My first DebHelper'd debian conversion! - * Trying it with NO original source changes... - - -- Paul Hedderly (DH/DSS) Wed, 20 Sep 2000 12:39:09 +0100 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 1e8b314..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -6 diff --git a/debian/control b/debian/control deleted file mode 100644 index 1a31bc8..0000000 --- a/debian/control +++ /dev/null @@ -1,31 +0,0 @@ -Source: motion -Section: graphics -Priority: optional -Maintainer: Ximin Luo -HomePage: http://motion.sf.net -Build-Depends: debhelper (>= 6), dpkg-dev (>= 1.16), dh-autoreconf, libjpeg-dev, zlib1g-dev, libavcodec-dev, libavformat-dev, libpq-dev, libmysqlclient-dev (>= 5.5.17-4), libv4l-dev, libswscale-dev -Standards-Version: 3.9.2 - -Package: motion -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, debconf -Recommends: ffmpeg -Suggests: mysql-client, postgresql-client -Description: V4L capture program supporting motion detection - Motion is a program that monitors the video signal from - one or more cameras and is able to detect if a significant - part of the picture has changed. Or in other words, it can - detect motion. - . - Motion is a command line based tool. It has no graphical - user interface. Everything is setup either via the - command line or via configuration files. - . - The output from motion can be: - - jpg files - - ppm format files - - mpeg video sequences - . - Also, motion has its own minimalistic web server. Thus, - you can access the webcam output from motion via a browser. - diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index eac7164..0000000 --- a/debian/copyright +++ /dev/null @@ -1,14 +0,0 @@ -This package was originally debianized by Paul Hedderly (DH/DSS) -on Wed, 20 Sep 2000 12:39:09 +0100. - -Package is currently maintained by Juan Angulo Moreno since -Thu, 01 Jun 2007 16:47:33 -0400. - -Upstream source: http://motion.sourceforge.net/ - -Upstream Author: Kenneth Lavrsen - -Copyright: 2000-2004 by Jeroen Vreeken/Folkert Van Heusden/Kenneth Lavrsen - -This software is released under the GNU GENERAL PUBLIC LICENSE Version 2. -See /usr/share/common-licenses/GPL-2 for details. diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index 74f52d2..0000000 --- a/debian/dirs +++ /dev/null @@ -1,6 +0,0 @@ -usr/bin -usr/share/man/man1 -etc/motion -etc/init.d -etc/default - diff --git a/debian/docs b/debian/docs deleted file mode 100644 index 9af2035..0000000 --- a/debian/docs +++ /dev/null @@ -1,5 +0,0 @@ -FAQ -README -README.axis_2100 -CREDITS -motion_guide.html diff --git a/debian/init.d b/debian/init.d deleted file mode 100644 index ac29630..0000000 --- a/debian/init.d +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -e -# -# /etc/init.d/motion: Start the motion detection -# -### BEGIN INIT INFO -# Provides: motion -# Required-Start: $local_fs $syslog $remote_fs -# Required-Stop: $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start Motion detection -# Description: loads motion and assigns privileges -### END INIT INFO - -# Ported to new debian way using sh and /lib/lsb/init-functions -# by Angel Carpintero -# Modified by : Juan Angulo Moreno -# Eddy Petrisor -# ArAge - -NAME=motion -PATH_BIN=/bin:/usr/bin:/sbin:/usr/sbin -DAEMON=/usr/bin/motion -PIDFILE=/var/run/$NAME.pid -DEFAULTS=/etc/default/$NAME -DESC="motion detection daemon" - -ENV="env -i LANG=C PATH=$PATH_BIN" - -. /lib/lsb/init-functions - -test -x $DAEMON || exit 0 - -RET=0 - -[ -r "$DEFAULTS" ] && . "$DEFAULTS" || start_motion_daemon=yes - - -check_daemon_enabled () { - if [ "$start_motion_daemon" = "yes" ] ; then - return 0 - else - log_warning_msg "Not starting $NAME daemon, disabled via /etc/default/$NAME" - return 1 - fi - -} - - -case "$1" in - start) - if check_daemon_enabled ; then - if ! [ -d /var/run/motion ]; then - mkdir /var/run/motion - fi - chown motion:motion /var/run/motion - - log_daemon_msg "Starting $DESC" "$NAME" -if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then - log_end_msg 0 - else - log_end_msg 1 - RET=1 - fi - fi - ;; - - stop) - log_daemon_msg "Stopping $DESC" "$NAME" - if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30 ; then - log_end_msg 0 - else - log_end_msg 1 - RET=1 - fi - ;; - - reload|force-reload) - log_daemon_msg "Reloading $NAME configuration" - if start-stop-daemon --stop --signal HUP --exec $DAEMON ; then - log_end_msg 0 - else - log_end_msg 1 - RET=1 - fi - ;; - - restart-motion) - if check_daemon_enabled ; then - log_action_begin_msg "Restarting $NAME" - if $0 stop && $0 start ; then - log_action_end_msg 0 - else - log_action_cont_msg "(failed)" - RET=1 - fi - fi - ;; - - restart) - $0 restart-motion - ;; - - *) - echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}" - RET=1 - ;; -esac - - -exit $RET diff --git a/debian/motion.1 b/debian/motion.1 deleted file mode 100644 index 44a9674..0000000 --- a/debian/motion.1 +++ /dev/null @@ -1,821 +0,0 @@ -.TH MOTION 1 2007-11-06 "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 level ] [ -p process_id_file ] -.SH DESCRIPTION -.I Motion -uses a video4linux device to detect motion. If motion is detected both normal -and motion pictures will be taken. Motion can also take actions to notify you -if needed. Creation of automated snapshots is also possible. -.SH OPTIONS -.TP -.B \-c -Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default. -.TP -.B \-h -Show help screen. -.TP -.B \-n -Run in non-daemon mode. -.TP -.B \-s -Run in setup mode. Also forces non-daemon mode -.TP -.B \-d level -Run in debug mode, level 1-9. -.TP -.B \-p -Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. -.TP -.SH "CONFIG FILE OPTIONS" -These are the options that can be used in the config file. -.I They are overridden by the commandline! -All number values are integer numbers (no decimals allowed). -Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). - -.TP -.B auto_brightness boolean -Values: on, off / Default: off -.br -Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness -.TP -.B brightness integer -Values: 0 - 255 / Default: 0 (disabled) -.br -The brightness level for the video device. -.TP -.B contrast boolean -Values: 0 - 255 / Default: 0 (disabled) -.br -The contrast level for the video device. -.TP -.B control_authentication string -Values: Max 4096 characters / Default: Not defined -.br -To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. -.TP -.B control_html_output boolean -Values: on, off / Default: on -.br -Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. -.TP -.B control_localhost boolean -Values: on, off / Default: on -.br -Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. -.TP -.B control_port integer -Values: 0 - 65535 / Default: 0 (disabled) -.br -Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. -.TP -.B daemon boolean -Values: on, off / Default: off -.br -Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. -.TP -.B despeckle string -Values: EedDl / Default: Not defined -.br -Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. -.TP -.B ffmpeg_bps integer -Values: 0 - 9999999 / Default: 400000 -.br -Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. -.TP -.B ffmpeg_cap_motion boolean -Values: on, off / Default: off -.br -Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. -.TP -.B ffmpeg_cap_new boolean -Values: on, off / Default: off -.br -Use ffmpeg libraries to encode mpeg movies in realtime. -.TP -.B ffmpeg_deinterlace boolean -Values: on, off / Default: off -.br -Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. -.TP -.B ffmpeg_timelapse boolean -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. -.TP -.B ffmpeg_timelapse_mode discrete strings -Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual / Default: daily -.br -The file rollover mode of the timelapse video. -.TP -.B ffmpeg_variable_bitrate integer -Values: 0, 2 - 31 / Default: 0 (disabled) -.br -Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. -.TP -.B ffmpeg_video_codec discrete strings -Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1 / Default: mpeg4 -.br -Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. -.TP -.B framerate integer -Values: 2 - 100 / Default: 100 (no limit) -.br -Maximum number of frames to be captured from the camera per second. -.TP -.B frequency boolean -Values: 0 - 999999 / Default: 0 (Not set) -.br -The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) -.TP -.B gap integer -Values: 0 - 2147483647 / Default: 60 -.br -Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. -.TP -.B height integer -Values: Device Dependent / Default: 288 -.br -The height of each frame in pixels. -.TP -.B hue integer -Values: 0 - 255 / Default: 0 (disabled) -.br -The hue level for the video device. -.TP -.B input integer -Values: 0 - 7, 8 = disabled / Default: 8 (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. -.TP -.B jpeg_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q -.br -File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. -.TP -.B lightswitch integer -Values: 0 - 100 / Default: 0 (disabled) -.br -Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. -.TP -.B locate boolean -Values: on, off, preview / Default: off -.br -Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. -.TP -.B low_cpu integer -Values: 0 - 100 / Default: 0 (disabled) -.br -When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. -.TP -.B mask_file string -Values: Max 4095 characters / Default: Not defined -.br -PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. -.TP -.B max_mpeg_time integer -Values: 0 (infinite) - 2147483647 / Default: 3600 -.br -The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. -.TP -.B minimum_frame_time integer -Values: 0 - 2147483647 / Default: 0 -.br -Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. -.TP -.B minimum_motion_frames boolean -Values: 1 - 1000s / Default: 1 -.br -Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. -.TP -.B motion_video_pipe string -Values: Max 4095 characters / Default: Not defined -.br -The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set -.TP -.B movie_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S -.br -File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. -.TP -.B mysql_db string -Values: Max 4095 characters / Default: Not defined -.br -Name of the MySQL database. -.TP -.B mysql_host string -Values: Max 4095 characters / Default: localhost -.br -IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. -.TP -.B mysql_password string -Values: Max 4095 characters / Default: Not defined -.br -The MySQL password. -.TP -.B mysql_user string -Values: Max 4095 characters / Default: Not defined -.br -The MySQL user name. -.TP -.B netcam_proxy string -Values: Max 4095 characters / Default: Not defined -.br -URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber -.TP -.B netcam_url string -Values: Max 4095 characters / Default: Not defined -.br -Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. -.TP -.B netcam_userpass string -Values: Max 4095 characters / Default: Not defined -.br -For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. -.TP -.B night_compensate boolean -Values: on, off / Default: off -.br -When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. -.TP -.B noise_level integer -Values: 1 - 255 / Default: 32 -.br -The noise level is used as a threshold for distinguishing between noise and motion. -.TP -.B noise_tune boolean -Values: on, off / Default: on -.br -Activates the automatic tuning of noise level. -.TP -.B norm discrete strings -Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) / Default: 0 (PAL) -.br -Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) -.TP -.B on_event_end string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. -.TP -.B on_event_start string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. -.TP -.B on_motion_detected string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. -.TP -.B on_movie_end string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B on_movie_start string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B on_picture_save string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B output_all boolean -Values: on, off / Default: off -.br -Picture are saved continuously as if motion was detected all the time. -.TP -.B output_motion boolean -Values: on, off / Default: off -.br -Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. -.TP -.B output_normal discrete strings -Values: on, off, first, best / Default: on -.br -Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. -.TP -.B pgsql_db string -Values: Max 4095 characters / Default: Not defined -.br -Name of the PostgreSQL database. -.TP -.B pgsql_host string -Values: Max 4095 characters / Default: localhost -.br -IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. -.TP -.B pgsql_password string -Values: Max 4095 characters / Default: Not defined -.br -The PostgreSQL password. -.TP -.B pgsql_port integer -Values: 0 - 65535 / Default: 5432 -.br -The PostgreSQL server port number. -.TP -.B pgsql_user string -Values: Max 4095 characters / Default: Not defined -.br -The PostgreSQL user name. -.TP -.B post_capture integer -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Specifies the number of frames to be captured after motion has been detected. -.TP -.B ppm boolean -Values: on, off / Default: off -.br -Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. -.TP -.B pre_capture integer -Values: 0 - 100s / Default: 0 (disabled) -.br -Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. -.TP -.B process_id_file string -Values: Max 4095 characters / Default: Not defined -.br -File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid -.TP -.B quality integer -Values: 1 - 100 / Default: 75 -.br -The quality for the jpeg images in percent. -.TP -.B quiet boolean -Values: on, off / Default: off -.br -Be quiet, don't output beeps when detecting motion. -.TP -.B rotate discrete strings -Values: 0, 90, 180, 270 / Default: 0 (not rotated) -.br -Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. -.TP -.B roundrobin_frames integer -Values: 1 - 2147483647 / Default: 1 -.br -Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. -.TP -.B roundrobin_skip integer -Values: 1 - 2147483647 / Default: 1 -.br -Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). -.TP -.B saturation integer -Values: 0 - 255 / Default: 0 (disabled) -.br -The colour saturation level for the video device. -.TP -.B setup_mode boolean -Values: on, off / Default: off -.br -Run Motion in setup mode. -.TP -.B smart_mask_speed integer -Values: 0 - 10 / Default: 0 (disabled) -.br -Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. -.TP -.B snapshot_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-snapshot -.br -File path for snapshots (jpeg or ppm) relative to target_dir. -.TP -.B snapshot_interval integer -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Make automated snapshots every 'snapshot_interval' seconds. -.TP -.B sql_log_image boolean -Values: on, off / Default: on -.br -Log to the database when creating motion triggered image file. -.TP -.B sql_log_mpeg boolean -Values: on, off / Default: off -.br -Log to the database when creating motion triggered mpeg file. -.TP -.B sql_log_snapshot boolean -Values: on, off / Default: on -.br -Log to the database when creating a snapshot image file. -.TP -.B sql_log_timelapse boolean -Values: on, off / Default: off -.br -Log to the database when creating timelapse mpeg file -.TP -.B sql_query string -Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -.br -SQL query string that is sent to the database. The values for each field are given by using convertion specifiers -.TP -.B switchfilter boolean -Values: on, off / Default: off -.br -Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. -.TP -.B target_dir string -Values: Max 4095 characters / Default: Not defined = current working directory -.br -Target directory for picture and movie files. -.TP -.B text_changes boolean -Values: on, off / Default: off -.br -Turns the text showing changed pixels on/off. -.TP -.B text_double boolean -Values: on, off / Default: off -.br -Draw characters at twice normal size on images. -.TP -.B text_event string -Values: Max 4095 characters / Default: %Y%m%d%H%M%S -.br -This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. -.TP -.B text_left string -Values: Max 4095 characters / Default: Not defined -.br -User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ -and conversion specifiers (codes starting by a %). -.TP -.B text_right string -Values: Max 4095 characters / Default: %Y-%m-%d\n%T -.br -User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ -and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -.TP -.B thread string -Values: Max 4095 characters / Default: Not defined -.br -Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file. -.TP -.B threshold integer -Values: 1 - 2147483647 / Default: 1500 -.br -Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. -.TP -.B threshold_tune boolean -Values: on, off / Default: off -.br -Activates the automatic tuning of threshold level. -.TP -.B timelapse_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d-timelapse -.br -File path for timelapse mpegs relative to target_dir (ffmpeg only). -.TP -.B track_auto boolean -Values: on, off / Default: off -.br -Enable auto tracking -.TP -.B track_iomojo_id integer -Values: 0 - 2147483647 / Default: 0 -.br -Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. -.TP -.B track_maxx integer -Values: 0 - 2147483647 / Default: 0 -.br -The maximum position for servo x. -.TP -.B track_maxy integer -Values: 0 - 2147483647 / Default: 0 -.br -The maximum position for servo y. -.TP -.B track_motorx integer -Values: -1 - 2147483647 / Default: -1 -.br -The motor number that is used for controlling the x-axis. -.TP -.B track_motory integer -Values: -1 - 2147483647 / Default: -1 -.br -The motor number that is used for controlling the y-axis. -.TP -.B track_move_wait integer -Values: 0 - 2147483647 / Default: 10 -.br -Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. -.TP -.B track_port string -Values: Max 4095 characters / Default: Not defined -.br -This is the device name of the serial port to which the stepper motor interface is connected. -.TP -.B track_speed integer -Values: 0 - 255 / Default: 255 -.br -Speed to set the motor to. -.TP -.B track_step_angle_x integer -Values: 0-90 / Default: 10 -.br -Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. -.TP -.B track_step_angle_y integer -Values: 0-40 / Default: 10 -.br -Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. -.TP -.B track_stepsize integer -Values: 0 - 255 / Default: 40 -.br -Number of steps to make. -.TP -.B track_type discrete strings -Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) -.br -Type of tracker. -.TP -.B tunerdevice string -Values: Max 4095 characters / Default: /dev/tuner0 -.br -The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. -.TP -.B video_pipe string -Values: Max 4095 characters / Default: Not defined -.br -The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. -.TP -.B videodevice string -Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) -.br -The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. -.TP -.B webcam_limit integer -Values: 0 - 2147483647 / Default: 0 (unlimited) -.br -Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. -.TP -.B webcam_localhost boolean -Values: on, off / Default: on -.br -Limits the access to the webcam to the localhost. -.TP -.B webcam_maxrate integer -Values: 1 - 100 / Default: 1 -.br -Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. -.TP -.B webcam_motion boolean -Values: on, off / Default: off -.br -If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. -.TP -.B webcam_port integer -Values: 0 - 65535 / Default: 0 (disabled) -.br -TCP port on which motion will listen for incoming connects with its webcam server. -.TP -.B webcam_quality integer -Values: 1 - 100 / Default: 50 -.br -Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. -.TP -.B width integer -Values: Device Dependent / Default: 352 -.br -The width in pixels of each frame. Valid range is camera dependent. - -.SH SIGNALS -Motion responds to the following signals: -.TP -.B SIGHUP -The config file will be reread. -.TP -.B SIGTERM -If needed motion will create an mpeg file of the last event and exit -.TP -.B SIGUSR1 -Motion will create an mpeg file of the current event. -.SH NOTES -.TP -.B Snapshot -A snapshot is a picture taken at regular intervals independently of any movement in the picture. -.TP -.B Motion image -A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. -.TP -.B Normal image -A "normal" image is the real image taken by the camera with text overlayed. -.TP -.B Threads and config files -If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. -.br -If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: -.br -1. Current directory from where motion was invoked -.br -2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf -.br -3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) -.br -If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. -.br -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. -.br -The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. -.br -If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. -.br -So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. -.br -An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). -.br -An option that is unique to a camera must be defined in each thread file. -.br -The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. -.br -Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. -.br -Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins. -.br -1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. -.br -2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. -.br -3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. -.br -4. Motion reads the command line option again overruling any previously defined options. -.br -So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. -.br -If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. -.br -If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. -.TP -.B Conversion Specifiers for Advanced Filename and Text Features -The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. -.br -In text_left and text_right you can additionally use '\n' for new line. - -.TP -.B %a -The abbreviated weekday name according to the current locale. -.TP -.B %A -The full weekday name according to the current locale. -.TP -.B %b -The abbreviated month name according to the current locale. -.TP -.B %B -The full month name according to the current locale. -.TP -.B %c -The preferred date and time representation for the current locale. -.TP -.B %C -Text defined by the text_event feature -.TP -.B %d -The day of the month as a decimal number (range 01 to 31). -.TP -.B %D -Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. -.TP -.B %E -Modifier: use alternative format, see below. -.TP -.B %f -File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. -.TP -.B %F -Equivalent to %Y-%m-%d (the ISO 8601 date format). -.TP -.B %H -The hour as a decimal number using a 24-hour clock (range 00 to 23). -.TP -.B %i -Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). -.TP -.B %I -The hour as a decimal number using a 12-hour clock (range 01 to 12). -.TP -.B %j -The day of the year as a decimal number (range 001 to 366). -.TP -.B %J -Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). -.TP -.B %k -The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) -.TP -.B %K -X coordinate in pixels of the center point of motion. Origin is upper left corner. -.TP -.B %l -The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) -.TP -.B %L -Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). -.TP -.B %m -The month as a decimal number (range 01 to 12). -.TP -.B %M -The minute as a decimal number (range 00 to 59). -.TP -.B %n -Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. -.TP -.B %N -Noise level. -.TP -.B %o -Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. -.TP -.B %p -Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. -.TP -.B %P -Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. -.TP -.B %q -Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. -.TP -.B %Q -Number of detected labels found by the despeckle feature -.TP -.B %r -The time in a.m. or p.m. notation. -.TP -.B %R -The time in 24-hour notation (%H:%M). -.TP -.B %s -The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. -.TP -.B %S -The second as a decimal number (range 00 to 61). -.TP -.B %t -Thread number (camera number) -.TP -.B %T -The time in 24-hour notation (%H:%M:%S). -.TP -.B %u -The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. -.TP -.B %U -The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. -.TP -.B %v -Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. -.TP -.B %V -The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. -.TP -.B %w -The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. -.TP -.B %W -The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. -.TP -.B %x -The preferred date representation for the current locale without the time. -.TP -.B %X -The preferred time representation for the current locale without the date. -.TP -.B %y -The year as a decimal number without a century (range 00 to 99). -.TP -.B %Y -The year as a decimal number including the century. -.TP -.B %z -The time-zone as hour offset from GMT. -.TP -.B %Z -The time zone or name or abbreviation. - -.TP -.B More information -Motion homepage: http://motion.sourceforge.net/ - -Motion Guide (user and installation guide): -.br http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide -.br http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice -.SH AUTHORS -Jeroen Vreeken (pe1rxq@amsat.org), -Folkert van Heusden, -Kenneth Lavrsen (kenneth@lavrsen.dk) -Juan Angulo Moreno diff --git a/debian/motion.conf b/debian/motion.conf deleted file mode 100644 index 10b9e28..0000000 --- a/debian/motion.conf +++ /dev/null @@ -1,736 +0,0 @@ -# Rename this distribution example file to motion.conf -# -# This config file was generated by motion 3.2.12-4ppa01 - - -############################################################ -# Daemon -############################################################ - -# Start in daemon (background) mode and release terminal (default: off) -daemon off - -# File to store the process ID, also called pid file. (default: not defined) -process_id_file /var/run/motion/motion.pid - -############################################################ -# Basic Setup Mode -############################################################ - -# Start in Setup-Mode, daemon disabled. (default: off) -setup_mode off - - -# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) -;logfile /tmp/motion.log - -# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -log_level 6 - -# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -log_type all - -########################################################### -# Capture device options -############################################################ - -# Videodevice to be used for capturing (default /dev/video0) -# for FreeBSD default is /dev/bktr0 -videodevice /dev/video0 - -# v4l2_palette allows to choose preferable palette to be use by motion -# to capture from those supported by your videodevice. (default: 17) -# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and -# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. -# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 -# instead. -# -# Values : -# V4L2_PIX_FMT_SN9C10X : 0 'S910' -# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -# V4L2_PIX_FMT_SPCA561 : 3 'S561' -# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -# V4L2_PIX_FMT_PAC207 : 6 'P207' -# V4L2_PIX_FMT_PJPG : 7 'PJPG' -# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -# V4L2_PIX_FMT_JPEG : 9 'JPEG' -# V4L2_PIX_FMT_RGB24 : 10 'RGB3' -# V4L2_PIX_FMT_SPCA501 : 11 'S501' -# V4L2_PIX_FMT_SPCA505 : 12 'S505' -# V4L2_PIX_FMT_SPCA508 : 13 'S508' -# V4L2_PIX_FMT_UYVY : 14 'UYVY' -# V4L2_PIX_FMT_YUYV : 15 'YUYV' -# V4L2_PIX_FMT_YUV422P : 16 '422P' -# V4L2_PIX_FMT_YUV420 : 17 'YU12' -# -v4l2_palette 17 - -# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) -# This is ONLY used for FreeBSD. Leave it commented out for Linux -; tunerdevice /dev/tuner0 - -# 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) -norm 0 - -# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) -frequency 0 - -# Rotate image this number of degrees. The rotation affects all saved images as -# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. -rotate 0 - -# Image width (pixels). Valid range: Camera dependent, default: 352 -width 320 - -# Image height (pixels). Valid range: Camera dependent, default: 288 -height 240 - -# Maximum number of frames to be captured per second. -# Valid range: 2-100. Default: 100 (almost no limit). -framerate 2 - -# Minimum time in seconds between capturing picture frames from the camera. -# Default: 0 = disabled - the capture rate is given by the camera framerate. -# This option is used when you want to capture images at a rate lower than 2 per second. -minimum_frame_time 0 - -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -; netcam_url value - -# Username and password for network camera (only if required). Default: not defined -# Syntax is user:password -; netcam_userpass value - -# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -# on: Use HTTP/1.1 requests that support keep alive as default. -# Default: off -netcam_keepalive off - -# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". -# If a port number other than 80 is needed, use "http://myproxy:1234". -# Default: not defined -; netcam_proxy value - -# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -# Default: off -netcam_tolerant_check off - -# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. -# Default: on -rtsp_uses_tcp on - -# Let motion regulate the brightness of a video device (default: off). -# The auto_brightness feature uses the brightness option as its target value. -# If brightness is zero auto_brightness will adjust to average brightness value 128. -# Only recommended for cameras without auto brightness -auto_brightness off - -# Set the initial brightness of a video device. -# If auto_brightness is enabled, this value defines the average brightness level -# which Motion will try and adjust to. -# Valid range 0-255, default 0 = disabled -brightness 0 - -# Set the contrast of a video device. -# Valid range 0-255, default 0 = disabled -contrast 0 - -# Set the saturation of a video device. -# Valid range 0-255, default 0 = disabled -saturation 0 - -# Set the hue of a video device (NTSC feature). -# Valid range 0-255, default 0 = disabled -hue 0 - - -############################################################ -# Round Robin (multiple inputs on same video device name) -############################################################ - -# Number of frames to capture in each roundrobin step (default: 1) -roundrobin_frames 1 - -# Number of frames to skip before each roundrobin step (default: 1) -roundrobin_skip 1 - -# Try to filter out noise generated by roundrobin (default: off) -switchfilter off - - -############################################################ -# Motion Detection Settings: -############################################################ - -# Threshold for number of changed pixels in an image that -# triggers motion detection (default: 1500) -threshold 1500 - -# Automatically tune the threshold down if possible (default: off) -threshold_tune off - -# Noise threshold for the motion detection (default: 32) -noise_level 32 - -# Automatically tune the noise threshold (default: on) -noise_tune on - -# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) -# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. -# (l)abeling must only be used once and the 'l' must be the last letter. -# Comment out to disable -despeckle_filter EedDl - -# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -# A script (on_area_detected) is started immediately when motion is 4 5 6 -# detected in one of the given areas, but only once during an event. 7 8 9 -# One or more areas can be specified with this option. Take care: This option -# does NOT restrict detection to these areas! (Default: not defined) -; area_detect value - -# PGM file to use as a sensitivity mask. -# Full path name to. (Default: not defined) -; mask_file value - -# Dynamically create a mask file during operation (default: 0) -# Adjust speed of mask changes from 0 (off) to 10 (fast) -smart_mask_speed 0 - -# Ignore sudden massive light intensity changes given as a percentage of the picture -# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled -lightswitch 0 - -# Picture frames must contain motion at least the specified number of frames -# in a row before they are detected as true motion. At the default of 1, all -# motion is detected. Valid range: 1 to thousands, recommended 1-5 -minimum_motion_frames 1 - -# Specifies the number of pre-captured (buffered) pictures from before motion -# was detected that will be output at motion detection. -# Recommended range: 0 to 5 (default: 0) -# Do not use large values! Large values will cause Motion to skip video frames and -# cause unsmooth movies. To smooth movies use larger values of post_capture instead. -pre_capture 0 - -# Number of frames to capture after motion is no longer detected (default: 0) -post_capture 0 - -# Event Gap is the seconds of no motion detection that triggers the end of an event. -# An event is defined as a series of motion images taken within a short timeframe. -# Recommended value is 60 seconds (Default). The value -1 is allowed and disables -# events causing all Motion to be written to one single movie file and no pre_capture. -# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An -# event ends right after no more motion is detected and post_capture is over. -event_gap 60 - -# Maximum length in seconds of a movie -# When value is exceeded a new movie file is created. (Default: 0 = infinite) -max_movie_time 0 - -# Always save images even if there was no motion (default: off) -emulate_motion off - - -############################################################ -# Image File Output -############################################################ - -# Output 'normal' pictures when motion is detected (default: on) -# Valid values: on, off, first, best, center -# When set to 'first', only the first picture of an event is saved. -# Picture with most motion of an event is saved when set to 'best'. -# Picture with motion nearest center of picture is saved when set to 'center'. -# Can be used as preview shot for the corresponding movie. -output_pictures on - -# Output pictures with only the pixels moving object (ghost images) (default: off) -output_debug_pictures off - -# The quality (in percent) to be used by the jpeg compression (default: 75) -quality 75 - -# Type of output images -# Valid values: jpeg, ppm (default: jpeg) -picture_type jpeg - -############################################################ -# FFMPEG related options -# Film (movies) file output, and deinterlacing of the video input -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################ - -# Use ffmpeg to encode movies in realtime (default: off) -ffmpeg_output_movies on - -# Use ffmpeg to make movies with only the pixels moving -# object (ghost images) (default: off) -ffmpeg_output_debug_movies off - -# Use ffmpeg to encode a timelapse movie -# Default value 0 = off - else save frame every Nth second -ffmpeg_timelapse 0 - -# The file rollover mode of the timelapse video -# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual -ffmpeg_timelapse_mode daily - -# Bitrate to be used by the ffmpeg encoder (default: 400000) -# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) -ffmpeg_bps 500000 - -# Enables and defines variable bitrate for the ffmpeg encoder. -# ffmpeg_bps is ignored if variable bitrate is enabled. -# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, -# or the range 2 - 31 where 2 means best quality and 31 is worst. -ffmpeg_variable_bitrate 0 - -# Codec to used by ffmpeg for the video compression. -# Timelapse mpegs are always made in mpeg1 format independent from this option. -# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. -# mpeg1 - gives you files with extension .mpg -# mpeg4 or msmpeg4 - gives you files with extension .avi -# msmpeg4 is recommended for use with Windows Media Player because -# it requires no installation of codec on the Windows client. -# swf - gives you a flash film with extension .swf -# flv - gives you a flash video with extension .flv -# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -# mov - QuickTime ( testing ) -# ogg - Ogg/Theora ( testing ) -ffmpeg_video_codec mpeg4 - -# Use ffmpeg to deinterlace video. Necessary if you use an analog camera -# and see horizontal combing on moving objects in video or pictures. -# (default: off) -ffmpeg_deinterlace off - -############################################################ -# SDL Window -############################################################ - -# Number of motion thread to show in SDL Window (default: 0 = disabled) -#sdl_threadnr 0 - -############################################################ -# External pipe to video encoder -# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. -# The options movie_filename and timelapse_filename are also used -# by the ffmpeg feature -############################################################# - -# Bool to enable or disable extpipe (default: off) -use_extpipe off - -# External program (full path and opts) to pipe raw video to -# Generally, use '-' for STDIN... -;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps - - - -############################################################ -# Snapshots (Traditional Periodic Webcam File Output) -############################################################ - -# Make automated snapshot every N seconds (default: 0 = disabled) -snapshot_interval 0 - - -############################################################ -# Text Display -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, \n = new line, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event - do not use with text_event! -# You can put quotation marks around the text to allow -# leading spaces -############################################################ - -# Locate and draw a box around the moving object. -# Valid values: on, off, preview (default: off) -# Set to 'preview' will only draw a box in preview_shot pictures. -locate_motion_mode off - -# Set the look and style of the locate box if enabled. -# Valid values: box, redbox, cross, redcross (default: box) -# Set to 'box' will draw the traditional box. -# Set to 'redbox' will draw a red box. -# Set to 'cross' will draw a little cross to mark center. -# Set to 'redcross' will draw a little red cross to mark center. -locate_motion_style box - -# Draws the timestamp using same options as C function strftime(3) -# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -# Text is placed in lower right corner -text_right %Y-%m-%d\n%T-%q - -# Draw a user defined text on the images using same options as C function strftime(3) -# Default: Not defined = no text -# Text is placed in lower left corner -; text_left CAMERA %t - -# Draw the number of changed pixed on the images (default: off) -# Will normally be set to off except when you setup and adjust the motion settings -# Text is placed in upper right corner -text_changes off - -# This option defines the value of the special event conversion specifier %C -# You can use any conversion specifier in this option except %C. Date and time -# values are from the timestamp of the first image in the current event. -# Default: %Y%m%d%H%M%S -# The idea is that %C can be used filenames and text_left/right for creating -# a unique identifier for each event. -text_event %Y%m%d%H%M%S - -# Draw characters at twice normal size on images. (default: off) -text_double off - - -# Text to include in a JPEG EXIF comment -# May be any text, including conversion specifiers. -# The EXIF timestamp is included independent of this text. -;exif_text %i%J/%K%L - -############################################################ -# Target Directories and filenames For Images And Films -# For the options snapshot_, picture_, movie_ and timelapse_filename -# you can use conversion specifiers -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# Quotation marks round string are allowed. -############################################################ - -# Target base directory for pictures and films -# Recommended to use absolute path. (Default: current working directory) -target_dir /tmp/motion - -# File path for snapshots (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-snapshot -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot -# File extension .jpg or .ppm is automatically added so do not include this. -# Note: A symbolic link called lastsnap.jpg created in the target_dir will always -# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -snapshot_filename %v-%Y%m%d%H%M%S-snapshot - -# File path for motion triggered images (jpeg or ppm) relative to target_dir -# Default: %v-%Y%m%d%H%M%S-%q -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -# File extension .jpg or .ppm is automatically added so do not include this -# Set to 'preview' together with best-preview feature enables special naming -# convention for preview shots. See motion guide for details -picture_filename %v-%Y%m%d%H%M%S-%q - -# File path for motion triggered ffmpeg films (movies) relative to target_dir -# Default: %v-%Y%m%d%H%M%S -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -# File extension .mpg or .avi is automatically added so do not include this -# This option was previously called ffmpeg_filename -movie_filename %v-%Y%m%d%H%M%S - -# File path for timelapse movies relative to target_dir -# Default: %Y%m%d-timelapse -# Default value is near equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse -# File extension .mpg is automatically added so do not include this -timelapse_filename %Y%m%d-timelapse - -############################################################ -# Global Network Options -############################################################ -# Enable or disable IPV6 for http control and stream (default: off ) -ipv6_enabled off - -############################################################ -# Live Stream Server -############################################################ - -# The mini-http server listens to this port for requests (default: 0 = disabled) -stream_port 8081 - -# Quality of the jpeg (in percent) images produced (default: 50) -stream_quality 50 - -# Output frames at 1 fps when no motion is detected and increase to the -# rate given by stream_maxrate when motion is detected (default: off) -stream_motion off - -# Maximum framerate for stream streams (default: 1) -stream_maxrate 1 - -# Restrict stream connections to localhost only (default: on) -stream_localhost on - -# Limits the number of images per connection (default: 0 = unlimited) -# Number can be defined by multiplying actual stream rate by desired number of seconds -# Actual stream rate is the smallest of the numbers framerate and stream_maxrate -stream_limit 0 - -# Set the authentication method (default: 0) -# 0 = disabled -# 1 = Basic authentication -# 2 = MD5 digest (the safer authentication) -stream_auth_method 0 - -# Authentication for the stream. Syntax username:password -# Default: not defined (Disabled) -; stream_authentication username:password - - -############################################################ -# HTTP Based Control -############################################################ - -# TCP/IP port for the http server to listen on (default: 0 = disabled) -webcontrol_port 8080 - -# Restrict control connections to localhost only (default: on) -webcontrol_localhost on - -# Output for http server, select off to choose raw text plain (default: on) -webcontrol_html_output on - -# Authentication for the http based control. Syntax username:password -# Default: not defined (Disabled) -; webcontrol_authentication username:password - - -############################################################ -# Tracking (Pan/Tilt) -############################################################# - -# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) -# The generic type enables the definition of motion center and motion size to -# be used with the conversion specifiers for options like on_motion_detected -track_type 0 - -# Enable auto tracking (default: off) -track_auto off - -# Serial port of motor (default: none) -;track_port /dev/ttyS0 - -# Motor number for x-axis (default: 0) -;track_motorx 0 - -# Set motorx reverse (default: 0) -;track_motorx_reverse 0 - -# Motor number for y-axis (default: 0) -;track_motory 1 - -# Set motory reverse (default: 0) -;track_motory_reverse 0 - -# Maximum value on x-axis (default: 0) -;track_maxx 200 - -# Minimum value on x-axis (default: 0) -;track_minx 50 - -# Maximum value on y-axis (default: 0) -;track_maxy 200 - -# Minimum value on y-axis (default: 0) -;track_miny 50 - -# Center value on x-axis (default: 0) -;track_homex 128 - -# Center value on y-axis (default: 0) -;track_homey 128 - -# ID of an iomojo camera if used (default: 0) -track_iomojo_id 0 - -# Angle in degrees the camera moves per step on the X-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_x 10 - -# Angle in degrees the camera moves per step on the Y-axis -# with auto-track (default: 10) -# Currently only used with pwc type cameras -track_step_angle_y 10 - -# Delay to wait for after tracking movement as number -# of picture frames (default: 10) -track_move_wait 10 - -# Speed to set the motor to (stepper motor option) (default: 255) -track_speed 255 - -# Number of steps to make (stepper motor option) (default: 40) -track_stepsize 40 - - -############################################################ -# External Commands, Warnings and Logging: -# You can use conversion specifiers for the on_xxxx commands -# %Y = year, %m = month, %d = date, -# %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, -# %D = changed pixels, %N = noise level, -# %i and %J = width and height of motion area, -# %K and %L = X and Y coordinates of motion center -# %C = value defined by text_event -# %f = filename with full path -# %n = number indicating filetype -# Both %f and %n are only defined for on_picture_save, -# on_movie_start and on_movie_end -# Quotation marks round string are allowed. -############################################################ - -# Do not sound beeps when detecting motion (default: on) -# Note: Motion never beeps when running in daemon mode. -quiet on - -# Command to be executed when an event starts. (default: none) -# An event starts at first motion detected after a period of no motion defined by event_gap -; on_event_start value - -# Command to be executed when an event ends after a period of no motion -# (default: none). The period of no motion is defined by option event_gap. -; on_event_end value - -# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -# To give the filename as an argument to a command append it with %f -; on_picture_save value - -# Command to be executed when a motion frame is detected (default: none) -; on_motion_detected value - -# Command to be executed when motion in a predefined area is detected -# Check option 'area_detect'. (default: none) -; on_area_detected value - -# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_start value - -# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -# To give the filename as an argument to a command append it with %f -; on_movie_end value - -# Command to be executed when a camera can't be opened or if it is lost -# NOTE: There is situations when motion don't detect a lost camera! -# It depends on the driver, some drivers dosn't detect a lost camera at all -# Some hangs the motion thread. Some even hangs the PC! (default: none) -; on_camera_lost value - -##################################################################### -# Common Options for database features. -# Options require database options to be active also. -##################################################################### - -# Log to the database when creating motion triggered picture file (default: on) -; sql_log_picture on - -# Log to the database when creating a snapshot image file (default: on) -; sql_log_snapshot on - -# Log to the database when creating motion triggered movie file (default: off) -; sql_log_movie off - -# Log to the database when creating timelapse movies file (default: off) -; sql_log_timelapse off - -# SQL query string that is sent to the database -# Use same conversion specifiers has for text features -# Additional special conversion specifiers are -# %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') - - -############################################################ -# Database Options -############################################################ - -# database type : mysql, postgresql, sqlite3 (default : not defined) -; database_type value - -# database to log to (default: not defined) -; database_dbname value - -# The host on which the database is located (default: localhost) -; database_host value - -# User account name for database (default: not defined) -; database_user value - -# User password for database (default: not defined) -; database_password value - -# Port on which the database is located -# mysql 3306 , postgresql 5432 (default: not defined) -; database_port value - -############################################################ -# Database Options For SQLite3 -############################################################ - -# SQLite3 database (file path) (default: not defined) -; sqlite3_db value - - - -############################################################ -# Video Loopback Device (vloopback project) -############################################################ - -# Output images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; video_pipe value - -# Output motion images to a video4linux loopback device -# The value '-' means next available (default: not defined) -; motion_video_pipe value - - -############################################################## -# Thread config files - One for each camera. -# Except if only one camera - You only need this config file. -# If you have more than one camera you MUST define one thread -# config file for each camera in addition to this config file. -############################################################## - -# Remember: If you have more than one camera you must have one -# thread file for each camera. E.g. 2 cameras requires 3 files: -# This motion.conf file AND thread1.conf and thread2.conf. -# Only put the options that are unique to each camera in the -# thread config files. -; thread /usr/local/etc/thread1.conf -; thread /usr/local/etc/thread2.conf -; thread /usr/local/etc/thread3.conf -; thread /usr/local/etc/thread4.conf - diff --git a/debian/motion.config b/debian/motion.config deleted file mode 100644 index 8ac1a4e..0000000 --- a/debian/motion.config +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -. /usr/share/debconf/confmodule - -if dpkg --compare-versions "$2" lt-nl "3.1.14-1"; then - db_input high motion/moved_conf_dir || true - db_go || true -fi - -exit 0 diff --git a/debian/motion.default b/debian/motion.default deleted file mode 100644 index 08ecd83..0000000 --- a/debian/motion.default +++ /dev/null @@ -1,3 +0,0 @@ -# set to 'yes' to enable the motion daemon -start_motion_daemon=no - diff --git a/debian/motion.postinst b/debian/motion.postinst deleted file mode 100644 index 29ac59c..0000000 --- a/debian/motion.postinst +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# postinst script for motion -# Made by Angel Carpintero - -set -e - - -. /usr/share/debconf/confmodule - -add_group_if_missing() { - if [ -x /usr/sbin/addgroup ]; then - if ! getent group motion >/dev/null; then - addgroup --system --force-badname motion || true - fi - fi -} - -add_user_if_missing() { - if [ -x /usr/sbin/adduser ]; then - if ! id -u motion > /dev/null 2>&1; then - adduser --system --no-create-home \ - --disabled-password \ - --force-badname motion \ - --ingroup motion - adduser motion video - fi - fi -} - -add_group_if_missing -add_user_if_missing - -# Fix motion.conf permission -chmod 0644 /etc/motion/motion.conf -chgrp motion /etc/motion/motion.conf - - -db_stop - -#DEBHELPER# - -exit 0 - - diff --git a/debian/motion.postinst.save b/debian/motion.postinst.save deleted file mode 100644 index b753792..0000000 --- a/debian/motion.postinst.save +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# postinst script for motion -# Made by Angel Carpintero - -set -e - - -. /usr/share/debconf/confmodule - -add_group_if_missing() { - if [ -x /usr/sbin/addgroup ]; then - if ! getent group motion >/dev/null; then - addgroup --force-badname motion || true - - fi - fi -} - -add_user_if_missing() { - if [ -x /usr/sbin/adduser ]; then - if ! id -u motion > /dev/null 2>&1; then - adduser --system --no-create-home \ - --disabled-password \ - --force-badname motion \ - --ingroup motion - adduser motion video - fi - fi -} - -create_pid_dir(){ - if ! [ -d /var/run/motion ]; then - mkdir /var/run/motion - fi - chown motion:motion /var/run/motion -} - -add_group_if_missing -add_user_if_missing -create_pid_dir - -# Fix motion.conf permission -chmod 0644 /etc/motion/motion.conf -chgrp motion /etc/motion/motion.conf - - -db_stop - -#DEBHELPER# - -exit 0 - - diff --git a/debian/motion.templates b/debian/motion.templates deleted file mode 100644 index 318ef4b..0000000 --- a/debian/motion.templates +++ /dev/null @@ -1,11 +0,0 @@ -Template: motion/moved_conf_dir -Type: note -_Description: Location of Motion's config files has changed - The default location of Motion's configuration files has moved from /etc/ - to /etc/motion/. So if you already have a motion.conf in /etc/ from a - previous installation of Motion, you should move this to /etc/motion/ in - order for it to take effect whenever Motion is used. - . - The same thing goes for any thread*.conf files you may have. You should - move these to /etc/motion/ as well (in this case, also remember to update - the path to the thread*.conf files inside motion.conf). diff --git a/debian/patches/github-changes b/debian/patches/github-changes deleted file mode 100644 index cc7bd64..0000000 --- a/debian/patches/github-changes +++ /dev/null @@ -1,48045 +0,0 @@ -Description: - TODO: Put a short summary on the line above and replace this paragraph - with a longer explanation of this change. Complete the meta-information - with other relevant fields (see below for details). To make it easier, the - information below has been extracted from the changelog. Adjust it or drop - it. - . - motion (3.2.12-4ppa01) trusty; urgency=low - . - * Nonmaintainer upload - * Due to conficts, removed patches (Mr Dave) - * Revise motion.postinst to put motion.conf at 0644 instead of 0640(Mr Dave) - * Many many changes from github repos of many many developers since 3.2.12 was released. - * - * Features - * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) - * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 - (Jeroen Massar & Angel Carpintero) - * Experimental approach for MJPEG streams (Motion JPEG) for network cameras - http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch ( ... ) - * Add draw a RED box around the movement as default (Joerg Weber) - * Add write/read nonblock functions in webhttpd( timeout on read/write). (Angel Carpintero) - * More changes in option names from http://www.lavrsen.dk/twiki/bin/view/Motion/IntuitiveOptionNamesDiscussion - (Angel Carpintero) - * motion_locate new parameter names : red , center , redcross instead of only on, off. (Angel Carpintero) - * External pipe to allow external video encoders - http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) - * Split locate_motion into separate 'mode' and 'style' option to allow all - possible combinations. (Joerg Weber) - * Implement 'gapless' event mode to allow for recording of movies without 'holes'. (Joerg Weber) - * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. (Joerg Weber) - * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. - http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 - Increased buffer in ffmpeg to allow encoding at 1600x1200 (Angel Carpintero) - * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch (Giacomo Graziosi) - * New RPM SPEC file and startup scripts compliant with Fedora 10 guidelines and above (Steven Moix) - * Increase write buffer size for writing image files and ffmpegs - http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionWriteBuffersPatch (Craig West) - * Fixed mask overlay in setup mode is now green instead of white (Joerg Weber) - * Add new config option 'ipv6_enabled' to enable/disable IPV6 (Angel Carpintero) - * Remove VIDIOC_S_JPEGCOMP support is deprecated. (Angel Carpintero) - * Use static memory allocation in ffmpeg_deinterlace() (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic - * Atom optimizacion in configure.in (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations - * Allow to change Standard method ( PAL / NECAM / SECAM ) (Angel Carpintero) - * Add authentication methods 'Basic Authentication' and 'Digest Authentication' - to the "Live Stream Server". (Michael Finsterbusch) - http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch - * Implemented new logging system - http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero) - * Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero) - * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis) - * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). - * 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) - * Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8. (Jeroen Massar) - * Added codec Ogg/Theora as new output format for regular movies. - http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) - * Added support for ffmpeg 0.11 new API. - * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) - * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) - * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) - * Buffer overflow vulnerabilities (hyperbolic2346) - * Redundand -- boundary prefix (torao) - * Removed compiler warnings: (Mr-Dave) - logger.c,jpegutils.c,netcam_ftp.c,track.c, - picture.c,webhttpd.c,stream.c,ffmpeg.c - * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) - * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) - * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) - * Resolve additional compiler warnings in ffmpeg (Mr-Dave) - * Revised INSTALL with samples(Mr-Dave) - * Revisions for RTSP and code standard.(Mr-Dave) - * Plugged most memory leaks in RTSP. (Mr-Dave) - * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) - * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) - * Regession fix for memory leaks and reconnection (Mr-Dave) - * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) - * Revised RTSP to support version 53 of libavformat (Mr-Dave) - * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) - * Revised INSTALL to have sample PI configure option.(Mr-Dave) - * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) - * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) - * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) - * Clean up the messaging for RTSP. - * Additional validations for RTSP connection and corrected free sequences - * Removed seg fault on failure to open first image, comments, isolation of RTSP - * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. - * Implement inits of AV functions from bcl fork - * Add gray image upon disconnection - * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) - * Revised comments to be in line with application standard. - * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format - * Revise version.sh to put out the git commit. - * Rollback revision to allow for a formal pull request. - * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 - * Implement requirement of modulo 16 to avoid seg fault when opening stream - * Add debian build files from trusty(14.04) - * Revise default values for motion.conf - * Revise CHANGELOG to conform with debian format - . - * Bugfixes - * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) - * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 - * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) - * Avoid compile vloopback in BSD (Angel Carpintero) - * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. (Isaac Richter) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 - * 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) - * Fix introduced bug for Content-Lenght = 0 in svn r476. (Angel Carpintero) - * 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 - * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 (Angel Carpintero) - * Fix issue with JPEG , adding dinfo.do_fancy_upsampling = FALSE; - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x08x20x194659 - * Made micro-lightswitch optional (see lightwitch option in motion.conf) - * 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. - * Replace malloc() by calloc(). (Jeroen Massar) - * Free file descriptor buffers on exit. - * Avoid segfault when text_left or text_right uses non supported chars. - * Fixed leak in vloopback. - * Fixed a build of motion for some kernel version with not good videodev.h - * Netcam Modulo 8 -Author: Mr Dave - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Bug-Ubuntu: https://launchpad.net/bugs/ -Forwarded: -Reviewed-By: -Last-Update: - ---- motion-3.2.12.orig/CHANGELOG -+++ motion-3.2.12/CHANGELOG -@@ -1,3 +1,129 @@ -+ * -+ * Features -+ * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) -+ * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 -+ (Jeroen Massar & Angel Carpintero) -+ * Experimental approach for MJPEG streams (Motion JPEG) for network cameras -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LinksysWVC200SupportPatch ( ... ) -+ * Add draw a RED box around the movement as default (Joerg Weber) -+ * Add write/read nonblock functions in webhttpd( timeout on read/write). (Angel Carpintero) -+ * More changes in option names from http://www.lavrsen.dk/twiki/bin/view/Motion/IntuitiveOptionNamesDiscussion -+ (Angel Carpintero) -+ * motion_locate new parameter names : red , center , redcross instead of only on, off. (Angel Carpintero) -+ * External pipe to allow external video encoders -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) -+ * Split locate_motion into separate 'mode' and 'style' option to allow all -+ possible combinations. (Joerg Weber) -+ * Implement 'gapless' event mode to allow for recording of movies without 'holes'. (Joerg Weber) -+ * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. (Joerg Weber) -+ * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 -+ Increased buffer in ffmpeg to allow encoding at 1600x1200 (Angel Carpintero) -+ * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch (Giacomo Graziosi) -+ * New RPM SPEC file and startup scripts compliant with Fedora 10 guidelines and above (Steven Moix) -+ * Increase write buffer size for writing image files and ffmpegs -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionWriteBuffersPatch (Craig West) -+ * Fixed mask overlay in setup mode is now green instead of white (Joerg Weber) -+ * Add new config option 'ipv6_enabled' to enable/disable IPV6 (Angel Carpintero) -+ * Remove VIDIOC_S_JPEGCOMP support is deprecated. (Angel Carpintero) -+ * Use static memory allocation in ffmpeg_deinterlace() (Peter Holik) -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic -+ * Atom optimizacion in configure.in (Peter Holik) -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations -+ * Allow to change Standard method ( PAL / NECAM / SECAM ) (Angel Carpintero) -+ * Add authentication methods 'Basic Authentication' and 'Digest Authentication' -+ to the "Live Stream Server". (Michael Finsterbusch) -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch -+ * Implemented new logging system -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero) -+ * Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero) -+ * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis) -+ * Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero). -+ * 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) -+ * Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8. (Jeroen Massar) -+ * Added codec Ogg/Theora as new output format for regular movies. -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse (Michael Luich) -+ * Added support for ffmpeg 0.11 new API. -+ * Added RSTP support for netcam ( merge https://github.com/hyperbolic2346/motion ) -+ * Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) (Mr-Dave) -+ * 3fps bugfix from SVN rev559 (tosiara, Joerg Weber) -+ * Buffer overflow vulnerabilities (hyperbolic2346) -+ * Redundand -- boundary prefix (torao) -+ * Removed compiler warnings: (Mr-Dave) -+ logger.c,jpegutils.c,netcam_ftp.c,track.c, -+ picture.c,webhttpd.c,stream.c,ffmpeg.c -+ * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) -+ * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) -+ * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) -+ * Resolve additional compiler warnings in ffmpeg (Mr-Dave) -+ * Revised INSTALL with samples(Mr-Dave) -+ * Revisions for RTSP and code standard.(Mr-Dave) -+ * Plugged most memory leaks in RTSP. (Mr-Dave) -+ * Undo changes caused by code editor and other unnecessary changes (Mr-Dave) -+ * Moved call to netcam_shutdown_rtsp into netcam_cleanup where it belongs. (Mr-Dave) -+ * Regession fix for memory leaks and reconnection (Mr-Dave) -+ * Eliminated requirement to manually build FFMPEG for RTSP support. (Mr-Dave) -+ * Revised RTSP to support version 53 of libavformat (Mr-Dave) -+ * Revised FFMPEG.c to eliminate warnings and functions no longer supported by Libav/FFMPEG(Mr-Dave) -+ * Revised INSTALL to have sample PI configure option.(Mr-Dave) -+ * Revised configure.ac to generate compiler flag AVFMT_V53.(Mr-Dave) -+ * Revised INSTALL to indicate standard APT packages for RTSP (Mr-Dave) -+ * Revised configure.ac to recognize libavformat version 54 RTSP (Mr-Dave) -+ * Clean up the messaging for RTSP. -+ * Additional validations for RTSP connection and corrected free sequences -+ * Removed seg fault on failure to open first image, comments, isolation of RTSP -+ * Add AC_GNU_SOURCE macro to check for GNU C Library, fix compile when no FFMpeg. -+ * Implement inits of AV functions from bcl fork -+ * Add gray image upon disconnection -+ * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) -+ * Revised comments to be in line with application standard. -+ * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format -+ * Revise version.sh to put out the git commit. -+ * Rollback revision to allow for a formal pull request. -+ * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 -+ * Implement requirement of modulo 16 to avoid seg fault when opening stream -+ * Add debian build files from trusty(14.04) -+ * Revise default values for motion.conf -+ * Revise CHANGELOG to conform with debian format -+ -+ * Bugfixes -+ * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) -+ * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 -+ * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) -+ * Avoid compile vloopback in BSD (Angel Carpintero) -+ * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. (Isaac Richter) -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 -+ * 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) -+ * Fix introduced bug for Content-Lenght = 0 in svn r476. (Angel Carpintero) -+ * 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 -+ * Added a conditional check for avformat_alloc_context , av_avformat_alloc_context to fix -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x10x05x071936 (Angel Carpintero) -+ * Fix issue with JPEG , adding dinfo.do_fancy_upsampling = FALSE; -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x08x20x194659 -+ * Made micro-lightswitch optional (see lightwitch option in motion.conf) -+ * 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. -+ * Replace malloc() by calloc(). (Jeroen Massar) -+ * Free file descriptor buffers on exit. -+ * Avoid segfault when text_left or text_right uses non supported chars. -+ * Fixed leak in vloopback. -+ * Fixed a build of motion for some kernel version with not good videodev.h -+ * Netcam Modulo 8 -+ - 3.2.12 Summary of Changes - - Bugfixes -@@ -6,10 +132,11 @@ Bugfixes - * Fixed FFV1 codec encode with ffmpeg (Angel Carpintero) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x13x032553 - * Fix conv_uyvyto420p segfault ( William M Brack ) -- * Enhancing the palette selection ( William M Brack ) -+ * Enhancing the palette selection ( William M Brack ) - * Fix zombies on OpenBSD. (Mark Feenstra) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x28x054348 - -+ - 3.2.11.1 Sumary of Changes - - Bugfixes -@@ -18,16 +145,15 @@ Bugfixes - * Fix fd leaks in external pipe. (Angel Carpintero) - * Avoid possible stack smashing in v4l_open_vidpipe(). (Angel Carpintero) - * Allow compile with OpenSuse ffmpeg package (15594svn-20081010) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x10x25x070400 (Angel Carpintero) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x10x25x070400 (Angel Carpintero) - * Fix warning for syslog(). (Angel Carpintero) -- * Better detection of ffmpeg -- http://www.lavrsen.dk/foswiki/pub/Motion/ReleaseNoteMotion3x2x11/ffmpeg-detection.diff.gz -- (Angel Carpintero) -- * Fix warning for __USE_GNU redefined (Peter Holik) -+ * Better detection of ffmpeg -+ http://www.lavrsen.dk/foswiki/pub/Motion/ReleaseNoteMotion3x2x11/ffmpeg-detection.diff.gz -+ (Angel Carpintero) -+ * Fix warning for __USE_GNU redefined (Peter Holik) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x122137 (Peter Holik) - * Allow compile with NetBSD and make LP64 compliant video_freebsd.c (Andreas Wrede) - * Fix segfault for new libjpeg v7. (Angel Carpintero) -- - - 3.2.11 Summary of Changes - -@@ -39,29 +165,31 @@ Features - - - Bugfixes -- * Fix Problem Encoding 1280x1024 resolution videos -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x06x11x183727 (Angel Carpintero) -+ * Fix Problem Encoding 1280x1024 resolution videos -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x06x11x183727 (Angel Carpintero) - * Add a new parameter netcam_tolerant_check, to be less strict with some buggy network cameras firmwares. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x06x19x123218 (Angel Carpintero) -- * Fix round robin in BSD switching to METEOR_CAP_SINGLE. (Angel Carpintero) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x06x19x123218 (Angel Carpintero) -+ * Fix round robin in BSD switching to METEOR_CAP_SINGLE. (Angel Carpintero) - * Fix rotate for v4l2 devices using JPEG / MJPEG palettes. (Angel Carpintero) -- * Fix v4l2_palette http://www.lavrsen.dk/foswiki/bin/view/Motion/UvcvideoMjpegPatch (Gerrit Hannaert) -+ * Fix v4l2_palette http://www.lavrsen.dk/twiki/bin/view/Motion/UvcvideoMjpegPatch (Gerrit Hannaert) - * Fix warning for x86_64 in conf.c using pointers LP64 compliant ( Angel Carpintero ). -+ * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) ( Peter Holik ) -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 -+ - - 3.2.10.1 Summary of Changes - - Bugfixes - * Fix a security issue in web control interface http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484572 -- (Angel Carpintero) -- -+ (Angel Carpintero) - - 3.2.10 Summary of Changes - - Features - * Added the pre_capture buffer redesign to throttle load and enhance pre_capture feature. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreCaptureRedesign (Dag Erlandsson). -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PreCaptureRedesign (Dag Erlandsson). - * Added preview center feature. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewCenter (Dag Erlandsson). -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewCenter (Dag Erlandsson). - * Removed low_cpu feature, as it is not really compatible with pre_capture and a lot of other - features rely on the pre_capture buffer behind the scenes. (Joerg Weber) - * Removed night_compensate feature. This functionality is covered by noise_tune. (Joerg Weber) -@@ -69,8 +197,8 @@ Features - * Improved smartmask feature: real moving objects don't trigger the mask anymore. (Joerg Weber) - * Added area_detect feature. New config options: area_detect, on_area_detected. (Joerg Weber) - * Added help in http control -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x181541 (Angel Carpintero) -- * Added Choose V4L2 palette http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x032318 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x181541 (Angel Carpintero) -+ * Added Choose V4L2 palette http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x032318 - (Angel Carpintero) - * Improved http control ( 'back' link, select box, show current values when are going to be changed ). - (Angel Carpintero) -@@ -78,7 +206,7 @@ Features - * Watchdog, restart hang threads (Dag Erlandsson) - * Added ON_CAMERA_LOST event (Dag Erlandsson) - * Motion start if a camera isn't there at start, retries to connect if lost (Dag Erlandsson) -- * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x01x22x231542 -+ * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x01x22x231542 - (Simon Walls) - * Added mov , Quicktime file format (Andrew Hamilton). - * Added to configure.in --with-pwcbsd to allow compile motion in freebsd with webcam support instead of bktr -@@ -87,25 +215,25 @@ Features - Bugfixes - * Fixed a problem with locate and fixed mask overlay (Dag Erlandsson). - * Preview pictures get the timestamp of moment they were captured (Dag Erlandsson). -- * Fixed http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x23x093651 (Angel Carpintero) -+ * Fixed http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x23x093651 (Angel Carpintero) - * Fix process_id_file when is passed from command line (Angel Carpintero) -- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x27x150419 (Angel Carpintero) -- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x25x102808 (Angel Carpintero) -+ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x27x150419 (Angel Carpintero) -+ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x25x102808 (Angel Carpintero) - * Avoid random errors , initialising some structs for V4L1 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) - * Fix motion segfault because ffmpeg API change -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2007x12x29x175530 (Angel Carpintero) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2007x12x29x175530 (Angel Carpintero) - * Little fix in ffmpeg.c comparing version of LIBAVFORMAT_BUILD, since ffmpeg svn -r4486 LIBAVFORMAT_BUILD and - LIBAVCODEC_BUILD uses LIBAVFORMAT_VERSION_INT ((49<<16)+(0<<8)+0) and LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+0) - (Angel Carpintero) -- * Fix choose v4l2 palette , http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x01x21x043812 (Onakra) -+ * Fix choose v4l2 palette , http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x01x21x043812 (Onakra) - * Get current directory to allow write motion.conf properly -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x013419 (John Bray) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x013419 (John Bray) - * Fix broken PostgreSQL detection for custom location, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x025134 ( Angel Carpintero ) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x025134 ( Angel Carpintero ) - * Fixed stepper when is used track_auto on ( Angel Carpintero ). - * Better debug in netcam for "Error reading image header" -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x27x092849 (Simon Walls) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x27x092849 (Simon Walls) - - - 3.2.9 Formal Release - Summary of Changes -@@ -115,20 +243,20 @@ Features - ( no needed to deploy BSD port here ) directories. ( Angel Carpintero ) - * Added --chuid motion to debian init.d script. ( Angel Carpintero ) - * Added Flash video format (FLV) to ffmpeg. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x07x19x131921 (Timo Taskinen). -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x07x19x131921 (Timo Taskinen). - * Added FFV1 ( FF video codec 1 ) codec , Lossless encoding -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LosslessEncoding (Andrew Hamilton). -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LosslessEncoding (Andrew Hamilton). - - - Bugfixes - * Fix segfault in webhttpd.c on motion restart (Angel Carpintero) -- * Fix segfault in debian http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x09x24x175945 -+ * Fix segfault in debian http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x09x24x175945 - (Angel Carpintero) - * Fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391055 , change - motion man page , -d requires level. (Angel Carpintero) - * Handle mjpeg decoding and fix colour issue adding mjpegtools dependency -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegColorIssue -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegToYUV420pPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegColorIssue -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch - (Marius Rieder, Angel Carpintero). - * Add debug level > 5 to get logs from v4l2_select_input, v4l2_set_control and v4l2_set_input. - (Angel Carpintero) -@@ -139,17 +267,17 @@ Bugfixes - Features - * Added connection status for all devices available from http web interface. - (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x11x09x050638 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x11x09x050638 - * Improved deb packaging, install the init.d script. (Angel Carpintero). - * Added swf codec to video creation (Bowser Pete, Andy Brown). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FFmpegSWFcreation -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FFmpegSWFcreation - * Added V4L2 support (Krzysztof Blaszkowski, Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoForLinuxTwoDiscussion, -+ http://www.lavrsen.dk/twiki/bin/view/Motion/VideoForLinuxTwoDiscussion, - * Added support for V4L2_PIX_FMT_SBGGR8 ( bayer ), V4L2_PIX_FMT_SN9C10X, - V4L2_PIX_FMT_MJPEG and V4L2_PIX_FMT_UYVY (Angel Carpintero). - * ucvideo track pan/tilt support ( Michal Licko ,Dirk Wesenberg and - Angel Carpintero ) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch - * Added a FreeBSD directory to allow people from BSD to get a daily version - and create a port. (Angel Carpintero). - * Removed mysql dependency from debian package and added a note to setup -@@ -164,18 +292,18 @@ Features - Bugfixes - * Removed a duplicate call to jpeg_destroy_decompress already is called from - netcam_image_conv (Krzysztof Blaszkowski). -- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x10x10x081903, -+ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x10x10x081903, - reconnect to mysql if connection dropped (Angel Carpintero). - * Fix memory management in ffmpeg.c (Rafis Khayrullin). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x19x062432 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x19x062432 - * Fix of ffmpeg_avcodec_log code (Alain Guidez). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x25x074612 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x25x074612 - * Fix a segfault adding correct size to be used for bayer2rgb24() - (Damian Wrobel) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x30x175913 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x30x175913 - * Fix an error in FreeBSD, the use of capture even fields depends on height - value. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x03x073610 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x03x073610 - * Fixed autodetection for VIA cpu, no needed to use --without-optimizecpu. - Added many others (Angel Carpintero) - * Fix, don't remove pid file when motion reload config file( HUP signal ) -@@ -184,12 +312,12 @@ Bugfixes - * Fixed the thread number assignment which could goof up if netcams started - very quickly before all thread were created at startup. (Kenneth Lavrsen) - * Fix RoundRobin v4l2 buffers in driver when switching input, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x07x07x182605 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x07x07x182605 - (Dag Erlandsson and Angel Carpintero). - * Check EIO for VIDIOC_DQBUF to workaround saa7134 problem. - (Dag Erlandsson and Angel Carpintero). - * Change bayer2rgb24() to fix a problem with sn9c102 driver -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x06x05x012249 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x06x05x012249 - (Jared D and Angel Carpintero). - - 3.2.7 Formal Release - Summary of Changes -@@ -200,30 +328,30 @@ Features - than 2 frames per second (Kenneth Lavrsen and Angel Carpintero) - * Made the creation of reference frame and the decay mechanism depending - on how much motion was detected relative to threshold setting (Joerg Weber) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReferenceFramePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReferenceFramePatch - * Added process_id_file feature (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x06x06x123003 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x06x06x123003 - - Bugfixes - * Fixed problem related to fetching images from Network camera and error - handling when it fails. Motion would end in infinite loops (Bill Brack). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x10x000151 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x10x000151 - * Improved reporting of thread numbers during startup in setup mode. - (Peter Smith and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging - * Ffmpeg code mutex locking fix (Peter Smith) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 - * Ffmpeg avicodec logging improved (Peter Smith and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegAvicodecLogging -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegAvicodecLogging - * Improved upon a few ambiguous log messages which may be emitted by the Event - handling code with regards to Ffmpeg (Peter Smith) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LoggingEventFix -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LoggingEventFix - * Implemented a fix for the rare problem where some experienced that the - move file names would only consist of the extension .mpg or .avi with no - name in front. The root cause was the use of sprintf for appending to - strings. (Mike Kenney and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2005x09x05x133031 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x06x19x174238 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2005x09x05x133031 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x06x19x174238 - * Altered the risky use of sprintf to snprintf in all places related to - use with config strings that can become very long (Kenneth Lavrsen) - * Removed annoying debug messages (v4l_set_input really needed ?) in the FreeBSD -@@ -236,20 +364,20 @@ Bugfixes - * Fixed interlace issue with METEOR_GEO_EVEN_ONLY in FreeBSD (Angel Carpintero) - * Fixed possible syntax error in configure related to MySQL (Angel Carpintero) - * Avoid open file descriptor when connecting to network cameras fails (Peter Holik) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidOpenfiledescriptors -+ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidOpenfiledescriptors - * Fixed http pause feature so that pausing thread 0 now pauses all threads. - (GunnarSkjold) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x10x111239 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x10x111239 - * Put a new global mutex around avcodec_close to avoid problems with not thread - safe functions in ffmpeg (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 - * On FreeBSD configure defines a redundant freebsd for motion. Fixed by replacing - -D__freebsd_ by BSD macro included in sys/param.h for BSD platforms. - (JukkaUkkonen and Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x070417 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x070417 - * For BSD platforms changed to using native pthreads as default and adding - linuxthreads as a optional parameter from configure. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x071646 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x071646 - * Smartmask overlay feature did not set intensity correctly. (Kenneth Lavrsen) - - -@@ -257,14 +385,14 @@ Bugfixes - * Fixed bug where variables time_last_frame and time_current_frame had been - extended to also be used for snapshot feature but declaration was hidden - between #ifdef HAVE_FFMPEG. (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x09x012244 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x09x012244 - * Fixed a bug that only allowed remote control of max 9 cameras. Now - Motion can present up to 99 cameras in its http remote control interface - (Angel Carpintero based on idea by Chuck Sheehan) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHttpManyThreads -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebHttpManyThreads - * text_changes now shows a '-' when motion detection is paused instead of - just showing 0 (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x03x16x095713 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x03x16x095713 - - 3.2.5.1 Doc and man page correction - * ffmpeg_filename has changed name to movie_filename to prepare for -@@ -285,30 +413,30 @@ Bugfixes - * Remove cpu optimization (is broken) - * Fixed memory leak in ffmpeg code. (Andrew Hamilton) - * Fixed http control of pan and tilt (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x12x22x122649 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x12x22x122649 - * Fixed netcamera bug related to separating frames in an mjpeg stream. - (Peter Holik). From mailing list 23 Dec 2005. - * Fix related to connecting to the netcam (William Black) - From mailing list 23 Dec 2005. -- * Changed CHANGELOG to same bullet format as used by Foswiki to make it easier -+ * Changed CHANGELOG to same bullet format as used by TWiki to make it easier - to write release notes (Kenneth Lavrsen) - * Changed CREDITS to same bullet format as CHANGELOG (Kenneth Lavrsen) - * Fixed sql_mask not initialised correctly (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x09x175603 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x09x175603 - * Fixed the management of strings from http remote control , setting to NULL - when they are set to "blank" and fixes a problem with despeckle , that didn't - allow to remove labeling action from http remote control. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixStringsAndDisableLabeling -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FixStringsAndDisableLabeling - * Fix many typos in comments ( i ran aspell against the code ). Also there's a - fix to free cnt->eventtime_tm when motion exits. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixTypoInComments -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FixTypoInComments - * Fix the problem that happens in FreeBSD and Debian Sarge because - version of ffmpeg is LIBAVFORMAT_BUILD < 4629. ( Pete Shipley and Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x12x120335 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x12x120335 - * Updated motion.spec. Changing D_FORTIFY_SOURCE=2 by D_FORTIFY_SOURCE=1 to fix - problem related to building with ffmpeg. (Angel Carpintero) - * Implemented fix for missed snapshots with slow network cameras (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x162149 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x162149 - * Added some constants in video.c function v4l_picture_controls() which can help - people hack an optimal set of values for controlling auto brightness for their - particular camera. For now I am do not want to add all of these to the already -@@ -316,19 +444,19 @@ Bugfixes - permanently change the constants and add an additional auto brightness option. - Or maybe a combined option that sets more constant based on an algorithm. - (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x212816 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x212816 - * Fixed a syntax error in picture.c get_pgm() which caused the program to segfault - when a mask file size did not match the picture size. Now the program - correctly gives an error message and continues without the mask. (Kenneth - Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x08x150720 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x08x150720 - * Added Tilt support to stepper track. ( Angel Carpintero ). - * CPU VIA Ezra C3 autodetection support added. (James Van Vleet) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/VIAEzraC3Patch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/VIAEzraC3Patch - * Fixed mysql configure auto-detection for x64 systems. ( Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x03x02x152208 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x03x02x152208 - * Added the ffmpeg_deinterlace feature (Andrew Hamilton) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionffmpegDeinterlace -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionffmpegDeinterlace - - 3.2.4 Formal Release. Summary of changes - -@@ -353,7 +481,7 @@ Features - after the camera has moved (auto or manual) during which motion detection - is disabled. This option should be set so low that the motion detection - is re-enabled the minute the camera is standing still again. -- * Added new sql_query option. This in combination with conversion -+ * Added new sql_query option. This in combination with convertion - specifiers incl the two new %f and %n enables the user to use any database - structure they please. Adding fields is now a simple matter of modifying - the sql query. -@@ -380,7 +508,7 @@ Features - and brightness, support large resolutions. - * RPM specs file changed as suggested for use in the Livna repository. - * Changed the sequence of events connected with creating files. Data is -- now written to the databases (if used) before an external commends is -+ now written to the databases (if used) before an external comments is - on (on_xxxx options) allowing the external program to use the new data - in the database. - * Motion is now also works on MaxOSX with similar feature set as FreeBSD. -@@ -427,21 +555,21 @@ snap1 - We now encourage developers to ensure that new code is checked with - --with-developer-flags and code made so that no new warnings shows originating - from the motion sources. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch - * Fixed error message with unknown config option (Bill Brack) - * Fixed small mistake in allocating memory for cnt->imgs.common_buffer - (Angel Carpintero). - * Implemented a speed-up patch of the draw text feature (Peter Holik). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextspeedup -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextspeedup - * http control updated: (null) messages replaced by "disabled", last parameter - in conf/list are displayed correctly and only in Main thread. When motion runs - with only one thread, it displays "No threads". (Angel Carpintero) - * Enhanced compatibility with Lumenera (Bill Brack) - * http control: selectbox instead of a textfield for changing boolean configs - (Peter Holik and Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebhttpEnhancements. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebhttpEnhancements. - * Introduced check for device image size being a multiple of 16 (Peter Holik). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamModulo16Patch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamModulo16Patch - * Added the debian sub directory so that people can build the deb package - (Angel Carpintero). - * Sync configure.in.freebsd (adding support for jpeg-mmx, developer-flags and -@@ -452,8 +580,8 @@ snap1 - cnt struct around just to be able to print the thread number in the log and - on the console. (Per Jönsson with additional removal of unused cnt by - Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadNrTlsPatch -- * Moved the motion_loop initialisation into a new function motion_init -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadNrTlsPatch -+ * Moved the motion_loop initialization into a new function motion_init - (Bill Brack). - * Removed old unused code related to read mode (not mmap) from V4L devices - (Kenneth Lavrsen). -@@ -481,7 +609,7 @@ snap1 - snap2 - * Simplified rotation code based on the fact that images must have dimensions - that are a multiple of 16 (Per Jönsson) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateSimplificationPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateSimplificationPatch - * Switchfilter feature repaired. It was called inside motion_detected() - after overlays on cnt->img.out were added which meant that the feature also - detected all the overlays, smartmasks, fixed mask and text. It is now moved -@@ -499,7 +627,7 @@ snap2 - and minimum_motion_frames images are time stamped before the event happens - so %C in text_left/right does not have any effect on those images (Kenneth - Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/EventConvertionSpecifierDiscussion -+ http://www.lavrsen.dk/twiki/bin/view/Motion/EventConvertionSpecifierDiscussion - * Renamed some variables related to time to be better descriptive of function - and type (Kenneth Lavrsen). - * Added new option 'sql_user_text'. This can be defined with the same -@@ -511,10 +639,10 @@ snap2 - - snap3 - * Enhancement to Netcam Code for Connection to Pixord Cameras (Bill Brack). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFixPixordBug -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFixPixordBug - * Implemented fix to configure so that LDFLAGS from the environment are used - when making the Makefile (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x09x15x185558 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x09x15x185558 - * Changed configure so that --with-jpeg-mmx is default off as a reaction to - known problems seen when using the jpeg-mmx library (Angel Carpintero). - * RPM specs file changed as suggested for use in the Livna repository. -@@ -523,35 +651,35 @@ snap3 - despeckle features are run. This should ensure that both algorithms work on - raw unfiltered motion pixels which they both were designed for. (Kenneth - Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x05x212444 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x05x212444 - - snap4 - * Integrated NetcamWithFtp patch. To use ftp simply use a URL starting with - ftp:// (Bill Brack). Code was additionally cleaned up by Kenneth Lavrsen. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFTP -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFTP - * Changed error handling in vid_start so that failing to open the video - device no longer causes an exit but a return with error code -1. (Kenneth - Lavrsen) - * Added the %t conversion specifier to show the thread number. (Angel - Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadConversionSpecifierPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadConversionSpecifierPatch - * Added help texts in conf.c and motion-dist.conf describing the %t - specifier. Added a good example of use in motion-dist.conf. (Kenneth - Lavrsen). - * Fixed bug related to init of mutex in netcam code (Angel Carpintero). - * Improved fix for netcam mutex init (Bill Brack). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFixPthreadInit -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFixPthreadInit - * Netcam_ftp code fixes (Angel Carpintero and Asbjørn Pettersen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFtpEnhancements -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFtpEnhancements - * Enhanced ffmpeg detection (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BetterFFmpegDetection -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BetterFFmpegDetection - * Added two new conversion specifiers: %f which is filename (full path) - and %n which is filetype (sqltype) valid in on_picture_save, on_movie_start, - on_movie_end and sql_query. This also means that filename is no longer - appended at the end of the 3 on_xxxx commands. (Kenneth Lavrsen) - * Removed the sql_user_text option that was added in snap 2 (Kenneth - Lavrsen) -- * Added new sql_query option. This in combination with conversion -+ * Added new sql_query option. This in combination with convertion - specifiers incl the two new %f and %n enables the user to use any database - structure they please. Added fields is now a simple matter of modifying - the sql query. The default is the same as the default in snap1. -@@ -569,7 +697,7 @@ snap4 - a good idea to setup width and height so it is the same as the netcam. - If the dimensions are the same Motion will switch over to the netcam - seemlessly. If the dimensions are different Motion will perform a quick -- restart so all the many internal buffers can be initialised properly -+ restart so all the many internal buffers can be initialized properly - (Kenneth Lavrsen). - * Added a better error handling of a netcam that changes dimensions - while Motion is running. Instead of just writing error messages Motion -@@ -584,7 +712,7 @@ snap5 - * Restored the function sigchild_handler so it contains the same code - as before motion-3.2.1_snap9. They is done in an attempt to fix an old - problem with zombie child processes that has shown up again. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x11x13x115016 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x11x13x115016 - (Kenneth Lavrsen). - * Move the declaration of sig_handler_action and sigchild_action from - the setup_signals function where they are local and will be destroyed -@@ -608,11 +736,11 @@ Release - is re-enabled the minute the camera is standing still again. Feature - originally made by Moshe Van Der Sterre. Kenneth Lavrsen extended it to - be more generic. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PwcConfiguration -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PwcConfiguration - * New Feature: Motion is now also supported on MaxOSX with similar - feature set as for Free BSD. See README.MacOSX for details how to install - it. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MacOSXPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MacOSXPatch - * Added a work-around so people in FreeBSD that uses a capture card - where input 1 is not tuner can use motion if frequency is set -1 in - motion.conf or thread#.conf (Angel Carpintero). -@@ -629,11 +757,11 @@ Release - not changed so that the ring buffer is used for timestamped images - and the image used for detection is in a buffer cnt->imgs.image_virgin. - (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x15x140701 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x15x140701 - * Auto brightness used the first image in ring buffer instead of the - latest image and it used an image with time stamping. It now uses the new - cnt->imgs.image_virgin buffer. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x15x160208 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x15x160208 - * Cleaned out unused code from httpd control (Angel Carpintero). - * Option switch_filter used print_int instead of print_bool when motion.conf - was saved (Kenneth Lavrsen). -@@ -704,15 +832,15 @@ Bug Fixes - 3.2.2 Detailed changes for 3.2.2 - snap1 - * Pthread deadlock in motion 3.2.1 fixed (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x26x125712 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x26x125712 - * http lockup bugfixes and ConvertSignalToSigaction only for webhttpd - (Angel Carpintero) - * alg_draw_location: Use temporary variables to store the values used in - for() loops instead of compute them in each loop (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImproveAlgDrawLocation -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ImproveAlgDrawLocation - * Small speed boost to the function draw_textn (Andrew Hamilton and - Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextnImprovement -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextnImprovement - * Added two new convertion specifiers: %o for threshold and %Q for number - of labels. (Kenneth Lavrsen) - * Improved the config file description for pre_capture to get people to -@@ -723,7 +851,7 @@ snap2 - strdup to avoid segfault is target_dir parameter is not supplied in - motion.conf. Moves out from signal handler the cleanup for pipe and mpipe. - (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidCleanupSegfault -+ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidCleanupSegfault - * Major code cleanup concerning signedness of chars all over the code to - allow compilation with gcc4.0 (like in Fedora Core 4) without any - errors or warnings. This will probably require that some of the not yet -@@ -752,27 +880,27 @@ snap4 - * Netcam First Header patch. If an error with jpeg decompression occurred at - connecting to a mjpeg streaming webcam, this patch skips this jpeg and tries - to decompress next jpeg up to MAX_HEADER_RETRIES (20) (Peter Holik). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFirstHeader -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFirstHeader - - snap5 - * Small improvement in framerate accuracy (Peter Holik). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FramerateAdjust -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FramerateAdjust - * Fixed a bug in the autobrightness algorithm (Per Johnsson) - * Fixed a bug in the webhttpd code related to pan/tilt. Bug was introduced in - snap4 (Angel Carpintero, Kenneth Lavrsen). - * Improved the labelling algorithm so that locate feature and tracking features - includes all labelled areas above threshold (Joerg Weber). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImprovedLabellingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ImprovedLabellingPatch - * Fixed bug reporting errors when creating symlink to last snap (Bill Maidment) - * Changed all use of localtime to localtime_r which is threadsafe - (Kenneth Lavrsen). - * Implemented a modified version of the WebcamCompressInMemory so that Motion - no longer uses the tmpfile() function for buffering the frames of the mjpeg - stream (Peter Holik). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory - * Modified the WebcamCompressInMemory patch so that Motion now supports the - mjpeg webcam stream while being setup for saving PPM images (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory - * Major clean-up of code in picture.c and webcam.c so that function names and - variable names are less confusing. Also added many comments in picture.c. - (Kenneth Lavrsen). -@@ -787,13 +915,13 @@ snap6 - - snap7 - * Implemented WebcamShortWriteHandling patch (Bill Brack) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamShortWriteHandlingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamShortWriteHandlingPatch - * Implemented the libjpeg-mmx patch. Installing the MMX version of libjpeg - can increase performance. Especially for machines with very little CPU power. - It only modifies the configure script. If you do not have the libjpeg-mmx - the configure script with ignore this and use the standard libjpeg. - Note that RPMS will be built without this (Peter Holik and Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LibJpegMmx -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LibJpegMmx - - snap8 - * Small code cleanup in webcam.c and picture.c and .h for the webcam code -@@ -803,19 +931,19 @@ snap8 - overflow every 71 minutes. (Bill Brack and Kenneth Lavrsen) - * Implemented a fix/work around to a bug related to building and installing - RPMs on Suse. (Paul Beltrani) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x07x14x212356 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x07x14x212356 - * Small speed optimization in the creation of reference frame (Peter Holik). - * Complete rewrite of the Netcam code. Should fix many of the reported and - still open netcam bugs. This is first release in a snapshot. Expect to find - bugs. Testing is important. If you have a netcam please test this and report - bugs. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamCodeRewritePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamCodeRewritePatch - - snap9 - * Fixed bug related to disabled webcam or duplicate webcam port. Error log - accept(): Socket operation on non-socket continuously written to syslog. - (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x01x150922 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x01x150922 - * Fixed memory leak in webhttpd related to use of strdup (Angel Carpintero). - * Improved the error reporting in the Netcam code and did a few minor - corrections and code cleanups (Bill Brack). -@@ -823,21 +951,21 @@ snap9 - calls to printf and syslog. The implementation to actually use this has been - implemented in video.c and the Netcam code files. Rest will be in next snap. - This code change as no impact to the user (Bill Brack). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch - * Fixed a bug in video.c so that VIDEO_PALETTE_GREY cameras now actually work - (Bill Brack). - * Implemented the conversion of signal to sigaction which should be more - thread safe. Hopefully this still keeps Motion from making Zombies. - (Christophe Grenier). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ConvertSignalToSigaction -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ConvertSignalToSigaction - * Added new feature: Double size text. A new config option 'text_double' can - be set 'on' and this scales the text to double size. Default is off. - (Andrew Hamilton). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/TextScalingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/TextScalingPatch - - snap10 - * Error Logging Enhancement Patch v 1.3 (Angel Carpintero) including: -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch - * Populate the motion_log to the whole motion source code. - * Fixed FreeBSD compilation. - * Added the possibility to pass NULL as struct context * -@@ -853,9 +981,9 @@ snap10 - * fixed bug where initialization would be incomplete for invalid degrees - of rotation - * now uses motion_log for error reporting -- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateBswapFix -+ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateBswapFix - * Re-mplementation of optional Proxy Server for Network Cameras (Bill Brack). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamProxyServerPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamProxyServerPatch - * Included a CODE_STANDARD text file to help new developers make patches - that are easier to integrate without too much manual editing. (Kenneth - Lavrsen) -@@ -864,7 +992,7 @@ snap10 - snap11 - * Updated the ffmpeg.c code so that Motion can now be built with ffmpeg CVS - release from the June/July 2005 timeframe (Per Jönsson). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegCodecPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegCodecPatch - * Improved error handling of missing picture frames from camera. Especially - network cameras will often not be able to provide a picture frame from time - to time. Motion would retry before and eventually and rather quickly exit -@@ -884,12 +1012,12 @@ snap11 - "Without Locking" portion of his proposal). - Version 2 however does not seems to recover when an mjpeg stream resumes - after a period of not being available. (Bill Brack) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamErrorImprovementPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamErrorImprovementPatch - * Note: Snap11 release as a developer sync release. Bug reports welcome. - FreeBSD code changes not tested yet. - - Release -- * Netcam error handling improvements and cleanup from Walgrind analysis -+ * Netcam error handling improvements and cleanup from Valgrind analysis - (Bill Brack). - * Added a configure option --with-developer-flags which enables many compiler - warnings that can be used by developers to make code more robust. Not -@@ -897,12 +1025,12 @@ Release - * http-control: Fixed segfault when motion is restarted from command line - ( kill -s 1 pid_motion ). Improved control code so Motion can Restart and - Finish 'smoothly'. (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Changed the 5 second missed camera signal timeout to 30 seconds. (Kenneth - Lavrsen) - * Fixed bug where an extra jpeg is saved if you have output_normal=best - and you stop motion after an event has ended. (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x05x173526 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x05x173526 - - - -@@ -910,19 +1038,19 @@ Release - snap1 - * Major new feature. XMLRPC is replaced by a simpler http remote control - interface (implemented by Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - - snap2 - * Fixed netcam->userpass problem (Angel Carpintero) - * Added support in configure for athlon64 from -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x190907 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x190907 - (Angel Carpintero and William M Brack) - * Fixed some gcc warnings (William M Brack) - * Code cleanup from a valgrind analysis (William M. Brack). - - snap3 - * Added Best Preview Patch (Joerg Weber) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BestPreviewShot -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BestPreviewShot - - snap4 - * Fix for tracking control with http control (Angel Carpintero) -@@ -932,7 +1060,7 @@ snap4 - for daemon mode debugging. - The patch is still being worked on and is not finished. - Changes in the FreeBSD code are not yet tested. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SetupModePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SetupModePatch - Remove most command line options and replace them by an option to specify - location to motion.conf and a few options related to setting up motion. - (Joerg Weber). This is also included in SetupModePatch. -@@ -948,7 +1076,7 @@ snap5 - - snap6 - * Netcam fixes and debug code by Christopher Price -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - snap5_post1_video.c and snap5-post1 patches - * Fixed netcam startup race condition. - * Refactored image handling back to single unified function -@@ -1017,20 +1145,20 @@ snap9 - snap10 - * Fixed a problem when compiling with --without-v4l configuration. - (Philip Marien) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x27x112843 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x27x112843 - * Threw away the file descriptor leak fix from snap 9 because it caused - more trouble than it fixed. Removed the close_anything_open() and the - cnt_list.control_socket_server field. Replaced it all with a simple - piece of code that all server daemons call when started: setsid() followed - by for (i=getdtablesize(); i>2; --i) close(i). Dirty and simple. - (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x21x070534 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x21x070534 - * Fixed a bug where rate of fetching picture frames was disturned by - the signal SIG_CHLD from exec_command programs terminating. The symptom - was that the number of post_capture frames became inaccurate and motion - in mpegs did not have constant time between frames. (Kenneth Lavrsen) - * Fixed a bug where motion did not work with gap=1 (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x073616 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x073616 - * Added the feature gap=0 which now also works. It disables gap completely - so that one single mpeg file is created. You can end the event from the - remote control interface make movie feature using for example cron. -@@ -1058,11 +1186,11 @@ snap11 - Movie starts (mpeg file opened) --- onmpeg --- on_movie_start - Movie ends (mpeg file closed) --- onffmpegclose --- on_movie_end - Motion detected --- New! --- on_motion_detected -- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxCommandsPatch and -- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxxFeatureDiscussion -+ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxCommandsPatch and -+ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxxFeatureDiscussion - (Joerg Weber) - * More Netcam Stability Fixes (snap10-post1-6) (Christopher Price) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - * Destroy mutexes in netcam_cleanup(). - * Add reconnection for netcam_start() - this may block other cameras - from starting up!. -@@ -1093,11 +1221,11 @@ snap11 - - snap12 - * Fixed a bug in the rgb2yuv420p function. (Daniel Ladd) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x30x011107 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x30x011107 - * Fixed a bug of locate feature for movement images combined with the - new output_normal best feature (Joerg Weber) - * More Netcam Stability Fixes (snap11-post1-4) (Christopher Price) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - * Reworked thread signal/wait conditions, should fix some race conditions. - * Use gettimeofday() to determine thread timeouts, results in better accuracy. - * Adjusted condition timeouts to smaller values due to usage of gettimeofday() -@@ -1112,7 +1240,7 @@ snap12 - * Fix bug in streaming camera without content-length, recent mod broke. - * Fix bug in startup of single image reads without content-length. - * Motion Guide refactored completely for 3.2.1 with better web navigation and -- auto generation of pages. Makefile updated so that the Motion Foswiki topic -+ auto generation of pages. Makefile updated so that the Motion TWiki topic - MotionGuideOneLargeDocument is fetched when updating the guide and making - releases. (Kenneth Lavrsen). - -@@ -1135,7 +1263,7 @@ snap13 - * Userpass now allowed in url (http://user:pass@example.com/). - Netcam_userpass has precedence, it will override a userpass embedded in - the url. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - - snap14 - * Added basic authentication to the http control interface introducing new -@@ -1150,30 +1278,30 @@ snap14 - snap15 - * Added new feature which shows the fixed mask (in addition to the smart mask) - in bright red on the Motion type images (Joerg Weber). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch - * Added new feature. When you specify a mask file in the config file and start - Motion, and the mask file does not exist, Motion will create a new clear - (white) mask file for you in the right size. Then it is easy to simply - open the file in your favourite paint program and add the masking in black - (Joerg Weber). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FixedMaskFileOnMotionImagesPatch - * Fixed a bug in the low_cpu feature where cpu load increased instead of - decreasing because the framerate calculations were completely wrong. This was - an old bug introduced in 3.0.1 (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x04x24x205933 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x04x24x205933 - * Improved the auto-brightness algorithm. When auto-brightness is enabled - the brightness option becomes a target value for the brightness level. - This should also close a bug report (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x26x195358 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x26x195358 - * http interface small fixes (motion-3.2.1_snap14-small-fixes 1.1) incl - Add 'back' link to response_client errors (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Started adding tuner_number as option. This is not fully implemented. First - code is added and rest will be done in next snap. (Kenneth Lavrsen) - - snap16 - * Made the http control interface more RFC compliant (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x180550 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x180550 - * Made the http control HTML responses nicer to look at as sources and - therefore easier to debug errors (Kenneth Lavrsen). - * Code style cleanup of webhttpd.c (Kenneth Lavrsen). -@@ -1182,23 +1310,23 @@ snap16 - Carpintero. However this fix made Firefox flicker even more than it normally - does. Final fix which works in both Palantir client, Firefox and Cambozola - was made by Kenneth Lavrsen. This closes the following bugs: -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 - - snap17 - * Fixed small bug when pre_capture buffer is resized during operation. - (Joerg Weber). - * In httpd control code: Fixed RAW syntax following API specs. (Angel - Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Added new conversion specifiers: %D (diffs), (noise) %K (motion center x), - %L (motion center y), %i (locate width x) and %J (locate width y). These - changes also required a refactoring of the alg_locate code. This change - is part of the implementation of a generic tracking feature and it enables - implementing external programs that can perform simple prediction features. - (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion -- http://www.lavrsen.dk/foswiki/bin/view/Motion/GenericTrackingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion -+ http://www.lavrsen.dk/twiki/bin/view/Motion/GenericTrackingPatch - * Fixed a bug in switchfilter which caused motion detection to not work - when the feature was enabled (Kenneth Lavrsen). - -@@ -1206,26 +1334,26 @@ Release - * Change the working directory to / in daemon mode. This way you don't have - to kill motion to umount the partition from where you start it. (Christophe - Grenier) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch - * In netcam-wget header_get() didn't always in add a \0 string terminator. - This was fixed by Christophe Grenier -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch - * Fix for Unknown content type with lumenera cameras (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x06x174416 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x06x174416 - * MotionHttpControl Patch motion-3.2.1_snap18-pre1 v,1.0 19 May 2005. - Fixed some HTTP response codes and added header copyrights. (Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Implemented pthread fix by Christophe Grenier. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PthreadFixPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PthreadFixPatch - * Fixed problem compiling "ffmpeg reports only YUV420 is supported" when - ffmpeg is a recent CVS version. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x22x213229 -- * Man page updated. It is now semi-autogenerated in the Motion Foswiki -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x22x213229 -+ * Man page updated. It is now semi-autogenerated in the Motion TWiki - (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionOptionsAlphabeticalManpage -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionOptionsAlphabeticalManpage - * Bug fix in netcam code: Sometimes motion try to free an invalid memory area - (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x21x105335 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x21x105335 - * Small configure fix related to --without-v4l (Angel Carpintero) - * Fixes for http control HTML code (Angel Carpintero) - * Added init script to RPM (Angel Carpintero) -@@ -1235,15 +1363,15 @@ Release - snap1 - * Fixed bug which caused Motion 3.1.18 fail to save timelapse mpegs when - setting ffmpeg_timelapse = 1 (fixed by Michael Reuschling) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x31x211756 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x31x211756 - * Fixed several bugs in new netcam code introduced in 3.1.18 - (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x16x030209 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x01x071546 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x03x035918 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x16x030209 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x01x071546 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x03x035918 - * Added patch that enables Motion to work with vloopback version 0.94 - and kernel 2.6.10+. (patch by William M Brack). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch - - snap2 - * Following bugfixes all by Angel Carpintero -@@ -1307,17 +1435,17 @@ Detailed changes for all 3.1.18 snapshot - snap1 - * Removed the Berkeley mpeg feature (code commented out) - * Implemented a bugfixed version of -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BrightnessContrastPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BrightnessContrastPatch - Released as snapshot for developers to merge other patches. - The snap1 is not recommended for normal use. - - snap2 - * Improved the Makefile with automatic check of dependencies and - nicer output for the user. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MakefileWithAutoDependencies -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MakefileWithAutoDependencies - * Implemented first phase of the rotate patch. Need to fix the storage - method for image height and width -- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotatePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/RotatePatch - - snap3 - * Implemented phase 2 of the rotate patch -@@ -1327,7 +1455,7 @@ snap4 - * Added the new smart mask feature. It is working but it is still under - development. It currently outputs an extra smart mask timelapse movie - when the normal timelapse is enabled. This will be removed in the final -- version. http://www.lavrsen.dk/foswiki/bin/view/Motion/PatchSmartMask -+ version. http://www.lavrsen.dk/twiki/bin/view/Motion/PatchSmartMask - * Added a new config option --without-optimizecpu which disables the - CPU specific compiler optimizations introduced with the rotate phase 2 - patch. The purpose of the new option is to enable a packager to build -@@ -1344,7 +1472,7 @@ snap4 - getting lost when saving with xmlrpc. For text_left and text_right - Motion now puts the string in quotation marks if the value starts with - a leading space. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x24x135840 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x24x135840 - - snap5 - * Implemented the November 10 update for smartmask -@@ -1353,7 +1481,7 @@ snap5 - - snap6 - * Merged in the DilateNineSpeedPatch -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DilateNineSpeedPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DilateNineSpeedPatch - * Changed a few image char definitions to unsigned char. Still many to fix. - - snap7 -@@ -1364,10 +1492,10 @@ snap7 - The patch is now in ReleasedScheduled state for 3.1.18. - * Implemented Angel Carpintero's FreeBSD auto-detection CPU/ARCH fix. - * Merged in Per Johnsson's DilateFiveSpeedPatch -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DilateFiveSpeedPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DilateFiveSpeedPatch - * Removed the prediction feature from the code (commented out for now). - * Included fix by Jan X. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x11x13x202132 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x11x13x202132 - - snap8 - * Implemented an improvement of Smartmask so that the mask is cleared when -@@ -1377,40 +1505,40 @@ snap8 - * Improved the picture control function so that cameras are only probed - when needed to avoid USB errors. (Kenneth Lavrsen) - * Implemented new ffmpeg patch (Per Jönsson) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegPatch049 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegPatch049 - * Implemented new preview patch (Joerg Weber) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewShotsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewShotsPatch - * Removed commented code from obsolete Berkeley and Prediction features - * Implemented labelling speed patch (Per Jönsson) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LabelingSpeedPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LabelingSpeedPatch - - snap9 - * Implemented Streaming Netcam Without Curl which enables connecting to - network cameras both with single jpeg frame mode and streaming mjpeg - mode. This enables much higher framerates with Netcams. (by Christopher - Price and Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/StreamingNetcamWithoutCurl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/StreamingNetcamWithoutCurl - * Implemented a significant speed improvement in the motion detection - algorithm (by Per Jönsson). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/AlgDiffStandardMmxPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/AlgDiffStandardMmxPatch - * Fixed a small bug which caused in jumpy mpeg1 videos with ffmpeg 0.4.8. - - snap10 - * Corrected a small error in the usage help text -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x05x174139 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x05x174139 - * Improved the help text for config option night_compensate in docs, - conf.c, motion man pages and config file. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x103939 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x103939 - * Improved the Netcam patch (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ -+ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ - (pre2 patch fixes problem with not detecting Content-length and segfaults - in netcam) - * Improved the signal handling of ctrl-C as suggested by Per Jonsson -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x181426 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x181426 - * Implemented a POSIX compliant SIGCHLD signal handler as replacement for - the traditional signal(SIGCHLD, SIG_IGN) which can cause floods of - warnings in some RedHat versions. (Angel Carpintero and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x26x134906 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x26x134906 - * Changed the reporting of the changes of noise detection level so that - it is only displayed in the console (daemon off) when the always_changes - option is enabled. (Kenneth Lavrsen) -@@ -1423,7 +1551,7 @@ snap11 - * The noise tune value displayed in the upper left corner along with - number of changed pixels is no longer displayed (was there for debugging). - * Improved the Netcam patch (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ -+ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ - (pre3 reconnection feature added) - * Changed the SIGCHLD handler introduced in snap10 so that it is a shorter - and faster function. Disabled this handler in the xmlrpc thread as this -@@ -1434,7 +1562,7 @@ snap11 - very high or the time was changes by ntp. Motion will now catch up a few - seconds later if this happens. Also fixed the code for monthly rollover - (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x23x133554 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x23x133554 - - Release - * Fixed a bug in the timelapse feature. Both the rollover events of the -@@ -1442,7 +1570,7 @@ Release - very high or the time was changes by ntp. Motion will now catch up a few - seconds later if this happens. Also fixed the code for monthly rollover - (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x23x133554 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x23x133554 - * Small improvement in timelapse feature so that an image is added when - the new mpeg is created and not waiting till the following timelapse - (Kenneth Lavrsen). -@@ -1456,15 +1584,15 @@ snap1 - when Motion receives SIGTERM or SIGHUB. - * Implemented fix for compiling errors when building the FreeBSD version - without bktr support. -- (http://www.lavrsen.dk/foswiki/bin/view/Motion/FreeBSDFixCompile) -+ (http://www.lavrsen.dk/twiki/bin/view/Motion/FreeBSDFixCompile) - * Commented out many unnecessary syslog debug only messages. The commented - out code was first patched by Mike Lees patch related to syslog causing - instability and hanging motion processes. -- (http://www.lavrsen.dk/foswiki/bin/view/Motion/SyslogEventPatch). -+ (http://www.lavrsen.dk/twiki/bin/view/Motion/SyslogEventPatch). - * Included Kalle Andersson's patch that ensures that Motion detaches from - the stdin and stout devices so that a secure shell that was used to start - Motion in daemon mode does not hang when you exit the shell. -- (http://www.lavrsen.dk/foswiki/bin/view/Motion/DaemonDetachFromSTDIO) -+ (http://www.lavrsen.dk/twiki/bin/view/Motion/DaemonDetachFromSTDIO) - - snap2 - * Implemented a new lightswitch feature so that is now triggers lightswitch -@@ -1797,7 +1925,7 @@ rc1 - is in "idle" mode. - * added Kenneth's patch: motion with ffmpeg-0.4.8 now compiles - again! -- * small optimalisation: if a file is created, the path is now -+ * small optimisation: if a file is created, the path is now - only recreated when it did not already exist. - - -@@ -2083,7 +2211,7 @@ van Heusden (http://www.vanheusden.com/) - -locate is on by default (-l function now works reversed) - -night_compensate is on by default - Added mpeg framerate adjustment. -- Added night_compenstate for dark pictures. -+ Added night_compensate for dark pictures. - - 2.0 froze 2.0 - Integrated motion tracking. ---- motion-3.2.12.orig/CODE_STANDARD -+++ motion-3.2.12/CODE_STANDARD -@@ -17,7 +17,8 @@ void * mymalloc(size_t nbytes) - void *dummy = malloc(nbytes); - if (!dummy) { - printf("Could not allocate %llu bytes of memory!\n", (unsigned long long) nbytes); -- syslog(LOG_EMERG, "Could not allocate %llu bytes of memory!", (unsigned long long) nbytes); -+ syslog(EMERG, TYPE_ALL, "%s: Could not allocate %llu bytes of memory!", -+ __FUNCTION__, (unsigned long long) nbytes); - exit(1); - } - -@@ -41,8 +42,8 @@ void * mymalloc(size_t nbytes) - if (!dummy) { - printf("Could not allocate %llu bytes of memory!\n", - (unsigned long long) nbytes); -- syslog(LOG_EMERG, "Could not allocate %llu bytes of memory!", -- (unsigned long long) nbytes); -+ syslog(EMERG, TYPE_ALL,"Could not allocate %llu bytes of memory!", -+ __FUNCTION__, (unsigned long long) nbytes); - exit(1); - } - ---- motion-3.2.12.orig/CREDITS -+++ motion-3.2.12/CREDITS -@@ -32,14 +32,14 @@ Ryan Ayers - Paul Beltrani - * Implemented a fix/work around to a bug related to building and installing - RPMs on Suse. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x07x14x212356 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x07x14x212356 - - Michael Newlyn Blake - * For setting up the motion mailinglist and the onsave command. - - Krzysztof Blaszkowski - * Removed a duplicate call to jpeg_destroy_decompress already is called from netcam_image_conv. -- * Added V4L2 support http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). -+ * Added V4L2 support http://www.lavrsen.dk/twiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). - - Mathias Bogaert - * Lots of good ideas and the motion logos -@@ -47,30 +47,30 @@ Mathias Bogaert - William M Brack - * Added patch that enables Motion to work with vloopback version 0.94 - and kernel 2.6.10+. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionAndVloopbackVideoDotCPatch - * Added support in configure for athlon64 from -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x190907 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x190907 - (Angel Carpintero and William M Brack) - * Fixed some gcc warnings - * Code cleanup from a valgrind analysis. - * Implemented WebcamShortWriteHandling patch -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamShortWriteHandlingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamShortWriteHandlingPatch - * Small code cleanup in motion.c for the variable holding the number of - microseconds since epoch. The old code worked fine but relied on an integer - overflow every 71 minutes. (Bill Brack and Kenneth Lavrsen) - * Complete rewrite of the Netcam code. Should fix many of the reported and - still open netcam bugs. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamCodeRewritePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamCodeRewritePatch - * Improved the error reporting in the Netcam code and did a few minor - corrections and code cleanups. - * Implemented a much easier to use motion_log function which replaces the - calls to printf and syslog. The implementation to actually use this has been - implemented in video.c and the Netcam code files. Rest will be in next snap. - This code change as no impact to the user. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch - * Fixed a buf in video.c so that VIDEO_PALETTE_GREY cameras now actually work. - * Re-mplementation of optional Proxy Server for Network Cameras. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamProxyServerPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamProxyServerPatch - * Added the missing rotate feature in the new netcam code (Billl Brack) - * Netcam error handling improvements and cleanup from Valgrind analysis. - * Added a configure option --with-developer-flags which enables many compiler -@@ -80,7 +80,7 @@ William M Brack - ./configure --with-developer-flags. - The modifications were done by the following people: Peter Holik, Bill Brack, - Angel Carpintero and Kenneth Lavrsen. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch - * Fixed error message with unknown config option. - * Enhanced compatibility with Lumenera. - * Moved the motion_loop initialization into a new function motion_init. -@@ -89,17 +89,17 @@ William M Brack - * Last --with-developer-flags warnings eliminated simply by swapping the - order of the #include statements in the sources (Bill Brack and Kenneth Lavrsen). - * Enhancement to Netcam Code for Connection to Pixord Cameras. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFixPixordBug -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFixPixordBug - * Fix related to connecting to the netcam. From mailing list 23 Dec 2005. - * Fixed problem related to fetching images from Network camera and error - handling when it fails. Motion would end in infinite loops. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x10x000151 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x10x000151 - * Fix conv_uyvyto420p segfault. - * Enhancing the palette selection. - - John Bray - * Get current directory to allow write motion.conf properly -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x013419 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x013419 - - Andy Brown - * Add swf codec to video creation (on behalf of Bowser Pete). -@@ -130,21 +130,21 @@ Angel Carpintero - mode. This enables much higher framerates with Netcams. (with - Christopher Price). - * Improved the Netcam patch (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ -+ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ - (pre2 patch fixes problem with not detecting Content-length and segfaults - in netcam) - * Implemented a POSIX compliant SIGCHLD signal handler as replacement for - the traditional signal(SIGCHLD, SIG_IGN) which can cause floods of - warnings in some RedHat versions. (with Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x26x134906 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x26x134906 - * Improved the Netcam patch (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/pub/Motion/StreamingNetcamWithoutCurl/ -+ http://www.lavrsen.dk/twiki/pub/Motion/StreamingNetcamWithoutCurl/ - (pre3 reconnection feature added) - * Fixed several bugs in new netcam code introduced in 3.1.18 - (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x16x030209 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x01x071546 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x03x035918 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x16x030209 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x01x071546 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x03x035918 - * Netcam code: Change printf() to fprintf(). - * Netcam code: Cleanup memory netcam (netcam.c , motion.c ). - * Netcam code: Redesign of reconnection feature. -@@ -154,10 +154,10 @@ Angel Carpintero - * Added fix to BugReport2005x02x11x150802 - * Major new feature. XMLRPC is replaced by a simpler http remote control - interface. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Fixed netcam->userpass problem - * Added support in configure for athlon64 from -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x190907 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x190907 - (Angel Carpintero and William M Brack) - * Updated code so Motion again runs on FreeBSD. - * Removed check for memmem from configure. -@@ -174,42 +174,42 @@ Angel Carpintero - (string) by submitting blank entry field in the http control interface. - * http interface small fixes (motion-3.2.1_snap14-small-fixes 1.1) incl - Add 'back' link to response_client errors. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Made the http control interface more RFC compliant. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x180550 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x180550 - * Fixed compatibility problem with Palantir. Fixed by making output more - compatible with RFC (\r\n). Original fixes by Roberto Spadim and Angel - Carpintero. However this fix made Firefox flicker even more than it normally - does. Final fix which works in both Palantir client, Firefox and Cambozola - was made by Kenneth Lavrsen. This closes the following bugs: -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 - * In httpd control code: Fixed RAW syntax following API specs. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * MotionHttpControl Patch motion-3.2.1_snap18-pre1 v,1.0 19 May 2005. - Fixed some HTTP response codes and added header copyrights. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl - * Fixed problem compiling "ffmpeg reports only YUV420 is supported" when - ffmpeg is a recent CVS version. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x22x213229 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x22x213229 - * Bug fix in netcam code: Sometimes motion try to free an invalid memory area -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x21x105335 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x21x105335 - * Small configure fix related to --without-v4l. - * Fixes for http control HTML code. - * Added init script to RPM. - * Pthread deadlock in motion 3.2.1 fixed. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x26x125712 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x26x125712 - * http lockup bugfixes and ConvertSignalToSigaction only for webhttpd - * alg_draw_location: Use temporary variables to store the values used in - for() loops instead of compute them in each loop -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImproveAlgDrawLocation. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ImproveAlgDrawLocation. - * Small speed boost to the function draw_textn (Andrew Hamilton and - Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextnImprovement -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextnImprovement - * Avoid Cleanup Segfault. Avoid Cleanup Segfault. Allocates filepath using - strdup to avoid segfault is target_dir parameter is not supplied in - motion.conf. Moves out from signal handler the cleanup for pipe and mpipe. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidCleanupSegfault -+ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidCleanupSegfault - * Changed the configure script so that rpms can be made by normal non-root - users. - * Above change in configure script for 64 bit ffmpeg support also implemented -@@ -222,7 +222,7 @@ Angel Carpintero - It only modifies the configure script. If you do not have the libjpeg-mmx - the configure script with ignore this and use the standard libjpeg. - Note that RPMS will be built without this (Peter Holik and Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LibJpegMmx -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LibJpegMmx - * Fixed memory leak in webhttpd related to use of strdup. - * Error Logging Enhancement Patch v 1.3 including: - * Populate the motion_log to the whole motion source code. -@@ -234,25 +234,25 @@ Angel Carpintero - * Fixed a bug when not motion.conf is found - * Removed printf from all files - * Fixed the conf_list[] index in motion.c -- * http://www.lavrsen.dk/foswiki/bin/view/Motion/ErrorLoggingEnhancementPatch -+ * http://www.lavrsen.dk/twiki/bin/view/Motion/ErrorLoggingEnhancementPatch - * http-control: Fixed segfault when motion is restarted from command line - ( kill -s 1 pid_motion ). Improved control code so Motion can Restart and - Finish 'smoothly'. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpControl. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpControl. - * Fixed a bug in the http control code that failed to accept a client - connecting in some systems - * Removed all warnings originating from the motion sources when running - ./configure --with-developer-flags. - The modifications were done by the following people: Peter Holik, Bill Brack, - Angel Carpintero and Kenneth Lavrsen. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch - * Fixed small mistake in allocating memory for cnt->imgs.common_buffer. - * http control updated: (null) messages replaced by "disabled", last parameter - in conf/list are displayed correctly and only in Main thread. When motion runs - with only one thread, it displays "No threads". - * http control: selectbox instead of a textfield for changing boolean configs - (Peter Holik and Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebhttpEnhancements. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebhttpEnhancements. - * Added the debian sub directory so that people can build the deb package. - * Sync configure.in.freebsd (adding support for jpeg-mmx, developer-flags and - some cosmetic changes ). -@@ -271,20 +271,20 @@ Angel Carpintero - * Cleanup code and fix warnings. - * Implemented fix to configure so that LDFLAGS from the environment are used - when making the Makefile. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x09x15x185558 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x09x15x185558 - * Changed configure so that --with-jpeg-mmx is default off as a reaction to - known problems seen when using the jpeg-mmx library. - * Added the %t conversion specifier to show the thread number. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadConversionSpecifierPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadConversionSpecifierPatch - * Fixed bug related to init of mutex in netcam code. - * Netcam_ftp code fixes (Angel Carpintero and Asbjørn Pettersen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFtpEnhancements -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFtpEnhancements - * Enhanced ffmpeg detection. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BetterFFmpegDetection -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BetterFFmpegDetection - * New Feature: Motion is now also supported on MaxOSX with similar - feature set as for Free BSD. See README.MacOSX for details how to install - it. (Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MacOSXPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MacOSXPatch - * Added a work-around so people in FreeBSD that uses a capture card - where input 1 is not tuner can use motion if frequency is set -1 in - motion.conf or thread#.conf. -@@ -298,28 +298,28 @@ Angel Carpintero - * Remove a warning when used --without-bktr - * Remove cpu optimization (is broken) - * Fixed http control of pan and tilt. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x12x22x122649 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x12x22x122649 - * Fixed sql_mask not initialised correctly -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x09x175603 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x09x175603 - * Fixed the management of strings from http remote control , setting to NULL - when they are set to "blank" and fixes a problem with despeckle , that didn't - allow to remove labeling action from http remote control. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixStringsAndDisableLabeling -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FixStringsAndDisableLabeling - * Fix many typos in comments ( i ran aspell against the code ). Also there's a - fix to free cnt->eventtime_tm when motion exits. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FixTypoInComments -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FixTypoInComments - * Fix the problem that happens in FreeBSD and Debian Sarge because - version of ffmpeg is LIBAVFORMAT_BUILD < 4629. ( Pete Shipley and Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x12x120335 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x12x120335 - * Updated motion.spec. Changing D_FORTIFY_SOURCE=2 by D_FORTIFY_SOURCE=1 to fix - problem related to building with ffmpeg. (Angel Carpintero) - * Added Tilt support to stepper track. - * Fixed mysql configure auto-detection for x64 systems. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x03x02x152208 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x03x02x152208 - * Fixed a bug that only allowed remote control of max 9 cameras. Now - Motion can present up to 99 cameras in its http remote control interface - (Angel Carpintero based on idea by Chuck Sheehan) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHttpManyThreads -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebHttpManyThreads - * Removed annoying debug messages (v4l_set_input really needed ?) in the FreeBSD - version. - * Added new feature: minimum_frame_time which enables capturing at a lower rate -@@ -331,97 +331,112 @@ Angel Carpintero - safe functions in ffmpeg - * Put a new global mutex around avcodec_close to avoid problems with not thread - safe functions in ffmpeg. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 - * On FreeBSD configure defines a redundant freebsd for motion. Fixed by replacing - -D__freebsd_ by BSD macro included in sys/param.h for BSD platforms. - (JukkaUkkonen and Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x070417 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x070417 - * For BSD platforms changed to using native pthreads as default and adding - linuxthreads as a optional parameter from configure. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x071646 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x071646 - * Added process_id_file feature -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x06x06x123003 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x06x06x123003 - * Add connection status for all devices available from http web interface. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x11x09x050638 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x11x09x050638 - * Improved deb packaging , install the init.d script. - * Reconnect to mysql if connection dropped. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x10x10x081903 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x10x10x081903 - * Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero ) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch -- * Added V4L2 support http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch -+ * Added V4L2 support http://www.lavrsen.dk/twiki/bin/view/Motion/VideoForLinuxTwoDiscussion, (Krzysztof Blaszkowski, Angel Carpintero). - * Added support for V4L2_PIX_FMT_SBGGR8 ( bayer ), V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_MJPEG and V4L2_PIX_FMT_UYVY. - * Added a FreeBSD directory to allow people from BSD to get a daily version and create a port. - * Removed mysql dependency from debian package and added a note to setup motion to run as daemon to create the pid file. -- * Changed the way configure search mysql headers and libs, added 3 parameters to configure --without-mysql to disable support, --with- mysql-include directory of mysql.h and --with-mysql-lib directory of libmysqlclient.a or libmysqlclient.so -+ * Changed the way configure search mysql headers and libs, added 3 parameters to configure --without-mysql to disable support, -+ --with-mysql-include directory of mysql.h and --with-mysql-lib directory of libmysqlclient.a or libmysqlclient.so - * Fix an error in FreeBSD , the use of capture even fields depends on height value. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x03x073610 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x03x073610 - * Fixed autodetection for VIA cpu , no needed to use --without-optimizecpu. Added many others. - * Fix , don't remove pid file when motion reload config file( HUP signal ). - * Fix compilation broken by uvc track type. - * Fix RoundRobin v4l2 buffers in driver when switching input, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x07x07x182605 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x07x07x182605 - (Dag Erlandsson and Angel Carpintero). - * Check EIO for VIDIOC_DQBUF to workaround saa7134 problem. - (Dag Erlandsson and Angel Carpintero). - * Change bayer2rgb24() to fix a problem with sn9c102 driver -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x06x05x012249 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x06x05x012249 - (Jared D and Angel Carpintero). - * Added MYSQL_OPT_RECONNECT flag for mysql connection (MYSQL 5.x only) and - changed default value for mysql_host. - * Fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391055 , change - motion man page , -d requires level. - * Handle mjpeg decoding and fix colour issue adding mjpegtools dependency -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegColorIssue -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegToYUV420pPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegColorIssue -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch - (Marius Rieder, Angel Carpintero). - * Fix segfault in webhttpd.c on motion restart. -- * Fix segfault in debian http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x09x24x175945 -+ * Fix segfault in debian http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x09x24x175945 - * Add debug level > 5 to get logs from v4l2_select_input, v4l2_set_control and v4l2_set_input. - * Removed debian ( to avoid conflicts with debian package) and FreeBSD - ( no needed to deploy BSD port here ) directories. - * Improve debian package, create user/group motion and added --chuid motion to init script. -- * Added help in http control http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x181541 -- * Fixed http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x23x093651 -+ * Added help in http control http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x181541 -+ * Fixed http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x23x093651 - * Fix process_id_file when is passed from command line -- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x10x27x150419 -- * Added Choose V4L2 palette http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x11x19x032318 -+ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x10x27x150419 -+ * Added Choose V4L2 palette http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x11x19x032318 - * Improved in http control ( 'back' link, select box, show current values when are going to be changed ). -- * Fix http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x25x102808 -+ * Fix http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x25x102808 - * Avoid random errors , initialising some structs for V4L1 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) - * Fix motion segfault because ffmpeg API change -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2007x12x29x17553 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2007x12x29x17553 - * Little fix in ffmpeg.c comparing version of LIBAVFORMAT_BUILD, since ffmpeg svn -r4486 LIBAVFORMAT_BUILD and - LIBAVCODEC_BUILD uses LIBAVFORMAT_VERSION_INT ((49<<16)+(0<<8)+0) and LIBAVCODEC_VERSION_INT ((49<<16)+(0<<8)+0) - * Fix broken PostgreSQL detection for custom location, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x25x025134 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x25x025134 - * Fixed stepper when is used track_auto on. - * Added to configure.in --with-pwcbsd to allow compile motion in freebsd with webcam support instead of bktr. -+ * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 -+ (Jeroen Massar & Angel Carpintero) - * Fix a security issue in web control interface http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484572 - * Fix Problem Encoding 1280x1024 resolution videos -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x06x11x183727 -- * Remove mjpegtools dependencies and integrate only needed functions from library. -- * Fix rotate for v4l2 devices using JPEG / MJPEG palettes. -- * Allow change/setup framerate in FreeBSD using pwcbsd. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x06x11x183727 -+ * Add write/read nonblock functions in webhttpd( timeout on read/write). - * Add a new parameter netcam_tolerant_check, to be less strict with some buggy network cameras firmwares. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x06x19x123218 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x06x19x123218 -+ * Remove mjpegtools dependencies and integrate only needed functions from library. -+ * Fix rotate for v4l2 devices using JPEG / MJPEG palettes. -+ * External pipe to allow external video encoders -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Bill Payne, Angel Carpintero) -+ * Allow change/setup framerate in FreeBSD using pwcbsd - * Get rid of ffmpeg-config in configure.in for debian. - * Fix warning for x86_64 in conf.c using pointers LP64 compliant. -- * Fix fd leaks in external pipe. -- * Avoid possible stack smashing in v4l_open_vidpipe(). -+ * Fix warning for syslog() , Added support for some new bayer palettes introduced in kernel 2.6.27. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2008x10x15x130110 -+ Increased buffer in ffmpeg to allow encoding at 1600x1200 -+ * Avoid possible stack smashing in v4l_open_vidpipe(). - * Allow compile with OpenSuse ffmpeg package (15594svn-20081010) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2008x10x25x070400 -- * Better detection of ffmpeg -- http://www.lavrsen.dk/foswiki/pub/Motion/ReleaseNoteMotion3x2x11/ffmpeg-detection.diff.gz -- (Angel Carpintero) -- * Fix warning for syslog(). -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2008x10x25x070400 -+ * Avoid segfault detecting strerror_r() version GNU or SUSv3. -+ * 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. - * Fixed FFV1 codec encode with ffmpeg. - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x13x032553 -+ * 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 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x06x05x012249 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x06x05x012249 - (Jared D and Angel Carpintero). - - John Edwards -@@ -429,23 +444,30 @@ John Edwards - - Dag Erlandsson - * Fix RoundRobin v4l2 buffers in driver when switching input, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x07x07x182605 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x07x07x182605 - (Dag Erlandsson and Angel Carpintero). - * Check EIO for VIDIOC_DQBUF to workaround saa7134 problem. - (Dag Erlandsson and Angel Carpintero). - * Added the pre_capture buffer redesign to throttle load and enhance pre_capture feature. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreCaptureRedesign -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PreCaptureRedesign - * Fixed a problem with locate and fixed mask overlay - * Added preview center feature. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewCenter -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewCenter - * Fixed timestamp for preview pictures. -+ * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 - - Stephen Farrugia - * Fixing the division by zero problem. - This makes motion a lot more stable. - -+Michael Finsterbusch -+ -+ * Add authentication methods 'Basic Authentication' and 'Digest Authentication' -+ to the "Live Stream Server". -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionStreamAuthPatch -+ - Mark Feenstra -- * Fix zombies on OpenBSD. -+ * Fix zombies on OpenBSD. - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x28x054348 - - Miguel Freitas -@@ -455,6 +477,9 @@ Aaron Gage - * Pointed me to the vid_mmap/int problem when calling SYNC in - video.c - -+Giacomo Graziosi -+ * Sqlite3 support http://www.lavrsen.dk/twiki/bin/view/Motion/SQLite3Patch -+ - Christophe Grenier - * Fixed some file descriptor leaks in webcam.c and netcam.c. - * Renamed the top level global context structure to cnt_list so it can be -@@ -467,15 +492,15 @@ Christophe Grenier - Kenneth Lavrsen. - * Change the working directory to / in daemon mode. This way you don't have - to kill motion to umount the partition from where you start it. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch - * In netcam-wget header_get() didn't always in add a \0 string terminator. - This was fixed. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ChdirNetCamWgetPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ChdirNetCamWgetPatch - * Made a pthread fix. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PthreadFixPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PthreadFixPatch - * Implemented the conversion of signal to sigaction which should be more - thread safe. Hopefully this still keeps Motion from making Zombies. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ConvertSignalToSigaction -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ConvertSignalToSigaction - - Mihnea-Costin Grigore - * Fixed the oldlayout behaviour of snapshots. -@@ -485,7 +510,7 @@ Mihnea-Costin Grigore - - Alain Guidez - * Fix of ffmpeg_avcodec_log code. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x25x074612 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x25x074612 - - Jan Gyselinck - * Original time/date-stamp code. -@@ -502,37 +527,38 @@ Steffen Haas - Andrew Hamilton - * Small speed boost to the function draw_textn (Andrew Hamilton and - Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextnImprovement -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextnImprovement - * Added new feature: Double size text. A new config option 'text_double' can - be set 'on' and this scales the text to double size. Default is off. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/TextScalingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/TextScalingPatch - * Fixed memory leak in ffmpeg code. - * Added the ffmpeg_deinterlace feature -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionffmpegDeinterlace -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionffmpegDeinterlace - * Added FFV1 ( FF video codec 1 ) codec , Lossless encoding -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LosslessEncoding -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LosslessEncoding - * Added mov , Quicktime file format (Andrew Hamilton). - - Gerrit Hannaert -- * Fix v4l2_palette http://www.lavrsen.dk/foswiki/bin/view/Motion/UvcvideoMjpegPatch -+ -+ * Fix v4l2_palette http://www.lavrsen.dk/twiki/bin/view/Motion/UvcvideoMjpegPatch - - Peter Holik - * Netcam First Header patch. If an error with jpeg decompression occurred at - connecting to a mjpeg streaming webcam, this patch skips this jpeg and tries - to decompress next jpeg up to MAX_HEADER_RETRIES (20). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamFirstHeader -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamFirstHeader - * Small improvement in framerate accuracy. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FramerateAdjust -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FramerateAdjust - * Implemented a modified version of the WebcamCompressInMemory so that Motion - no longer uses the tmpfile() function for buffering the frames of the mjpeg - stream. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory - * Implemented the libjpeg-mmx patch. Installing the MMX version of libjpeg - can increase performance. Especially for machines with very little CPU power. - It only modifies the configure script. If you do not have the libjpeg-mmx - the configure script with ignore this and use the standard libjpeg. - Note that RPMS will be built without this (Peter Holik and Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LibJpegMmx -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LibJpegMmx - * Small code cleanup in webcam.c and picture.c and .h for the webcam code - (Peter Holik and Kenneth Lavrsen). - * Small speed optimization in the creation of reference frame. -@@ -540,22 +566,27 @@ Peter Holik - ./configure --with-developer-flags. - The modifications were done by the following people: Peter Holik, Bill Brack, - Angel Carpintero and Kenneth Lavrsen. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch - * Implemented a speed-up patch of the draw text feature. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/DrawTextspeedup -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DrawTextspeedup - * http control: selectbox instead of a textfield for changing boolean configs - (Peter Holik and Angel Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebhttpEnhancements. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebhttpEnhancements. - * Introduced check for device image size being a multiple of 16. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamModulo16Patch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamModulo16Patch - * Fixed netcamera bug related to separating frames in an mjpeg stream. - From mailing list 23 Dec 2005. - * Avoid open file descriptor when connecting to network cameras fails -- http://www.lavrsen.dk/foswiki/bin/view/Motion/AvoidOpenfiledescriptors -+ http://www.lavrsen.dk/twiki/bin/view/Motion/AvoidOpenfiledescriptors - * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) - http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 - * Fix warning for __USE_GNU redefined -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x122137 -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x122137 -+ * Use static memory allocation in ffmpeg_deinterlace() -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegDeinterlaceStatic -+ * Atom optimizacion in configure.in -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/AtomOptimizations -+ - - Wesley Hosking - * For pointing me to the absence of a frame length check using -@@ -569,15 +600,15 @@ Per Jönsson - * Added the rotate feature. - * Improved the Makefile with automatic check of dependencies and - nicer output for the user. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MakefileWithAutoDependencies -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MakefileWithAutoDependencies - * Improved rotate feature (speed) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotatePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/RotatePatch - * Implemented new ffmpeg patch -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegPatch049 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegPatch049 - * Implemented labelling speed patch -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LabelingSpeedPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LabelingSpeedPatch - * Improved the signal handling of ctrl-C -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x181426 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x181426 - * Fixed the ffmpeg code so that Motion also compiles against libavcodec - build 4754 or later. - * Fixed a bug in the autobrightness algorithm. -@@ -587,28 +618,28 @@ Per Jönsson - * fixed bug where initialization would be incomplete for invalid degrees - of rotation - * now uses motion_log for error reporting -- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateBswapFix -+ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateBswapFix - * Implemented Threadnr in TLS (thread-local storage)patch. It puts the thread - number into TLS and modifies motion_log() so that we do not have to drag the - cnt struct around just to be able to print the thread number in the log and - on the console. (Per Jönsson with additional removal of unused cnt by - Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadNrTlsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadNrTlsPatch - * Simplified rotation code based on the fact that images must have dimensions - that are a multiple of 16. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/RotateSimplificationPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/RotateSimplificationPatch - - Mike Kenney - * Implemented a fix for the rare problem where some experienced that the - move file names would only consist of the extension .mpg or .avi with no - name in front. The root cause was the use of sprintf for appending to - strings. (Mike Kenney and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2005x09x05x133031 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x06x19x174238 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2005x09x05x133031 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x06x19x174238 - - Rafis Khayrullin - * Fix memory management in ffmpeg.c -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x12x19x062432 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x12x19x062432 - - Matthias Kilian - * Configure patch which enables configure to find and use a -@@ -616,7 +647,7 @@ Matthias Kilian - - Daniel Ladd - * Fixed a bug in the rgb2yuv420p function. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x30x011107 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x30x011107 - - Kenneth Lavrsen (Currently project managing Motion) - * Wrote the excellent Motion Guide. (Jeroen wrote this :-) ) -@@ -720,14 +751,14 @@ Kenneth Lavrsen (Currently project manag - * Fixed a bug in netcam_start() - wrong imgs.size calculation. - * Removed the obsolete Berkeley mpeg feature. - * Corrected a small error in the usage help text -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x05x174139 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x05x174139 - * Improved the help text for config option night_compensate in docs, - conf.c, motion man pages and config file. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x06x103939 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x06x103939 - * Implemented a POSIX compliant SIGCHLD signal handler as replacement for - the traditional signal(SIGCHLD, SIG_IGN) which can cause floods of - warnings in some RedHat versions. (with Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2004x10x26x134906 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2004x10x26x134906 - * Changed the reporting of the changes of noise detection level so that - it is only displayed in the console (daemon off) when the always_changes - option is enabled. (Kenneth Lavrsen) -@@ -746,7 +777,7 @@ Kenneth Lavrsen (Currently project manag - very high or the time was changes by ntp. Motion will now catch up a few - seconds later if this happens. Also fixed the code for monthly rollover. - (Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x23x133554 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x23x133554 - * Small improvement in timelapse feature so that an image is added when - the new mpeg is created and not waiting till the following timelapse - (Kenneth Lavrsen). -@@ -786,13 +817,13 @@ Kenneth Lavrsen (Currently project manag - cnt_list.control_socket_server field. Replaced it all with a simple - piece of code that all server daemons call when started: setsid() followed - by for (i=getdtablesize(); i>2; --i) close(i). Dirty and simple. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x03x21x070534 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x03x21x070534 - * Fixed a bug where rate of fetching picture frames was disturned by - the signal SIG_CHLD from exec_command programs terminating. The symptom - was that the number of post_capture frames became inaccurate and motion - in mpegs did not have constant time between frames. - * Fixed a bug where motion did not work with gap=1. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x30x073616 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x30x073616 - * Added the feature gap=0 which now also works. It disables gap completely - so that one single mpeg file is created. You can end the event from the - remote control interface make movie feature using for example cron. -@@ -806,7 +837,7 @@ Kenneth Lavrsen (Currently project manag - * Improvements of motion.conf help comments including improvements in new - onxxxx options. - * Motion Guide refactored completely for 3.2.1 with better web navigation and -- auto generation of pages. Makefile updated so that the Motion Foswiki topic -+ auto generation of pages. Makefile updated so that the Motion TWiki topic - MotionGuideOneLargeDocument is fetched when updating the guide and making - releases. - * Removed the debug_parameter option which had no use. Programmers can still -@@ -822,11 +853,11 @@ Kenneth Lavrsen (Currently project manag - * Fixed a bug in the low_cpu feature where cpu load increased instead of - decreasing because the framerate calculations were completely wrong. This was - an old bug introduced in 3.0.1. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x04x24x205933 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x04x24x205933 - * Improved the auto-brightness algorithm. When auto-brightness is enabled - the brightness option becomes a target value for the brightness level. - This should also close a bug report. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x02x26x195358. -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x02x26x195358. - * Made the http control HTML responses nicer to look at as sources and - therefore easier to debug errors. - * Code style cleanup of webhttpd.c. -@@ -835,22 +866,22 @@ Kenneth Lavrsen (Currently project manag - Carpintero. However this fix made Firefox flicker even more than it normally - does. Final fix which works in both Palantir client, Firefox and Cambozola - was made by Kenneth Lavrsen. This closes the following bugs: -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 - * Added new conversion specifiers: %D (diffs), (noise) %K (motion center x), - %L (motion center y), %i (locate width x) and %J (locate width y). These - changes also required a refactoring of the alg_locate code. This change - is part of the implementation of a generic tracking feature and it enables - implementing external programs that can perform simple prediction features. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion -- http://www.lavrsen.dk/foswiki/bin/view/Motion/GenericTrackingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ExtendReplaceConversionSpecifiersDiscussion -+ http://www.lavrsen.dk/twiki/bin/view/Motion/GenericTrackingPatch - * Fixed a bug in switchfilter which caused motion detection to not work - when the feature was enabled. - * Fix for Unknown content type with lumenera cameras -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x06x174416 -- * Man page updated. It is now semi-autogenerated in the Motion Foswiki -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionOptionsAlphabeticalManpage -- * Added two new conversion specifiers: %o for threshold and %Q for number -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x06x174416 -+ * Man page updated. It is now semi-autogenerated in the Motion TWiki -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionOptionsAlphabeticalManpage -+ * Added two new convertion specifiers: %o for threshold and %Q for number - of labels. - * Improved the config file description for pre_capture to get people to - use small values. -@@ -868,7 +899,7 @@ Kenneth Lavrsen (Currently project manag - * Changed all use of localtime to localtime_r which is threadsafe. - * Modified the WebcamCompressInMemory patch so that Motion now supports the - mjpeg webcam stream while being setup for saving PPM images. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/WebcamCompressInMemory -+ http://www.lavrsen.dk/twiki/bin/view/Motion/WebcamCompressInMemory - * Major clean-up of code in picture.c and webcam.c so that function names and - variable names are less confusing. Also added many comments in picture.c. - * Webcam code commented more. -@@ -884,26 +915,26 @@ Kenneth Lavrsen (Currently project manag - overflow every 71 minutes. (Bill Brack and Kenneth Lavrsen) - * Fixed bug related to disabled webcam or duplicate webcam port. Error log - accept(): Socket operation on non-socket continuously written to syslog. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x01x150922 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x01x150922 - * Included a CODE_STANDARD text file to help new developers make patches - that are easier to integrate without too much manual editing. - * Changed the 5 second missed camera signal timeout to 30 seconds. - * Fixed bug where an extra jpeg is saved if you have output_normal=best - and you stop motion after an event has ended. (Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x08x05x173526 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x08x05x173526 - * Option switch filter used print_int instead of print_bool when motion.conf - was saved. - * Removed all warnings originating from the motion sources when running - ./configure --with-developer-flags. - The modifications were done by the following people: Peter Holik, Bill Brack, - Angel Carpintero and Kenneth Lavrsen. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReduceWarningsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReduceWarningsPatch - * Implemented Threadnr in TLS (thread-local storage)patch. It puts the thread - number into TLS and modifies motion_log() so that we do not have to drag the - cnt struct around just to be able to print the thread number in the log and - on the console. (Per Jönsson with additional removal of unused cnt by - Kenneth Lavrsen). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ThreadNrTlsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ThreadNrTlsPatch - * Removed old unused code related to read mode (not mmap) from V4L devices. - * Motion loop resets its frame timer when the image received is from a netcam. - This lowers the actual framerate of Motion to the rate the netcam can actually -@@ -925,7 +956,7 @@ Kenneth Lavrsen (Currently project manag - string when no event is in progress (gap period expired). Pre_captured - and minimum_motion_frames images are time stamped before the event happens - so %C in text_left/right does not have any effect on those images. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/EventConvertionSpecifierDiscussion -+ http://www.lavrsen.dk/twiki/bin/view/Motion/EventConvertionSpecifierDiscussion - * Renamed some variables related to time to be better descriptive of function - and type. - * Added new option 'sql_user_text'. This can be defined with the same -@@ -937,7 +968,7 @@ Kenneth Lavrsen (Currently project manag - * The lightswitch and switchfilter features have been moved up before the - despeckle features are run. This should ensure that both algorithms work on - raw unfiltered motion pixels which they both were designed for. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x05x212444 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x05x212444 - * Added help texts in conf.c and motion-dist.conf describing the %t - specifier. Added a good example of use in motion-dist.conf. - * Added two new conversion specifiers: %f which is filename (full path) -@@ -973,7 +1004,7 @@ Kenneth Lavrsen (Currently project manag - * Restored the function sigchild_handler so it contains the same code - as before motion-3.2.1_snap9. They is done in an attempt to fix an old - problem with zombie child processes that has shown up again. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x11x13x115016 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x11x13x115016 - * Move the declaration of sig_handler_action and sigchild_action from - the setup_signals function where they are local and will be destroyed - and out in main just before setup_signals is called. Changed the -@@ -993,39 +1024,39 @@ Kenneth Lavrsen (Currently project manag - is re-enabled the minute the camera is standing still again. Feature - originally made by Moshe Van Der Sterre. Kenneth Lavrsen extended it to - be more generic. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PwcConfiguration -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PwcConfiguration - * Implemented fix for missed snapshots with slow network cameras -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x162149 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x162149 - * Added some constants in video.c function v4l_picture_controls() which can help - people hack an optimal set of values for controlling auto brightness for their - particular camera. For now I am do not want to add all of these to the already - too large number of motion config options. Maybe based on feedback we can - permanently change the constants and add an additional auto brightness option. - Or maybe a combined option that sets more constant based on an algorithm. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x02x07x212816 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x02x07x212816 - * Fixed a syntax error in picture.c get_pgm() which caused the program to segfault - when a mask file size did not match the picture size. Now the program - correctly gives an error message and continues without the mask. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x10x08x150720 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x10x08x150720 - * ffmpeg_filename has changed name to movie_filename to prepare for - alternative movie encoding to the current ffmpeg based implementation - and ffmpeg_filename will then be a bad name. - * Fixed bug where variables time_last_frame and time_current_frame had been - extended to also be used for snapshot feature but declaration was hidden - between #ifdef HAVE_FFMPEG. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x03x09x012244 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x03x09x012244 - * text_changes now shows a '-' when motion detection is paused instead of - just showing 0 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2006x03x16x095713 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2006x03x16x095713 - * Improved reporting of thread numbers during startup in setup mode. - (Peter Smith and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging - * Implemented a fix for the rare problem where some experienced that the - move file names would only consist of the extension .mpg or .avi with no - name in front. The root cause was the use of sprintf for appending to - strings. (Mike Kenney and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2005x09x05x133031 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SupportQuestion2006x06x19x174238 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2005x09x05x133031 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SupportQuestion2006x06x19x174238 - * Altered the risky use of sprintf to snprintf in all places related to - use with config strings that can become very long. - * Removed the minimum_gap feature which was utterly useless -@@ -1045,11 +1076,20 @@ Mike Lees - * Fixed a serious stability issue related to syslog not being a fully - re-entrant function. - * Implemented the new brightness, contrast, hue, saturation features -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BrightnessContrastPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BrightnessContrastPatch -+ -+Wim Lewis -+ -+ * Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch - - Michal Licko - * Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero ) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch -+ -+Michael Luich -+ -+ * Added codec Ogg/Theora as new output format for regular movies. -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/OggTimelapse - - Bill Maidment - * Fixed bug reporting errors when creating symlink to last snap. -@@ -1057,6 +1097,10 @@ Bill Maidment - Philip Marien - * Fixed a problem when compiling with --without-v4l configuration. - -+Jeroen Massar -+ * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 -+ (Jeroen Massar & Angel Carpintero) -+ - Lionnel Maugis - * ffmpeg code - -@@ -1091,17 +1135,21 @@ nullset? - * For the ir script to turn motion and lights on and of - - Onakra -- * Fix choose v4l2 palette , http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x01x21x043812 -+ * Fix choose v4l2 palette , http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x01x21x043812 - - Mikko Paananen - * Changed netcam open to use pipes and fixed authentication. - -+Bill Payne, -+ * External pipe to allow external video encoders -+ http://www.lavrsen.dk/twiki/bin/view/Motion/DarkwindHackeronMotionPatching (Angel Carpintero, Bill Payne) -+ - Bowser Pete - * Add swf codec to video creation. - - Asbjørn Pettersen - * Netcam_ftp code fixes (Angel Carpintero and Asbjørn Pettersen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamWithFtpEnhancements -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamWithFtpEnhancements - - Pawel Pierscionek - * Signal blocking during ioctls. -@@ -1120,9 +1168,9 @@ Christopher Price - network cameras both with single jpeg frame mode and streaming mjpeg - mode. This enables much higher framerates with Netcams. (with Angel - Carpintero). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/StreamingNetcamWithoutCurl -+ http://www.lavrsen.dk/twiki/bin/view/Motion/StreamingNetcamWithoutCurl - * Netcam fixes and debug code by Christopher Price -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - * snap5_post1_video.c and snap5-post1 patches - * Fixed netcam startup race condition. - * Refactored image handling back to single unified function -@@ -1137,7 +1185,7 @@ Christopher Price - * Added support for netcams without content-length header (streaming only) - * Remove memmem from netcam_wget.[c|h] (no longer used) - * Several miscellaneous code cosmetic changes -- * Netcam Stabilty Patch version 3.2.1-snap7-post1 -+ * Netcam Stability Patch version 3.2.1-snap7-post1 - * Added support for non-streaming (image based) netcams without - content-lengthheader. - * Contributed code for new function in event.c close_anything_open() -@@ -1146,7 +1194,7 @@ Christopher Price - causing freezing and instability. Code contributed by Christophe Grenier, - Christopher Price and Kenneth Lavrsen. - * More Netcam Stability Fixes (snap10-post1-6) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - * Destroy mutexes in netcam_cleanup(). - * Add reconnection for netcam_start() - this may block other cameras - from starting up!. -@@ -1173,7 +1221,7 @@ Christopher Price - * Rearranged timeout assignments for pthread_cond_timedwait() calls. - * Adjusted TIMEOUT_COND_WHICH to 4 seconds. - * More Netcam Stability Fixes (snap11-post1-4) (Christopher Price) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - * Reworked thread signal/wait conditions, should fix some race conditions. - * Use gettimeofday() to determine thread timeouts, results in better accuracy. - * Adjusted condition timeouts to smaller values due to usage of gettimeofday() -@@ -1188,7 +1236,7 @@ Christopher Price - * Fix bug in streaming camera without content-length, recent mod broke. - * Fix bug in startup of single image reads without content-length. - * More Netcam Stability Fixes (snap12-post1) (Christopher Price) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/NetcamStabilityPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/NetcamStabilityPatch - * Newrote url parser, better syntax checking and error handling of urls. - * Userpass now allowed in url (http://user:pass@example.com/). - Netcam_userpass has precedence, it will override a userpass embedded in -@@ -1206,15 +1254,19 @@ rasca - Michael Reuschling - * Fixed bug which caused Motion 3.1.18 fail to save timelapse mpegs when - setting ffmpeg_timelapse = 1 (fixed by Michael Reuschling) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x01x31x211756 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x01x31x211756 - - Petter Reinholdtsen - * Adding the install option to the makefile. - -+Isaac Richte -+ * V4L2 fourcc GRBG not supported, updated default value for v4l2_palette 17. -+ http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x10x29x222753 -+ - Marius Rieder - * Handle mjpeg decoding and fix colour issue adding mjpegtools dependency -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegColorIssue -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MjpegToYUV420pPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegColorIssue -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch - (Marius Rieder, Angel Carpintero). - - James A. Russo. -@@ -1227,29 +1279,29 @@ James A. Russo. - - Jason Sharpee - * Avoid random errors , initialising some structs for V4L1 -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x11x26x010755 (Jason Sharpee & Angel Carpintero) - - - Pete Shipley - * Fix the problem that happens in FreeBSD and Debian Sarge because - version of ffmpeg is LIBAVFORMAT_BUILD < 4629. ( Angel Carpintero and Pete Shipley) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x01x12x120335 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x01x12x120335 - - Gunnar Skjold - * Fixed http pause feature so that pausing thread 0 now pauses all threads. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x10x111239 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x10x111239 - - Peter Smith - * Improved reporting of thread numbers during startup in setup mode. - (Peter Smith and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SlightlyImprovedThreadCreationLogging - * Ffmpeg code mutex locking fix -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x04x07x164654 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x04x07x164654 - * Ffmpeg avicodec logging improved (Peter Smith and Kenneth Lavrsen) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FfmpegAvicodecLogging -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FfmpegAvicodecLogging - * Improved upon a few ambiguous log messages which may be emitted by the Event - handling code with regards to Ffmpeg (Peter Smith) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LoggingEventFix -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LoggingEventFix - - Roberto Spadim - * Fixed compatibility problem with Palantir. Fixed by making output more -@@ -1257,8 +1309,8 @@ Roberto Spadim - Carpintero. However this fix made Firefox flicker even more than it normally - does. Final fix which works in both Palantir client, Firefox and Cambozola - was made by Kenneth Lavrsen. This closes the following bugs: -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x02x205307, -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2005x05x07x042849 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x02x205307, -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2005x05x07x042849 - - Daniel Sterling - * Studies of the performance of Motion. -@@ -1284,7 +1336,7 @@ Tommy Svensson - - Timo Taskinen - * Added Flash video format (FLV) to ffmpeg. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x07x19x131921 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x07x19x131921 - - technolust.cx - * For hosting motion.technolust.cx -@@ -1302,7 +1354,7 @@ Jukka Ukkonen - * On FreeBSD configure defines a redundant freebsd for motion. Fixed by replacing - -D__freebsd_ by BSD macro included in sys/param.h for BSD platforms. - (JukkaUkkonen and Angel Carpintero) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2006x07x08x070417 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2006x07x08x070417 - - Moshe Van Der Sterre - * Added 3 new tracking options: track_step_angle_x, track_step_angle_y, -@@ -1315,14 +1367,14 @@ Moshe Van Der Sterre - is re-enabled the minute the camera is standing still again. Feature - originally made by Moshe Van Der Sterre. Kenneth Lavrsen extended it to - be more generic. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PwcConfiguration -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PwcConfiguration - - Folkert Van Heusden - * Maintained the code from version 3.1.9 till 3.1.12-rc1 - Including features like.. - * Error reporting to syslog. - * Better memory allocation. -- low_cpu feature extention to configurable frame rate. -+ low_cpu feature extension to configurable frame rate. - * First work on Logitech Sphere/Orbit tracking. - * Implemented original pre-record feature. - Misc code optimisations -@@ -1331,13 +1383,12 @@ Folkert Van Heusden - - James Van Vleet - * CPU VIA Ezra C3 autodetection support added. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/VIAEzraC3Patch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/VIAEzraC3Patch - - Simon Walls -- * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/foswiki/bin/view/Motion/FeatureRequest2007x01x22x231542 -+ * Netcam Keepalive and HTTP/1.1 http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x01x22x231542 - * Better debug in netcam for "Error reading image header" -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2008x02x27x092849 -- -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2008x02x27x092849 (Simon Walls) - - Sean Watkins - * Created a centralized logging function that became event() -@@ -1346,18 +1397,18 @@ Joerg Weber - * Added the new labeling motion detection feature. - * Added the new Smartmask feature. - * Implemented new preview patch (Joerg Weber) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/PreviewShotsPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewShotsPatch - * Implemented an improvement of Smartmask so that the mask is cleared when - the smart_mask_speed is set from a non-zero to zero - * Implemented an improvement of noise_tune with smart mask (and probably - also in general) - * Added Best Preview Patch -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BestPreviewShot -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BestPreviewShot - * Added the new feature Setup Mode (Joerg Weber). This also enables - much more error messages given to the console when in non-daemon mode - while still preserving the messages in syslog which are important - for daemon mode debugging. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/SetupModePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/SetupModePatch - * Fixed a bug in noise tune which was most visible at very low light. - * Improved console output in setup mode. Now also outputs threshold. - * Improvement in the noise-tune algorithm. -@@ -1369,8 +1420,8 @@ Joerg Weber - Movie starts (mpeg file opened) --- onmpeg --- on_movie_start - Movie ends (mpeg file closed) --- onffmpegclose --- on_movie_end - Motion detected --- New! --- on_motion_detected -- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxCommandsPatch and -- http://www.lavrsen.dk/foswiki/bin/view/Motion/OnXxxxFeatureDiscussion -+ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxCommandsPatch and -+ http://www.lavrsen.dk/twiki/bin/view/Motion/OnXxxxFeatureDiscussion - * Fixed small bug when pre_capture buffer is resized during operation. - * Changed the order of drawing the red mask in setup mode so that the - smartmask is drawn after the fixed mask. -@@ -1379,19 +1430,25 @@ Joerg Weber - a fixed mask. - * Improved the labelling algorithm so that locate feature and tracking - features includes all labelled areas above threshold. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ImprovedLabellingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ImprovedLabellingPatch - * Make the creation of reference frame and the decay mechanism depending - on how much motion was detected relative to threshold setting. -- http://www.lavrsen.dk/foswiki/bin/view/Motion/ReferenceFramePatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/ReferenceFramePatch - * Removed low_cpu feature. - * Removed night_compensate feature - * Implemented a new reference frame algorithm to improve object recognition and location. - * Improved smartmask feature: real moving objects don't trigger the mask anymore. - * Added area_detect feature. -- -+ * Add draw a RED box around the movement as default. -+ * Split locate_motion into separate 'mode' and 'style' option to allow all -+ possible combinations. -+ * Gapless_event mode. -+ * Limit detection rate to 3fps at framerates above 5fps, to reduce CPU load. -+ * Fixed mask overlay in setup mode is now green instead of white. -+ - Dirk Wesenberg - * Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero ) -- http://www.lavrsen.dk/foswiki/bin/view/Motion/LinuxUvcTrackingPatch -+ http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch - - Tristan Willy - * Wrote Axis 2100 support and added the check for ~/.motion/motion.conf -@@ -1404,7 +1461,7 @@ Andreas Wrede - - Damian Wrobel - * Fix a segfault adding correct size to be used for bayer2rgb24(). -- http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2007x03x30x175913 -+ http://www.lavrsen.dk/twiki/bin/view/Motion/BugReport2007x03x30x175913 - - Yieldtech - * These guys are making a complete linux based security system ---- motion-3.2.12.orig/FAQ -+++ motion-3.2.12/FAQ -@@ -1,6 +1,6 @@ - This FAQ is no longer kept up to date - Look at this URL for a more up to date wiki based FAQ --http://www.lavrsen.dk/foswiki/bin/view/Motion/FrequentlyAskedQuestions -+http://www.lavrsen.dk/twiki/bin/view/Motion/FrequentlyAskedQuestions - - Q: motion crashes while parsing the config file. - ---- motion-3.2.12.orig/INSTALL -+++ motion-3.2.12/INSTALL -@@ -1,16 +1,61 @@ --Very simple: -+NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point -+ and may need modification by the time you read this. - --type: -+********************************** -+*** DEBIAN BASED SYSTEMS *** - -+Required Packages: -+ sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev -+ -+Obtain source code (via git) -+ sudo apt-get install git -+ cd ~ -+ git clone {https://github.com/your favorite fork} -+ -+To rebuild the motion configure file use -+ autoreconf -+ -+Optional: With FFMPEG support: -+ Build FFMPEG via their instructions -+ Configure with manually built ffmpeg which currently installs to ~/bin and ~/ffmpeg_build -+ Basic -+ ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include -+ -+ With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG -+ ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " -+ -+ With extra libraries for ffmpeg and install to ~/motion_build -+ ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " -+ -+With LIBAV APT versions of libraries -+ sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools libswscale-dev -+ -+Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat - ./configure - --followed by: -+Sample PI configuration with LIBAV -+ ./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf --with-ffmpeg-headers=/usr/include -+ - -+Once configured type: - make -+ make install - --And -+***************************** -+*** OpenSUSE SYSTEM *** - -+sudo zypper install autoconf automake libtool git -+sudo zypper install --type pattern devel_basis -+sudo zypper install libjpeg8-devel -+sudo zypper install -t pattern devel_C_C++ -+ -+Optional: FFmpeg files -+sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials -+sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia -+sudo zypper install libffmpeg-devel -+ -+./configure -+ make - make install - -- --Next read the README -+************************* ---- /dev/null -+++ motion-3.2.12/Makefile -@@ -0,0 +1,279 @@ -+################################################################################ -+# Makefile for Motion # -+################################################################################ -+# Copyright 2000 by Jeroen Vreeken # -+# # -+# This program is published under the GNU public license version 2.0 or later. # -+# Please read the file COPYING for more info. # -+################################################################################ -+# Please visit the Motion home page: # -+# http://www.lavrsen.dk/twiki/bin/view/Motion # -+################################################################################ -+ -+CC = gcc -+INSTALL = install -+ -+################################################################################ -+# Install locations, controlled by setting configure flags. # -+################################################################################ -+prefix = /home/dave/motion_build -+exec_prefix = ${prefix} -+bindir = ${exec_prefix}/bin -+mandir = ${datarootdir}/man -+sysconfdir = ${prefix}/etc -+datadir = ${datarootdir} -+datarootdir = ${prefix}/share -+docdir = $(datadir)/doc/motion-3.2.12-4ppa01 -+examplesdir = $(datadir)/motion-3.2.12-4ppa01/examples -+ -+################################################################################ -+# These variables contain compiler flags, object files to build and files to # -+# install. # -+################################################################################ -+CFLAGS = -g -O2 -D_REENTRANT -DHAVE_FFMPEG -I/usr/include -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW -DMOTION_V4L2 -DMOTION_V4L2_OLD -DTYPE_32BIT="int" -DHAVE_BSWAP -march=native -mtune=native -Wall -DVERSION=\"3.2.12-4ppa01\" -Dsysconfdir=\"$(sysconfdir)\" -+LDFLAGS = -L/usr/lib/x86_64-linux-gnu -+LIBS = -lm -lpthread -ljpeg -L/usr/lib/x86_64-linux-gnu -lavformat -lavcodec -lavutil -lm -lz -lswscale -+VIDEO_OBJ = video.o video2.o video_common.o -+OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ -+ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ -+ alg.o event.o picture.o rotate.o webhttpd.o \ -+ stream.o md5.o ffmpeg.o netcam_rtsp.o -+SRC = $(OBJ:.o=.c) -+DOC = CHANGELOG COPYING CREDITS INSTALL README motion_guide.html -+EXAMPLES = *.conf motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh -+PROGS = motion -+DEPEND_FILE = .depend -+ -+################################################################################ -+# ALL and PROGS build Motion and, possibly, Motion-control. # -+################################################################################ -+all: progs -+ifneq (,$(findstring freebsd,$(VIDEO_OBJ))) -+ @echo "Build complete, run \"gmake install\" to install Motion!" -+else -+ @echo "Build complete, run \"make install\" to install Motion!" -+endif -+ @echo -+ -+progs: pre-build-info $(PROGS) -+ -+################################################################################ -+# PRE-BUILD-INFO outputs some general info before the build process starts. # -+################################################################################ -+pre-build-info: -+ @echo "Welcome to the setup procedure for Motion, the motion detection daemon! If you get" -+ @echo "error messages during this procedure, please report them to the mailing list. The" -+ @echo "Motion Guide contains all information you should need to get Motion up and running." -+ @echo "Run \"make updateguide\" to download the latest version of the Motion Guide." -+ @echo -+ @echo "Version: 3.2.12-4ppa01" -+ifneq (,$(findstring freebsd,$(VIDEO_OBJ))) -+ @echo "Platform: FreeBSD" -+else -+ @echo "Platform: Linux (if this is incorrect, please read README.FreeBSD)" -+endif -+ @echo -+ -+################################################################################ -+# MOTION builds motion. MOTION-OBJECTS and PRE-MOBJECT-INFO are helpers. # -+################################################################################ -+motion: motion-objects -+ @echo "Linking Motion..." -+ @echo "--------------------------------------------------------------------------------" -+ $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) -+ @echo "--------------------------------------------------------------------------------" -+ @echo "Motion has been linked." -+ @echo -+ -+motion-objects: dep pre-mobject-info $(OBJ) -+ @echo "--------------------------------------------------------------------------------" -+ @echo "Motion object files compiled." -+ @echo -+ -+pre-mobject-info: -+ @echo "Compiling Motion object files..." -+ @echo "--------------------------------------------------------------------------------" -+ -+################################################################################ -+# Define the compile command for C files. # -+################################################################################ -+#%.o: %.c -+# @echo -e "\tCompiling $< into $@..." -+# @$(CC) -c $(CFLAGS) $< -o $@ -+ -+################################################################################ -+# Include the dependency file if it exists. # -+################################################################################ -+ifeq ($(DEPEND_FILE), $(wildcard $(DEPEND_FILE))) -+ifeq (,$(findstring clean,$(MAKECMDGOALS))) -+-include $(DEPEND_FILE) -+endif -+endif -+ -+################################################################################ -+# Make the dependency file depend on all header files and all relevant source # -+# files. This forces the file to be re-generated if the source/header files # -+# change. Note, however, that the existing version will be included before # -+# re-generation. # -+################################################################################ -+$(DEPEND_FILE): *.h $(SRC) -+ @echo "Generating dependencies, please wait..." -+ @$(CC) $(CFLAGS) -M $(SRC) > .tmp -+ @mv -f .tmp $(DEPEND_FILE) -+ @echo -+ -+################################################################################ -+# DEP, DEPEND and FASTDEP generate the dependency file. # -+################################################################################ -+dep depend fastdep: $(DEPEND_FILE) -+ -+ -+################################################################################ -+# DEV, BUILD with developer flags # -+################################################################################ -+dev: distclean autotools all -+ -+################################################################################ -+# DEV-GIT, BUILD with developer flags # -+################################################################################ -+dev-git: distclean autotools-git all -+ -+ -+################################################################################ -+# GIT, BUILD with developer flags # -+################################################################################ -+build-commit-git: distclean set-version-git all -+ -+################################################################################ -+# CURRENT, BUILD current svn trunk. # -+################################################################################ -+current: distclean svn autotools all -+ -+svn: -+ svn update -+ -+autotools: -+ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in -+ autoconf -+ ./configure --with-developer-flags -+ -+autotools-git: -+ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in -+ autoconf -+ ./configure --with-developer-flags -+ -+ -+build-commit: distclean svn set-version all -+ -+set-version: -+ @sed -i 's/.\/version.sh/.\/commit-version.sh/g' configure.in -+ autoconf -+ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in -+ ./configure --with-developer-flags -+ -+set-version-git: -+ @sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.in -+ autoconf -+ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in -+ ./configure --with-developer-flags -+ -+ -+help: -+ @echo "--------------------------------------------------------------------------------" -+ @echo "make Build motion from local copy in your computer" -+ @echo "make current Build last version of motion from svn" -+ @echo "make dev Build motion with dev flags" -+ @echo "make dev-git Build motion with dev flags for git" -+ @echo "make build-commit Build last version of motion and prepare to commit to svn" -+ @echo "make build-commit-git Build last version of motion and prepare to commit to git" -+ @echo "make clean Clean objects" -+ @echo "make distclean Clean everything" -+ @echo "make install Install binary , examples , docs and config files" -+ @echo "make uninstall Uninstall all installed files" -+ @echo "--------------------------------------------------------------------------------" -+ @echo -+ -+################################################################################ -+# INSTALL installs all relevant files. # -+################################################################################ -+install: -+ @echo "Installing files..." -+ @echo "--------------------------------------------------------------------------------" -+ mkdir -p $(DESTDIR)$(bindir) -+ mkdir -p $(DESTDIR)$(mandir)/man1 -+ mkdir -p $(DESTDIR)$(sysconfdir) -+ mkdir -p $(DESTDIR)$(docdir) -+ mkdir -p $(DESTDIR)$(examplesdir) -+ $(INSTALL) motion.1 $(DESTDIR)$(mandir)/man1 -+ $(INSTALL) $(DOC) $(DESTDIR)$(docdir) -+ $(INSTALL) $(EXAMPLES) $(DESTDIR)$(examplesdir) -+ $(INSTALL) motion-dist.conf $(DESTDIR)$(sysconfdir) -+ for prog in $(PROGS); \ -+ do \ -+ ($(INSTALL) $$prog $(DESTDIR)$(bindir) ); \ -+ done -+ @echo "--------------------------------------------------------------------------------" -+ @echo "Install complete! The default configuration file, motion-dist.conf, has been" -+ @echo "installed to $(sysconfdir). You need to rename/copy it to $(sysconfdir)/motion.conf" -+ @echo "for Motion to find it. More configuration examples as well as init scripts" -+ @echo "can be found in $(examplesdir)." -+ @echo -+ -+################################################################################ -+# UNINSTALL and REMOVE uninstall already installed files. # -+################################################################################ -+uninstall remove: pre-build-info -+ @echo "Uninstalling files..." -+ @echo "--------------------------------------------------------------------------------" -+ for prog in $(PROGS); \ -+ do \ -+ ($ rm -f $(bindir)/$$prog ); \ -+ done -+ rm -f $(mandir)/man1/motion.1 -+ rm -f $(sysconfdir)/motion-dist.conf -+ rm -rf $(docdir) -+ rm -rf $(examplesdir) -+ @echo "--------------------------------------------------------------------------------" -+ @echo "Uninstall complete!" -+ @echo -+ -+################################################################################ -+# CLEAN is basic cleaning; removes object files and executables, but does not # -+# remove files generated from the configure step. # -+################################################################################ -+clean: pre-build-info -+ @echo "Removing compiled files and binaries..." -+ @rm -f *~ *.jpg *.o $(PROGS) combine $(DEPEND_FILE) -+ -+################################################################################ -+# DIST restores the directory to distribution state. # -+################################################################################ -+dist: distclean updateguide -+ @chmod -R 644 * -+ @chmod 755 configure -+ @chmod 755 version.sh -+ -+################################################################################ -+# DISTCLEAN removes all files generated during the configure step in addition # -+# to basic cleaning. # -+################################################################################ -+distclean: clean -+ @echo "Removing files generated by configure..." -+ @rm -f config.status config.log config.cache Makefile motion.init-Fedora motion.init-Debian motion.init-FreeBSD.sh -+ @rm -f thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion-help.conf motion.spec -+ @rm -rf autom4te.cache config.h -+ @echo "You will need to re-run configure if you want to build Motion." -+ @echo -+ -+################################################################################ -+# UPDATEGUIDE downloads the Motion Guide from TWiki. # -+################################################################################ -+updateguide: pre-build-info -+ @echo "Downloading Motion Guide. If it fails, please check your Internet connection." -+ @echo -+ wget www.lavrsen.dk/twiki/bin/view/Motion/MotionGuideOneLargeDocument?skin=text -O motion_guide.tmp -+ @echo "Cleaning up and fixing links..." -+ @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/twiki/,"http://www.lavrsen.dk/twiki/,g' > motion_guide.html -+ @rm -f motion_guide.tmp -+ @echo "All done, you should now have an up-to-date local copy of the Motion guide." -+ @echo ---- motion-3.2.12.orig/Makefile.in -+++ motion-3.2.12/Makefile.in -@@ -7,7 +7,7 @@ - # Please read the file COPYING for more info. # - ################################################################################ - # Please visit the Motion home page: # --# http://www.lavrsen.dk/foswiki/bin/view/Motion # -+# http://www.lavrsen.dk/twiki/bin/view/Motion # - ################################################################################ - - CC = @CC@ -@@ -23,7 +23,7 @@ mandir = @mandir@ - sysconfdir = @sysconfdir@ - datadir = @datadir@ - datarootdir = @datarootdir@ --docdir = $(datadir)/doc/@PACKAGE_NAME@-@PACKAGE_VERSION@ -+docdir = $(datadir)/doc/@PACKAGE_NAME@-@PACKAGE_VERSION@ - examplesdir = $(datadir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/examples - - ################################################################################ -@@ -34,10 +34,10 @@ CFLAGS = @CFLAGS@ -Wall -DVERSION= - LDFLAGS = @LDFLAGS@ - LIBS = @LIBS@ - VIDEO_OBJ = @VIDEO@ --OBJ = motion.o conf.o draw.o jpegutils.o $(VIDEO_OBJ) netcam.o \ -- netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ -+OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ -+ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ - alg.o event.o picture.o rotate.o webhttpd.o \ -- webcam.o @FFMPEG_OBJ@ -+ stream.o md5.o @FFMPEG_OBJ@ @SDL_OBJ@ @RTPS_OBJ@ - SRC = $(OBJ:.o=.c) - DOC = CHANGELOG COPYING CREDITS INSTALL README motion_guide.html - EXAMPLES = *.conf motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh -@@ -127,6 +127,72 @@ $(DEPEND_FILE): *.h $(SRC) - ################################################################################ - dep depend fastdep: $(DEPEND_FILE) - -+ -+################################################################################ -+# DEV, BUILD with developer flags # -+################################################################################ -+dev: distclean autotools all -+ -+################################################################################ -+# DEV-GIT, BUILD with developer flags # -+################################################################################ -+dev-git: distclean autotools-git all -+ -+ -+################################################################################ -+# GIT, BUILD with developer flags # -+################################################################################ -+build-commit-git: distclean set-version-git all -+ -+################################################################################ -+# CURRENT, BUILD current svn trunk. # -+################################################################################ -+current: distclean svn autotools all -+ -+svn: -+ svn update -+ -+autotools: -+ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in -+ autoconf -+ ./configure --with-developer-flags -+ -+autotools-git: -+ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in -+ autoconf -+ ./configure --with-developer-flags -+ -+ -+build-commit: distclean svn set-version all -+ -+set-version: -+ @sed -i 's/.\/version.sh/.\/commit-version.sh/g' configure.in -+ autoconf -+ @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in -+ ./configure --with-developer-flags -+ -+set-version-git: -+ @sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.in -+ autoconf -+ @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in -+ ./configure --with-developer-flags -+ -+ -+help: -+ @echo "--------------------------------------------------------------------------------" -+ @echo "make Build motion from local copy in your computer" -+ @echo "make current Build last version of motion from svn" -+ @echo "make dev Build motion with dev flags" -+ @echo "make dev-git Build motion with dev flags for git" -+ @echo "make build-commit Build last version of motion and prepare to commit to svn" -+ @echo "make build-commit-git Build last version of motion and prepare to commit to git" -+ @echo "make clean Clean objects" -+ @echo "make distclean Clean everything" -+ @echo "make install Install binary , examples , docs and config files" -+ @echo "make uninstall Uninstall all installed files" -+ @echo "--------------------------------------------------------------------------------" -+ @echo -+ - ################################################################################ - # INSTALL installs all relevant files. # - ################################################################################ -@@ -185,6 +251,7 @@ clean: pre-build-info - dist: distclean updateguide - @chmod -R 644 * - @chmod 755 configure -+ @chmod 755 version.sh - - ################################################################################ - # DISTCLEAN removes all files generated during the configure step in addition # -@@ -199,14 +266,14 @@ distclean: clean - @echo - - ################################################################################ --# UPDATEGUIDE downloads the Motion Guide from the Motion Foswiki. # -+# UPDATEGUIDE downloads the Motion Guide from TWiki. # - ################################################################################ - updateguide: pre-build-info - @echo "Downloading Motion Guide. If it fails, please check your Internet connection." - @echo -- wget www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuideOneLargeDocument?skin=text -O motion_guide.tmp -+ wget www.lavrsen.dk/twiki/bin/view/Motion/MotionGuideOneLargeDocument?skin=text -O motion_guide.tmp - @echo "Cleaning up and fixing links..." -- @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/foswiki/,"http://www.lavrsen.dk/foswiki/,g' > motion_guide.html -+ @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/twiki/,"http://www.lavrsen.dk/twiki/,g' > motion_guide.html - @rm -f motion_guide.tmp - @echo "All done, you should now have an up-to-date local copy of the Motion guide." - @echo ---- motion-3.2.12.orig/README -+++ motion-3.2.12/README -@@ -44,17 +44,17 @@ installation and use. - The Motion Guide is part of the distribution (motion_guide.htm). - You are encouraged to look up an up to date version by visiting the Motion - homepage at --http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome -+http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome - and specifically the Motion Guide at --http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide -+http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide - - - Support: - --Lots of resources at http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome -+Lots of resources at http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome - - Please join the mailing list --http://www.lavrsen.dk/foswiki/bin/view/Motion/MailingList -+http://www.lavrsen.dk/twiki/bin/view/Motion/MailingList - Newbies and silly questions are welcome. We prefer support through the mailing - list because more will have benefit from the answers. - ---- motion-3.2.12.orig/README.FreeBSD -+++ motion-3.2.12/README.FreeBSD -@@ -78,11 +78,11 @@ Packages needed (dependencies for 6.x): - Any question / fix / suggestion please send it to motion mailing list. - - -- http://www.lavrsen.dk/foswiki/bin/view/Motion/FreeBSD -+ http://www.lavrsen.dk/twiki/bin/view/Motion/FreeBSD - - * WEBCAMS - ---------- -- http://www.lavrsen.dk/foswiki/bin/view/Motion/HowtoMotionPwcFreeBSD -+ http://www.lavrsen.dk/twiki/bin/view/Motion/HowtoMotionPwcFreeBSD - - Angel Carpintero - ack@telefonica.net ---- motion-3.2.12.orig/alg.c -+++ motion-3.2.12/alg.c -@@ -17,7 +17,10 @@ - #define MAX2(x, y) ((x) > (y) ? (x) : (y)) - #define MAX3(x, y, z) ((x) > (y) ? ((x) > (z) ? (x) : (z)) : ((y) > (z) ? (y) : (z))) - --/* locate the center and size of the movement. */ -+/** -+ * alg_locate_center_size -+ * Locates the center and size of the movement. -+ */ - void alg_locate_center_size(struct images *imgs, int width, int height, struct coord *cent) - { - unsigned char *out = imgs->out; -@@ -31,18 +34,19 @@ void alg_locate_center_size(struct image - cent->minx = width; - cent->miny = height; - -- /* If Labeling enabled - locate center of largest labelgroup */ -+ /* If Labeling enabled - locate center of largest labelgroup. */ - if (imgs->labelsize_max) { - /* Locate largest labelgroup */ - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { -- if (*(labels++)&32768) { -+ if (*(labels++) & 32768) { - cent->x += x; - cent->y += y; - centc++; - } - } - } -+ - } else { - /* Locate movement */ - for (y = 0; y < height; y++) { -@@ -54,6 +58,7 @@ void alg_locate_center_size(struct image - } - } - } -+ - } - - if (centc) { -@@ -61,18 +66,18 @@ void alg_locate_center_size(struct image - cent->y = cent->y / centc; - } - -- /* Now we find the size of the Motion */ -+ /* Now we find the size of the Motion. */ - -- /* First reset pointers back to initial value */ -+ /* First reset pointers back to initial value. */ - centc = 0; - labels = imgs->labels; - out = imgs->out; - -- /* If Labeling then we find the area around largest labelgroup instead */ -+ /* If Labeling then we find the area around largest labelgroup instead. */ - if (imgs->labelsize_max) { - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { -- if (*(labels++)&32768) { -+ if (*(labels++) & 32768) { - if (x > cent->x) - xdist += x - cent->x; - else if (x < cent->x) -@@ -87,6 +92,7 @@ void alg_locate_center_size(struct image - } - } - } -+ - } else { - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { -@@ -105,14 +111,17 @@ void alg_locate_center_size(struct image - } - } - } -+ - } - - if (centc) { - cent->minx = cent->x - xdist / centc * 2; - cent->maxx = cent->x + xdist / centc * 2; -- /* Make the box a little bigger in y direction to make sure the -- heads fit in so we multiply by 3 instead of 2 which seems to -- to work well in practical */ -+ /* -+ * Make the box a little bigger in y direction to make sure the -+ * heads fit in so we multiply by 3 instead of 2 which seems to -+ * to work well in practical. -+ */ - cent->miny = cent->y - ydist / centc * 3; - cent->maxy = cent->y + ydist / centc * 2; - } -@@ -126,85 +135,227 @@ void alg_locate_center_size(struct image - cent->maxy = height - 1; - else if (cent->maxy < 0) - cent->maxy = 0; -- -+ - if (cent->minx > width - 1) - cent->minx = width - 1; - else if (cent->minx < 0) - cent->minx = 0; -- -+ - if (cent->miny > height - 1) - cent->miny = height - 1; - else if (cent->miny < 0) - cent->miny = 0; -+ -+ /* Align for better locate box handling */ -+ cent->minx += cent->minx % 2; -+ cent->miny += cent->miny % 2; -+ cent->maxx -= cent->maxx % 2; -+ cent->maxy -= cent->maxy % 2; - - cent->width = cent->maxx - cent->minx; - cent->height = cent->maxy - cent->miny; - -- /* We want to center Y coordinate to be the center of the action. -- The head of a person is important so we correct the cent.y coordinate -- to match the correction to include a persons head that we just did above */ -+ /* -+ * We want to center Y coordinate to be the center of the action. -+ * The head of a person is important so we correct the cent.y coordinate -+ * to match the correction to include a persons head that we just did above. -+ */ - cent->y = (cent->miny + cent->maxy) / 2; - - } - - --/* draw a box around the movement */ --void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, int mode) -+/** -+ * alg_draw_location -+ * Draws a box around the movement. -+ */ -+void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, -+ int style, int mode, int process_thisframe) - { - unsigned char *out = imgs->out; - int x, y; - - out = imgs->out; - -- /* Draw a box around the movement */ -- if (mode == LOCATE_BOTH){ /* both normal and motion image gets a box */ -+ /* Debug image always gets a 'normal' box. */ -+ if ((mode == LOCATE_BOTH) && process_thisframe) { - int width_miny = width * cent->miny; - int width_maxy = width * cent->maxy; - - for (x = cent->minx; x <= cent->maxx; x++) { - int width_miny_x = x + width_miny; - int width_maxy_x = x + width_maxy; -- new[width_miny_x]=~new[width_miny_x]; -- new[width_maxy_x]=~new[width_maxy_x]; -- out[width_miny_x]=~out[width_miny_x]; -- out[width_maxy_x]=~out[width_maxy_x]; -+ -+ out[width_miny_x] =~out[width_miny_x]; -+ out[width_maxy_x] =~out[width_maxy_x]; - } - - for (y = cent->miny; y <= cent->maxy; y++) { - int width_minx_y = cent->minx + y * width; - int width_maxx_y = cent->maxx + y * width; -- new[width_minx_y]=~new[width_minx_y]; -- new[width_maxx_y]=~new[width_maxx_y]; -- out[width_minx_y]=~out[width_minx_y]; -- out[width_maxx_y]=~out[width_maxx_y]; -+ -+ out[width_minx_y] =~out[width_minx_y]; -+ out[width_maxx_y] =~out[width_maxx_y]; - } -- } else { /* normal image only (e.g. preview shot) */ -+ } -+ if (style == LOCATE_BOX) { /* Draw a box on normal images. */ - int width_miny = width * cent->miny; - int width_maxy = width * cent->maxy; -+ - for (x = cent->minx; x <= cent->maxx; x++) { -- int width_miny_x = width_miny + x; -- int width_maxy_x = width_maxy + x; -- new[width_miny_x]=~new[width_miny_x]; -- new[width_maxy_x]=~new[width_maxy_x]; -+ int width_miny_x = x + width_miny; -+ int width_maxy_x = x + width_maxy; -+ -+ new[width_miny_x] =~new[width_miny_x]; -+ new[width_maxy_x] =~new[width_maxy_x]; - } - - for (y = cent->miny; y <= cent->maxy; y++) { -- int minx_y = cent->minx + y * width; -- int maxx_y = cent->maxx + y * width; -- new[minx_y]=~new[minx_y]; -- new[maxx_y]=~new[maxx_y]; -+ int width_minx_y = cent->minx + y * width; -+ int width_maxx_y = cent->maxx + y * width; -+ -+ new[width_minx_y] =~new[width_minx_y]; -+ new[width_maxx_y] =~new[width_maxx_y]; -+ } -+ } else if (style == LOCATE_CROSS) { /* Draw a cross on normal images. */ -+ int centy = cent->y * width; -+ -+ for (x = cent->x - 10; x <= cent->x + 10; x++) { -+ new[centy + x] =~new[centy + x]; -+ out[centy + x] =~out[centy + x]; - } -+ -+ for (y = cent->y - 10; y <= cent->y + 10; y++) { -+ new[cent->x + y * width] =~new[cent->x + y * width]; -+ out[cent->x + y * width] =~out[cent->x + y * width]; -+ } - } - } - - -+/** -+ * alg_draw_red_location -+ * Draws a RED box around the movement. -+ */ -+void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, -+ int style, int mode, int process_thisframe) -+{ -+ unsigned char *out = imgs->out; -+ unsigned char *new_u, *new_v; -+ int x, y, v, cwidth, cblock; -+ -+ cwidth = width / 2; -+ cblock = imgs->motionsize / 4; -+ x = imgs->motionsize; -+ v = x + cblock; -+ out = imgs->out; -+ new_u = new + x; -+ new_v = new + v; -+ -+ /* Debug image always gets a 'normal' box. */ -+ if ((mode == LOCATE_BOTH) && process_thisframe) { -+ int width_miny = width * cent->miny; -+ int width_maxy = width * cent->maxy; -+ -+ for (x = cent->minx; x <= cent->maxx; x++) { -+ int width_miny_x = x + width_miny; -+ int width_maxy_x = x + width_maxy; -+ -+ out[width_miny_x] =~out[width_miny_x]; -+ out[width_maxy_x] =~out[width_maxy_x]; -+ } -+ -+ for (y = cent->miny; y <= cent->maxy; y++) { -+ int width_minx_y = cent->minx + y * width; -+ int width_maxx_y = cent->maxx + y * width; -+ -+ out[width_minx_y] =~out[width_minx_y]; -+ out[width_maxx_y] =~out[width_maxx_y]; -+ } -+ } -+ -+ if (style == LOCATE_REDBOX) { /* Draw a red box on normal images. */ -+ int width_miny = width * cent->miny; -+ int width_maxy = width * cent->maxy; -+ int cwidth_miny = cwidth * (cent->miny / 2); -+ int cwidth_maxy = cwidth * (cent->maxy / 2); -+ -+ for (x = cent->minx + 2; x <= cent->maxx - 2; x += 2) { -+ int width_miny_x = x + width_miny; -+ int width_maxy_x = x + width_maxy; -+ int cwidth_miny_x = x / 2 + cwidth_miny; -+ int cwidth_maxy_x = x / 2 + cwidth_maxy; -+ -+ new_u[cwidth_miny_x] = 128; -+ new_u[cwidth_maxy_x] = 128; -+ new_v[cwidth_miny_x] = 255; -+ new_v[cwidth_maxy_x] = 255; -+ -+ new[width_miny_x] = 128; -+ new[width_maxy_x] = 128; -+ -+ new[width_miny_x + 1] = 128; -+ new[width_maxy_x + 1] = 128; -+ -+ new[width_miny_x + width] = 128; -+ new[width_maxy_x + width] = 128; -+ -+ new[width_miny_x + 1 + width] = 128; -+ new[width_maxy_x + 1 + width] = 128; -+ } -+ -+ for (y = cent->miny; y <= cent->maxy; y += 2) { -+ int width_minx_y = cent->minx + y * width; -+ int width_maxx_y = cent->maxx + y * width; -+ int cwidth_minx_y = (cent->minx / 2) + (y / 2) * cwidth; -+ int cwidth_maxx_y = (cent->maxx / 2) + (y / 2) * cwidth; -+ -+ new_u[cwidth_minx_y] = 128; -+ new_u[cwidth_maxx_y] = 128; -+ new_v[cwidth_minx_y] = 255; -+ new_v[cwidth_maxx_y] = 255; -+ -+ new[width_minx_y] = 128; -+ new[width_maxx_y] = 128; -+ -+ new[width_minx_y + width] = 128; -+ new[width_maxx_y + width] = 128; -+ -+ new[width_minx_y + 1] = 128; -+ new[width_maxx_y + 1] = 128; -+ -+ new[width_minx_y + width + 1] = 128; -+ new[width_maxx_y + width + 1] = 128; -+ } -+ } else if (style == LOCATE_REDCROSS) { /* Draw a red cross on normal images. */ -+ int cwidth_maxy = cwidth * (cent->y / 2); -+ -+ for (x = cent->x - 10; x <= cent->x + 10; x += 2) { -+ int cwidth_maxy_x = x / 2 + cwidth_maxy; -+ -+ new_u[cwidth_maxy_x] = 128; -+ new_v[cwidth_maxy_x] = 255; -+ } -+ -+ for (y = cent->y - 10; y <= cent->y + 10; y += 2) { -+ int cwidth_minx_y = (cent->x / 2) + (y / 2) * cwidth; -+ -+ new_u[cwidth_minx_y] = 128; -+ new_v[cwidth_minx_y] = 255; -+ } -+ } -+} -+ - - #define NORM 100 - #define ABS(x) ((x) < 0 ? -(x) : (x)) --#define DIFF(x, y) (ABS((x) - (y))) --#define NDIFF(x, y) (ABS(x) * NORM/(ABS(x) + 2 * DIFF(x,y))) -- -+#define DIFF(x, y) (ABS((x)-(y))) -+#define NDIFF(x, y) (ABS(x) * NORM / (ABS(x) + 2 * DIFF(x, y))) - -+/** -+ * alg_noise_tune -+ * -+ */ - void alg_noise_tune(struct context *cnt, unsigned char *new) - { - struct images *imgs = &cnt->imgs; -@@ -216,25 +367,33 @@ void alg_noise_tune(struct context *cnt, - - i = imgs->motionsize; - -- for (; i>0; i--) { -+ for (; i > 0; i--) { - diff = ABS(*ref - *new); -+ - if (mask) -- diff = ((diff * *mask++)/255); -- if (*smartmask){ -+ diff = ((diff * *mask++) / 255); -+ -+ if (*smartmask) { - sum += diff + 1; - count++; - } -+ - ref++; - new++; - smartmask++; - } - -- if (count > 3) /* avoid divide by zero */ -+ if (count > 3) /* Avoid divide by zero. */ - sum /= count / 3; - -- cnt->noise = 4 + (cnt->noise + sum) / 2; /* 5: safe, 4: regular, 3: more sensitive */ -+ /* 5: safe, 4: regular, 3: more sensitive */ -+ cnt->noise = 4 + (cnt->noise + sum) / 2; - } - -+/** -+ * alg_threshold_tune -+ * -+ */ - void alg_threshold_tune(struct context *cnt, int diffs, int motion) - { - int i; -@@ -248,6 +407,7 @@ void alg_threshold_tune(struct context * - - for (i = 0; i < THRESHOLD_TUNE_LENGTH - 1; i++) { - sum += cnt->diffs_last[i]; -+ - if (cnt->diffs_last[i + 1] && !motion) - cnt->diffs_last[i] = cnt->diffs_last[i + 1]; - else -@@ -256,10 +416,12 @@ void alg_threshold_tune(struct context * - if (cnt->diffs_last[i] > top) - top = cnt->diffs_last[i]; - } -+ - sum += cnt->diffs_last[i]; - cnt->diffs_last[i] = diffs; - - sum /= THRESHOLD_TUNE_LENGTH / 4; -+ - if (sum < top * 2) - sum = top * 2; - -@@ -268,47 +430,50 @@ void alg_threshold_tune(struct context * - } - - /* --Labeling by Joerg Weber. Based on an idea from Hubert Mara. --Floodfill enhanced by Ian McConnel based on code from --http://www.acm.org/pubs/tog/GraphicsGems/ --http://www.codeproject.com/gdi/QuickFill.asp --*/ -+ * Labeling by Joerg Weber. Based on an idea from Hubert Mara. -+ * Floodfill enhanced by Ian McConnel based on code from -+ * http://www.acm.org/pubs/tog/GraphicsGems/ -+ * http://www.codeproject.com/gdi/QuickFill.asp - --/* -- * Filled horizontal segment of scanline y for xl<=x<=xr. -- * Parent segment was on line y-dy. dy=1 or -1 -+ * Filled horizontal segment of scanline y for xl <= x <= xr. -+ * Parent segment was on line y - dy. dy = 1 or -1 - */ - - #define MAXS 10000 /* max depth of stack */ - --#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \ -- if (sp= 0 && Y+(DY) < height) \ -+#define PUSH(Y, XL, XR, DY) /* push new segment on stack */ \ -+ if (sp= 0 && Y+(DY) < height) \ - {sp->y = Y; sp->xl = XL; sp->xr = XR; sp->dy = DY; sp++;} - --#define POP(Y, XL, XR, DY) /* pop segment off stack */ \ -+#define POP(Y, XL, XR, DY) /* pop segment off stack */ \ - {sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;} - --typedef struct {short y, xl, xr, dy;} Segment; -+typedef struct { -+ short y, xl, xr, dy; -+} Segment; - -- --static int iflood(int x, int y, -- int width, int height, unsigned char *out, int *labels, int newvalue, int oldvalue) -+/** -+ * iflood -+ * -+ */ -+static int iflood(int x, int y, int width, int height, -+ unsigned char *out, int *labels, int newvalue, int oldvalue) - { - int l, x1, x2, dy; -- Segment stack[MAXS], *sp = stack; /* stack of filled segments */ -+ Segment stack[MAXS], *sp = stack; /* Stack of filled segments. */ - int count = 0; - - if (x < 0 || x >= width || y < 0 || y >= height) - return 0; - -- PUSH(y, x, x, 1); /* needed in some cases */ -- PUSH(y+1, x, x, -1); /* seed segment (popped 1st) */ -+ PUSH(y, x, x, 1); /* Needed in some cases. */ -+ PUSH(y+1, x, x, -1); /* Seed segment (popped 1st). */ - - while (sp > stack) { -- /* pop segment off stack and fill a neighboring scan line */ -+ /* Pop segment off stack and fill a neighboring scan line. */ - POP(y, x1, x2, dy); - /* -- * segment of scan line y-dy for x1<=x<=x2 was previously filled, -+ * Segment of scan line y-dy for x1<=x<=x2 was previously filled, - * now explore adjacent pixels in scan line y - */ - for (x = x1; x >= 0 && out[y * width + x] != 0 && labels[y * width + x] == oldvalue; x--) { -@@ -322,7 +487,7 @@ static int iflood(int x, int y, - l = x + 1; - - if (l < x1) -- PUSH(y, l, x1-1, -dy); /* leak on left? */ -+ PUSH(y, l, x1 - 1, -dy); /* Leak on left? */ - - x = x1 + 1; - -@@ -335,7 +500,7 @@ static int iflood(int x, int y, - PUSH(y, l, x - 1, dy); - - if (x > x2 + 1) -- PUSH(y, x2 + 1, x - 1, -dy); /* leak on right? */ -+ PUSH(y, x2 + 1, x - 1, -dy); /* Leak on right? */ - - skip: - -@@ -347,6 +512,10 @@ static int iflood(int x, int y, - return count; - } - -+/** -+ * alg_labeling -+ * -+ */ - static int alg_labeling(struct context *cnt) - { - struct images *imgs = &cnt->imgs; -@@ -357,60 +526,76 @@ static int alg_labeling(struct context * - int height = imgs->height; - int labelsize = 0; - int current_label = 2; -+ - cnt->current_image->total_labels = 0; - imgs->labelsize_max = 0; -- /* ALL labels above threshold are counted as labelgroup */ -+ /* ALL labels above threshold are counted as labelgroup. */ - imgs->labelgroup_max = 0; - imgs->labels_above = 0; - -- /* init: 0 means no label set / not checked */ -+ /* Init: 0 means no label set / not checked. */ - memset(labels, 0, width * height * sizeof(labels)); - pixelpos = 0; -+ - for (iy = 0; iy < height - 1; iy++) { - for (ix = 0; ix < width - 1; ix++, pixelpos++) { -- /* no motion - no label */ -+ /* No motion - no label */ - if (out[pixelpos] == 0) { - labels[pixelpos] = 1; - continue; - } - -- /* already visited by iflood */ -+ /* Already visited by iflood */ - if (labels[pixelpos] > 0) - continue; -- labelsize=iflood(ix, iy, width, height, out, labels, current_label, 0); -+ -+ labelsize = iflood(ix, iy, width, height, out, labels, current_label, 0); - - if (labelsize > 0) { -- /* Label above threshold? Mark it again (add 32768 to labelnumber) */ -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Label: %i (%i) Size: %i (%i,%i)", -+ current_label, cnt->current_image->total_labels, -+ labelsize, ix, iy); -+ -+ /* Label above threshold? Mark it again (add 32768 to labelnumber). */ - if (labelsize > cnt->threshold) { -- labelsize=iflood(ix, iy, width, height, out, labels, current_label + 32768, current_label); -+ labelsize = iflood(ix, iy, width, height, out, labels, current_label + 32768, current_label); - imgs->labelgroup_max += labelsize; - imgs->labels_above++; - } - - if (imgs->labelsize_max < labelsize) { -- imgs->labelsize_max=labelsize; -- imgs->largest_label=current_label; -+ imgs->labelsize_max = labelsize; -+ imgs->largest_label = current_label; - } - - cnt->current_image->total_labels++; - current_label++; - } - } -- pixelpos++; /* compensate for ixlargest_label, imgs->labelsize_max, -+ cnt->current_image->total_labels); -+ -+ /* Return group of significant labels. */ - return imgs->labelgroup_max; - } - --/* Dilates a 3x3 box */ -+/** -+ * dilate9 -+ * Dilates a 3x3 box. -+ */ - static int dilate9(unsigned char *img, int width, int height, void *buffer) - { -- /* - row1, row2 and row3 represent lines in the temporary buffer -- * - window is a sliding window containing max values of the columns -- * in the 3x3 matrix -- * - widx is an index into the sliding window (this is faster than -- * doing modulo 3 on i) -- * - blob keeps the current max value -+ /* -+ * - row1, row2 and row3 represent lines in the temporary buffer. -+ * - Window is a sliding window containing max values of the columns -+ * in the 3x3 matrix. -+ * - width is an index into the sliding window (this is faster than -+ * doing modulo 3 on i). -+ * - blob keeps the current max value. - */ - int y, i, sum = 0, widx; - unsigned char *row1, *row2, *row3, *rowTemp,*yp; -@@ -439,7 +624,7 @@ static int dilate9(unsigned char *img, i - if (y == height - 1) - memset(row3, 0, width); - else -- memcpy(row3, yp + width, width); -+ memcpy(row3, yp+width, width); - - /* Init slots 0 and 1 in the moving window. */ - window[0] = MAX3(row1[0], row2[0], row3[0]); -@@ -449,14 +634,16 @@ static int dilate9(unsigned char *img, i - blob = MAX2(window[0], window[1]); - widx = 2; - -- /* Iterate over the current row; index i is off by one to eliminate -+ /* -+ * Iterate over the current row; index i is off by one to eliminate - * a lot of +1es in the loop. - */ - for (i = 2; i <= width - 1; i++) { - /* Get the max value of the next column in the 3x3 matrix. */ - latest = window[widx] = MAX3(row1[i], row2[i], row3[i]); - -- /* If the value is larger than the current max, use it. Otherwise, -+ /* -+ * If the value is larger than the current max, use it. Otherwise, - * calculate a new max (because the new value may not be the max. - */ - if (latest >= blob) -@@ -483,11 +670,15 @@ static int dilate9(unsigned char *img, i - return sum; - } - --/* Dilates a + shape */ -+/** -+ * dilate5 -+ * Dilates a + shape. -+ */ - static int dilate5(unsigned char *img, int width, int height, void *buffer) - { -- /* - row1, row2 and row3 represent lines in the temporary buffer -- * - mem holds the max value of the overlapping part of two + shapes -+ /* -+ * - row1, row2 and row3 represent lines in the temporary buffer. -+ * - mem holds the max value of the overlapping part of two + shapes. - */ - int y, i, sum = 0; - unsigned char *row1, *row2, *row3, *rowTemp, *yp; -@@ -516,7 +707,7 @@ static int dilate5(unsigned char *img, i - if (y == height - 1) - memset(row3, 0, width); - else -- memcpy(row3, yp+width, width); -+ memcpy(row3, yp + width, width); - - /* Init mem and set blob to force an evaluation of the entire + shape. */ - mem = MAX2(row2[0], row2[1]); -@@ -550,48 +741,59 @@ static int dilate5(unsigned char *img, i - return sum; - } - --/* Erodes a 3x3 box */ -+/** -+ * erode9 -+ * Erodes a 3x3 box. -+ */ - static int erode9(unsigned char *img, int width, int height, void *buffer, unsigned char flag) - { - int y, i, sum = 0; - char *Row1,*Row2,*Row3; -+ - Row1 = buffer; - Row2 = Row1 + width; -- Row3 = Row1 + 2*width; -+ Row3 = Row1 + 2 * width; - memset(Row2, flag, width); - memcpy(Row3, img, width); -+ - for (y = 0; y < height; y++) { - memcpy(Row1, Row2, width); - memcpy(Row2, Row3, width); -- if (y == height - 1) -+ -+ if (y == height-1) - memset(Row3, flag, width); - else -- memcpy(Row3, img+(y + 1) * width, width); -+ memcpy(Row3, img + (y+1) * width, width); - -- for (i = width-2; i >= 1; i--) { -- if (Row1[i-1] == 0 || -- Row1[i] == 0 || -- Row1[i+1] == 0 || -- Row2[i-1] == 0 || -- Row2[i] == 0 || -- Row2[i+1] == 0 || -- Row3[i-1] == 0 || -- Row3[i] == 0 || -- Row3[i+1] == 0) -+ for (i = width - 2; i >= 1; i--) { -+ if (Row1[i - 1] == 0 || -+ Row1[i] == 0 || -+ Row1[i + 1] == 0 || -+ Row2[i - 1] == 0 || -+ Row2[i] == 0 || -+ Row2[i + 1] == 0 || -+ Row3[i - 1] == 0 || -+ Row3[i] == 0 || -+ Row3[i + 1] == 0) - img[y * width + i] = 0; - else - sum++; - } -+ - img[y * width] = img[y * width + width - 1] = flag; - } - return sum; - } - --/* Erodes in a + shape */ -+/** -+ * erode5 -+ * Erodes in a + shape. -+ */ - static int erode5(unsigned char *img, int width, int height, void *buffer, unsigned char flag) - { - int y, i, sum = 0; - char *Row1,*Row2,*Row3; -+ - Row1 = buffer; - Row2 = Row1 + width; - Row3 = Row1 + 2 * width; -@@ -607,12 +809,12 @@ static int erode5(unsigned char *img, in - else - memcpy(Row3, img + (y + 1) * width, width); - -- for (i = width-2; i >= 1; i--) { -- if (Row1[i] == 0 || -- Row2[i-1] == 0 || -- Row2[i] == 0 || -- Row2[i+1] == 0 || -- Row3[i] == 0) -+ for (i = width - 2; i >= 1; i--) { -+ if (Row1[i] == 0 || -+ Row2[i - 1] == 0 || -+ Row2[i] == 0 || -+ Row2[i + 1] == 0 || -+ Row3[i] == 0) - img[y * width + i] = 0; - else - sum++; -@@ -623,20 +825,21 @@ static int erode5(unsigned char *img, in - return sum; - } - --/* -- * Despeckling routine to remove noisy detections. -+/** -+ * alg_despeckle -+ * Despeckling routine to remove noisy detections. - */ - int alg_despeckle(struct context *cnt, int olddiffs) - { - int diffs = 0; - unsigned char *out = cnt->imgs.out; - int width = cnt->imgs.width; -- int height= cnt->imgs.height; -- int done = 0, i, len = strlen(cnt->conf.despeckle); -+ int height = cnt->imgs.height; -+ int done = 0, i, len = strlen(cnt->conf.despeckle_filter); - unsigned char *common_buffer = cnt->imgs.common_buffer; - - for (i = 0; i < len; i++) { -- switch (cnt->conf.despeckle[i]) { -+ switch (cnt->conf.despeckle_filter[i]) { - case 'E': - if ((diffs = erode9(out, width, height, common_buffer, 0)) == 0) - i = len; -@@ -655,7 +858,7 @@ int alg_despeckle(struct context *cnt, i - diffs = dilate5(out, width, height, common_buffer); - done = 1; - break; -- /* no further despeckle after labeling! */ -+ /* No further despeckle after labeling! */ - case 'l': - diffs = alg_labeling(cnt); - i = len; -@@ -664,58 +867,66 @@ int alg_despeckle(struct context *cnt, i - } - } - -- /* If conf.despeckle contains any valid action EeDdl */ -+ /* If conf.despeckle_filter contains any valid action EeDdl */ - if (done) { - if (done != 2) - cnt->imgs.labelsize_max = 0; // Disable Labeling - return diffs; - } else { - cnt->imgs.labelsize_max = 0; // Disable Labeling -- } -- -+ } -+ - return olddiffs; - } - --/* Generate actual smartmask. Calculate sensitivity based on motion */ -+/** -+ * alg_tune_smartmask -+ * Generates actual smartmask. Calculate sensitivity based on motion. -+ */ - void alg_tune_smartmask(struct context *cnt) - { - int i, diff; -- - int motionsize = cnt->imgs.motionsize; - unsigned char *smartmask = cnt->imgs.smartmask; - unsigned char *smartmask_final = cnt->imgs.smartmask_final; - int *smartmask_buffer = cnt->imgs.smartmask_buffer; -- int sensitivity=cnt->lastrate*(11-cnt->smartmask_speed); -+ int sensitivity = cnt->lastrate * (11 - cnt->smartmask_speed); - - for (i = 0; i < motionsize; i++) { -- -- /* Decrease smart_mask sensitivity every 5*speed seconds only */ -+ /* Decrease smart_mask sensitivity every 5*speed seconds only. */ - if (smartmask[i] > 0) - smartmask[i]--; -- /* Increase smart_mask sensitivity based on the buffered values */ -+ /* Increase smart_mask sensitivity based on the buffered values. */ - diff = smartmask_buffer[i]/sensitivity; -+ - if (diff) { - if (smartmask[i] <= diff + 80) - smartmask[i] += diff; - else -- smartmask[i]=80; -- smartmask_buffer[i]%=sensitivity; -+ smartmask[i] = 80; -+ smartmask_buffer[i] %= sensitivity; - } -- /* Transfer raw mask to the final stage when above trigger value */ -+ /* Transfer raw mask to the final stage when above trigger value. */ - if (smartmask[i] > 20) - smartmask_final[i] = 0; - else - smartmask_final[i] = 255; - } -- /* Further expansion (here:erode due to inverted logic!) of the mask */ -- diff = erode9(smartmask_final, cnt->imgs.width, cnt->imgs.height, cnt->imgs.common_buffer, 255); -- diff = erode5(smartmask_final, cnt->imgs.width, cnt->imgs.height, cnt->imgs.common_buffer, 255); -+ /* Further expansion (here:erode due to inverted logic!) of the mask. */ -+ diff = erode9(smartmask_final, cnt->imgs.width, cnt->imgs.height, -+ cnt->imgs.common_buffer, 255); -+ diff = erode5(smartmask_final, cnt->imgs.width, cnt->imgs.height, -+ cnt->imgs.common_buffer, 255); - } - - /* Increment for *smartmask_buffer in alg_diff_standard. */ - #define SMARTMASK_SENSITIVITY_INCR 5 - --int alg_diff_standard (struct context *cnt, unsigned char *new) -+/** -+ * alg_diff_standard -+ * -+ */ -+int alg_diff_standard(struct context *cnt, unsigned char *new) - { - struct images *imgs = &cnt->imgs; - int i, diffs = 0; -@@ -724,23 +935,25 @@ int alg_diff_standard (struct context *c - unsigned char *ref = imgs->ref; - unsigned char *out = imgs->out; - unsigned char *mask = imgs->mask; -- unsigned char *smartmask_final=imgs->smartmask_final; -+ unsigned char *smartmask_final = imgs->smartmask_final; - int *smartmask_buffer = imgs->smartmask_buffer; - #ifdef HAVE_MMX -- mmx_t mmtemp; /* used for transferring to/from memory */ -- int unload; /* counter for unloading diff counts */ -+ mmx_t mmtemp; /* Used for transferring to/from memory. */ -+ int unload; /* Counter for unloading diff counts. */ - #endif - - i = imgs->motionsize; -- memset(out + i, 128, i / 2); /* motion pictures are now b/w i.o. green */ -- /* Keeping this memset in the MMX case when zeroes are necessarily -+ memset(out + i, 128, i / 2); /* Motion pictures are now b/w i.o. green */ -+ /* -+ * Keeping this memset in the MMX case when zeroes are necessarily - * written anyway seems to be beneficial in terms of speed. Perhaps a - * cache thing? - */ - memset(out, 0, i); - - #ifdef HAVE_MMX -- /* NOTE: The Pentium has two instruction pipes: U and V. I have grouped MMX -+ /* -+ * NOTE: The Pentium has two instruction pipes: U and V. I have grouped MMX - * instructions in pairs according to how I think they will be scheduled in - * the U and V pipes. Due to pairing constraints, the V pipe will sometimes - * be empty (for example, memory access always goes into the U pipe). -@@ -753,13 +966,16 @@ int alg_diff_standard (struct context *c - * -- Per Jonsson - */ - -- /* To avoid a div, we work with differences multiplied by 255 in the -+ /* -+ * To avoid a div, we work with differences multiplied by 255 in the - * default case and *mask otherwise. Thus, the limit to compare with is -- * 255*(noise+1)-1). -+ * 255 * (noise + 1) - 1). - */ -- mmtemp.uw[0] = mmtemp.uw[1] = mmtemp.uw[2] = mmtemp.uw[3] = (unsigned short)(noise * 255 + 254); -+ mmtemp.uw[0] = mmtemp.uw[1] = mmtemp.uw[2] = mmtemp.uw[3] = -+ (unsigned short)(noise * 255 + 254); - -- /* Reset mm5 to zero, set the mm6 mask, and store the multiplied noise -+ /* -+ * Reset mm5 to zero, set the mm6 mask, and store the multiplied noise - * level as four words in mm7. - */ - movq_m2r(mmtemp, mm7); /* U */ -@@ -768,7 +984,8 @@ int alg_diff_standard (struct context *c - pxor_r2r(mm5, mm5); /* U */ - psrlw_i2r(8, mm6); /* V */ - -- /* We must unload mm5 every 255th round, because the diffs accumulate -+ /* -+ * We must unload mm5 every 255th round, because the diffs accumulate - * in each packed byte, which can hold at most 255 diffs before it - * gets saturated. - */ -@@ -796,7 +1013,8 @@ int alg_diff_standard (struct context *c - punpckhbw_r2r(mm4, mm1); /* U: mm1 = d7 d6 d5 d4 */ - - if (mask) { -- /* Load and expand 8 mask bytes to words in mm2 and mm3. Then -+ /* -+ * Load and expand 8 mask bytes to words in mm2 and mm3. Then - * multiply by mm0 and mm1, respectively. - */ - movq_m2r(*mask, mm2); /* U: mm2 = m7 m6 m5 m4 m3 m2 m1 m0 */ -@@ -809,9 +1027,10 @@ int alg_diff_standard (struct context *c - - pmullw_r2r(mm3, mm1); /* U: mm1 = (d7*m7) ... (d4*m4) */ - -- mask+=8; -+ mask += 8; - } else { -- /* Not using mask - multiply the absolute differences by 255. We -+ /* -+ * Not using mask - multiply the absolute differences by 255. We - * do this by left-shifting 8 places and then subtracting dX. - */ - movq_r2r(mm0, mm2); /* U: mm2 = d3 d2 d1 d0 */ -@@ -824,7 +1043,8 @@ int alg_diff_standard (struct context *c - psubusw_r2r(mm3, mm1); /* V */ - } - -- /* Next, compare the multiplied absolute differences with the multiplied -+ /* -+ * Next, compare the multiplied absolute differences with the multiplied - * noise level (repeated as 4 words in mm7), resulting in a "motion flag" - * for each pixel. - * -@@ -851,32 +1071,34 @@ int alg_diff_standard (struct context *c - packuswb_r2r(mm1, mm0); /* U: mm0 = f7 f6 f5 f4 f3 f2 f1 f0 */ - - if (smartmask_speed) { -- /* Apply the smartmask. Basically, if *smartmask_final is 0, the -+ /* -+ * Apply the smartmask. Basically, if *smartmask_final is 0, the - * corresponding "motion flag" in mm0 will be reset. - */ - movq_m2r(*smartmask_final, mm3); /* U: mm3 = s7 s6 s5 s4 s3 s2 s1 s0 */ - -- /* ...but move the "motion flags" to memory before, in order to -+ /* -+ * ...but move the "motion flags" to memory before, in order to - * increment *smartmask_buffer properly below. - */ - movq_r2m(mm0, mmtemp); /* U */ - pcmpeqb_r2r(mm4, mm3); /* V: mm3 = 0xff where sX==0 */ - -- /* ANDN negates the target before anding. */ -+ /* AND negates the target before anding. */ - pandn_r2r(mm0, mm3); /* U: mm3 = 0xff where dX>noise && sX>0 */ - - movq_r2r(mm3, mm0); /* U */ - - /* Add to *smartmask_buffer. This is probably the fastest way to do it. */ - if (cnt->event_nr != cnt->prev_event) { -- if (mmtemp.ub[0]) smartmask_buffer[0]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[1]) smartmask_buffer[1]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[2]) smartmask_buffer[2]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[3]) smartmask_buffer[3]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[4]) smartmask_buffer[4]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[5]) smartmask_buffer[5]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[6]) smartmask_buffer[6]+=SMARTMASK_SENSITIVITY_INCR; -- if (mmtemp.ub[7]) smartmask_buffer[7]+=SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[0]) smartmask_buffer[0] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[1]) smartmask_buffer[1] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[2]) smartmask_buffer[2] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[3]) smartmask_buffer[3] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[4]) smartmask_buffer[4] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[5]) smartmask_buffer[5] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[6]) smartmask_buffer[6] += SMARTMASK_SENSITIVITY_INCR; -+ if (mmtemp.ub[7]) smartmask_buffer[7] += SMARTMASK_SENSITIVITY_INCR; - } - - smartmask_buffer += 8; -@@ -885,19 +1107,22 @@ int alg_diff_standard (struct context *c - - movq_m2r(*new, mm2); /* U: mm1 = n7 n6 n5 n4 n3 n2 n1 n0 */ - -- /* Cancel out pixels in *new according to the "motion flags" in mm0. -+ /* -+ * Cancel out pixels in *new according to the "motion flags" in mm0. - * Each NX is either 0 or nX as from *new. - */ - pand_r2r(mm0, mm2); /* U: mm1 = N7 N6 N5 N4 N3 N2 N1 N0 */ - psubb_r2r(mm0, mm4); /* V: mm4 = 0x01 where dX>noise */ - -- /* mm5 holds 8 separate counts - each one is increased according to -+ /* -+ * mm5 holds 8 separate counts - each one is increased according to - * the contents of mm4 (where each byte is either 0x00 or 0x01). - */ - movq_r2m(mm2, *out); /* U: this will stall */ - paddusb_r2r(mm4, mm5); /* V: add counts to mm5 */ - -- /* Every 255th turn, we need to unload mm5 into the diffs variable, -+ /* -+ * Every 255th turn, we need to unload mm5 into the diffs variable, - * because otherwise the packed bytes will get saturated. - */ - if (--unload == 0) { -@@ -910,12 +1135,13 @@ int alg_diff_standard (struct context *c - unload = 255; - } - -- out+=8; -- ref+=8; -- new+=8; -+ out += 8; -+ ref += 8; -+ new += 8; - } - -- /* Check if there are diffs left in mm5 that need to be copied to the -+ /* -+ * Check if there are diffs left in mm5 that need to be copied to the - * diffs variable. - */ - if (unload < 255) { -@@ -927,27 +1153,30 @@ int alg_diff_standard (struct context *c - emms(); - - #endif -- /* Note that the non-MMX code is present even if the MMX code is present. -+ /* -+ * Note that the non-MMX code is present even if the MMX code is present. - * This is necessary if the resolution is not a multiple of 8, in which - * case the non-MMX code needs to take care of the remaining pixels. - */ - -- for (; i>0; i--) { -- register unsigned char curdiff=(int)(abs(*ref - *new)); /* using a temp variable is 12% faster */ -- /* apply fixed mask */ -+ for (; i > 0; i--) { -+ register unsigned char curdiff = (int)(abs(*ref - *new)); /* Using a temp variable is 12% faster. */ -+ /* Apply fixed mask */ - if (mask) -- curdiff=((int)(curdiff * *mask++) / 255); -+ curdiff = ((int)(curdiff * *mask++) / 255); - - if (smartmask_speed) { - if (curdiff > noise) { -- /* increase smart_mask sensitivity every frame when motion -- is detected. (with speed=5, mask is increased by 1 every -- second. To be able to increase by 5 every second (with -- speed=10) we add 5 here. NOT related to the 5 at ratio- -- calculation. */ -+ /* -+ * Increase smart_mask sensitivity every frame when motion -+ * is detected. (with speed=5, mask is increased by 1 every -+ * second. To be able to increase by 5 every second (with -+ * speed=10) we add 5 here. NOT related to the 5 at ratio- -+ * calculation. -+ */ - if (cnt->event_nr != cnt->prev_event) - (*smartmask_buffer) += SMARTMASK_SENSITIVITY_INCR; -- /* apply smart_mask */ -+ /* Apply smart_mask */ - if (!*smartmask_final) - curdiff = 0; - } -@@ -966,25 +1195,26 @@ int alg_diff_standard (struct context *c - return diffs; - } - --/* -- Very fast diff function, does not apply mask overlaying. --*/ -+/** -+ * alg_diff_fast -+ * Very fast diff function, does not apply mask overlaying. -+ */ - static char alg_diff_fast(struct context *cnt, int max_n_changes, unsigned char *new) - { - struct images *imgs = &cnt->imgs; -- int i, diffs = 0, step = imgs->motionsize / 10000; -- int noise=cnt->noise; -+ int i, diffs = 0, step = imgs->motionsize/10000; -+ int noise = cnt->noise; - unsigned char *ref = imgs->ref; - - if (!step % 2) - step++; -- /* we're checking only 1 of several pixels */ -+ /* We're checking only 1 of several pixels. */ - max_n_changes /= step; - - i = imgs->motionsize; - - for (; i > 0; i -= step) { -- register unsigned char curdiff = (int)(abs((char)(*ref-*new))); /* using a temp variable is 12% faster */ -+ register unsigned char curdiff = (int)(abs((char)(*ref - *new))); /* Using a temp variable is 12% faster. */ - if (curdiff > noise) { - diffs++; - if (diffs > max_n_changes) -@@ -997,9 +1227,11 @@ static char alg_diff_fast(struct context - return 0; - } - --/* alg_diff uses diff_fast to quickly decide if there is anything worth -- * sending to diff_standard. --*/ -+/** -+ * alg_diff -+ * Uses diff_fast to quickly decide if there is anything worth -+ * sending to diff_standard. -+ */ - int alg_diff(struct context *cnt, unsigned char *new) - { - int diffs = 0; -@@ -1010,9 +1242,11 @@ int alg_diff(struct context *cnt, unsign - return diffs; - } - --/* Detect a sudden massive change in the picture. -- It is assumed to be the light being switched on or a camera displacement. -- In any way the user doesn't think it is worth capturing. -+/** -+ * alg_lightswitch -+ * Detects a sudden massive change in the picture. -+ * It is assumed to be the light being switched on or a camera displacement. -+ * In any way the user doesn't think it is worth capturing. - */ - int alg_lightswitch(struct context *cnt, int diffs) - { -@@ -1023,13 +1257,17 @@ int alg_lightswitch(struct context *cnt, - if (cnt->conf.lightswitch > 100) - cnt->conf.lightswitch = 100; - -- /* is lightswitch percent of the image changed? */ -+ /* Is lightswitch percent of the image changed? */ - if (diffs > (imgs->motionsize * cnt->conf.lightswitch / 100)) - return 1; - - return 0; - } - -+/** -+ * alg_switchfilter -+ * -+ */ - int alg_switchfilter(struct context *cnt, int diffs, unsigned char *newimg) - { - int linediff = diffs / cnt->imgs.height; -@@ -1042,7 +1280,6 @@ int alg_switchfilter(struct context *cnt - for (x = 0; x < cnt->imgs.width; x++) { - if (*(out++)) - line++; -- - } - - if (line > cnt->imgs.width / 18) -@@ -1050,7 +1287,6 @@ int alg_switchfilter(struct context *cnt - - if (line > linediff * 2) - lines++; -- - } - - if (vertlines > cnt->imgs.height / 10 && lines < vertlines / 3 && -@@ -1058,7 +1294,7 @@ int alg_switchfilter(struct context *cnt - if (cnt->conf.text_changes) { - char tmp[80]; - sprintf(tmp, "%d %d", lines, vertlines); -- draw_text(newimg, cnt->imgs.width-10, 20, cnt->imgs.width, tmp, cnt->conf.text_double); -+ draw_text(newimg, cnt->imgs.width - 10, 20, cnt->imgs.width, tmp, cnt->conf.text_double); - } - return diffs; - } -@@ -1078,8 +1314,7 @@ int alg_switchfilter(struct context *cnt - * action - UPDATE_REF_FRAME or RESET_REF_FRAME - * - */ --/* Seconds */ --#define ACCEPT_STATIC_OBJECT_TIME 10 -+#define ACCEPT_STATIC_OBJECT_TIME 10 /* Seconds */ - #define EXCLUDE_LEVEL_PERCENT 20 - void alg_update_reference_frame(struct context *cnt, int action) - { -@@ -1091,40 +1326,43 @@ void alg_update_reference_frame(struct c - unsigned char *smartmask = cnt->imgs.smartmask_final; - unsigned char *out = cnt->imgs.out; - -- if (cnt->lastrate > 5) /* match rate limit */ -+ if (cnt->lastrate > 5) /* Match rate limit */ - accept_timer /= (cnt->lastrate / 3); - -- if (action == UPDATE_REF_FRAME) { /* black&white only for better performance */ -+ if (action == UPDATE_REF_FRAME) { /* Black&white only for better performance. */ - threshold_ref = cnt->noise * EXCLUDE_LEVEL_PERCENT / 100; -+ - for (i = cnt->imgs.motionsize; i > 0; i--) { -- /* exclude pixels from ref frame well below noise level */ -+ /* Exclude pixels from ref frame well below noise level. */ - if (((int)(abs(*ref - *image_virgin)) > threshold_ref) && (*smartmask)) { -- if (*ref_dyn == 0) { /* Always give new pixels a chance */ -+ if (*ref_dyn == 0) { /* Always give new pixels a chance. */ - *ref_dyn = 1; -- } else if (*ref_dyn > accept_timer) { /* Include static Object after some time */ -+ } else if (*ref_dyn > accept_timer) { /* Include static Object after some time. */ - *ref_dyn = 0; - *ref = *image_virgin; - } else if (*out) { -- (*ref_dyn)++; /* Motionpixel? Keep excluding from ref frame */ -+ (*ref_dyn)++; /* Motionpixel? Keep excluding from ref frame. */ - } else { -- *ref_dyn = 0; /* Nothing special - release pixel */ -+ *ref_dyn = 0; /* Nothing special - release pixel. */ - *ref = (*ref + *image_virgin) / 2; - } - -- } else { /* No motion: copy to ref frame */ -- *ref_dyn = 0; /* reset pixel */ -+ } else { /* No motion: copy to ref frame. */ -+ *ref_dyn = 0; /* Reset pixel */ - *ref = *image_virgin; - } -+ - ref++; - image_virgin++; - smartmask++; - ref_dyn++; - out++; - } /* end for i */ -- } else { /* action == RESET_REF_FRAME - also used to initialize the frame at startup */ -- /* copy fresh image */ -+ -+ } else { /* action == RESET_REF_FRAME - also used to initialize the frame at startup. */ -+ /* Copy fresh image */ - memcpy(cnt->imgs.ref, cnt->imgs.image_virgin, cnt->imgs.size); -- /* reset static objects */ -- memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); -+ /* Reset static objects */ -+ memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); - } - } ---- motion-3.2.12.orig/alg.h -+++ motion-3.2.12/alg.h -@@ -32,7 +32,8 @@ struct segment { - }; - - void alg_locate_center_size(struct images *, int width, int height, struct coord *); --void alg_draw_location(struct coord *, struct images *, int width, unsigned char *, int); -+void alg_draw_location(struct coord *, struct images *, int width, unsigned char *, int, int, int); -+void alg_draw_red_location(struct coord *, struct images *, int width, unsigned char *, int, int, int); - int alg_diff(struct context *, unsigned char *); - int alg_diff_standard(struct context *, unsigned char *); - int alg_lightswitch(struct context *, int diffs); ---- /dev/null -+++ motion-3.2.12/commit-version.sh -@@ -0,0 +1,5 @@ -+#!/bin/sh -+ -+SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` -+SNV_VERSION=`expr $SNV_VERSION + 1` -+echo -n "trunkREV$SNV_VERSION" ---- motion-3.2.12.orig/conf.c -+++ motion-3.2.12/conf.c -@@ -25,8 +25,7 @@ - */ - #include "motion.h" - -- --#if (defined(BSD)) -+#if (defined(BSD) && !defined(PWCBSD)) - #include "video_freebsd.h" - #else - #include "video.h" -@@ -35,140 +34,151 @@ - #ifndef HAVE_GET_CURRENT_DIR_NAME - char *get_current_dir_name(void) - { -- char *buf = malloc(MAXPATHLEN); -+ char *buf = mymalloc(MAXPATHLEN); - getwd(buf); - return buf; - } - #endif - -- --#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0;} -- -+#define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0; } - - struct config conf_template = { -- width: DEF_WIDTH, -- height: DEF_HEIGHT, -- quality: DEF_QUALITY, -- rotate_deg: 0, -- max_changes: DEF_CHANGES, -- threshold_tune: 0, -- output_normal: "on", -- motion_img: 0, -- output_all: 0, -- gap: DEF_GAP, -- maxmpegtime: DEF_MAXMPEGTIME, -- snapshot_interval: 0, -- locate: "off", -- input: IN_DEFAULT, -- norm: 0, -- frame_limit: DEF_MAXFRAMERATE, -- quiet: 1, -- ppm: 0, -- noise: DEF_NOISELEVEL, -- noise_tune: 1, -- minimum_frame_time: 0, -- lightswitch: 0, -- autobright: 0, -- brightness: 0, -- contrast: 0, -- saturation: 0, -- hue: 0, -- roundrobin_frames: 1, -- roundrobin_skip: 1, -- pre_capture: 0, -- post_capture: 0, -- switchfilter: 0, -- ffmpeg_cap_new: 0, -- ffmpeg_cap_motion: 0, -- ffmpeg_bps: DEF_FFMPEG_BPS, -- ffmpeg_vbr: DEF_FFMPEG_VBR, -- ffmpeg_video_codec: DEF_FFMPEG_CODEC, -- webcam_port: 0, -- webcam_quality: 50, -- webcam_motion: 0, -- webcam_maxrate: 1, -- webcam_localhost: 1, -- webcam_limit: 0, -- control_port: 0, -- control_localhost: 1, -- control_html_output: 1, -- control_authentication: NULL, -- frequency: 0, -- tuner_number: 0, -- timelapse: 0, -- timelapse_mode: DEF_TIMELAPSE_MODE, -+ width: DEF_WIDTH, -+ height: DEF_HEIGHT, -+ quality: DEF_QUALITY, -+ rotate_deg: 0, -+ max_changes: DEF_CHANGES, -+ threshold_tune: 0, -+ output_pictures: "on", -+ motion_img: 0, -+ emulate_motion: 0, -+ event_gap: DEF_EVENT_GAP, -+ max_movie_time: DEF_MAXMOVIETIME, -+ snapshot_interval: 0, -+ locate_motion_mode: "off", -+ locate_motion_style: "box", -+ input: IN_DEFAULT, -+ norm: 0, -+ frame_limit: DEF_MAXFRAMERATE, -+ quiet: 1, -+ picture_type: "jpeg", -+ noise: DEF_NOISELEVEL, -+ noise_tune: 1, -+ minimum_frame_time: 0, -+ lightswitch: 0, -+ autobright: 0, -+ brightness: 0, -+ contrast: 0, -+ saturation: 0, -+ hue: 0, -+ roundrobin_frames: 1, -+ roundrobin_skip: 1, -+ pre_capture: 0, -+ post_capture: 0, -+ switchfilter: 0, -+ ffmpeg_output: 0, -+ extpipe: NULL, -+ useextpipe: 0, -+ ffmpeg_output_debug: 0, -+ ffmpeg_bps: DEF_FFMPEG_BPS, -+ ffmpeg_vbr: DEF_FFMPEG_VBR, -+ ffmpeg_video_codec: DEF_FFMPEG_CODEC, -+#ifdef HAVE_SDL -+ sdl_threadnr: 0, -+#endif -+ ipv6_enabled: 0, -+ stream_port: 0, -+ stream_quality: 50, -+ stream_motion: 0, -+ stream_maxrate: 1, -+ stream_localhost: 1, -+ stream_limit: 0, -+ stream_auth_method: 0, -+ stream_authentication: NULL, -+ webcontrol_port: 0, -+ webcontrol_localhost: 1, -+ webcontrol_html_output: 1, -+ webcontrol_authentication: NULL, -+ frequency: 0, -+ tuner_number: 0, -+ timelapse: 0, -+ timelapse_mode: DEF_TIMELAPSE_MODE, - #if (defined(BSD)) -- tuner_device: NULL, -+ tuner_device: NULL, -+#endif -+ video_device: VIDEO_DEVICE, -+ v4l2_palette: DEF_PALETTE, -+ vidpipe: NULL, -+ filepath: NULL, -+ imagepath: DEF_IMAGEPATH, -+ moviepath: DEF_MOVIEPATH, -+ snappath: DEF_SNAPPATH, -+ timepath: DEF_TIMEPATH, -+ on_event_start: NULL, -+ on_event_end: NULL, -+ mask_file: NULL, -+ smart_mask_speed: 0, -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) -+ sql_log_image: 1, -+ sql_log_snapshot: 1, -+ sql_log_movie: 0, -+ sql_log_timelapse: 0, -+ sql_query: DEF_SQL_QUERY, -+ database_type: NULL, -+ database_dbname: NULL, -+ database_host: "localhost", -+ database_user: NULL, -+ database_password: NULL, -+ database_port: 0, -+#ifdef HAVE_SQLITE3 -+ sqlite3_db: NULL, - #endif -- video_device: VIDEO_DEVICE, -- v4l2_palette: 8, -- vidpipe: NULL, -- filepath: NULL, -- jpegpath: DEF_JPEGPATH, -- mpegpath: DEF_MPEGPATH, -- snappath: DEF_SNAPPATH, -- timepath: DEF_TIMEPATH, -- on_event_start: NULL, -- on_event_end: NULL, -- mask_file: NULL, -- smart_mask_speed: 0, -- sql_log_image: 1, -- sql_log_snapshot: 1, -- sql_log_mpeg: 0, -- sql_log_timelapse: 0, -- sql_query: DEF_SQL_QUERY, -- mysql_db: NULL, -- mysql_host: "localhost", -- mysql_user: NULL, -- mysql_password: NULL, -- on_picture_save: NULL, -- on_motion_detected: NULL, -- on_area_detected: NULL, -- on_movie_start: NULL, -- on_movie_end: NULL, -- on_camera_lost: NULL, -- motionvidpipe: NULL, -- netcam_url: NULL, -- netcam_userpass: NULL, -- netcam_http: "1.0", /* Choices: 1.0, 1.1, or keep_alive */ -- netcam_proxy: NULL, -- netcam_tolerant_check: 0, -- pgsql_db: NULL, -- pgsql_host: "localhost", -- pgsql_user: NULL, -- pgsql_password: NULL, -- pgsql_port: 5432, -- text_changes: 0, -- text_left: NULL, -- text_right: DEF_TIMESTAMP, -- text_event: DEF_EVENTSTAMP, -- text_double: 0, -- despeckle: NULL, -- area_detect: NULL, -- minimum_motion_frames: 1, -- pid_file: NULL, -+#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || define(HAVE_SQLITE3) */ -+ on_picture_save: NULL, -+ on_motion_detected: NULL, -+ on_area_detected: NULL, -+ on_movie_start: NULL, -+ on_movie_end: NULL, -+ on_camera_lost: NULL, -+ motionvidpipe: NULL, -+ netcam_url: NULL, -+ netcam_userpass: NULL, -+ netcam_keepalive: "off", -+ netcam_proxy: NULL, -+ netcam_tolerant_check: 0, -+ rtsp_uses_tcp: 1, -+ text_changes: 0, -+ text_left: NULL, -+ text_right: DEF_TIMESTAMP, -+ text_event: DEF_EVENTSTAMP, -+ text_double: 0, -+ despeckle_filter: NULL, -+ area_detect: NULL, -+ minimum_motion_frames: 1, -+ exif_text: NULL, -+ pid_file: NULL, -+ log_file: NULL, -+ log_level: LEVEL_DEFAULT+10, -+ log_type_str: NULL, - }; - - -- --static struct context ** copy_bool(struct context **, const char *, int); --static struct context ** copy_int(struct context **, const char *, int); --static struct context ** copy_short(struct context **, const char *, int); --static struct context ** config_thread(struct context **cnt, const char *str, int val); -- --static const char * print_bool(struct context **, char **, int, unsigned short int); --static const char * print_int(struct context **, char **, int, unsigned short int); --static const char * print_short(struct context **, char **, int, unsigned short int); --static const char * print_string(struct context **, char **, int, unsigned short int); --static const char * print_thread(struct context **, char **, int, unsigned short int); -+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); -+ -+static const char *print_bool(struct context **, char **, int, unsigned int); -+static const char *print_int(struct context **, char **, int, unsigned int); -+static const char *print_string(struct context **, char **, int, unsigned int); -+static const char *print_thread(struct context **, char **, int, unsigned int); - - static void usage(void); - - /* Pointer magic to determine relative addresses of variables to a - struct context pointer */ - #define CNT_OFFSET(varname) ((long)&((struct context *)NULL)->varname) --#define CONF_OFFSET(varname) ((long)&((struct context *)NULL)->conf.varname) --#define TRACK_OFFSET(varname) ((long)&((struct context *)NULL)->track.varname) -+#define CONF_OFFSET(varname) ((long)&((struct context *)NULL)->conf.varname) -+#define TRACK_OFFSET(varname) ((long)&((struct context *)NULL)->track.varname) - - config_param config_params[] = { - { -@@ -202,6 +212,30 @@ config_param config_params[] = { - print_bool - }, - { -+ "logfile", -+ "# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)", -+ 1, -+ CONF_OFFSET(log_file), -+ copy_string, -+ print_string -+ }, -+ { -+ "log_level", -+ "# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC)", -+ 1, -+ CONF_OFFSET(log_level), -+ copy_int, -+ print_int -+ }, -+ { -+ "log_type", -+ "# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)", -+ 1, -+ CONF_OFFSET(log_type_str), -+ copy_string, -+ print_string -+ }, -+ { - "videodevice", - "\n###########################################################\n" - "# Capture device options\n" -@@ -216,26 +250,36 @@ config_param config_params[] = { - { - "v4l2_palette", - "# v4l2_palette allows to choose preferable palette to be use by motion\n" -- "# to capture from those supported by your videodevice. (default: 8)\n" -+ "# to capture from those supported by your videodevice. (default: 17)\n" - "# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and\n" - "# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG.\n" -- "# Setting v4l2_palette to 1 forces motion to use V4L2_PIX_FMT_SBGGR8\n" -+ "# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8\n" - "# instead.\n" - "#\n" - "# Values :\n" - "# V4L2_PIX_FMT_SN9C10X : 0 'S910'\n" -- "# V4L2_PIX_FMT_SBGGR8 : 1 'BA81'\n" -- "# V4L2_PIX_FMT_MJPEG : 2 'MJPEG'\n" -- "# V4L2_PIX_FMT_JPEG : 3 'JPEG'\n" -- "# V4L2_PIX_FMT_RGB24 : 4 'RGB3'\n" -- "# V4L2_PIX_FMT_UYVY : 5 'UYVY'\n" -- "# V4L2_PIX_FMT_YUYV : 6 'YUYV'\n" -- "# V4L2_PIX_FMT_YUV422P : 7 '422P'\n" -- "# V4L2_PIX_FMT_YUV420 : 8 'YU12'", -+ "# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2'\n" -+ "# V4L2_PIX_FMT_SBGGR8 : 2 'BA81'\n" -+ "# V4L2_PIX_FMT_SPCA561 : 3 'S561'\n" -+ "# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG'\n" -+ "# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG'\n" -+ "# V4L2_PIX_FMT_PAC207 : 6 'P207'\n" -+ "# V4L2_PIX_FMT_PJPG : 7 'PJPG'\n" -+ "# V4L2_PIX_FMT_MJPEG : 8 'MJPEG'\n" -+ "# V4L2_PIX_FMT_JPEG : 9 'JPEG'\n" -+ "# V4L2_PIX_FMT_RGB24 : 10 'RGB3'\n" -+ "# V4L2_PIX_FMT_SPCA501 : 11 'S501'\n" -+ "# V4L2_PIX_FMT_SPCA505 : 12 'S505'\n" -+ "# V4L2_PIX_FMT_SPCA508 : 13 'S508'\n" -+ "# V4L2_PIX_FMT_UYVY : 14 'UYVY'\n" -+ "# V4L2_PIX_FMT_YUYV : 15 'YUYV'\n" -+ "# V4L2_PIX_FMT_YUV422P : 16 '422P'\n" -+ "# V4L2_PIX_FMT_YUV420 : 17 'YU12'\n" -+ "#", - 0, - CONF_OFFSET(v4l2_palette), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - #if (defined(BSD)) - { -@@ -250,8 +294,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, -@@ -277,7 +321,7 @@ config_param config_params[] = { - { - "rotate", - "# Rotate image this number of degrees. The rotation affects all saved images as\n" -- "# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270.", -+ "# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270.", - 0, - CONF_OFFSET(rotate_deg), - copy_int, -@@ -320,7 +364,7 @@ config_param config_params[] = { - }, - { - "netcam_url", -- "# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///)\n" -+ "# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// or file:///)\n" - "# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined", - 0, - CONF_OFFSET(netcam_url), -@@ -337,14 +381,14 @@ config_param config_params[] = { - print_string - }, - { -- "netcam_http", -+ "netcam_keepalive", - "# The setting for keep-alive of network socket, should improve performance on compatible net cameras.\n" -- "# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request.\n" -- "# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection.\n" -- "# 1.1: Use HTTP/1.1 requests that support keep alive as default.\n" -- "# Default: 1.0", -+ "# off: The historical implementation using HTTP/1.0, closing the socket after each http request.\n" -+ "# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection.\n" -+ "# on: Use HTTP/1.1 requests that support keep alive as default.\n" -+ "# Default: off", - 0, -- CONF_OFFSET(netcam_http), -+ CONF_OFFSET(netcam_keepalive), - copy_string, - print_string - }, -@@ -361,11 +405,20 @@ config_param config_params[] = { - { - "netcam_tolerant_check", - "# Set less strict jpeg checks for network cameras with a poor/buggy firmware.\n" -- "# Default: off", -+ "# Default: off", - 0, - CONF_OFFSET(netcam_tolerant_check), - copy_bool, -- print_bool -+ print_bool -+ }, -+ { -+ "rtsp_uses_tcp", -+ "# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption.\n" -+ "# Default: on", -+ 1, -+ CONF_OFFSET(rtsp_uses_tcp), -+ copy_bool, -+ print_bool - }, - { - "auto_brightness", -@@ -480,22 +533,23 @@ config_param config_params[] = { - print_bool - }, - { -- "despeckle", -+ "despeckle_filter", - "# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined)\n" - "# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid.\n" - "# (l)abeling must only be used once and the 'l' must be the last letter.\n" - "# Comment out to disable", - 0, -- CONF_OFFSET(despeckle), -+ CONF_OFFSET(despeckle_filter), - copy_string, - print_string - }, - { - "area_detect", -- "# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3\n" -+ "# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3\n" - "# A script (on_area_detected) is started immediately when motion is 4 5 6\n" - "# detected in one of the given areas, but only once during an event. 7 8 9\n" -- "# One or more areas can be specified with this option. (Default: not defined)", -+ "# One or more areas can be specified with this option. Take care: This option\n" -+ "# does NOT restrict detection to these areas! (Default: not defined)", - 0, - CONF_OFFSET(area_detect), - copy_string, -@@ -522,7 +576,9 @@ config_param config_params[] = { - { - "lightswitch", - "# Ignore sudden massive light intensity changes given as a percentage of the picture\n" -- "# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled", -+ "# area that changed intensity. If set to 1, motion will do some kind of\n" -+ "# auto-lightswitch. Valid range: 0 - 100 , default: 0 = disabled", -+ - 0, - CONF_OFFSET(lightswitch), - copy_int, -@@ -544,7 +600,7 @@ config_param config_params[] = { - "# was detected that will be output at motion detection.\n" - "# Recommended range: 0 to 5 (default: 0)\n" - "# Do not use large values! Large values will cause Motion to skip video frames and\n" -- "# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.", -+ "# cause unsmooth movies. To smooth movies use larger values of post_capture instead.", - 0, - CONF_OFFSET(pre_capture), - copy_int, -@@ -559,35 +615,37 @@ config_param config_params[] = { - print_int - }, - { -- "gap", -- "# Gap is the seconds of no motion detection that triggers the end of an event\n" -+ "event_gap", -+ "# Event Gap is the seconds of no motion detection that triggers the end of an event.\n" - "# An event is defined as a series of motion images taken within a short timeframe.\n" -- "# Recommended value is 60 seconds (Default). The value 0 is allowed and disables\n" -- "# events causing all Motion to be written to one single mpeg file and no pre_capture.", -+ "# Recommended value is 60 seconds (Default). The value -1 is allowed and disables\n" -+ "# events causing all Motion to be written to one single movie file and no pre_capture.\n" -+ "# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An\n" -+ "# event ends right after no more motion is detected and post_capture is over.", - 0, -- CONF_OFFSET(gap), -+ CONF_OFFSET(event_gap), - copy_int, - print_int - }, - { -- "max_mpeg_time", -- "# Maximum length in seconds of an mpeg movie\n" -- "# When value is exceeded a new mpeg file is created. (Default: 0 = infinite)", -+ "max_movie_time", -+ "# Maximum length in seconds of a movie\n" -+ "# When value is exceeded a new movie file is created. (Default: 0 = infinite)", - 0, -- CONF_OFFSET(maxmpegtime), -+ CONF_OFFSET(max_movie_time), - copy_int, - print_int - }, - { -- "output_all", -+ "emulate_motion", - "# Always save images even if there was no motion (default: off)", - 0, -- CONF_OFFSET(output_all), -+ CONF_OFFSET(emulate_motion), - copy_bool, - print_bool - }, - { -- "output_normal", -+ "output_pictures", - "\n############################################################\n" - "# Image File Output\n" - "############################################################\n\n" -@@ -598,12 +656,12 @@ config_param config_params[] = { - "# Picture with motion nearest center of picture is saved when set to 'center'.\n" - "# Can be used as preview shot for the corresponding movie.", - 0, -- CONF_OFFSET(output_normal), -+ CONF_OFFSET(output_pictures), - copy_string, - print_string - }, - { -- "output_motion", -+ "output_debug_pictures", - "# Output pictures with only the pixels moving object (ghost images) (default: off)", - 0, - CONF_OFFSET(motion_img), -@@ -619,34 +677,35 @@ config_param config_params[] = { - print_int - }, - { -- "ppm", -- "# Output ppm images instead of jpeg (default: off)", -+ "picture_type", -+ "# Type of output images\n" -+ "# Valid values: jpeg, ppm (default: jpeg)", - 0, -- CONF_OFFSET(ppm), -- copy_bool, -- print_bool -+ CONF_OFFSET(picture_type), -+ copy_string, -+ print_string - }, - #ifdef HAVE_FFMPEG - { -- "ffmpeg_cap_new", -+ "ffmpeg_output_movies", - "\n############################################################\n" - "# FFMPEG related options\n" -- "# Film (mpeg) file output, and deinterlacing of the video input\n" -+ "# Film (movie) file output, and deinterlacing of the video input\n" - "# The options movie_filename and timelapse_filename are also used\n" - "# by the ffmpeg feature\n" - "############################################################\n\n" -- "# Use ffmpeg to encode mpeg movies in realtime (default: off)", -+ "# Use ffmpeg to encode movies in realtime (default: off)", - 0, -- CONF_OFFSET(ffmpeg_cap_new), -+ CONF_OFFSET(ffmpeg_output), - copy_bool, - print_bool - }, - { -- "ffmpeg_cap_motion", -+ "ffmpeg_output_debug_movies", - "# Use ffmpeg to make movies with only the pixels moving\n" - "# object (ghost images) (default: off)", - 0, -- CONF_OFFSET(ffmpeg_cap_motion), -+ CONF_OFFSET(ffmpeg_output_debug), - copy_bool, - print_bool - }, -@@ -691,7 +750,7 @@ config_param config_params[] = { - { - "ffmpeg_video_codec", - "# Codec to used by ffmpeg for the video compression.\n" -- "# Timelapse mpegs are always made in mpeg1 format independent from this option.\n" -+ "# Timelapse movies are always made in mpeg1 format independent from this option.\n" - "# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4.\n" - "# mpeg1 - gives you files with extension .mpg\n" - "# mpeg4 or msmpeg4 - gives you files with extension .avi\n" -@@ -700,7 +759,8 @@ config_param config_params[] = { - "# swf - gives you a flash film with extension .swf\n" - "# flv - gives you a flash video with extension .flv\n" - "# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )\n" -- "# mov - QuickTime ( testing )", -+ "# mov - QuickTime ( testing )\n" -+ "# ogg - Ogg/Theora ( testing )", - 0, - CONF_OFFSET(ffmpeg_video_codec), - copy_string, -@@ -717,6 +777,42 @@ config_param config_params[] = { - print_bool - }, - #endif /* HAVE_FFMPEG */ -+#ifdef HAVE_SDL -+ { -+ "sdl_threadnr", -+ "\n############################################################\n" -+ "# SDL Window\n" -+ "############################################################\n\n" -+ "# Number of motion thread to show in SDL Window (default: 0 = disabled)", -+ 1, -+ CONF_OFFSET(sdl_threadnr), -+ copy_int, -+ print_int -+ }, -+#endif /* HAVE_SDL */ -+ { -+ "use_extpipe", -+ "\n############################################################\n" -+ "# External pipe to video encoder\n" -+ "# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only.\n" -+ "# The options movie_filename and timelapse_filename are also used\n" -+ "# by the ffmpeg feature\n" -+ "############################################################\n\n" -+ "# Bool to enable or disable extpipe (default: off)", -+ 0, -+ CONF_OFFSET(useextpipe), -+ copy_bool, -+ print_bool -+ }, -+ { -+ "extpipe", -+ "# External program (full path and opts) to pipe raw video to\n" -+ "# Generally, use '-' for STDIN...", -+ 0, -+ CONF_OFFSET(extpipe), -+ copy_string, -+ print_string -+ }, - { - "snapshot_interval", - "\n############################################################\n" -@@ -729,7 +825,7 @@ config_param config_params[] = { - print_int - }, - { -- "locate", -+ "locate_motion_mode", - "\n############################################################\n" - "# Text Display\n" - "# %Y = year, %m = month, %d = date,\n" -@@ -743,10 +839,23 @@ config_param config_params[] = { - "# leading spaces\n" - "############################################################\n\n" - "# Locate and draw a box around the moving object.\n" -- "# Valid values: on, off and preview (default: off)\n" -+ "# Valid values: on, off, preview (default: off)\n" - "# Set to 'preview' will only draw a box in preview_shot pictures.", - 0, -- CONF_OFFSET(locate), -+ CONF_OFFSET(locate_motion_mode), -+ copy_string, -+ print_string -+ }, -+ { -+ "locate_motion_style", -+ "# Set the look and style of the locate box if enabled.\n" -+ "# Valid values: box, redbox, cross, redcross (default: box)\n" -+ "# Set to 'box' will draw the traditional box.\n" -+ "# Set to 'redbox' will draw a red box.\n" -+ "# Set to 'cross' will draw a little cross to mark center.\n" -+ "# Set to 'redcross' will draw a little red cross to mark center.", -+ 0, -+ CONF_OFFSET(locate_motion_style), - copy_string, - print_string - }, -@@ -770,7 +879,7 @@ config_param config_params[] = { - copy_string, - print_string - }, -- { -+ { - "text_changes", - "# Draw the number of changed pixed on the images (default: off)\n" - "# Will normally be set to off except when you setup and adjust the motion settings\n" -@@ -802,10 +911,20 @@ config_param config_params[] = { - print_bool - }, - { -+ "exif_text", -+ "# Text to include in a JPEG EXIF comment\n" -+ "# May be any text, including conversion specifiers.\n" -+ "# The EXIF timestamp is included independent of this text.", -+ 0, -+ CONF_OFFSET(exif_text), -+ copy_string, -+ print_string -+ }, -+ { - "target_dir", - "\n############################################################\n" - "# Target Directories and filenames For Images And Films\n" -- "# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename\n" -+ "# For the options snapshot_, picture_, movie_ and timelapse_filename\n" - "# you can use conversion specifiers\n" - "# %Y = year, %m = month, %d = date,\n" - "# %H = hour, %M = minute, %S = second,\n" -@@ -838,36 +957,36 @@ config_param config_params[] = { - print_string - }, - { -- "jpeg_filename", -+ "picture_filename", - "# File path for motion triggered images (jpeg or ppm) relative to target_dir\n" -- "# Default: "DEF_JPEGPATH"\n" -+ "# Default: "DEF_IMAGEPATH"\n" - "# Default value is equivalent to legacy oldlayout option\n" - "# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q\n" - "# File extension .jpg or .ppm is automatically added so do not include this\n" - "# Set to 'preview' together with best-preview feature enables special naming\n" - "# convention for preview shots. See motion guide for details", - 0, -- CONF_OFFSET(jpegpath), -+ CONF_OFFSET(imagepath), - copy_string, - print_string - }, - #ifdef HAVE_FFMPEG - { - "movie_filename", -- "# File path for motion triggered ffmpeg films (mpeg) relative to target_dir\n" -- "# Default: "DEF_MPEGPATH"\n" -+ "# File path for motion triggered ffmpeg films (movies) relative to target_dir\n" -+ "# Default: "DEF_MOVIEPATH"\n" - "# Default value is equivalent to legacy oldlayout option\n" - "# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S\n" - "# File extension .mpg or .avi is automatically added so do not include this\n" - "# This option was previously called ffmpeg_filename", - 0, -- CONF_OFFSET(mpegpath), -+ CONF_OFFSET(moviepath), - copy_string, - print_string - }, - { - "timelapse_filename", -- "# File path for timelapse mpegs relative to target_dir\n" -+ "# File path for timelapse movies relative to target_dir\n" - "# Default: "DEF_TIMEPATH"\n" - "# Default value is near equivalent to legacy oldlayout option\n" - "# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse\n" -@@ -879,107 +998,138 @@ config_param config_params[] = { - }, - #endif /* HAVE_FFMPEG */ - { -- "webcam_port", -+ "ipv6_enabled", - "\n############################################################\n" -- "# Live Webcam Server\n" -+ "# Global Network Options\n" -+ "############################################################\n\n" -+ "# Enable or disable IPV6 for http control and stream (default: off)", -+ 0, -+ CONF_OFFSET(ipv6_enabled), -+ copy_bool, -+ print_bool -+ }, -+ { -+ "stream_port", -+ "\n############################################################\n" -+ "# Live Stream Server\n" - "############################################################\n\n" - "# The mini-http server listens to this port for requests (default: 0 = disabled)", - 0, -- CONF_OFFSET(webcam_port), -+ CONF_OFFSET(stream_port), - copy_int, - print_int - }, - { -- "webcam_quality", -+ "stream_quality", - "# Quality of the jpeg (in percent) images produced (default: 50)", - 0, -- CONF_OFFSET(webcam_quality), -+ CONF_OFFSET(stream_quality), - copy_int, - print_int - }, - { -- "webcam_motion", -+ "stream_motion", - "# Output frames at 1 fps when no motion is detected and increase to the\n" -- "# rate given by webcam_maxrate when motion is detected (default: off)", -+ "# rate given by stream_maxrate when motion is detected (default: off)", - 0, -- CONF_OFFSET(webcam_motion), -+ CONF_OFFSET(stream_motion), - copy_bool, - print_bool - }, - { -- "webcam_maxrate", -- "# Maximum framerate for webcam streams (default: 1)", -+ "stream_maxrate", -+ "# Maximum framerate for streams (default: 1)", - 0, -- CONF_OFFSET(webcam_maxrate), -+ CONF_OFFSET(stream_maxrate), - copy_int, - print_int - }, - { -- "webcam_localhost", -- "# Restrict webcam connections to localhost only (default: on)", -+ "stream_localhost", -+ "# Restrict stream connections to localhost only (default: on)", - 0, -- CONF_OFFSET(webcam_localhost), -+ CONF_OFFSET(stream_localhost), - copy_bool, - print_bool - }, - { -- "webcam_limit", -+ "stream_limit", - "# Limits the number of images per connection (default: 0 = unlimited)\n" -- "# Number can be defined by multiplying actual webcam rate by desired number of seconds\n" -- "# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate", -+ "# Number can be defined by multiplying actual stream rate by desired number of seconds\n" -+ "# Actual stream rate is the smallest of the numbers framerate and stream_maxrate", -+ 0, -+ CONF_OFFSET(stream_limit), -+ copy_int, -+ print_int -+ }, -+ { -+ "stream_auth_method", -+ "# Set the authentication method (default: 0)\n" -+ "# 0 = disabled \n" -+ "# 1 = Basic authentication\n" -+ "# 2 = MD5 digest (the safer authentication)\n", - 0, -- CONF_OFFSET(webcam_limit), -+ CONF_OFFSET(stream_auth_method), - copy_int, - print_int - }, - { -- "control_port", -+ "stream_authentication", -+ "# Authentication for the stream. Syntax username:password\n" -+ "# Default: not defined (Disabled)", -+ 1, -+ CONF_OFFSET(stream_authentication), -+ copy_string, -+ print_string -+ }, -+ { -+ "webcontrol_port", - "\n############################################################\n" - "# HTTP Based Control\n" - "############################################################\n\n" - "# TCP/IP port for the http server to listen on (default: 0 = disabled)", - 1, -- CONF_OFFSET(control_port), -+ CONF_OFFSET(webcontrol_port), - copy_int, - print_int - }, - { -- "control_localhost", -+ "webcontrol_localhost", - "# Restrict control connections to localhost only (default: on)", - 1, -- CONF_OFFSET(control_localhost), -+ CONF_OFFSET(webcontrol_localhost), - copy_bool, - print_bool - }, - { -- "control_html_output", -+ "webcontrol_html_output", - "# Output for http server, select off to choose raw text plain (default: on)", - 1, -- CONF_OFFSET(control_html_output), -+ CONF_OFFSET(webcontrol_html_output), - copy_bool, - print_bool - }, - { -- "control_authentication", -+ "webcontrol_authentication", - "# Authentication for the http based control. Syntax username:password\n" - "# Default: not defined (Disabled)", - 1, -- CONF_OFFSET(control_authentication), -+ CONF_OFFSET(webcontrol_authentication), - copy_string, - print_string -- }, -+ }, - { - "track_type", - "\n############################################################\n" - "# Tracking (Pan/Tilt)\n" - "############################################################\n\n" -- "# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo)\n" -+ "# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo)\n" - "# The generic type enables the definition of motion center and motion size to\n" - "# be used with the conversion specifiers for options like on_motion_detected", - 0, - TRACK_OFFSET(type), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "track_auto", -@@ -1002,40 +1152,88 @@ config_param config_params[] = { - "# Motor number for x-axis (default: 0)", - 0, - TRACK_OFFSET(motorx), -- copy_short, -- print_short -+ copy_int, -+ print_int -+ }, -+ { -+ "track_motorx_reverse", -+ "# Set motorx reverse (default: off)", -+ 0, -+ TRACK_OFFSET(motorx_reverse), -+ copy_bool, -+ print_bool - }, - { - "track_motory", - "# Motor number for y-axis (default: 0)", - 0, - TRACK_OFFSET(motory), -- copy_short, -- print_short -+ copy_int, -+ print_int -+ }, -+ { -+ "track_motory_reverse", -+ "# Set motory reverse (default: off)", -+ 0, -+ TRACK_OFFSET(motory_reverse), -+ copy_bool, -+ print_bool - }, - { - "track_maxx", - "# Maximum value on x-axis (default: 0)", - 0, - TRACK_OFFSET(maxx), -- copy_short, -- print_short -+ copy_int, -+ print_int -+ }, -+ { -+ "track_minx", -+ "# Minimum value on x-axis (default: 0)", -+ 0, -+ TRACK_OFFSET(minx), -+ copy_int, -+ print_int - }, - { - "track_maxy", - "# Maximum value on y-axis (default: 0)", - 0, - TRACK_OFFSET(maxy), -- copy_short, -- print_short -+ copy_int, -+ print_int -+ }, -+ { -+ "track_miny", -+ "# Minimum value on y-axis (default: 0)", -+ 0, -+ TRACK_OFFSET(miny), -+ copy_int, -+ print_int -+ }, -+ { -+ "track_homex", -+ "# Center value on x-axis (default: 0)", -+ 0, -+ TRACK_OFFSET(homex), -+ copy_int, -+ print_int -+ }, -+ { -+ "track_homey", -+ "# Center value on y-axis (default: 0)", -+ 0, -+ TRACK_OFFSET(homey), -+ copy_int, -+ print_int - }, - { - "track_iomojo_id", - "# ID of an iomojo camera if used (default: 0)", - 0, - TRACK_OFFSET(iomojo_id), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "track_step_angle_x", -@@ -1044,8 +1242,8 @@ config_param config_params[] = { - "# Currently only used with pwc type cameras", - 0, - TRACK_OFFSET(step_angle_x), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "track_step_angle_y", -@@ -1054,8 +1252,8 @@ config_param config_params[] = { - "# Currently only used with pwc type cameras", - 0, - TRACK_OFFSET(step_angle_y), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "track_move_wait", -@@ -1063,24 +1261,24 @@ config_param config_params[] = { - "# of picture frames (default: 10)", - 0, - TRACK_OFFSET(move_wait), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "track_speed", - "# Speed to set the motor to (stepper motor option) (default: 255)", - 0, - TRACK_OFFSET(speed), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "track_stepsize", - "# Number of steps to make (stepper motor option) (default: 40)", - 0, - TRACK_OFFSET(stepsize), -- copy_short, -- print_short -+ copy_int, -+ print_int - }, - { - "quiet", -@@ -1097,7 +1295,7 @@ config_param config_params[] = { - "# %f = filename with full path\n" - "# %n = number indicating filetype\n" - "# Both %f and %n are only defined for on_picture_save,\n" -- "# on_movie_start and on_movie_end\n" -+ "# on_movie_start and on_movie_end\n" - "# Quotation marks round string are allowed.\n" - "############################################################\n\n" - "# Do not sound beeps when detecting motion (default: on)\n" -@@ -1110,7 +1308,7 @@ config_param config_params[] = { - { - "on_event_start", - "# Command to be executed when an event starts. (default: none)\n" -- "# An event starts at first motion detected after a period of no motion defined by gap ", -+ "# An event starts at first motion detected after a period of no motion defined by event_gap ", - 0, - CONF_OFFSET(on_event_start), - copy_string, -@@ -1119,7 +1317,7 @@ config_param config_params[] = { - { - "on_event_end", - "# Command to be executed when an event ends after a period of no motion\n" -- "# (default: none). The period of no motion is defined by option gap.", -+ "# (default: none). The period of no motion is defined by option event_gap.", - 0, - CONF_OFFSET(on_event_end), - copy_string, -@@ -1174,21 +1372,21 @@ config_param config_params[] = { - { - "on_camera_lost", - "# Command to be executed when a camera can't be opened or if it is lost\n" -- "# NOTE: There is situations when motion doesn't detect a lost camera!\n" -- "# It depends on the driver, some drivers don't detect a lost camera at all\n" -- "# Some hang the motion thread. Some even hang the PC! (default: none)", -+ "# NOTE: There is situations when motion don't detect a lost camera!\n" -+ "# It depends on the driver, some drivers dosn't detect a lost camera at all\n" -+ "# Some hangs the motion thread. Some even hangs the PC! (default: none)", - 0, - CONF_OFFSET(on_camera_lost), - copy_string, - print_string - }, - --#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) - { -- "sql_log_image", -+ "sql_log_picture", - "\n############################################################\n" -- "# Common Options For MySQL and PostgreSQL database features.\n" -- "# Options require the MySQL/PostgreSQL options to be active also.\n" -+ "# Common Options for database features.\n" -+ "# Options require the database options to be active also.\n" - "############################################################\n\n" - "# Log to the database when creating motion triggered image file (default: on)", - 0, -@@ -1205,16 +1403,16 @@ config_param config_params[] = { - print_bool - }, - { -- "sql_log_mpeg", -- "# Log to the database when creating motion triggered mpeg file (default: off)", -+ "sql_log_movie", -+ "# Log to the database when creating motion triggered movie file (default: off)", - 0, -- CONF_OFFSET(sql_log_mpeg), -+ CONF_OFFSET(sql_log_movie), - copy_bool, - print_bool - }, - { - "sql_log_timelapse", -- "# Log to the database when creating timelapse mpeg file (default: off)", -+ "# Log to the database when creating timelapse movie file (default: off)", - 0, - CONF_OFFSET(sql_log_timelapse), - copy_bool, -@@ -1227,6 +1425,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, -@@ -1234,98 +1440,80 @@ config_param config_params[] = { - copy_string, - print_string - }, --#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) */ -- --#ifdef HAVE_MYSQL - { -- "mysql_db", -+ "database_type", - "\n############################################################\n" -- "# Database Options For MySQL\n" -+ "# Database Options \n" - "############################################################\n\n" -- "# Mysql database to log to (default: not defined)", -+ "# database type : mysql, postgresql, sqlite3 (default : not defined)", - 0, -- CONF_OFFSET(mysql_db), -+ CONF_OFFSET(database_type), - copy_string, - print_string - }, - { -- "mysql_host", -- "# The host on which the database is located (default: localhost)", -+ "database_dbname", -+ "# database to log to (default: not defined)", - 0, -- CONF_OFFSET(mysql_host), -+ CONF_OFFSET(database_dbname), - copy_string, - print_string - }, - { -- "mysql_user", -- "# User account name for MySQL database (default: not defined)", -+ "database_host", -+ "# The host on which the database is located (default: not defined)", - 0, -- CONF_OFFSET(mysql_user), -+ CONF_OFFSET(database_host), - copy_string, - print_string - }, - { -- "mysql_password", -- "# User password for MySQL database (default: not defined)", -+ "database_user", -+ "# User account name for database (default: not defined)", - 0, -- CONF_OFFSET(mysql_password), -+ CONF_OFFSET(database_user), - copy_string, - print_string - }, --#endif /* HAVE_MYSQL */ -- --#ifdef HAVE_PGSQL - { -- "pgsql_db", -- "\n############################################################\n" -- "# Database Options For PostgreSQL\n" -- "############################################################\n\n" -- "# PostgreSQL database to log to (default: not defined)", -+ "database_password", -+ "# User password for database (default: not defined)", - 0, -- CONF_OFFSET(pgsql_db), -+ CONF_OFFSET(database_password), - copy_string, - print_string - }, - { -- "pgsql_host", -- "# The host on which the database is located (default: localhost)", -+ "database_port", -+ "# Port on which the database is located (default: not defined)\n" -+ "# mysql 3306 , postgresql 5432 (default: not defined)", - 0, -- CONF_OFFSET(pgsql_host), -- copy_string, -- print_string -- }, -- { -- "pgsql_user", -- "# User account name for PostgreSQL database (default: not defined)", -- 0, -- CONF_OFFSET(pgsql_user), -- copy_string, -- print_string -+ CONF_OFFSET(database_port), -+ copy_int, -+ print_int - }, -+#ifdef HAVE_SQLITE3 - { -- "pgsql_password", -- "# User password for PostgreSQL database (default: not defined)", -+ "sqlite3_db", -+ "\n############################################################\n" -+ "# Database Options For SQLite3\n" -+ "############################################################\n\n" -+ "# SQLite3 database to log to (default: not defined)", - 0, -- CONF_OFFSET(pgsql_password), -+ CONF_OFFSET(sqlite3_db), - copy_string, - print_string - }, -- { -- "pgsql_port", -- "# Port on which the PostgreSQL database is located (default: 5432)", -- 0, -- CONF_OFFSET(pgsql_port), -- copy_int, -- print_int -- }, --#endif /* HAVE_PGSQL */ -+#endif /* HAVE_SQLITE3 */ -+ -+#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ - { - "video_pipe", - "\n############################################################\n" - "# Video Loopback Device (vloopback project)\n" - "############################################################\n\n" - "# Output images to a video4linux loopback device\n" -- "# The value '-' means next available (default: not defined)", -+ "# The value '-' means next available (default: not defined)", - 0, - CONF_OFFSET(vidpipe), - copy_string, -@@ -1356,22 +1544,27 @@ config_param config_params[] = { - { NULL, NULL, 0, 0, NULL, NULL } - }; - --/* conf_cmdline sets the conf struct options as defined by the command line. -- * Any option already set from a config file are overridden. -+/** -+ * conf_cmdline -+ * Sets the conf struct options as defined by the Command-line. -+ * Any option already set from a config file are overridden. -+ * -+ * Returns nothing. - */ --static void conf_cmdline(struct context *cnt, short int thread) -+static void conf_cmdline(struct context *cnt, int thread) - { - struct config *conf = &cnt->conf; - int c; - -- /* For the string options, we free() if necessary and malloc() -+ /* -+ * For the string options, we free() if necessary and malloc() - * 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:")) != EOF) -+ while ((c = getopt(conf->argc, conf->argv, "c:d:hmns?p:k:l:")) != EOF) - switch (c) { - case 'c': -- if (thread == -1) -+ if (thread == -1) - strcpy(cnt->conf_filename, optarg); - break; - case 'n': -@@ -1381,59 +1574,83 @@ static void conf_cmdline(struct context - conf->setup_mode = 1; - break; - case 'd': -- /* no validation - just take what user gives */ -- debug_level = (unsigned short int)atoi(optarg); -+ /* No validation - just take what user gives. */ -+ if (thread == -1) -+ cnt->log_level = (unsigned int)atoi(optarg); - break; -+ case 'k': -+ if (thread == -1) { -+ strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); -+ cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; -+ } -+ break; - case 'p': -- if (thread == -1) -- strcpy(cnt->pid_file, optarg); -+ if (thread == -1) { -+ strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); -+ cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; -+ } -+ break; -+ case 'l': -+ if (thread == -1) { -+ strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); -+ cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; -+ } -+ break; -+ case 'm': -+ cnt->pause = 1; - break; - case 'h': - case '?': - default: -- usage(); -- exit(1); -+ usage(); -+ exit(1); - } -+ - optind = 1; - } - - --/* conf_cmdparse sets a config option given by 'cmd' to the value given by 'arg1'. -- * Based on the name of the option it searches through the struct 'config_params' -- * for an option where the config_params[i].param_name matches the option. -- * By calling the function pointed to by config_params[i].copy the option gets -- * assigned. -+/** -+ * conf_cmdparse -+ * Sets a config option given by 'cmd' to the value given by 'arg1'. -+ * Based on the name of the option it searches through the struct 'config_params' -+ * for an option where the config_params[i].param_name matches the option. -+ * By calling the function pointed to by config_params[i].copy the option gets -+ * assigned. -+ * -+ * Returns context struct. - */ - struct context **conf_cmdparse(struct context **cnt, const char *cmd, const char *arg1) - { -- unsigned short int i = 0; -+ unsigned int i = 0; - - if (!cmd) - return cnt; - -- /* We search through config_params until we find a param_name that matches -- * our option given by cmd (or reach the end = NULL) -+ /* -+ * We search through config_params until we find a param_name that matches -+ * our option given by cmd (or reach the end = NULL). - */ - while (config_params[i].param_name != NULL) { - if (!strncasecmp(cmd, config_params[i].param_name , 255 + 50)) { // Why +50? -- -- /* if config_param is string we don't want to check arg1 */ -- if (strcmp(config_type(&config_params[i]),"string")) { -+ -+ /* If config_param is string we don't want to check arg1. */ -+ if (strcmp(config_type(&config_params[i]), "string")) { - if (config_params[i].conf_value && !arg1) - return cnt; - } -- -- /* We call the function given by the pointer config_params[i].copy -+ -+ /* -+ * We call the function given by the pointer config_params[i].copy - * If the option is a bool, copy_bool is called. - * If the option is an int, copy_int is called. -- * If the option is a short, copy_short is called. - * If the option is a string, copy_string is called. - * If the option is a thread, config_thread is called. - * The arguments to the function are: -- * cnt - a pointer to the context structure -- * arg1 - a pointer to the new option value (represented as string) -+ * cnt - a pointer to the context structure. -+ * arg1 - a pointer to the new option value (represented as string). - * config_params[i].conf_value - an integer value which is a pointer -- * to the context structure member relative to the pointer cnt. -+ * to the context structure member relative to the pointer cnt. - */ - cnt = config_params[i].copy(cnt, arg1, config_params[i].conf_value); - return cnt; -@@ -1441,78 +1658,85 @@ struct context **conf_cmdparse(struct co - i++; - } - -- /* We reached the end of config_params without finding a matching option */ -- motion_log(LOG_ERR, 0, "Unknown config option \"%s\"", cmd); -+ /* We reached the end of config_params without finding a matching option. */ -+ MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, "%s: Unknown config option \"%s\"", -+ cmd); - - return cnt; - } - --/* conf_process walks through an already open config file line by line -- * Any line starting with '#' or ';' or empty lines are ignored as a comments. -- * Any non empty line is process so that the first word is the name of an option 'cnd' -- * and the rest of the line is the argument 'arg1' -- * White space before the first word, between option and argument and end of the line -- * is discarded. A '=' between option and first word in argument is also discarded. -- * Quotation marks round the argument are also discarded. -- * For each option/argument pair the function conf_cmdparse is called which takes -- * care of assigning the value to the option in the config structures. -+/** -+ * conf_process -+ * Walks through an already open config file line by line -+ * Any line starting with '#' or ';' or empty lines are ignored as a comments. -+ * Any non empty line is process so that the first word is the name of an option 'cnd' -+ * and the rest of the line is the argument 'arg1' -+ * White space before the first word, between option and argument and end of the line -+ * is discarded. A '=' between option and first word in argument is also discarded. -+ * Quotation marks round the argument are also discarded. -+ * For each option/argument pair the function conf_cmdparse is called which takes -+ * care of assigning the value to the option in the config structures. -+ * -+ * Returns context struct. - */ - static struct context **conf_process(struct context **cnt, FILE *fp) - { -- /* process each line from the config file */ -- -+ /* Process each line from the config file. */ -+ - char line[PATH_MAX], *cmd = NULL, *arg1 = NULL; - char *beg = NULL, *end = NULL; - - while (fgets(line, PATH_MAX-1, fp)) { -- if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) {/* skipcomment */ -- -+ if (!(line[0] == '#' || line[0] == ';' || strlen(line) < 2)) {/* skipcomment */ -+ - arg1 = NULL; - -- /* trim white space and any CR or LF at the end of the line */ -- end = line + strlen(line) - 1; /* Point to the last non-null character in the string */ -+ /* Trim white space and any CR or LF at the end of the line. */ -+ end = line + strlen(line) - 1; /* Point to the last non-null character in the string. */ - while (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r') - end--; - - *(end+1) = '\0'; -- -- /* If line is only whitespace we continue to the next line */ -+ -+ /* If line is only whitespace we continue to the next line. */ - if (strlen(line) == 0) - continue; - -- /* trim leading whitespace from the line and find command */ -+ /* Trim leading whitespace from the line and find command. */ - beg = line; -- - while (*beg == ' ' || *beg == '\t') - beg++; - -- cmd = beg; /* command starts here */ -+ -+ cmd = beg; /* Command starts here. */ - - while (*beg != ' ' && *beg != '\t' && *beg != '=' && *beg != '\0') - beg++; -- -- *beg = '\0'; /* command string terminates here */ - -- /* trim space between command and argument */ -+ *beg = '\0'; /* Command string terminates here. */ -+ -+ /* Trim space between command and argument. */ - beg++; - - if (strlen(beg) > 0) { - while (*beg == ' ' || *beg == '\t' || *beg == '=' || *beg == '\n' || *beg == '\r') - beg++; -- - -- /* If argument is in "" we will strip them off -- It is important that we can use "" so that we can use -- leading spaces in text_left and text_right */ -- if ((beg[0]=='"' && beg[strlen(beg)-1]=='"') || -- (beg[0]=='\'' && beg[strlen(beg)-1]=='\'')) { -- beg[strlen(beg)-1]='\0'; -+ -+ /* -+ * If argument is in "" we will strip them off -+ * It is important that we can use "" so that we can use -+ * leading spaces in text_left and text_right. -+ */ -+ if ((beg[0] == '"' && beg[strlen(beg)-1] == '"') || -+ (beg[0] == '\'' && beg[strlen(beg)-1] == '\'')) { -+ beg[strlen(beg)-1] = '\0'; - beg++; - } -- -+ - arg1 = beg; /* Argument starts here */ - } -- /* else arg1 stays null pointer */ -+ /* Else arg1 stays null pointer */ - - cnt = conf_cmdparse(cnt, cmd, arg1); - } -@@ -1522,19 +1746,25 @@ static struct context **conf_process(str - } - - --/* conf_print is used to write out the config file(s) motion.conf and any thread -- * config files. The function is called when using http remote control. -+/** -+ * conf_print -+ * Is used to write out the config file(s) motion.conf and any thread -+ * config files. The function is called when using http remote control. -+ * -+ * Returns nothing. - */ - void conf_print(struct context **cnt) - { - const char *retval; - char *val; -- unsigned short int i, thread; -+ unsigned int i, thread; - FILE *conffile; - - for (thread = 0; cnt[thread]; thread++) { -- motion_log(LOG_INFO, 0, "Writing config file to %s",cnt[thread]->conf_filename); -- conffile=myfopen(cnt[thread]->conf_filename, "w"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Writing config file to %s", -+ cnt[thread]->conf_filename); -+ -+ conffile = myfopen(cnt[thread]->conf_filename, "w", 0); - - if (!conffile) - continue; -@@ -1544,13 +1774,14 @@ void conf_print(struct context **cnt) - fprintf(conffile, "\n\n"); - - for (i = 0; config_params[i].param_name; i++) { -- retval=config_params[i].print(cnt, NULL, i, thread); -- /*If config parameter has a value (not NULL) print it to the config file*/ -- -+ retval = config_params[i].print(cnt, NULL, i, thread); -+ /* If config parameter has a value (not NULL) print it to the config file. */ - if (retval) { - fprintf(conffile, "%s\n", config_params[i].param_help); -- /* If the option is a text_* and first char is a space put -- quotation marks around to allow leading spaces */ -+ /* -+ * If the option is a text_* and first char is a space put -+ * quotation marks around to allow leading spaces. -+ */ - if (strncmp(config_params[i].param_name, "text", 4) || strncmp(retval, " ", 1)) - fprintf(conffile, "%s %s\n\n", config_params[i].param_name, retval); - else -@@ -1558,34 +1789,38 @@ void conf_print(struct context **cnt) - } else { - val = NULL; - config_params[i].print(cnt, &val, i, thread); -- /* It can either be a thread file parameter or a disabled parameter -- If it is a thread parameter write it out -- Else write the disabled option to the config file but with a -- comment mark in front of the parameter name */ -+ /* -+ * It can either be a thread file parameter or a disabled parameter. -+ * If it is a thread parameter write it out. -+ * Else write the disabled option to the config file but with a -+ * comment mark in front of the parameter name. -+ */ - if (val) { -- fprintf(conffile,"%s\n", config_params[i].param_help); -+ fprintf(conffile, "%s\n", config_params[i].param_help); - fprintf(conffile, "%s\n", val); - - if (strlen(val) == 0) -- fprintf(conffile,"; thread /usr/local/etc/thread1.conf\n"); -+ fprintf(conffile, "; thread /usr/local/etc/thread1.conf\n"); -+ - free(val); -- } else if (thread == 0) { -- fprintf(conffile,"%s\n", config_params[i].param_help); -- fprintf(conffile,"; %s value\n\n", config_params[i].param_name); -+ } else if (thread == 0) { -+ fprintf(conffile, "%s\n", config_params[i].param_help); -+ fprintf(conffile, "; %s value\n\n", config_params[i].param_name); - } - } - } - - fprintf(conffile, "\n"); -- fclose(conffile); -+ myfclose(conffile); - conffile = NULL; - } - } - --/************************************************************************** -- * conf_load is the main function, called from motion.c -+/** -+ * conf_load -+ * Is the main function, called from motion.c - * The function sets the important context structure "cnt" including -- * loading the config parameters from config files and command line. -+ * loading the config parameters from config files and Command-line. - * The following takes place in the function: - * - The default start values for cnt stored in the struct conf_template - * are copied to cnt[0] which is the default context structure common to -@@ -1596,31 +1831,35 @@ void conf_print(struct context **cnt) - * - motion.conf is opened and processed. The process populates the cnt[0] and - * for each thread config file it populates a cnt[1], cnt[2]... for each - * thread -- * - Finally it process the options given in the command line. This is done -- * for each thread cnt[i] so that the command line options overrides any -+ * - Finally it process the options given in the Command-line. This is done -+ * for each thread cnt[i] so that the Command-line options overrides any - * option given by motion.conf or a thread config file. -- **************************************************************************/ -+ * -+ * Returns context struct. -+ */ - struct context **conf_load(struct context **cnt) - { - FILE *fp = NULL; - char filename[PATH_MAX]; - int i; -- /* We preserve argc and argv because they get overwritten by the memcpy command */ -+ /* We preserve argc and argv because they get overwritten by the memcpy command. */ - char **argv = cnt[0]->conf.argv; - int argc = cnt[0]->conf.argc; - -- /* Copy the template config structure with all the default config values -+ /* -+ * Copy the template config structure with all the default config values - * into cnt[0]->conf - */ - memcpy(&cnt[0]->conf, &conf_template, sizeof(struct config)); -- -- /* For each member of cnt[0] which is a pointer to a string -- * if the member points to a string in conf_template and is not NULL -- * 1. Reserve (malloc) memory for the string -- * 2. Copy the conf_template given string to the reserved memory -- * 3. Change the cnt[0] member (char*) pointing to the string in reserved memory -+ -+ /* -+ * For each member of cnt[0] which is a pointer to a string -+ * if the member points to a string in conf_template and is not NULL. -+ * 1. Reserve (malloc) memory for the string. -+ * 2. Copy the conf_template given string to the reserved memory. -+ * 3. Change the cnt[0] member (char*) pointing to the string in reserved memory. - * This ensures that we can free and malloc the string when changed -- * via http remote control or config file or command line options -+ * via http remote control or config file or Command-line options. - */ - malloc_strings(cnt[0]); - -@@ -1628,29 +1867,37 @@ struct context **conf_load(struct contex - cnt[0]->conf.argv = argv; - cnt[0]->conf.argc = argc; - -- /* Open the motion.conf file. We try in this sequence: -- * 1. commandline -+ /* -+ * Open the motion.conf file. We try in this sequence: -+ * 1. Command-line - * 2. current working directory - * 3. $HOME/.motion/motion.conf - * 4. sysconfig/motion.conf - */ -- /* Get filename & pid file from commandline */ -+ /* Get filename , pid file & log file from Command-line. */ -+ cnt[0]->log_type_str[0] = 0; - cnt[0]->conf_filename[0] = 0; - cnt[0]->pid_file[0] = 0; -+ cnt[0]->log_file[0] = 0; -+ cnt[0]->log_level = -1; - - conf_cmdline(cnt[0], -1); -- if (cnt[0]->conf_filename[0]) { /* User has supplied filename on commandline*/ -- strcpy(filename, cnt[0]->conf_filename); -- fp = fopen (filename, "r"); -+ -+ if (cnt[0]->conf_filename[0]) { /* User has supplied filename on Command-line. */ -+ strncpy(filename, cnt[0]->conf_filename, PATH_MAX-1); -+ filename[PATH_MAX-1] = '\0'; -+ fp = fopen (filename, "r"); - } - -- if (!fp) { /* Commandline didn't work, try current dir */ -+ if (!fp) { /* Command-line didn't work, try current dir. */ - char *path = NULL; -+ - if (cnt[0]->conf_filename[0]) -- motion_log(-1, 1, "Configfile %s not found - trying defaults.", filename); -- -+ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Configfile %s not found - trying defaults.", -+ filename); -+ - if ((path = get_current_dir_name()) == NULL) { -- motion_log(LOG_ERR, 1, "Error get_current_dir_name"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error get_current_dir_name"); - exit(-1); - } - -@@ -1659,65 +1906,89 @@ struct context **conf_load(struct contex - free(path); - } - -- if (!fp) { /* specified file does not exist... try default file */ -+ if (!fp) { /* Specified file does not exist... try default file. */ - snprintf(filename, PATH_MAX, "%s/.motion/motion.conf", getenv("HOME")); - fp = fopen(filename, "r"); -+ - if (!fp) { - snprintf(filename, PATH_MAX, "%s/motion.conf", sysconfdir); - fp = fopen(filename, "r"); -- if (!fp) /* there is no config file.... use defaults */ -- motion_log(-1, 1, "could not open configfile %s",filename); -+ -+ if (!fp) /* There is no config file.... use defaults. */ -+ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: could not open configfile %s", -+ filename); - } - } - -- /* Now we process the motion.conf config file and close it*/ -+ /* Now we process the motion.conf config file and close it. */ - if (fp) { -- strcpy(cnt[0]->conf_filename, filename); -- motion_log(LOG_INFO, 0, "Processing thread 0 - config file %s",filename); -- cnt = conf_process(cnt, fp); -- fclose(fp); -+ strncpy(cnt[0]->conf_filename, filename, sizeof(cnt[0]->conf_filename) - 1); -+ cnt[0]->conf_filename[sizeof(cnt[0]->conf_filename) - 1] = '\0'; -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing thread 0 - config file %s", -+ filename); -+ cnt = conf_process(cnt, fp); -+ myfclose(fp); - } else { -- motion_log(LOG_INFO, 0, "Not config file to process using default values"); -+ MOTION_LOG(CRT, TYPE_ALL, NO_ERRNO, "%s: Not config file to process using default values"); - } -- - -- /* For each thread (given by cnt[i]) being not null -+ -+ /* -+ * For each thread (given by cnt[i]) being not null - * cnt is an array of pointers to a context type structure - * cnt[0] is the default context structure - * cnt[1], cnt[2], ... are context structures for each thread - * Command line options always wins over config file options -- * so we go through each thread and overrides any set command line -- * options -+ * so we go through each thread and overrides any set Command-line -+ * options. - */ - i = -1; -+ - while (cnt[++i]) - conf_cmdline(cnt[i], i); - -- /* if pid file was passed from command line copy to main thread conf struct */ -- if (cnt[0]->pid_file[0]) -+ /* If pid file was passed from Command-line copy to main thread conf struct. */ -+ if (cnt[0]->pid_file[0]) - cnt[0]->conf.pid_file = mystrcpy(cnt[0]->conf.pid_file, cnt[0]->pid_file); - -+ /* If log file was passed from Command-line copy to main thread conf struct. */ -+ if (cnt[0]->log_file[0]) -+ cnt[0]->conf.log_file = mystrcpy(cnt[0]->conf.log_file, cnt[0]->log_file); -+ -+ /* If log type string was passed from Command-line copy to main thread conf struct. */ -+ if (cnt[0]->log_type_str[0]) -+ cnt[0]->conf.log_type_str = mystrcpy(cnt[0]->conf.log_type_str, cnt[0]->log_type_str); -+ -+ /* if log level was passed from Command-line copy to main thread conf struct. */ -+ if (cnt[0]->log_level != -1) -+ cnt[0]->conf.log_level = cnt[0]->log_level; -+ - return cnt; - } - --/* malloc_strings goes through the members of a context structure. -- * For each context structure member which is a pointer to a string it does this: -- * If the member points to a string and is not NULL -- * 1. Reserve (malloc) memory for the string -- * 2. Copy the original string to the reserved memory -- * 3. Change the cnt member (char*) pointing to the string in reserved memory -- * This ensures that we can free and malloc the string if it is later changed -+/** -+ * malloc_strings -+ * goes through the members of a context structure. -+ * For each context structure member which is a pointer to a string it does this: -+ * If the member points to a string and is not NULL -+ * 1. Reserve (malloc) memory for the string -+ * 2. Copy the original string to the reserved memory -+ * 3. Change the cnt member (char*) pointing to the string in reserved memory -+ * This ensures that we can free and malloc the string if it is later changed -+ * -+ * Returns nothing. - */ --void malloc_strings(struct context * cnt) -+void malloc_strings(struct context *cnt) - { -- unsigned short int i = 0; -+ unsigned int i = 0; - char **val; - while (config_params[i].param_name != NULL) { - if (config_params[i].copy == copy_string) { /* if member is a string */ -- /* val is made to point to a pointer to the current string */ -+ /* val is made to point to a pointer to the current string. */ - val = (char **)((char *)cnt+config_params[i].conf_value); - -- /* if there is a string, malloc() space for it, copy -+ /* -+ * If there is a string, malloc() space for it, copy - * the string to new space, and point to the new - * string. we don't free() because we're copying a - * static string. -@@ -1733,7 +2004,6 @@ void malloc_strings(struct context * cnt - * - * copy_bool - convert a bool representation to int - * copy_int - convert a string to int -- * copy_short - convert a string to short - * copy_string - just a string copy - * - * @param str - A char *, pointing to a string representation of the -@@ -1752,10 +2022,14 @@ void malloc_strings(struct context * cnt - * the function will only assign the value for the given thread. - ***********************************************************************/ - --/* copy_bool assigns a config option to a new boolean value. -- * The boolean is given as a string in str which is converted to 0 or 1 -- * by the function. Values 1, yes and on are converted to 1 ignoring case. -- * Any other value is converted to 0. -+/** -+ * copy_bool -+ * Assigns a config option to a new boolean value. -+ * The boolean is given as a string in str which is converted to 0 or 1 -+ * by the function. Values 1, yes and on are converted to 1 ignoring case. -+ * Any other value is converted to 0. -+ * -+ * Returns context struct. - */ - static struct context **copy_bool(struct context **cnt, const char *str, int val_ptr) - { -@@ -1764,8 +2038,9 @@ static struct context **copy_bool(struct - - i = -1; - while (cnt[++i]) { -- tmp = (char *)cnt[i] + (int)val_ptr; -- if (!strcmp(str, "1") || !strcasecmp(str, "yes") || !strcasecmp(str,"on")) { -+ tmp = (char *)cnt[i]+(int)val_ptr; -+ -+ if (!strcmp(str, "1") || !strcasecmp(str, "yes") || !strcasecmp(str, "on")) { - *((int *)tmp) = 1; - } else { - *((int *)tmp) = 0; -@@ -1774,11 +2049,17 @@ static struct context **copy_bool(struct - if (cnt[0]->threadnr) - return cnt; - } -+ - return cnt; - } - --/* copy_int assigns a config option to a new integer value. -- * The integer is given as a string in str which is converted to integer by the function. -+/** -+ * copy_int -+ * Assigns a config option to a new integer value. -+ * The integer is given as a string in str which is converted to integer -+ * by the function. -+ * -+ * Returns context struct. - */ - static struct context **copy_int(struct context **cnt, const char *str, int val_ptr) - { -@@ -1787,38 +2068,26 @@ static struct context **copy_int(struct - - i = -1; - while (cnt[++i]) { -- tmp = (char *)cnt[i] + val_ptr; -+ tmp = (char *)cnt[i]+val_ptr; - *((int *)tmp) = atoi(str); -- if (cnt[0]->threadnr) -- return cnt; -- } -- return cnt; --} -- --/* copy_short assigns a config option to a new short value. -- * The integer is given as a string in str which is converted to short by the function. -- */ --static struct context **copy_short(struct context **cnt, const char *str, int val_ptr) --{ -- void *tmp; -- int i; - -- i = -1; -- while (cnt[++i]) { -- tmp = (char *)cnt[i] + val_ptr; -- *((short int *)tmp) = atoi(str); - if (cnt[0]->threadnr) - return cnt; - } -+ - return cnt; - } - --/* copy_string assigns a new string value to a config option. -- * Strings are handled differently from bool and int. -- * the char *conf->option that we are working on is free()'d -- * (if memory for it has already been malloc()'d), and set to -- * a freshly malloc()'d string with the value from str, -- * or NULL if str is blank -+/** -+ * copy_string -+ * Assigns a new string value to a config option. -+ * Strings are handled differently from bool and int. -+ * the char *conf->option that we are working on is free()'d -+ * (if memory for it has already been malloc()'d), and set to -+ * a freshly malloc()'d string with the value from str, -+ * or NULL if str is blank. -+ * -+ * Returns context struct. - */ - struct context **copy_string(struct context **cnt, const char *str, int val_ptr) - { -@@ -1826,64 +2095,75 @@ struct context **copy_string(struct cont - int i; - - i = -1; -+ - while (cnt[++i]) { - tmp = (char **)((char *)cnt[i] + val_ptr); - -- /* mystrcpy assigns the new string value -+ /* -+ * mystrcpy assigns the new string value - * including free'ing and reserving new memory for it. - */ - *tmp = mystrcpy(*tmp, str); - -- /* set the option on all threads if setting the option -- * for thread 0; otherwise just set that one thread's option -+ /* -+ * Set the option on all threads if setting the option -+ * for thread 0; otherwise just set that one thread's option. - */ - if (cnt[0]->threadnr) - return cnt; - } -+ - return cnt; - } - - --/* mystrcpy is used to assign string type fields (e.g. config options) -- * In a way so that we the memory is malloc'ed to fit the string. -- * If a field is already pointing to a string (not NULL) the memory of the -- * old string is free'd and new memory is malloc'ed and filled with the -- * new string is copied into the the memory and with the char pointer -- * pointing to the new string. -+/** -+ * mystrcpy -+ * Is used to assign string type fields (e.g. config options) -+ * In a way so that we the memory is malloc'ed to fit the string. -+ * If a field is already pointing to a string (not NULL) the memory of the -+ * old string is free'd and new memory is malloc'ed and filled with the -+ * new string is copied into the the memory and with the char pointer -+ * pointing to the new string. -+ * -+ * from - pointer to the new string we want to copy -+ * to - the pointer to the current string (or pointing to NULL) -+ * If not NULL the memory it points to is free'd. - * -- * from - pointer to the new string we want to copy -- * to - the pointer to the current string (or pointing to NULL) -- * If not NULL the memory it points to is free'd. -- * function returns pointer to the new string which is in malloc'ed memory -+ * Returns pointer to the new string which is in malloc'ed memory - * FIXME The strings that are malloc'ed with this function should be freed - * when the motion program is terminated normally instead of relying on the - * OS to clean up. - */ - char *mystrcpy(char *to, const char *from) - { -- /* free the memory used by the to string, if such memory exists, -+ /* -+ * Free the memory used by the to string, if such memory exists, - * and return a pointer to a freshly malloc()'d string with the - * same value as from. - */ - -- if (to != NULL) -+ if (to != NULL) - free(to); - - return mystrdup(from); - } - - --/* mystrdup return a pointer to a freshly malloc()'d string with the same -- * value as the string that the input parameter 'from' points to, -- * or NULL if the from string is 0 characters. -- * The function truncates the string to the length given by the environment -- * variable PATH_MAX to ensure that config options can always contain -- * a really long path but no more than that. -+/** -+ * mystrdup -+ * Truncates the string to the length given by the environment -+ * variable PATH_MAX to ensure that config options can always contain -+ * a really long path but no more than that. -+ * -+ * Returns a pointer to a freshly malloc()'d string with the same -+ * value as the string that the input parameter 'from' points to, -+ * or NULL if the from string is 0 characters. - */ - char *mystrdup(const char *from) - { - char *tmp; -- int stringlength; -+ size_t stringlength; - - if (from == NULL || !strlen(from)) { - tmp = NULL; -@@ -1893,33 +2173,46 @@ char *mystrdup(const char *from) - tmp = (char *)mymalloc(stringlength + 1); - strncpy(tmp, from, stringlength); - -- /* We must ensure the string always has a NULL terminator. -+ /* -+ * We must ensure the string always has a NULL terminator. - * This necessary because strncpy will not append a NULL terminator -- * if the original string is greater than stringlength. -+ * if the original string is greater than string length. - */ - tmp += stringlength; - *tmp = '\0'; - tmp -= stringlength; - } -+ - return tmp; - } - -+/** -+ * config_type -+ * Returns a pointer to string containing value the type of config parameter passed. -+ * -+ * Returns const char *. -+ */ - const char *config_type(config_param *configparam) - { - if (configparam->copy == copy_string) - return "string"; - if (configparam->copy == copy_int) - return "int"; -- if (configparam->copy == copy_short) -- return "short"; - if (configparam->copy == copy_bool) - return "bool"; - - return "unknown"; - } - -+ -+/** -+ * print_bool -+ * Returns a pointer to string containing boolean value 'on' / 'off' or NULL. -+ * -+ * Returns const char *. -+ */ - static const char *print_bool(struct context **cnt, char **str ATTRIBUTE_UNUSED, -- int parm, unsigned short int threadnr) -+ int parm, unsigned int threadnr) - { - int val = config_params[parm].conf_value; - -@@ -1933,22 +2226,27 @@ static const char *print_bool(struct con - return "off"; - } - --/* print_string returns a pointer to a string containing the value of the config option -- * If the option is not defined NULL is returned. -- * If the thread number is not 0 the string is compared with the value of the same -- * option in thread 0. If the value is the same, NULL is returned which means that -- * the option is not written to the thread config file. -+/** -+ * print_string -+ * Returns a pointer to a string containing the value of the config option, -+ * If the thread number is not 0 the string is compared with the value of the same -+ * option in thread 0. -+ * -+ * Returns If the option is not defined NULL is returned. -+ * If the value is the same, NULL is returned which means that -+ * the option is not written to the thread config file. - */ - static const char *print_string(struct context **cnt, -- char **str ATTRIBUTE_UNUSED, int parm, -- unsigned short int threadnr) -+ char **str ATTRIBUTE_UNUSED, int parm, -+ unsigned int threadnr) - { - int val = config_params[parm].conf_value; - const char **cptr0, **cptr1; -- -- /* strcmp does not like NULL so we have to check for this also */ -+ -+ /* strcmp does not like NULL so we have to check for this also. */ - cptr0 = (const char **)((char *)cnt[0] + val); - cptr1 = (const char **)((char *)cnt[threadnr] + val); -+ - if ((threadnr) && (*cptr0 != NULL) && (*cptr1 != NULL) && (!strcmp(*cptr0, *cptr1))) - return NULL; - -@@ -1956,7 +2254,7 @@ static const char *print_string(struct c - } - - static const char *print_int(struct context **cnt, char **str ATTRIBUTE_UNUSED, -- int parm, unsigned short int threadnr) -+ int parm, unsigned int threadnr) - { - static char retval[20]; - int val = config_params[parm].conf_value; -@@ -1971,106 +2269,107 @@ static const char *print_int(struct cont - } - - --static const char *print_short(struct context **cnt, char **str ATTRIBUTE_UNUSED, -- int parm, unsigned short int threadnr) --{ -- static char retval[20]; -- int val = config_params[parm].conf_value; -- -- if (threadnr && -- *(short int*)((char *)cnt[threadnr] + val) == *(short int*)((char *)cnt[0] + val)) -- return NULL; -- -- sprintf(retval, "%d", *(short int*)((char *)cnt[threadnr] + val)); -- -- return retval; --} -- - static const char *print_thread(struct context **cnt, char **str, -- int parm ATTRIBUTE_UNUSED, unsigned short int threadnr) -+ int parm ATTRIBUTE_UNUSED, unsigned int threadnr) - { - char *retval; -- unsigned short int i = 0; -+ unsigned int i = 0; - - if (!str || threadnr) - return NULL; - - retval = mymalloc(1); - retval[0] = 0; -+ - while (cnt[++i]) { -- retval = myrealloc(retval, strlen(retval) + strlen(cnt[i]->conf_filename) + 10, "print_thread"); -+ retval = myrealloc(retval, strlen(retval) + strlen(cnt[i]->conf_filename) + 10, -+ "print_thread"); - sprintf(retval + strlen(retval), "thread %s\n", cnt[i]->conf_filename); - } -+ - *str = retval; - - return NULL; - } - --/* config_thread() is called during initial config file loading each time Motion -- * finds a thread option in motion.conf -- * The size of the context array is increased and the main context's values are -- * copied to the new thread. -+/** -+ * config_thread -+ * Is called during initial config file loading each time Motion -+ * finds a thread option in motion.conf -+ * The size of the context array is increased and the main context's values are -+ * copied to the new thread. - * -- * cnt - pointer to the array of pointers pointing to the context structures -- * str - pointer to a string which is the filename of the thread config file -- * val - is not used. It is defined to be function header compatible with -- * copy_int, copy_bool and copy_string. -+ * cnt - pointer to the array of pointers pointing to the context structures -+ * str - pointer to a string which is the filename of the thread config file -+ * val - is not used. It is defined to be function header compatible with -+ * copy_int, copy_bool and copy_string. - */ - static struct context **config_thread(struct context **cnt, const char *str, -- int val ATTRIBUTE_UNUSED) -+ int val ATTRIBUTE_UNUSED) - { - int i; - FILE *fp; -- -+ - if (cnt[0]->threadnr) - return cnt; - - fp = fopen(str, "r"); - - if (!fp) { -- motion_log(LOG_ERR, 1, "Thread config file %s not found",str); -+ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Thread config file %s not found", -+ str); - return cnt; - } - - /* Find the current number of threads defined. */ - i = -1; -+ - while (cnt[++i]); - -- /* Make space for the threads + the terminating NULL pointer -+ /* -+ * Make space for the threads + the terminating NULL pointer - * in the array of pointers to context structures -- * First thread is 0 so the number of threads is i+1 -- * plus an extra for the NULL pointer. This gives i+2 -+ * First thread is 0 so the number of threads is i + 1 -+ * plus an extra for the NULL pointer. This gives i + 2 - */ - cnt = myrealloc(cnt, sizeof(struct context *) * (i + 2), "config_thread"); - - /* Now malloc space for an additional context structure for thread nr. i */ - cnt[i] = mymalloc(sizeof(struct context)); -- -+ - /* And make this an exact clone of the context structure for thread 0 */ - memcpy(cnt[i], cnt[0], sizeof(struct context)); - -- /* All the integers are copies of the actual value. -+ /* -+ * All the integers are copies of the actual value. - * The strings are all pointers to strings so we need to create - * unique malloc'ed space for all the strings that are not NULL and - * change the string pointers to point to the new strings. - * malloc_strings takes care of this. - */ - malloc_strings(cnt[i]); -- -- /* Mark the end if the array of pointers to context structures */ -+ -+ /* Mark the end if the array of pointers to context structures. */ - cnt[i + 1] = NULL; - -- /* process the thread's config file and notify user on console */ -+ /* Process the thread's config file and notify user on console. */ - strcpy(cnt[i]->conf_filename, str); -- motion_log(LOG_INFO, 0, "Processing config file %s", str); -- conf_process(cnt+i, fp); -- -- /* Finally we close the thread config file */ -- fclose(fp); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing config file %s", -+ str); -+ conf_process(cnt + i, fp); -+ -+ /* Finally we close the thread config file. */ -+ myfclose(fp); - - return cnt; - } - -+/** -+ * usage -+ * Prints usage and options allowed from Command-line. -+ * -+ * Returns nothing. -+ */ - static void usage() - { - printf("motion Version "VERSION", Copyright 2000-2005 Jeroen Vreeken/Folkert van Heusden/Kenneth Lavrsen\n"); -@@ -2080,8 +2379,11 @@ static void usage() - printf("-n\t\t\tRun in non-daemon mode.\n"); - 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\tDebug mode.\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 (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"); ---- motion-3.2.12.orig/conf.h -+++ motion-3.2.12/conf.h -@@ -1,24 +1,27 @@ - /* -- ** -- ** conf.h - function prototypes for the config handling routines -- ** -- ** Originally written for the dproxy package by Matthew Pratt. -- ** -- ** Copyright 2000 Jeroen Vreeken (pe1rxq@chello.nl) -- ** -- ** This software is licensed under the terms of the GNU General -- ** Public License (GPL). Please see the file COPYING for details. -- ** -- ** --*/ -+ * -+ * conf.h - function prototypes for the config handling routines -+ * -+ * Originally written for the dproxy package by Matthew Pratt. -+ * -+ * Copyright 2000 Jeroen Vreeken (pe1rxq@chello.nl) -+ * -+ * This software is licensed under the terms of the GNU General -+ * Public License (GPL). Please see the file COPYING for details. -+ * -+ * -+ */ - - #ifndef _INCLUDE_CONF_H - #define _INCLUDE_CONF_H - - /* -- more parameters may be added later. -+ * More parameters may be added later. - */ - struct config { -+ unsigned int log_level; -+ char *log_type_str; -+ char *log_file; - int setup_mode; - int width; - int height; -@@ -26,18 +29,21 @@ struct config { - int rotate_deg; - int max_changes; - int threshold_tune; -- const char *output_normal; -+ const char *output_pictures; - int motion_img; -- int output_all; -- int gap; -- int maxmpegtime; -+ int emulate_motion; -+ int event_gap; -+ int max_movie_time; - int snapshot_interval; -- const char *locate; -+ const char *locate_motion_mode; -+ const char *locate_motion_style; - int input; - int norm; - int frame_limit; - int quiet; -- int ppm; -+ int useextpipe; /* ext_pipe on or off */ -+ const char *extpipe; /* full Command-line for pipe -- must accept YUV420P images */ -+ const char *picture_type; - int noise; - int noise_tune; - int minimum_frame_time; -@@ -52,22 +58,28 @@ struct config { - int pre_capture; - int post_capture; - int switchfilter; -- int ffmpeg_cap_new; -- int ffmpeg_cap_motion; -+ int ffmpeg_output; -+ int ffmpeg_output_debug; - int ffmpeg_bps; - int ffmpeg_vbr; - int ffmpeg_deinterlace; - const char *ffmpeg_video_codec; -- int webcam_port; -- int webcam_quality; -- int webcam_motion; -- int webcam_maxrate; -- int webcam_localhost; -- int webcam_limit; -- int control_port; -- int control_localhost; -- int control_html_output; -- const char *control_authentication; -+#ifdef HAVE_SDL -+ int sdl_threadnr; -+#endif -+ int ipv6_enabled; -+ int stream_port; -+ int stream_quality; -+ int stream_motion; -+ int stream_maxrate; -+ int stream_localhost; -+ int stream_limit; -+ int stream_auth_method; -+ const char *stream_authentication; -+ int webcontrol_port; -+ int webcontrol_localhost; -+ int webcontrol_html_output; -+ const char *webcontrol_authentication; - unsigned long frequency; - int tuner_number; - int timelapse; -@@ -76,11 +88,11 @@ struct config { - const char *tuner_device; - #endif - const char *video_device; -- short unsigned int v4l2_palette; -+ int v4l2_palette; - const char *vidpipe; - const char *filepath; -- const char *jpegpath; -- const char *mpegpath; -+ const char *imagepath; -+ const char *moviepath; - const char *snappath; - const char *timepath; - char *on_event_start; -@@ -89,13 +101,16 @@ struct config { - int smart_mask_speed; - int sql_log_image; - int sql_log_snapshot; -- int sql_log_mpeg; -+ int sql_log_movie; - int sql_log_timelapse; - const char *sql_query; -- const char *mysql_db; -- const char *mysql_host; -- const char *mysql_user; -- const char *mysql_password; -+ const char *database_type; -+ const char *database_dbname; -+ const char *database_host; -+ const char *database_user; -+ const char *database_password; -+ const char *sqlite3_db; -+ int database_port; - char *on_picture_save; - char *on_area_detected; - char *on_motion_detected; -@@ -105,22 +120,19 @@ struct config { - const char *motionvidpipe; - const char *netcam_url; - const char *netcam_userpass; -- const char *netcam_http; -+ const char *netcam_keepalive; - const char *netcam_proxy; - unsigned int netcam_tolerant_check; -- const char *pgsql_db; -- const char *pgsql_host; -- const char *pgsql_user; -- const char *pgsql_password; -- int pgsql_port; -+ unsigned int rtsp_uses_tcp; - int text_changes; - const char *text_left; - const char *text_right; - const char *text_event; - int text_double; -- const char *despeckle; -+ const char *despeckle_filter; - const char *area_detect; - int minimum_motion_frames; -+ const char *exif_text; - char *pid_file; - int argc; - char **argv; -@@ -130,28 +142,27 @@ struct config { - * typedef for a param copy function. - */ - typedef struct context ** (* conf_copy_func)(struct context **, const char *, int); --typedef const char *(* conf_print_func)(struct context **, char **, int, unsigned short int); -+typedef const char *(* conf_print_func)(struct context **, char **, int, unsigned int); - - /** - * description for parameters in the config file - */ - typedef struct { -- const char * param_name; /* name for this parameter */ -- const char * param_help; /* short explanation for parameter */ -- unsigned short int main_thread; /* belong only to main thread when value>0 */ -- int conf_value; /* pointer to a field in struct context */ -- conf_copy_func copy; /* a function to set the value in 'config' */ -- conf_print_func print; /* a function to output the value to a file */ -+ const char *param_name; /* name for this parameter */ -+ const char *param_help; /* short explanation for parameter */ -+ unsigned int main_thread; /* belong only to main thread when value>0 */ -+ int conf_value; /* pointer to a field in struct context */ -+ conf_copy_func copy; /* a function to set the value in 'config' */ -+ conf_print_func print; /* a function to output the value to a file */ - } config_param; - -- - extern config_param config_params[]; - - struct context **conf_load(struct context **); - struct context **conf_cmdparse(struct context **, const char *, const char *); - const char *config_type(config_param *); - void conf_print(struct context **); --void malloc_strings (struct context *); -+void malloc_strings(struct context *); - char *mystrdup(const char *); - char *mystrcpy(char *, const char *); - struct context **copy_string(struct context **, const char *, int); -@@ -160,5 +171,4 @@ struct context **copy_string(struct cont - char *get_current_dir_name(void); - #endif - -- - #endif /* _INCLUDE_CONF_H */ ---- /dev/null -+++ motion-3.2.12/config.h -@@ -0,0 +1,145 @@ -+/* config.h. Generated from config.h.in by configure. */ -+/* config.h.in. Generated from configure.ac by autoheader. */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_FCNTL_H 1 -+ -+/* Define to 1 if you have the `get_current_dir_name' function. */ -+#define HAVE_GET_CURRENT_DIR_NAME 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_INTTYPES_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_LINUX_VIDEODEV2_H 1 -+ -+/* Define to 1 if you have the header file. */ -+/* #undef HAVE_LINUX_VIDEODEV_H */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_MEMORY_H 1 -+ -+/* Define to 1 if you have MySQL support */ -+/* #undef HAVE_MYSQL */ -+ -+/* Define to 1 if you have PostgreSQL support */ -+/* #undef HAVE_PGSQL */ -+ -+/* Define to 1 if you have SDL support */ -+/* #undef HAVE_SDL */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SIGNAL_H 1 -+ -+/* Define to 1 if you have SQLITE3 support */ -+/* #undef HAVE_SQLITE3 */ -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STDINT_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STDIO_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STDLIB_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STRINGS_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_STRING_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_IOCTL_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_MMAN_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_PARAM_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_STAT_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_SYS_TYPES_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_TIME_H 1 -+ -+/* Define to 1 if you have the header file. */ -+#define HAVE_UNISTD_H 1 -+ -+/* Define to the address where bug reports for this package should be sent. */ -+#define PACKAGE_BUGREPORT "" -+ -+/* Define to the full name of this package. */ -+#define PACKAGE_NAME "motion" -+ -+/* Define to the full name and version of this package. */ -+#define PACKAGE_STRING "motion 3.2.12-4ppa01" -+ -+/* Define to the one symbol short name of this package. */ -+#define PACKAGE_TARNAME "motion" -+ -+/* Define to the home page for this package. */ -+#define PACKAGE_URL "" -+ -+/* Define to the version of this package. */ -+#define PACKAGE_VERSION "3.2.12-4ppa01" -+ -+/* The size of `int', as computed by sizeof. */ -+#define SIZEOF_INT 4 -+ -+/* The size of `int *', as computed by sizeof. */ -+#define SIZEOF_INT_P 8 -+ -+/* The size of `long int', as computed by sizeof. */ -+#define SIZEOF_LONG_INT 8 -+ -+/* The size of `long long', as computed by sizeof. */ -+#define SIZEOF_LONG_LONG 8 -+ -+/* The size of `short', as computed by sizeof. */ -+#define SIZEOF_SHORT 2 -+ -+/* The size of `void *', as computed by sizeof. */ -+#define SIZEOF_VOID_P 8 -+ -+/* Define to 1 if you have the ANSI C header files. */ -+#define STDC_HEADERS 1 -+ -+/* Enable extensions on AIX 3, Interix. */ -+#ifndef _ALL_SOURCE -+# define _ALL_SOURCE 1 -+#endif -+/* Enable GNU extensions on systems that have them. */ -+#ifndef _GNU_SOURCE -+# define _GNU_SOURCE 1 -+#endif -+/* Enable threading extensions on Solaris. */ -+#ifndef _POSIX_PTHREAD_SEMANTICS -+# define _POSIX_PTHREAD_SEMANTICS 1 -+#endif -+/* Enable extensions on HP NonStop. */ -+#ifndef _TANDEM_SOURCE -+# define _TANDEM_SOURCE 1 -+#endif -+/* Enable general extensions on Solaris. */ -+#ifndef __EXTENSIONS__ -+# define __EXTENSIONS__ 1 -+#endif -+ -+ -+/* Define to 1 if on MINIX. */ -+/* #undef _MINIX */ -+ -+/* Define to 2 if the system does not provide POSIX.1 features except with -+ this defined. */ -+/* #undef _POSIX_1_SOURCE */ -+ -+/* Define to 1 if you need to in order for `stat' and other things to work. */ -+/* #undef _POSIX_SOURCE */ -+ -+/* Define to empty if `const' does not conform to ANSI C. */ -+/* #undef const */ ---- motion-3.2.12.orig/config.h.in -+++ motion-3.2.12/config.h.in -@@ -1,4 +1,4 @@ --/* config.h.in. Generated from configure.in by autoheader. */ -+/* config.h.in. Generated from configure.ac by autoheader. */ - - /* Define to 1 if you have the header file. */ - #undef HAVE_FCNTL_H -@@ -24,9 +24,15 @@ - /* Define to 1 if you have PostgreSQL support */ - #undef HAVE_PGSQL - -+/* Define to 1 if you have SDL support */ -+#undef HAVE_SDL -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_SIGNAL_H - -+/* Define to 1 if you have SQLITE3 support */ -+#undef HAVE_SQLITE3 -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_STDINT_H - -@@ -75,20 +81,64 @@ - /* Define to the one symbol short name of this package. */ - #undef PACKAGE_TARNAME - -+/* Define to the home page for this package. */ -+#undef PACKAGE_URL -+ - /* Define to the version of this package. */ - #undef PACKAGE_VERSION - - /* The size of `int', as computed by sizeof. */ - #undef SIZEOF_INT - -+/* The size of `int *', as computed by sizeof. */ -+#undef SIZEOF_INT_P -+ - /* The size of `long int', as computed by sizeof. */ - #undef SIZEOF_LONG_INT - --/* The size of `short int', as computed by sizeof. */ --#undef SIZEOF_SHORT_INT -+/* The size of `long long', as computed by sizeof. */ -+#undef SIZEOF_LONG_LONG -+ -+/* The size of `short', as computed by sizeof. */ -+#undef SIZEOF_SHORT -+ -+/* The size of `void *', as computed by sizeof. */ -+#undef SIZEOF_VOID_P - - /* Define to 1 if you have the ANSI C header files. */ - #undef STDC_HEADERS - -+/* Enable extensions on AIX 3, Interix. */ -+#ifndef _ALL_SOURCE -+# undef _ALL_SOURCE -+#endif -+/* Enable GNU extensions on systems that have them. */ -+#ifndef _GNU_SOURCE -+# undef _GNU_SOURCE -+#endif -+/* Enable threading extensions on Solaris. */ -+#ifndef _POSIX_PTHREAD_SEMANTICS -+# undef _POSIX_PTHREAD_SEMANTICS -+#endif -+/* Enable extensions on HP NonStop. */ -+#ifndef _TANDEM_SOURCE -+# undef _TANDEM_SOURCE -+#endif -+/* Enable general extensions on Solaris. */ -+#ifndef __EXTENSIONS__ -+# undef __EXTENSIONS__ -+#endif -+ -+ -+/* Define to 1 if on MINIX. */ -+#undef _MINIX -+ -+/* Define to 2 if the system does not provide POSIX.1 features except with -+ this defined. */ -+#undef _POSIX_1_SOURCE -+ -+/* Define to 1 if you need to in order for `stat' and other things to work. */ -+#undef _POSIX_SOURCE -+ - /* Define to empty if `const' does not conform to ANSI C. */ - #undef const ---- motion-3.2.12.orig/configure -+++ motion-3.2.12/configure -@@ -1,11 +1,9 @@ - #! /bin/sh - # Guess values for system-dependent variables and create Makefiles. --# Generated by GNU Autoconf 2.65 for motion 3.2.12. -+# Generated by GNU Autoconf 2.69 for motion 3.2.12-4ppa01. - # - # --# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, --# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, --# Inc. -+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. - # - # - # This configure script is free software; the Free Software Foundation -@@ -89,6 +87,7 @@ fi - IFS=" "" $as_nl" - - # Find who we are. Look in the path if we contain no directory separator. -+as_myself= - case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -@@ -133,6 +132,31 @@ export LANGUAGE - # CDPATH. - (unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -+# Use a proper internal environment variable to ensure we don't fall -+ # into an infinite loop, continuously re-executing ourselves. -+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then -+ _as_can_reexec=no; export _as_can_reexec; -+ # We cannot yet assume a decent shell, so we have to provide a -+# neutralization value for shells without unset; and this also -+# works around shells that cannot unset nonexistent variables. -+# Preserve -v and -x to the replacement shell. -+BASH_ENV=/dev/null -+ENV=/dev/null -+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -+case $- in # (((( -+ *v*x* | *x*v* ) as_opts=-vx ;; -+ *v* ) as_opts=-v ;; -+ *x* ) as_opts=-x ;; -+ * ) as_opts= ;; -+esac -+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -+# Admittedly, this is quite paranoid, since all the known shells bail -+# out after a failed `exec'. -+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -+as_fn_exit 255 -+ fi -+ # We don't want this to propagate to other subprocesses. -+ { _as_can_reexec=; unset _as_can_reexec;} - if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh -@@ -166,7 +190,8 @@ if ( set x; as_fn_ret_success y && test - else - exitcode=1; echo positional parameters were not saved. - fi --test x\$exitcode = x0 || exit 1" -+test x\$exitcode = x0 || exit 1 -+test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && -@@ -211,14 +236,25 @@ IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : -- # We cannot yet assume a decent shell, so we have to provide a -- # neutralization value for shells without unset; and this also -- # works around shells that cannot unset nonexistent variables. -- BASH_ENV=/dev/null -- ENV=/dev/null -- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -- export CONFIG_SHELL -- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -+ export CONFIG_SHELL -+ # We cannot yet assume a decent shell, so we have to provide a -+# neutralization value for shells without unset; and this also -+# works around shells that cannot unset nonexistent variables. -+# Preserve -v and -x to the replacement shell. -+BASH_ENV=/dev/null -+ENV=/dev/null -+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -+case $- in # (((( -+ *v*x* | *x*v* ) as_opts=-vx ;; -+ *v* ) as_opts=-v ;; -+ *x* ) as_opts=-x ;; -+ * ) as_opts= ;; -+esac -+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -+# Admittedly, this is quite paranoid, since all the known shells bail -+# out after a failed `exec'. -+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -+exit 255 - fi - - if test x$as_have_required = xno; then : -@@ -316,10 +352,18 @@ $as_echo X"$as_dir" | - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" -- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" -+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - - } # as_fn_mkdir_p -+ -+# as_fn_executable_p FILE -+# ----------------------- -+# Test if FILE is an executable regular file. -+as_fn_executable_p () -+{ -+ test -f "$1" && test -x "$1" -+} # as_fn_executable_p - # as_fn_append VAR VALUE - # ---------------------- - # Append the text in VALUE to the end of the definition contained in VAR. Take -@@ -356,19 +400,19 @@ else - fi # as_fn_arith - - --# as_fn_error ERROR [LINENO LOG_FD] --# --------------------------------- -+# as_fn_error STATUS ERROR [LINENO LOG_FD] -+# ---------------------------------------- - # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are - # provided, also output the error to LOG_FD, referencing LINENO. Then exit the --# script with status $?, using 1 if that was 0. -+# script with STATUS, using 1 if that was 0. - as_fn_error () - { -- as_status=$?; test $as_status -eq 0 && as_status=1 -- if test "$3"; then -- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 -+ as_status=$1; test $as_status -eq 0 && as_status=1 -+ if test "$4"; then -+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi -- $as_echo "$as_me: error: $1" >&2 -+ $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status - } # as_fn_error - -@@ -441,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - -+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have -+ # already done that, so ensure we don't try to do so again and fall -+ # in an infinite loop. This has already happened in practice. -+ _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). -@@ -475,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. -- # In both cases, we have to default to `cp -p'. -+ # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || -- as_ln_s='cp -p' -+ as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else -- as_ln_s='cp -p' -+ as_ln_s='cp -pR' - fi - else -- as_ln_s='cp -p' -+ as_ln_s='cp -pR' - fi - rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file - rmdir conf$$.dir 2>/dev/null -@@ -496,28 +544,8 @@ else - as_mkdir_p=false - fi - --if test -x / >/dev/null 2>&1; then -- as_test_x='test -x' --else -- if ls -dL / >/dev/null 2>&1; then -- as_ls_L_option=L -- else -- as_ls_L_option= -- fi -- as_test_x=' -- eval sh -c '\'' -- if test -d "$1"; then -- test -d "$1/."; -- else -- case $1 in #( -- -*)set "./$1";; -- esac; -- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( -- ???[sx]*):;;*)false;;esac;fi -- '\'' sh -- ' --fi --as_executable_p=$as_test_x -+as_test_x='test -x' -+as_executable_p=as_fn_executable_p - - # Sed expression to map a string onto a valid CPP name. - as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" -@@ -530,7 +558,7 @@ test -n "$DJDIR" || exec 7<&0 &1 - - # Name of the host. --# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, - # so uname gets run too. - ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -@@ -549,12 +577,11 @@ MAKEFLAGS= - # Identity of this package. - PACKAGE_NAME='motion' - PACKAGE_TARNAME='motion' --PACKAGE_VERSION='3.2.12' --PACKAGE_STRING='motion 3.2.12' -+PACKAGE_VERSION='3.2.12-4ppa01' -+PACKAGE_STRING='motion 3.2.12-4ppa01' - PACKAGE_BUGREPORT='' - PACKAGE_URL='' - --ac_unique_file="motion.c" - # Factoring default headers for most tests. - ac_includes_default="\ - #include -@@ -591,14 +618,17 @@ ac_includes_default="\ - # include - #endif" - -+ac_unique_file="motion.c" - ac_subst_vars='LTLIBOBJS - LIBOBJS - BIN_PATH --DOC_DIR -+RTPS_OBJ -+FFMPEG_OBJ -+SDL_OBJ -+VIDEO - EGREP - GREP - CPP --FFMPEG_OBJ - OBJEXT - EXEEXT - ac_ct_CC -@@ -606,7 +636,6 @@ CPPFLAGS - LDFLAGS - CFLAGS - CC --VIDEO - target_alias - host_alias - build_alias -@@ -652,8 +681,13 @@ with_linuxthreads - with_pwcbsd - with_bktr - with_v4l -+with_sdl -+with_jpeg_turbo - with_jpeg_mmx - with_ffmpeg -+with_ffmpeg_headers -+with_ffmpeg_libs -+with_sqlite3 - with_mysql - with_mysql_lib - with_mysql_include -@@ -734,8 +768,9 @@ do - fi - - case $ac_option in -- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; -- *) ac_optarg=yes ;; -+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; -+ *=) ac_optarg= ;; -+ *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. -@@ -780,7 +815,7 @@ do - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && -- as_fn_error "invalid feature name: $ac_useropt" -+ as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in -@@ -806,7 +841,7 @@ do - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && -- as_fn_error "invalid feature name: $ac_useropt" -+ as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in -@@ -1010,7 +1045,7 @@ do - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && -- as_fn_error "invalid package name: $ac_useropt" -+ as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in -@@ -1026,7 +1061,7 @@ do - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && -- as_fn_error "invalid package name: $ac_useropt" -+ as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in -@@ -1056,8 +1091,8 @@ do - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - -- -*) as_fn_error "unrecognized option: \`$ac_option' --Try \`$0 --help' for more information." -+ -*) as_fn_error $? "unrecognized option: \`$ac_option' -+Try \`$0 --help' for more information" - ;; - - *=*) -@@ -1065,7 +1100,7 @@ Try \`$0 --help' for more information." - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) -- as_fn_error "invalid variable name: \`$ac_envvar'" ;; -+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; -@@ -1075,7 +1110,7 @@ Try \`$0 --help' for more information." - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 -- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} -+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -@@ -1083,13 +1118,13 @@ done - - if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` -- as_fn_error "missing argument to $ac_option" -+ as_fn_error $? "missing argument to $ac_option" - fi - - if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; -- fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; -+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac - fi -@@ -1112,7 +1147,7 @@ do - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac -- as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" -+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" - done - - # There might be people who depend on the old broken behavior: `$host' -@@ -1126,8 +1161,6 @@ target=$target_alias - if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe -- $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. -- If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -@@ -1142,9 +1175,9 @@ test "$silent" = yes && exec 6>/dev/null - ac_pwd=`pwd` && test -n "$ac_pwd" && - ac_ls_di=`ls -di .` && - ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || -- as_fn_error "working directory cannot be determined" -+ as_fn_error $? "working directory cannot be determined" - test "X$ac_ls_di" = "X$ac_pwd_ls_di" || -- as_fn_error "pwd does not report name of working directory" -+ as_fn_error $? "pwd does not report name of working directory" - - - # Find the source files, if location was not specified. -@@ -1183,11 +1216,11 @@ else - fi - if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." -- as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" -+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" - fi - ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" - ac_abs_confdir=`( -- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" -+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` - # When building in place, set srcdir=. - if test "$ac_abs_confdir" = "$ac_pwd"; then -@@ -1213,7 +1246,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 3.2.12 to adapt to many kinds of systems. -+\`configure' configures motion 3.2.12-4ppa01 to adapt to many kinds of systems. - - Usage: $0 [OPTION]... [VAR=VALUE]... - -@@ -1227,7 +1260,7 @@ Configuration: - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit -- -q, --quiet, --silent do not print \`checking...' messages -+ -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files -@@ -1274,7 +1307,7 @@ fi - - if test -n "$ac_init_help"; then - case $ac_init_help in -- short | recursive ) echo "Configuration of motion 3.2.12:";; -+ short | recursive ) echo "Configuration of motion 3.2.12-4ppa01:";; - esac - cat <<\_ACEOF - -@@ -1294,6 +1327,11 @@ Optional Packages: - --without-v4l Exclude using v4l (video4linux) subsystem. - Makes Motion so it only supports network cameras. - -+ --without-sdl Compile without sdl support to get stream in SDL window. -+ -+ --with-jpeg-turbo=DIR Specify the prefix for the install path for -+ jpeg-turbo for optimized jpeg handling (optional). -+ - --with-jpeg-mmx=DIR Specify the prefix for the install path for - jpeg-mmx for optimized jpeg handling (optional). - If this is not specified motion will try to find -@@ -1305,6 +1343,12 @@ Optional Packages: - If this is not specified motion will try to find - the libraries in /usr and /usr/local. - -+ --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. -+ -+ --with-ffmpeg-libs=libs Specify the extra libs for ffmpeg -+ -+ --without-sqlite3 Disable sqlite3 support in motion. -+ - --without-mysql Disable mysql support in motion. - - --with-mysql-lib=DIR Normally, configure will scan all possible default -@@ -1413,10 +1457,10 @@ fi - test -n "$ac_init_help" && exit $ac_status - if $ac_init_version; then - cat <<\_ACEOF --motion configure 3.2.12 --generated by GNU Autoconf 2.65 -+motion configure 3.2.12-4ppa01 -+generated by GNU Autoconf 2.69 - --Copyright (C) 2009 Free Software Foundation, Inc. -+Copyright (C) 2012 Free Software Foundation, Inc. - This configure script is free software; the Free Software Foundation - gives unlimited permission to copy, distribute and modify it. - _ACEOF -@@ -1460,57 +1504,11 @@ sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 - fi -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - - } # ac_fn_c_try_compile - --# ac_fn_c_try_link LINENO --# ----------------------- --# Try to link conftest.$ac_ext, and return whether this succeeded. --ac_fn_c_try_link () --{ -- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -- rm -f conftest.$ac_objext conftest$ac_exeext -- if { { ac_try="$ac_link" --case "(($ac_try" in -- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -- *) ac_try_echo=$ac_try;; --esac --eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" --$as_echo "$ac_try_echo"; } >&5 -- (eval "$ac_link") 2>conftest.err -- ac_status=$? -- if test -s conftest.err; then -- grep -v '^ *+' conftest.err >conftest.er1 -- cat conftest.er1 >&5 -- mv -f conftest.er1 conftest.err -- fi -- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -- test $ac_status = 0; } && { -- test -z "$ac_c_werror_flag" || -- test ! -s conftest.err -- } && test -s conftest$ac_exeext && { -- test "$cross_compiling" = yes || -- $as_test_x conftest$ac_exeext -- }; then : -- ac_retval=0 --else -- $as_echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -- -- ac_retval=1 --fi -- # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information -- # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would -- # interfere with the next link command; also delete a directory that is -- # left behind by Apple's compiler. We do this before executing the actions. -- rm -rf conftest.dSYM conftest_ipa8_conftest.oo -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -- as_fn_set_status $ac_retval -- --} # ac_fn_c_try_link -- - # ac_fn_c_try_cpp LINENO - # ---------------------- - # Try to preprocess conftest.$ac_ext, and return whether this succeeded. -@@ -1532,7 +1530,7 @@ $as_echo "$ac_try_echo"; } >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -- test $ac_status = 0; } >/dev/null && { -+ test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : -@@ -1543,53 +1541,11 @@ sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 - fi -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - - } # ac_fn_c_try_cpp - --# ac_fn_c_try_run LINENO --# ---------------------- --# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes --# that executables *can* be run. --ac_fn_c_try_run () --{ -- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -- if { { ac_try="$ac_link" --case "(($ac_try" in -- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -- *) ac_try_echo=$ac_try;; --esac --eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" --$as_echo "$ac_try_echo"; } >&5 -- (eval "$ac_link") 2>&5 -- ac_status=$? -- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -- test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' -- { { case "(($ac_try" in -- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -- *) ac_try_echo=$ac_try;; --esac --eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" --$as_echo "$ac_try_echo"; } >&5 -- (eval "$ac_try") 2>&5 -- ac_status=$? -- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -- test $ac_status = 0; }; }; then : -- ac_retval=0 --else -- $as_echo "$as_me: program exited with status $ac_status" >&5 -- $as_echo "$as_me: failed program was:" >&5 --sed 's/^/| /' conftest.$ac_ext >&5 -- -- ac_retval=$ac_status --fi -- rm -rf conftest.dSYM conftest_ipa8_conftest.oo -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -- as_fn_set_status $ac_retval -- --} # ac_fn_c_try_run -- - # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES - # ------------------------------------------------------- - # Tests whether HEADER exists, giving a warning if it cannot be compiled using -@@ -1598,10 +1554,10 @@ fi - ac_fn_c_check_header_mongrel () - { - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -- if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : -+ if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 - $as_echo_n "checking for $2... " >&6; } --if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : -+if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 - fi - eval ac_res=\$$3 -@@ -1637,7 +1593,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : - else - ac_header_preproc=no - fi --rm -f conftest.err conftest.$ac_ext -+rm -f conftest.err conftest.i conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 - $as_echo "$ac_header_preproc" >&6; } - -@@ -1664,7 +1620,7 @@ $as_echo "$as_me: WARNING: $2: proceedin - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 - $as_echo_n "checking for $2... " >&6; } --if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : -+if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 - else - eval "$3=\$ac_header_compiler" -@@ -1673,10 +1629,52 @@ eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 - $as_echo "$ac_res" >&6; } - fi -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - - } # ac_fn_c_check_header_mongrel - -+# ac_fn_c_try_run LINENO -+# ---------------------- -+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -+# that executables *can* be run. -+ac_fn_c_try_run () -+{ -+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -+ if { { ac_try="$ac_link" -+case "(($ac_try" in -+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -+ *) ac_try_echo=$ac_try;; -+esac -+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -+$as_echo "$ac_try_echo"; } >&5 -+ (eval "$ac_link") 2>&5 -+ ac_status=$? -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' -+ { { case "(($ac_try" in -+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -+ *) ac_try_echo=$ac_try;; -+esac -+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -+$as_echo "$ac_try_echo"; } >&5 -+ (eval "$ac_try") 2>&5 -+ ac_status=$? -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; }; }; then : -+ ac_retval=0 -+else -+ $as_echo "$as_me: program exited with status $ac_status" >&5 -+ $as_echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_retval=$ac_status -+fi -+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -+ as_fn_set_status $ac_retval -+ -+} # ac_fn_c_try_run -+ - # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES - # ------------------------------------------------------- - # Tests whether HEADER exists and can be compiled using the include files in -@@ -1686,7 +1684,7 @@ ac_fn_c_check_header_compile () - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 - $as_echo_n "checking for $2... " >&6; } --if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : -+if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -@@ -1704,10 +1702,56 @@ fi - eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 - $as_echo "$ac_res" >&6; } -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - - } # ac_fn_c_check_header_compile - -+# ac_fn_c_try_link LINENO -+# ----------------------- -+# Try to link conftest.$ac_ext, and return whether this succeeded. -+ac_fn_c_try_link () -+{ -+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -+ rm -f conftest.$ac_objext conftest$ac_exeext -+ if { { ac_try="$ac_link" -+case "(($ac_try" in -+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -+ *) ac_try_echo=$ac_try;; -+esac -+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -+$as_echo "$ac_try_echo"; } >&5 -+ (eval "$ac_link") 2>conftest.err -+ ac_status=$? -+ if test -s conftest.err; then -+ grep -v '^ *+' conftest.err >conftest.er1 -+ cat conftest.er1 >&5 -+ mv -f conftest.er1 conftest.err -+ fi -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; } && { -+ test -z "$ac_c_werror_flag" || -+ test ! -s conftest.err -+ } && test -s conftest$ac_exeext && { -+ test "$cross_compiling" = yes || -+ test -x conftest$ac_exeext -+ }; then : -+ ac_retval=0 -+else -+ $as_echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_retval=1 -+fi -+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information -+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would -+ # interfere with the next link command; also delete a directory that is -+ # left behind by Apple's compiler. We do this before executing the actions. -+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -+ as_fn_set_status $ac_retval -+ -+} # ac_fn_c_try_link -+ - # ac_fn_c_check_func LINENO FUNC VAR - # ---------------------------------- - # Tests whether FUNC exists, setting the cache variable VAR accordingly -@@ -1716,7 +1760,7 @@ ac_fn_c_check_func () - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 - $as_echo_n "checking for $2... " >&6; } --if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : -+if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -@@ -1771,7 +1815,7 @@ fi - eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 - $as_echo "$ac_res" >&6; } -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - - } # ac_fn_c_check_func - -@@ -1784,7 +1828,7 @@ ac_fn_c_check_type () - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 - $as_echo_n "checking for $2... " >&6; } --if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : -+if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 - else - eval "$3=no" -@@ -1825,7 +1869,7 @@ fi - eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 - $as_echo "$ac_res" >&6; } -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - - } # ac_fn_c_check_type - -@@ -1846,7 +1890,8 @@ int - main () - { - static int test_array [1 - 2 * !(($2) >= 0)]; --test_array [0] = 0 -+test_array [0] = 0; -+return test_array [0]; - - ; - return 0; -@@ -1862,7 +1907,8 @@ int - main () - { - static int test_array [1 - 2 * !(($2) <= $ac_mid)]; --test_array [0] = 0 -+test_array [0] = 0; -+return test_array [0]; - - ; - return 0; -@@ -1888,7 +1934,8 @@ int - main () - { - static int test_array [1 - 2 * !(($2) < 0)]; --test_array [0] = 0 -+test_array [0] = 0; -+return test_array [0]; - - ; - return 0; -@@ -1904,7 +1951,8 @@ int - main () - { - static int test_array [1 - 2 * !(($2) >= $ac_mid)]; --test_array [0] = 0 -+test_array [0] = 0; -+return test_array [0]; - - ; - return 0; -@@ -1938,7 +1986,8 @@ int - main () - { - static int test_array [1 - 2 * !(($2) <= $ac_mid)]; --test_array [0] = 0 -+test_array [0] = 0; -+return test_array [0]; - - ; - return 0; -@@ -2002,7 +2051,7 @@ rm -f core *.core core.conftest.* gmon.o - rm -f conftest.val - - fi -- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} -+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - - } # ac_fn_c_compute_int -@@ -2010,8 +2059,8 @@ 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 3.2.12, which was --generated by GNU Autoconf 2.65. Invocation command line was -+It was created by motion $as_me 3.2.12-4ppa01, which was -+generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -@@ -2121,11 +2170,9 @@ trap 'exit_status=$? - { - echo - -- cat <<\_ASBOX --## ---------------- ## -+ $as_echo "## ---------------- ## - ## Cache variables. ## --## ---------------- ## --_ASBOX -+## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, - ( -@@ -2159,11 +2206,9 @@ $as_echo "$as_me: WARNING: cache variabl - ) - echo - -- cat <<\_ASBOX --## ----------------- ## -+ $as_echo "## ----------------- ## - ## Output variables. ## --## ----------------- ## --_ASBOX -+## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do -@@ -2176,11 +2221,9 @@ _ASBOX - echo - - if test -n "$ac_subst_files"; then -- cat <<\_ASBOX --## ------------------- ## -+ $as_echo "## ------------------- ## - ## File substitutions. ## --## ------------------- ## --_ASBOX -+## ------------------- ##" - echo - for ac_var in $ac_subst_files - do -@@ -2194,11 +2237,9 @@ _ASBOX - fi - - if test -s confdefs.h; then -- cat <<\_ASBOX --## ----------- ## -+ $as_echo "## ----------- ## - ## confdefs.h. ## --## ----------- ## --_ASBOX -+## ----------- ##" - echo - cat confdefs.h - echo -@@ -2253,7 +2294,12 @@ _ACEOF - ac_site_file1=NONE - ac_site_file2=NONE - if test -n "$CONFIG_SITE"; then -- ac_site_file1=$CONFIG_SITE -+ # We do not want a PATH search for config.site. -+ case $CONFIG_SITE in #(( -+ -*) ac_site_file1=./$CONFIG_SITE;; -+ */*) ac_site_file1=$CONFIG_SITE;; -+ *) ac_site_file1=./$CONFIG_SITE;; -+ esac - elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -@@ -2268,7 +2314,11 @@ do - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 - $as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 -- . "$ac_site_file" -+ . "$ac_site_file" \ -+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -+as_fn_error $? "failed to load site script $ac_site_file -+See \`config.log' for more details" "$LINENO" 5; } - fi - done - -@@ -2344,7 +2394,7 @@ if $ac_cache_corrupted; then - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 - $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} -- as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 - fi - ## -------------------- ## - ## Main body of script. ## -@@ -2357,134 +2407,47 @@ ac_link='$CC -o conftest$ac_exeext $CFLA - ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -- --ac_config_headers="$ac_config_headers config.h" -- -- --THREAD_CFLAGS="" --THREAD_CHECK="/usr/include/pthread.h" -- --Darwin="" --FreeBSD="" -- --LINUXTHREADS="no" -- --# Check whether --with-linuxthreads was given. --if test "${with_linuxthreads+set}" = set; then : -- withval=$with_linuxthreads; LINUXTHREADS="$withval" -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -+set dummy ${ac_tool_prefix}gcc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="${ac_tool_prefix}gcc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS - - fi -- -- --PWCBSD="no" -- --# Check whether --with-pwcbsd was given. --if test "${with_pwcbsd+set}" = set; then : -- withval=$with_pwcbsd; PWCBSD="$withval" -- --fi -- -- -- --{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 --$as_echo_n "checking for Darwin... " >&6; } --Darwin=`uname -a | grep "Darwin"` -- --if test "${Darwin}" = ""; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 --$as_echo "no" >&6; } -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 --$as_echo_n "checking for *BSD... " >&6; } -- -- FreeBSD=`uname -a | grep "BSD"` -- if test "${FreeBSD}" = ""; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 --$as_echo "no" >&6; } -- VIDEO="video.o video2.o video_common.o" -- else -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 --$as_echo "yes" >&6; } -- if test "${LINUXTHREADS}" = "no"; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linuxthreads" >&5 --$as_echo_n "checking Linuxthreads... " >&6; } -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 --$as_echo "skipping" >&6; } -- else -- THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" -- THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" -- fi -- -- if test "${PWCBSD}" != "no"; then -- VIDEO="video.o video2.o video_common.o" -- TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" -- else -- VIDEO="video_freebsd.o" -- TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" -- fi -- -- TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" -- TEMP_LIBS="-L/usr/local/lib" -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: Build with PWCBSD support $PWCBSD" >&5 --$as_echo "Build with PWCBSD support $PWCBSD" >&6; } -- -- fi --else -- TEMP_CFLAGS="${CFLAGS} -I/sw/include" -- TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" -- TEMP_LIBS="-L/sw/lib" -- VIDEO="video_freebsd.o" -- FINK_LIB="-L/sw/lib" -- Darwin="yes" -- V4L="no" -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Darwin" >&5 --$as_echo "$Darwin" >&6; } --fi -- -- -- -- --# Checks for programs. --ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu --if test -n "$ac_tool_prefix"; then -- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. --set dummy ${ac_tool_prefix}gcc; ac_word=$2 --{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 --$as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_prog_CC+set}" = set; then : -- $as_echo_n "(cached) " >&6 --else -- if test -n "$CC"; then -- ac_cv_prog_CC="$CC" # Let the user override the test. --else --as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -- ac_cv_prog_CC="${ac_tool_prefix}gcc" -- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -- break 2 -- fi --done -- done --IFS=$as_save_IFS -- --fi --fi --CC=$ac_cv_prog_CC --if test -n "$CC"; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 --$as_echo "$CC" >&6; } --else -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 --$as_echo "no" >&6; } --fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi - - - fi -@@ -2494,7 +2457,7 @@ if test -z "$ac_cv_prog_CC"; then - set dummy gcc; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : -+if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 - else - if test -n "$ac_ct_CC"; then -@@ -2506,7 +2469,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 -@@ -2547,7 +2510,7 @@ if test -z "$CC"; then - set dummy ${ac_tool_prefix}cc; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_prog_CC+set}" = set; then : -+if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 - else - if test -n "$CC"; then -@@ -2559,7 +2522,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 -@@ -2587,7 +2550,7 @@ if test -z "$CC"; then - set dummy cc; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_prog_CC+set}" = set; then : -+if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 - else - if test -n "$CC"; then -@@ -2600,7 +2563,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue -@@ -2646,7 +2609,7 @@ if test -z "$CC"; then - set dummy $ac_tool_prefix$ac_prog; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_prog_CC+set}" = set; then : -+if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 - else - if test -n "$CC"; then -@@ -2658,7 +2621,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 -@@ -2690,7 +2653,7 @@ do - set dummy $ac_prog; ac_word=$2 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 - $as_echo_n "checking for $ac_word... " >&6; } --if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : -+if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 - else - if test -n "$ac_ct_CC"; then -@@ -2702,7 +2665,7 @@ do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do -- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 -@@ -2744,8 +2707,8 @@ fi - - test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --as_fn_error "no acceptable C compiler found in \$PATH --See \`config.log' for more details." "$LINENO" 5; } -+as_fn_error $? "no acceptable C compiler found in \$PATH -+See \`config.log' for more details" "$LINENO" 5; } - - # Provide some information about the compiler. - $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -@@ -2859,9 +2822,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 - - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "C compiler cannot create executables --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "C compiler cannot create executables -+See \`config.log' for more details" "$LINENO" 5; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 - $as_echo "yes" >&6; } -@@ -2903,8 +2865,8 @@ done - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --as_fn_error "cannot compute suffix of executables: cannot compile and link --See \`config.log' for more details." "$LINENO" 5; } -+as_fn_error $? "cannot compute suffix of executables: cannot compile and link -+See \`config.log' for more details" "$LINENO" 5; } - fi - rm -f conftest conftest$ac_cv_exeext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -@@ -2961,9 +2923,9 @@ $as_echo "$ac_try_echo"; } >&5 - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --as_fn_error "cannot run C compiled programs. -+as_fn_error $? "cannot run C compiled programs. - If you meant to cross compile, use \`--host'. --See \`config.log' for more details." "$LINENO" 5; } -+See \`config.log' for more details" "$LINENO" 5; } - fi - fi - fi -@@ -2974,7 +2936,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_ex - ac_clean_files=$ac_clean_files_save - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 - $as_echo_n "checking for suffix of object files... " >&6; } --if test "${ac_cv_objext+set}" = set; then : -+if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -@@ -3014,8 +2976,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 - - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --as_fn_error "cannot compute suffix of object files: cannot compile --See \`config.log' for more details." "$LINENO" 5; } -+as_fn_error $? "cannot compute suffix of object files: cannot compile -+See \`config.log' for more details" "$LINENO" 5; } - fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext - fi -@@ -3025,7 +2987,7 @@ OBJEXT=$ac_cv_objext - ac_objext=$OBJEXT - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 - $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } --if test "${ac_cv_c_compiler_gnu+set}" = set; then : -+if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -@@ -3062,7 +3024,7 @@ ac_test_CFLAGS=${CFLAGS+set} - ac_save_CFLAGS=$CFLAGS - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 - $as_echo_n "checking whether $CC accepts -g... " >&6; } --if test "${ac_cv_prog_cc_g+set}" = set; then : -+if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 - else - ac_save_c_werror_flag=$ac_c_werror_flag -@@ -3140,7 +3102,7 @@ else - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 - $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } --if test "${ac_cv_prog_cc_c89+set}" = set; then : -+if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 - else - ac_cv_prog_cc_c89=no -@@ -3149,8 +3111,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ - /* end confdefs.h. */ - #include - #include --#include --#include -+struct stat; - /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ - struct buf { int x; }; - FILE * (*rcsopen) (struct buf *, struct stat *, int); -@@ -3236,64 +3197,1688 @@ ac_link='$CC -o conftest$ac_exeext $CFLA - ac_compiler_gnu=$ac_cv_c_compiler_gnu - - --TEMP_LIBS="-lm ${TEMP_LIBS}" --TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" --TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" -- -- --if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then -- -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking bktr headers in /usr/include/dev/bktr" >&5 --$as_echo_n "checking bktr headers in /usr/include/dev/bktr... " >&6; } -- -- if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 --$as_echo "yes" >&6; } -- else -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 --$as_echo "no" >&6; } -- TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" -- fi --# --# Check to Exclude BKTR --# --BKTR="yes" -- --# Check whether --with-bktr was given. --if test "${with_bktr+set}" = set; then : -- withval=$with_bktr; BKTR="$withval" -- -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -+$as_echo_n "checking how to run the C preprocessor... " >&6; } -+# On Suns, sometimes $CPP names a directory. -+if test -n "$CPP" && test -d "$CPP"; then -+ CPP= - fi -- -- -- -- if test "${BKTR}" = "no"; then -- TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -- fi -- -+if test -z "$CPP"; then -+ if ${ac_cv_prog_CPP+:} false; then : -+ $as_echo_n "(cached) " >&6 - else -+ # Double quotes because CPP needs to be expanded -+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" -+ do -+ ac_preproc_ok=false -+for ac_c_preproc_warn_flag in '' yes -+do -+ # Use a header file that comes with gcc, so configuring glibc -+ # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. -+ # On the NeXT, cc -E runs the code through the compiler's parser, -+ # not just through cpp. "Syntax error" is here to catch this case. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ Syntax error -+_ACEOF -+if ac_fn_c_try_cpp "$LINENO"; then : - --# --# Check to Exclude V4L --# --V4L="yes" -+else -+ # Broken: fails on valid input. -+continue -+fi -+rm -f conftest.err conftest.i conftest.$ac_ext - --# Check whether --with-v4l was given. --if test "${with_v4l+set}" = set; then : -- withval=$with_v4l; V4L="$withval" -+ # OK, works on sane cases. Now check whether nonexistent headers -+ # can be detected and how. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+_ACEOF -+if ac_fn_c_try_cpp "$LINENO"; then : -+ # Broken: success on invalid input. -+continue -+else -+ # Passes both tests. -+ac_preproc_ok=: -+break -+fi -+rm -f conftest.err conftest.i conftest.$ac_ext - -+done -+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -+rm -f conftest.i conftest.err conftest.$ac_ext -+if $ac_preproc_ok; then : -+ break - fi - -+ done -+ ac_cv_prog_CPP=$CPP - - fi -+ CPP=$ac_cv_prog_CPP -+else -+ ac_cv_prog_CPP=$CPP -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -+$as_echo "$CPP" >&6; } -+ac_preproc_ok=false -+for ac_c_preproc_warn_flag in '' yes -+do -+ # Use a header file that comes with gcc, so configuring glibc -+ # with a fresh cross-compiler works. -+ # Prefer to if __STDC__ is defined, since -+ # exists even on freestanding compilers. -+ # On the NeXT, cc -E runs the code through the compiler's parser, -+ # not just through cpp. "Syntax error" is here to catch this case. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#ifdef __STDC__ -+# include -+#else -+# include -+#endif -+ Syntax error -+_ACEOF -+if ac_fn_c_try_cpp "$LINENO"; then : - -+else -+ # Broken: fails on valid input. -+continue -+fi -+rm -f conftest.err conftest.i conftest.$ac_ext - --if test "${V4L}" = "no"; then -- TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -+ # OK, works on sane cases. Now check whether nonexistent headers -+ # can be detected and how. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+_ACEOF -+if ac_fn_c_try_cpp "$LINENO"; then : -+ # Broken: success on invalid input. -+continue -+else -+ # Passes both tests. -+ac_preproc_ok=: -+break - fi -+rm -f conftest.err conftest.i conftest.$ac_ext - -+done -+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -+rm -f conftest.i conftest.err conftest.$ac_ext -+if $ac_preproc_ok; then : - --if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then -+else -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -+See \`config.log' for more details" "$LINENO" 5; } -+fi -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -+$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -+if ${ac_cv_path_GREP+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -z "$GREP"; then -+ ac_path_GREP_found=false -+ # Loop through the user's path and test for each of PROGNAME-LIST -+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_prog in grep ggrep; do -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" -+ as_fn_executable_p "$ac_path_GREP" || continue -+# Check for GNU ac_path_GREP and select it if it is found. -+ # Check for GNU $ac_path_GREP -+case `"$ac_path_GREP" --version 2>&1` in -+*GNU*) -+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -+*) -+ ac_count=0 -+ $as_echo_n 0123456789 >"conftest.in" -+ while : -+ do -+ cat "conftest.in" "conftest.in" >"conftest.tmp" -+ mv "conftest.tmp" "conftest.in" -+ cp "conftest.in" "conftest.nl" -+ $as_echo 'GREP' >> "conftest.nl" -+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break -+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break -+ as_fn_arith $ac_count + 1 && ac_count=$as_val -+ if test $ac_count -gt ${ac_path_GREP_max-0}; then -+ # Best one so far, save it but keep looking for a better one -+ ac_cv_path_GREP="$ac_path_GREP" -+ ac_path_GREP_max=$ac_count -+ fi -+ # 10*(2^10) chars as input seems more than enough -+ test $ac_count -gt 10 && break -+ done -+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -+esac -+ -+ $ac_path_GREP_found && break 3 -+ done -+ done -+ done -+IFS=$as_save_IFS -+ if test -z "$ac_cv_path_GREP"; then -+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 -+ fi -+else -+ ac_cv_path_GREP=$GREP -+fi -+ -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -+$as_echo "$ac_cv_path_GREP" >&6; } -+ GREP="$ac_cv_path_GREP" -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -+$as_echo_n "checking for egrep... " >&6; } -+if ${ac_cv_path_EGREP+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 -+ then ac_cv_path_EGREP="$GREP -E" -+ else -+ if test -z "$EGREP"; then -+ ac_path_EGREP_found=false -+ # Loop through the user's path and test for each of PROGNAME-LIST -+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_prog in egrep; do -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" -+ as_fn_executable_p "$ac_path_EGREP" || continue -+# Check for GNU ac_path_EGREP and select it if it is found. -+ # Check for GNU $ac_path_EGREP -+case `"$ac_path_EGREP" --version 2>&1` in -+*GNU*) -+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -+*) -+ ac_count=0 -+ $as_echo_n 0123456789 >"conftest.in" -+ while : -+ do -+ cat "conftest.in" "conftest.in" >"conftest.tmp" -+ mv "conftest.tmp" "conftest.in" -+ cp "conftest.in" "conftest.nl" -+ $as_echo 'EGREP' >> "conftest.nl" -+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break -+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break -+ as_fn_arith $ac_count + 1 && ac_count=$as_val -+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then -+ # Best one so far, save it but keep looking for a better one -+ ac_cv_path_EGREP="$ac_path_EGREP" -+ ac_path_EGREP_max=$ac_count -+ fi -+ # 10*(2^10) chars as input seems more than enough -+ test $ac_count -gt 10 && break -+ done -+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -+esac -+ -+ $ac_path_EGREP_found && break 3 -+ done -+ done -+ done -+IFS=$as_save_IFS -+ if test -z "$ac_cv_path_EGREP"; then -+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 -+ fi -+else -+ ac_cv_path_EGREP=$EGREP -+fi -+ -+ fi -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -+$as_echo "$ac_cv_path_EGREP" >&6; } -+ EGREP="$ac_cv_path_EGREP" -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -+$as_echo_n "checking for ANSI C header files... " >&6; } -+if ${ac_cv_header_stdc+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+#include -+#include -+#include -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_header_stdc=yes -+else -+ ac_cv_header_stdc=no -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ -+if test $ac_cv_header_stdc = yes; then -+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+ -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "memchr" >/dev/null 2>&1; then : -+ -+else -+ ac_cv_header_stdc=no -+fi -+rm -f conftest* -+ -+fi -+ -+if test $ac_cv_header_stdc = yes; then -+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+ -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "free" >/dev/null 2>&1; then : -+ -+else -+ ac_cv_header_stdc=no -+fi -+rm -f conftest* -+ -+fi -+ -+if test $ac_cv_header_stdc = yes; then -+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -+ if test "$cross_compiling" = yes; then : -+ : -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+#include -+#if ((' ' & 0x0FF) == 0x020) -+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -+#else -+# define ISLOWER(c) \ -+ (('a' <= (c) && (c) <= 'i') \ -+ || ('j' <= (c) && (c) <= 'r') \ -+ || ('s' <= (c) && (c) <= 'z')) -+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -+#endif -+ -+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -+int -+main () -+{ -+ int i; -+ for (i = 0; i < 256; i++) -+ if (XOR (islower (i), ISLOWER (i)) -+ || toupper (i) != TOUPPER (i)) -+ return 2; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_run "$LINENO"; then : -+ -+else -+ ac_cv_header_stdc=no -+fi -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ -+ conftest.$ac_objext conftest.beam conftest.$ac_ext -+fi -+ -+fi -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -+$as_echo "$ac_cv_header_stdc" >&6; } -+if test $ac_cv_header_stdc = yes; then -+ -+$as_echo "#define STDC_HEADERS 1" >>confdefs.h -+ -+fi -+ -+# On IRIX 5.3, sys/types and inttypes.h are conflicting. -+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ -+ inttypes.h stdint.h unistd.h -+do : -+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -+" -+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : -+ cat >>confdefs.h <<_ACEOF -+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -+_ACEOF -+ -+fi -+ -+done -+ -+ -+ -+ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -+if test "x$ac_cv_header_minix_config_h" = xyes; then : -+ MINIX=yes -+else -+ MINIX= -+fi -+ -+ -+ if test "$MINIX" = yes; then -+ -+$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h -+ -+ -+$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h -+ -+ -+$as_echo "#define _MINIX 1" >>confdefs.h -+ -+ fi -+ -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 -+$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -+if ${ac_cv_safe_to_define___extensions__+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+# define __EXTENSIONS__ 1 -+ $ac_includes_default -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_safe_to_define___extensions__=yes -+else -+ ac_cv_safe_to_define___extensions__=no -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 -+$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } -+ test $ac_cv_safe_to_define___extensions__ = yes && -+ $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h -+ -+ $as_echo "#define _ALL_SOURCE 1" >>confdefs.h -+ -+ $as_echo "#define _GNU_SOURCE 1" >>confdefs.h -+ -+ $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h -+ -+ $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h -+ -+ -+ -+ -+ac_config_headers="$ac_config_headers config.h" -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -+set dummy ${ac_tool_prefix}gcc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="${ac_tool_prefix}gcc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+fi -+if test -z "$ac_cv_prog_CC"; then -+ ac_ct_CC=$CC -+ # Extract the first word of "gcc", so it can be a program name with args. -+set dummy gcc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_ac_ct_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$ac_ct_CC"; then -+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_CC="gcc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+ac_ct_CC=$ac_cv_prog_ac_ct_CC -+if test -n "$ac_ct_CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -+$as_echo "$ac_ct_CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ if test "x$ac_ct_CC" = x; then -+ CC="" -+ else -+ case $cross_compiling:$ac_tool_warned in -+yes:) -+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -+ac_tool_warned=yes ;; -+esac -+ CC=$ac_ct_CC -+ fi -+else -+ CC="$ac_cv_prog_CC" -+fi -+ -+if test -z "$CC"; then -+ if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -+set dummy ${ac_tool_prefix}cc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="${ac_tool_prefix}cc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+ fi -+fi -+if test -z "$CC"; then -+ # Extract the first word of "cc", so it can be a program name with args. -+set dummy cc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+ ac_prog_rejected=no -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then -+ ac_prog_rejected=yes -+ continue -+ fi -+ ac_cv_prog_CC="cc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+if test $ac_prog_rejected = yes; then -+ # We found a bogon in the path, so make sure we never use it. -+ set dummy $ac_cv_prog_CC -+ shift -+ if test $# != 0; then -+ # We chose a different compiler from the bogus one. -+ # However, it has the same basename, so the bogon will be chosen -+ # first if we set CC to just the basename; use the full file name. -+ shift -+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" -+ fi -+fi -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+fi -+if test -z "$CC"; then -+ if test -n "$ac_tool_prefix"; then -+ for ac_prog in cl.exe -+ do -+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -+set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+ test -n "$CC" && break -+ done -+fi -+if test -z "$CC"; then -+ ac_ct_CC=$CC -+ for ac_prog in cl.exe -+do -+ # Extract the first word of "$ac_prog", so it can be a program name with args. -+set dummy $ac_prog; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_ac_ct_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$ac_ct_CC"; then -+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_CC="$ac_prog" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+ac_ct_CC=$ac_cv_prog_ac_ct_CC -+if test -n "$ac_ct_CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -+$as_echo "$ac_ct_CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+ test -n "$ac_ct_CC" && break -+done -+ -+ if test "x$ac_ct_CC" = x; then -+ CC="" -+ else -+ case $cross_compiling:$ac_tool_warned in -+yes:) -+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -+ac_tool_warned=yes ;; -+esac -+ CC=$ac_ct_CC -+ fi -+fi -+ -+fi -+ -+ -+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -+as_fn_error $? "no acceptable C compiler found in \$PATH -+See \`config.log' for more details" "$LINENO" 5; } -+ -+# Provide some information about the compiler. -+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -+set X $ac_compile -+ac_compiler=$2 -+for ac_option in --version -v -V -qversion; do -+ { { ac_try="$ac_compiler $ac_option >&5" -+case "(($ac_try" in -+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -+ *) ac_try_echo=$ac_try;; -+esac -+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -+$as_echo "$ac_try_echo"; } >&5 -+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err -+ ac_status=$? -+ if test -s conftest.err; then -+ sed '10a\ -+... rest of stderr output deleted ... -+ 10q' conftest.err >conftest.er1 -+ cat conftest.er1 >&5 -+ fi -+ rm -f conftest.er1 conftest.err -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; } -+done -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -+if ${ac_cv_c_compiler_gnu+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+#ifndef __GNUC__ -+ choke me -+#endif -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_compiler_gnu=yes -+else -+ ac_compiler_gnu=no -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ac_cv_c_compiler_gnu=$ac_compiler_gnu -+ -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -+$as_echo "$ac_cv_c_compiler_gnu" >&6; } -+if test $ac_compiler_gnu = yes; then -+ GCC=yes -+else -+ GCC= -+fi -+ac_test_CFLAGS=${CFLAGS+set} -+ac_save_CFLAGS=$CFLAGS -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -+$as_echo_n "checking whether $CC accepts -g... " >&6; } -+if ${ac_cv_prog_cc_g+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_save_c_werror_flag=$ac_c_werror_flag -+ ac_c_werror_flag=yes -+ ac_cv_prog_cc_g=no -+ CFLAGS="-g" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_prog_cc_g=yes -+else -+ CFLAGS="" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ -+else -+ ac_c_werror_flag=$ac_save_c_werror_flag -+ CFLAGS="-g" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_prog_cc_g=yes -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ ac_c_werror_flag=$ac_save_c_werror_flag -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -+$as_echo "$ac_cv_prog_cc_g" >&6; } -+if test "$ac_test_CFLAGS" = set; then -+ CFLAGS=$ac_save_CFLAGS -+elif test $ac_cv_prog_cc_g = yes; then -+ if test "$GCC" = yes; then -+ CFLAGS="-g -O2" -+ else -+ CFLAGS="-g" -+ fi -+else -+ if test "$GCC" = yes; then -+ CFLAGS="-O2" -+ else -+ CFLAGS= -+ fi -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -+if ${ac_cv_prog_cc_c89+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_cv_prog_cc_c89=no -+ac_save_CC=$CC -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+#include -+struct stat; -+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -+struct buf { int x; }; -+FILE * (*rcsopen) (struct buf *, struct stat *, int); -+static char *e (p, i) -+ char **p; -+ int i; -+{ -+ return p[i]; -+} -+static char *f (char * (*g) (char **, int), char **p, ...) -+{ -+ char *s; -+ va_list v; -+ va_start (v,p); -+ s = g (p, va_arg (v,int)); -+ va_end (v); -+ return s; -+} -+ -+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has -+ function prototypes and stuff, but not '\xHH' hex character constants. -+ These don't provoke an error unfortunately, instead are silently treated -+ as 'x'. The following induces an error, until -std is added to get -+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an -+ array size at least. It's necessary to write '\x00'==0 to get something -+ that's true only with -std. */ -+int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -+ -+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters -+ inside strings and character constants. */ -+#define FOO(x) 'x' -+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; -+ -+int test (int i, double x); -+struct s1 {int (*f) (int a);}; -+struct s2 {int (*f) (double a);}; -+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -+int argc; -+char **argv; -+int -+main () -+{ -+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; -+ ; -+ return 0; -+} -+_ACEOF -+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -+do -+ CC="$ac_save_CC $ac_arg" -+ if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_prog_cc_c89=$ac_arg -+fi -+rm -f core conftest.err conftest.$ac_objext -+ test "x$ac_cv_prog_cc_c89" != "xno" && break -+done -+rm -f conftest.$ac_ext -+CC=$ac_save_CC -+ -+fi -+# AC_CACHE_VAL -+case "x$ac_cv_prog_cc_c89" in -+ x) -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -+$as_echo "none needed" >&6; } ;; -+ xno) -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -+$as_echo "unsupported" >&6; } ;; -+ *) -+ CC="$CC $ac_cv_prog_cc_c89" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -+esac -+if test "x$ac_cv_prog_cc_c89" != xno; then : -+ -+fi -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+ -+ -+THREAD_CFLAGS="" -+THREAD_CHECK="/usr/include/pthread.h" -+ -+Darwin="" -+FreeBSD="" -+ -+LINUXTHREADS="no" -+ -+# Check whether --with-linuxthreads was given. -+if test "${with_linuxthreads+set}" = set; then : -+ withval=$with_linuxthreads; LINUXTHREADS="$withval" -+ -+fi -+ -+ -+PWCBSD="no" -+ -+# Check whether --with-pwcbsd was given. -+if test "${with_pwcbsd+set}" = set; then : -+ withval=$with_pwcbsd; PWCBSD="$withval" -+ -+fi -+ -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 -+$as_echo_n "checking for Darwin... " >&6; } -+Darwin=`uname -a | grep "Darwin"` -+ -+if test "${Darwin}" = ""; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 -+$as_echo_n "checking for *BSD... " >&6; } -+ -+ FreeBSD=`uname -a | grep "BSD"` -+ if test "${FreeBSD}" = ""; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ VIDEO="video.o video2.o video_common.o" -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ if test "${LINUXTHREADS}" = "no"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linuxthreads" >&5 -+$as_echo_n "checking Linuxthreads... " >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -+$as_echo "skipping" >&6; } -+ else -+ THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" -+ THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" -+ fi -+ -+ if test "${PWCBSD}" != "no"; then -+ VIDEO="video.o video2.o video_common.o" -+ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" -+ else -+ VIDEO="video_freebsd.o" -+ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" -+ fi -+ -+ TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" -+ TEMP_LIBS="-L/usr/local/lib" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: Build with PWCBSD support $PWCBSD" >&5 -+$as_echo "Build with PWCBSD support $PWCBSD" >&6; } -+ -+ fi -+else -+ TEMP_CFLAGS="${CFLAGS} -I/sw/include" -+ TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" -+ TEMP_LIBS="-L/sw/lib" -+ VIDEO="video_freebsd.o" -+ FINK_LIB="-L/sw/lib" -+ Darwin="yes" -+ V4L="no" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Darwin" >&5 -+$as_echo "$Darwin" >&6; } -+fi -+ -+ -+ -+ -+# Checks for programs. -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -+set dummy ${ac_tool_prefix}gcc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="${ac_tool_prefix}gcc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+fi -+if test -z "$ac_cv_prog_CC"; then -+ ac_ct_CC=$CC -+ # Extract the first word of "gcc", so it can be a program name with args. -+set dummy gcc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_ac_ct_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$ac_ct_CC"; then -+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_CC="gcc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+ac_ct_CC=$ac_cv_prog_ac_ct_CC -+if test -n "$ac_ct_CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -+$as_echo "$ac_ct_CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ if test "x$ac_ct_CC" = x; then -+ CC="" -+ else -+ case $cross_compiling:$ac_tool_warned in -+yes:) -+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -+ac_tool_warned=yes ;; -+esac -+ CC=$ac_ct_CC -+ fi -+else -+ CC="$ac_cv_prog_CC" -+fi -+ -+if test -z "$CC"; then -+ if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -+set dummy ${ac_tool_prefix}cc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="${ac_tool_prefix}cc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+ fi -+fi -+if test -z "$CC"; then -+ # Extract the first word of "cc", so it can be a program name with args. -+set dummy cc; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+ ac_prog_rejected=no -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then -+ ac_prog_rejected=yes -+ continue -+ fi -+ ac_cv_prog_CC="cc" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+if test $ac_prog_rejected = yes; then -+ # We found a bogon in the path, so make sure we never use it. -+ set dummy $ac_cv_prog_CC -+ shift -+ if test $# != 0; then -+ # We chose a different compiler from the bogus one. -+ # However, it has the same basename, so the bogon will be chosen -+ # first if we set CC to just the basename; use the full file name. -+ shift -+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" -+ fi -+fi -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+fi -+if test -z "$CC"; then -+ if test -n "$ac_tool_prefix"; then -+ for ac_prog in cl.exe -+ do -+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -+set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$CC"; then -+ ac_cv_prog_CC="$CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+CC=$ac_cv_prog_CC -+if test -n "$CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -+$as_echo "$CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+ test -n "$CC" && break -+ done -+fi -+if test -z "$CC"; then -+ ac_ct_CC=$CC -+ for ac_prog in cl.exe -+do -+ # Extract the first word of "$ac_prog", so it can be a program name with args. -+set dummy $ac_prog; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if ${ac_cv_prog_ac_ct_CC+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test -n "$ac_ct_CC"; then -+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -+else -+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then -+ ac_cv_prog_ac_ct_CC="$ac_prog" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+fi -+fi -+ac_ct_CC=$ac_cv_prog_ac_ct_CC -+if test -n "$ac_ct_CC"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -+$as_echo "$ac_ct_CC" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+ test -n "$ac_ct_CC" && break -+done -+ -+ if test "x$ac_ct_CC" = x; then -+ CC="" -+ else -+ case $cross_compiling:$ac_tool_warned in -+yes:) -+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -+ac_tool_warned=yes ;; -+esac -+ CC=$ac_ct_CC -+ fi -+fi -+ -+fi -+ -+ -+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -+as_fn_error $? "no acceptable C compiler found in \$PATH -+See \`config.log' for more details" "$LINENO" 5; } -+ -+# Provide some information about the compiler. -+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -+set X $ac_compile -+ac_compiler=$2 -+for ac_option in --version -v -V -qversion; do -+ { { ac_try="$ac_compiler $ac_option >&5" -+case "(($ac_try" in -+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -+ *) ac_try_echo=$ac_try;; -+esac -+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -+$as_echo "$ac_try_echo"; } >&5 -+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err -+ ac_status=$? -+ if test -s conftest.err; then -+ sed '10a\ -+... rest of stderr output deleted ... -+ 10q' conftest.err >conftest.er1 -+ cat conftest.er1 >&5 -+ fi -+ rm -f conftest.er1 conftest.err -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; } -+done -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -+if ${ac_cv_c_compiler_gnu+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+#ifndef __GNUC__ -+ choke me -+#endif -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_compiler_gnu=yes -+else -+ ac_compiler_gnu=no -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ac_cv_c_compiler_gnu=$ac_compiler_gnu -+ -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -+$as_echo "$ac_cv_c_compiler_gnu" >&6; } -+if test $ac_compiler_gnu = yes; then -+ GCC=yes -+else -+ GCC= -+fi -+ac_test_CFLAGS=${CFLAGS+set} -+ac_save_CFLAGS=$CFLAGS -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -+$as_echo_n "checking whether $CC accepts -g... " >&6; } -+if ${ac_cv_prog_cc_g+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_save_c_werror_flag=$ac_c_werror_flag -+ ac_c_werror_flag=yes -+ ac_cv_prog_cc_g=no -+ CFLAGS="-g" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_prog_cc_g=yes -+else -+ CFLAGS="" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ -+else -+ ac_c_werror_flag=$ac_save_c_werror_flag -+ CFLAGS="-g" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_prog_cc_g=yes -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ ac_c_werror_flag=$ac_save_c_werror_flag -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -+$as_echo "$ac_cv_prog_cc_g" >&6; } -+if test "$ac_test_CFLAGS" = set; then -+ CFLAGS=$ac_save_CFLAGS -+elif test $ac_cv_prog_cc_g = yes; then -+ if test "$GCC" = yes; then -+ CFLAGS="-g -O2" -+ else -+ CFLAGS="-g" -+ fi -+else -+ if test "$GCC" = yes; then -+ CFLAGS="-O2" -+ else -+ CFLAGS= -+ fi -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -+if ${ac_cv_prog_cc_c89+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_cv_prog_cc_c89=no -+ac_save_CC=$CC -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include -+#include -+struct stat; -+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -+struct buf { int x; }; -+FILE * (*rcsopen) (struct buf *, struct stat *, int); -+static char *e (p, i) -+ char **p; -+ int i; -+{ -+ return p[i]; -+} -+static char *f (char * (*g) (char **, int), char **p, ...) -+{ -+ char *s; -+ va_list v; -+ va_start (v,p); -+ s = g (p, va_arg (v,int)); -+ va_end (v); -+ return s; -+} -+ -+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has -+ function prototypes and stuff, but not '\xHH' hex character constants. -+ These don't provoke an error unfortunately, instead are silently treated -+ as 'x'. The following induces an error, until -std is added to get -+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an -+ array size at least. It's necessary to write '\x00'==0 to get something -+ that's true only with -std. */ -+int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -+ -+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters -+ inside strings and character constants. */ -+#define FOO(x) 'x' -+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; -+ -+int test (int i, double x); -+struct s1 {int (*f) (int a);}; -+struct s2 {int (*f) (double a);}; -+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -+int argc; -+char **argv; -+int -+main () -+{ -+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; -+ ; -+ return 0; -+} -+_ACEOF -+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -+do -+ CC="$ac_save_CC $ac_arg" -+ if ac_fn_c_try_compile "$LINENO"; then : -+ ac_cv_prog_cc_c89=$ac_arg -+fi -+rm -f core conftest.err conftest.$ac_objext -+ test "x$ac_cv_prog_cc_c89" != "xno" && break -+done -+rm -f conftest.$ac_ext -+CC=$ac_save_CC -+ -+fi -+# AC_CACHE_VAL -+case "x$ac_cv_prog_cc_c89" in -+ x) -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -+$as_echo "none needed" >&6; } ;; -+ xno) -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -+$as_echo "unsupported" >&6; } ;; -+ *) -+ CC="$CC $ac_cv_prog_cc_c89" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -+esac -+if test "x$ac_cv_prog_cc_c89" != xno; then : -+ -+fi -+ -+ac_ext=c -+ac_cpp='$CPP $CPPFLAGS' -+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -+ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ -+ -+TEMP_LIBS="-lm ${TEMP_LIBS}" -+TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" -+TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" -+ -+if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking bktr headers in /usr/include/dev/bktr" >&5 -+$as_echo_n "checking bktr headers in /usr/include/dev/bktr... " >&6; } -+ -+ if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" -+ fi -+# -+# Check to Exclude BKTR -+# -+BKTR="yes" -+ -+# Check whether --with-bktr was given. -+if test "${with_bktr+set}" = set; then : -+ withval=$with_bktr; BKTR="$withval" -+ -+fi -+ -+ -+ if test "${BKTR}" = "no"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -+ fi -+ -+else -+ -+# -+# Check to Exclude V4L -+# -+V4L="yes" -+ -+# Check whether --with-v4l was given. -+if test "${with_v4l+set}" = set; then : -+ withval=$with_v4l; V4L="$withval" -+ -+fi -+ -+ -+fi -+ -+ -+if test "${V4L}" = "no"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -+fi -+ -+ -+if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linuxthreads" >&5 - $as_echo_n "checking for linuxthreads... " >&6; } -@@ -3302,10 +4887,10 @@ $as_echo_n "checking for linuxthreads... - # Check for thread header - # - if test -f "${THREAD_CHECK}"; then -- HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" -- THREADS="yes" -+ HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" -+ THREADS="yes" - else -- THREADS="no" -+ THREADS="no" - fi - - # -@@ -3315,7 +4900,7 @@ $as_echo_n "checking for linuxthreads... - THREADS="yes" - LIB_THREAD="-llthread -llgcc_r" - else -- THREADS="no" -+ THREADS="no" - fi - - # Checks for Library linuxthreads for FreeBSD -@@ -3328,26 +4913,25 @@ $as_echo_n "checking for linuxthreads... - - if test "${THREADS}" = "yes"; then - TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" -- TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" -- THREAD_CFLAGS="-D_THREAD_SAFE" -- PTHREAD_SUPPORT="yes" -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 -+ TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" -+ THREAD_CFLAGS="-D_THREAD_SAFE" -+ PTHREAD_SUPPORT="yes" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 - $as_echo "$THREADS" >&6; } -- else -- PTHREAD_SUPPORT="no" -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 -+ else -+ PTHREAD_SUPPORT="no" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 - $as_echo "$THREADS" >&6; } -- echo -- echo "You do not have linuxthread installed" -- echo -- fi -+ echo -+ echo "You do not have linuxthread installed" -+ echo -+ fi - - elif test -f "${THREAD_CHECK}"; then - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking threads" >&5 - $as_echo_n "checking threads... " >&6; } -- - cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - #include -@@ -3388,6 +4972,142 @@ else - fi - - -+# -+# Check for sdl library -+# -+SDL_SUPPORT="no" -+ -+# Check whether --with-sdl was given. -+if test "${with_sdl+set}" = set; then : -+ withval=$with_sdl; -+fi -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl" >&5 -+$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; } -+else -+ if test "${FreeBSD}" != ""; then -+ CONFIG_SDL='sdl11-config' -+ else -+ CONFIG_SDL='sdl-config' -+ fi -+ if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ if test "$withval" = "yes"; then -+ echo "" -+ echo "****************************************************" -+ echo "* sdl-config could not be found. Please install it *" -+ echo "* and remove the --with-sdl configure argument. *" -+ echo "* libSDL can be found at http://www.libsdl.org *" -+ echo "****************************************************" -+ echo "" -+ fi -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ SDL_SUPPORT="yes" -+ TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" -+ TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" -+ -+$as_echo "#define HAVE_SDL 1" >>confdefs.h -+ -+ SDL_OBJ="sdl.o" -+ -+ fi -+fi -+ -+# -+# Check for the libjpeg-turbo library -+# -+JPEG_TURBO="no" -+JPEG_TURBO_OK="not_found" -+ -+ -+# Check whether --with-jpeg-turbo was given. -+if test "${with_jpeg_turbo+set}" = set; then : -+ withval=$with_jpeg_turbo; JPEG_TURBO="$withval" -+ -+fi -+ -+ -+if test "${JPEG_TURBO}" = "no"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo" >&5 -+$as_echo_n "checking for libjpeg-turbo... " >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -+$as_echo "skipping" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo in -> ${JPEG_TURBO} <-" >&5 -+$as_echo_n "checking for libjpeg-turbo in -> ${JPEG_TURBO} <-... " >&6; } -+ if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -+$as_echo "found" >&6; } -+ JPEG_TURBO_OK="found" -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -+$as_echo "not found" >&6; } -+ fi -+fi -+ -+ -+if test "${JPEG_TURBO_OK}" = "found"; then -+ saved_CFLAGS="$CFLAGS" -+ saved_LIBS="$LIBS" -+ saved_LDFLAGS="$LDFLAGS" -+ LDFLAGS="-L${JPEG_TURBO}/lib" -+ CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" -+ LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 -+$as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } -+if ${ac_cv_lib_jpeg_jpeg_start_compress+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-ljpeg $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char jpeg_start_compress (); -+int -+main () -+{ -+return jpeg_start_compress (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_jpeg_jpeg_start_compress=yes -+else -+ ac_cv_lib_jpeg_jpeg_start_compress=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 -+$as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } -+if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = xyes; then : -+ TEMP_LIBS="$LIBS" -+ TEMP_CFLAGS="${CFLAGS}" -+ TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" -+ JPEG_SUPPORT="yes" -+fi -+ -+ LIBS="$saved_LIBS" -+ CFLAGS="$saved_CFLAGS" -+ LDFLAGS="$saved_LDFLAGS" -+ JPEG_SUPPORT_TURBO="yes" -+fi -+ - - # - # Check for the special mmx accelerated jpeg library -@@ -3406,7 +5126,7 @@ fi - # --without-jpeg-mmx or with-jpeg-mmx=no - # - --if test "${JPEG_MMX}" = "no"; then -+if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx" >&5 - $as_echo_n "checking for libjpeg-mmx... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -@@ -3450,7 +5170,7 @@ if test "${JPEG_MMX_OK}" = "found"; then - LIBS="$LIBS -L${JPEG_MMX}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg-mmx" >&5 - $as_echo_n "checking for jpeg_start_compress in -ljpeg-mmx... " >&6; } --if test "${ac_cv_lib_jpeg_mmx_jpeg_start_compress+set}" = set; then : -+if ${ac_cv_lib_jpeg_mmx_jpeg_start_compress+:} false; then : - $as_echo_n "(cached) " >&6 - else - ac_check_lib_save_LIBS=$LIBS -@@ -3484,7 +5204,7 @@ LIBS=$ac_check_lib_save_LIBS - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&5 - $as_echo "$ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&6; } --if test "x$ac_cv_lib_jpeg_mmx_jpeg_start_compress" = x""yes; then : -+if test "x$ac_cv_lib_jpeg_mmx_jpeg_start_compress" = xyes; then : - TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" - TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" - JPEG_SUPPORT="yes" -@@ -3500,15 +5220,11 @@ fi - # - if test x$JPEG_SUPPORT != xyes ; then - # Checks for libraries -- LDFLAGS="$TEMP_LDFLAGS" -- -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg" >&5 --$as_echo_n "checking for libjpeg... " >&6; } -- echo -+ LDFLAGS=$TEMP_LDFLAGS - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_set_defaults in -ljpeg" >&5 - $as_echo_n "checking for jpeg_set_defaults in -ljpeg... " >&6; } --if test "${ac_cv_lib_jpeg_jpeg_set_defaults+set}" = set; then : -+if ${ac_cv_lib_jpeg_jpeg_set_defaults+:} false; then : - $as_echo_n "(cached) " >&6 - else - ac_check_lib_save_LIBS=$LIBS -@@ -3542,7 +5258,7 @@ LIBS=$ac_check_lib_save_LIBS - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_set_defaults" >&5 - $as_echo "$ac_cv_lib_jpeg_jpeg_set_defaults" >&6; } --if test "x$ac_cv_lib_jpeg_jpeg_set_defaults" = x""yes; then : -+if test "x$ac_cv_lib_jpeg_jpeg_set_defaults" = xyes; then : - - TEMP_LIBS="$TEMP_LIBS -ljpeg" - JPEG_SUPPORT="yes" -@@ -3562,6 +5278,7 @@ fi - # - # Check for libavcodec and libavformat from ffmpeg - # -+ - FFMPEG_DIR="yes" - FFMPEG_OK="no_found" - FFMPEG_OBJ="" -@@ -3572,6 +5289,31 @@ if test "${with_ffmpeg+set}" = set; then - - fi - -+ -+# -+# ffmpeg headers custom location -+# -+FFMPEG_HEADERS_DIR="yes" -+ -+# Check whether --with-ffmpeg_headers was given. -+if test "${with_ffmpeg_headers+set}" = set; then : -+ withval=$with_ffmpeg_headers; FFMPEG_HEADERS_DIR="$withval" -+ -+fi -+ -+ -+# -+# ffmpeg custom extra libraries -+# -+FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " -+ -+# Check whether --with-ffmpeg-libs was given. -+if test "${with_ffmpeg_libs+set}" = set; then : -+ withval=$with_ffmpeg_libs; FFMPEG_EXTRALIBS="$withval" -+ -+fi -+ -+ - # - # --without-ffmpeg or with-ffmpeg=no - # -@@ -3585,8 +5327,8 @@ $as_echo "skipping" >&6; } - # - else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting" >&5 --$as_echo_n "checking for ffmpeg autodetecting... " >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting libraries" >&5 -+$as_echo_n "checking for ffmpeg autodetecting libraries... " >&6; } - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib64" >&5 -@@ -3606,6 +5348,18 @@ $as_echo "found in /usr/local/lib" >&6; - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" -+ elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/x86_64-linux-gnu" >&5 -+$as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" -+ FFMPEG_DIR="/usr" -+ elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 -+$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib/i386-linux-gnu" -+ FFMPEG_DIR="/usr" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 - $as_echo "not found" >&6; } -@@ -3621,8 +5375,8 @@ $as_echo "not found" >&6; } - echo "" - fi - else -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg in -> ${FFMPEG_DIR} <-" >&5 --$as_echo_n "checking for ffmpeg in -> ${FFMPEG_DIR} <-... " >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-" >&5 -+$as_echo_n "checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-... " >&6; } - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 - $as_echo "found" >&6; } -@@ -3651,94 +5405,202 @@ $as_echo "not found" >&6; } - fi - fi - -+ - # - # Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found - # - -+AVFORMAT_DIR="" -+ - if test "${FFMPEG_OK}" = "found"; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 -+ if test "${FFMPEG_HEADERS_DIR}" = "yes"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 - $as_echo_n "checking for ffmpeg headers in ${FFMPEG_DIR}... " >&6; } -+ AVFORMAT_DIR="${FFMPEG_DIR}" -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}" >&5 -+$as_echo_n "checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}... " >&6; } -+ FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" -+ AVFORMAT_DIR="${FFMPEG_DIR}" -+ fi - -- if test -f ${FFMPEG_DIR}/include/avformat.h; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 -+ if test -f ${FFMPEG_DIR}/include/avformat.h; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 - $as_echo "found ${FFMPEG_DIR}/include/avformat.h" >&6; } -- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" -- elif test -f ${FFMPEG_DIR}/avformat.h; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" -+ elif test -f ${FFMPEG_DIR}/avformat.h; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 - $as_echo "found ${FFMPEG_DIR}/avformat.h" >&6; } -- FFMPEG_CFLAGS="-I${FFMPEG_DIR}" -- elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}" -+ AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" -+ elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 - $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; } -- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" -- elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" -+ elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 - $as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; } -- FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5 - $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" -- else -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -+ AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" -+ elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/libavformat/avformat.h" >&5 -+$as_echo "found ${FFMPEG_DIR}/libavformat/avformat.h" >&6; } -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I{FFMPEG_DIR}/libavformat" -+ AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 - $as_echo "not found" >&6; } -- FFMPEG_OK="no_found" -- echo "**********************************************" -- echo "* avformat.h not found: *" -- echo "* ALL FFMPEG FEATURES DISABLED *" -- echo "* *" -- echo "* Please read the Motion Guide for help: *" -- echo "* http://motion.sourceforge.net *" -- echo "**********************************************" -- echo "" -- fi -+ FFMPEG_OK="no_found" -+ AVFORMAT_DIR="avformat.h" -+ echo "**********************************************" -+ echo "* avformat.h not found: *" -+ echo "* ALL FFMPEG FEATURES DISABLED *" -+ echo "* *" -+ echo "* Please read the Motion Guide for help: *" -+ echo "* http://motion.sourceforge.net *" -+ echo "**********************************************" -+ echo "" -+ fi - - # - # If ffmpeg libs and headers have been found - # - -- if test "${FFMPEG_OK}" = "found"; then -- TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} -lavformat -lavcodec -lavutil -lm -lz" -- TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" -- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" -+ if test "${FFMPEG_OK}" = "found"; then -+ TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" -+ TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" - -- FFMPEG_OBJ="ffmpeg.o" -+ FFMPEG_OBJ="ffmpeg.o" - - -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 - $as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } -- saved_CFLAGS=$CFLAGS -- saved_LIBS=$LIBS -- CFLAGS="${FFMPEG_CFLAGS}" -- LIBS="$TEMP_LIBS" -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ -+ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" -+ LIBS="$TEMP_LIBS" -+ -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ - -- cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+ -+ #include <${AVFORMAT_DIR}> -+ URLProtocol test_file_protocol; -+ int main(void){ -+ test_file_protocol.url_read = file_protocol.url_read; -+ return 0; -+ } -+ -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+else -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" -+ -+ -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+ fi -+fi -+fi -+ -+# Revised RTSP module so that it can be included -+# whether or not FFMPEG is found. -+ -+ RTPS_OBJ="netcam_rtsp.o" -+ -+ -+# -+# Check SQLITE3 -+# -+ -+SQLITE3_SUPPORT="no" -+ -+# Check whether --with-sqlite3 was given. -+if test "${with_sqlite3+set}" = set; then : -+ withval=$with_sqlite3; SQLITE3="$withval" -+ # if not given argument, assume standard -+ -+fi -+ -+ -+if test "${SQLITE3}" = "no"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3" >&5 -+$as_echo_n "checking for sqlite3... " >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -+$as_echo "skipping" >&6; } -+else -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5 -+$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; } -+if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lsqlite3 $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext - /* end confdefs.h. */ - -- #include -- URLProtocol test_file_protocol; -- int main(void){ -- test_file_protocol.url_read = file_protocol.url_read; -- return 0; -- } -- -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char sqlite3_open (); -+int -+main () -+{ -+return sqlite3_open (); -+ ; -+ return 0; -+} - _ACEOF --if ac_fn_c_try_compile "$LINENO"; then : -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 --$as_echo "yes" >&6; } -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_sqlite3_sqlite3_open=yes - else -+ ac_cv_lib_sqlite3_sqlite3_open=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5 -+$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; } -+if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then : -+ -+ TEMP_LIBS="$TEMP_LIBS -lsqlite3" -+ SQLITE3_SUPPORT="yes" -+ -+$as_echo "#define HAVE_SQLITE3 1" >>confdefs.h - -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 --$as_echo "no" >&6; } -- TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" - - - fi --rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -- CFLAGS=$saved_CFLAGS -- LIBS=$saved_LIBS -- fi --fi -+ -+ -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS - fi - - -@@ -3821,8 +5683,8 @@ $as_echo "skipped" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers in $MYSQL_HEADERS" >&5 - $as_echo_n "checking for mysql headers in $MYSQL_HEADERS... " >&6; } - # Manual detection for -- if test -f $MYSQL_HEADERS/mysql.h; then -- MYSQL_INCDIR=$MYSQL_HEADERS -+ if test -f $MYSQL_HEADERS/mysql.h; then -+ MYSQL_INCDIR=$MYSQL_HEADERS - fi - fi - -@@ -3832,8 +5694,8 @@ $as_echo_n "checking for mysql headers i - $as_echo "not found" >&6; } - echo "Invalid MySQL directory - unable to find mysql.h." - else -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 --$as_echo "yes" >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_INCDIR yes" >&5 -+$as_echo "$MYSQL_INCDIR yes" >&6; } - MYSQL_HEADERS="yes" - fi - -@@ -3844,8 +5706,8 @@ $as_echo "yes" >&6; } - if test "${MYSQL_LIBS}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql libs" >&5 - $as_echo_n "checking autodect mysql libs... " >&6; } -- # Autodetect -- for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql; do -+ # Autodetect -+ for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do - # check for plain setups - if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then - MYSQL_LIBDIR=$w -@@ -3863,7 +5725,7 @@ $as_echo_n "checking autodect mysql libs - fi - done - elif test "${MYSQL_LIBS}" = "no"; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 - $as_echo_n "checking for mysql libs... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 - $as_echo "skipped" >&6; } -@@ -3891,7 +5753,7 @@ $as_echo "$MYSQL_LIBDIR" >&6; } - LIBS="-L$MYSQL_LIBDIR" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 - $as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } --if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then : -+if ${ac_cv_lib_mysqlclient_mysql_init+:} false; then : - $as_echo_n "(cached) " >&6 - else - ac_check_lib_save_LIBS=$LIBS -@@ -3925,7 +5787,7 @@ LIBS=$ac_check_lib_save_LIBS - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 - $as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } --if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then : -+if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then : - - TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" - TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" -@@ -3935,7 +5797,7 @@ $as_echo "#define HAVE_MYSQL 1" >>confde - - - else -- as_fn_error "MySQL support can't build without MySQL libraries" "$LINENO" 5 -+ as_fn_error $? "MySQL support can't build without MySQL libraries" "$LINENO" 5 - fi - - CFLAGS=$saved_CFLAGS -@@ -4018,8 +5880,8 @@ $as_echo "skipped" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers in $PGSQL_HEADERS" >&5 - $as_echo_n "checking for pgsql headers in $PGSQL_HEADERS... " >&6; } - # Manual detection for -- if test -f $PGSQL_HEADERS/libpq-fe.h; then -- PGSQL_INCDIR=$PGSQL_HEADERS -+ if test -f $PGSQL_HEADERS/libpq-fe.h; then -+ PGSQL_INCDIR=$PGSQL_HEADERS - fi - fi - -@@ -4037,386 +5899,118 @@ $as_echo "yes $PGSQL_INCDIR" >&6; } - - if test "${PGSQL_HEADERS}" = "yes"; then - -- # ******* Search pgsql libs ********* -- if test "${PGSQL_LIBS}" = "yes"; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 --$as_echo_n "checking autodect pgsql libs... " >&6; } -- # Autodetect -- PGSQL_INCLUDE="-I$PGSQL_INCDIR" -- PGSQL_LIBDIR=$PGSQL_DIR/lib -- -- if test -f /usr/lib64/libpq.so ; then -- PGSQL_LIBDIR=/usr/lib64 -- elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then -- PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql -- elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then -- PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql -- elif test -f $PGSQL_DIR/lib/libpq.so ; then -- PGSQL_LIBDIR=$PGSQL_DIR/lib -- else -- PGSQL_LIBDIR="" -- fi -- -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 --$as_echo "$PGSQL_LIBDIR" >&6; } -- -- elif test "${PGSQL_LIBS}" = "no"; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 --$as_echo_n "checking for pgsql libs... " >&6; } -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 --$as_echo "skipped" >&6; } -- else -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 --$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } -- # Manual detection for -- if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then -- PGSQL_LIBDIR=$PGSQL_LIBS -- fi -- fi -- -- -- if test -z "$PGSQL_LIBDIR" ; then -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 --$as_echo "not found" >&6; } -- echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." -- else -- #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" -- saved_CFLAGS=$CFLAGS -- saved_LIBS=$LIBS -- CFLAGS="-I$PGSQL_INCDIR" -- LIBS="-L$PGSQL_LIBDIR" -- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 --$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } --if test "${ac_cv_lib_pq_PQconnectStart+set}" = set; then : -- $as_echo_n "(cached) " >&6 --else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-lpq $LIBS" --cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ -- --/* Override any GCC internal prototype to avoid an error. -- Use char because int might match the return type of a GCC -- builtin and then its argument prototype would still apply. */ --#ifdef __cplusplus --extern "C" --#endif --char PQconnectStart (); --int --main () --{ --return PQconnectStart (); -- ; -- return 0; --} --_ACEOF --if ac_fn_c_try_link "$LINENO"; then : -- ac_cv_lib_pq_PQconnectStart=yes --else -- ac_cv_lib_pq_PQconnectStart=no --fi --rm -f core conftest.err conftest.$ac_objext \ -- conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS --fi --{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 --$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } --if test "x$ac_cv_lib_pq_PQconnectStart" = x""yes; then : -- -- PGSQL_SUPPORT="yes" -- TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" -- TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" -- --$as_echo "#define HAVE_PGSQL 1" >>confdefs.h -- -- --else -- as_fn_error "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 --fi -- -- LDFLAGS="" -- CFLAGS=$saved_CFLAGS -- LIBS=$saved_LIBS -- fi -- -- fi # end pgsql-include , pgsql-libs -- --# end PostgreSQL detection --fi -- -- --#Checks for header files. --ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu --{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 --$as_echo_n "checking how to run the C preprocessor... " >&6; } --# On Suns, sometimes $CPP names a directory. --if test -n "$CPP" && test -d "$CPP"; then -- CPP= --fi --if test -z "$CPP"; then -- if test "${ac_cv_prog_CPP+set}" = set; then : -- $as_echo_n "(cached) " >&6 --else -- # Double quotes because CPP needs to be expanded -- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" -- do -- ac_preproc_ok=false --for ac_c_preproc_warn_flag in '' yes --do -- # Use a header file that comes with gcc, so configuring glibc -- # with a fresh cross-compiler works. -- # Prefer to if __STDC__ is defined, since -- # exists even on freestanding compilers. -- # On the NeXT, cc -E runs the code through the compiler's parser, -- # not just through cpp. "Syntax error" is here to catch this case. -- cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ --#ifdef __STDC__ --# include --#else --# include --#endif -- Syntax error --_ACEOF --if ac_fn_c_try_cpp "$LINENO"; then : -- --else -- # Broken: fails on valid input. --continue --fi --rm -f conftest.err conftest.$ac_ext -- -- # OK, works on sane cases. Now check whether nonexistent headers -- # can be detected and how. -- cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ --#include --_ACEOF --if ac_fn_c_try_cpp "$LINENO"; then : -- # Broken: success on invalid input. --continue --else -- # Passes both tests. --ac_preproc_ok=: --break --fi --rm -f conftest.err conftest.$ac_ext -- --done --# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. --rm -f conftest.err conftest.$ac_ext --if $ac_preproc_ok; then : -- break --fi -- -- done -- ac_cv_prog_CPP=$CPP -- --fi -- CPP=$ac_cv_prog_CPP --else -- ac_cv_prog_CPP=$CPP --fi --{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 --$as_echo "$CPP" >&6; } --ac_preproc_ok=false --for ac_c_preproc_warn_flag in '' yes --do -- # Use a header file that comes with gcc, so configuring glibc -- # with a fresh cross-compiler works. -- # Prefer to if __STDC__ is defined, since -- # exists even on freestanding compilers. -- # On the NeXT, cc -E runs the code through the compiler's parser, -- # not just through cpp. "Syntax error" is here to catch this case. -- cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ --#ifdef __STDC__ --# include --#else --# include --#endif -- Syntax error --_ACEOF --if ac_fn_c_try_cpp "$LINENO"; then : -- --else -- # Broken: fails on valid input. --continue --fi --rm -f conftest.err conftest.$ac_ext -- -- # OK, works on sane cases. Now check whether nonexistent headers -- # can be detected and how. -- cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ --#include --_ACEOF --if ac_fn_c_try_cpp "$LINENO"; then : -- # Broken: success on invalid input. --continue --else -- # Passes both tests. --ac_preproc_ok=: --break --fi --rm -f conftest.err conftest.$ac_ext -- --done --# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. --rm -f conftest.err conftest.$ac_ext --if $ac_preproc_ok; then : -+ # ******* Search pgsql libs ********* -+ if test "${PGSQL_LIBS}" = "yes"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 -+$as_echo_n "checking autodect pgsql libs... " >&6; } -+ # Autodetect -+ PGSQL_INCLUDE="-I$PGSQL_INCDIR" -+ PGSQL_LIBDIR=$PGSQL_DIR/lib - --else -- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 --$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --as_fn_error "C preprocessor \"$CPP\" fails sanity check --See \`config.log' for more details." "$LINENO" 5; } --fi -+ if test -f /usr/lib64/libpq.so ; then -+ PGSQL_LIBDIR=/usr/lib64 -+ elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then -+ PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql -+ elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then -+ PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql -+ elif test -f $PGSQL_DIR/lib/libpq.so ; then -+ PGSQL_LIBDIR=$PGSQL_DIR/lib -+ else -+ PGSQL_LIBDIR="" -+ fi - --ac_ext=c --ac_cpp='$CPP $CPPFLAGS' --ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' --ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' --ac_compiler_gnu=$ac_cv_c_compiler_gnu -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 -+$as_echo "$PGSQL_LIBDIR" >&6; } - -+ elif test "${PGSQL_LIBS}" = "no"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 -+$as_echo_n "checking for pgsql libs... " >&6; } -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -+$as_echo "skipped" >&6; } -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 -+$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } -+ # Manual detection for -+ if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then -+ PGSQL_LIBDIR=$PGSQL_LIBS -+ fi -+ fi - --{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 --$as_echo_n "checking for grep that handles long lines and -e... " >&6; } --if test "${ac_cv_path_GREP+set}" = set; then : -+ -+ if test -z "$PGSQL_LIBDIR" ; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -+$as_echo "not found" >&6; } -+ echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." -+ else -+ #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ CFLAGS="-I$PGSQL_INCDIR" -+ LIBS="-L$PGSQL_LIBDIR" -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 -+$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } -+if ${ac_cv_lib_pq_PQconnectStart+:} false; then : - $as_echo_n "(cached) " >&6 - else -- if test -z "$GREP"; then -- ac_path_GREP_found=false -- # Loop through the user's path and test for each of PROGNAME-LIST -- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_prog in grep ggrep; do -- for ac_exec_ext in '' $ac_executable_extensions; do -- ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" -- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue --# Check for GNU ac_path_GREP and select it if it is found. -- # Check for GNU $ac_path_GREP --case `"$ac_path_GREP" --version 2>&1` in --*GNU*) -- ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; --*) -- ac_count=0 -- $as_echo_n 0123456789 >"conftest.in" -- while : -- do -- cat "conftest.in" "conftest.in" >"conftest.tmp" -- mv "conftest.tmp" "conftest.in" -- cp "conftest.in" "conftest.nl" -- $as_echo 'GREP' >> "conftest.nl" -- "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break -- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break -- as_fn_arith $ac_count + 1 && ac_count=$as_val -- if test $ac_count -gt ${ac_path_GREP_max-0}; then -- # Best one so far, save it but keep looking for a better one -- ac_cv_path_GREP="$ac_path_GREP" -- ac_path_GREP_max=$ac_count -- fi -- # 10*(2^10) chars as input seems more than enough -- test $ac_count -gt 10 && break -- done -- rm -f conftest.in conftest.tmp conftest.nl conftest.out;; --esac -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lpq $LIBS" -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ - -- $ac_path_GREP_found && break 3 -- done -- done -- done --IFS=$as_save_IFS -- if test -z "$ac_cv_path_GREP"; then -- as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 -- fi -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char PQconnectStart (); -+int -+main () -+{ -+return PQconnectStart (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_pq_PQconnectStart=yes - else -- ac_cv_path_GREP=$GREP -+ ac_cv_lib_pq_PQconnectStart=no - fi -- -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS - fi --{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 --$as_echo "$ac_cv_path_GREP" >&6; } -- GREP="$ac_cv_path_GREP" -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 -+$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } -+if test "x$ac_cv_lib_pq_PQconnectStart" = xyes; then : - -+ PGSQL_SUPPORT="yes" -+ TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" -+ TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" -+ -+$as_echo "#define HAVE_PGSQL 1" >>confdefs.h - --{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 --$as_echo_n "checking for egrep... " >&6; } --if test "${ac_cv_path_EGREP+set}" = set; then : -- $as_echo_n "(cached) " >&6 --else -- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 -- then ac_cv_path_EGREP="$GREP -E" -- else -- if test -z "$EGREP"; then -- ac_path_EGREP_found=false -- # Loop through the user's path and test for each of PROGNAME-LIST -- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR --for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin --do -- IFS=$as_save_IFS -- test -z "$as_dir" && as_dir=. -- for ac_prog in egrep; do -- for ac_exec_ext in '' $ac_executable_extensions; do -- ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" -- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue --# Check for GNU ac_path_EGREP and select it if it is found. -- # Check for GNU $ac_path_EGREP --case `"$ac_path_EGREP" --version 2>&1` in --*GNU*) -- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; --*) -- ac_count=0 -- $as_echo_n 0123456789 >"conftest.in" -- while : -- do -- cat "conftest.in" "conftest.in" >"conftest.tmp" -- mv "conftest.tmp" "conftest.in" -- cp "conftest.in" "conftest.nl" -- $as_echo 'EGREP' >> "conftest.nl" -- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break -- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break -- as_fn_arith $ac_count + 1 && ac_count=$as_val -- if test $ac_count -gt ${ac_path_EGREP_max-0}; then -- # Best one so far, save it but keep looking for a better one -- ac_cv_path_EGREP="$ac_path_EGREP" -- ac_path_EGREP_max=$ac_count -- fi -- # 10*(2^10) chars as input seems more than enough -- test $ac_count -gt 10 && break -- done -- rm -f conftest.in conftest.tmp conftest.nl conftest.out;; --esac - -- $ac_path_EGREP_found && break 3 -- done -- done -- done --IFS=$as_save_IFS -- if test -z "$ac_cv_path_EGREP"; then -- as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 -- fi - else -- ac_cv_path_EGREP=$EGREP -+ as_fn_error $? "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 - fi - -- fi -+ LDFLAGS="" -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+ fi -+ -+ fi # end pgsql-include , pgsql-libs -+ -+# end PostgreSQL detection - fi --{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 --$as_echo "$ac_cv_path_EGREP" >&6; } -- EGREP="$ac_cv_path_EGREP" - - -+#Checks for header files. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 - $as_echo_n "checking for ANSI C header files... " >&6; } --if test "${ac_cv_header_stdc+set}" = set; then : -+if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -@@ -4526,30 +6120,11 @@ $as_echo "#define STDC_HEADERS 1" >>conf - - fi - --# On IRIX 5.3, sys/types and inttypes.h are conflicting. --for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ -- inttypes.h stdint.h unistd.h --do : -- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` --ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default --" --eval as_val=\$$as_ac_Header -- if test "x$as_val" = x""yes; then : -- cat >>confdefs.h <<_ACEOF --#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 --_ACEOF -- --fi -- --done -- -- - for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h - do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` - ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" --eval as_val=\$$as_ac_Header -- if test "x$as_val" = x""yes; then : -+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF - #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 - _ACEOF -@@ -4562,7 +6137,7 @@ done - for ac_func in get_current_dir_name - do : - ac_fn_c_check_func "$LINENO" "get_current_dir_name" "ac_cv_func_get_current_dir_name" --if test "x$ac_cv_func_get_current_dir_name" = x""yes; then : -+if test "x$ac_cv_func_get_current_dir_name" = xyes; then : - cat >>confdefs.h <<_ACEOF - #define HAVE_GET_CURRENT_DIR_NAME 1 - _ACEOF -@@ -4575,7 +6150,6 @@ done - SUPPORTED_V4L2=false - SUPPORTED_V4L2_old=false - -- - if test "${V4L}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 - $as_echo_n "checking for V42L support... " >&6; } -@@ -4585,7 +6159,7 @@ else - ac_fn_c_check_type "$LINENO" "struct v4l2_buffer" "ac_cv_type_struct_v4l2_buffer" "#include - #include - " --if test "x$ac_cv_type_struct_v4l2_buffer" = x""yes; then : -+if test "x$ac_cv_type_struct_v4l2_buffer" = xyes; then : - SUPPORTED_V4L2=true - else - SUPPORTED_V4L2=false -@@ -4613,7 +6187,7 @@ $as_echo "testing" >&6; } - do : - ac_fn_c_check_header_compile "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "#include - " --if test "x$ac_cv_header_linux_videodev2_h" = x""yes; then : -+if test "x$ac_cv_header_linux_videodev2_h" = xyes; then : - cat >>confdefs.h <<_ACEOF - #define HAVE_LINUX_VIDEODEV2_H 1 - _ACEOF -@@ -4640,7 +6214,7 @@ fi - # This bug is HP SR number 8606223364. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 - $as_echo_n "checking size of short... " >&6; } --if test "${ac_cv_sizeof_short+set}" = set; then : -+if ${ac_cv_sizeof_short+:} false; then : - $as_echo_n "(cached) " >&6 - else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : -@@ -4649,9 +6223,8 @@ else - if test "$ac_cv_type_short" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "cannot compute sizeof (short) --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "cannot compute sizeof (short) -+See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_short=0 - fi -@@ -4674,7 +6247,7 @@ _ACEOF - # This bug is HP SR number 8606223364. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 - $as_echo_n "checking size of int... " >&6; } --if test "${ac_cv_sizeof_int+set}" = set; then : -+if ${ac_cv_sizeof_int+:} false; then : - $as_echo_n "(cached) " >&6 - else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : -@@ -4683,9 +6256,8 @@ else - if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "cannot compute sizeof (int) --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "cannot compute sizeof (int) -+See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_int=0 - fi -@@ -4708,7 +6280,7 @@ _ACEOF - # This bug is HP SR number 8606223364. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5 - $as_echo_n "checking size of long int... " >&6; } --if test "${ac_cv_sizeof_long_int+set}" = set; then : -+if ${ac_cv_sizeof_long_int+:} false; then : - $as_echo_n "(cached) " >&6 - else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then : -@@ -4717,9 +6289,8 @@ else - if test "$ac_cv_type_long_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "cannot compute sizeof (long int) --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "cannot compute sizeof (long int) -+See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_int=0 - fi -@@ -4742,7 +6313,7 @@ _ACEOF - # This bug is HP SR number 8606223364. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 - $as_echo_n "checking size of long long... " >&6; } --if test "${ac_cv_sizeof_long_long+set}" = set; then : -+if ${ac_cv_sizeof_long_long+:} false; then : - $as_echo_n "(cached) " >&6 - else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : -@@ -4751,9 +6322,8 @@ else - if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "cannot compute sizeof (long long) --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "cannot compute sizeof (long long) -+See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_long=0 - fi -@@ -4776,7 +6346,7 @@ _ACEOF - # This bug is HP SR number 8606223364. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 - $as_echo_n "checking size of int *... " >&6; } --if test "${ac_cv_sizeof_int_p+set}" = set; then : -+if ${ac_cv_sizeof_int_p+:} false; then : - $as_echo_n "(cached) " >&6 - else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : -@@ -4785,9 +6355,8 @@ else - if test "$ac_cv_type_int_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "cannot compute sizeof (int *) --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "cannot compute sizeof (int *) -+See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_int_p=0 - fi -@@ -4810,7 +6379,7 @@ _ACEOF - # This bug is HP SR number 8606223364. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 - $as_echo_n "checking size of void *... " >&6; } --if test "${ac_cv_sizeof_void_p+set}" = set; then : -+if ${ac_cv_sizeof_void_p+:} false; then : - $as_echo_n "(cached) " >&6 - else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : -@@ -4819,9 +6388,8 @@ else - if test "$ac_cv_type_void_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 - $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} --{ as_fn_set_status 77 --as_fn_error "cannot compute sizeof (void *) --See \`config.log' for more details." "$LINENO" 5; }; } -+as_fn_error 77 "cannot compute sizeof (void *) -+See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_void_p=0 - fi -@@ -4875,7 +6443,7 @@ fi - # Checks for typedefs, structures, and compiler characteristics. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 - $as_echo_n "checking for an ANSI C-conforming const... " >&6; } --if test "${ac_cv_c_const+set}" = set; then : -+if ${ac_cv_c_const+:} false; then : - $as_echo_n "(cached) " >&6 - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -@@ -4884,11 +6452,11 @@ else - int - main () - { --/* FIXME: Include the comments suggested by Paul. */ -+ - #ifndef __cplusplus -- /* Ultrix mips cc rejects this. */ -+ /* Ultrix mips cc rejects this sort of thing. */ - typedef int charset[2]; -- const charset cs; -+ const charset cs = { 0, 0 }; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; -@@ -4905,8 +6473,9 @@ main () - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; -- { /* SCO 3.2v4 cc rejects this. */ -- char *t; -+ { /* SCO 3.2v4 cc rejects this sort of thing. */ -+ char tx; -+ char *t = &tx; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; -@@ -4922,10 +6491,10 @@ main () - iptr p = 0; - ++p; - } -- { /* AIX XL C 1.02.0.0 rejects this saying -+ { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ -- struct s { int j; const int *ap[3]; }; -- struct s *b; b->j = 5; -+ struct s { int j; const int *ap[3]; } bx; -+ struct s *b = &bx; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; -@@ -4992,6 +6561,7 @@ if test -e "/proc/cpuinfo" ; then - intel[152]="-march=pentium4" - intel[154]="-march=pentium4" - intel[614]="-march=prescott" -+ intel[628]="-march=core2" - amd[50]="-march=i586" - amd[51]="-march=i586" - amd[52]="-march=i586" -@@ -5063,6 +6633,9 @@ if test -e "/proc/cpuinfo" ; then - sse3) - CPU_FPU="-msse3" - ;; -+ ssse3) -+ CPU_FPU="-mfpmath=sse -msse2 -mssse3" -+ ;; - 3dnow) - CPU_EXT="$CPU_EXT -m3dnow" - ;; -@@ -5137,7 +6710,7 @@ if test "x${CPU_TYPE}" = "xunknown"; the - CPU_OPTIONS="-march=k6-3" - ;; - *) -- CPU_OPTIONS="" -+ CPU_OPTIONS="-march=native -mtune=native" - ;; - esac - fi -@@ -5205,7 +6778,7 @@ rm -f core conftest.err conftest.$ac_obj - - - if test "${DEVELOPER_FLAGS}" = "yes"; then -- TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3 " -+ TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" - fi - - CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" -@@ -5213,6 +6786,7 @@ CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU - LIBS="${TEMP_LIBS}" - LDFLAGS="${TEMP_LDFLAGS}" - -+ - # - # Add the right exec path for rc scripts - # -@@ -5234,7 +6808,6 @@ fi - - - -- - ac_config_files="$ac_config_files thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian motion.init-Fedora motion.spec Makefile" - - cat >confcache <<\_ACEOF -@@ -5301,10 +6874,21 @@ $as_echo "$as_me: WARNING: cache variabl - :end' >>confcache - if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then -- test "x$cache_file" != "x/dev/null" && -+ if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 - $as_echo "$as_me: updating cache $cache_file" >&6;} -- cat confcache >$cache_file -+ if test ! -f "$cache_file" || test -h "$cache_file"; then -+ cat confcache >"$cache_file" -+ else -+ case $cache_file in #( -+ */* | ?:*) -+ mv -f confcache "$cache_file"$$ && -+ mv -f "$cache_file"$$ "$cache_file" ;; #( -+ *) -+ mv -f confcache "$cache_file" ;; -+ esac -+ fi -+ fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 - $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} -@@ -5320,6 +6904,7 @@ DEFS=-DHAVE_CONFIG_H - - ac_libobjs= - ac_ltlibobjs= -+U= - for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' -@@ -5335,7 +6920,7 @@ LTLIBOBJS=$ac_ltlibobjs - - - --: ${CONFIG_STATUS=./config.status} -+: "${CONFIG_STATUS=./config.status}" - ac_write_fail=0 - ac_clean_files_save=$ac_clean_files - ac_clean_files="$ac_clean_files $CONFIG_STATUS" -@@ -5436,6 +7021,7 @@ fi - IFS=" "" $as_nl" - - # Find who we are. Look in the path if we contain no directory separator. -+as_myself= - case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -@@ -5481,19 +7067,19 @@ export LANGUAGE - (unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - --# as_fn_error ERROR [LINENO LOG_FD] --# --------------------------------- -+# as_fn_error STATUS ERROR [LINENO LOG_FD] -+# ---------------------------------------- - # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are - # provided, also output the error to LOG_FD, referencing LINENO. Then exit the --# script with status $?, using 1 if that was 0. -+# script with STATUS, using 1 if that was 0. - as_fn_error () - { -- as_status=$?; test $as_status -eq 0 && as_status=1 -- if test "$3"; then -- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 -+ as_status=$1; test $as_status -eq 0 && as_status=1 -+ if test "$4"; then -+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack -+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi -- $as_echo "$as_me: error: $1" >&2 -+ $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status - } # as_fn_error - -@@ -5631,16 +7217,16 @@ if (echo >conf$$.file) 2>/dev/null; then - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. -- # In both cases, we have to default to `cp -p'. -+ # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || -- as_ln_s='cp -p' -+ as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else -- as_ln_s='cp -p' -+ as_ln_s='cp -pR' - fi - else -- as_ln_s='cp -p' -+ as_ln_s='cp -pR' - fi - rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file - rmdir conf$$.dir 2>/dev/null -@@ -5689,7 +7275,7 @@ $as_echo X"$as_dir" | - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" -- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" -+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - - } # as_fn_mkdir_p -@@ -5700,28 +7286,16 @@ else - as_mkdir_p=false - fi - --if test -x / >/dev/null 2>&1; then -- as_test_x='test -x' --else -- if ls -dL / >/dev/null 2>&1; then -- as_ls_L_option=L -- else -- as_ls_L_option= -- fi -- as_test_x=' -- eval sh -c '\'' -- if test -d "$1"; then -- test -d "$1/."; -- else -- case $1 in #( -- -*)set "./$1";; -- esac; -- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( -- ???[sx]*):;;*)false;;esac;fi -- '\'' sh -- ' --fi --as_executable_p=$as_test_x -+ -+# as_fn_executable_p FILE -+# ----------------------- -+# Test if FILE is an executable regular file. -+as_fn_executable_p () -+{ -+ test -f "$1" && test -x "$1" -+} # as_fn_executable_p -+as_test_x='test -x' -+as_executable_p=as_fn_executable_p - - # Sed expression to map a string onto a valid CPP name. - as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" -@@ -5742,8 +7316,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri - # 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 3.2.12, which was --generated by GNU Autoconf 2.65. Invocation command line was -+This file was extended by motion $as_me 3.2.12-4ppa01, which was -+generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS -@@ -5804,11 +7378,11 @@ _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 3.2.12 --configured by $0, generated by GNU Autoconf 2.65, -+motion config.status 3.2.12-4ppa01 -+configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - --Copyright (C) 2009 Free Software Foundation, Inc. -+Copyright (C) 2012 Free Software Foundation, Inc. - This config.status script is free software; the Free Software Foundation - gives unlimited permission to copy, distribute and modify it." - -@@ -5823,11 +7397,16 @@ ac_need_defaults=: - while test $# != 0 - do - case $1 in -- --*=*) -+ --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; -+ --*=) -+ ac_option=`expr "X$1" : 'X\([^=]*\)='` -+ ac_optarg= -+ ac_shift=: -+ ;; - *) - ac_option=$1 - ac_optarg=$2 -@@ -5849,6 +7428,7 @@ do - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; -+ '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; -@@ -5861,7 +7441,7 @@ do - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header -- as_fn_error "ambiguous option: \`$1' -+ as_fn_error $? "ambiguous option: \`$1' - Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; -@@ -5870,7 +7450,7 @@ Try \`$0 --help' for more information."; - ac_cs_silent=: ;; - - # This is an error. -- -*) as_fn_error "unrecognized option: \`$1' -+ -*) as_fn_error $? "unrecognized option: \`$1' - Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" -@@ -5890,7 +7470,7 @@ fi - _ACEOF - cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - if \$ac_cs_recheck; then -- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' -@@ -5931,7 +7511,7 @@ do - "motion.spec") CONFIG_FILES="$CONFIG_FILES motion.spec" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - -- *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac - done - -@@ -5953,9 +7533,10 @@ fi - # after its creation but before its name has been assigned to `$tmp'. - $debug || - { -- tmp= -+ tmp= ac_tmp= - trap 'exit_status=$? -- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -+ : "${ac_tmp:=$tmp}" -+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status - ' 0 - trap 'as_fn_exit 1' 1 2 13 15 - } -@@ -5963,12 +7544,13 @@ $debug || - - { - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && -- test -n "$tmp" && test -d "$tmp" -+ test -d "$tmp" - } || - { - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") --} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 -+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -+ac_tmp=$tmp - - # Set up the scripts for CONFIG_FILES section. - # No need to generate them if there are no CONFIG_FILES. -@@ -5985,12 +7567,12 @@ if test "x$ac_cr" = x; then - fi - ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` - if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then -- ac_cs_awk_cr='\r' -+ ac_cs_awk_cr='\\r' - else - ac_cs_awk_cr=$ac_cr - fi - --echo 'BEGIN {' >"$tmp/subs1.awk" && -+echo 'BEGIN {' >"$ac_tmp/subs1.awk" && - _ACEOF - - -@@ -5999,18 +7581,18 @@ _ACEOF - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" - } >conf$$subs.sh || -- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 --ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` -+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` - ac_delim='%!_!# ' - for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || -- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then -- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -@@ -6018,7 +7600,7 @@ done - rm -f conf$$subs.sh - - cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 --cat >>"\$tmp/subs1.awk" <<\\_ACAWK && -+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && - _ACEOF - sed -n ' - h -@@ -6066,7 +7648,7 @@ t delim - rm -f conf$$subs.awk - cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - _ACAWK --cat >>"\$tmp/subs1.awk" <<_ACAWK && -+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -@@ -6098,21 +7680,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/n - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" - else - cat --fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ -- || as_fn_error "could not setup config files machinery" "$LINENO" 5 -+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ -+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 - _ACEOF - --# VPATH may cause trouble with some makes, so we remove $(srcdir), --# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -+# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and - # trailing colons and then remove the whole line if VPATH becomes empty - # (actually we leave an empty line to preserve line numbers). - if test "x$srcdir" = x.; then -- ac_vpsub='/^[ ]*VPATH[ ]*=/{ --s/:*\$(srcdir):*/:/ --s/:*\${srcdir}:*/:/ --s/:*@srcdir@:*/:/ --s/^\([^=]*=[ ]*\):*/\1/ -+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -+h -+s/// -+s/^/:/ -+s/[ ]*$/:/ -+s/:\$(srcdir):/:/g -+s/:\${srcdir}:/:/g -+s/:@srcdir@:/:/g -+s/^:*// - s/:*$// -+x -+s/\(=[ ]*\).*/\1/ -+G -+s/\n// - s/^[^=]*=[ ]*$// - }' - fi -@@ -6124,7 +7714,7 @@ fi # test -n "$CONFIG_FILES" - # No need to generate them if there are no CONFIG_HEADERS. - # This happens for instance with `./config.status Makefile'. - if test -n "$CONFIG_HEADERS"; then --cat >"$tmp/defines.awk" <<\_ACAWK || -+cat >"$ac_tmp/defines.awk" <<\_ACAWK || - BEGIN { - _ACEOF - -@@ -6136,11 +7726,11 @@ _ACEOF - # handling of long lines. - ac_delim='%!_!# ' - for ac_last_try in false false :; do -- ac_t=`sed -n "/$ac_delim/p" confdefs.h` -- if test -z "$ac_t"; then -+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h` -+ if test -z "$ac_tt"; then - break - elif $ac_last_try; then -- as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 -+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -@@ -6225,7 +7815,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_writ - _ACAWK - _ACEOF - cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -- as_fn_error "could not setup config headers machinery" "$LINENO" 5 -+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 - fi # test -n "$CONFIG_HEADERS" - - -@@ -6238,7 +7828,7 @@ do - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; -- :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; -+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac -@@ -6257,7 +7847,7 @@ do - for ac_f - do - case $ac_f in -- -) ac_f="$tmp/stdin";; -+ -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. -@@ -6266,7 +7856,7 @@ do - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || -- as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; -+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" -@@ -6292,8 +7882,8 @@ $as_echo "$as_me: creating $ac_file" >&6 - esac - - case $ac_tag in -- *:-:* | *:-) cat >"$tmp/stdin" \ -- || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; -+ *:-:* | *:-) cat >"$ac_tmp/stdin" \ -+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac -@@ -6418,23 +8008,24 @@ s&@abs_builddir@&$ac_abs_builddir&;t t - s&@abs_top_builddir@&$ac_abs_top_builddir&;t t - $ac_datarootdir_hack - " --eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ -- || as_fn_error "could not create $ac_file" "$LINENO" 5 -+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ -+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - - test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && -- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && -- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && -+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && -+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ -+ "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' --which seems to be undefined. Please make sure it is defined." >&5 -+which seems to be undefined. Please make sure it is defined" >&5 - $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' --which seems to be undefined. Please make sure it is defined." >&2;} -+which seems to be undefined. Please make sure it is defined" >&2;} - -- rm -f "$tmp/stdin" -+ rm -f "$ac_tmp/stdin" - case $ac_file in -- -) cat "$tmp/out" && rm -f "$tmp/out";; -- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; -+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; -+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ -- || as_fn_error "could not create $ac_file" "$LINENO" 5 -+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # -@@ -6443,21 +8034,21 @@ which seems to be undefined. Please mak - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ -- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" -- } >"$tmp/config.h" \ -- || as_fn_error "could not create $ac_file" "$LINENO" 5 -- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then -+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" -+ } >"$ac_tmp/config.h" \ -+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 -+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 - $as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" -- mv "$tmp/config.h" "$ac_file" \ -- || as_fn_error "could not create $ac_file" "$LINENO" 5 -+ mv "$ac_tmp/config.h" "$ac_file" \ -+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ -- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ -- || as_fn_error "could not create -" "$LINENO" 5 -+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ -+ || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; - -@@ -6472,7 +8063,7 @@ _ACEOF - ac_clean_files=$ac_clean_files_save - - test $ac_write_fail = 0 || -- as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 -+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - - # configure is writing to config.log, and then calls config.status. -@@ -6493,7 +8084,7 @@ if test "$no_create" != yes; then - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. -- $ac_cs_success || as_fn_exit $? -+ $ac_cs_success || as_fn_exit 1 - fi - if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -@@ -6502,92 +8093,104 @@ fi - - - echo "" --echo " *******************************" --echo " Configure status " -+echo " **************************" -+echo " Configure status " - echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" --echo " *******************************" -+echo " **************************" - echo - - - if test "${Darwin}" != ""; then -- echo "OS : Darwin" -+ echo "OS : Darwin" - elif test "${FreeBSD}" != ""; then -- echo "OS : *BSD" -+ echo "OS : *BSD" - else -- echo "OS : Linux" -+ echo "OS : Linux" - fi - - if test "${PTHREAD_SUPPORT}" = "yes"; then -- echo "pthread Support: Yes" -+ echo "pthread support: Yes" - else -- echo "pthread Support: No" -- echo "**********************************************" -- echo "** Fatal Error YOU MUST HAVE pthread Support *" -- echo "**********************************************" -+ echo "pthread support: No" -+ echo "**********************************************" -+ echo "** Fatal Error YOU MUST HAVE pthread Support *" -+ echo "**********************************************" - fi - --if test "${JPEG_SUPPORT_MMX}" = "yes"; then -- echo "jpeg-mmx Support: Yes" -+ -+if test "${JPEG_SUPPORT_TURBO}" = "yes"; then -+ echo "jpeg turbo support: Yes" -+elif test "${JPEG_SUPPORT_MMX}" = "yes"; then -+ echo "jpeg-mmx support: Yes" - elif test "${JPEG_SUPPORT}" = "yes"; then -- echo "jpeg Support: Yes" -+ echo "jpeg support: Yes" - else -- echo "jpeg Support: No" -- echo "**********************************************" -- echo "** Fatal Error YOU MUST HAVE jpeg Support ***" -- echo "**********************************************" -+ echo "jpeg support: No" -+ echo "**********************************************" -+ echo "** Fatal Error YOU MUST HAVE jpeg Support ***" -+ echo "**********************************************" - fi - - if test "${FreeBSD}" != ""; then - if test "${BKTR}" = "yes"; then -- echo "BKTR included: Yes" -+ echo "BKTR included: Yes" - else -- echo "BKTR included: No" -+ echo "BKTR included: No" - fi - - if test "${PWCBSD}" = "yes"; then -- echo "PWCBSD include: Yes" -+ echo "PWCBSD include: Yes" - else -- echo "PWCBSD include: No" -+ echo "PWCBSD include: No" - fi - - else - if test "${V4L}" = "yes"; then -- echo "V4L included: Yes" -+ echo "V4L support: Yes" - else -- echo "V4L included: No" -+ echo "V4L support: No" - fi - - if test x$SUPPORTED_V4L2 = xtrue; then -- echo "V4L2 supported: Yes" -+ echo "V4L2 support: Yes" - else -- echo "V4L2 supported: No" -+ echo "V4L2 support: No" - fi - fi - -+if test "${SDL_SUPPORT}" = "yes"; then -+ echo "SDL support: Yes" -+else -+ echo "SDL support: No" -+fi -+ - if test "${FFMPEG_OK}" = "found"; then -- echo "FFmpeg Support: Yes" -+ echo "FFmpeg support: Yes" -+else -+ echo "FFmpeg support: No" -+fi -+ -+if test "${SQLITE3_SUPPORT}" = "yes"; then -+ echo "SQLite3 support: Yes" - else -- echo "FFmpeg Support: No" -+ echo "SQLite3 support: No" - fi - - if test "${MYSQL_SUPPORT}" = "yes"; then -- echo "MYSQL Support: Yes" -+ echo "MYSQL support: Yes" - else -- echo "MYSQL Support: No" -+ echo "MYSQL support: No" - fi - - if test "${PGSQL_SUPPORT}" = "yes"; then -- echo "PostgreSQL Support: Yes" -+ echo "PostgreSQL support: Yes" - else -- echo "PostgreSQL Support: No" -+ echo "PostgreSQL support: No" - fi - echo -- - echo "CFLAGS: $CFLAGS" - echo "LIBS: $LIBS" - echo "LDFLAGS: $LDFLAGS" -- - echo - echo "Install prefix: $prefix" - echo -- ---- /dev/null -+++ motion-3.2.12/configure.ac -@@ -0,0 +1,1386 @@ -+# Process this file with autoconf to produce a configure script -+ -+AC_INIT(motion, esyscmd(['./version.sh'])) -+AC_GNU_SOURCE -+AC_CONFIG_SRCDIR([motion.c]) -+AC_CONFIG_HEADERS(config.h) -+AC_PROG_CC -+ -+ -+THREAD_CFLAGS="" -+THREAD_CHECK="/usr/include/pthread.h" -+ -+Darwin="" -+FreeBSD="" -+ -+LINUXTHREADS="no" -+AC_ARG_WITH(linuxthreads, -+[ --with-linuxthreads Use linuxthreads in BSD instead of native pthreads -+ ] -+ , -+LINUXTHREADS="$withval" -+) -+ -+PWCBSD="no" -+AC_ARG_WITH(pwcbsd, -+[ --with-pwcbsd Use pwcbsd based webcams ( only BSD ) -+] -+, -+PWCBSD="$withval" -+) -+ -+ -+AC_MSG_CHECKING(for Darwin) -+Darwin=`uname -a | grep "Darwin"` -+ -+if test "${Darwin}" = ""; then -+ AC_MSG_RESULT(no) -+ AC_MSG_CHECKING(for *BSD) -+ -+ FreeBSD=`uname -a | grep "BSD"` -+ if test "${FreeBSD}" = ""; then -+ AC_MSG_RESULT(no) -+ VIDEO="video.o video2.o video_common.o" -+ else -+ AC_MSG_RESULT(yes) -+ if test "${LINUXTHREADS}" = "no"; then -+ AC_MSG_CHECKING(Linuxthreads) -+ AC_MSG_RESULT(skipping) -+ else -+ THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" -+ THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" -+ fi -+ -+ if test "${PWCBSD}" != "no"; then -+ VIDEO="video.o video2.o video_common.o" -+ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" -+ else -+ VIDEO="video_freebsd.o" -+ TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" -+ fi -+ -+ TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" -+ TEMP_LIBS="-L/usr/local/lib" -+ AC_MSG_RESULT(Build with PWCBSD support $PWCBSD) -+ -+ fi -+else -+ TEMP_CFLAGS="${CFLAGS} -I/sw/include" -+ TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" -+ TEMP_LIBS="-L/sw/lib" -+ VIDEO="video_freebsd.o" -+ FINK_LIB="-L/sw/lib" -+ Darwin="yes" -+ V4L="no" -+ AC_MSG_RESULT($Darwin) -+fi -+ -+ -+AC_SUBST(VIDEO) -+ -+# Checks for programs. -+AC_PROG_CC -+ -+TEMP_LIBS="-lm ${TEMP_LIBS}" -+TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" -+TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" -+ -+if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then -+ -+ AC_MSG_CHECKING(bktr headers in /usr/include/dev/bktr) -+ -+ if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then -+ AC_MSG_RESULT(yes) -+ else -+ AC_MSG_RESULT(no) -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" -+ fi -+# -+# Check to Exclude BKTR -+# -+BKTR="yes" -+AC_ARG_WITH(bktr, -+[ --without-bktr Exclude to use bktr subsystem , that usually useful -+ for devices as network cameras ( ONLY used in *BSD). -+ ] -+ , -+BKTR="$withval" -+) -+ -+ if test "${BKTR}" = "no"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -+ fi -+ -+else -+ -+# -+# Check to Exclude V4L -+# -+V4L="yes" -+AC_ARG_WITH(v4l, -+[ --without-v4l Exclude using v4l (video4linux) subsystem. -+ Makes Motion so it only supports network cameras. -+ ], -+V4L="$withval" -+) -+ -+fi -+ -+ -+if test "${V4L}" = "no"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -+fi -+ -+ -+if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then -+ -+AC_MSG_CHECKING(for linuxthreads) -+ -+# -+# Check for thread header -+# -+ if test -f "${THREAD_CHECK}"; then -+ HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" -+ THREADS="yes" -+ else -+ THREADS="no" -+ fi -+ -+# -+# Check for thread lib -+# -+ if test -f "${THREAD_LIB_CHECK}" ; then -+ THREADS="yes" -+ LIB_THREAD="-llthread -llgcc_r" -+ else -+ THREADS="no" -+ fi -+ -+# Checks for Library linuxthreads for FreeBSD -+# -+# linuxthreads on freeBSD, ports collection -+# /usr/local/include/pthreads/linuxthreads/pthread.h -+# #include -+# /usr/local/lib/libpthread.so -+# -+ -+ if test "${THREADS}" = "yes"; then -+ TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" -+ TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" -+ THREAD_CFLAGS="-D_THREAD_SAFE" -+ PTHREAD_SUPPORT="yes" -+ AC_MSG_RESULT($THREADS) -+ else -+ PTHREAD_SUPPORT="no" -+ AC_MSG_RESULT($THREADS) -+ echo -+ echo "You do not have linuxthread installed" -+ echo -+ fi -+ -+elif test -f "${THREAD_CHECK}"; then -+ -+ -+AC_MSG_CHECKING(threads) -+AC_TRY_LINK([#include ], -+[pthread_t th; pthread_join(th, 0); -+ pthread_attr_init(0); pthread_cleanup_push(0, 0); -+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], -+ [PTHREAD_LIB=yes]) -+ -+if test x$PTHREAD_LIB != xyes; then -+ -+ if test "${FreeBSD}" != ""; then -+ TEMP_LIBS="$TEMP_LIBS -pthread" -+ TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" -+ else -+ TEMP_LIBS="$TEMP_LIBS -lpthread" -+ TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" -+ fi -+ PTHREAD_SUPPORT="yes" -+fi -+ AC_MSG_RESULT($PTHREAD_SUPPORT) -+ -+else -+ echo -+ echo "You do not have threads support" -+ echo -+fi -+ -+ -+# -+# Check for sdl library -+# -+SDL_SUPPORT="no" -+AC_ARG_WITH(sdl, -+[ --without-sdl Compile without sdl support to get stream in SDL window. -+], -+[], -+[]) -+AC_MSG_CHECKING(for sdl) -+if test "x$withval" = "xno"; then -+ AC_MSG_RESULT(skipped) -+else -+ if test "${FreeBSD}" != ""; then -+ CONFIG_SDL='sdl11-config' -+ else -+ CONFIG_SDL='sdl-config' -+ fi -+ if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then -+ AC_MSG_RESULT(no) -+ if test "$withval" = "yes"; then -+ echo "" -+ echo "****************************************************" -+ echo "* sdl-config could not be found. Please install it *" -+ echo "* and remove the --with-sdl configure argument. *" -+ echo "* libSDL can be found at http://www.libsdl.org *" -+ echo "****************************************************" -+ echo "" -+ fi -+ else -+ AC_MSG_RESULT(yes) -+ SDL_SUPPORT="yes" -+ TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" -+ TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" -+ AC_DEFINE([HAVE_SDL],1,[Define to 1 if you have SDL support]) -+ SDL_OBJ="sdl.o" -+ AC_SUBST(SDL_OBJ) -+ fi -+fi -+ -+# -+# Check for the libjpeg-turbo library -+# -+JPEG_TURBO="no" -+JPEG_TURBO_OK="not_found" -+ -+AC_ARG_WITH(jpeg-turbo, -+[ --with-jpeg-turbo[=DIR] Specify the prefix for the install path for -+ jpeg-turbo for optimized jpeg handling (optional). -+ ], -+JPEG_TURBO="$withval" -+) -+ -+if test "${JPEG_TURBO}" = "no"; then -+ AC_MSG_CHECKING(for libjpeg-turbo) -+ AC_MSG_RESULT(skipping) -+else -+ AC_MSG_CHECKING(for libjpeg-turbo in -> [${JPEG_TURBO}] <-) -+ if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then -+ AC_MSG_RESULT(found) -+ JPEG_TURBO_OK="found" -+ else -+ AC_MSG_RESULT(not found) -+ fi -+fi -+ -+ -+if test "${JPEG_TURBO_OK}" = "found"; then -+ saved_CFLAGS="$CFLAGS" -+ saved_LIBS="$LIBS" -+ saved_LDFLAGS="$LDFLAGS" -+ LDFLAGS="-L${JPEG_TURBO}/lib" -+ CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" -+ LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" -+ AC_CHECK_LIB(jpeg, jpeg_start_compress, -+ [ TEMP_LIBS="$LIBS" -+ TEMP_CFLAGS="${CFLAGS}" -+ TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" -+ JPEG_SUPPORT="yes"],,) -+ LIBS="$saved_LIBS" -+ CFLAGS="$saved_CFLAGS" -+ LDFLAGS="$saved_LDFLAGS" -+ JPEG_SUPPORT_TURBO="yes" -+fi -+ -+ -+# -+# Check for the special mmx accelerated jpeg library -+# -+JPEG_MMX="no" -+JPEG_MMX_OK="not_found" -+AC_ARG_WITH(jpeg-mmx, -+[ --with-jpeg-mmx[=DIR] Specify the prefix for the install path for -+ jpeg-mmx for optimized jpeg handling (optional). -+ If this is not specified motion will try to find -+ the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. -+ ], -+JPEG_MMX="$withval" -+) -+ -+# -+# --without-jpeg-mmx or with-jpeg-mmx=no -+# -+ -+if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then -+ AC_MSG_CHECKING(for libjpeg-mmx) -+ AC_MSG_RESULT(skipping) -+elif test "${JPEG_MMX}" = "yes"; then -+ # AUTODETECT STATIC LIB -+ AC_MSG_CHECKING(for libjpeg-mmx autodetecting) -+ -+ if test -f /usr/lib/libjpeg-mmx.a ; then -+ AC_MSG_RESULT(found) -+ JPEG_MMX_OK="found" -+ JPEG_MMX="/usr/lib" -+ elif test -f /usr/local/lib/libjpeg-mmx.a ; then -+ AC_MSG_RESULT(found) -+ JPEG_MMX_OK="found" -+ JPEG_MMX="/usr/local/lib" -+ else -+ AC_MSG_RESULT(not found) -+ fi -+else -+ AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) -+ if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then -+ AC_MSG_RESULT(found) -+ JPEG_MMX_OK="found" -+ else -+ AC_MSG_RESULT(not found) -+ fi -+fi -+ -+if test "${JPEG_MMX_OK}" = "found"; then -+ saved_CFLAGS="$CFLAGS" -+ saved_LIBS="$LIBS" -+ CFLAGS="$CFLAGS -I${JPEG_MMX}" -+ LIBS="$LIBS -L${JPEG_MMX}" -+ AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress, -+ [ TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" -+ TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" -+ JPEG_SUPPORT="yes"],,) -+ LIBS="$saved_LIBS" -+ CFLAGS="$saved_CFLAGS" -+ JPEG_SUPPORT_MMX="yes" -+fi -+ -+# -+# Look for _a_ jpeg lib that will work. -+# -+if test x$JPEG_SUPPORT != xyes ; then -+ # Checks for libraries -+ LDFLAGS=$TEMP_LDFLAGS -+ -+ AC_CHECK_LIB(jpeg, jpeg_set_defaults, [ -+ TEMP_LIBS="$TEMP_LIBS -ljpeg" -+ JPEG_SUPPORT="yes" -+ ], [ -+ echo -+ echo "You do not have libjpeg installed" -+ echo -+ ] -+ ) -+fi -+ -+ -+# -+# Check for libavcodec and libavformat from ffmpeg -+# -+ -+FFMPEG_DIR="yes" -+FFMPEG_OK="no_found" -+FFMPEG_OBJ="" -+AC_ARG_WITH(ffmpeg, -+[ --with-ffmpeg[=DIR] Specify the prefix for the install path for -+ libavcodec/libavformat (part of ffmpeg) be able to -+ encode mpeg movies realtime. -+ If this is not specified motion will try to find -+ the libraries in /usr and /usr/local. -+ ], -+FFMPEG_DIR="$withval" -+) -+ -+# -+# ffmpeg headers custom location -+# -+FFMPEG_HEADERS_DIR="yes" -+AC_ARG_WITH(ffmpeg_headers, -+[ --with-ffmpeg-headers[=DIR] Specify the prefix for ffmpeg headers. -+ ], -+FFMPEG_HEADERS_DIR="$withval" -+) -+ -+# -+# ffmpeg custom extra libraries -+# -+FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " -+AC_ARG_WITH(ffmpeg-libs, -+[ --with-ffmpeg-libs[=libs] Specify the extra libs for ffmpeg -+ ], -+FFMPEG_EXTRALIBS="$withval" -+) -+ -+# -+# --without-ffmpeg or with-ffmpeg=no -+# -+if test "${FFMPEG_DIR}" = "no"; then -+ AC_MSG_CHECKING(for ffmpeg) -+ AC_MSG_RESULT(skipping) -+# -+# with-ffmpeg= or nothing -+# -+else if test "${FFMPEG_DIR}" = "yes"; then -+ # AUTODETECT STATIC/SHARED LIB -+ AC_MSG_CHECKING(for ffmpeg autodetecting libraries) -+ -+ if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then -+ AC_MSG_RESULT(found in /usr/lib64) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib64" -+ FFMPEG_DIR="/usr" -+ elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then -+ AC_MSG_RESULT(found in /usr/lib) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib" -+ FFMPEG_DIR="/usr" -+ elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then -+ AC_MSG_RESULT(found in /usr/local/lib) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/local/lib" -+ FFMPEG_DIR="/usr/local" -+ elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then -+ AC_MSG_RESULT(found in /usr/lib/x86_64-linux-gnu) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" -+ FFMPEG_DIR="/usr" -+ elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then -+ AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="/usr/lib/i386-linux-gnu" -+ FFMPEG_DIR="/usr" -+ else -+ AC_MSG_RESULT(not found) -+ echo "" -+ echo "**********************************************" -+ echo "* libavcodec.a or libavcodec.so or *" -+ echo "* libavformat.a or libavformat.so not found: *" -+ echo "* ALL FFMPEG FEATURES DISABLED *" -+ echo "* *" -+ echo "* Please read the Motion Guide for help: *" -+ echo "* http://motion.sourceforge.net *" -+ echo "**********************************************" -+ echo "" -+ fi -+else -+ AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) -+ if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then -+ AC_MSG_RESULT(found) -+ FFMPEG_OK="found" -+ FFMPEG_LIB="${FFMPEG_DIR}/lib" -+ elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then -+ AC_MSG_RESULT(found) -+ FFMPEG_LIB="${FFMPEG_DIR}" -+ FFMPEG_OK="found" -+ else -+ AC_MSG_RESULT(not found) -+ if test "${FFMPEG_OK}" != "found"; then -+ echo "" -+ echo "**********************************************" -+ echo "* libavcodec.a or libavcodec.so or *" -+ echo "* libavformat.a or libavformat.so not found: *" -+ echo "* ALL FFMPEG FEATURES DISABLED *" -+ echo "* *" -+ echo "* Please read the Motion Guide for help: *" -+ echo "* http://motion.sourceforge.net *" -+ echo "**********************************************" -+ echo "" -+ fi -+ fi -+fi -+ -+ -+# -+# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found -+# -+ -+AVFORMAT_DIR="" -+ -+if test "${FFMPEG_OK}" = "found"; then -+ if test "${FFMPEG_HEADERS_DIR}" = "yes"; then -+ AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_DIR}) -+ AVFORMAT_DIR="${FFMPEG_DIR}" -+ else -+ AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_HEADERS_DIR}) -+ FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" -+ AVFORMAT_DIR="${FFMPEG_DIR}" -+ fi -+ -+ if test -f ${FFMPEG_DIR}/include/avformat.h; then -+ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/avformat.h) -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" -+ elif test -f ${FFMPEG_DIR}/avformat.h; then -+ AC_MSG_RESULT(found ${FFMPEG_DIR}/avformat.h) -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}" -+ AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" -+ elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then -+ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/avformat.h) -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" -+ elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then -+ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" -+ elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then -+ AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" -+ AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" -+ elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then -+ AC_MSG_RESULT(found ${FFMPEG_DIR}/libavformat/avformat.h) -+ FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" -+ AVFORMAT="-I{FFMPEG_DIR}/libavformat" -+ AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" -+ else -+ AC_MSG_RESULT(not found) -+ FFMPEG_OK="no_found" -+ AVFORMAT_DIR="avformat.h" -+ echo "**********************************************" -+ echo "* avformat.h not found: *" -+ echo "* ALL FFMPEG FEATURES DISABLED *" -+ echo "* *" -+ echo "* Please read the Motion Guide for help: *" -+ echo "* http://motion.sourceforge.net *" -+ echo "**********************************************" -+ echo "" -+ fi -+ -+# -+# If ffmpeg libs and headers have been found -+# -+ -+ if test "${FFMPEG_OK}" = "found"; then -+ TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" -+ TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" -+ -+ FFMPEG_OBJ="ffmpeg.o" -+ AC_SUBST(FFMPEG_OBJ) -+ -+ AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ -+ CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" -+ LIBS="$TEMP_LIBS" -+ -+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -+ [ -+ #include <${AVFORMAT_DIR}> -+ URLProtocol test_file_protocol; -+ int main(void){ -+ test_file_protocol.url_read = file_protocol.url_read; -+ return 0; -+ } -+ ]])], -+ [AC_MSG_RESULT(yes)], -+ [ -+ AC_MSG_RESULT(no) -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" -+ ] -+ ) -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+ fi -+fi -+fi -+ -+# Revised RTSP module so that it can be included -+# whether or not FFMPEG is found. -+ -+ RTPS_OBJ="netcam_rtsp.o" -+ AC_SUBST(RTPS_OBJ) -+ -+# -+# Check SQLITE3 -+# -+ -+SQLITE3_SUPPORT="no" -+AC_ARG_WITH(sqlite3, -+ [ --without-sqlite3 Disable sqlite3 support in motion. -+ ], -+ SQLITE3="$withval" -+ # if not given argument, assume standard -+) -+ -+if test "${SQLITE3}" = "no"; then -+ AC_MSG_CHECKING(for sqlite3) -+ AC_MSG_RESULT(skipping) -+else -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ -+ AC_CHECK_LIB(sqlite3, sqlite3_open, -+ [ -+ TEMP_LIBS="$TEMP_LIBS -lsqlite3" -+ SQLITE3_SUPPORT="yes" -+ AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 support]) -+ ] -+ ) -+ -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+fi -+ -+ -+# -+# Check Mysql -+# -+ -+MYSQL="yes" -+MYSQL_SUPPORT="no" -+MYSQL_HEADERS="yes" -+MYSQL_LIBS="yes" -+ -+AC_MSG_CHECKING(for mysql support) -+ -+AC_ARG_WITH(mysql, -+[ --without-mysql Disable mysql support in motion. -+ ], -+MYSQL="$withval" -+# if not given argument, assume standard -+) -+ -+AC_ARG_WITH(mysql-lib, -+[ --with-mysql-lib[=DIR] Normally, configure will scan all possible default -+ installation paths for mysql libs. When it fails, use -+ this command to tell configure where mysql libs -+ installation root directory is. -+ ], -+MYSQL_LIBS="$withval" -+# if not given argument, assume standard -+) -+ -+ -+AC_ARG_WITH(mysql-include, -+[ --with-mysql-include[=DIR] Normally, configure will scan all possible default -+ installation paths for mysql include. When it fails, use -+ this command to tell configure where mysql include -+ installation root directory is. -+ ], -+MYSQL_HEADERS="$withval" -+# if not given argument, assume standard -+) -+ -+ -+if test "${MYSQL}" = "no"; then -+ AC_MSG_RESULT(skipped) -+else -+ AC_MSG_RESULT(testing) -+ # ******* Search mysql headers ******* -+ -+ if test "${MYSQL_HEADERS}" = "yes"; then -+ AC_MSG_CHECKING(autodect mysql headers) -+ # Autodetect -+ for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do -+ # check for plain setups -+ if test -f $w/mysql.h; then -+ MYSQL_INCDIR=$w -+ break -+ fi -+ # check for "/usr/include/" type setups -+ if test -f $w/mysql/mysql.h; then -+ MYSQL_INCDIR=$w/mysql -+ break -+ fi -+ # check for "/usr//include" type setups -+ if test -f $w/mysql/include/mysql.h; then -+ MYSQL_INCDIR=$w/mysql/include -+ break -+ fi -+ done -+ elif test "${MYSQL_HEADERS}" = "no"; then -+ AC_MSG_CHECKING(for mysql headers) -+ AC_MSG_RESULT(skipped) -+ else -+ AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) -+ # Manual detection for -+ if test -f $MYSQL_HEADERS/mysql.h; then -+ MYSQL_INCDIR=$MYSQL_HEADERS -+ fi -+ fi -+ -+ if test -z "$MYSQL_INCDIR" ; then -+ MYSQL_HEADERS="no" -+ AC_MSG_RESULT(not found) -+ echo "Invalid MySQL directory - unable to find mysql.h." -+ else -+ AC_MSG_RESULT($MYSQL_INCDIR yes) -+ MYSQL_HEADERS="yes" -+ fi -+ -+ -+ if test "${MYSQL_HEADERS}" = "yes"; then -+ -+ # ******* Search mysql libs ********* -+ if test "${MYSQL_LIBS}" = "yes"; then -+ AC_MSG_CHECKING(autodect mysql libs) -+ # Autodetect -+ for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do -+ # check for plain setups -+ if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then -+ MYSQL_LIBDIR=$w -+ break -+ fi -+ # check for "/usr/lib/" type setups -+ if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then -+ MYSQL_LIBDIR=$w/mysql -+ break -+ fi -+ # check for "/usr//lib" type setups -+ if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then -+ MYSQL_LIBDIR=$w/mysql/lib -+ break -+ fi -+ done -+ elif test "${MYSQL_LIBS}" = "no"; then -+ AC_MSG_CHECKING(for mysql libs) -+ AC_MSG_RESULT(skipped) -+ else -+ AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) -+ # Manual detection for -+ if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then -+ MYSQL_LIBDIR=$MYSQL_LIBS -+ fi -+ fi -+ -+ -+ if test -z "$MYSQL_LIBDIR" ; then -+ AC_MSG_RESULT(not found) -+ echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." -+ else -+ AC_MSG_RESULT($MYSQL_LIBDIR) -+ #LDFLAGS="-L$MYSQL_LIBDIR" -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ CFLAGS="-I$MYSQL_INCDIR" -+ LIBS="-L$MYSQL_LIBDIR" -+ AC_CHECK_LIB(mysqlclient,mysql_init,[ -+ TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" -+ TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" -+ MYSQL_SUPPORT="yes" -+ AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) -+ ], -+ AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+ fi -+ -+ # end mysql-include , mysql-libs -+ fi -+ -+# end Mysql detection -+fi -+ -+ -+# -+# Check PostgreSQL -+# -+PGSQL="yes" -+PGSQL_SUPPORT="no" -+PGSQL_HEADERS="yes" -+PGSQL_LIBS="yes" -+ -+AC_DEFUN([PGSQL_INC_CHK],[if test -r $i$1/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i$1]) -+ -+AC_ARG_WITH(pgsql, -+[ --without-pgsql Disable PostgreSQL support in motion. -+ ], -+PGSQL="$withval" -+# if not given argument, assume standard -+) -+ -+AC_ARG_WITH(pgsql-lib, -+[ --with-pgsql-lib[=DIR] Normally, configure will scan all possible default -+ installation paths for pgsql libs. When it fails, use -+ this command to tell configure where pgsql libs -+ installation root directory is. -+ ], -+PGSQL_LIBS="$withval" -+# if not given argument, assume standard -+) -+ -+AC_ARG_WITH(pgsql-include, -+[ --with-pgsql-include[=DIR] Normally, configure will scan all possible default -+ installation paths for pgsql include. When it fails, use -+ this command to tell configure where pgsql include -+ installation root directory is. -+ ], -+PGSQL_HEADERS="$withval" -+# if not given argument, assume standard -+) -+ -+AC_MSG_CHECKING(for PostgreSQL) -+ -+if test "${PGSQL}" = "no"; then -+ AC_MSG_RESULT(skipped) -+else -+ AC_MSG_RESULT(testing) -+ -+ # ******* Search pgsql headers ******* -+ if test "${PGSQL_HEADERS}" = "yes"; then -+ -+ AC_MSG_CHECKING(autodect pgsql headers) -+ # Autodetect -+ for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do -+ PGSQL_INC_CHK(/include) -+ el[]PGSQL_INC_CHK(/include/pgsql) -+ el[]PGSQL_INC_CHK(/include/postgresql) -+ fi -+ done -+ -+ elif test "${PGSQL_HEADERS}" = "no"; then -+ AC_MSG_CHECKING(for pgsql headers) -+ AC_MSG_RESULT(skipped) -+ else -+ AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) -+ # Manual detection for -+ if test -f $PGSQL_HEADERS/libpq-fe.h; then -+ PGSQL_INCDIR=$PGSQL_HEADERS -+ fi -+ fi -+ -+ if test -z "$PGSQL_INCDIR" ; then -+ PGSQL_HEADERS="no" -+ AC_MSG_RESULT(not found) -+ echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." -+ else -+ AC_MSG_RESULT(yes [$PGSQL_INCDIR]) -+ PGSQL_HEADERS="yes" -+ fi -+ -+ -+ if test "${PGSQL_HEADERS}" = "yes"; then -+ -+ # ******* Search pgsql libs ********* -+ if test "${PGSQL_LIBS}" = "yes"; then -+ AC_MSG_CHECKING(autodect pgsql libs) -+ # Autodetect -+ PGSQL_INCLUDE="-I$PGSQL_INCDIR" -+ PGSQL_LIBDIR=$PGSQL_DIR/lib -+ -+ if test -f /usr/lib64/libpq.so ; then -+ PGSQL_LIBDIR=/usr/lib64 -+ elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then -+ PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql -+ elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then -+ PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql -+ elif test -f $PGSQL_DIR/lib/libpq.so ; then -+ PGSQL_LIBDIR=$PGSQL_DIR/lib -+ else -+ PGSQL_LIBDIR="" -+ fi -+ -+ AC_MSG_RESULT($PGSQL_LIBDIR) -+ -+ elif test "${PGSQL_LIBS}" = "no"; then -+ AC_MSG_CHECKING(for pgsql libs) -+ AC_MSG_RESULT(skipped) -+ else -+ AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) -+ # Manual detection for -+ if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then -+ PGSQL_LIBDIR=$PGSQL_LIBS -+ fi -+ fi -+ -+ -+ if test -z "$PGSQL_LIBDIR" ; then -+ AC_MSG_RESULT(not found) -+ echo "Invalid PostgreSQL directory [$PGSQL_LIBDIR] - unable to find libpq.a or libpq.so." -+ else -+ #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" -+ saved_CFLAGS=$CFLAGS -+ saved_LIBS=$LIBS -+ CFLAGS="-I$PGSQL_INCDIR" -+ LIBS="-L$PGSQL_LIBDIR" -+ AC_CHECK_LIB(pq, PQconnectStart, [ -+ PGSQL_SUPPORT="yes" -+ TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" -+ TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" -+ AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) -+ ], -+ AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) -+ LDFLAGS="" -+ CFLAGS=$saved_CFLAGS -+ LIBS=$saved_LIBS -+ fi -+ -+ fi # end pgsql-include , pgsql-libs -+ -+# end PostgreSQL detection -+fi -+ -+ -+#Checks for header files. -+AC_HEADER_STDC -+AC_CHECK_HEADERS(stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h) -+ -+AC_CHECK_FUNCS(get_current_dir_name) -+ -+# Check if v4l2 is available -+SUPPORTED_V4L2=false -+SUPPORTED_V4L2_old=false -+ -+if test "${V4L}" = "no"; then -+ AC_MSG_CHECKING(for V42L support) -+ AC_MSG_RESULT(skipping) -+else -+ AC_CHECK_TYPE([struct v4l2_buffer], -+ [SUPPORTED_V4L2=true], -+ [SUPPORTED_V4L2=false], -+ [#include -+ #include ]) -+ -+ AC_MSG_CHECKING(for V42L support) -+ if test x$SUPPORTED_V4L2 = xtrue; then -+ AC_MSG_RESULT(yes) -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" -+ else -+ AC_MSG_RESULT(no) -+ fi -+ -+ # linux/videodev.h doesn't include videodev2.h -+ if test x$SUPPORTED_V4L2 = xfalse; then -+ AC_MSG_CHECKING(for V42L *old* support) -+ AC_MSG_RESULT(testing) -+ AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) -+ fi -+ -+ -+ if test x$SUPPORTED_V4L2_old = xtrue; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" -+ SUPPORTED_V4L2=true -+ fi -+ -+fi -+ -+ -+# Check sizes of integer types -+AC_CHECK_SIZEOF(short) -+AC_CHECK_SIZEOF(int) -+AC_CHECK_SIZEOF(long int) -+AC_CHECK_SIZEOF(long long) -+AC_CHECK_SIZEOF(int *) -+AC_CHECK_SIZEOF(void *) -+ -+if test "$ac_cv_sizeof_short" = "4"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" -+else -+ if test "$ac_cv_sizeof_int" = "4"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" -+ else -+ if test "$ac_cv_sizeof_long_int" = "4"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" -+ fi -+ fi -+fi -+ -+ -+OPTIMIZECPU="yes" -+ -+AC_ARG_WITH(optimizecpu, -+[ --without-optimizecpu Exclude autodetecting platform and cpu type. -+ This will disable the compilation of gcc -+ optimizing code by platform and cpu. -+ ], -+OPTIMIZECPU="$withval" -+) -+ -+DEVELOPER_FLAGS="no" -+ -+AC_ARG_WITH(developer-flags, -+[ --with-developer-flags Causes practically all of the possible gcc -+ warning flags to be set. This may produce -+ a large amount of warnings.], -+DEVELOPER_FLAGS="$withval" -+) -+ -+# Checks for typedefs, structures, and compiler characteristics. -+AC_C_CONST -+ -+if test "${FreeBSD}" != ""; then -+ OPTIMIZECPU="" -+fi -+ -+if test "${OPTIMIZECPU}" = "yes"; then -+ -+# Try to autodetect cpu type -+CPU_NAME="unknown" -+CPU_TYPE="unknown" -+if test -e "/proc/cpuinfo" ; then -+ intel[[30]]="-march=i386" -+ intel[[32]]="-march=i386" -+ intel[[34]]="-march=i386" -+ intel[[40]]="-march=i486" -+ intel[[41]]="-march=i486" -+ intel[[42]]="-march=i486" -+ intel[[43]]="-march=i486" -+ intel[[44]]="-march=i486" -+ intel[[45]]="-march=i486" -+ intel[[47]]="-march=i486" -+ intel[[48]]="-march=i486" -+ intel[[51]]="-march=pentium" -+ intel[[52]]="-march=pentium" -+ intel[[54]]="-march=pentium-mmx" -+ intel[[56]]="-march=pentium-mmx" -+ intel[[61]]="-march=pentiumpro" -+ intel[[63]]="-march=pentium2" -+ intel[[65]]="-march=pentium2" -+ intel[[66]]="-march=pentium2" -+ intel[[67]]="-march=pentium3" -+ intel[[68]]="-march=pentium3" -+ intel[[610]]="-march=pentium3" -+ intel[[611]]="-march=pentium3" -+ intel[[150]]="-march=pentium4" -+ intel[[151]]="-march=pentium4" -+ intel[[152]]="-march=pentium4" -+ intel[[154]]="-march=pentium4" -+ intel[[614]]="-march=prescott" -+ intel[[628]]="-march=core2" -+ amd[[50]]="-march=i586" -+ amd[[51]]="-march=i586" -+ amd[[52]]="-march=i586" -+ amd[[53]]="-march=i586" -+ amd[[56]]="-march=k6" -+ amd[[57]]="-march=k6" -+ amd[[58]]="-march=k6-2" -+ amd[[510]]="-march=k6-2" -+ amd[[59]]="-march=k6-3" -+ amd[[513]]="-march=k6-3" -+ amd[[61]]="-march=athlon" -+ amd[[62]]="-march=athlon" -+ amd[[63]]="-march=athlon" -+ amd[[64]]="-march=athlon" -+ amd[[66]]="-march=athlon" -+ amd[[67]]="-march=athlon" -+ amd[[68]]="-march=athlon" -+ amd[[610]]="-march=athlon" -+ amd[[158]]="-march=athlon-xp" -+ amd[[154]]="-march=k8" -+ amd[[155]]="-march=athlon64" -+ amd[[1543]]="-march=athlon64" -+ amd[[1544]]="-march=athlon64" -+ amd[[1565]]="-march=opteron" -+ amd[[1572]]="-march=k8" -+ via[[67]]="-march=c3" -+ via[[68]]="-march=c3" -+ via[[69]]="-march=i686" -+ via[[610]]="-march=i686" -+ -+ CPU_TYPE="known" -+ CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` -+ CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` -+ CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` -+ CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` -+ CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` -+ CPU_FAMILY=${CPU_FAMILY#*: } -+ CPU_MODEL=${CPU_MODEL#*: } -+ CPU_NAME=${CPU_NAME#*: } -+ CPU_FLAGS=${CPU_FLAGS#*: } -+ CPU_VENDOR=${CPU_VENDOR#*: } -+ if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then -+ CPU_OPTIONS=${intel[[$CPU_FAMILY$CPU_MODEL]]} -+ fi -+ if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then -+ CPU_OPTIONS=${amd[[$CPU_FAMILY$CPU_MODEL]]} -+ fi -+ if test "x${CPU_VENDOR}" = "xCentaurHauls"; then -+ CPU_OPTIONS=${via[[$CPU_FAMILY$CPU_MODEL]]} -+ fi -+ if test "x${CPU_OPTIONS}" = "x" ; then -+ CPU_TYPE="unknown" -+ fi -+ CPU_EXT="" -+ for i in $CPU_FLAGS ; do -+ case $i in -+ fpu) -+ CPU_FPU="-mfpmath=387" -+ ;; -+ mmx) -+ CPU_EXT="$CPU_EXT -mmmx" -+ ;; -+ sse) -+ CPU_FPU="-mfpmath=sse -msse" -+ ;; -+ sse2) -+ CPU_FPU="-mfpmath=sse -msse2" -+ ;; -+ sse3) -+ CPU_FPU="-msse3" -+ ;; -+ ssse3) -+ CPU_FPU="-mfpmath=sse -msse2 -mssse3" -+ ;; -+ 3dnow) -+ CPU_EXT="$CPU_EXT -m3dnow" -+ ;; -+ esac -+ done -+ CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" -+fi -+if test "x${CPU_TYPE}" = "xunknown"; then -+ CPU_TYPE=`( uname -p ) 2>&1` -+ case $CPU_TYPE in -+ i386) -+ CPU_OPTIONS="-march=i386" -+ ;; -+ i486) -+ CPU_OPTIONS="-march=i486" -+ ;; -+ Pentium2) -+ CPU_OPTIONS="-march=pentium2" -+ ;; -+ Pentiumpro) -+ CPU_OPTIONS="-march=pentiumpro" -+ ;; -+ Pentium*) -+ CPU_OPTIONS="-march=pentium" -+ ;; -+ k6) -+ CPU_OPTIONS="-march=k6" -+ ;; -+ k6-2) -+ CPU_OPTIONS="-march=k6-2" -+ ;; -+ k6-3) -+ CPU_OPTIONS="-march=k6-3" -+ ;; -+ "VIA C3 Ezra") -+ CPU_OPTIONS="-march=c3" -+ CPU_TYPE="known" -+ ;; -+ *) -+ CPU_OPTIONS="" -+ CPU_TYPE="unknown" -+ ;; -+ esac -+ if test "x${CPU_TYPE}" = "xunknown"; then -+ CPU_TYPE=`( uname -m ) 2>&1` -+ case $CPU_TYPE in -+ i386) -+ CPU_OPTIONS="-march=i386" -+ ;; -+ i486) -+ CPU_OPTIONS="-march=i486" -+ ;; -+ i586) -+ CPU_OPTIONS="-march=i586" -+ ;; -+ i686) -+ CPU_OPTIONS="-march=i686" -+ ;; -+ Pentium2) -+ CPU_OPTIONS="-march=pentium2" -+ ;; -+ Pentiumpro) -+ CPU_OPTIONS="-march=pentiumpro" -+ ;; -+ k6) -+ CPU_OPTIONS="-march=k6" -+ ;; -+ k6-2) -+ CPU_OPTIONS="-march=k6-2" -+ ;; -+ k6-3) -+ CPU_OPTIONS="-march=k6-3" -+ ;; -+ *) -+ CPU_OPTIONS="-march=native -mtune=native" -+ ;; -+ esac -+ fi -+fi -+echo "Detected CPU: $CPU_NAME" -+# Now we check if the compiler supports the detected cpu -+COMPILER=$CC -+for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do -+ test "$I" && break -+done -+TMPC="$I/cpu_test-$RANDOM-$$.c" -+TMPO="$I/cpu_test-$RANDOM-$$.o" -+cat > $TMPC << EOF -+int main(void) { return 0; } -+EOF -+( $COMPILER $CPU_OPTIONS -o $TMPO $TMPC ) 2>&1 -+TMP="$?" -+rm -f $TMPO -+rm -f $TMPC -+ -+ -+if test "x${TMP}" = "x1" ; then -+ CPU_OPTIONS="" -+ echo "No CPU optimizations will be added" -+else -+ echo "CPU optimization: $CPU_OPTIONS" -+fi -+ -+else -+ CPU_OPTIONS="" -+fi -+ -+ -+AC_MSG_CHECKING(for bswap instruction) -+AC_LINK_IFELSE([ -+ AC_LANG_PROGRAM([ ], -+ [unsigned int __x=0; -+ register unsigned int __v; -+ __asm("bswap %0" : "=r" (__v) : "0" (__x));]) -+ ], -+ [ -+ TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" -+ AC_MSG_RESULT(yes) -+ ], -+ [ -+ AC_MSG_RESULT(no) -+ ]) -+ -+ -+if test "${DEVELOPER_FLAGS}" = "yes"; then -+ TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" -+fi -+ -+CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" -+ -+LIBS="${TEMP_LIBS}" -+LDFLAGS="${TEMP_LDFLAGS}" -+ -+ -+# -+# Add the right exec path for rc scripts -+# -+if test $prefix = "NONE";then -+ BIN_PATH="$ac_default_prefix" -+ if test $exec_prefix = "NONE"; then -+ BIN_PATH="$BIN_PATH/bin" -+ else -+ BIN_PATH="$BIN_PATH/$bindir" -+ fi -+else -+ if test $exec_prefix = "NONE";then -+ BIN_PATH="$prefix/bin" -+ else -+ BIN_PATH="$prefix/$bindir" -+ fi -+fi -+ -+ -+AC_SUBST(BIN_PATH) -+ -+AC_CONFIG_FILES([ -+thread1.conf -+thread2.conf -+thread3.conf -+thread4.conf -+motion-dist.conf -+motion.init-FreeBSD.sh -+motion.init-Debian -+motion.init-Fedora -+motion.spec -+Makefile -+]) -+AC_OUTPUT -+ -+echo "" -+echo " **************************" -+echo " Configure status " -+echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" -+echo " **************************" -+echo -+ -+ -+if test "${Darwin}" != ""; then -+ echo "OS : Darwin" -+elif test "${FreeBSD}" != ""; then -+ echo "OS : *BSD" -+else -+ echo "OS : Linux" -+fi -+ -+if test "${PTHREAD_SUPPORT}" = "yes"; then -+ echo "pthread support: Yes" -+else -+ echo "pthread support: No" -+ echo "**********************************************" -+ echo "** Fatal Error YOU MUST HAVE pthread Support *" -+ echo "**********************************************" -+fi -+ -+ -+if test "${JPEG_SUPPORT_TURBO}" = "yes"; then -+ echo "jpeg turbo support: Yes" -+elif test "${JPEG_SUPPORT_MMX}" = "yes"; then -+ echo "jpeg-mmx support: Yes" -+elif test "${JPEG_SUPPORT}" = "yes"; then -+ echo "jpeg support: Yes" -+else -+ echo "jpeg support: No" -+ echo "**********************************************" -+ echo "** Fatal Error YOU MUST HAVE jpeg Support ***" -+ echo "**********************************************" -+fi -+ -+if test "${FreeBSD}" != ""; then -+ if test "${BKTR}" = "yes"; then -+ echo "BKTR included: Yes" -+ else -+ echo "BKTR included: No" -+ fi -+ -+ if test "${PWCBSD}" = "yes"; then -+ echo "PWCBSD include: Yes" -+ else -+ echo "PWCBSD include: No" -+ fi -+ -+else -+ if test "${V4L}" = "yes"; then -+ echo "V4L support: Yes" -+ else -+ echo "V4L support: No" -+ fi -+ -+ if test x$SUPPORTED_V4L2 = xtrue; then -+ echo "V4L2 support: Yes" -+ else -+ echo "V4L2 support: No" -+ fi -+fi -+ -+if test "${SDL_SUPPORT}" = "yes"; then -+ echo "SDL support: Yes" -+else -+ echo "SDL support: No" -+fi -+ -+if test "${FFMPEG_OK}" = "found"; then -+ echo "FFmpeg support: Yes" -+else -+ echo "FFmpeg support: No" -+fi -+ -+if test "${SQLITE3_SUPPORT}" = "yes"; then -+ echo "SQLite3 support: Yes" -+else -+ echo "SQLite3 support: No" -+fi -+ -+if test "${MYSQL_SUPPORT}" = "yes"; then -+ echo "MYSQL support: Yes" -+else -+ echo "MYSQL support: No" -+fi -+ -+if test "${PGSQL_SUPPORT}" = "yes"; then -+ echo "PostgreSQL support: Yes" -+else -+ echo "PostgreSQL support: No" -+fi -+echo -+echo "CFLAGS: $CFLAGS" -+echo "LIBS: $LIBS" -+echo "LDFLAGS: $LDFLAGS" -+echo -+echo "Install prefix: $prefix" -+echo ---- motion-3.2.12.orig/draw.c -+++ motion-3.2.12/draw.c -@@ -12,7 +12,7 @@ - #include - #include "motion.h" - --/* highest ascii value is 126 (~) */ -+/* Highest ascii value is 126 (~) */ - #define ASCII_MAX 127 - - unsigned char *small_char_arr_ptr[ASCII_MAX]; -@@ -1075,8 +1075,10 @@ struct draw_char draw_table[]= { - struct big_char big_table[sizeof(draw_table) / sizeof(struct draw_char)]; - - #define NEWLINE "\\n" -- --static int draw_textn (unsigned char *image, int startx, int starty, int width, const char *text, int len, unsigned short int factor) -+/** -+ * draw_textn -+ */ -+static int draw_textn(unsigned char *image, unsigned int startx, unsigned int starty, unsigned int width, const char *text, int len, unsigned int factor) - { - int pos, x, y, line_offset, next_char_offs; - unsigned char *image_ptr, *char_ptr, **char_arr_ptr; -@@ -1084,9 +1086,6 @@ static int draw_textn (unsigned char *im - if (startx > width / 2) - startx -= len * (6 * (factor + 1)); - -- if (startx < 0) -- startx = 0; -- - if (startx + len * 6 * (factor + 1) >= width) - len = (width-startx-1)/(6*(factor+1)); - -@@ -1098,10 +1097,19 @@ static int draw_textn (unsigned char *im - char_arr_ptr = factor ? big_char_arr_ptr : small_char_arr_ptr; - - for (pos = 0; pos < len; pos++) { -- char_ptr = char_arr_ptr[(int)text[pos]]; -+ int pos_check = (int)text[pos]; -+ -+ char_ptr = char_arr_ptr[pos_check]; - - for (y = 8 * (factor + 1); y--;) { - for (x = 7 * (factor + 1); x--;) { -+ -+ if (pos_check < 0) { -+ image_ptr++; -+ char_ptr++; -+ continue; -+ } -+ - switch(*char_ptr) { - case 1: - *image_ptr = 0; -@@ -1124,13 +1132,16 @@ static int draw_textn (unsigned char *im - return 0; - } - --int draw_text (unsigned char *image, int startx, int starty, int width, const char *text, unsigned short int factor) -+/** -+ * draw_text -+ */ -+int draw_text(unsigned char *image, unsigned int startx, unsigned int starty, unsigned int width, const char *text, unsigned int factor) - { - int num_nl = 0; - const char *end, *begin; - const int line_space = (factor + 1) * 9; - -- /* Count the number of newlines in "text" so we scroll it up the image */ -+ /* Count the number of newlines in "text" so we scroll it up the image. */ - end = text; - - while ((end = strstr(end, NEWLINE))) { -@@ -1139,6 +1150,7 @@ int draw_text (unsigned char *image, int - } - - starty -= line_space * num_nl; -+ - begin = end = text; - - while ((end = strstr(end, NEWLINE))) { -@@ -1155,6 +1167,9 @@ int draw_text (unsigned char *image, int - return 0; - } - -+/** -+ * initialize_chars -+ */ - int initialize_chars(void) - { - unsigned int i, x, y; -@@ -1167,19 +1182,19 @@ int initialize_chars(void) - big_table[i].ascii = draw_table[i].ascii; - - for(x = 0; x < 14; x++) { -- for(y = 0; y < 16; y++) -+ for(y = 0; y < 16; y++) - big_table[i].pix[y][x] = draw_table[i].pix[y / 2][x / 2]; - - } - } - -- /* first init all char ptr's to a space character */ -+ /* First init all char ptr's to a space character. */ - for (i = 0; i < ASCII_MAX; i++) { - small_char_arr_ptr[i] = &draw_table[0].pix[0][0]; - big_char_arr_ptr[i] = &big_table[0].pix[0][0]; - } - -- /* build [big_]char_arr_ptr table to point to each available ascii */ -+ /* Build [big_]char_arr_ptr table to point to each available ascii. */ - for (i = 0; i < draw_table_size; i++) { - small_char_arr_ptr[(int)draw_table[i].ascii] = &draw_table[i].pix[0][0]; - big_char_arr_ptr[(int)draw_table[i].ascii] = &big_table[i].pix[0][0]; ---- motion-3.2.12.orig/event.c -+++ motion-3.2.12/event.c -@@ -6,34 +6,33 @@ - Copyright Jeroen Vreeken, 2002 - This software is distributed under the GNU Public License Version 2 - see also the file 'COPYING'. -- - */ - - #include "ffmpeg.h" /* must be first to avoid 'shadow' warning */ --#include "picture.h" /* already includes motion.h */ -+#include "picture.h" /* already includes motion.h */ - #include "event.h" --#if !defined(BSD) -+#if (!defined(BSD)) - #include "video.h" - #endif - --/* -- * Various functions (most doing the actual action) -- */ -+/* Various functions (most doing the actual action) */ - --/* Execute 'command' with 'arg' as its argument. -- * if !arg command is started with no arguments -- * Before we call execl we need to close all the file handles -- * that the fork inherited from the parent in order not to pass -- * the open handles on to the shell -+/** -+ * exec_command -+ * Execute 'command' with 'arg' as its argument. -+ * if !arg command is started with no arguments -+ * Before we call execl we need to close all the file handles -+ * that the fork inherited from the parent in order not to pass -+ * the open handles on to the shell - */ - static void exec_command(struct context *cnt, char *command, char *filename, int filetype) - { - char stamp[PATH_MAX]; - mystrftime(cnt, stamp, sizeof(stamp), command, &cnt->current_image->timestamp_tm, filename, filetype); -- -+ - if (!fork()) { - int i; -- -+ - /* Detach from parent */ - setsid(); - -@@ -43,27 +42,30 @@ static void exec_command(struct context - */ - for (i = getdtablesize(); i > 2; --i) - close(i); -- -+ - execl("/bin/sh", "sh", "-c", stamp, " &", NULL); - - /* if above function succeeds the program never reach here */ -- motion_log(LOG_ERR, 1, "Unable to start external command '%s'", stamp); -+ MOTION_LOG(ALR, TYPE_EVENTS, SHOW_ERRNO, "%s: Unable to start external command '%s'", -+ stamp); - - exit(1); -- } else if (cnt->conf.setup_mode) { -- motion_log(-1, 0, "Executing external command '%s'", stamp); -- } -+ } -+ -+ MOTION_LOG(DBG, TYPE_EVENTS, NO_ERRNO, "%s: Executing external command '%s'", -+ stamp); - } - --/* -- * Event handlers -+/* -+ * Event handlers - */ - - static void event_newfile(struct context *cnt ATTRIBUTE_UNUSED, - int type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, - char *filename, void *ftype, struct tm *tm ATTRIBUTE_UNUSED) - { -- motion_log(-1, 0, "File of type %ld saved to: %s", (unsigned long)ftype, filename); -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: File of type %ld saved to: %s", -+ (unsigned long)ftype, filename); - } - - -@@ -77,17 +79,19 @@ static void event_beep(struct context *c - printf("\a"); - } - --/* on_picture_save_command handles both on_picture_save and on_movie_start -- * If arg = FTYPE_IMAGE_ANY on_picture_save script is executed -- * If arg = FTYPE_MPEG_ANY on_movie_start script is executed -- * The scripts are executed with the filename of picture or movie appended -- * to the config parameter. -+/** -+ * on_picture_save_command -+ * handles both on_picture_save and on_movie_start -+ * If arg = FTYPE_IMAGE_ANY on_picture_save script is executed -+ * If arg = FTYPE_MPEG_ANY on_movie_start script is executed -+ * The scripts are executed with the filename of picture or movie appended -+ * to the config parameter. - */ - static void on_picture_save_command(struct context *cnt, - int type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, - char *filename, void *arg, struct tm *tm ATTRIBUTE_UNUSED) - { -- int filetype = (unsigned long)arg; -+ int filetype = (unsigned long)arg; - - if ((filetype & FTYPE_IMAGE_ANY) != 0 && cnt->conf.on_picture_save) - exec_command(cnt, cnt->conf.on_picture_save, filename, filetype); -@@ -105,7 +109,7 @@ static void on_motion_detected_command(s - exec_command(cnt, cnt->conf.on_motion_detected, NULL, 0); - } - --#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) - - static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *dummy ATTRIBUTE_UNUSED, -@@ -114,66 +118,102 @@ static void event_sqlnewfile(struct cont - int sqltype = (unsigned long)arg; - - /* Only log the file types we want */ -- if (!(cnt->conf.mysql_db || cnt->conf.pgsql_db) || (sqltype & cnt->sql_mask) == 0) -+ if (!(cnt->conf.database_type) || (sqltype & cnt->sql_mask) == 0) - return; - -- /* We place the code in a block so we only spend time making space in memory -+ /* -+ * We place the code in a block so we only spend time making space in memory - * for the sqlquery and timestr when we actually need it. - */ - { - char sqlquery[PATH_MAX]; -- -- mystrftime(cnt, sqlquery, sizeof(sqlquery), cnt->conf.sql_query, -- &cnt->current_image->timestamp_tm, filename, sqltype); -- --#ifdef HAVE_MYSQL -- if (cnt->conf.mysql_db) { -- int ret; - -- ret = mysql_query(cnt->database, sqlquery); -+ mystrftime(cnt, sqlquery, sizeof(sqlquery), cnt->conf.sql_query, -+ &cnt->current_image->timestamp_tm, filename, sqltype); - -- if (ret != 0) { -+#ifdef HAVE_MYSQL -+ if (!strcmp(cnt->conf.database_type, "mysql")) { -+ if (mysql_query(cnt->database, sqlquery) != 0) { - int error_code = mysql_errno(cnt->database); -- -- motion_log(LOG_ERR, 1, "Mysql query failed %s error code %d", -+ -+ MOTION_LOG(ERR, TYPE_DB, SHOW_ERRNO, "%s: Mysql query failed %s error code %d", - mysql_error(cnt->database), error_code); - /* Try to reconnect ONCE if fails continue and discard this sql query */ - if (error_code >= 2000) { -+ // Close connection before start a new connection -+ mysql_close(cnt->database); -+ - cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); - mysql_init(cnt->database); - -- if (!mysql_real_connect(cnt->database, cnt->conf.mysql_host, -- cnt->conf.mysql_user, cnt->conf.mysql_password, -- cnt->conf.mysql_db, 0, NULL, 0)) { -- motion_log(LOG_ERR, 0, "Cannot reconnect to MySQL database %s on host %s with user %s", -- cnt->conf.mysql_db, cnt->conf.mysql_host, cnt->conf.mysql_user); -- motion_log(LOG_ERR, 0, "MySQL error was %s", mysql_error(cnt->database)); -- } else { -- mysql_query(cnt->database, sqlquery); -- } -- } -- -- } -+ if (!mysql_real_connect(cnt->database, cnt->conf.database_host, -+ cnt->conf.database_user, cnt->conf.database_password, -+ cnt->conf.database_dbname, 0, NULL, 0)) { -+ MOTION_LOG(ALR, TYPE_DB, NO_ERRNO, "%s: Cannot reconnect to MySQL" -+ " database %s on host %s with user %s MySQL error was %s", -+ cnt->conf.database_dbname, -+ cnt->conf.database_host, cnt->conf.database_user, -+ mysql_error(cnt->database)); -+ } else { -+ 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_my = 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_my); -+ } -+ } -+ } -+ } - } - #endif /* HAVE_MYSQL */ - - #ifdef HAVE_PGSQL -- if (cnt->conf.pgsql_db) { -+ if (!strcmp(cnt->conf.database_type, "postgresql")) { - PGresult *res; - - res = PQexec(cnt->database_pg, sqlquery); - -- if (PQresultStatus(res) != PGRES_COMMAND_OK) { -- motion_log(LOG_ERR, 1, "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 */ - -+#ifdef HAVE_SQLITE3 -+ if ((!strcmp(cnt->conf.database_type, "sqlite3")) && (cnt->conf.sqlite3_db)) { -+ int res; -+ char *errmsg = 0; -+ res = sqlite3_exec(cnt->database_sqlite3, sqlquery, NULL, 0, &errmsg); -+ if (res != SQLITE_OK ) { -+ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: SQLite error was %s", -+ errmsg); -+ sqlite3_free(errmsg); -+ } -+ } -+#endif /* HAVE_SQLITE3 */ - } - } - --#endif /* defined HAVE_MYSQL || defined HAVE_PGSQL */ -+#endif /* defined HAVE_MYSQL || defined HAVE_PGSQL || defined(HAVE_SQLITE3) */ - - static void on_area_command(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *dummy1 ATTRIBUTE_UNUSED, -@@ -202,41 +242,50 @@ static void on_event_end_command(struct - exec_command(cnt, cnt->conf.on_event_end, NULL, 0); - } - --static void event_stop_webcam(struct context *cnt, int type ATTRIBUTE_UNUSED, -+static void event_stop_stream(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *dummy1 ATTRIBUTE_UNUSED, - char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, - struct tm *tm ATTRIBUTE_UNUSED) - { -- if ((cnt->conf.webcam_port) && (cnt->webcam.socket != -1)) -- webcam_stop(cnt); -- -+ if ((cnt->conf.stream_port) && (cnt->stream.socket != -1)) -+ stream_stop(cnt); - } - --static void event_webcam_put(struct context *cnt, int type ATTRIBUTE_UNUSED, -+static void event_stream_put(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, - void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) - { -- if (cnt->conf.webcam_port) -- webcam_put(cnt, img); -+ if (cnt->conf.stream_port) -+ stream_put(cnt, img); - } - --#if !defined(WITHOUT_V4L) && !defined(BSD) -+#ifdef HAVE_SDL -+static void event_sdl_put(struct context *cnt, int type ATTRIBUTE_UNUSED, -+ unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, -+ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) -+{ -+ sdl_put(img, cnt->imgs.width, cnt->imgs.height); -+} -+#endif -+ -+ -+#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) - static void event_vid_putpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *img, char *dummy ATTRIBUTE_UNUSED, void *devpipe, - struct tm *tm ATTRIBUTE_UNUSED) - { - if (*(int *)devpipe >= 0) { - if (vid_putpipe(*(int *)devpipe, img, cnt->imgs.size) == -1) -- motion_log(LOG_ERR, 1, "Failed to put image into video pipe"); -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Failed to put image into video pipe"); - } - } --#endif /* WITHOUT_V4L && !BSD */ -- -+#endif /* !WITHOUT_V4L && !BSD */ - - const char *imageext(struct context *cnt) - { -- if (cnt->conf.ppm) -+ if (cnt->imgs.picture_type == IMAGE_TYPE_PPM) - return "ppm"; -+ - return "jpg"; - } - -@@ -248,17 +297,20 @@ static void event_image_detect(struct co - char filename[PATH_MAX]; - - if (cnt->new_img & NEWIMG_ON) { -- const char *jpegpath; -+ const char *imagepath; - -- /* conf.jpegpath would normally be defined but if someone deleted it by control interface -- it is better to revert to the default than fail */ -- if (cnt->conf.jpegpath) -- jpegpath = cnt->conf.jpegpath; -+ /* -+ * conf.imagepath would normally be defined but if someone deleted it by control interface -+ * it is better to revert to the default than fail -+ */ -+ if (cnt->conf.imagepath) -+ imagepath = cnt->conf.imagepath; - else -- jpegpath = DEF_JPEGPATH; -- -- mystrftime(cnt, filename, sizeof(filename), jpegpath, currenttime_tm, NULL, 0); -+ imagepath = DEF_IMAGEPATH; -+ -+ mystrftime(cnt, filename, sizeof(filename), imagepath, currenttime_tm, NULL, 0); - snprintf(fullfilename, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filename, imageext(cnt)); -+ - put_picture(cnt, fullfilename, newimg, FTYPE_IMAGE); - } - } -@@ -267,22 +319,24 @@ static void event_imagem_detect(struct c - unsigned char *newimg ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, - void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) - { -- struct config *conf=&cnt->conf; -+ struct config *conf = &cnt->conf; - char fullfilenamem[PATH_MAX]; - char filename[PATH_MAX]; - char filenamem[PATH_MAX]; - - if (conf->motion_img) { -- const char *jpegpath; -+ const char *imagepath; - -- /* conf.jpegpath would normally be defined but if someone deleted it by control interface -- it is better to revert to the default than fail */ -- if (cnt->conf.jpegpath) -- jpegpath = cnt->conf.jpegpath; -+ /* -+ * conf.imagepath would normally be defined but if someone deleted it by control interface -+ * it is better to revert to the default than fail -+ */ -+ if (cnt->conf.imagepath) -+ imagepath = cnt->conf.imagepath; - else -- jpegpath = DEF_JPEGPATH; -- -- mystrftime(cnt, filename, sizeof(filename), jpegpath, currenttime_tm, NULL, 0); -+ imagepath = DEF_IMAGEPATH; -+ -+ mystrftime(cnt, filename, sizeof(filename), imagepath, currenttime_tm, NULL, 0); - /* motion images gets same name as normal images plus an appended 'm' */ - snprintf(filenamem, PATH_MAX, "%sm", filename); - snprintf(fullfilenamem, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filenamem, imageext(cnt)); -@@ -302,25 +356,30 @@ static void event_image_snapshot(struct - char filepath[PATH_MAX]; - char linkpath[PATH_MAX]; - const char *snappath; -- /* conf.snappath would normally be defined but if someone deleted it by control interface -- it is better to revert to the default than fail */ -+ /* -+ * conf.snappath would normally be defined but if someone deleted it by control interface -+ * it is better to revert to the default than fail -+ */ - if (cnt->conf.snappath) - snappath = cnt->conf.snappath; - else - snappath = DEF_SNAPPATH; -- -+ - mystrftime(cnt, filepath, sizeof(filepath), snappath, currenttime_tm, NULL, 0); - snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); - snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); - put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); - -- /* Update symbolic link *after* image has been written so that -- the link always points to a valid file. */ -+ /* -+ * Update symbolic link *after* image has been written so that -+ * the link always points to a valid file. -+ */ - snprintf(linkpath, PATH_MAX, "%s/lastsnap.%s", cnt->conf.filepath, imageext(cnt)); - remove(linkpath); - - if (symlink(filename, linkpath)) { -- motion_log(LOG_ERR, 1, "Could not create symbolic link [%s]", filename); -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Could not create symbolic link [%s]", -+ filename); - return; - } - } else { -@@ -340,13 +399,6 @@ static void event_camera_lost(struct con - exec_command(cnt, cnt->conf.on_camera_lost, NULL, 0); - } - --#ifdef HAVE_FFMPEG --static void grey2yuv420p(unsigned char *u, unsigned char *v, int width, int height) --{ -- memset(u, 128, width * height / 4); -- memset(v, 128, width * height / 4); --} -- - static void on_movie_end_command(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *dummy ATTRIBUTE_UNUSED, char *filename, - void *arg, struct tm *tm ATTRIBUTE_UNUSED) -@@ -357,6 +409,134 @@ static void on_movie_end_command(struct - exec_command(cnt, cnt->conf.on_movie_end, filename, filetype); - } - -+static void event_extpipe_end(struct context *cnt, int type ATTRIBUTE_UNUSED, -+ unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, -+ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) -+{ -+ if (cnt->extpipe_open) { -+ cnt->extpipe_open = 0; -+ fflush(cnt->extpipe); -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: CLOSING: extpipe file desc %d, error state %d", -+ fileno(cnt->extpipe), ferror(cnt->extpipe)); -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: pclose return: %d", -+ pclose(cnt->extpipe)); -+ event(cnt, EVENT_FILECLOSE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL); -+ } -+} -+ -+static void event_create_extpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, -+ unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, -+ void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) -+{ -+ if ((cnt->conf.useextpipe) && (cnt->conf.extpipe)) { -+ char stamp[PATH_MAX] = ""; -+ const char *moviepath; -+ FILE *fd_dummy = NULL; -+ -+ /* -+ * conf.mpegpath would normally be defined but if someone deleted it by control interface -+ * it is better to revert to the default than fail -+ */ -+ if (cnt->conf.moviepath) { -+ moviepath = cnt->conf.moviepath; -+ } else { -+ moviepath = DEF_MOVIEPATH; -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: moviepath: %s", -+ moviepath); -+ } -+ -+ mystrftime(cnt, stamp, sizeof(stamp), moviepath, currenttime_tm, NULL, 0); -+ snprintf(cnt->extpipefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); -+ -+ /* Open a dummy file to check if path is correct */ -+ fd_dummy = myfopen(cnt->extpipefilename, "w", 0); -+ -+ /* TODO: trigger some warning instead of only log an error message */ -+ if (fd_dummy == NULL) { -+ /* Permission denied */ -+ if (errno == EACCES) { -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: error opening file %s ..." -+ "check access rights to target directory", -+ cnt->extpipefilename); -+ return ; -+ } else { -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: error opening file %s", -+ cnt->extpipefilename); -+ return ; -+ } -+ -+ } -+ -+ myfclose(fd_dummy); -+ unlink(cnt->extpipefilename); -+ -+ mystrftime(cnt, stamp, sizeof(stamp), cnt->conf.extpipe, currenttime_tm, cnt->extpipefilename, 0); -+ -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: pipe: %s", -+ stamp); -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: cnt->moviefps: %d", -+ cnt->movie_fps); -+ -+ event(cnt, EVENT_FILECREATE, NULL, cnt->extpipefilename, (void *)FTYPE_MPEG, NULL); -+ cnt->extpipe = popen(stamp, "w"); -+ -+ if (cnt->extpipe == NULL) { -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: popen failed"); -+ return; -+ } -+ -+ setbuf(cnt->extpipe, NULL); -+ cnt->extpipe_open = 1; -+ } -+} -+ -+static void event_extpipe_put(struct context *cnt, int type ATTRIBUTE_UNUSED, -+ unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, -+ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) -+{ -+ /* Check use_extpipe enabled and ext_pipe not NULL */ -+ if ((cnt->conf.useextpipe) && (cnt->extpipe != NULL)) { -+ MOTION_LOG(DBG, TYPE_EVENTS, NO_ERRNO, "%s:"); -+ -+ /* Check that is open */ -+ if ((cnt->extpipe_open) && (fileno(cnt->extpipe) > 0)) { -+ if (!fwrite(img, cnt->imgs.size, 1, cnt->extpipe)) -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Error writting in pipe , state error %d", -+ ferror(cnt->extpipe)); -+ } else { -+ MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO, "%s: pipe %s not created or closed already ", -+ cnt->extpipe); -+ } -+ } -+} -+ -+ -+static void event_new_video(struct context *cnt, int type ATTRIBUTE_UNUSED, -+ unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, -+ void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) -+{ -+ cnt->movie_last_shot = -1; -+ -+ cnt->movie_fps = cnt->lastrate; -+ -+ MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s FPS %d", -+ cnt->movie_fps); -+ -+ if (cnt->movie_fps > 30) -+ cnt->movie_fps = 30; -+ else if (cnt->movie_fps < 2) -+ cnt->movie_fps = 2; -+} -+ -+#ifdef HAVE_FFMPEG -+ -+static void grey2yuv420p(unsigned char *u, unsigned char *v, int width, int height) -+{ -+ memset(u, 128, width * height / 4); -+ memset(v, 128, width * height / 4); -+} -+ -+ - static void event_ffmpeg_newfile(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, - void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) -@@ -364,30 +544,33 @@ static void event_ffmpeg_newfile(struct - int width = cnt->imgs.width; - int height = cnt->imgs.height; - unsigned char *convbuf, *y, *u, *v; -- int fps = 0; - char stamp[PATH_MAX]; -- const char *mpegpath; -+ const char *moviepath; - -- if (!cnt->conf.ffmpeg_cap_new && !cnt->conf.ffmpeg_cap_motion) -+ if (!cnt->conf.ffmpeg_output && !cnt->conf.ffmpeg_output_debug) - return; -- -- /* conf.mpegpath would normally be defined but if someone deleted it by control interface -- it is better to revert to the default than fail */ -- if (cnt->conf.mpegpath) -- mpegpath = cnt->conf.mpegpath; -+ -+ /* -+ * conf.mpegpath would normally be defined but if someone deleted it by control interface -+ * it is better to revert to the default than fail -+ */ -+ if (cnt->conf.moviepath) -+ moviepath = cnt->conf.moviepath; - else -- mpegpath = DEF_MPEGPATH; -+ moviepath = DEF_MOVIEPATH; - -- mystrftime(cnt, stamp, sizeof(stamp), mpegpath, currenttime_tm, NULL, 0); -+ mystrftime(cnt, stamp, sizeof(stamp), moviepath, currenttime_tm, NULL, 0); - -- /* motion mpegs get the same name as normal mpegs plus an appended 'm' */ -- /* PATH_MAX - 4 to allow for .mpg to be appended without overflow */ -+ /* -+ * motion movies get the same name as normal movies plus an appended 'm' -+ * PATH_MAX - 4 to allow for .mpg to be appended without overflow -+ */ - snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%sm", cnt->conf.filepath, stamp); - snprintf(cnt->newfilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); - -- if (cnt->conf.ffmpeg_cap_new) { -+ if (cnt->conf.ffmpeg_output) { - if (cnt->imgs.type == VIDEO_PALETTE_GREY) { -- convbuf=mymalloc((width * height) / 2); -+ convbuf = mymalloc((width * height) / 2); - y = img; - u = convbuf; - v = convbuf + (width * height) / 4; -@@ -399,29 +582,21 @@ static void event_ffmpeg_newfile(struct - v = u + (width * height) / 4; - } - -- fps = cnt->lastrate; -- -- if (debug_level >= CAMERA_DEBUG) -- motion_log(LOG_DEBUG, 0, "%s FPS %d",__FUNCTION__, fps); -- -- if (fps > 30) -- fps = 30; -- else if (fps < 2) -- fps = 2; -- -- if ((cnt->ffmpeg_new = -- ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->newfilename, y, u, v, -- cnt->imgs.width, cnt->imgs.height, fps, cnt->conf.ffmpeg_bps, -+ if ((cnt->ffmpeg_output = -+ ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->newfilename, y, u, v, -+ cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, - cnt->conf.ffmpeg_vbr)) == NULL) { -- motion_log(LOG_ERR, 1, "ffopen_open error creating (new) file [%s]",cnt->newfilename); -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (new) file [%s]", -+ cnt->newfilename); - cnt->finish = 1; - return; - } -- ((struct ffmpeg *)cnt->ffmpeg_new)->udata=convbuf; -+ -+ ((struct ffmpeg *)cnt->ffmpeg_output)->udata = convbuf; - event(cnt, EVENT_FILECREATE, NULL, cnt->newfilename, (void *)FTYPE_MPEG, NULL); - } - -- if (cnt->conf.ffmpeg_cap_motion) { -+ if (cnt->conf.ffmpeg_output_debug) { - if (cnt->imgs.type == VIDEO_PALETTE_GREY) { - convbuf = mymalloc((width * height) / 2); - y = cnt->imgs.out; -@@ -430,30 +605,22 @@ static void event_ffmpeg_newfile(struct - grey2yuv420p(u, v, width, height); - } else { - y = cnt->imgs.out; -- u = cnt->imgs.out + width * height; -+ u = cnt->imgs.out + width *height; - v = u + (width * height) / 4; - convbuf = NULL; - } - -- if (debug_level >= CAMERA_DEBUG) -- motion_log(LOG_DEBUG, 0, "%s FPS %d", __FUNCTION__, fps); -- -- fps = cnt->lastrate; -- -- if (fps > 30) -- fps = 30; -- else if (fps < 2) -- fps = 2; -- -- if ((cnt->ffmpeg_motion = -- ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->motionfilename, y, u, v, -- cnt->imgs.width, cnt->imgs.height, fps, cnt->conf.ffmpeg_bps, -+ if ((cnt->ffmpeg_output_debug = -+ ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->motionfilename, y, u, v, -+ cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, - cnt->conf.ffmpeg_vbr)) == NULL) { -- motion_log(LOG_ERR, 1, "ffopen_open error creating (motion) file [%s]", cnt->motionfilename); -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (motion) file [%s]", -+ cnt->motionfilename); - cnt->finish = 1; - return; - } -- cnt->ffmpeg_motion->udata = convbuf; -+ -+ cnt->ffmpeg_output_debug->udata = convbuf; - event(cnt, EVENT_FILECREATE, NULL, cnt->motionfilename, (void *)FTYPE_MPEG_MOTION, NULL); - } - } -@@ -471,23 +638,25 @@ static void event_ffmpeg_timelapse(struc - char tmp[PATH_MAX]; - const char *timepath; - -- /* conf.timepath would normally be defined but if someone deleted it by control interface -- it is better to revert to the default than fail */ -+ /* -+ * conf.timepath would normally be defined but if someone deleted it by control interface -+ * it is better to revert to the default than fail -+ */ - if (cnt->conf.timepath) - timepath = cnt->conf.timepath; - else - timepath = DEF_TIMEPATH; -- -+ - mystrftime(cnt, tmp, sizeof(tmp), timepath, currenttime_tm, NULL, 0); -- -+ - /* PATH_MAX - 4 to allow for .mpg to be appended without overflow */ - snprintf(cnt->timelapsefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, tmp); -- -+ - if (cnt->imgs.type == VIDEO_PALETTE_GREY) { - convbuf = mymalloc((width * height) / 2); - y = img; - u = convbuf; -- v = convbuf+(width * height) / 4; -+ v = convbuf + (width * height) / 4; - grey2yuv420p(u, v, width, height); - } else { - convbuf = NULL; -@@ -495,54 +664,65 @@ static void event_ffmpeg_timelapse(struc - u = img + width * height; - v = u + (width * height) / 4; - } -- -+ - if ((cnt->ffmpeg_timelapse = -- ffmpeg_open((char *)TIMELAPSE_CODEC, cnt->timelapsefilename, y, u, v, -+ ffmpeg_open((char *)TIMELAPSE_CODEC, cnt->timelapsefilename, y, u, v, - cnt->imgs.width, cnt->imgs.height, 24, cnt->conf.ffmpeg_bps, - cnt->conf.ffmpeg_vbr)) == NULL) { -- motion_log(LOG_ERR, 1, "ffopen_open error creating (timelapse) file [%s]", cnt->timelapsefilename); -+ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating " -+ "(timelapse) file [%s]", cnt->timelapsefilename); - cnt->finish = 1; - return; - } -- -+ - cnt->ffmpeg_timelapse->udata = convbuf; - event(cnt, EVENT_FILECREATE, NULL, cnt->timelapsefilename, (void *)FTYPE_MPEG_TIMELAPSE, NULL); - } -- -+ - y = img; -- -+ - if (cnt->imgs.type == VIDEO_PALETTE_GREY) - u = cnt->ffmpeg_timelapse->udata; - else - u = img + width * height; -- -+ - v = u + (width * height) / 4; -- ffmpeg_put_other_image(cnt->ffmpeg_timelapse, y, u, v); -- -+ -+ if (ffmpeg_put_other_image(cnt->ffmpeg_timelapse, y, u, v) == -1) { -+ cnt->finish = 1; -+ cnt->restart = 0; -+ } -+ - } - - static void event_ffmpeg_put(struct context *cnt, int type ATTRIBUTE_UNUSED, - unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, - void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) - { -- if (cnt->ffmpeg_new) { -- int width=cnt->imgs.width; -- int height=cnt->imgs.height; -+ if (cnt->ffmpeg_output) { -+ int width = cnt->imgs.width; -+ int height = cnt->imgs.height; - unsigned char *y = img; - unsigned char *u, *v; -- -+ - if (cnt->imgs.type == VIDEO_PALETTE_GREY) - u = cnt->ffmpeg_timelapse->udata; - else - u = y + (width * height); -- -+ - v = u + (width * height) / 4; -- ffmpeg_put_other_image(cnt->ffmpeg_new, y, u, v); -+ if (ffmpeg_put_other_image(cnt->ffmpeg_output, y, u, v) == -1) { -+ cnt->finish = 1; -+ cnt->restart = 0; -+ } -+ } -+ -+ if (cnt->ffmpeg_output_debug) { -+ if (ffmpeg_put_image(cnt->ffmpeg_output_debug) == -1) { -+ cnt->finish = 1; -+ cnt->restart = 0; -+ } - } -- -- if (cnt->ffmpeg_motion) -- ffmpeg_put_image(cnt->ffmpeg_motion); -- - } - - static void event_ffmpeg_closefile(struct context *cnt, -@@ -550,22 +730,23 @@ static void event_ffmpeg_closefile(struc - char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, - struct tm *tm ATTRIBUTE_UNUSED) - { -- -- if (cnt->ffmpeg_new) { -- if (cnt->ffmpeg_new->udata) -- free(cnt->ffmpeg_new->udata); -- ffmpeg_close(cnt->ffmpeg_new); -- cnt->ffmpeg_new = NULL; -+ -+ if (cnt->ffmpeg_output) { -+ if (cnt->ffmpeg_output->udata) -+ free(cnt->ffmpeg_output->udata); -+ -+ ffmpeg_close(cnt->ffmpeg_output); -+ cnt->ffmpeg_output = NULL; - - event(cnt, EVENT_FILECLOSE, NULL, cnt->newfilename, (void *)FTYPE_MPEG, NULL); - } - -- if (cnt->ffmpeg_motion) { -- if (cnt->ffmpeg_motion->udata) -- free(cnt->ffmpeg_motion->udata); -+ if (cnt->ffmpeg_output_debug) { -+ if (cnt->ffmpeg_output_debug->udata) -+ free(cnt->ffmpeg_output_debug->udata); - -- ffmpeg_close(cnt->ffmpeg_motion); -- cnt->ffmpeg_motion = NULL; -+ ffmpeg_close(cnt->ffmpeg_output_debug); -+ cnt->ffmpeg_output_debug = NULL; - - event(cnt, EVENT_FILECLOSE, NULL, cnt->motionfilename, (void *)FTYPE_MPEG_MOTION, NULL); - } -@@ -590,8 +771,8 @@ static void event_ffmpeg_timelapseend(st - #endif /* HAVE_FFMPEG */ - - --/* -- * Starting point for all events -+/* -+ * Starting point for all events - */ - - struct event_handlers { -@@ -600,7 +781,7 @@ struct event_handlers { - }; - - struct event_handlers event_handlers[] = { --#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) - { - EVENT_FILECREATE, - event_sqlnewfile -@@ -646,15 +827,29 @@ struct event_handlers event_handlers[] = - EVENT_IMAGE_SNAPSHOT, - event_image_snapshot - }, --#if !defined(WITHOUT_V4L) && !defined(BSD) -+#ifdef HAVE_SDL - { -- EVENT_IMAGE | EVENT_IMAGEM, -+ EVENT_SDL_PUT, -+ event_sdl_put -+ }, -+#endif -+#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) -+ { -+ EVENT_IMAGE, - event_vid_putpipe - }, --#endif /* WITHOUT_V4L && !BSD */ - { -- EVENT_WEBCAM, -- event_webcam_put -+ EVENT_IMAGEM, -+ event_vid_putpipe -+ }, -+#endif /* !WITHOUT_V4L && !BSD */ -+ { -+ EVENT_STREAM, -+ event_stream_put -+ }, -+ { -+ EVENT_FIRSTMOTION, -+ event_new_video - }, - #ifdef HAVE_FFMPEG - { -@@ -666,6 +861,10 @@ struct event_handlers event_handlers[] = - event_ffmpeg_put - }, - { -+ EVENT_FFMPEG_PUT, -+ event_ffmpeg_put -+ }, -+ { - EVENT_ENDMOTION, - event_ffmpeg_closefile - }, -@@ -677,39 +876,57 @@ struct event_handlers event_handlers[] = - EVENT_TIMELAPSEEND, - event_ffmpeg_timelapseend - }, -+#endif /* HAVE_FFMPEG */ - { - EVENT_FILECLOSE, - on_movie_end_command - }, --#endif /* HAVE_FFMPEG */ -+ { -+ EVENT_FIRSTMOTION, -+ event_create_extpipe -+ }, -+ { -+ EVENT_IMAGE_DETECTED, -+ event_extpipe_put -+ }, -+ { -+ EVENT_FFMPEG_PUT, -+ event_extpipe_put -+ }, -+ { -+ EVENT_ENDMOTION, -+ event_extpipe_end -+ }, - { - EVENT_CAMERA_LOST, - event_camera_lost - }, - { - EVENT_STOP, -- event_stop_webcam -+ event_stop_stream - }, - {0, NULL} - }; - - --/* The event functions are defined with the following parameters: -- * - Type as defined in event.h (EVENT_...) -- * - The global context struct cnt -- * - image - A pointer to unsigned char as used for images -- * - filename - A pointer to typically a string for a file path -- * - eventdata - A void pointer that can be cast to anything. E.g. FTYPE_... -- * - tm - A tm struct that carries a full time structure -+/** -+ * event -+ * defined with the following parameters: -+ * - Type as defined in event.h (EVENT_...) -+ * - The global context struct cnt -+ * - image - A pointer to unsigned char as used for images -+ * - filename - A pointer to typically a string for a file path -+ * - eventdata - A void pointer that can be cast to anything. E.g. FTYPE_... -+ * - tm - A tm struct that carries a full time structure - * The split between unsigned images and signed filenames was introduced in 3.2.2 - * as a code reading friendly solution to avoid a stream of compiler warnings in gcc 4.0. - */ - void event(struct context *cnt, int type, unsigned char *image, char *filename, void *eventdata, struct tm *tm) - { -- int i = -1; -+ int i=-1; - - while (event_handlers[++i].handler) { -- if (type & event_handlers[i].type) -+ if (type == event_handlers[i].type) - event_handlers[i].handler(cnt, type, image, filename, eventdata, tm); - } - } ---- motion-3.2.12.orig/event.h -+++ motion-3.2.12/event.h -@@ -13,22 +13,25 @@ - - #define EVENT_FILECREATE 1 - #define EVENT_MOTION 2 --#define EVENT_FIRSTMOTION 4 --#define EVENT_ENDMOTION 8 --#define EVENT_STOP 16 --#define EVENT_TIMELAPSE 32 --#define EVENT_TIMELAPSEEND 64 --#define EVENT_WEBCAM 128 --#define EVENT_IMAGE_DETECTED 256 --#define EVENT_IMAGEM_DETECTED 512 --#define EVENT_IMAGE_SNAPSHOT 1024 --#define EVENT_IMAGE 2048 --#define EVENT_IMAGEM 8192 --#define EVENT_FILECLOSE 16384 --#define EVENT_DEBUG 65536 --#define EVENT_CRITICAL 131072 --#define EVENT_AREA_DETECTED 262144 --#define EVENT_CAMERA_LOST 524288 -+#define EVENT_FIRSTMOTION 3 -+#define EVENT_ENDMOTION 4 -+#define EVENT_STOP 5 -+#define EVENT_TIMELAPSE 6 -+#define EVENT_TIMELAPSEEND 7 -+#define EVENT_STREAM 8 -+#define EVENT_IMAGE_DETECTED 9 -+#define EVENT_IMAGEM_DETECTED 10 -+#define EVENT_IMAGE_SNAPSHOT 11 -+#define EVENT_IMAGE 12 -+#define EVENT_IMAGEM 13 -+#define EVENT_FILECLOSE 14 -+#define EVENT_DEBUG 15 -+#define EVENT_CRITICAL 16 -+#define EVENT_AREA_DETECTED 17 -+#define EVENT_CAMERA_LOST 18 -+#define EVENT_FFMPEG_PUT 19 -+#define EVENT_SDL_PUT 20 -+ - - typedef void(* event_handler)(struct context *, int, unsigned char *, char *, void *, struct tm *); - ---- motion-3.2.12.orig/ffmpeg.c -+++ motion-3.2.12/ffmpeg.c -@@ -1,14 +1,14 @@ --/********************************************************************** -+/* - * - * ffmpeg.c - * - * This software is distributed under the GNU Public License version 2 - * See also the file 'COPYING'. - * -- * The contents of this file has been derived from output_example.c -+ * The contents of this file has been derived from output_example.c - * and apiexample.c from the FFmpeg distribution. - * -- **********************************************************************/ -+ */ - - #ifdef HAVE_FFMPEG - -@@ -16,37 +16,32 @@ - #include "motion.h" - - #if LIBAVCODEC_BUILD > 4680 --/* FFmpeg after build 4680 doesn't have support for mpeg1 videos with -- * non-standard framerates. Previous builds contained a broken hack -+/* -+ * FFmpeg after build 4680 doesn't have support for mpeg1 videos with -+ * non-standard framerates. Previous builds contained a broken hack - * that padded with B frames to obtain the correct framerate. - */ - # define FFMPEG_NO_NONSTD_MPEG1 --# ifdef __GNUC__ --/* #warning is a non-standard gcc extension */ --# warning ************************************************** --# warning Your version of FFmpeg is newer than version 0.4.8 --# warning Newer versions of ffmpeg do not support MPEG1 with --# warning non-standard framerate. MPEG1 will be disabled for --# warning normal video output. You can still use mpeg4 and --# warning and mpeg4ms which are both better in terms of size --# warning and quality. MPEG1 is always used for timelapse. --# warning Please read the Motion Guide for more information. --# warning Note that this is not an error message! --# warning ************************************************** --# endif /* __GNUC__ */ - #endif /* LIBAVCODEC_BUILD > 4680 */ - -+#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR -+# if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 -+# define GUESS_NO_DEPRECATED -+# endif -+#endif - - #if LIBAVFORMAT_BUILD >= 4616 --/* The API for av_write_frame changed with FFmpeg version 0.4.9pre1. -+/* -+ * The API for av_write_frame changed with FFmpeg version 0.4.9pre1. - * It now uses an AVPacket struct instead of direct parameters to the -- * function. The -+ * function. - */ - # define FFMPEG_AVWRITEFRAME_NEWAPI - #endif /* LIBAVFORMAT_BUILD >= 4616 */ - - #if LIBAVFORMAT_BUILD >= 4629 --/* In this build/header version, the codec member of struct AVStream -+/* -+ * In this build/header version, the codec member of struct AVStream - * was changed to a pointer so changes to AVCodecContext shouldn't - * break binary compatibility with AVStream. - */ -@@ -55,52 +50,83 @@ - # define AVSTREAM_CODEC_PTR(avs_ptr) (&avs_ptr->codec) - #endif /* LIBAVFORMAT_BUILD >= 4629 */ - --/* Name of custom file protocol for appending to existing files instead -+// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) -+// (54*2^16 | 6*2^8 | 100) -+#if LIBAVFORMAT_BUILD >= 3540580 -+#define FF_API_NEW_AVIO -+#define URL_RDONLY AVIO_FLAG_READ /**< read-only */ -+#define URL_WRONLY AVIO_FLAG_WRITE /**< write-only */ -+#define URL_RDWR AVIO_FLAG_READ_WRITE /**< read-write pseudo flag */ -+#endif -+ -+ -+/* -+ * Name of custom file protocol for appending to existing files instead - * of truncating. - */ - #define APPEND_PROTO "appfile" - - /* Some forward-declarations. */ --void ffmpeg_put_frame(struct ffmpeg *, AVFrame *); -+int ffmpeg_put_frame(struct ffmpeg *, AVFrame *); - void ffmpeg_cleanups(struct ffmpeg *); --AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, -+AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, - unsigned char *, unsigned char *); - - /* This is the trailer used to end mpeg1 videos. */ - static unsigned char mpeg1_trailer[] = {0x00, 0x00, 0x01, 0xb7}; - --/* Append version of the file open function used in libavformat when opening -- * an ordinary file. The original file open function truncates an existing -- * file, but this version appends to it instead. -+ -+// FFMPEG API changed in 0.8 -+#if defined FF_API_NEW_AVIO -+ -+// TODO -+ -+ -+#else -+ -+/** -+ * file_open_append -+ * Append version of the file open function used in libavformat when opening -+ * an ordinary file. The original file open function truncates an existing -+ * file, but this version appends to it instead. -+ * -+ * Returns 0 on success and AVERROR(ENOENT) on error. -+ * - */ - static int file_open_append(URLContext *h, const char *filename, int flags) - { - const char *colon; -- int access_flags, fd; -+ const char *mode; -+ FILE *fh; -+ size_t bufsize = 0; - - /* Skip past the protocol part of filename. */ - colon = strchr(filename, ':'); -- if (colon) -+ -+ if (colon) - filename = colon + 1; -- -+ - - if (flags & URL_RDWR) { -- access_flags = O_CREAT | O_APPEND | O_RDWR; -+ mode = "ab+"; -+ bufsize = BUFSIZE_1MEG; - } else if (flags & URL_WRONLY) { -- access_flags = O_CREAT | O_APPEND | O_WRONLY; -+ mode = "ab"; -+ bufsize = BUFSIZE_1MEG; - } else { -- access_flags = O_RDONLY; -+ mode = "rb"; - } - -- fd = open(filename, access_flags, 0666); -- if (fd < 0) -+ fh = myfopen(filename, mode, bufsize); -+ if (fh == NULL) - return AVERROR(ENOENT); -- -- h->priv_data = (void *)(size_t)fd; -+ -+ h->priv_data = (void *)fh; - return 0; - } - --/* URLProtocol entry for the append file protocol, which we use for mpeg1 videos -+/* -+ * URLProtocol entry for the append file protocol, which we use for mpeg1 videos - * in order to get append behavior with url_fopen. - * - * Libavformat uses protocols for achieving flexibility when handling files -@@ -117,134 +143,97 @@ URLProtocol mpeg1_file_protocol = { - - #ifdef HAVE_FFMPEG_NEW - --/* -- * file_procotol has been removed from avio.h -- * -- */ -- -+/* file_procotol has been removed from avio.h */ - #ifdef FFMPEG_NEW_INCLUDES - #include - #else - #include "avstring.h" - #endif - --static int file_open(URLContext *h, const char *filename, int flags) --{ -- int access_flags, fd; -- -- av_strstart(filename, "file:", &filename); -+#endif // HAVE_FFMPEG_NEW - -- if (flags & URL_RDWR) { -- access_flags = O_CREAT | O_TRUNC | O_RDWR; -- } else if (flags & URL_WRONLY) { -- access_flags = O_CREAT | O_TRUNC | O_WRONLY; -- } else { -- access_flags = O_RDONLY; -- } --#ifdef O_BINARY -- access_flags |= O_BINARY; -+#endif // FF_API_NEW_AVIO -+/**************************************************************************** -+ * The section below is the "my" section of functions. -+ * These are designed to be extremely simple version specific -+ * variants of the libav functions. -+ ****************************************************************************/ -+AVFrame *my_frame_alloc(void){ -+ AVFrame *pic; -+#if (LIBAVFORMAT_VERSION_MAJOR >= 55) -+ pic = av_frame_alloc(); -+#else -+ pic = avcodec_alloc_frame(); - #endif -- fd = open(filename, access_flags, 0666); -- if (fd < 0) -- return AVERROR(ENOENT); -- -- h->priv_data = (void *)(size_t)fd; -- return 0; -+ return pic; - } - --static int file_read(URLContext *h, unsigned char *buf, int size) --{ -- int fd = (size_t)h->priv_data; -- return read(fd, buf, size); --} -- --static int file_write(URLContext *h, unsigned char *buf, int size) --{ -- int fd = (size_t)h->priv_data; -- return write(fd, buf, size); --} -- --static int64_t file_seek(URLContext *h, int64_t pos, int whence) --{ -- int fd = (size_t)h->priv_data; -- return lseek(fd, pos, whence); --} -- --static int file_close(URLContext *h) --{ -- int fd = (size_t)h->priv_data; -- return close(fd); --} -- --URLProtocol file_protocol = { -- "file", -- file_open, -- file_read, -- file_write, -- file_seek, -- file_close, --#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) -- NULL, -- NULL, -- NULL, --#endif --}; -- -+void my_frame_free(AVFrame *frame){ -+#if (LIBAVFORMAT_VERSION_MAJOR >= 55) -+ av_frame_free(&frame); -+#else -+ //avcodec_free_frame(&frame); -+ //av_frame_free(&netcam->rtsp->frame); -+ av_freep(&frame); - #endif -+} - -- --/* We set AVOutputFormat->write_trailer to this function for mpeg1. That way, -- * the mpeg1 video gets a proper trailer when it is closed. -+/**************************************************************************** -+ **************************************************************************** -+ ****************************************************************************/ -+ -+/** -+ * mpeg1_write_trailer -+ * We set AVOutputFormat->write_trailer to this function for mpeg1. That way, -+ * the mpeg1 video gets a proper trailer when it is closed. -+ * -+ * Returns 0 -+ * - */ - static int mpeg1_write_trailer(AVFormatContext *s) - { --#if LIBAVFORMAT_BUILD >= (52<<16) -- put_buffer(s->pb, mpeg1_trailer, 4); -- put_flush_packet(s->pb); --#else -- put_buffer(&s->pb, mpeg1_trailer, 4); -- put_flush_packet(&s->pb); --#endif /* LIBAVFORMAT_BUILD >= (52<<16) */ -+ avio_write(s->pb, mpeg1_trailer, 4); -+ avio_flush(s->pb); - - return 0; /* success */ - } - --/* ffmpeg_init initializes for libavformat. */ -+/** -+ * ffmpeg_init -+ * Initializes for libavformat. -+ * -+ * Returns -+ * Function returns nothing. -+ */ - void ffmpeg_init() - { -- motion_log(LOG_INFO, 0, "ffmpeg LIBAVCODEC_BUILD %d LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD); -+ MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d" -+ " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, -+ LIBAVFORMAT_BUILD); - av_register_all(); - - #if LIBAVCODEC_BUILD > 4680 -- av_log_set_callback( (void *)ffmpeg_avcodec_log ); -+ av_log_set_callback((void *)ffmpeg_avcodec_log); -+ av_log_set_level(AV_LOG_ERROR); - #endif - -- /* Copy the functions to use for the append file protocol from the standard -- * file protocol. -- */ -- mpeg1_file_protocol.url_read = file_protocol.url_read; -- mpeg1_file_protocol.url_write = file_protocol.url_write; -- mpeg1_file_protocol.url_seek = file_protocol.url_seek; -- mpeg1_file_protocol.url_close = file_protocol.url_close; -- -- /* Register the append file protocol. */ --#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) -- av_register_protocol(&mpeg1_file_protocol); --#else -- register_protocol(&mpeg1_file_protocol); --#endif - } - --/* Obtains the output format used for the specified codec. For mpeg4 codecs, -- * the format is avi; for mpeg1 codec, the format is mpeg. The filename has -- * to be passed, because it gets the appropriate extension appended onto it. -+/** -+ * get_oformat -+ * Obtains the output format used for the specified codec. For mpeg4 codecs, -+ * the format is avi; for mpeg1 codec, the format is mpeg. The filename has -+ * to be passed, because it gets the appropriate extension appended onto it. -+ * -+ * Returns -+ * AVOutputFormat pointer or NULL if any error happens. - */ - static AVOutputFormat *get_oformat(const char *codec, char *filename) - { - const char *ext; - AVOutputFormat *of = NULL; -- -- /* Here, we use guess_format to automatically setup the codec information. -+ /* -+ * Here, we use guess_format to automatically setup the codec information. - * If we are using msmpeg4, manually set that codec here. - * We also dynamically add the file extension to the filename here. This was - * done to support both mpeg1 and mpeg4 codecs since they have different extensions. -@@ -252,70 +241,118 @@ static AVOutputFormat *get_oformat(const - if ((strcmp(codec, TIMELAPSE_CODEC) == 0) - #ifndef FFMPEG_NO_NONSTD_MPEG1 - || (strcmp(codec, "mpeg1") == 0) --#endif -+#endif - ) { - ext = ".mpg"; -- /* We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would -+ /* -+ * We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would - * result in a muxed output file, which isn't appropriate here. - */ -- of = guess_format("mpeg1video", NULL, NULL); -- if (of) { -- /* But we want the trailer to be correctly written. */ -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("mpeg1video", NULL, NULL); -+#endif -+ /* But we want the trailer to be correctly written. */ -+ if (of) - of->write_trailer = mpeg1_write_trailer; -- } -+ - #ifdef FFMPEG_NO_NONSTD_MPEG1 - } else if (strcmp(codec, "mpeg1") == 0) { -- motion_log(LOG_ERR, 0, "*** mpeg1 support for normal videos has been disabled ***"); -+ MOTION_LOG(WRN, TYPE_ENCODER, NO_ERRNO, "%s: *** mpeg1 support for normal" -+ " videos has been disabled ***"); - return NULL; - #endif - } else if (strcmp(codec, "mpeg4") == 0) { - ext = ".avi"; -- of = guess_format("avi", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("avi", NULL, NULL); -+#endif - } else if (strcmp(codec, "msmpeg4") == 0) { - ext = ".avi"; -- of = guess_format("avi", NULL, NULL); -- if (of) { -- /* Manually override the codec id. */ -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("avi", NULL, NULL); -+#endif -+ /* Manually override the codec id. */ -+ if (of) - of->video_codec = CODEC_ID_MSMPEG4V2; -- } -+ - } else if (strcmp(codec, "swf") == 0) { - ext = ".swf"; -- of = guess_format("swf", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("swf", NULL, NULL); -+#endif - } else if (strcmp(codec, "flv") == 0) { - ext = ".flv"; -- of = guess_format("flv", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("flv", NULL, NULL); -+#endif - of->video_codec = CODEC_ID_FLV1; - } else if (strcmp(codec, "ffv1") == 0) { - ext = ".avi"; -- of = guess_format("avi", NULL, NULL); -- if (of) { -- /* Use the FFMPEG Lossless Video codec (experimental!). -- Requires strict_std_compliance to be <= -2 */ -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("avi", NULL, NULL); -+#endif -+ /* -+ * Use the FFMPEG Lossless Video codec (experimental!). -+ * Requires strict_std_compliance to be <= -2 -+ */ -+ if (of) - of->video_codec = CODEC_ID_FFV1; -- } -+ - } else if (strcmp(codec, "mov") == 0) { - ext = ".mov"; -- of = guess_format("mov", NULL, NULL); -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format("mpeg1video", NULL, NULL); -+#else -+ of = av_guess_format("mov", NULL, NULL); -+#endif -+ } -+ else if (strcmp (codec, "ogg") == 0) -+ { -+ ext = ".ogg"; -+#ifdef GUESS_NO_DEPRECATED -+ of = guess_format ("ogg", NULL, NULL); -+#else -+ of = av_guess_format ("ogg", NULL, NULL); -+#endif - } else { -- motion_log(LOG_ERR, 0, "ffmpeg_video_codec option value %s is not supported", codec); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg_video_codec option value" -+ " %s is not supported", codec); - return NULL; - } - - if (!of) { -- motion_log(LOG_ERR, 0, "Could not guess format for %s", codec); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not guess format for %s", -+ codec); - return NULL; - } - -- /* The 4 allows for ".avi" or ".mpg" to be appended */ -+ /* The 4 allows for ".avi" or ".mpg" to be appended. */ - strncat(filename, ext, 4); - - return of; - } - --/* This function opens an mpeg file using the new libavformat method. Both mpeg1 -- * and mpeg4 are supported. However, if the current ffmpeg version doesn't allow -- * mpeg1 with non-standard framerate, the open will fail. Timelapse is a special -- * case and is tested separately. -+/** -+ * ffmpeg_open -+ * Opens an mpeg file using the new libavformat method. Both mpeg1 -+ * and mpeg4 are supported. However, if the current ffmpeg version doesn't allow -+ * mpeg1 with non-standard framerate, the open will fail. Timelapse is a special -+ * case and is tested separately. -+ * -+ * Returns -+ * A new allocated ffmpeg struct or NULL if any error happens. - */ - struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, - unsigned char *y, unsigned char *u, unsigned char *v, -@@ -325,8 +362,9 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - AVCodec *codec; - struct ffmpeg *ffmpeg; - int is_mpeg1; -- -- /* Allocate space for our ffmpeg structure. This structure contains all the -+ int ret; -+ /* -+ * Allocate space for our ffmpeg structure. This structure contains all the - * codec and image information we need to generate movies. - * FIXME when motion exits we should close the movie to ensure that - * ffmpeg is freed. -@@ -335,22 +373,26 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - memset(ffmpeg, 0, sizeof(struct ffmpeg)); - - ffmpeg->vbr = vbr; -- -- /* store codec name in ffmpeg->codec, with buffer overflow check */ -+ -+ /* Store codec name in ffmpeg->codec, with buffer overflow check. */ - snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); - -- /* allocation the output media context */ -- ffmpeg->oc = av_mallocz(sizeof(AVFormatContext)); -+ /* Allocation the output media context. */ -+#if (LIBAVFORMAT_VERSION_MAJOR >= 53) -+ ffmpeg->oc = avformat_alloc_context(); -+#else -+ ffmpeg->oc = av_alloc_format_context(); -+#endif - - if (!ffmpeg->oc) { -- motion_log(LOG_ERR, 1, "Memory error while allocating output media context"); -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Memory error while allocating" -+ " output media context"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - - /* Setup output format */ - ffmpeg->oc->oformat = get_oformat(ffmpeg_video_codec, filename); -- - if (!ffmpeg->oc->oformat) { - ffmpeg_cleanups(ffmpeg); - return NULL; -@@ -358,30 +400,35 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - - snprintf(ffmpeg->oc->filename, sizeof(ffmpeg->oc->filename), "%s", filename); - -- /* Create a new video stream and initialize the codecs */ -+ /* Create a new video stream and initialize the codecs. */ - ffmpeg->video_st = NULL; -- - if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { -- ffmpeg->video_st = av_new_stream(ffmpeg->oc, 0); -+ ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); - if (!ffmpeg->video_st) { -- motion_log(LOG_ERR, 1, "av_new_stream - could not alloc stream"); -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: av_new_stream - could" -+ " not alloc stream"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - } else { - /* We did not get a proper video codec. */ -- motion_log(LOG_ERR, 0, "Failed to obtain a proper video codec"); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Failed to obtain a proper" -+ " video codec"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - - ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); - c->codec_id = ffmpeg->oc->oformat->video_codec; -+#if (LIBAVFORMAT_VERSION_MAJOR >= 53) -+ c->codec_type = AVMEDIA_TYPE_VIDEO; -+#else - c->codec_type = CODEC_TYPE_VIDEO; -+#endif - is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; - - if (strcmp(ffmpeg_video_codec, "ffv1") == 0) -- c->strict_std_compliance = -2; -+ c->strict_std_compliance = -2; - - /* Uncomment to allow non-standard framerates. */ - //c->strict_std_compliance = -1; -@@ -391,7 +438,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - c->width = width; - c->height = height; - #if LIBAVCODEC_BUILD >= 4754 -- /* frame rate = 1/time_base, so we set 1/rate, not rate/1 */ -+ /* Frame rate = 1/time_base, so we set 1/rate, not rate/1 */ - c->time_base.num = 1; - c->time_base.den = rate; - #else -@@ -399,54 +446,55 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - c->frame_rate_base = 1; - #endif /* LIBAVCODEC_BUILD >= 4754 */ - -- if (debug_level >= CAMERA_DEBUG) -- motion_log(LOG_DEBUG, 0, "%s FPS %d",__FUNCTION__,rate); -+ MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s FPS %d", -+ rate); - - if (vbr) - c->flags |= CODEC_FLAG_QSCALE; - -- /* Set codec specific parameters. */ -- /* set intra frame distance in frames depending on codec */ -+ /* -+ * Set codec specific parameters. -+ * Set intra frame distance in frames depending on codec. -+ */ - c->gop_size = is_mpeg1 ? 10 : 12; -- -- /* some formats want stream headers to be separate */ -- if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || -- !strcmp(ffmpeg->oc->oformat->name, "mov") || -- !strcmp(ffmpeg->oc->oformat->name, "3gp")) { -- c->flags |= CODEC_FLAG_GLOBAL_HEADER; -- } - -- /* set the output parameters (must be done even if no parameters). */ -- if (av_set_parameters(ffmpeg->oc, NULL) < 0) { -- motion_log(LOG_ERR, 0, "ffmpeg av_set_parameters error: Invalid output format parameters"); -- ffmpeg_cleanups(ffmpeg); -- return NULL; -+ /* Some formats want stream headers to be separate. */ -+ if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || -+ !strcmp(ffmpeg->oc->oformat->name, "mov") || -+ !strcmp(ffmpeg->oc->oformat->name, "3gp")) { -+ c->flags |= CODEC_FLAG_GLOBAL_HEADER; - } - -- /* Dump the format settings. This shows how the various streams relate to each other */ -+ /* Dump the format settings. This shows how the various streams relate to each other. */ - //dump_format(ffmpeg->oc, 0, filename, 1); - -- /* Now that all the parameters are set, we can open the video -- codec and allocate the necessary encode buffers */ -+ /* -+ * Now that all the parameters are set, we can open the video -+ * codec and allocate the necessary encode buffers. -+ */ - codec = avcodec_find_encoder(c->codec_id); - - if (!codec) { -- motion_log(LOG_ERR, 1, "Codec not found"); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Codec %s not found", -+ ffmpeg_video_codec); - ffmpeg_cleanups(ffmpeg); - return NULL; - } -- -+ - /* Set the picture format - need in ffmpeg starting round April-May 2005 */ - c->pix_fmt = PIX_FMT_YUV420P; - - /* Get a mutex lock. */ - pthread_mutex_lock(&global_lock); - -- /* open the codec */ -- if (avcodec_open(c, codec) < 0) { -+ /* Open the codec */ -+ ret = avcodec_open2(c, codec, NULL /* options */ ); -+ -+ if (ret < 0) { - /* Release the lock. */ - pthread_mutex_unlock(&global_lock); -- motion_log(LOG_ERR, 1, "avcodec_open - could not open codec"); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_open - could not open codec %s", -+ ffmpeg_video_codec); - ffmpeg_cleanups(ffmpeg); - return NULL; - } -@@ -454,30 +502,34 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - /* Release the lock. */ - pthread_mutex_unlock(&global_lock); - -- - ffmpeg->video_outbuf = NULL; -+ - if (!(ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE)) { -- /* allocate output buffer */ -- /* XXX: API change will be done */ -- /* ffmpeg->video_outbuf_size = 20000; */ -- ffmpeg->video_outbuf_size = ffmpeg->c->width * 256; -+ /* -+ * Allocate output buffer -+ * XXX: API change will be done -+ * ffmpeg->video_outbuf_size = 200000 -+ */ -+ ffmpeg->video_outbuf_size = ffmpeg->c->width * 512; - ffmpeg->video_outbuf = mymalloc(ffmpeg->video_outbuf_size); - } - -- /* allocate the encoded raw picture */ -- ffmpeg->picture = avcodec_alloc_frame(); -+ /* Allocate the encoded raw picture. */ -+ ffmpeg->picture = my_frame_alloc(); -+ - if (!ffmpeg->picture) { -- motion_log(LOG_ERR, 1, "avcodec_alloc_frame - could not alloc frame"); -+ MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -" -+ " could not alloc frame"); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - -- /* set variable bitrate if requested */ -- if (ffmpeg->vbr) -+ /* Set variable bitrate if requested. */ -+ if (ffmpeg->vbr) - ffmpeg->picture->quality = ffmpeg->vbr; -- - -- /* set the frame data */ -+ -+ /* Set the frame data. */ - ffmpeg->picture->data[0] = y; - ffmpeg->picture->data[1] = u; - ffmpeg->picture->data[2] = v; -@@ -485,85 +537,89 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_ - ffmpeg->picture->linesize[1] = ffmpeg->c->width / 2; - ffmpeg->picture->linesize[2] = ffmpeg->c->width / 2; - -- /* open the output file, if needed */ -+ /* Open the output file, if needed. */ - if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { - char file_proto[256]; - -- /* Use append file protocol for mpeg1, to get the append behavior from -+ /* -+ * Use append file protocol for mpeg1, to get the append behavior from - * url_fopen, but no protocol (=> default) for other codecs. - */ -- if (is_mpeg1) -+ if (is_mpeg1) -+#if defined FF_API_NEW_AVIO -+ snprintf(file_proto, sizeof(file_proto), "%s", filename); -+#else - snprintf(file_proto, sizeof(file_proto), APPEND_PROTO ":%s", filename); -- else -+#endif -+ else - snprintf(file_proto, sizeof(file_proto), "%s", filename); -- - -- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -- /* path did not exist? */ -+ -+ if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -+ /* Path did not exist? */ - if (errno == ENOENT) { -- /* create path for file (don't use file_proto)... */ -+ /* Create path for file (don't use file_proto)... */ - if (create_path(filename) == -1) { - ffmpeg_cleanups(ffmpeg); - return NULL; - } - -- /* and retry opening the file (use file_proto) */ -- if (url_fopen(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -- motion_log(LOG_ERR, 1, "url_fopen - error opening file %s",filename); -+ if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: url_fopen -" -+ " error opening file %s", filename); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - /* Permission denied */ - } else if (errno == EACCES) { -- motion_log(LOG_ERR, 1, -- "url_fopen - error opening file %s" -- " ... check access rights to target directory", filename); -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, -+ "%s: url_fopen - error opening file %s" -+ " ... check access rights to target directory", -+ filename); - ffmpeg_cleanups(ffmpeg); - return NULL; - } else { -- motion_log(LOG_ERR, 1, "Error opening file %s", filename); -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error opening file %s", -+ filename); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - } - } - -- /* write the stream header, if any */ -- av_write_header(ffmpeg->oc); -- -+ /* Write the stream header, if any. */ -+ avformat_write_header(ffmpeg->oc, NULL); - return ffmpeg; - } - --/* -- Clean up ffmpeg struct if something was wrong --*/ -+/** -+ * ffmpeg_cleanups -+ * Clean up ffmpeg struct if something was wrong. -+ * -+ * Returns -+ * Function returns nothing. -+ */ - void ffmpeg_cleanups(struct ffmpeg *ffmpeg) - { - unsigned int i; - -- /* close each codec */ -+ /* Close each codec */ - if (ffmpeg->video_st) { - pthread_mutex_lock(&global_lock); - #if LIBAVCODEC_BUILD > 4680 - if (ffmpeg->video_st->codec->priv_data != NULL) - #endif - avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); -- pthread_mutex_unlock(&global_lock); -+ pthread_mutex_unlock(&global_lock); - av_freep(&ffmpeg->picture); - free(ffmpeg->video_outbuf); - } - -- /* free the streams */ -- for (i = 0; i < ffmpeg->oc->nb_streams; i++) -+ /* Free the streams */ -+ for (i = 0; i < ffmpeg->oc->nb_streams; i++) - av_freep(&ffmpeg->oc->streams[i]); -- --/* -- if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { -- // close the output file -- if (ffmpeg->oc->pb) url_fclose(&ffmpeg->oc->pb); -- } --*/ -- /* free the stream */ -+ -+ /* Free the stream */ - av_free(ffmpeg->oc); - #if LIBAVFORMAT_BUILD >= 4629 - av_free(ffmpeg->c); -@@ -571,12 +627,18 @@ void ffmpeg_cleanups(struct ffmpeg *ffmp - free(ffmpeg); - } - --/* Closes a video file. */ -+/** -+ * ffmpeg_close -+ * Closes a video file. -+ * -+ * Returns -+ * Function returns nothing. -+ */ - void ffmpeg_close(struct ffmpeg *ffmpeg) - { - unsigned int i; - -- /* close each codec */ -+ /* Close each codec */ - if (ffmpeg->video_st) { - pthread_mutex_lock(&global_lock); - avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); -@@ -585,24 +647,20 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) - free(ffmpeg->video_outbuf); - } - -- /* write the trailer, if any */ -+ /* Write the trailer, if any. */ - av_write_trailer(ffmpeg->oc); - -- /* free the streams */ -- for (i = 0; i < ffmpeg->oc->nb_streams; i++) -+ /* Free the streams. */ -+ for (i = 0; i < ffmpeg->oc->nb_streams; i++) - av_freep(&ffmpeg->oc->streams[i]); -- - - if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { -- /* close the output file */ --#if LIBAVFORMAT_BUILD >= (52<<16) -- url_fclose(ffmpeg->oc->pb); --#else -- url_fclose(&ffmpeg->oc->pb); --#endif /* LIBAVFORMAT_BUILD >= (52<<16) */ -+ /* Close the output file. */ -+ avio_close(ffmpeg->oc->pb); - } - -- /* free the stream */ -+ -+ /* Free the stream. */ - av_free(ffmpeg->oc); - #if LIBAVFORMAT_BUILD >= 4629 - av_free(ffmpeg->c); -@@ -610,43 +668,72 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) - free(ffmpeg); - } - --/* Puts the image pointed to by ffmpeg->picture. */ --void ffmpeg_put_image(struct ffmpeg *ffmpeg) -+/** -+ * ffmpeg_put_image -+ * Puts the image pointed to by ffmpeg->picture. -+ * -+ * Returns -+ * value returned by ffmpeg_put_frame call. -+ */ -+int ffmpeg_put_image(struct ffmpeg *ffmpeg) - { -- ffmpeg_put_frame(ffmpeg, ffmpeg->picture); -+ return ffmpeg_put_frame(ffmpeg, ffmpeg->picture); - } - --/* Puts an arbitrary picture defined by y, u and v. */ --void ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, -+/** -+ * ffmpeg_put_other_image -+ * Puts an arbitrary picture defined by y, u and v. -+ * -+ * Returns -+ * Number of bytes written by ffmpeg_put_frame -+ * -1 if any error happens in ffmpeg_put_frame -+ * 0 if error allocating picture. -+ */ -+int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, - unsigned char *u, unsigned char *v) - { - AVFrame *picture; -- /* allocate the encoded raw picture */ -+ int ret = 0; -+ -+ /* Allocate the encoded raw picture. */ - picture = ffmpeg_prepare_frame(ffmpeg, y, u, v); - - if (picture) { -- ffmpeg_put_frame(ffmpeg, picture); -- av_free(picture); -+ ret = ffmpeg_put_frame(ffmpeg, picture); -+ if (!ret) -+ av_free(picture); - } -+ -+ return ret; - } - --/* Encodes and writes a video frame using the av_write_frame API. This is -- * a helper function for ffmpeg_put_image and ffmpeg_put_other_image. -+/** -+ * ffmpeg_put_frame -+ * Encodes and writes a video frame using the av_write_frame API. This is -+ * a helper function for ffmpeg_put_image and ffmpeg_put_other_image. -+ * -+ * Returns -+ * Number of bytes written or -1 if any error happens. - */ --void ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) -+int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) - { - int out_size, ret; -+ - #ifdef FFMPEG_AVWRITEFRAME_NEWAPI - AVPacket pkt; - -- av_init_packet(&pkt); /* init static structure */ -+ av_init_packet(&pkt); /* Init static structure. */ - pkt.stream_index = ffmpeg->video_st->index; - #endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ - - if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { -- /* raw video case. The API will change slightly in the near future for that */ -+ /* Raw video case. The API will change slightly in the near future for that. */ - #ifdef FFMPEG_AVWRITEFRAME_NEWAPI -+# if LIBAVCODEC_VERSION_MAJOR < 53 - pkt.flags |= PKT_FLAG_KEY; -+# else -+ pkt.flags |= AV_PKT_FLAG_KEY; -+# endif - pkt.data = (uint8_t *)pic; - pkt.size = sizeof(AVPicture); - ret = av_write_frame(ffmpeg->oc, &pkt); -@@ -655,62 +742,91 @@ void ffmpeg_put_frame(struct ffmpeg *ffm - (uint8_t *)pic, sizeof(AVPicture)); - #endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ - } else { -- /* encode the image */ -+ /* Encodes the image. */ -+#if defined FF_API_NEW_AVIO -+ -+ int got_packet_ptr; -+ pkt.data = ffmpeg->video_outbuf; -+ pkt.size = ffmpeg->video_outbuf_size; -+ -+ out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), -+ &pkt, pic, &got_packet_ptr); -+ if (out_size < 0) -+ // Error encondig -+ out_size = 0; -+ else -+ out_size = pkt.size; -+#else - out_size = avcodec_encode_video(AVSTREAM_CODEC_PTR(ffmpeg->video_st), -- ffmpeg->video_outbuf, -+ ffmpeg->video_outbuf, - ffmpeg->video_outbuf_size, pic); -- -- /* if zero size, it means the image was buffered */ -+#endif -+ /* If zero size, it means the image was buffered. */ - if (out_size != 0) { -- /* write the compressed frame in the media file */ -- /* XXX: in case of B frames, the pts is not yet valid */ -+ /* -+ * Writes the compressed frame in the media file. -+ * XXX: in case of B frames, the pts is not yet valid. -+ */ - #ifdef FFMPEG_AVWRITEFRAME_NEWAPI - pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; -- if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) { -+ -+ if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) -+# if LIBAVCODEC_VERSION_MAJOR < 53 - pkt.flags |= PKT_FLAG_KEY; -- } -+# else -+ pkt.flags |= AV_PKT_FLAG_KEY; -+# endif -+ - pkt.data = ffmpeg->video_outbuf; - pkt.size = out_size; - ret = av_write_frame(ffmpeg->oc, &pkt); - #else -- ret = av_write_frame(ffmpeg->oc, ffmpeg->video_st->index, -+ ret = av_write_frame(ffmpeg->oc, ffmpeg->video_st->index, - ffmpeg->video_outbuf, out_size); - #endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ -+ - } else { - ret = 0; - } - } -- -+ - if (ret != 0) { -- motion_log(LOG_ERR, 1, "Error while writing video frame"); -- return; -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error while writing" -+ " video frame"); -+ ffmpeg_cleanups(ffmpeg); -+ return -1; - } -+ -+ return ret; - } - --/* Allocates and prepares a picture frame by setting up the U, Y and V pointers in -- * the frame according to the passed pointers. -+/** -+ * ffmpeg_prepare_frame -+ * Allocates and prepares a picture frame by setting up the U, Y and V pointers in -+ * the frame according to the passed pointers. - * -- * Returns NULL If the allocation fails. -+ * Returns -+ * NULL If the allocation fails. - * -- * The returned AVFrame pointer must be freed after use. -+ * The returned AVFrame pointer must be freed after use. - */ - AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y, - unsigned char *u, unsigned char *v) - { - AVFrame *picture; - -- picture = avcodec_alloc_frame(); -+ picture = my_frame_alloc(); -+ - if (!picture) { -- motion_log(LOG_ERR, 1, "Could not alloc frame"); -+ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc frame"); - return NULL; - } - -- /* take care of variable bitrate setting */ -- if (ffmpeg->vbr) -+ /* Take care of variable bitrate setting. */ -+ if (ffmpeg->vbr) - picture->quality = ffmpeg->vbr; -- -- -- /* setup pointers and line widths */ -+ -+ /* Setup pointers and line widths. */ - picture->data[0] = y; - picture->data[1] = u; - picture->data[2] = v; -@@ -722,9 +838,10 @@ AVFrame *ffmpeg_prepare_frame(struct ffm - } - - --/** ffmpeg_deinterlace -+/** -+ * ffmpeg_deinterlace - * Make the image suitable for deinterlacing using ffmpeg, then deinterlace the picture. -- * -+ * - * Parameters - * img image in YUV420P format - * width image width in pixels -@@ -736,33 +853,35 @@ AVFrame *ffmpeg_prepare_frame(struct ffm - */ - void ffmpeg_deinterlace(unsigned char *img, int width, int height) - { -- AVFrame *picture; -+ AVPicture picture; - int width2 = width / 2; -- -- picture = avcodec_alloc_frame(); -- if (!picture) { -- motion_log(LOG_ERR, 1, "Could not alloc frame"); -- return; -- } -- -- picture->data[0] = img; -- picture->data[1] = img+width*height; -- picture->data[2] = picture->data[1]+(width*height)/4; -- picture->linesize[0] = width; -- picture->linesize[1] = width2; -- picture->linesize[2] = width2; -- -+ -+ picture.data[0] = img; -+ picture.data[1] = img + width * height; -+ picture.data[2] = picture.data[1] + (width * height) / 4; -+ picture.linesize[0] = width; -+ picture.linesize[1] = width2; -+ picture.linesize[2] = width2; -+ - /* We assume using 'PIX_FMT_YUV420P' always */ -- avpicture_deinterlace((AVPicture *)picture, (AVPicture *)picture, PIX_FMT_YUV420P, width, height); -- -- av_free(picture); -- -+#if (LIBAVFORMAT_VERSION_MAJOR >= 53) -+ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Deinterlace depreciated for recent versions of FFMPEG."); -+#else -+ avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height); -+#endif -+ -+ -+#if !defined(__SSE_MATH__) && (defined(__i386__) || defined(__x86_64__)) -+ __asm__ __volatile__ ( "emms"); -+#endif -+ - return; - } - --/** ffmpeg_avcodec_log -+/** -+ * ffmpeg_avcodec_log - * Handle any logging output from the ffmpeg library avcodec. -- * -+ * - * Parameters - * *ignoreme A pointer we will ignore - * errno_flag The error number value -@@ -776,15 +895,12 @@ void ffmpeg_avcodec_log(void *ignoreme A - { - char buf[1024]; - -- /* Do not log the message coming from avcodec if the debug_level is not set. */ -- if (debug_level) { -+ /* Flatten the message coming in from avcodec. */ -+ vsnprintf(buf, sizeof(buf), fmt, vl); - -- /* Flatten the message coming in from avcodec */ -- vsnprintf(buf, sizeof(buf), fmt, vl); -- -- /* If the debug_level is correct then send the message to the motion logging routine. */ -- motion_log(LOG_ERR, 0, "ffmpeg_avcodec_log: %s - flag %d", buf, errno_flag); -- } -+ /* If the debug_level is correct then send the message to the motion logging routine. */ -+ MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s: %s - flag %d", -+ buf, errno_flag); - } - - #endif /* HAVE_FFMPEG */ ---- motion-3.2.12.orig/ffmpeg.h -+++ motion-3.2.12/ffmpeg.h -@@ -29,7 +29,8 @@ - #include - #include - --/* Define a codec name/identifier for timelapse videos, so that we can -+/* -+ * Define a codec name/identifier for timelapse videos, so that we can - * differentiate between normal mpeg1 videos and timelapse videos. - */ - #define TIMELAPSE_CODEC "mpeg1_tl" -@@ -55,7 +56,8 @@ struct ffmpeg { - /* Initialize FFmpeg stuff. Needs to be called before ffmpeg_open. */ - void ffmpeg_init(void); - --/* Open an mpeg file. This is a generic interface for opening either an mpeg1 or -+/* -+ * Open an mpeg file. This is a generic interface for opening either an mpeg1 or - * an mpeg4 video. If non-standard mpeg1 isn't supported (FFmpeg build > 4680), - * calling this function with "mpeg1" as codec results in an error. To create a - * timelapse video, use TIMELAPSE_CODEC as codec name. -@@ -74,10 +76,10 @@ struct ffmpeg *ffmpeg_open( - ); - - /* Puts the image pointed to by the picture member of struct ffmpeg. */ --void ffmpeg_put_image(struct ffmpeg *); -+int ffmpeg_put_image(struct ffmpeg *); - - /* Puts the image defined by u, y and v (YUV420 format). */ --void ffmpeg_put_other_image( -+int ffmpeg_put_other_image( - struct ffmpeg *ffmpeg, - unsigned char *y, - unsigned char *u, -@@ -87,10 +89,15 @@ void ffmpeg_put_other_image( - /* Closes the mpeg file. */ - void ffmpeg_close(struct ffmpeg *); - --/*Deinterlace the image. */ -+/* Deinterlace the image. */ - void ffmpeg_deinterlace(unsigned char *, int, int); - --/*Setup an avcodec log handler. */ -+/* Setup an avcodec log handler. */ - void ffmpeg_avcodec_log(void *, int, const char *, va_list); - -+#ifdef HAVE_FFMPEG -+AVFrame *my_frame_alloc(void); -+void my_frame_free(AVFrame *frame); -+#endif -+ - #endif /* _INCLUDE_FFMPEG_H_ */ ---- /dev/null -+++ motion-3.2.12/git-commit-version.sh -@@ -0,0 +1,5 @@ -+#!/bin/sh -+ -+SNV_VERSION=`git show -s --format=%H` -+echo -n "Git-$SNV_VERSION" -+ ---- motion-3.2.12.orig/jpegutils.c -+++ motion-3.2.12/jpegutils.c -@@ -4,7 +4,7 @@ - * - * Copyright (C) 1999 Rainer Johanni - * Copyright (C) 2001 pHilipp Zabel -- * Copyright (C) 2008 Angel Carpintero -+ * Copyright (C) 2008 Angel Carpintero - * - * based on jdatasrc.c and jdatadst.c from the Independent - * JPEG Group's software by Thomas G. Lane -@@ -35,7 +35,7 @@ - #include - #include - -- /* -+/* - * jpeg_data: buffer with input / output jpeg - * len: Length of jpeg buffer - * itype: 0: Not interlaced -@@ -49,8 +49,6 @@ - * width width of Y channel (width of U/V is width/2) - * height height of Y channel (height of U/V is height/2) - */ -- -- - static void jpeg_buffer_src(j_decompress_ptr cinfo, unsigned char *buffer, - long num); - static void jpeg_buffer_dest(j_compress_ptr cinfo, unsigned char *buffer, -@@ -70,13 +68,11 @@ static void jpeg_skip_ff(j_decompress_pt - * Initialize source --- called by jpeg_read_header - * before any data is actually read. - */ -- - static void init_source(j_decompress_ptr cinfo ATTRIBUTE_UNUSED) - { -- /* no work necessary here */ -+ /* No work necessary here */ - } - -- - /* - * Fill the input buffer --- called whenever buffer is emptied. - * -@@ -85,7 +81,6 @@ static void init_source(j_decompress_ptr - * which is the JPEG EOI marker; - * - */ -- - static uint8_t EOI_data[2] = { 0xFF, 0xD9 }; - - static boolean fill_input_buffer(j_decompress_ptr cinfo) -@@ -101,7 +96,6 @@ static boolean fill_input_buffer(j_decom - * uninteresting data (such as an APPn marker). - * - */ -- - static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) - { - if (num_bytes > 0) { -@@ -117,27 +111,25 @@ static void skip_input_data(j_decompress - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - */ -- - static void term_source(j_decompress_ptr cinfo ATTRIBUTE_UNUSED) - { -- /* no work necessary here */ -+ /* No work necessary here */ - } - - - /* - * Prepare for input from a data buffer. - */ -- - static void jpeg_buffer_src(j_decompress_ptr cinfo, unsigned char *buffer, long num) - { - /* The source object and input buffer are made permanent so that a series --* of JPEG images can be read from the same buffer by calling jpeg_buffer_src --* only before the first one. (If we discarded the buffer at the end of --* one image, we'd likely lose the start of the next one.) --* This makes it unsafe to use this manager and a different source --* manager serially with the same JPEG object. Caveat programmer. --*/ -- if (cinfo->src == NULL) { /* first time for this JPEG object? */ -+ * of JPEG images can be read from the same buffer by calling jpeg_buffer_src -+ * only before the first one. (If we discarded the buffer at the end of -+ * one image, we'd likely lose the start of the next one.) -+ * This makes it unsafe to use this manager and a different source -+ * manager serially with the same JPEG object. Caveat programmer. -+ */ -+ if (cinfo->src == NULL) { /* First time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - sizeof (struct jpeg_source_mgr)); -@@ -146,7 +138,7 @@ static void jpeg_buffer_src(j_decompress - cinfo->src->init_source = init_source; - cinfo->src->fill_input_buffer = fill_input_buffer; - cinfo->src->skip_input_data = skip_input_data; -- cinfo->src->resync_to_restart = jpeg_resync_to_restart; /* use default method */ -+ cinfo->src->resync_to_restart = jpeg_resync_to_restart; /* Use default method */ - cinfo->src->term_source = term_source; - cinfo->src->bytes_in_buffer = num; - cinfo->src->next_input_byte = (JOCTET *) buffer; -@@ -158,7 +150,6 @@ static void jpeg_buffer_src(j_decompress - * particularly useful when reading several images from the same buffer: - * It should be called to skip padding 0xff bytes beetween images. - */ -- - static void jpeg_skip_ff(j_decompress_ptr cinfo) - { - while (cinfo->src->bytes_in_buffer > 1 -@@ -183,7 +174,6 @@ static void jpeg_skip_ff(j_decompress_pt - * Initialize destination --- called by jpeg_start_compress - * before any data is actually written. - */ -- - static void init_destination(j_compress_ptr cinfo ATTRIBUTE_UNUSED) - { - /* No work necessary here */ -@@ -197,12 +187,11 @@ static void init_destination(j_compress_ - * If it gets called, the given jpeg buffer was too small. - * - */ -- - static boolean empty_output_buffer(j_compress_ptr cinfo) - { - /*FIXME: */ -- motion_log(LOG_ERR, 0, "%s: Given jpeg buffer was too small", __FUNCTION__); -- ERREXIT (cinfo, JERR_BUFFER_SIZE); /* shouldn't be FILE_WRITE but BUFFER_OVERRUN! */ -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Given jpeg buffer was too small"); -+ ERREXIT (cinfo, JERR_BUFFER_SIZE); /* Shouldn't be FILE_WRITE but BUFFER_OVERRUN! */ - return TRUE; - } - -@@ -215,10 +204,9 @@ static boolean empty_output_buffer(j_com - * application must deal with any cleanup that should happen even - * for error exit. - */ -- - static void term_destination(j_compress_ptr cinfo ATTRIBUTE_UNUSED) - { -- /* no work necessary here */ -+ /* No work necessary here */ - } - - -@@ -231,13 +219,14 @@ static void term_destination(j_compress_ - static void jpeg_buffer_dest(j_compress_ptr cinfo, unsigned char *buf, long len) - { - -- /* The destination object is made permanent so that multiple JPEG images -- * can be written to the same file without re-executing jpeg_stdio_dest. -+ /* -+ * The destination object is made permanent so that multiple JPEG images -+ * can be written to the same file without re-executing jpeg_stdio_dest. - * This makes it dangerous to use this manager and a different destination - * manager serially with the same JPEG object, because their private object - * sizes may be different. Caveat programmer. - */ -- if (cinfo->dest == NULL) { /* first time for this JPEG object? */ -+ if (cinfo->dest == NULL) { /* First time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - sizeof (struct jpeg_destination_mgr)); -@@ -264,39 +253,40 @@ static void jpeg_buffer_dest(j_compress_ - * The following kind of error handling is from the - * example.c file in the Independent JPEG Group's JPEG software - */ -- - struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ -- jmp_buf setjmp_buffer; /* for return to caller */ -+ jmp_buf setjmp_buffer; /* For return to caller */ - -- /* original emit_message method */ -+ /* Original emit_message method. */ - JMETHOD(void, original_emit_message, (j_common_ptr cinfo, int msg_level)); -- /* was a corrupt-data warning seen */ -+ /* Was a corrupt-data warning seen. */ - int warning_seen; - }; - - static void my_error_exit(j_common_ptr cinfo) - { -- /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ -+ /* cinfo->err really points to a my_error_mgr struct, so coerce pointer. */ - struct my_error_mgr *myerr = (struct my_error_mgr *) cinfo->err; - -- /* Always display the message. */ -- /* We could postpone this until after returning, if we chose. */ -+ /* -+ * Always display the message. -+ * We could postpone this until after returning, if we chose. -+ */ - (*cinfo->err->output_message) (cinfo); - -- /* Return control to the setjmp point */ -+ /* Return control to the setjmp point. */ - longjmp (myerr->setjmp_buffer, 1); - } - - static void my_emit_message(j_common_ptr cinfo, int msg_level) - { -- /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ -+ /* cinfo->err really points to a my_error_mgr struct, so coerce pointer. */ - struct my_error_mgr *myerr = (struct my_error_mgr *) cinfo->err; - -- if(msg_level < 0) -+ if (msg_level < 0) - myerr->warning_seen = 1; - -- /* call original emit_message() */ -+ /* Call original emit_message() */ - (myerr->original_emit_message)(cinfo, msg_level); - } - -@@ -311,9 +301,9 @@ static unsigned char chr2[8][MAX_CHROMA_ - - - --#if 1 /* generation of 'std' Huffman tables... */ -+#if 1 /* Generation of 'std' Huffman tables... */ - --static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, -+static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, - const UINT8 *bits, const UINT8 *val) - /* Define a Huffman table */ - { -@@ -322,23 +312,23 @@ static void add_huff_table(j_decompress_ - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) dinfo); - -- /* Copy the number-of-symbols-of-each-code-length counts */ -- memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); -+ /* Copy the number-of-symbols-of-each-code-length counts. */ -+ memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); -+ -+ /* -+ * Validate the counts. We do this here mainly so we can copy the right -+ * number of symbols from the val[] array, without risking marching off -+ * the end of memory. jchuff.c will do a more thorough test later. -+ */ -+ nsymbols = 0; - -- /* Validate the counts. We do this here mainly so we can copy the right -- * number of symbols from the val[] array, without risking marching off -- * the end of memory. jchuff.c will do a more thorough test later. -- */ -- nsymbols = 0; -- -- for (len = 1; len <= 16; len++) -- nsymbols += bits[len]; -- -- if (nsymbols < 1 || nsymbols > 256) -- motion_log(LOG_ERR, 0, "%s: Given jpeg buffer was too small", -- __FUNCTION__); -+ for (len = 1; len <= 16; len++) -+ nsymbols += bits[len]; - -- memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8)); -+ if (nsymbols < 1 || nsymbols > 256) -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Given jpeg buffer was too small"); -+ -+ memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8)); - } - - -@@ -351,12 +341,12 @@ static void std_huff_tables (j_decompres - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; -- -+ - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; -- -+ - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = -@@ -381,7 +371,7 @@ static void std_huff_tables (j_decompres - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; -- -+ - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = -@@ -406,7 +396,7 @@ static void std_huff_tables (j_decompres - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; -- -+ - add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[0], -@@ -443,29 +433,28 @@ static void guarantee_huff_tables(j_deco - * ctype Chroma format for decompression. - * Currently only Y4M_CHROMA_{420JPEG,422} are available - * returns: -- * -1 on fatal error -- * 0 on success -- * 1 if jpeg lib threw a "corrupt jpeg data" warning. -- * in this case, "a damaged output image is likely." -- * -+ * -1 on fatal error -+ * 0 on success -+ * 1 if jpeg lib threw a "corrupt jpeg data" warning. -+ * in this case, "a damaged output image is likely." -+ * - */ -- - int decode_jpeg_raw (unsigned char *jpeg_data, int len, -- int itype, int ctype, unsigned int width, -- unsigned int height, unsigned char *raw0, -+ int itype, int ctype, unsigned int width, -+ unsigned int height, unsigned char *raw0, - unsigned char *raw1, unsigned char *raw2) - { - int numfields, hsf[3], field, yl, yc; - int i, xsl, xsc, xs, hdown; - unsigned int x, y = 0, vsf[3], xd; -- -+ - JSAMPROW row0[16] = { buf0[0], buf0[1], buf0[2], buf0[3], - buf0[4], buf0[5], buf0[6], buf0[7], - buf0[8], buf0[9], buf0[10], buf0[11], - buf0[12], buf0[13], buf0[14], buf0[15]}; - - JSAMPROW row1[8] = { buf1[0], buf1[1], buf1[2], buf1[3], -- buf1[4], buf1[5], buf1[6], buf1[7]}; -+ buf1[4], buf1[5], buf1[6], buf1[7]}; - - JSAMPROW row2[16] = { buf2[0], buf2[1], buf2[2], buf2[3], - buf2[4], buf2[5], buf2[6], buf2[7]}; -@@ -480,7 +469,7 @@ int decode_jpeg_raw (unsigned char *jpeg - /* We set up the normal JPEG error routines, then override error_exit. */ - dinfo.err = jpeg_std_error (&jerr.pub); - jerr.pub.error_exit = my_error_exit; -- /* also hook the emit_message routine to note corrupt-data warnings */ -+ /* Also hook the emit_message routine to note corrupt-data warnings. */ - jerr.original_emit_message = jerr.pub.emit_message; - jerr.pub.emit_message = my_emit_message; - jerr.warning_seen = 0; -@@ -489,26 +478,30 @@ int decode_jpeg_raw (unsigned char *jpeg - if (setjmp (jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. */ - jpeg_destroy_decompress (&dinfo); -- return -1; -+ return 1; - } - - jpeg_create_decompress (&dinfo); - - jpeg_buffer_src (&dinfo, jpeg_data, len); - -- /* Read header, make some checks and try to figure out what the -- user really wants */ -- -+ /* -+ * Read header, make some checks and try to figure out what the -+ * user really wants. -+ */ - jpeg_read_header (&dinfo, TRUE); - dinfo.raw_data_out = TRUE; -+#if JPEG_LIB_VERSION >= 70 -+ dinfo.do_fancy_upsampling = FALSE; -+#endif - dinfo.out_color_space = JCS_YCbCr; - dinfo.dct_method = JDCT_IFAST; - guarantee_huff_tables(&dinfo); - jpeg_start_decompress (&dinfo); - - if (dinfo.output_components != 3) { -- motion_log(LOG_ERR, 0, "%s: Output components of JPEG image = %d, must be 3", -- __FUNCTION__, dinfo.output_components); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Output components of JPEG image" -+ " = %d, must be 3", dinfo.output_components); - goto ERR_EXIT; - } - -@@ -519,43 +512,44 @@ int decode_jpeg_raw (unsigned char *jpeg - - if ((hsf[0] != 2 && hsf[0] != 1) || hsf[1] != 1 || hsf[2] != 1 || - (vsf[0] != 1 && vsf[0] != 2) || vsf[1] != 1 || vsf[2] != 1) { -- motion_log(LOG_ERR, 0, "%s: Unsupported sampling factors, hsf=(%d, %d, %d) " -- "vsf=(%d, %d, %d) !", __FUNCTION__, hsf[0], hsf[1], hsf[2], vsf[0], vsf[1], vsf[2]); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Unsupported sampling factors," -+ " hsf=(%d, %d, %d) vsf=(%d, %d, %d) !", hsf[0], hsf[1], -+ hsf[2], vsf[0], vsf[1], vsf[2]); - goto ERR_EXIT; - } - - if (hsf[0] == 1) { - if (height % 8 != 0) { -- motion_log(LOG_ERR, 0, "%s: YUV 4:4:4 sampling, but image height %d " -- "not dividable by 8 !", __FUNCTION__, height); -- goto ERR_EXIT; -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: YUV 4:4:4 sampling, but image" -+ " height %d not dividable by 8 !", height); -+ goto ERR_EXIT; - } - -- for (y = 0; y < 16; y++) { // allocate a special buffer for the extra sampling depth -+ for (y = 0; y < 16; y++) { // Allocate a special buffer for the extra sampling depth. - row1_444[y] = (unsigned char *)malloc(dinfo.output_width * sizeof(char)); - row2_444[y] = (unsigned char *)malloc(dinfo.output_width * sizeof(char)); - } -- scanarray[1] = row1_444; -- scanarray[2] = row2_444; -+ scanarray[1] = row1_444; -+ scanarray[2] = row2_444; - } - -- /* Height match image height or be exact twice the image height */ -+ /* Height match image height or be exact twice the image height. */ - - if (dinfo.output_height == height) { - numfields = 1; - } else if (2 * dinfo.output_height == height) { - numfields = 2; - } else { -- motion_log(LOG_ERR, 0, "%s: Read JPEG: requested height = %d, " -- "height of image = %d", __FUNCTION__, height, dinfo.output_height); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Read JPEG: requested height = %d, " -+ "height of image = %d", height, dinfo.output_height); - goto ERR_EXIT; - } - - /* Width is more flexible */ - - if (dinfo.output_width > MAX_LUMA_WIDTH) { -- motion_log(LOG_ERR, 0, "%s: Image width of %d exceeds max", -- __FUNCTION__, dinfo.output_width); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image width of %d exceeds max", -+ dinfo.output_width); - goto ERR_EXIT; - } - -@@ -567,7 +561,7 @@ int decode_jpeg_raw (unsigned char *jpeg - else - xsl = 0; - } else if (width == 2 * dinfo.output_width / 3) { -- /* special case of 3:2 downsampling */ -+ /* Special case of 3:2 downsampling */ - hdown = 2; - xsl = 0; - } else { -@@ -590,6 +584,9 @@ int decode_jpeg_raw (unsigned char *jpeg - if (field > 0) { - jpeg_read_header (&dinfo, TRUE); - dinfo.raw_data_out = TRUE; -+#if JPEG_LIB_VERSION >= 70 -+ dinfo.do_fancy_upsampling = FALSE; -+#endif - dinfo.out_color_space = JCS_YCbCr; - dinfo.dct_method = JDCT_IFAST; - jpeg_start_decompress (&dinfo); -@@ -604,16 +601,16 @@ int decode_jpeg_raw (unsigned char *jpeg - yl = yc = (1 - field); - break; - default: -- motion_log(LOG_ERR, 0, "%s: Input is interlaced but no interlacing set", -- __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Input is interlaced but" -+ " no interlacing set"); - goto ERR_EXIT; - } - } else { - yl = yc = 0; -- } -+ } - - while (dinfo.output_scanline < dinfo.output_height) { -- /* read raw data */ -+ /* Read raw data */ - jpeg_read_raw_data (&dinfo, scanarray, 8 * vsf[0]); - - for (y = 0; y < 8 * vsf[0]; yl += numfields, y++) { -@@ -631,7 +628,7 @@ int decode_jpeg_raw (unsigned char *jpeg - raw0[xd] = (2 * row0[y][xs] + row0[y][xs + 1]) / 3; - raw0[xd + 1] = (2 * row0[y][xs + 2] + row0[y][xs + 1]) / 3; - } -- } -+ } - } - - /* Horizontal downsampling of chroma */ -@@ -639,23 +636,23 @@ int decode_jpeg_raw (unsigned char *jpeg - for (y = 0; y < 8; y++) { - xs = xsc; - -- if (hsf[0] == 1) -- for (x = 0; x < width / 2; x++, xs++) { -- row1[y][xs] = (row1_444[y][2*x] + row1_444[y][2*x + 1]) >> 1; -- row2[y][xs] = (row2_444[y][2*x] + row2_444[y][2*x + 1]) >> 1; -- } -+ if (hsf[0] == 1) -+ for (x = 0; x < width / 2; x++, xs++) { -+ row1[y][xs] = (row1_444[y][2*x] + row1_444[y][2*x + 1]) >> 1; -+ row2[y][xs] = (row2_444[y][2*x] + row2_444[y][2*x + 1]) >> 1; -+ } - - xs = xsc; - if (hdown == 0) { - for (x = 0; x < width / 2; x++, xs++) { -- chr1[y][x] = row1[y][xs]; -- chr2[y][x] = row2[y][xs]; -- } -+ chr1[y][x] = row1[y][xs]; -+ chr2[y][x] = row2[y][xs]; -+ } - } else if (hdown == 1) { - for (x = 0; x < width / 2; x++, xs += 2) { - chr1[y][x] = (row1[y][xs] + row1[y][xs + 1]) >> 1; - chr2[y][x] = (row2[y][xs] + row2[y][xs + 1]) >> 1; -- } -+ } - } else { - for (x = 0; x < width / 2; x += 2, xs += 3) { - chr1[y][x] = (2 * row1[y][xs] + row1[y][xs + 1]) / 3; -@@ -663,7 +660,7 @@ int decode_jpeg_raw (unsigned char *jpeg - chr2[y][x] = (2 * row2[y][xs] + row2[y][xs + 1]) / 3; - chr2[y][x + 1] = (2 * row2[y][xs + 2] + row2[y][xs + 1]) / 3; - } -- } -+ } - } - - /* Vertical resampling of chroma */ -@@ -671,68 +668,68 @@ int decode_jpeg_raw (unsigned char *jpeg - switch (ctype) { - case Y4M_CHROMA_422: - if (vsf[0] == 1) { -- /* Just copy */ -- for (y = 0; y < 8 /*&& yc < height */; y++, yc += numfields) { -- xd = yc * width / 2; -- -- for (x = 0; x < width / 2; x++, xd++) { -- raw1[xd] = chr1[y][x]; -- raw2[xd] = chr2[y][x]; -- } -- } -- } else { -- /* upsample */ -- for (y = 0; y < 8 /*&& yc < height */; y++) { -- xd = yc * width / 2; -- -+ /* Just copy */ -+ for (y = 0; y < 8 /*&& yc < height */; y++, yc += numfields) { -+ xd = yc * width / 2; -+ -+ for (x = 0; x < width / 2; x++, xd++) { -+ raw1[xd] = chr1[y][x]; -+ raw2[xd] = chr2[y][x]; -+ } -+ } -+ } else { -+ /* upsample */ -+ for (y = 0; y < 8 /*&& yc < height */; y++) { -+ xd = yc * width / 2; -+ -+ for (x = 0; x < width / 2; x++, xd++) { -+ raw1[xd] = chr1[y][x]; -+ raw2[xd] = chr2[y][x]; -+ } -+ -+ yc += numfields; -+ xd = yc * width / 2; -+ - for (x = 0; x < width / 2; x++, xd++) { -- raw1[xd] = chr1[y][x]; -- raw2[xd] = chr2[y][x]; -- } -- -- yc += numfields; -- xd = yc * width / 2; -- -- for (x = 0; x < width / 2; x++, xd++) { -- raw1[xd] = chr1[y][x]; -- raw2[xd] = chr2[y][x]; -- } -- -- yc += numfields; -- } -- } -- break; -- default: -+ raw1[xd] = chr1[y][x]; -+ raw2[xd] = chr2[y][x]; -+ } -+ -+ yc += numfields; -+ } -+ } -+ break; -+ default: - /* -- * should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some -- * pass things like '420' in with the expectation that anything other than -- * Y4M_CHROMA_422 will default to 420JPEG. -- */ -+ * Should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some -+ * pass things like '420' in with the expectation that anything other than -+ * Y4M_CHROMA_422 will default to 420JPEG. -+ */ - if (vsf[0] == 1) { -- /* Really downsample */ -- for (y = 0; y < 8 /*&& yc < height/2*/; y += 2, yc += numfields) { -- xd = yc * width / 2; -- -- for (x = 0; x < width / 2; x++, xd++) { -- assert(xd < (width * height / 4)); -- raw1[xd] = (chr1[y][x] + chr1[y + 1][x]) >> 1; -- raw2[xd] = (chr2[y][x] + chr2[y + 1][x]) >> 1; -- } -- } -- -- } else { -- /* Just copy */ -- for (y = 0; y < 8 /*&& yc < height/2 */; y++, yc += numfields) { -- xd = yc * width / 2; -- -+ /* Really downsample */ -+ for (y = 0; y < 8 /*&& yc < height/2*/; y += 2, yc += numfields) { -+ xd = yc * width / 2; -+ - for (x = 0; x < width / 2; x++, xd++) { -- raw1[xd] = chr1[y][x]; -- raw2[xd] = chr2[y][x]; -- } -- } -- } -- break; -- } -+ assert(xd < (width * height / 4)); -+ raw1[xd] = (chr1[y][x] + chr1[y + 1][x]) >> 1; -+ raw2[xd] = (chr2[y][x] + chr2[y + 1][x]) >> 1; -+ } -+ } -+ -+ } else { -+ /* Just copy */ -+ for (y = 0; y < 8 /* && yc < height / 2 */; y++, yc += numfields) { -+ xd = yc * width / 2; -+ -+ for (x = 0; x < width / 2; x++, xd++) { -+ raw1[xd] = chr1[y][x]; -+ raw2[xd] = chr2[y][x]; -+ } -+ } -+ } -+ break; -+ } - } - - (void) jpeg_finish_decompress (&dinfo); -@@ -741,10 +738,10 @@ int decode_jpeg_raw (unsigned char *jpeg - } - - if (hsf[0] == 1) { -- for (y = 0; y < 16; y++) { // allocate a special buffer for the extra sampling depth -+ for (y = 0; y < 16; y++) { // Allocate a special buffer for the extra sampling depth. - free(row1_444[y]); -- free(row2_444[y]); -- } -+ free(row2_444[y]); -+ } - } - - jpeg_destroy_decompress (&dinfo); -@@ -768,13 +765,12 @@ ERR_EXIT: - * ctype Chroma format for decompression. - * Currently only Y4M_CHROMA_{420JPEG,422} are available - */ -- - int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, -- int itype, int ctype, unsigned int width, -- unsigned int height, unsigned char *raw0, -+ int itype, int ctype, unsigned int width, -+ unsigned int height, unsigned char *raw0, - unsigned char *raw1, unsigned char *raw2) - { -- int numfields, hsf[3], field, yl, yc, xsl, xsc, xs, xd, hdown; -+ int numfields, field, yl, yc, xsl, xsc, xs, xd, hdown; - unsigned int x, y, vsf[3]; - - JSAMPROW row0[16] = { buf0[0], buf0[1], buf0[2], buf0[3], -@@ -801,43 +797,46 @@ int decode_jpeg_gray_raw(unsigned char * - - jpeg_buffer_src (&dinfo, jpeg_data, len); - -- /* Read header, make some checks and try to figure out what the -- user really wants */ -- -+ /* -+ * Read header, make some checks and try to figure out what the -+ * user really wants. -+ */ - jpeg_read_header (&dinfo, TRUE); - dinfo.raw_data_out = TRUE; -+#if JPEG_LIB_VERSION >= 70 -+ dinfo.do_fancy_upsampling = FALSE; -+#endif - dinfo.out_color_space = JCS_GRAYSCALE; - dinfo.dct_method = JDCT_IFAST; -- -- if (dinfo.jpeg_color_space != JCS_GRAYSCALE) { -- motion_log(LOG_ERR, 0, "%s: Expected grayscale colorspace for JPEG raw decoding", -- __FUNCTION__); -+ -+ if (dinfo.jpeg_color_space != JCS_GRAYSCALE) { -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Expected grayscale colorspace" -+ " for JPEG raw decoding"); - goto ERR_EXIT; - } - - guarantee_huff_tables(&dinfo); - jpeg_start_decompress (&dinfo); - -- hsf[0] = 1; hsf[1] = 1; hsf[2] = 1; - vsf[0]= 1; vsf[1] = 1; vsf[2] = 1; - -- /* Height match image height or be exact twice the image height */ -+ /* Height match image height or be exact twice the image height. */ - - if (dinfo.output_height == height) { - numfields = 1; - } else if (2 * dinfo.output_height == height) { - numfields = 2; - } else { -- motion_log(LOG_ERR, 0, "%s: Read JPEG: requested height = %d, " -- "height of image = %d", __FUNCTION__, height, dinfo.output_height); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Read JPEG: requested height = %d, " -+ "height of image = %d", height, dinfo.output_height); - goto ERR_EXIT; - } - - /* Width is more flexible */ - - if (dinfo.output_width > MAX_LUMA_WIDTH) { -- motion_log(LOG_ERR, 0, "%s: Image width of %d exceeds max", -- __FUNCTION__, dinfo.output_width); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image width of %d exceeds max", -+ dinfo.output_width); - goto ERR_EXIT; - } - -@@ -872,6 +871,9 @@ int decode_jpeg_gray_raw(unsigned char * - if (field > 0) { - jpeg_read_header (&dinfo, TRUE); - dinfo.raw_data_out = TRUE; -+#if JPEG_LIB_VERSION >= 70 -+ dinfo.do_fancy_upsampling = FALSE; -+#endif - dinfo.out_color_space = JCS_GRAYSCALE; - dinfo.dct_method = JDCT_IFAST; - jpeg_start_decompress (&dinfo); -@@ -886,13 +888,13 @@ int decode_jpeg_gray_raw(unsigned char * - yl = yc = (1 - field); - break; - default: -- motion_log(LOG_ERR, 0, "%s: Input is interlaced but no interlacing set", -- __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Input is interlaced" -+ " but no interlacing set"); - goto ERR_EXIT; - } - } else { - yl = yc = 0; -- } -+ } - - while (dinfo.output_scanline < dinfo.output_height) { - jpeg_read_raw_data (&dinfo, scanarray, 16); -@@ -901,10 +903,10 @@ int decode_jpeg_gray_raw(unsigned char * - xd = yl * width; - xs = xsl; - -- if (hdown == 0) { // no horiz downsampling -+ if (hdown == 0) { // No horiz downsampling - for (x = 0; x < width; x++) - raw0[xd++] = row0[y][xs++]; -- } else if (hdown == 1) { // half the res -+ } else if (hdown == 1) { // Half the res - for (x = 0; x < width; x++, xs += 2) - raw0[xd++] = (row0[y][xs] + row0[y][xs + 1]) >> 1; - } else { // 2:3 downsampling -@@ -912,7 +914,7 @@ int decode_jpeg_gray_raw(unsigned char * - raw0[xd] = (2 * row0[y][xs] + row0[y][xs + 1]) / 3; - raw0[xd + 1] = (2 * row0[y][xs + 2] + row0[y][xs + 1]) / 3; - } -- } -+ } - } - - -@@ -923,21 +925,21 @@ int decode_jpeg_gray_raw(unsigned char * - for (x = 0; x < width / 2; x++, xs++) { - chr1[y][x] = 0; //row1[y][xs]; - chr2[y][x] = 0; //row2[y][xs]; -- } -+ } - } else if (hdown == 1) { - for (x = 0; x < width / 2; x++, xs += 2) { -- chr1[y][x] = 0; //(row1[y][xs] + row1[y][xs + 1]) >> 1; -- chr2[y][x] = 0; //(row2[y][xs] + row2[y][xs + 1]) >> 1; -- } -+ chr1[y][x] = 0; //(row1[y][xs] + row1[y][xs + 1]) >> 1; -+ chr2[y][x] = 0; //(row2[y][xs] + row2[y][xs + 1]) >> 1; -+ } - } else { - for (x = 0; x < width / 2; x += 2, xs += 3) { -- chr1[y][x] = 0; //(2 * row1[y][xs] + row1[y][xs + 1]) / 3; -- chr1[y][x + 1] = 0; -- //(2 * row1[y][xs + 2] + row1[y][xs + 1]) / 3; -- chr2[y][x] = 0; // (2 * row2[y][xs] + row2[y][xs + 1]) / 3; -- chr2[y][x + 1] = 0; -- //(2 * row2[y][xs + 2] + row2[y][xs + 1]) / 3; -- } -+ chr1[y][x] = 0; //(2 * row1[y][xs] + row1[y][xs + 1]) / 3; -+ chr1[y][x + 1] = 0; -+ //(2 * row1[y][xs + 2] + row1[y][xs + 1]) / 3; -+ chr2[y][x] = 0; // (2 * row2[y][xs] + row2[y][xs + 1]) / 3; -+ chr2[y][x + 1] = 0; -+ //(2 * row2[y][xs + 2] + row2[y][xs + 1]) / 3; -+ } - } - } - -@@ -945,7 +947,7 @@ int decode_jpeg_gray_raw(unsigned char * - case Y4M_CHROMA_422: - if (vsf[0] == 1) { - /* Just copy */ -- for (y = 0; y < 8 /*&& yc < height */; y++, yc += numfields) { -+ for (y = 0; y < 8 /* && yc < height */; y++, yc += numfields) { - xd = yc * width / 2; - - for (x = 0; x < width / 2; x++, xd++) { -@@ -955,9 +957,9 @@ int decode_jpeg_gray_raw(unsigned char * - } - } else { - /* upsample */ -- for (y = 0; y < 8 /*&& yc < height */; y++) { -+ for (y = 0; y < 8 /* && yc < height */; y++) { - xd = yc * width / 2; -- -+ - for (x = 0; x < width / 2; x++, xd++) { - raw1[xd] = 127; //chr1[y][x]; - raw2[xd] = 127; //chr2[y][x]; -@@ -965,22 +967,22 @@ int decode_jpeg_gray_raw(unsigned char * - - yc += numfields; - xd = yc * width / 2; -- -+ - for (x = 0; x < width / 2; x++, xd++) { - raw1[xd] = 127; //chr1[y][x]; - raw2[xd] = 127; //chr2[y][x]; - } - - yc += numfields; -- } -- } -- break; -+ } -+ } -+ break; - /* -- * should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some -+ * Should be case Y4M_CHROMA_420JPEG: but use default: for compatibility. Some - * pass things like '420' in with the expectation that anything other than - * Y4M_CHROMA_422 will default to 420JPEG. - */ -- default: -+ default: - if (vsf[0] == 1) { - /* Really downsample */ - for (y = 0; y < 8; y += 2, yc += numfields) { -@@ -988,11 +990,11 @@ int decode_jpeg_gray_raw(unsigned char * - - for (x = 0; x < width / 2; x++, xd++) { - raw1[xd] = 127; //(chr1[y][x] + chr1[y + 1][x]) >> 1; -- raw2[xd] = 127; //(chr2[y][x] + chr2[y + 1][x]) >> 1; -+ raw2[xd] = 127; //(chr2[y][x] + chr2[y + 1][x]) >> 1; - } -- } -- } else { -- /* Just copy */ -+ } -+ } else { -+ /* Just copy */ - - for (y = 0; y < 8; y++, yc += numfields) { - xd = yc * width / 2; -@@ -1000,11 +1002,11 @@ int decode_jpeg_gray_raw(unsigned char * - for (x = 0; x < width / 2; x++, xd++) { - raw1[xd] = 127; //chr1[y][x]; - raw2[xd] = 127; //chr2[y][x]; -- } -- } -- } -- break; -- } -+ } -+ } -+ } -+ break; -+ } - } - - (void) jpeg_finish_decompress (&dinfo); -@@ -1028,8 +1030,8 @@ ERR_EXIT: - * may be interlaced * - * * - *******************************************************************/ -- -- /* -+ -+/* - * jpeg_data: Buffer to hold output jpeg - * len: Length of buffer - * itype: 0: Not interlaced -@@ -1038,10 +1040,9 @@ ERR_EXIT: - * ctype Chroma format for decompression. - * Currently only Y4M_CHROMA_{420JPEG,422} are available - */ -- - int encode_jpeg_raw(unsigned char *jpeg_data, int len, int quality, -- int itype, int ctype, unsigned int width, -- unsigned int height, unsigned char *raw0, -+ int itype, int ctype, unsigned int width, -+ unsigned int height, unsigned char *raw0, - unsigned char *raw1, unsigned char *raw2) - { - int numfields, field, yl, yc, y, i; -@@ -1090,22 +1091,22 @@ int encode_jpeg_raw(unsigned char *jpeg_ - cinfo.input_gamma = 1.0; - - cinfo.comp_info[0].h_samp_factor = 2; -- cinfo.comp_info[0].v_samp_factor = 1; /*1||2 */ -+ cinfo.comp_info[0].v_samp_factor = 1; /*1||2 */ - cinfo.comp_info[1].h_samp_factor = 1; - cinfo.comp_info[1].v_samp_factor = 1; -- cinfo.comp_info[2].h_samp_factor = 1; /*1||2 */ -+ cinfo.comp_info[2].h_samp_factor = 1; /*1||2 */ - cinfo.comp_info[2].v_samp_factor = 1; - - - if ((width > 4096) || (height > 4096)) { -- motion_log(LOG_ERR, 0, "%s: Image dimensions (%dx%d) exceed lavtools' max " -- "(4096x4096)", __FUNCTION__, width, height); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image dimensions (%dx%d) exceed" -+ " lavtools' max (4096x4096)", width, height); - goto ERR_EXIT; - } - - if ((width % 16) || (height % 16)) { -- motion_log(LOG_ERR, 0, "%s: Image dimensions (%dx%d) not multiples of 16", -- __FUNCTION__, width, height); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image dimensions (%dx%d) not" -+ " multiples of 16", width, height); - goto ERR_EXIT; - } - -@@ -1113,14 +1114,14 @@ int encode_jpeg_raw(unsigned char *jpeg_ - - switch (itype) { - case Y4M_ILACE_TOP_FIRST: -- case Y4M_ILACE_BOTTOM_FIRST: /* interlaced */ -+ case Y4M_ILACE_BOTTOM_FIRST: /* Interlaced */ - numfields = 2; - break; - default: - numfields = 1; - if (height > 2048) { -- motion_log(LOG_ERR, 0, "%s: Image height (%d) exceeds lavtools max " -- "for non-interlaced frames", __FUNCTION__, height); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Image height (%d) exceeds" -+ " lavtools max for non-interlaced frames", height); - goto ERR_EXIT; - } - } -@@ -1131,7 +1132,7 @@ int encode_jpeg_raw(unsigned char *jpeg_ - - for (field = 0; field < numfields; field++) { - jpeg_start_compress (&cinfo, FALSE); -- -+ - if (numfields == 2) { - static const JOCTET marker0[40]; - -@@ -1139,22 +1140,22 @@ int encode_jpeg_raw(unsigned char *jpeg_ - jpeg_write_marker(&cinfo, JPEG_APP0 + 1, marker0, 40); - - switch (itype) { -- case Y4M_ILACE_TOP_FIRST: /* top field first */ -+ case Y4M_ILACE_TOP_FIRST: /* Top field first */ - yl = yc = field; - break; -- case Y4M_ILACE_BOTTOM_FIRST: /* bottom field first */ -+ case Y4M_ILACE_BOTTOM_FIRST: /* Bottom field first */ - yl = yc = (1 - field); - break; - default: -- motion_log(LOG_ERR, 0, "%s: Input is interlaced but no interlacing set", -- __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Input is interlaced" -+ " but no interlacing set"); - goto ERR_EXIT; - } - - } else { - yl = yc = 0; - } -- -+ - while (cinfo.next_scanline < cinfo.image_height) { - - for (y = 0; y < 8 * cinfo.comp_info[0].v_samp_factor; -@@ -1177,12 +1178,12 @@ int encode_jpeg_raw(unsigned char *jpeg_ - - (void) jpeg_finish_compress (&cinfo); - } -- -+ - /* FIXME */ - i = len - cinfo.dest->free_in_buffer; - - jpeg_destroy_compress (&cinfo); -- return i; /* size of jpeg */ -+ return i; /* Size of jpeg */ - - ERR_EXIT: - jpeg_destroy_compress (&cinfo); ---- motion-3.2.12.orig/jpegutils.h -+++ motion-3.2.12/jpegutils.h -@@ -1,10 +1,10 @@ --/* -+/* - * jpegutils.h: Some Utility programs for dealing with - * JPEG encoded images - * - * Copyright (C) 1999 Rainer Johanni - * Copyright (C) 2001 pHilipp Zabel -- * Copyright (C) 2008 Angel Carpintero -+ * Copyright (C) 2008 Angel Carpintero - * - */ - -@@ -44,17 +44,17 @@ - - - int decode_jpeg_raw(unsigned char *jpeg_data, int len, -- int itype, int ctype, unsigned int width, -- unsigned int height, unsigned char *raw0, -+ int itype, int ctype, unsigned int width, -+ unsigned int height, unsigned char *raw0, - unsigned char *raw1, unsigned char *raw2); - - int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, -- int itype, int ctype, unsigned int width, -- unsigned int height, unsigned char *raw0, -+ int itype, int ctype, unsigned int width, -+ unsigned int height, unsigned char *raw0, - unsigned char *raw1, unsigned char *raw2); - - int encode_jpeg_raw(unsigned char *jpeg_data, int len, int quality, -- int itype, int ctype, unsigned int width, -- unsigned int height, unsigned char *raw0, -+ int itype, int ctype, unsigned int width, -+ unsigned int height, unsigned char *raw0, - unsigned char *raw1, unsigned char *raw2); - #endif ---- /dev/null -+++ motion-3.2.12/logger.c -@@ -0,0 +1,259 @@ -+/* -+ * logger.c -+ * -+ * Logger for motion -+ * -+ * Copyright 2005, William M. Brack -+ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) -+ * This software is distributed under the GNU Public License Version 2 -+ * See also the file 'COPYING'. -+ * -+ */ -+ -+#include "logger.h" /* already includes motion.h */ -+#include -+ -+static int log_mode = LOGMODE_SYSLOG; -+static FILE *logfile; -+static unsigned int log_level = LEVEL_DEFAULT; -+static unsigned int log_type = TYPE_DEFAULT; -+ -+static const char *log_type_str[] = {NULL, "COR", "STR", "ENC", "NET", "DBL", "EVT", "TRK", "VID", "ALL"}; -+static const char *log_level_str[] = {"EMG", "ALR", "CRT", "ERR", "WRN", "NTC", "INF", "DBG", "ALL", NULL}; -+ -+ -+/** -+ * get_log_type -+ * -+ * -+ * Returns: index of log type or 0 if not valid type. -+ */ -+int get_log_type(const char *type) -+{ -+ unsigned int i, ret = 0; -+ unsigned int maxtype = sizeof(log_type_str)/sizeof(const char *); -+ -+ for (i = 1;i < maxtype; i++) { -+ if (!strncasecmp(type, log_type_str[i], 3)) { -+ ret = i; -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+/** -+ * get_log_type_str -+ * Gets string value for type log level. -+ * -+ * Returns: name of type log level. -+ */ -+const char* get_log_type_str(unsigned int type) -+{ -+ return log_type_str[type]; -+} -+ -+/** -+ * set_log_type -+ * Sets log type level. -+ * -+ * Returns: nothing. -+ */ -+void set_log_type(unsigned int type) -+{ -+ log_type = type; -+ //printf("set log type %d\n", type); -+} -+ -+/** -+ * get_log_level_str -+ * Gets string value for log level. -+ * -+ * Returns: name of log level. -+ */ -+const char* get_log_level_str(unsigned int level) -+{ -+ return log_level_str[level]; -+} -+ -+/** -+ * set_log_level -+ * Sets log level. -+ * -+ * Returns nothing. -+ */ -+void set_log_level(unsigned int level) -+{ -+ log_level = level; -+ //printf("set log level %d\n", level); -+} -+ -+/** -+ * set_log_mode -+ * Sets mode of logging , could be using syslog or files. -+ * -+ * Returns: nothing. -+ */ -+void set_log_mode(int mode) -+{ -+ log_mode = mode; -+ //printf("set log mode %d\n", mode); -+} -+ -+/** -+ * set_logfile -+ * Sets logfile to be used instead of syslog. -+ * -+ * Returns: pointer to log file. -+ */ -+FILE * set_logfile(const char *logfile_name) -+{ -+ log_mode = LOGMODE_SYSLOG; /* Setup temporary to let log if myfopen fails */ -+ logfile = myfopen(logfile_name, "a", 0); -+ -+ /* If logfile was opened correctly */ -+ if (logfile) -+ log_mode = LOGMODE_FILE; -+ -+ return logfile; -+} -+ -+/** -+ * str_time -+ * -+ * Return: string with human readable time -+ */ -+static char *str_time(void) -+{ -+ static char buffer[16]; -+ time_t now = 0; -+ -+ now = time(0); -+ strftime(buffer, 16, "%b %d %H:%M:%S", localtime(&now)); -+ return buffer; -+} -+ -+/** -+ * MOTION_LOG -+ * -+ * This routine is used for printing all informational, debug or error -+ * messages produced by any of the other motion functions. It always -+ * produces a message of the form "[n] {message}", and (if the param -+ * 'errno_flag' is set) follows the message with the associated error -+ * message from the library. -+ * -+ * Parameters: -+ * -+ * level logging level for the 'syslog' function -+ * -+ * type logging type. -+ * -+ * errno_flag if set, the log message should be followed by the -+ * error message. -+ * fmt the format string for producing the message -+ * ap variable-length argument list -+ * -+ * Returns: -+ * Nothing -+ */ -+void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, ...) -+{ -+ int errno_save, n; -+ char buf[1024]; -+/* GNU-specific strerror_r() */ -+#if (!defined(XSI_STRERROR_R)) -+ char msg_buf[100]; -+#endif -+ va_list ap; -+ int threadnr; -+ -+ /* Exit if level is greater than log_level */ -+ if ((unsigned int)level > log_level) -+ return; -+ -+ /* Exit if type is not equal to log_type and not TYPE_ALL */ -+ 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, -+ * which is nice because that's what we want in that case. -+ */ -+ threadnr = (unsigned long)pthread_getspecific(tls_key_threadnr); -+ -+ /* -+ * First we save the current 'error' value. This is required because -+ * the subsequent calls to vsnprintf could conceivably change it! -+ */ -+ errno_save = errno; -+ -+ /* -+ * Prefix the message with the log level string, log type string, -+ * time and thread number. e.g. [1] [ERR] [ENC] [Apr 03 00:08:44] blah -+ * -+ */ -+ if (!log_mode) { -+ n = snprintf(buf, sizeof(buf), "[%d] [%s] [%s] [%s] ", -+ threadnr, get_log_level_str(level), get_log_type_str(type), -+ str_time()); -+ } else { -+ /* -+ * Prefix the message with the log level string, log type string -+ * and thread number. e.g. [1] [DBG] [TRK] blah -+ */ -+ n = snprintf(buf, sizeof(buf), "[%d] [%s] [%s] ", -+ threadnr, get_log_level_str(level), get_log_type_str(type)); -+ } -+ -+ /* Next add the user's message. */ -+ va_start(ap, fmt); -+ n += vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); -+ buf[1023] = '\0'; -+ -+ /* If errno_flag is set, add on the library error message. */ -+ if (errno_flag) { -+ size_t buf_len = strlen(buf); -+ -+ // just knock off 10 characters if we're that close... -+ if (buf_len + 10 > 1024) { -+ buf[1024 - 10] = '\0'; -+ buf_len = 1024 - 10; -+ } -+ -+ strncat(buf, ": ", 1024 - buf_len); -+ n += 2; -+ /* -+ * This is bad - apparently gcc/libc wants to use the non-standard GNU -+ * version of strerror_r, which doesn't actually put the message into -+ * my buffer :-(. I have put in a 'hack' to get around this. -+ */ -+#if defined(XSI_STRERROR_R) -+ /* XSI-compliant strerror_r() */ -+ strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */ -+#else -+ /* GNU-specific strerror_r() */ -+ strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf)); -+#endif -+ } -+ -+ if (!log_mode) { -+ strncat(buf, "\n", 1024 - strlen(buf)); -+ fputs(buf, logfile); -+ fflush(logfile); -+ -+ /* If log_mode, send the message to the syslog. */ -+ } else { -+ syslog(level, "%s", buf); -+ strncat(buf, "\n", 1024 - strlen(buf)); -+ fputs(buf, stderr); -+ fflush(stderr); -+ } -+ -+ /* Clean up the argument list routine. */ -+ va_end(ap); -+} -+ ---- /dev/null -+++ motion-3.2.12/logger.h -@@ -0,0 +1,63 @@ -+/* -+ * logger.h -+ * -+ * Include file for logger.c -+ * -+ * Copyright 2005, William M. Brack -+ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) -+ * This software is distributed under the GNU Public License Version 2 -+ * See also the file 'COPYING'. -+ * -+ */ -+#ifndef _INCLUDE_LOGGER_H_ -+#define _INCLUDE_LOGGER_H_ -+ -+#include "motion.h" -+#include -+ -+/* Logging mode */ -+#define LOGMODE_FILE 0 /* Log messages to file */ -+#define LOGMODE_SYSLOG 1 /* Log messages to syslog */ -+ -+#define NO_ERRNO 0 /* Flag to avoid how message associated to errno */ -+#define SHOW_ERRNO 1 /* Flag to show message associated to errno */ -+ -+/* Log levels */ -+#define LOG_ALL 9 -+#define EMG LOG_EMERG /* syslog 0 motion 1 */ -+#define ALR LOG_ALERT /* syslog 1 motion 2 */ -+#define CRT LOG_CRIT /* syslog 2 motion 3 */ -+#define ERR LOG_ERR /* syslog 3 motion 4 */ -+#define WRN LOG_WARNING /* syslog 4 motion 5 */ -+#define NTC LOG_NOTICE /* syslog 5 motion 6 */ -+#define INF LOG_INFO /* syslog 6 motion 7 */ -+#define DBG LOG_DEBUG /* syslog 7 motion 8 */ -+#define ALL LOG_ALL /* syslog 8 motion 9 */ -+#define LEVEL_DEFAULT NTC /* syslog 5 motion 6 default */ -+#define SHOW_LEVEL_VALUE(x) (x+1) -+ -+/* Log types */ -+#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 */ -+ -+#define MOTION_LOG(x, y, z, format, args...) motion_log(x, y, z, format, __FUNCTION__, ##args) -+ -+int get_log_type(const char* type); -+const char* get_log_type_str(unsigned int type); -+void set_log_type(unsigned int type); -+const char* get_log_level_str(unsigned int level); -+void set_log_level(unsigned int level); -+void set_log_mode(int mode); -+FILE * set_logfile(const char *logfile_name); -+void motion_log(int, unsigned int, int, const char *, ...); -+ -+#endif ---- /dev/null -+++ motion-3.2.12/md5.c -@@ -0,0 +1,348 @@ -+/* -+ * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm -+ * taken from RFC 1321 -+ */ -+ -+/* -+ Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -+rights reserved. -+ -+License to copy and use this software is granted provided that it -+is identified as the "RSA Data Security, Inc. MD5 Message-Digest -+Algorithm" in all material mentioning or referencing this software -+or this function. -+ -+License is also granted to make and use derivative works provided -+that such works are identified as "derived from the RSA Data -+Security, Inc. MD5 Message-Digest Algorithm" in all material -+mentioning or referencing the derived work. -+ -+RSA Data Security, Inc. makes no representations concerning either -+the merchantability of this software or the suitability of this -+software for any particular purpose. It is provided "as is" -+without express or implied warranty of any kind. -+ -+These notices must be retained in any copies of any part of this -+documentation and/or software. -+*/ -+ -+#include "md5.h" -+ -+/* -+ * Constants for MD5Transform routine. -+ */ -+ -+#define S11 7 -+#define S12 12 -+#define S13 17 -+#define S14 22 -+#define S21 5 -+#define S22 9 -+#define S23 14 -+#define S24 20 -+#define S31 4 -+#define S32 11 -+#define S33 16 -+#define S34 23 -+#define S41 6 -+#define S42 10 -+#define S43 15 -+#define S44 21 -+ -+static void MD5Transform(UINT4 [4], unsigned char [64]); -+static void Encode(unsigned char *, UINT4 *, unsigned int); -+static void Decode(UINT4 *, unsigned char *, unsigned int); -+static void MD5_memcpy(POINTER, POINTER, unsigned int); -+static void MD5_memset(POINTER, int, unsigned int); -+ -+static unsigned char PADDING[64] = { -+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -+}; -+ -+/* -+ * F, G, H and I are basic MD5 functions. -+ */ -+#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -+#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -+#define H(x, y, z) ((x) ^ (y) ^ (z)) -+#define I(x, y, z) ((y) ^ ((x) | (~z))) -+ -+/* -+ * ROTATE_LEFT rotates x left n bits. -+ */ -+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) -+ -+/* -+ * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -+ * Rotation is separate from addition to prevent recomputation. -+ */ -+#define FF(a, b, c, d, x, s, ac) { \ -+ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ -+ (a) = ROTATE_LEFT ((a), (s)); \ -+ (a) += (b); \ -+ } -+#define GG(a, b, c, d, x, s, ac) { \ -+ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ -+ (a) = ROTATE_LEFT ((a), (s)); \ -+ (a) += (b); \ -+ } -+#define HH(a, b, c, d, x, s, ac) { \ -+ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ -+ (a) = ROTATE_LEFT ((a), (s)); \ -+ (a) += (b); \ -+ } -+#define II(a, b, c, d, x, s, ac) { \ -+ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ -+ (a) = ROTATE_LEFT ((a), (s)); \ -+ (a) += (b); \ -+ } -+ -+/* -+ * MD5 initialization. Begins an MD5 operation, writing a new context. -+ */ -+void MD5Init(MD5_CTX *context) -+{ -+ context->count[0] = context->count[1] = 0; -+ /* Load magic initialization constants. */ -+ context->state[0] = 0x67452301; -+ context->state[1] = 0xefcdab89; -+ context->state[2] = 0x98badcfe; -+ context->state[3] = 0x10325476; -+} -+ -+/* -+ * MD5 block update operation. Continues an MD5 message-digest -+ * operation, processing another message block, and updating the -+ * context. -+ */ -+void MD5Update ( -+ MD5_CTX *context, /* context */ -+ unsigned char *input, /* input block */ -+ unsigned int inputLen) /* length of input block */ -+{ -+ unsigned int i, index, partLen; -+ -+ /* Compute number of bytes mod 64 */ -+ index = (unsigned int)((context->count[0] >> 3) & 0x3F); -+ -+ /* Update number of bits */ -+ if ((context->count[0] += ((UINT4)inputLen << 3)) -+ < ((UINT4)inputLen << 3)) -+ context->count[1]++; -+ context->count[1] += ((UINT4)inputLen >> 29); -+ -+ partLen = 64 - index; -+ -+ /* Transform as many times as possible. */ -+ if (inputLen >= partLen) { -+ MD5_memcpy -+ ((POINTER)&context->buffer[index], (POINTER)input, partLen); -+ MD5Transform (context->state, context->buffer); -+ -+ for (i = partLen; i + 63 < inputLen; i += 64) -+ MD5Transform (context->state, &input[i]); -+ -+ index = 0; -+ } -+ else -+ i = 0; -+ -+ /* Buffer remaining input */ -+ MD5_memcpy -+ ((POINTER)&context->buffer[index], (POINTER)&input[i], -+ inputLen-i); -+} -+ -+/* -+ * MD5 finalization. Ends an MD5 message-digest operation, writing the -+ * the message digest and zeroizing the context. -+ */ -+void MD5Final ( -+ unsigned char digest[16], /* message digest */ -+ MD5_CTX *context) /* context */ -+{ -+ unsigned char bits[8]; -+ unsigned int index, padLen; -+ -+ /* Save number of bits */ -+ Encode (bits, context->count, 8); -+ -+ /* Pad out to 56 mod 64. */ -+ index = (unsigned int)((context->count[0] >> 3) & 0x3f); -+ padLen = (index < 56) ? (56 - index) : (120 - index); -+ MD5Update (context, PADDING, padLen); -+ -+ /* Append length (before padding) */ -+ MD5Update (context, bits, 8); -+ -+ /* Store state in digest */ -+ Encode (digest, context->state, 16); -+ -+ /* Zeroize sensitive information. */ -+ MD5_memset ((POINTER)context, 0, sizeof (*context)); -+} -+ -+/* -+ * MD5 basic transformation. Transforms state based on block. -+ */ -+static void MD5Transform (state, block) -+UINT4 state[4]; -+unsigned char block[64]; -+{ -+ UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; -+ -+ Decode (x, block, 64); -+ -+ /* Round 1 */ -+ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ -+ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ -+ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ -+ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ -+ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ -+ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ -+ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ -+ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ -+ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ -+ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ -+ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ -+ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ -+ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ -+ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ -+ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ -+ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ -+ -+ /* Round 2 */ -+ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ -+ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ -+ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ -+ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ -+ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ -+ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ -+ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ -+ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ -+ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ -+ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ -+ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ -+ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ -+ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ -+ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ -+ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ -+ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ -+ -+ /* Round 3 */ -+ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ -+ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ -+ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ -+ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ -+ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ -+ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ -+ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ -+ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ -+ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ -+ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ -+ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ -+ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ -+ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ -+ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ -+ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ -+ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ -+ -+ /* Round 4 */ -+ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ -+ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ -+ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ -+ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ -+ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ -+ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ -+ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ -+ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ -+ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ -+ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ -+ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ -+ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ -+ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ -+ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ -+ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ -+ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ -+ -+ state[0] += a; -+ state[1] += b; -+ state[2] += c; -+ state[3] += d; -+ -+ /* Zeroize sensitive information. */ -+ MD5_memset ((POINTER)x, 0, sizeof (x)); -+} -+ -+/* -+ * Encodes input (UINT4) into output (unsigned char). Assumes len is -+ * a multiple of 4. -+ */ -+static void Encode (output, input, len) -+unsigned char *output; -+UINT4 *input; -+unsigned int len; -+{ -+ unsigned int i, j; -+ -+ for (i = 0, j = 0; j < len; i++, j += 4) { -+ output[j] = (unsigned char)(input[i] & 0xff); -+ output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); -+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); -+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); -+ } -+} -+ -+/* -+ * Decodes input (unsigned char) into output (UINT4). Assumes len is -+ * a multiple of 4. -+ */ -+static void Decode (output, input, len) -+UINT4 *output; -+unsigned char *input; -+unsigned int len; -+{ -+ unsigned int i, j; -+ -+ for (i = 0, j = 0; j < len; i++, j += 4) -+ output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | -+ (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -+} -+ -+/* Note: Replace "for loop" with standard memcpy if possible. */ -+ -+static void MD5_memcpy (output, input, len) -+POINTER output; -+POINTER input; -+unsigned int len; -+{ -+ unsigned int i; -+ -+ for (i = 0; i < len; i++) -+ output[i] = input[i]; -+} -+ -+/* Note: Replace "for loop" with standard memset if possible. */ -+static void MD5_memset (output, value, len) -+POINTER output; -+int value; -+unsigned int len; -+{ -+ unsigned int i; -+ -+ for (i = 0; i < len; i++) -+ ((char *)output)[i] = (char)value; -+} -+ -+void MD5(unsigned char *message,unsigned long message_length,unsigned char *md) -+{ -+ MD5_CTX state; -+ -+ MD5Init(&state); -+ MD5Update(&state,message,message_length); -+ MD5Final(md,&state); -+ -+ return; -+} ---- /dev/null -+++ motion-3.2.12/md5.h -@@ -0,0 +1,77 @@ -+/* -+ * MD5.H - header file for MD5C.C -+ * taken from RFC 1321 -+ */ -+ -+#ifndef MD5_H -+#define MD5_H -+ -+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -+rights reserved. -+ -+License to copy and use this software is granted provided that it -+is identified as the "RSA Data Security, Inc. MD5 Message-Digest -+Algorithm" in all material mentioning or referencing this software -+or this function. -+ -+License is also granted to make and use derivative works provided -+that such works are identified as "derived from the RSA Data -+Security, Inc. MD5 Message-Digest Algorithm" in all material -+mentioning or referencing the derived work. -+ -+RSA Data Security, Inc. makes no representations concerning either -+the merchantability of this software or the suitability of this -+software for any particular purpose. It is provided "as is" -+without express or implied warranty of any kind. -+ -+These notices must be retained in any copies of any part of this -+documentation and/or software. -+ */ -+ -+/* GLOBAL.H - RSAREF types and constants -+ */ -+ -+/* -+ * PROTOTYPES should be set to one if and only if the compiler supports -+ * function argument prototyping. -+ * The following makes PROTOTYPES default to 0 if it has not already -+ * been defined with C compiler flags. -+ */ -+ -+#ifndef PROTOTYPES -+#define PROTOTYPES 0 -+#endif -+ -+/* POINTER defines a generic pointer type */ -+typedef unsigned char *POINTER; -+ -+/* UINT2 defines a two byte word */ -+typedef unsigned short int UINT2; -+ -+/* UINT4 defines a four byte word */ -+typedef unsigned int UINT4; -+ -+/* -+ * PROTO_LIST is defined depending on how PROTOTYPES is defined above. -+ * If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it -+ * returns an empty list. -+ */ -+#if PROTOTYPES -+#define PROTO_LIST(list) list -+#else -+#define PROTO_LIST(list) () -+#endif -+ -+/* MD5 context. */ -+typedef struct { -+ UINT4 state[4]; /* state (ABCD) */ -+ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ -+ unsigned char buffer[64]; /* input buffer */ -+} MD5_CTX; -+ -+void MD5Init(MD5_CTX *); -+void MD5Update(MD5_CTX *, unsigned char *, unsigned int); -+void MD5Final(unsigned char [16], MD5_CTX *); -+void MD5(unsigned char *message, unsigned long message_length, unsigned char *md); -+ -+#endif // MD5_H ---- motion-3.2.12.orig/mmx.h -+++ motion-3.2.12/mmx.h -@@ -12,22 +12,22 @@ - */ - - typedef union { -- long long q; /* Quadword (64-bit) value */ -- unsigned long long uq; /* Unsigned Quadword */ -- int d[2]; /* 2 Doubleword (32-bit) values */ -- unsigned int ud[2]; /* 2 Unsigned Doubleword */ -- short w[4]; /* 4 Word (16-bit) values */ -- unsigned short uw[4]; /* 4 Unsigned Word */ -- char b[8]; /* 8 Byte (8-bit) values */ -- unsigned char ub[8]; /* 8 Unsigned Byte */ -- float s[2]; /* Single-precision (32-bit) value */ -+ long long q; /* Quadword (64-bit) value */ -+ unsigned long long uq; /* Unsigned Quadword */ -+ int d[2]; /* 2 Doubleword (32-bit) values */ -+ unsigned int ud[2]; /* 2 Unsigned Doubleword */ -+ short w[4]; /* 4 Word (16-bit) values */ -+ unsigned short uw[4]; /* 4 Unsigned Word */ -+ char b[8]; /* 8 Byte (8-bit) values */ -+ unsigned char ub[8]; /* 8 Unsigned Byte */ -+ float s[2]; /* Single-precision (32-bit) value */ - } mmx_t; /* On an 8-byte (64-bit) boundary */ - - - #define mmx_i2r(op,imm,reg) \ - __asm__ __volatile__ (#op " %0, %%" #reg \ - : /* nothing */ \ -- : "i" (imm) ) -+ : "i" (imm)) - - #define mmx_m2r(op,mem,reg) \ - __asm__ __volatile__ (#op " %0, %%" #reg \ -@@ -188,7 +188,7 @@ typedef union { - #define mmx_r2ri(op,regs,regd,imm) \ - __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \ - : /* nothing */ \ -- : "X" (imm) ) -+ : "X" (imm)) - - #define mmx_fetch(mem,hint) \ - __asm__ __volatile__ ("prefetch" #hint " %0" \ ---- /dev/null -+++ motion-3.2.12/motion-dist.conf -@@ -0,0 +1,736 @@ -+# Rename this distribution example file to motion.conf -+# -+# This config file was generated by motion 3.2.12-4ppa01 -+ -+ -+############################################################ -+# Daemon -+############################################################ -+ -+# Start in daemon (background) mode and release terminal (default: off) -+daemon off -+ -+# File to store the process ID, also called pid file. (default: not defined) -+process_id_file /var/run/motion/motion.pid -+ -+############################################################ -+# Basic Setup Mode -+############################################################ -+ -+# Start in Setup-Mode, daemon disabled. (default: off) -+setup_mode off -+ -+ -+# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) -+;logfile /tmp/motion.log -+ -+# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -+log_level 6 -+ -+# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -+log_type all -+ -+########################################################### -+# Capture device options -+############################################################ -+ -+# Videodevice to be used for capturing (default /dev/video0) -+# for FreeBSD default is /dev/bktr0 -+videodevice /dev/video0 -+ -+# v4l2_palette allows to choose preferable palette to be use by motion -+# to capture from those supported by your videodevice. (default: 17) -+# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and -+# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. -+# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 -+# instead. -+# -+# Values : -+# V4L2_PIX_FMT_SN9C10X : 0 'S910' -+# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -+# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -+# V4L2_PIX_FMT_SPCA561 : 3 'S561' -+# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -+# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -+# V4L2_PIX_FMT_PAC207 : 6 'P207' -+# V4L2_PIX_FMT_PJPG : 7 'PJPG' -+# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -+# V4L2_PIX_FMT_JPEG : 9 'JPEG' -+# V4L2_PIX_FMT_RGB24 : 10 'RGB3' -+# V4L2_PIX_FMT_SPCA501 : 11 'S501' -+# V4L2_PIX_FMT_SPCA505 : 12 'S505' -+# V4L2_PIX_FMT_SPCA508 : 13 'S508' -+# V4L2_PIX_FMT_UYVY : 14 'UYVY' -+# V4L2_PIX_FMT_YUYV : 15 'YUYV' -+# V4L2_PIX_FMT_YUV422P : 16 '422P' -+# V4L2_PIX_FMT_YUV420 : 17 'YU12' -+# -+v4l2_palette 17 -+ -+# Tuner device to be used for capturing using tuner as source (default /dev/tuner0) -+# This is ONLY used for FreeBSD. Leave it commented out for Linux -+; tunerdevice /dev/tuner0 -+ -+# 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) -+norm 0 -+ -+# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) -+frequency 0 -+ -+# Rotate image this number of degrees. The rotation affects all saved images as -+# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. -+rotate 0 -+ -+# Image width (pixels). Valid range: Camera dependent, default: 352 -+width 320 -+ -+# Image height (pixels). Valid range: Camera dependent, default: 288 -+height 240 -+ -+# Maximum number of frames to be captured per second. -+# Valid range: 2-100. Default: 100 (almost no limit). -+framerate 2 -+ -+# Minimum time in seconds between capturing picture frames from the camera. -+# Default: 0 = disabled - the capture rate is given by the camera framerate. -+# This option is used when you want to capture images at a rate lower than 2 per second. -+minimum_frame_time 0 -+ -+# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) -+# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -+; netcam_url value -+ -+# Username and password for network camera (only if required). Default: not defined -+# Syntax is user:password -+; netcam_userpass value -+ -+# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -+# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -+# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -+# on: Use HTTP/1.1 requests that support keep alive as default. -+# Default: off -+netcam_keepalive off -+ -+# URL to use for a netcam proxy server, if required, e.g. "http://myproxy". -+# If a port number other than 80 is needed, use "http://myproxy:1234". -+# Default: not defined -+; netcam_proxy value -+ -+# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -+# Default: off -+netcam_tolerant_check off -+ -+# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. -+# Default: on -+rtsp_uses_tcp on -+ -+# Let motion regulate the brightness of a video device (default: off). -+# The auto_brightness feature uses the brightness option as its target value. -+# If brightness is zero auto_brightness will adjust to average brightness value 128. -+# Only recommended for cameras without auto brightness -+auto_brightness off -+ -+# Set the initial brightness of a video device. -+# If auto_brightness is enabled, this value defines the average brightness level -+# which Motion will try and adjust to. -+# Valid range 0-255, default 0 = disabled -+brightness 0 -+ -+# Set the contrast of a video device. -+# Valid range 0-255, default 0 = disabled -+contrast 0 -+ -+# Set the saturation of a video device. -+# Valid range 0-255, default 0 = disabled -+saturation 0 -+ -+# Set the hue of a video device (NTSC feature). -+# Valid range 0-255, default 0 = disabled -+hue 0 -+ -+ -+############################################################ -+# Round Robin (multiple inputs on same video device name) -+############################################################ -+ -+# Number of frames to capture in each roundrobin step (default: 1) -+roundrobin_frames 1 -+ -+# Number of frames to skip before each roundrobin step (default: 1) -+roundrobin_skip 1 -+ -+# Try to filter out noise generated by roundrobin (default: off) -+switchfilter off -+ -+ -+############################################################ -+# Motion Detection Settings: -+############################################################ -+ -+# Threshold for number of changed pixels in an image that -+# triggers motion detection (default: 1500) -+threshold 1500 -+ -+# Automatically tune the threshold down if possible (default: off) -+threshold_tune off -+ -+# Noise threshold for the motion detection (default: 32) -+noise_level 32 -+ -+# Automatically tune the noise threshold (default: on) -+noise_tune on -+ -+# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) -+# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. -+# (l)abeling must only be used once and the 'l' must be the last letter. -+# Comment out to disable -+despeckle_filter EedDl -+ -+# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -+# A script (on_area_detected) is started immediately when motion is 4 5 6 -+# detected in one of the given areas, but only once during an event. 7 8 9 -+# One or more areas can be specified with this option. Take care: This option -+# does NOT restrict detection to these areas! (Default: not defined) -+; area_detect value -+ -+# PGM file to use as a sensitivity mask. -+# Full path name to. (Default: not defined) -+; mask_file value -+ -+# Dynamically create a mask file during operation (default: 0) -+# Adjust speed of mask changes from 0 (off) to 10 (fast) -+smart_mask_speed 0 -+ -+# Ignore sudden massive light intensity changes given as a percentage of the picture -+# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled -+lightswitch 0 -+ -+# Picture frames must contain motion at least the specified number of frames -+# in a row before they are detected as true motion. At the default of 1, all -+# motion is detected. Valid range: 1 to thousands, recommended 1-5 -+minimum_motion_frames 1 -+ -+# Specifies the number of pre-captured (buffered) pictures from before motion -+# was detected that will be output at motion detection. -+# Recommended range: 0 to 5 (default: 0) -+# Do not use large values! Large values will cause Motion to skip video frames and -+# cause unsmooth movies. To smooth movies use larger values of post_capture instead. -+pre_capture 0 -+ -+# Number of frames to capture after motion is no longer detected (default: 0) -+post_capture 0 -+ -+# Event Gap is the seconds of no motion detection that triggers the end of an event. -+# An event is defined as a series of motion images taken within a short timeframe. -+# Recommended value is 60 seconds (Default). The value -1 is allowed and disables -+# events causing all Motion to be written to one single movie file and no pre_capture. -+# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An -+# event ends right after no more motion is detected and post_capture is over. -+event_gap 60 -+ -+# Maximum length in seconds of a movie -+# When value is exceeded a new movie file is created. (Default: 0 = infinite) -+max_movie_time 0 -+ -+# Always save images even if there was no motion (default: off) -+emulate_motion off -+ -+ -+############################################################ -+# Image File Output -+############################################################ -+ -+# Output 'normal' pictures when motion is detected (default: on) -+# Valid values: on, off, first, best, center -+# When set to 'first', only the first picture of an event is saved. -+# Picture with most motion of an event is saved when set to 'best'. -+# Picture with motion nearest center of picture is saved when set to 'center'. -+# Can be used as preview shot for the corresponding movie. -+output_pictures on -+ -+# Output pictures with only the pixels moving object (ghost images) (default: off) -+output_debug_pictures off -+ -+# The quality (in percent) to be used by the jpeg compression (default: 75) -+quality 75 -+ -+# Type of output images -+# Valid values: jpeg, ppm (default: jpeg) -+picture_type jpeg -+ -+############################################################ -+# FFMPEG related options -+# Film (movies) file output, and deinterlacing of the video input -+# The options movie_filename and timelapse_filename are also used -+# by the ffmpeg feature -+############################################################ -+ -+# Use ffmpeg to encode movies in realtime (default: off) -+ffmpeg_output_movies on -+ -+# Use ffmpeg to make movies with only the pixels moving -+# object (ghost images) (default: off) -+ffmpeg_output_debug_movies off -+ -+# Use ffmpeg to encode a timelapse movie -+# Default value 0 = off - else save frame every Nth second -+ffmpeg_timelapse 0 -+ -+# The file rollover mode of the timelapse video -+# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual -+ffmpeg_timelapse_mode daily -+ -+# Bitrate to be used by the ffmpeg encoder (default: 400000) -+# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) -+ffmpeg_bps 500000 -+ -+# Enables and defines variable bitrate for the ffmpeg encoder. -+# ffmpeg_bps is ignored if variable bitrate is enabled. -+# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, -+# or the range 2 - 31 where 2 means best quality and 31 is worst. -+ffmpeg_variable_bitrate 0 -+ -+# Codec to used by ffmpeg for the video compression. -+# Timelapse mpegs are always made in mpeg1 format independent from this option. -+# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. -+# mpeg1 - gives you files with extension .mpg -+# mpeg4 or msmpeg4 - gives you files with extension .avi -+# msmpeg4 is recommended for use with Windows Media Player because -+# it requires no installation of codec on the Windows client. -+# swf - gives you a flash film with extension .swf -+# flv - gives you a flash video with extension .flv -+# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -+# mov - QuickTime ( testing ) -+# ogg - Ogg/Theora ( testing ) -+ffmpeg_video_codec mpeg4 -+ -+# Use ffmpeg to deinterlace video. Necessary if you use an analog camera -+# and see horizontal combing on moving objects in video or pictures. -+# (default: off) -+ffmpeg_deinterlace off -+ -+############################################################ -+# SDL Window -+############################################################ -+ -+# Number of motion thread to show in SDL Window (default: 0 = disabled) -+#sdl_threadnr 0 -+ -+############################################################ -+# External pipe to video encoder -+# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. -+# The options movie_filename and timelapse_filename are also used -+# by the ffmpeg feature -+############################################################# -+ -+# Bool to enable or disable extpipe (default: off) -+use_extpipe off -+ -+# External program (full path and opts) to pipe raw video to -+# Generally, use '-' for STDIN... -+;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps -+ -+ -+ -+############################################################ -+# Snapshots (Traditional Periodic Webcam File Output) -+############################################################ -+ -+# Make automated snapshot every N seconds (default: 0 = disabled) -+snapshot_interval 0 -+ -+ -+############################################################ -+# Text Display -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, \n = new line, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event - do not use with text_event! -+# You can put quotation marks around the text to allow -+# leading spaces -+############################################################ -+ -+# Locate and draw a box around the moving object. -+# Valid values: on, off, preview (default: off) -+# Set to 'preview' will only draw a box in preview_shot pictures. -+locate_motion_mode off -+ -+# Set the look and style of the locate box if enabled. -+# Valid values: box, redbox, cross, redcross (default: box) -+# Set to 'box' will draw the traditional box. -+# Set to 'redbox' will draw a red box. -+# Set to 'cross' will draw a little cross to mark center. -+# Set to 'redcross' will draw a little red cross to mark center. -+locate_motion_style box -+ -+# Draws the timestamp using same options as C function strftime(3) -+# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -+# Text is placed in lower right corner -+text_right %Y-%m-%d\n%T-%q -+ -+# Draw a user defined text on the images using same options as C function strftime(3) -+# Default: Not defined = no text -+# Text is placed in lower left corner -+; text_left CAMERA %t -+ -+# Draw the number of changed pixed on the images (default: off) -+# Will normally be set to off except when you setup and adjust the motion settings -+# Text is placed in upper right corner -+text_changes off -+ -+# This option defines the value of the special event conversion specifier %C -+# You can use any conversion specifier in this option except %C. Date and time -+# values are from the timestamp of the first image in the current event. -+# Default: %Y%m%d%H%M%S -+# The idea is that %C can be used filenames and text_left/right for creating -+# a unique identifier for each event. -+text_event %Y%m%d%H%M%S -+ -+# Draw characters at twice normal size on images. (default: off) -+text_double off -+ -+ -+# Text to include in a JPEG EXIF comment -+# May be any text, including conversion specifiers. -+# The EXIF timestamp is included independent of this text. -+;exif_text %i%J/%K%L -+ -+############################################################ -+# Target Directories and filenames For Images And Films -+# For the options snapshot_, picture_, movie_ and timelapse_filename -+# you can use conversion specifiers -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event -+# Quotation marks round string are allowed. -+############################################################ -+ -+# Target base directory for pictures and films -+# Recommended to use absolute path. (Default: current working directory) -+target_dir /tmp/motion -+ -+# File path for snapshots (jpeg or ppm) relative to target_dir -+# Default: %v-%Y%m%d%H%M%S-snapshot -+# Default value is equivalent to legacy oldlayout option -+# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot -+# File extension .jpg or .ppm is automatically added so do not include this. -+# Note: A symbolic link called lastsnap.jpg created in the target_dir will always -+# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -+snapshot_filename %v-%Y%m%d%H%M%S-snapshot -+ -+# File path for motion triggered images (jpeg or ppm) relative to target_dir -+# Default: %v-%Y%m%d%H%M%S-%q -+# Default value is equivalent to legacy oldlayout option -+# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q -+# File extension .jpg or .ppm is automatically added so do not include this -+# Set to 'preview' together with best-preview feature enables special naming -+# convention for preview shots. See motion guide for details -+picture_filename %v-%Y%m%d%H%M%S-%q -+ -+# File path for motion triggered ffmpeg films (movies) relative to target_dir -+# Default: %v-%Y%m%d%H%M%S -+# Default value is equivalent to legacy oldlayout option -+# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -+# File extension .mpg or .avi is automatically added so do not include this -+# This option was previously called ffmpeg_filename -+movie_filename %v-%Y%m%d%H%M%S -+ -+# File path for timelapse movies relative to target_dir -+# Default: %Y%m%d-timelapse -+# Default value is near equivalent to legacy oldlayout option -+# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse -+# File extension .mpg is automatically added so do not include this -+timelapse_filename %Y%m%d-timelapse -+ -+############################################################ -+# Global Network Options -+############################################################ -+# Enable or disable IPV6 for http control and stream (default: off ) -+ipv6_enabled off -+ -+############################################################ -+# Live Stream Server -+############################################################ -+ -+# The mini-http server listens to this port for requests (default: 0 = disabled) -+stream_port 8081 -+ -+# Quality of the jpeg (in percent) images produced (default: 50) -+stream_quality 50 -+ -+# Output frames at 1 fps when no motion is detected and increase to the -+# rate given by stream_maxrate when motion is detected (default: off) -+stream_motion off -+ -+# Maximum framerate for stream streams (default: 1) -+stream_maxrate 1 -+ -+# Restrict stream connections to localhost only (default: on) -+stream_localhost on -+ -+# Limits the number of images per connection (default: 0 = unlimited) -+# Number can be defined by multiplying actual stream rate by desired number of seconds -+# Actual stream rate is the smallest of the numbers framerate and stream_maxrate -+stream_limit 0 -+ -+# Set the authentication method (default: 0) -+# 0 = disabled -+# 1 = Basic authentication -+# 2 = MD5 digest (the safer authentication) -+stream_auth_method 0 -+ -+# Authentication for the stream. Syntax username:password -+# Default: not defined (Disabled) -+; stream_authentication username:password -+ -+ -+############################################################ -+# HTTP Based Control -+############################################################ -+ -+# TCP/IP port for the http server to listen on (default: 0 = disabled) -+webcontrol_port 8080 -+ -+# Restrict control connections to localhost only (default: on) -+webcontrol_localhost on -+ -+# Output for http server, select off to choose raw text plain (default: on) -+webcontrol_html_output on -+ -+# Authentication for the http based control. Syntax username:password -+# Default: not defined (Disabled) -+; webcontrol_authentication username:password -+ -+ -+############################################################ -+# Tracking (Pan/Tilt) -+############################################################# -+ -+# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) -+# The generic type enables the definition of motion center and motion size to -+# be used with the conversion specifiers for options like on_motion_detected -+track_type 0 -+ -+# Enable auto tracking (default: off) -+track_auto off -+ -+# Serial port of motor (default: none) -+;track_port /dev/ttyS0 -+ -+# Motor number for x-axis (default: 0) -+;track_motorx 0 -+ -+# Set motorx reverse (default: 0) -+;track_motorx_reverse 0 -+ -+# Motor number for y-axis (default: 0) -+;track_motory 1 -+ -+# Set motory reverse (default: 0) -+;track_motory_reverse 0 -+ -+# Maximum value on x-axis (default: 0) -+;track_maxx 200 -+ -+# Minimum value on x-axis (default: 0) -+;track_minx 50 -+ -+# Maximum value on y-axis (default: 0) -+;track_maxy 200 -+ -+# Minimum value on y-axis (default: 0) -+;track_miny 50 -+ -+# Center value on x-axis (default: 0) -+;track_homex 128 -+ -+# Center value on y-axis (default: 0) -+;track_homey 128 -+ -+# ID of an iomojo camera if used (default: 0) -+track_iomojo_id 0 -+ -+# Angle in degrees the camera moves per step on the X-axis -+# with auto-track (default: 10) -+# Currently only used with pwc type cameras -+track_step_angle_x 10 -+ -+# Angle in degrees the camera moves per step on the Y-axis -+# with auto-track (default: 10) -+# Currently only used with pwc type cameras -+track_step_angle_y 10 -+ -+# Delay to wait for after tracking movement as number -+# of picture frames (default: 10) -+track_move_wait 10 -+ -+# Speed to set the motor to (stepper motor option) (default: 255) -+track_speed 255 -+ -+# Number of steps to make (stepper motor option) (default: 40) -+track_stepsize 40 -+ -+ -+############################################################ -+# External Commands, Warnings and Logging: -+# You can use conversion specifiers for the on_xxxx commands -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event -+# %f = filename with full path -+# %n = number indicating filetype -+# Both %f and %n are only defined for on_picture_save, -+# on_movie_start and on_movie_end -+# Quotation marks round string are allowed. -+############################################################ -+ -+# Do not sound beeps when detecting motion (default: on) -+# Note: Motion never beeps when running in daemon mode. -+quiet on -+ -+# Command to be executed when an event starts. (default: none) -+# An event starts at first motion detected after a period of no motion defined by event_gap -+; on_event_start value -+ -+# Command to be executed when an event ends after a period of no motion -+# (default: none). The period of no motion is defined by option event_gap. -+; on_event_end value -+ -+# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -+# To give the filename as an argument to a command append it with %f -+; on_picture_save value -+ -+# Command to be executed when a motion frame is detected (default: none) -+; on_motion_detected value -+ -+# Command to be executed when motion in a predefined area is detected -+# Check option 'area_detect'. (default: none) -+; on_area_detected value -+ -+# Command to be executed when a movie file (.mpg|.avi) is created. (default: none) -+# To give the filename as an argument to a command append it with %f -+; on_movie_start value -+ -+# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -+# To give the filename as an argument to a command append it with %f -+; on_movie_end value -+ -+# Command to be executed when a camera can't be opened or if it is lost -+# NOTE: There is situations when motion don't detect a lost camera! -+# It depends on the driver, some drivers dosn't detect a lost camera at all -+# Some hangs the motion thread. Some even hangs the PC! (default: none) -+; on_camera_lost value -+ -+##################################################################### -+# Common Options for database features. -+# Options require database options to be active also. -+##################################################################### -+ -+# Log to the database when creating motion triggered picture file (default: on) -+; sql_log_picture on -+ -+# Log to the database when creating a snapshot image file (default: on) -+; sql_log_snapshot on -+ -+# Log to the database when creating motion triggered movie file (default: off) -+; sql_log_movie off -+ -+# Log to the database when creating timelapse movies file (default: off) -+; sql_log_timelapse off -+ -+# SQL query string that is sent to the database -+# Use same conversion specifiers has for text features -+# Additional special conversion specifiers are -+# %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') -+ -+ -+############################################################ -+# Database Options -+############################################################ -+ -+# database type : mysql, postgresql, sqlite3 (default : not defined) -+; database_type value -+ -+# database to log to (default: not defined) -+; database_dbname value -+ -+# The host on which the database is located (default: localhost) -+; database_host value -+ -+# User account name for database (default: not defined) -+; database_user value -+ -+# User password for database (default: not defined) -+; database_password value -+ -+# Port on which the database is located -+# mysql 3306 , postgresql 5432 (default: not defined) -+; database_port value -+ -+############################################################ -+# Database Options For SQLite3 -+############################################################ -+ -+# SQLite3 database (file path) (default: not defined) -+; sqlite3_db value -+ -+ -+ -+############################################################ -+# Video Loopback Device (vloopback project) -+############################################################ -+ -+# Output images to a video4linux loopback device -+# The value '-' means next available (default: not defined) -+; video_pipe value -+ -+# Output motion images to a video4linux loopback device -+# The value '-' means next available (default: not defined) -+; motion_video_pipe value -+ -+ -+############################################################## -+# Thread config files - One for each camera. -+# Except if only one camera - You only need this config file. -+# If you have more than one camera you MUST define one thread -+# config file for each camera in addition to this config file. -+############################################################## -+ -+# Remember: If you have more than one camera you must have one -+# thread file for each camera. E.g. 2 cameras requires 3 files: -+# This motion.conf file AND thread1.conf and thread2.conf. -+# Only put the options that are unique to each camera in the -+# thread config files. -+; thread /usr/local/etc/thread1.conf -+; thread /usr/local/etc/thread2.conf -+; thread /usr/local/etc/thread3.conf -+; thread /usr/local/etc/thread4.conf -+ ---- motion-3.2.12.orig/motion-dist.conf.in -+++ motion-3.2.12/motion-dist.conf.in -@@ -8,10 +8,10 @@ - ############################################################ - - # Start in daemon (background) mode and release terminal (default: off) --daemon on -+daemon off - - # File to store the process ID, also called pid file. (default: not defined) --process_id_file /var/run/motion/motion.pid -+process_id_file /var/run/motion/motion.pid - - ############################################################ - # Basic Setup Mode -@@ -20,6 +20,16 @@ process_id_file /var/run/motion/motion.p - # Start in Setup-Mode, daemon disabled. (default: off) - setup_mode off - -+ -+# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) -+;logfile /tmp/motion.log -+ -+# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -+log_level 6 -+ -+# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -+log_type all -+ - ########################################################### - # Capture device options - ############################################################ -@@ -29,31 +39,41 @@ setup_mode off - videodevice /dev/video0 - - # v4l2_palette allows to choose preferable palette to be use by motion --# to capture from those supported by your videodevice. (default: 8) -+# to capture from those supported by your videodevice. (default: 17) - # E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and - # V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. --# Setting v4l2_palette to 1 forces motion to use V4L2_PIX_FMT_SBGGR8 -+# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 - # instead. - # - # Values : - # V4L2_PIX_FMT_SN9C10X : 0 'S910' --# V4L2_PIX_FMT_SBGGR8 : 1 'BA81' --# V4L2_PIX_FMT_MJPEG : 2 'MJPEG' --# V4L2_PIX_FMT_JPEG : 3 'JPEG' --# V4L2_PIX_FMT_RGB24 : 4 'RGB3' --# V4L2_PIX_FMT_UYVY : 5 'UYVY' --# V4L2_PIX_FMT_YUYV : 6 'YUYV' --# V4L2_PIX_FMT_YUV422P : 7 '422P' --# V4L2_PIX_FMT_YUV420 : 8 'YU12' --v4l2_palette 8 -+# V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -+# V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -+# V4L2_PIX_FMT_SPCA561 : 3 'S561' -+# V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -+# V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -+# V4L2_PIX_FMT_PAC207 : 6 'P207' -+# V4L2_PIX_FMT_PJPG : 7 'PJPG' -+# V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -+# V4L2_PIX_FMT_JPEG : 9 'JPEG' -+# V4L2_PIX_FMT_RGB24 : 10 'RGB3' -+# V4L2_PIX_FMT_SPCA501 : 11 'S501' -+# V4L2_PIX_FMT_SPCA505 : 12 'S505' -+# V4L2_PIX_FMT_SPCA508 : 13 'S508' -+# V4L2_PIX_FMT_UYVY : 14 'UYVY' -+# V4L2_PIX_FMT_YUYV : 15 'YUYV' -+# V4L2_PIX_FMT_YUV422P : 16 '422P' -+# V4L2_PIX_FMT_YUV420 : 17 'YU12' -+# -+v4l2_palette 17 - - # Tuner device to be used for capturing using tuner as source (default /dev/tuner0) - # 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) -@@ -63,7 +83,7 @@ norm 0 - frequency 0 - - # Rotate image this number of degrees. The rotation affects all saved images as --# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270. -+# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. - rotate 0 - - # Image width (pixels). Valid range: Camera dependent, default: 352 -@@ -81,7 +101,7 @@ framerate 2 - # This option is used when you want to capture images at a rate lower than 2 per second. - minimum_frame_time 0 - --# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) -+# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) - # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined - ; netcam_url value - -@@ -90,21 +110,25 @@ minimum_frame_time 0 - ; netcam_userpass value - - # The setting for keep-alive of network socket, should improve performance on compatible net cameras. --# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request. --# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection. --# 1.1: Use HTTP/1.1 requests that support keep alive as default. --# Default: 1.0 --; netcam_http 1.0 -+# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -+# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -+# on: Use HTTP/1.1 requests that support keep alive as default. -+# Default: off -+netcam_keepalive off - - # URL to use for a netcam proxy server, if required, e.g. "http://myproxy". - # If a port number other than 80 is needed, use "http://myproxy:1234". - # Default: not defined --; netcam_proxy value -+; netcam_proxy value - - # Set less strict jpeg checks for network cameras with a poor/buggy firmware. - # Default: off - netcam_tolerant_check off - -+# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption. -+# Default: on -+rtsp_uses_tcp on -+ - # Let motion regulate the brightness of a video device (default: off). - # The auto_brightness feature uses the brightness option as its target value. - # If brightness is zero auto_brightness will adjust to average brightness value 128. -@@ -165,12 +189,13 @@ noise_tune on - # Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. - # (l)abeling must only be used once and the 'l' must be the last letter. - # Comment out to disable --despeckle EedDl -+despeckle_filter EedDl - - # Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 - # A script (on_area_detected) is started immediately when motion is 4 5 6 - # detected in one of the given areas, but only once during an event. 7 8 9 --# One or more areas can be specified with this option. (Default: not defined) -+# One or more areas can be specified with this option. Take care: This option -+# does NOT restrict detection to these areas! (Default: not defined) - ; area_detect value - - # PGM file to use as a sensitivity mask. -@@ -194,24 +219,26 @@ minimum_motion_frames 1 - # was detected that will be output at motion detection. - # Recommended range: 0 to 5 (default: 0) - # Do not use large values! Large values will cause Motion to skip video frames and --# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. -+# cause unsmooth movies. To smooth movies use larger values of post_capture instead. - pre_capture 0 - - # Number of frames to capture after motion is no longer detected (default: 0) - post_capture 0 - --# Gap is the seconds of no motion detection that triggers the end of an event -+# Event Gap is the seconds of no motion detection that triggers the end of an event. - # An event is defined as a series of motion images taken within a short timeframe. --# Recommended value is 60 seconds (Default). The value 0 is allowed and disables --# events causing all Motion to be written to one single mpeg file and no pre_capture. --gap 60 -- --# Maximum length in seconds of an mpeg movie --# When value is exceeded a new mpeg file is created. (Default: 0 = infinite) --max_mpeg_time 0 -+# Recommended value is 60 seconds (Default). The value -1 is allowed and disables -+# events causing all Motion to be written to one single movie file and no pre_capture. -+# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An -+# event ends right after no more motion is detected and post_capture is over. -+event_gap 60 -+ -+# Maximum length in seconds of a movie -+# When value is exceeded a new movie file is created. (Default: 0 = infinite) -+max_movie_time 0 - - # Always save images even if there was no motion (default: off) --output_all off -+emulate_motion off - - - ############################################################ -@@ -224,33 +251,33 @@ output_all off - # Picture with most motion of an event is saved when set to 'best'. - # Picture with motion nearest center of picture is saved when set to 'center'. - # Can be used as preview shot for the corresponding movie. --output_normal on -+output_pictures on - - # Output pictures with only the pixels moving object (ghost images) (default: off) --output_motion off -+output_debug_pictures off - - # The quality (in percent) to be used by the jpeg compression (default: 75) - quality 75 - --# Output ppm images instead of jpeg (default: off) --ppm off -- -+# Type of output images -+# Valid values: jpeg, ppm (default: jpeg) -+picture_type jpeg - - ############################################################ - # FFMPEG related options --# Film (mpeg) file output, and deinterlacing of the video input -+# Film (movies) file output, and deinterlacing of the video input - # The options movie_filename and timelapse_filename are also used - # by the ffmpeg feature - ############################################################ - --# Use ffmpeg to encode mpeg movies in realtime (default: off) --ffmpeg_cap_new on -+# Use ffmpeg to encode movies in realtime (default: off) -+ffmpeg_output_movies on - - # Use ffmpeg to make movies with only the pixels moving - # object (ghost images) (default: off) --ffmpeg_cap_motion off -+ffmpeg_output_debug_movies off - --# Use ffmpeg to encode a timelapse movie -+# Use ffmpeg to encode a timelapse movie - # Default value 0 = off - else save frame every Nth second - ffmpeg_timelapse 0 - -@@ -279,6 +306,7 @@ ffmpeg_variable_bitrate 0 - # flv - gives you a flash video with extension .flv - # ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) - # mov - QuickTime ( testing ) -+# ogg - Ogg/Theora ( testing ) - ffmpeg_video_codec mpeg4 - - # Use ffmpeg to deinterlace video. Necessary if you use an analog camera -@@ -286,6 +314,28 @@ ffmpeg_video_codec mpeg4 - # (default: off) - ffmpeg_deinterlace off - -+############################################################ -+# SDL Window -+############################################################ -+ -+# Number of motion thread to show in SDL Window (default: 0 = disabled) -+#sdl_threadnr 0 -+ -+############################################################ -+# External pipe to video encoder -+# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. -+# The options movie_filename and timelapse_filename are also used -+# by the ffmpeg feature -+############################################################# -+ -+# Bool to enable or disable extpipe (default: off) -+use_extpipe off -+ -+# External program (full path and opts) to pipe raw video to -+# Generally, use '-' for STDIN... -+;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps -+ -+ - - ############################################################ - # Snapshots (Traditional Periodic Webcam File Output) -@@ -309,9 +359,17 @@ snapshot_interval 0 - ############################################################ - - # Locate and draw a box around the moving object. --# Valid values: on, off and preview (default: off) -+# Valid values: on, off, preview (default: off) - # Set to 'preview' will only draw a box in preview_shot pictures. --locate off -+locate_motion_mode off -+ -+# Set the look and style of the locate box if enabled. -+# Valid values: box, redbox, cross, redcross (default: box) -+# Set to 'box' will draw the traditional box. -+# Set to 'redbox' will draw a red box. -+# Set to 'cross' will draw a little cross to mark center. -+# Set to 'redcross' will draw a little red cross to mark center. -+locate_motion_style box - - # Draws the timestamp using same options as C function strftime(3) - # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -@@ -340,9 +398,14 @@ text_event %Y%m%d%H%M%S - text_double off - - -+# Text to include in a JPEG EXIF comment -+# May be any text, including conversion specifiers. -+# The EXIF timestamp is included independent of this text. -+;exif_text %i%J/%K%L -+ - ############################################################ - # Target Directories and filenames For Images And Films --# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename -+# For the options snapshot_, picture_, movie_ and timelapse_filename - # you can use conversion specifiers - # %Y = year, %m = month, %d = date, - # %H = hour, %M = minute, %S = second, -@@ -356,7 +419,7 @@ text_double off - - # Target base directory for pictures and films - # Recommended to use absolute path. (Default: current working directory) --target_dir /usr/local/apache2/htdocs/cam1 -+target_dir /tmp/motion - - # File path for snapshots (jpeg or ppm) relative to target_dir - # Default: %v-%Y%m%d%H%M%S-snapshot -@@ -374,9 +437,9 @@ snapshot_filename %v-%Y%m%d%H%M%S-snapsh - # File extension .jpg or .ppm is automatically added so do not include this - # Set to 'preview' together with best-preview feature enables special naming - # convention for preview shots. See motion guide for details --jpeg_filename %v-%Y%m%d%H%M%S-%q -+picture_filename %v-%Y%m%d%H%M%S-%q - --# File path for motion triggered ffmpeg films (mpeg) relative to target_dir -+# File path for motion triggered ffmpeg films (movies) relative to target_dir - # Default: %v-%Y%m%d%H%M%S - # Default value is equivalent to legacy oldlayout option - # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -@@ -384,38 +447,53 @@ jpeg_filename %v-%Y%m%d%H%M%S-%q - # This option was previously called ffmpeg_filename - movie_filename %v-%Y%m%d%H%M%S - --# File path for timelapse mpegs relative to target_dir -+# File path for timelapse movies relative to target_dir - # Default: %Y%m%d-timelapse - # Default value is near equivalent to legacy oldlayout option - # For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse - # File extension .mpg is automatically added so do not include this - timelapse_filename %Y%m%d-timelapse - -+############################################################ -+# Global Network Options -+############################################################ -+# Enable or disable IPV6 for http control and stream (default: off ) -+ipv6_enabled off - - ############################################################ --# Live Webcam Server -+# Live Stream Server - ############################################################ - - # The mini-http server listens to this port for requests (default: 0 = disabled) --webcam_port 8081 -+stream_port 8081 - --# Quality of the jpeg (in percent) images produced (default: 50) --webcam_quality 50 -+# Quality of the jpeg (in percent) images produced (default: 50) -+stream_quality 50 - - # Output frames at 1 fps when no motion is detected and increase to the --# rate given by webcam_maxrate when motion is detected (default: off) --webcam_motion off -+# rate given by stream_maxrate when motion is detected (default: off) -+stream_motion off - --# Maximum framerate for webcam streams (default: 1) --webcam_maxrate 1 -+# Maximum framerate for stream streams (default: 1) -+stream_maxrate 1 - --# Restrict webcam connections to localhost only (default: on) --webcam_localhost on -+# Restrict stream connections to localhost only (default: on) -+stream_localhost on - - # Limits the number of images per connection (default: 0 = unlimited) --# Number can be defined by multiplying actual webcam rate by desired number of seconds --# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate --webcam_limit 0 -+# Number can be defined by multiplying actual stream rate by desired number of seconds -+# Actual stream rate is the smallest of the numbers framerate and stream_maxrate -+stream_limit 0 -+ -+# Set the authentication method (default: 0) -+# 0 = disabled -+# 1 = Basic authentication -+# 2 = MD5 digest (the safer authentication) -+stream_auth_method 0 -+ -+# Authentication for the stream. Syntax username:password -+# Default: not defined (Disabled) -+; stream_authentication username:password - - - ############################################################ -@@ -423,24 +501,24 @@ webcam_limit 0 - ############################################################ - - # TCP/IP port for the http server to listen on (default: 0 = disabled) --control_port 8080 -+webcontrol_port 8080 - - # Restrict control connections to localhost only (default: on) --control_localhost on -+webcontrol_localhost on - - # Output for http server, select off to choose raw text plain (default: on) --control_html_output on -+webcontrol_html_output on - - # Authentication for the http based control. Syntax username:password - # Default: not defined (Disabled) --; control_authentication username:password -+; webcontrol_authentication username:password - - - ############################################################ - # Tracking (Pan/Tilt) --############################################################ -+############################################################# - --# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo) -+# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) - # The generic type enables the definition of motion center and motion size to - # be used with the conversion specifiers for options like on_motion_detected - track_type 0 -@@ -449,19 +527,37 @@ track_type 0 - track_auto off - - # Serial port of motor (default: none) --; track_port value -+;track_port /dev/ttyS0 - - # Motor number for x-axis (default: 0) --track_motorx 0 -+;track_motorx 0 -+ -+# Set motorx reverse (default: 0) -+;track_motorx_reverse 0 - - # Motor number for y-axis (default: 0) --track_motory 0 -+;track_motory 1 -+ -+# Set motory reverse (default: 0) -+;track_motory_reverse 0 - - # Maximum value on x-axis (default: 0) --track_maxx 0 -+;track_maxx 200 -+ -+# Minimum value on x-axis (default: 0) -+;track_minx 50 - - # Maximum value on y-axis (default: 0) --track_maxy 0 -+;track_maxy 200 -+ -+# Minimum value on y-axis (default: 0) -+;track_miny 50 -+ -+# Center value on x-axis (default: 0) -+;track_homex 128 -+ -+# Center value on y-axis (default: 0) -+;track_homey 128 - - # ID of an iomojo camera if used (default: 0) - track_iomojo_id 0 -@@ -509,11 +605,11 @@ track_stepsize 40 - quiet on - - # Command to be executed when an event starts. (default: none) --# An event starts at first motion detected after a period of no motion defined by gap -+# An event starts at first motion detected after a period of no motion defined by event_gap - ; on_event_start value - - # Command to be executed when an event ends after a period of no motion --# (default: none). The period of no motion is defined by option gap. -+# (default: none). The period of no motion is defined by option event_gap. - ; on_event_end value - - # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -@@ -536,27 +632,27 @@ quiet on - ; on_movie_end value - - # Command to be executed when a camera can't be opened or if it is lost --# NOTE: There is situations when motion doesn't detect a lost camera! --# It depends on the driver, some drivers don't detect a lost camera at all --# Some hang the motion thread. Some even hang the PC! (default: none) -+# NOTE: There is situations when motion don't detect a lost camera! -+# It depends on the driver, some drivers dosn't detect a lost camera at all -+# Some hangs the motion thread. Some even hangs the PC! (default: none) - ; on_camera_lost value - --############################################################ --# Common Options For MySQL and PostgreSQL database features. --# Options require the MySQL/PostgreSQL options to be active also. --############################################################ -+##################################################################### -+# Common Options for database features. -+# Options require database options to be active also. -+##################################################################### - --# Log to the database when creating motion triggered image file (default: on) --sql_log_image on -+# Log to the database when creating motion triggered picture file (default: on) -+; sql_log_picture on - - # Log to the database when creating a snapshot image file (default: on) --sql_log_snapshot on -+; sql_log_snapshot on - --# Log to the database when creating motion triggered mpeg file (default: off) --sql_log_mpeg off -+# Log to the database when creating motion triggered movie file (default: off) -+; sql_log_movie off - --# Log to the database when creating timelapse mpeg file (default: off) --sql_log_timelapse off -+# Log to the database when creating timelapse movies file (default: off) -+; sql_log_timelapse off - - # SQL query string that is sent to the database - # Use same conversion specifiers has for text features -@@ -564,45 +660,48 @@ sql_log_timelapse off - # %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') -+; 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') - - - ############################################################ --# Database Options For MySQL -+# Database Options - ############################################################ - --# Mysql database to log to (default: not defined) --; mysql_db value -+# database type : mysql, postgresql, sqlite3 (default : not defined) -+; database_type value -+ -+# database to log to (default: not defined) -+; database_dbname value - - # The host on which the database is located (default: localhost) --; mysql_host value -+; database_host value - --# User account name for MySQL database (default: not defined) --; mysql_user value -+# User account name for database (default: not defined) -+; database_user value - --# User password for MySQL database (default: not defined) --; mysql_password value -+# User password for database (default: not defined) -+; database_password value - -+# Port on which the database is located -+# mysql 3306 , postgresql 5432 (default: not defined) -+; database_port value - - ############################################################ --# Database Options For PostgreSQL -+# Database Options For SQLite3 - ############################################################ - --# PostgreSQL database to log to (default: not defined) --; pgsql_db value -- --# The host on which the database is located (default: localhost) --; pgsql_host value -- --# User account name for PostgreSQL database (default: not defined) --; pgsql_user value -- --# User password for PostgreSQL database (default: not defined) --; pgsql_password value -+# SQLite3 database (file path) (default: not defined) -+; sqlite3_db value - --# Port on which the PostgreSQL database is located (default: 5432) --; pgsql_port 5432 - - - ############################################################ -@@ -629,7 +728,7 @@ sql_query insert into security(camera, f - # thread file for each camera. E.g. 2 cameras requires 3 files: - # This motion.conf file AND thread1.conf and thread2.conf. - # Only put the options that are unique to each camera in the --# thread config files. -+# thread config files. - ; thread /usr/local/etc/thread1.conf - ; thread /usr/local/etc/thread2.conf - ; thread /usr/local/etc/thread3.conf ---- motion-3.2.12.orig/motion.1 -+++ motion-3.2.12/motion.1 -@@ -1,9 +1,9 @@ --.TH MOTION 1 2008-09-20 "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 level ] [ -p process_id_file ] -+[ -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,28 +17,43 @@ Full path and filename of config file. E - .B \-h - Show help screen. - .TP -+.B \-m -+Disable motion detection at startup. -+.TP - .B \-n - Run in non-daemon mode. - .TP - .B \-s - Run in setup mode. Also forces non-daemon mode - .TP --.B \-d level --Run in debug mode, level 1-9. -+.B \-d log level -+Set log level [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -+.TP -+.B \-k log type -+Set type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) - .TP - .B \-p - Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. - .TP -+.B \-l -+Full path and filename of log file. ( use -l syslog to log to stderr and syslog ) -+.TP - .SH "CONFIG FILE OPTIONS" - These are the options that can be used in the config file. - .I They are overridden by the commandline! - All number values are integer numbers (no decimals allowed). - Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). - .TP --.B area_detect string --Values: 1 - 999999999 / Default: Not defined -+.B area_detect integer -+Values: 0 - 999999999 / Default: Not defined -+.br -+Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -+.br -+A script (on_area_detected) is started immediately when motion is 4 5 6 - .br --Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. -+detected in one of the given areas, but only once during an event. 7 8 9 -+.br -+One or more areas can be specified with this option. Take care: This option does NOT restrict detection to these areas! (Default: not defined) - .TP - .B auto_brightness boolean - Values: on, off / Default: off -@@ -55,57 +70,91 @@ Values: 0 - 255 / Default: 0 (disabled) - .br - The contrast level for the video device. - .TP --.B control_authentication string --Values: Max 4096 characters / Default: Not defined -+.B daemon boolean -+Values: on, off / Default: off - .br --To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. -+Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. - .TP --.B control_html_output boolean --Values: on, off / Default: on -+.B database_dbname string -+Values: Max 4095 characters / Default: Not defined - .br --Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. -+Name of the database. - .TP --.B control_localhost boolean --Values: on, off / Default: on -+.B database_host string -+Values: Max 4095 characters / Default: localhost - .br --Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. -+IP address or domain name for the database server. Use "localhost" if motion and database runs on the same server. - .TP --.B control_port integer --Values: 0 - 65535 / Default: 0 (disabled) -+.B database_password string -+Values: Max 4095 characters / Default: Not defined - .br --Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. -+The database password. - .TP --.B daemon boolean --Values: on, off / Default: off -+.B database_port integer -+Values: 0 - 65535 / Default: Not defined - .br --Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. -+The database server port number. -+.TP -+.B database_type discrete strings -+Values: mysql, postgresql / Default: Not defined -+.br -+The database type ( mysql , postgresql ). - .TP --.B despeckle string -+.B database_user string -+Values: Max 4095 characters / Default: Not defined -+.br -+The database user name. -+.TP -+.B despeckle_filter string - Values: EedDl / Default: Not defined - .br - Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. - .TP -+.B emulate_motion boolean -+Values: on, off / Default: off -+.br -+Picture are saved continuously as if motion was detected all the time. -+.TP -+.B event_gap integer -+Values: 0 - 2147483647 / Default: 60 -+.br -+Event Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. -+.TP -+.B exif_text string -+Values: Max 4095 characters / Default: Not defined -+.br -+Text to include in a JPEG EXIF comment , may be any text, including conversion specifiers. The EXIF timestamp is included independent of this text. -+.TP -+.B extpipe string -+Values: Max 4095 characters / Default: Not defined -+.br -+pipe raw video to generally - 'STDIN', allowing to use an external video encoder. -+.br -+e.g. using memcoder : -+.br -+extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt: threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps -+.TP - .B ffmpeg_bps integer - Values: 0 - 9999999 / Default: 400000 - .br --Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. -+Bitrate of movies produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. - .TP --.B ffmpeg_cap_motion boolean -+.B ffmpeg_output_debug_movies boolean - Values: on, off / Default: off - .br --Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. -+Use ffmpeg libraries to encode motion type movies where you only see the pixels that changes. - .TP --.B ffmpeg_cap_new boolean -+.B ffmpeg_output_movies boolean - Values: on, off / Default: off - .br --Use ffmpeg libraries to encode mpeg movies in realtime. -+Use ffmpeg libraries to encode movies in realtime. - .TP - .B ffmpeg_deinterlace boolean - Values: on, off / Default: off - .br --Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. -+Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. - .TP --.B ffmpeg_timelapse boolean -+.B ffmpeg_timelapse integer - Values: 0 - 2147483647 / Default: 0 (disabled) - .br - Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. -@@ -121,26 +170,21 @@ Values: 0, 2 - 31 / Default: 0 (disabled - Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. - .TP - .B ffmpeg_video_codec discrete strings --Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1, mov / Default: mpeg4 -+Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf , flv , ffv1, mov, ogg / Default: mpeg4 - .br --Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. -+Codec to be used by ffmpeg for the video compression. Timelapse movies are always made in mpeg1 format independent from this option. - .TP - .B framerate integer - Values: 2 - 100 / Default: 100 (no limit) - .br - Maximum number of frames to be captured from the camera per second. - .TP --.B frequency boolean -+.B frequency integer - Values: 0 - 999999 / Default: 0 (Not set) - .br - The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) - .TP --.B gap integer --Values: 0 - 2147483647 / Default: 60 --.br --Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. --.TP --.B height integer -+.B height integer - Values: Device Dependent / Default: 288 - .br - The height of each frame in pixels. -@@ -150,42 +194,62 @@ Values: 0 - 255 / Default: 0 (disabled) - .br - The hue level for the video device. - .TP --.B input integer --Values: 0 - 7, 8 = disabled / Default: 8 (disabled) -+.B input integer -+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 jpeg_filename string --Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q -+.B ipv6_enabled boolean -+Values: on, off / Default: off - .br --File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. -+Enable or disable IPV6 for http control and stream. - .TP --.B lightswitch integer -+.B lightswitch integer - Values: 0 - 100 / Default: 0 (disabled) - .br - Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. - .TP --.B locate boolean --Values: on, off, preview / Default: off -+.B locate_motion discrete strings -+Values: on, off, redbox, center, redcross, preview / Default: off -+.br -+Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved movie. -+.TP -+.B logfile string -+Values: Max 4095 characters / Default: Not defined - .br --Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. -+Use a file to save logs messages, if not defined stderr and syslog is used. -+.TP -+.B logfile string -+Values: Max 4095 characters / Default: Not defined -+.br -+Use a file to save logs messages, if not defined stderr and syslog is used. ( if syslog is set then will log to stderr and syslog ) -+.TP -+.B log_level integer -+Values: 1 - 9 / Default: 6 -+.br -+Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC). -+.TP -+.B log_type discrete strings -+Values: STR, ENC, NET, DBL, EVT, TRK, VID, ALL / Default: ALL -+.br -+Filter to log messages by type (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). - .TP - .B mask_file string - Values: Max 4095 characters / Default: Not defined - .br --PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. -+PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. - .TP --.B max_mpeg_time integer -+.B max_movie_time integer - Values: 0 (infinite) - 2147483647 / Default: 3600 - .br --The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. -+The maximum length of a movie in seconds. Set this to zero for unlimited length. - .TP - .B minimum_frame_time integer - Values: 0 - 2147483647 / Default: 0 - .br - Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. - .TP --.B minimum_motion_frames boolean -+.B minimum_motion_frames integer - Values: 1 - 1000s / Default: 1 - .br - Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. -@@ -198,47 +262,29 @@ The video4linux video loopback input dev - .B movie_filename string - Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S - .br --File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. -+File path for motion triggered ffmpeg movies relative to target_dir. This was previously called ffmpeg_filename. - .TP --.B mysql_db string --Values: Max 4095 characters / Default: Not defined --.br --Name of the MySQL database. --.TP --.B mysql_host string --Values: Max 4095 characters / Default: localhost --.br --IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. --.TP --.B mysql_password string --Values: Max 4095 characters / Default: Not defined --.br --The MySQL password. --.TP --.B mysql_user string --Values: Max 4095 characters / Default: Not defined -+.B netcam_tolerant_check boolean -+Values: on, off / Default: off - .br --The MySQL user name. -+Set less strict jpeg checks for network cameras with a poor/buggy firmware. - .TP --.B netcam_http discrete strings --Values: 1.0, keep_alive, 1.1 / Default: 1.0 -+.B netcam_keepalive discrete string -+Values: off , force, on / Default: off - .br --The setting for keep-alive of network socket, should improve performance on compatible net cameras. ( new in 3.2.10 )
                                                            -+The setting for keep-alive of network socket, should improve performance on compatible net cameras. - .TP - .B netcam_proxy string - Values: Max 4095 characters / Default: Not defined - .br - URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber - .TP --.B netcam_tolerant_check boolean --Values: on, off / Default: off --.br --Set less strict jpeg checks for network cameras with a poor/buggy firmware. --.TP - .B netcam_url string - Values: Max 4095 characters / Default: Not defined - .br - Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. -+.br -+http:// ftp:// mjpg:// or file:/// ( mjpg:// is for network cameras with codec mjpeg ). - .TP - .B netcam_userpass string - Values: Max 4095 characters / Default: Not defined -@@ -255,7 +301,7 @@ Values: on, off / Default: on - .br - Activates the automatic tuning of noise level. - .TP --.B norm discrete strings -+.B norm integer - Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) / Default: 0 (PAL) - .br - Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) -@@ -263,22 +309,22 @@ Select the norm of the video device. Val - .B on_area_detected string - Values: Max 4095 characters / Default: Not defined - .br --Command to be executed when motion in a predefined area is detected. Check option area_detect. -+Command to be executed when motion in a predefined area is detected, check option area_detect. - .TP --.B on_camera_lost string -+.B on_camera_lost - Values: Max 4095 characters / Default: Not defined - .br --Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10) -+Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. - .TP - .B on_event_end string - Values: Max 4095 characters / Default: Not defined - .br --Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. -+Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option event_gap. You can use Conversion Specifiers and spaces as part of the command. - .TP - .B on_event_start string - Values: Max 4095 characters / Default: Not defined - .br --Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. -+Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by event_gap. You can use ConversionSpecifiers and spaces as part of the command. - .TP - .B on_motion_detected string - Values: Max 4095 characters / Default: Not defined -@@ -293,67 +339,42 @@ Command to be executed when an ffmpeg mo - .B on_movie_start string - Values: Max 4095 characters / Default: Not defined - .br --Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -+Command to be executed when a movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. - .TP - .B on_picture_save string - Values: Max 4095 characters / Default: Not defined - .br - Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. - .TP --.B output_all boolean --Values: on, off / Default: off --.br --Picture are saved continuously as if motion was detected all the time. --.TP --.B output_motion boolean -+.B output_debug_pictures boolean - Values: on, off / Default: off - .br - Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. - .TP --.B output_normal discrete strings --Values: on, off, first, best, center (since 3.2.10) / Default: on -+.B output_pictures discrete strings -+Values: on, off, first, best, center / Default: on - .br - Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. - .TP --.B pgsql_db string --Values: Max 4095 characters / Default: Not defined --.br --Name of the PostgreSQL database. --.TP --.B pgsql_host string --Values: Max 4095 characters / Default: localhost --.br --IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. --.TP --.B pgsql_password string --Values: Max 4095 characters / Default: Not defined -+.B picture_filename string -+Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q - .br --The PostgreSQL password. -+File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved movie file. - .TP --.B pgsql_port integer --Values: 0 - 65535 / Default: 5432 -+.B picture_type discrete strings -+Values: jpeg , ppm / Default: jpeg - .br --The PostgreSQL server port number. --.TP --.B pgsql_user string --Values: Max 4095 characters / Default: Not defined --.br --The PostgreSQL user name. -+Type of images motion will trigger when motion is detected. - .TP - .B post_capture integer --Values: 0 - 2147483647 / Default: 0 (disabled) -+Values: 0 - 2147483647 / Default: 0 (disabled) - .br - Specifies the number of frames to be captured after motion has been detected. - .TP --.B ppm boolean --Values: on, off / Default: off --.br --Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. --.TP - .B pre_capture integer - Values: 0 - 100s / Default: 0 (disabled) - .br --Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. -+Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth movies. To smooth movies use larger values of post_capture instead. - .TP - .B process_id_file string - Values: Max 4095 characters / Default: Not defined -@@ -373,7 +394,7 @@ Be quiet, don't output beeps when detect - .B rotate discrete strings - Values: 0, 90, 180, 270 / Default: 0 (not rotated) - .br --Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. -+Rotate image the given number of degrees. The rotation affects all saved images as well as movies. - .TP - .B roundrobin_frames integer - Values: 1 - 2147483647 / Default: 1 -@@ -390,10 +411,15 @@ Values: 0 - 255 / Default: 0 (disabled) - .br - The colour saturation level for the video device. - .TP -+.B sdl_threadnr -+Values: 0 - 2147483647 / Default: 0 (disabled) -+.br -+Number of motion thread to show in SDL Window (default: 0 = disabled) -+.TP - .B setup_mode boolean - Values: on, off / Default: off - .br --Run Motion in setup mode. -+Run Motion in setup mode. - .TP - .B smart_mask_speed integer - Values: 0 - 10 / Default: 0 (disabled) -@@ -410,15 +436,15 @@ Values: 0 - 2147483647 / Default: 0 (dis - .br - Make automated snapshots every 'snapshot_interval' seconds. - .TP --.B sql_log_image boolean -+.B sql_log_picture boolean - Values: on, off / Default: on - .br - Log to the database when creating motion triggered image file. - .TP --.B sql_log_mpeg boolean -+.B sql_log_movie boolean - Values: on, off / Default: off - .br --Log to the database when creating motion triggered mpeg file. -+Log to the database when creating motion triggered movie file. - .TP - .B sql_log_snapshot boolean - Values: on, off / Default: on -@@ -428,13 +454,53 @@ Log to the database when creating a snap - .B sql_log_timelapse boolean - Values: on, off / Default: off - .br --Log to the database when creating timelapse mpeg file -+Log to the database when creating timelapse movie file - .TP - .B sql_query string --Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -+Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') - .br - SQL query string that is sent to the database. The values for each field are given by using convertion specifiers - .TP -+.B stream_auth_method integer -+Values: 0 = disabled , 1 = Basic authentication ,2 = MD5 digest (the safer authentication). / Default: 0 (disabled) -+.br -+Set the authentication method for stream. -+.TP -+.B stream_authentication string -+Values: username:password / Default: not defined (disabled) -+.br -+Authentication for the stream. -+.TP -+.B stream_limit integer -+Values: 0 - 2147483647 / Default: 0 (unlimited) -+.br -+Limit the number of frames to number frames. After 'stream_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. -+.TP -+.B stream_localhost boolean -+Values: on, off / Default: on -+.br -+Limits the access to the stream to the localhost. -+.TP -+.B stream_maxrate integer -+Values: 1 - 100 / Default: 1 -+.br -+Limit the framerate of the stream in frames per second. Default is 1. Set the value to 100 for practically unlimited. -+.TP -+.B stream_motion boolean -+Values: on, off / Default: off -+.br -+If set to 'on' Motion sends slows down the stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by stream_maxrate. When 'off' the stream always runs as defined by stream_maxrate. -+.TP -+.B stream_port integer -+Values: 0 - 65535 / Default: 0 (disabled) -+.br -+TCP port on which motion will listen for incoming connects with its stream server. -+.TP -+.B stream_quality integer -+Values: 1 - 100 / Default: 50 -+.br -+Quality setting in percent for the mjpeg picture frames transferred over the stream connection. Keep it low to restrict needed bandwidth. -+.TP - .B switchfilter boolean - Values: on, off / Default: off - .br -@@ -458,17 +524,17 @@ Draw characters at twice normal size on - .B text_event string - Values: Max 4095 characters / Default: %Y%m%d%H%M%S - .br --This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. -+This option defines the value of the special event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. - .TP - .B text_left string - Values: Max 4095 characters / Default: Not defined - .br --User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). -+User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). - .TP - .B text_right string - Values: Max 4095 characters / Default: %Y-%m-%d\n%T - .br --User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -+User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock - .TP - .B thread string - Values: Max 4095 characters / Default: Not defined -@@ -483,12 +549,12 @@ Threshold for declaring motion. The thre - .B threshold_tune boolean - Values: on, off / Default: off - .br --Activates the automatic tuning of threshold level. ( It's broken ) -+Activates the automatic tuning of threshold level. - .TP - .B timelapse_filename string - Values: Max 4095 characters / Default: %v-%Y%m%d-timelapse - .br --File path for timelapse mpegs relative to target_dir (ffmpeg only). -+File path for timelapse movies relative to target_dir (ffmpeg only). - .TP - .B track_auto boolean - Values: on, off / Default: off -@@ -496,17 +562,17 @@ Values: on, off / Default: off - Enable auto tracking - .TP - .B track_iomojo_id integer --Values: 0 - 65535 / Default: 0 -+Values: 0 - 65535 / Default: 0 - .br - Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. - .TP - .B track_maxx integer --Values: 0 - 65535 / Default: 0 -+Values: 0 - 65535 / Default: 0 - .br - The maximum position for servo x. - .TP - .B track_maxy integer --Values: 0 - 65535 / Default: 0 -+Values: 0 - 65535 / Default: 0 - .br - The maximum position for servo y. - .TP -@@ -551,7 +617,7 @@ Values: 0 - 255 / Default: 40 - Number of steps to make. - .TP - .B track_type discrete strings --Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) -+Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) - .br - Type of tracker. - .TP -@@ -560,55 +626,52 @@ Values: Max 4095 characters / Default: / - .br - The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. - .TP --.B v4l2_palette integer --Values: 0 - 8 / Default: 8 -+.B use_extpipe boolean -+Values: on, off / Default: off - .br --Allow to choose preferable palette to be use by motion
                                                            to capture from those supported by your videodevice. ( new in 3.2.10 ) -+Enables extpipe to use an external video encoder feeding with YUV420 using a pipe . - .TP --.B videodevice string --Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) -+.B v4l2_palette discrete strings -+Values: 0 - 8 / Default: 8 - .br --The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. -+Allow to choose preferable palette to be use by motion to capture from those supported by your videodevice. - .TP - .B video_pipe string - Values: Max 4095 characters / Default: Not defined - .br - The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. - .TP --.B webcam_limit integer --Values: 0 - 2147483647 / Default: 0 (unlimited) -+.B videodevice string -+Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) - .br --Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. -+The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. - .TP --.B webcam_localhost boolean --Values: on, off / Default: on -+.B webcontrol_authentication string -+Values: Max 4096 characters / Default: Not defined - .br --Limits the access to the webcam to the localhost. -+To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username: password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. - .TP --.B webcam_maxrate integer --Values: 1 - 100 / Default: 1 -+.B webcontrol_html_output boolean -+Values: on, off / Default: on - .br --Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. -+Enable HTML in the answer sent back to a browser connecting to the webcontrol_port. This option must be placed in motion.conf and not in a thread config file. - .TP --.B webcam_motion boolean --Values: on, off / Default: off -+.B webcontrol_localhost boolean -+Values: on, off / Default: on - .br --If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. -+Limits the webcontrol to the localhost. This option must be placed in motion.conf and not in a thread config file. - .TP --.B webcam_port integer -+.B webcontrol_port integer - Values: 0 - 65535 / Default: 0 (disabled) - .br --TCP port on which motion will listen for incoming connects with its webcam server. --.TP --.B webcam_quality integer --Values: 1 - 100 / Default: 50 --.br --Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. -+Sets the port number for the http (html using browser) based remote webcontrol. This option must be placed in motion.conf and not in a thread config file. -+ - .TP - .B width integer - Values: Device Dependent / Default: 352 - .br - The width in pixels of each frame. Valid range is camera dependent. -+ - .SH SIGNALS - Motion responds to the following signals: - .TP -@@ -616,17 +679,17 @@ Motion responds to the following signals - The config file will be reread. - .TP - .B SIGTERM --If needed motion will create an mpeg file of the last event and exit -+If needed motion will create a movie file of the last event and exit - .TP - .B SIGUSR1 --Motion will create an mpeg file of the current event. -+Motion will create a movie file of the current event. - .SH NOTES - .TP - .B Snapshot - A snapshot is a picture taken at regular intervals independently of any movement in the picture. - .TP - .B Motion image --A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. -+A "motion" image/movie shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. - .TP - .B Normal image - A "normal" image is the real image taken by the camera with text overlayed. -@@ -674,13 +737,13 @@ So always call the thread config files i - .br - If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. - .br --If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. -+If you run the webcontrol command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. - .TP - .B Conversion Specifiers for Advanced Filename and Text Features --The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_area_detected, on_camera_lost, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. -- -+The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, picture_filename, movie_filename, timelapse_filename, on_area_detected, on_camera_lost, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. - .br - In text_left and text_right you can additionally use '\n' for new line. -+ - .TP - .B %a - The abbreviated weekday name according to the current locale. -@@ -719,7 +782,7 @@ Equivalent to %Y-%m-%d (the ISO 8601 dat - The hour as a decimal number using a 24-hour clock (range 00 to 23). - .TP - .B %i --Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). -+Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate_motion is on). - .TP - .B %I - The hour as a decimal number using a 12-hour clock (range 01 to 12). -@@ -728,7 +791,7 @@ The hour as a decimal number using a 12- - The day of the year as a decimal number (range 001 to 366). - .TP - .B %J --Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). -+Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate_motion is on). - .TP - .B %k - The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) -@@ -764,7 +827,7 @@ Either 'AM' or 'PM' according to the giv - Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. - .TP - .B %q --Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. -+Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for movies. - .TP - .B %Q - Number of detected labels found by the despeckle feature -@@ -822,16 +885,17 @@ The time-zone as hour offset from GMT. - .TP - .B %Z - The time zone or name or abbreviation. -+ - .TP - .B More information - Motion homepage: http://motion.sourceforge.net/ - - Motion Guide (user and installation guide): - .br --http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide -+http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide - .br --http://www.lavrsen.dk/foswiki/bin/view/Motion/VideoFourLinuxLoopbackDevice -+http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice - .SH AUTHORS - Jeroen Vreeken (pe1rxq@amsat.org), - Folkert van Heusden, --Kenneth Lavrsen (kenneth@lavrsen.dk) -\ No newline at end of file -+Kenneth Lavrsen (kenneth@lavrsen.dk) ---- motion-3.2.12.orig/motion.c -+++ motion-3.2.12/motion.c -@@ -9,7 +9,7 @@ - #include "ffmpeg.h" - #include "motion.h" - --#if (defined(BSD) && !defined(PWCBSD)) -+#if (defined(BSD) && !defined(PWCBSD)) - #include "video_freebsd.h" - #else - #include "video.h" -@@ -58,15 +58,11 @@ struct context **cnt_list = NULL; - */ - volatile int threads_running = 0; - --/* -- * debug_level is for developers, normally used to control which -- * types of messages get output. -- */ --unsigned short int debug_level; -+/* Set this when we want main to end or restart */ -+volatile unsigned int finish = 0; - --/* Set this when we want main to end or restart -- */ --volatile unsigned short int finish = 0; -+/* Log file used instead of stderr and syslog */ -+FILE *ptr_logfile = NULL; - - /** - * restart -@@ -75,7 +71,7 @@ volatile unsigned short int finish = 0; - * finished running, 'main' checks if 'restart' is true and if so starts - * up again (instead of just quitting). - */ --unsigned short int restart = 0; -+unsigned int restart = 0; - - /** - * image_ring_resize -@@ -92,29 +88,33 @@ unsigned short int restart = 0; - */ - static void image_ring_resize(struct context *cnt, int new_size) - { -- /* Only resize if : -+ /* -+ * Only resize if : - * Not in an event and - * decreasing at last position in new buffer - * increasing at last position in old buffer -- * e.g. at end of smallest buffer */ -+ * e.g. at end of smallest buffer -+ */ - if (cnt->event_nr != cnt->prev_event) { - int smallest; -- -- if (new_size < cnt->imgs.image_ring_size) { /* Decreasing */ -+ -+ if (new_size < cnt->imgs.image_ring_size) /* Decreasing */ - smallest = new_size; -- } else { /* Increasing */ -+ else /* Increasing */ - smallest = cnt->imgs.image_ring_size; -- } -- -+ - if (cnt->imgs.image_ring_in == smallest - 1 || smallest == 0) { -- motion_log(LOG_INFO, 0, "Resizing pre_capture buffer to %d items", new_size); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Resizing pre_capture buffer to %d items", -+ new_size); - - /* Create memory for new ring buffer */ - struct image_data *tmp; - tmp = mymalloc(new_size * sizeof(struct image_data)); - -- /* Copy all information from old to new -- * Smallest is 0 at initial init */ -+ /* -+ * Copy all information from old to new -+ * Smallest is 0 at initial init -+ */ - if (smallest > 0) - memcpy(tmp, cnt->imgs.image_ring, sizeof(struct image_data) * smallest); - -@@ -152,7 +152,7 @@ static void image_ring_resize(struct con - */ - static void image_ring_destroy(struct context *cnt) - { -- unsigned short int i; -+ int i; - - /* Exit if don't have any ring */ - if (cnt->imgs.image_ring == NULL) -@@ -195,16 +195,30 @@ static void image_save_as_preview(struct - /* Copy image */ - memcpy(cnt->imgs.preview_image.image, img->image, cnt->imgs.size); - -- /* If we set output_all to yes and during the event -- * there is no image with motion, diffs is 0, we are not going to save the preview event */ -+ /* -+ * If we set output_all to yes and during the event -+ * there is no image with motion, diffs is 0, we are not going to save the preview event -+ */ - if (cnt->imgs.preview_image.diffs == 0) - cnt->imgs.preview_image.diffs = 1; - -- /* If we have locate on it is already done */ -- if (cnt->locate == LOCATE_PREVIEW) -- alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, -- cnt->imgs.preview_image.image, LOCATE_NORMAL); -- -+ /* draw locate box here when mode = LOCATE_PREVIEW */ -+ if (cnt->locate_motion_mode == LOCATE_PREVIEW) { -+ -+ if (cnt->locate_motion_style == LOCATE_BOX) { -+ alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, -+ LOCATE_BOX, LOCATE_NORMAL, cnt->process_thisframe); -+ } else if (cnt->locate_motion_style == LOCATE_REDBOX) { -+ alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, -+ LOCATE_REDBOX, LOCATE_NORMAL, cnt->process_thisframe); -+ } else if (cnt->locate_motion_style == LOCATE_CROSS) { -+ alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, -+ LOCATE_CROSS, LOCATE_NORMAL, cnt->process_thisframe); -+ } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { -+ alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, -+ LOCATE_REDCROSS, LOCATE_NORMAL, cnt->process_thisframe); -+ } -+ } - } - - /** -@@ -219,9 +233,9 @@ static void image_save_as_preview(struct - * - * Returns: nothing - */ --static void context_init (struct context *cnt) -+static void context_init(struct context *cnt) - { -- /* -+ /* - * We first clear the entire structure to zero, then fill in any - * values which have non-zero default values. Note that this - * assumes that a NULL address pointer has a value of binary 0 -@@ -255,7 +269,7 @@ static void context_init (struct context - */ - static void context_destroy(struct context *cnt) - { -- unsigned short int j; -+ unsigned int j; - - /* Free memory allocated for config parameters */ - for (j = 0; config_params[j].param_name != NULL; j++) { -@@ -279,11 +293,12 @@ static void context_destroy(struct conte - */ - static void sig_handler(int signo) - { -- short int i; -+ int i; - - switch(signo) { - case SIGALRM: -- /* Somebody (maybe we ourself) wants us to make a snapshot -+ /* -+ * Somebody (maybe we ourself) wants us to make a snapshot - * This feature triggers snapshots on ALL threads that have - * snapshot_interval different from 0. - */ -@@ -292,13 +307,15 @@ static void sig_handler(int signo) - while (cnt_list[++i]) { - if (cnt_list[i]->conf.snapshot_interval) - cnt_list[i]->snapshot = 1; -- -+ - } - } - break; - case SIGUSR1: -- /* Ouch! We have been hit from the outside! Someone wants us to -- make a movie! */ -+ /* -+ * Ouch! We have been hit from the outside! Someone wants us to -+ * make a movie! -+ */ - if (cnt_list) { - i = -1; - while (cnt_list[++i]) -@@ -307,27 +324,33 @@ static void sig_handler(int signo) - break; - case SIGHUP: - restart = 1; -- /* Fall through, as the value of 'restart' is the only difference -+ /* -+ * Fall through, as the value of 'restart' is the only difference - * between SIGHUP and the ones below. - */ - case SIGINT: - case SIGQUIT: - case SIGTERM: -- /* Somebody wants us to quit! We should better finish the actual -- movie and end up! */ -+ /* -+ * Somebody wants us to quit! We should better finish the actual -+ * movie and end up! -+ */ - if (cnt_list) { - i = -1; - while (cnt_list[++i]) { - cnt_list[i]->makemovie = 1; - cnt_list[i]->finish = 1; -- /* don't restart thread when it ends, -+ /* -+ * Don't restart thread when it ends, - * all threads restarts if global restart is set - */ -- cnt_list[i]->restart = 0; -+ cnt_list[i]->restart = 0; - } - } -- /* Set flag we want to quit main check threads loop -- * if restart is set (above) we start up again */ -+ /* -+ * Set flag we want to quit main check threads loop -+ * if restart is set (above) we start up again -+ */ - finish = 1; - break; - case SIGSEGV: -@@ -350,26 +373,34 @@ static void sigchild_handler(int signo A - } - - /** -- * motion_remove_pid -- * -- * This function remove the process id file ( pid file ) before motion exit. -+ * motion_remove_pid - * -+ * This function remove the process id file ( pid file ) before motion exit. - */ - static void motion_remove_pid(void) - { - if ((cnt_list[0]->daemon) && (cnt_list[0]->conf.pid_file) && (restart == 0)) { - if (!unlink(cnt_list[0]->conf.pid_file)) -- motion_log(LOG_INFO, 0, "Removed process id file (pid file)."); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Removed process id file (pid file)."); - else -- motion_log(LOG_INFO, 1, "Error removing pid file"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error removing pid file"); - } -+ -+ if (ptr_logfile) { -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Closing logfile (%s).", -+ cnt_list[0]->conf.log_file); -+ myfclose(ptr_logfile); -+ set_log_mode(LOGMODE_SYSLOG); -+ ptr_logfile = NULL; -+ } -+ - } - - /** - * motion_detected - * - * Called from 'motion_loop' when motion is detected -- * Can be called when no motion if output_all is set! -+ * Can be called when no motion if emulate_motion is set! - * - * Parameters: - * -@@ -384,14 +415,29 @@ static void motion_detected(struct conte - struct coord *location = &img->location; - - /* Draw location */ -- if (cnt->locate == LOCATE_ON) -- alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_BOTH); -+ if (cnt->locate_motion_mode == LOCATE_ON) { -+ -+ if (cnt->locate_motion_style == LOCATE_BOX) { -+ alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_BOX, -+ LOCATE_BOTH, cnt->process_thisframe); -+ } else if (cnt->locate_motion_style == LOCATE_REDBOX) { -+ alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDBOX, -+ LOCATE_BOTH, cnt->process_thisframe); -+ } else if (cnt->locate_motion_style == LOCATE_CROSS) { -+ alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_CROSS, -+ LOCATE_BOTH, cnt->process_thisframe); -+ } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { -+ alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDCROSS, -+ LOCATE_BOTH, cnt->process_thisframe); -+ } -+ } - - /* Calculate how centric motion is if configured preview center*/ - if (cnt->new_img & NEWIMG_CENTER) { -- unsigned int distX = abs((imgs->width/2) - location->x); -- unsigned int distY = abs((imgs->height/2) - location->y); -- img->cent_dist = distX*distX + distY*distY; -+ unsigned int distX = abs((imgs->width / 2) - location->x); -+ unsigned int distY = abs((imgs->height / 2) - location->y); -+ -+ img->cent_dist = distX * distX + distY * distY; - } - - -@@ -399,14 +445,16 @@ static void motion_detected(struct conte - if (img->flags & IMAGE_TRIGGER) { - /* Take action if this is a new event and we have a trigger image */ - if (cnt->event_nr != cnt->prev_event) { -- /* Reset prev_event number to current event and save event time -+ /* -+ * Reset prev_event number to current event and save event time - * in both time_t and struct tm format. - */ - cnt->prev_event = cnt->event_nr; - cnt->eventtime = img->timestamp; - localtime_r(&cnt->eventtime, cnt->eventtime_tm); - -- /* Since this is a new event we create the event_text_string used for -+ /* -+ * Since this is a new event we create the event_text_string used for - * the %C conversion specifier. We may already need it for - * on_motion_detected_commend so it must be done now. - */ -@@ -416,8 +464,8 @@ static void motion_detected(struct conte - /* EVENT_FIRSTMOTION triggers on_event_start_command and event_ffmpeg_newfile */ - event(cnt, EVENT_FIRSTMOTION, img->image, NULL, NULL, &img->timestamp_tm); - -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Motion detected - starting event %d", cnt->event_nr); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion detected - starting event %d", -+ cnt->event_nr); - - /* always save first motion frame as preview-shot, may be changed to an other one later */ - if (cnt->new_img & (NEWIMG_FIRST | NEWIMG_BEST | NEWIMG_CENTER)) -@@ -431,23 +479,25 @@ static void motion_detected(struct conte - - /* Limit framerate */ - if (img->shot < conf->frame_limit) { -- /* If config option webcam_motion is enabled, send the latest motion detected image -- * to the webcam but only if it is not the first shot within a second. This is to -- * avoid double frames since we already have sent a frame to the webcam. -+ /* -+ * If config option stream_motion is enabled, send the latest motion detected image -+ * to the stream but only if it is not the first shot within a second. This is to -+ * avoid double frames since we already have sent a frame to the stream. - * We also disable this in setup_mode. - */ -- if (conf->webcam_motion && !conf->setup_mode && img->shot != 1) -- event(cnt, EVENT_WEBCAM, img->image, NULL, NULL, &img->timestamp_tm); -- -+ if (conf->stream_motion && !conf->setup_mode && img->shot != 1) -+ event(cnt, EVENT_STREAM, img->image, NULL, NULL, &img->timestamp_tm); - -- /* Save motion jpeg, if configured */ -- /* Output the image_out (motion) picture. */ -+ /* -+ * Save motion jpeg, if configured -+ * Output the image_out (motion) picture. -+ */ - if (conf->motion_img) - event(cnt, EVENT_IMAGEM_DETECTED, NULL, NULL, NULL, &img->timestamp_tm); -- - } - -- if (cnt->track.type) -+ /* if track enabled and auto track on */ -+ if (cnt->track.type && cnt->track.active) - cnt->moved = track_move(cnt, dev, location, imgs, 0); - - } -@@ -466,26 +516,99 @@ static void motion_detected(struct conte - #define IMAGE_BUFFER_FLUSH ((unsigned int)-1) - static void process_image_ring(struct context *cnt, unsigned int max_images) - { -- /* we are going to send an event, in the events there is still -+ /* -+ * We are going to send an event, in the events there is still - * some code that use cnt->current_image -- * so set it temporary to our image */ -+ * so set it temporary to our image -+ */ - struct image_data *saved_current_image = cnt->current_image; - - /* If image is flaged to be saved and not saved yet, process it */ - do { - /* Check if we should save/send this image, breakout if not */ -- if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & -- (IMAGE_SAVE | IMAGE_SAVED)) != IMAGE_SAVE) -+ if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & (IMAGE_SAVE | IMAGE_SAVED)) != IMAGE_SAVE) - break; - - /* Set inte global cotext that we are working with this image */ - cnt->current_image = &cnt->imgs.image_ring[cnt->imgs.image_ring_out]; - - if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot < cnt->conf.frame_limit) { -+ if (cnt->log_level >= DBG) { -+ char tmp[32]; -+ const char *t; -+ -+ if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_TRIGGER) -+ t = "Trigger"; -+ else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_MOTION) -+ t = "Motion"; -+ else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_PRECAP) -+ t = "Precap"; -+ else if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_POSTCAP) -+ t = "Postcap"; -+ else -+ t = "Other"; -+ -+ mystrftime(cnt, tmp, sizeof(tmp), "%H%M%S-%q", -+ &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm, NULL, 0); -+ draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 20, -+ cnt->imgs.width, tmp, cnt->conf.text_double); -+ draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 30, -+ cnt->imgs.width, t, cnt->conf.text_double); -+ } -+ - /* Output the picture to jpegs and ffmpeg */ - event(cnt, EVENT_IMAGE_DETECTED, - cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, - &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm); -+ -+ /* -+ * 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) && -+#ifdef HAVE_FFMPEG -+ (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { -+#else -+ (cnt->conf.useextpipe && cnt->extpipe)) { -+#endif -+ /* -+ * 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) { -+ if (cnt_list[0]->log_level >= DBG) { -+ int frames = cnt->movie_fps - (cnt->movie_last_shot + 1); -+ if (frames > 0) { -+ char tmp[15]; -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Added %d fillerframes into movie", -+ frames); -+ sprintf(tmp, "Fillerframes %d", frames); -+ draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 40, -+ cnt->imgs.width, tmp, cnt->conf.text_double); -+ } -+ } -+ /* Check how many frames it was last sec */ -+ while ((cnt->movie_last_shot + 1) < cnt->movie_fps) { -+ /* Add a filler frame into encoder */ -+ event(cnt, EVENT_FFMPEG_PUT, -+ cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, -+ &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm); -+ -+ cnt->movie_last_shot++; -+ } -+ } -+ 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! 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; - } - - /* Mark the image as saved */ -@@ -493,17 +616,17 @@ static void process_image_ring(struct co - - /* Store it as a preview image, only if it have motion */ - if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].flags & IMAGE_MOTION) { -- -- /* Check for most significant preview-shot when output_normal=best */ -+ /* Check for most significant preview-shot when output_pictures=best */ - if (cnt->new_img & NEWIMG_BEST) { -- if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].diffs > cnt->imgs.preview_image.diffs) -+ if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].diffs > cnt->imgs.preview_image.diffs) { - image_save_as_preview(cnt, &cnt->imgs.image_ring[cnt->imgs.image_ring_out]); -+ } - } -- -- /* Check for most significant preview-shot when output_normal=center */ -+ /* Check for most significant preview-shot when output_pictures=center */ - if (cnt->new_img & NEWIMG_CENTER) { -- if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].cent_dist < cnt->imgs.preview_image.cent_dist) -+ if (cnt->imgs.image_ring[cnt->imgs.image_ring_out].cent_dist < cnt->imgs.preview_image.cent_dist) { - image_save_as_preview(cnt, &cnt->imgs.image_ring[cnt->imgs.image_ring_out]); -+ } - } - } - -@@ -538,10 +661,10 @@ static void process_image_ring(struct co - * Returns: 0 OK - * -1 Fatal error, open loopback error - * -2 Fatal error, open SQL database error -+ * -3 Fatal error, image dimensions are not modulo 16 - */ - static int motion_init(struct context *cnt) - { -- int i; - FILE *picture; - - /* Store thread number in TLS. */ -@@ -555,34 +678,42 @@ static int motion_init(struct context *c - - cnt->smartmask_speed = 0; - -- /* We initialize cnt->event_nr to 1 and cnt->prev_event to 0 (not really needed) so -- * that certain code below does not run until motion has been detected the first time */ -+ /* -+ * We initialize cnt->event_nr to 1 and cnt->prev_event to 0 (not really needed) so -+ * that certain code below does not run until motion has been detected the first time -+ */ - cnt->event_nr = 1; - cnt->prev_event = 0; - cnt->lightswitch_framecounter = 0; - cnt->detecting_motion = 0; - cnt->makemovie = 0; - -- motion_log(LOG_DEBUG, 0, "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 = strdup("."); -+ cnt->conf.filepath = mystrdup("."); - - /* set the device settings */ - cnt->video_dev = vid_start(cnt); - -- /* We failed to get an initial image from a camera -+ /* -+ * We failed to get an initial image from a camera - * So we need to guess height and width based on the config - * file options. - */ -- if (cnt->video_dev < 0) { -- motion_log(LOG_ERR, 0, "Could not fetch initial image from camera"); -- motion_log(LOG_ERR, 0, "Motion continues using width and height from config file(s)"); -+ if (cnt->video_dev == -1) { -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " -+ "Motion continues using width and height from config file(s)"); - cnt->imgs.width = cnt->conf.width; - cnt->imgs.height = cnt->conf.height; - cnt->imgs.size = cnt->conf.width * cnt->conf.height * 3 / 2; - cnt->imgs.motionsize = cnt->conf.width * cnt->conf.height; - cnt->imgs.type = VIDEO_PALETTE_YUV420P; -+ } else if (cnt->video_dev == -2) { -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " -+ "Motion only supports width and height modulo 16"); -+ return -3; - } - - image_ring_resize(cnt, 1); /* Create a initial precapture ring buffer with 1 frame */ -@@ -590,6 +721,7 @@ static int motion_init(struct context *c - cnt->imgs.ref = mymalloc(cnt->imgs.size); - cnt->imgs.out = mymalloc(cnt->imgs.size); - memset(cnt->imgs.out, 0, cnt->imgs.size); -+ - /* contains the moving objects of ref. frame */ - cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); - cnt->imgs.image_virgin = mymalloc(cnt->imgs.size); -@@ -599,14 +731,23 @@ static int motion_init(struct context *c - cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.labels)); - cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(cnt->imgs.labelsize)); - -+ /* Set output picture type */ -+ if (!strcmp(cnt->conf.picture_type, "ppm")) -+ cnt->imgs.picture_type = IMAGE_TYPE_PPM; -+ else -+ cnt->imgs.picture_type = IMAGE_TYPE_JPEG; -+ - /* allocate buffer here for preview buffer */ - cnt->imgs.preview_image.image = mymalloc(cnt->imgs.size); - -- /* Allocate a buffer for temp. usage in some places */ -- /* Only despeckle & bayer2rgb24() for now for now... */ -+ /* -+ * Allocate a buffer for temp. usage in some places -+ * Only despeckle & bayer2rgb24() for now for now... -+ */ - cnt->imgs.common_buffer = mymalloc(3 * cnt->imgs.width * cnt->imgs.height); - -- /* Now is a good time to init rotation data. Since vid_start has been -+ /* -+ * Now is a good time to init rotation data. Since vid_start has been - * called, we know that we have imgs.width and imgs.height. When capturing - * from a V4L device, these are copied from the corresponding conf values - * in vid_start. When capturing from a netcam, they get set in netcam_start, -@@ -618,130 +759,160 @@ static int motion_init(struct context *c - - /* Capture first image, or we will get an alarm on start */ - if (cnt->video_dev > 0) { -+ int i; -+ - for (i = 0; i < 5; i++) { - if (vid_next(cnt, cnt->imgs.image_virgin) == 0) - break; -- SLEEP(2,0); -+ SLEEP(2, 0); - } -+ - if (i >= 5) { - memset(cnt->imgs.image_virgin, 0x80, cnt->imgs.size); /* initialize to grey */ - draw_text(cnt->imgs.image_virgin, 10, 20, cnt->imgs.width, - "Error capturing first image", cnt->conf.text_double); -- motion_log(LOG_ERR, 0, "Error capturing first image"); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Error capturing first image"); - } - } - - /* create a reference frame */ - alg_update_reference_frame(cnt, RESET_REF_FRAME); - --#if !defined(WITHOUT_V4L) && !defined(BSD) -+#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) - /* open video loopback devices if enabled */ - if (cnt->conf.vidpipe) { -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Opening video loopback device for normal pictures"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for normal pictures"); - - /* vid_startpipe should get the output dimensions */ - cnt->pipe = vid_startpipe(cnt->conf.vidpipe, cnt->imgs.width, cnt->imgs.height, cnt->imgs.type); - - if (cnt->pipe < 0) { -- motion_log(LOG_ERR, 0, "Failed to open video loopback"); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for normal pictures"); - return -1; - } - } -+ - if (cnt->conf.motionvidpipe) { -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Opening video loopback device for motion pictures"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for motion pictures"); - - /* vid_startpipe should get the output dimensions */ - cnt->mpipe = vid_startpipe(cnt->conf.motionvidpipe, cnt->imgs.width, cnt->imgs.height, cnt->imgs.type); - - if (cnt->mpipe < 0) { -- motion_log(LOG_ERR, 0, "Failed to open video loopback"); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for motion pictures"); - return -1; - } - } --#endif /*WITHOUT_V4L && !BSD */ -+#endif /* !WITHOUT_V4L && !BSD */ - --#ifdef HAVE_MYSQL -- if (cnt->conf.mysql_db) { -- cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); -- mysql_init(cnt->database); -- -- if (!mysql_real_connect(cnt->database, cnt->conf.mysql_host, cnt->conf.mysql_user, -- cnt->conf.mysql_password, cnt->conf.mysql_db, 0, NULL, 0)) { -- motion_log(LOG_ERR, 0, "Cannot connect to MySQL database %s on host %s with user %s", -- cnt->conf.mysql_db, cnt->conf.mysql_host, cnt->conf.mysql_user); -- motion_log(LOG_ERR, 0, "MySQL error was %s", mysql_error(cnt->database)); -- return -2; -- } -- #if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) -- my_bool my_true = TRUE; -- mysql_options(cnt->database,MYSQL_OPT_RECONNECT,&my_true); -- #endif -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) -+ if (cnt->conf.database_type) { -+ MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: Database backend %s", -+ cnt->conf.database_type); -+ -+#ifdef HAVE_SQLITE3 -+ if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { -+ MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: DB %s", -+ cnt->conf.sqlite3_db); -+ -+ if (sqlite3_open(cnt->conf.sqlite3_db, &cnt->database_sqlite3) != SQLITE_OK) { -+ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s\n", -+ cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); -+ sqlite3_close(cnt->database_sqlite3); -+ exit(1); -+ } - } -+#endif /* HAVE_SQLITE3 */ -+ -+#ifdef HAVE_MYSQL -+ if ((!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { -+ // close database to be sure that we are not leaking -+ mysql_close(cnt->database); -+ -+ cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); -+ mysql_init(cnt->database); -+ -+ if (!mysql_real_connect(cnt->database, cnt->conf.database_host, cnt->conf.database_user, -+ cnt->conf.database_password, cnt->conf.database_dbname, 0, NULL, 0)) { -+ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Cannot connect to MySQL database %s on host %s with user %s", -+ cnt->conf.database_dbname, cnt->conf.database_host, -+ cnt->conf.database_user); -+ MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: MySQL error was %s", mysql_error(cnt->database)); -+ return -2; -+ } -+#if (defined(MYSQL_VERSION_ID)) && (MYSQL_VERSION_ID > 50012) -+ my_bool my_true = TRUE; -+ mysql_options(cnt->database, MYSQL_OPT_RECONNECT, &my_true); -+#endif -+ } - #endif /* HAVE_MYSQL */ - - #ifdef HAVE_PGSQL -- if (cnt->conf.pgsql_db) { -- char connstring[255]; -+ if ((!strcmp(cnt->conf.database_type, "postgresql")) && (cnt->conf.database_dbname)) { -+ char connstring[255]; - -- /* create the connection string. -- Quote the values so we can have null values (blank)*/ -- snprintf(connstring, 255, -- "dbname='%s' host='%s' user='%s' password='%s' port='%d'", -- cnt->conf.pgsql_db, /* dbname */ -- (cnt->conf.pgsql_host ? cnt->conf.pgsql_host : ""), /* host (may be blank) */ -- (cnt->conf.pgsql_user ? cnt->conf.pgsql_user : ""), /* user (may be blank) */ -- (cnt->conf.pgsql_password ? cnt->conf.pgsql_password : ""), /* password (may be blank) */ -- cnt->conf.pgsql_port -- ); -- -- cnt->database_pg = PQconnectdb(connstring); -- -- if (PQstatus(cnt->database_pg) == CONNECTION_BAD) { -- motion_log(LOG_ERR, 0, "Connection to PostgreSQL database '%s' failed: %s", -- cnt->conf.pgsql_db, PQerrorMessage(cnt->database_pg)); -- return -2; -+ /* -+ * Create the connection string. -+ * Quote the values so we can have null values (blank) -+ */ -+ snprintf(connstring, 255, -+ "dbname='%s' host='%s' user='%s' password='%s' port='%d'", -+ cnt->conf.database_dbname, /* dbname */ -+ (cnt->conf.database_host ? cnt->conf.database_host : ""), /* host (may be blank) */ -+ (cnt->conf.database_user ? cnt->conf.database_user : ""), /* user (may be blank) */ -+ (cnt->conf.database_password ? cnt->conf.database_password : ""), /* password (may be blank) */ -+ cnt->conf.database_port -+ ); -+ -+ cnt->database_pg = PQconnectdb(connstring); -+ 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)); -+ return -2; -+ } - } -- } - #endif /* HAVE_PGSQL */ -+ - -+ /* Set the sql mask file according to the SQL config options*/ - --#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) -- /* Set the sql mask file according to the SQL config options*/ -+ cnt->sql_mask = cnt->conf.sql_log_image * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + -+ cnt->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + -+ cnt->conf.sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + -+ cnt->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; -+ } - -- cnt->sql_mask = cnt->conf.sql_log_image * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + -- cnt->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + -- cnt->conf.sql_log_mpeg * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + -- cnt->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; --#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) */ -+#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ - - /* Load the mask file if any */ - if (cnt->conf.mask_file) { -- if ((picture = fopen(cnt->conf.mask_file, "r"))) { -- /* NOTE: The mask is expected to have the output dimensions. I.e., the mask -+ if ((picture = myfopen(cnt->conf.mask_file, "r", 0))) { -+ /* -+ * NOTE: The mask is expected to have the output dimensions. I.e., the mask - * applies to the already rotated image, not the capture image. Thus, use - * width and height from imgs. - */ - cnt->imgs.mask = get_pgm(picture, cnt->imgs.width, cnt->imgs.height); -- fclose(picture); -+ myfclose(picture); - } else { -- motion_log(LOG_ERR, 1, "Error opening mask file %s", cnt->conf.mask_file); -- /* Try to write an empty mask file to make it easier -- for the user to edit it */ -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening mask file %s", -+ cnt->conf.mask_file); -+ /* -+ * Try to write an empty mask file to make it easier -+ * for the user to edit it -+ */ - put_fixed_mask(cnt, cnt->conf.mask_file); - } - - if (!cnt->imgs.mask) { -- motion_log(LOG_ERR, 0, "Failed to read mask image. Mask feature disabled."); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to read mask image. Mask feature disabled."); - } else { -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Maskfile \"%s\" loaded.",cnt->conf.mask_file); -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Maskfile \"%s\" loaded.", -+ cnt->conf.mask_file); - } -- - } else { - cnt->imgs.mask = NULL; -- } -+ } - - /* Always initialize smart_mask - someone could turn it on later... */ - memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); -@@ -754,13 +925,15 @@ static int motion_init(struct context *c - /* Set threshold value */ - cnt->threshold = cnt->conf.max_changes; - -- /* Initialize webcam server if webcam port is specified to not 0 */ -- if (cnt->conf.webcam_port) { -- if (webcam_init(cnt) == -1) { -- motion_log(LOG_ERR, 1, "Problem enabling stream server in port %d", cnt->conf.webcam_port); -+ /* Initialize stream server if stream port is specified to not 0 */ -+ if (cnt->conf.stream_port) { -+ if (stream_init(cnt) == -1) { -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem enabling motion-stream server in port %d", -+ cnt->conf.stream_port); - cnt->finish = 1; -- } else { -- motion_log(LOG_DEBUG, 0, "Started stream webcam server in port %d", cnt->conf.webcam_port); -+ } else { -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Started motion-stream server in port %d auth %s", -+ cnt->conf.stream_port, cnt->conf.stream_auth_method ? "Enabled":"Disabled"); - } - } - -@@ -786,11 +959,11 @@ static int motion_init(struct context *c - */ - static void motion_cleanup(struct context *cnt) - { -- /* Stop webcam */ -+ /* Stop stream */ - event(cnt, EVENT_STOP, NULL, NULL, NULL, NULL); - - if (cnt->video_dev >= 0) { -- motion_log(LOG_DEBUG, 0, "Calling vid_close() from motion_cleanup"); -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Calling vid_close() from motion_cleanup"); - vid_close(cnt); - } - -@@ -874,6 +1047,26 @@ static void motion_cleanup(struct contex - free(cnt->eventtime_tm); - cnt->eventtime_tm = NULL; - } -+ -+ if (cnt->conf.database_type) { -+#ifdef HAVE_MYSQL -+ if ( (!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { -+ mysql_close(cnt->database); -+ } -+#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 -+ /* Close the SQLite database */ -+ if (cnt->conf.sqlite3_db) -+ sqlite3_close(cnt->database_sqlite3); -+#endif /* HAVE_SQLITE3 */ -+ } - } - - /** -@@ -888,34 +1081,33 @@ static void *motion_loop(void *arg) - int i, j, z = 0; - time_t lastframetime = 0; - int frame_buffer_size; -- unsigned short int ref_frame_limit = 0; -+ unsigned int rate_limit = 0; - int area_once = 0; - int area_minx[9], area_miny[9], area_maxx[9], area_maxy[9]; - int smartmask_ratio = 0; - int smartmask_count = 20; -- int smartmask_lastrate = 0; -+ unsigned int smartmask_lastrate = 0; - int olddiffs = 0; - int previous_diffs = 0, previous_location_x = 0, previous_location_y = 0; -- unsigned short int text_size_factor; -- unsigned short int passflag = 0; -+ unsigned int text_size_factor; -+ unsigned int passflag = 0; - long int *rolling_average_data = NULL; - long int rolling_average_limit, required_frame_time, frame_delay, delay_time_nsec; - int rolling_frame = 0; - struct timeval tv1, tv2; - unsigned long int rolling_average, elapsedtime; - unsigned long long int timenow = 0, timebefore = 0; -- /* Return code used when calling vid_next */ -- int vid_return_code = 0; -- /* time in seconds to skip between capturing images */ -- int minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; -- /* Flag used to signal that we capture new image when we run the loop */ -- unsigned short int get_image = 1; -+ int vid_return_code = 0; /* Return code used when calling vid_next */ -+ int minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; /* time in seconds to skip between capturing images */ -+ unsigned int get_image = 1; /* Flag used to signal that we capture new image when we run the loop */ -+ struct image_data *old_image; - -- /* Next two variables are used for snapshot and timelapse feature -- * time_last_frame is set to 1 so that first coming timelapse or second=0 -+ /* -+ * Next two variables are used for snapshot and timelapse feature -+ * time_last_frame is set to 1 so that first coming timelapse or second = 0 - * is acted upon. - */ -- unsigned long int time_last_frame=1, time_current_frame; -+ unsigned long int time_last_frame = 1, time_current_frame; - - cnt->running = 1; - -@@ -967,6 +1159,10 @@ static void *motion_loop(void *arg) - for (j = 0; j < rolling_average_limit; j++) - rolling_average_data[j] = required_frame_time; - -+ -+ if (cnt->track.type) -+ cnt->moved = track_center(cnt, cnt->video_dev, 0, 0, 0); -+ - #ifdef __OpenBSD__ - /* - * FIXMARK -@@ -977,8 +1173,10 @@ static void *motion_loop(void *arg) - setup_signals(&sig_handler_action, &sigchild_action); - #endif - -- /* MAIN MOTION LOOP BEGINS HERE */ -- /* Should go on forever... unless you bought vaporware :) */ -+ /* -+ * MAIN MOTION LOOP BEGINS HERE -+ * Should go on forever... unless you bought vaporware :) -+ */ - - while (!cnt->finish || cnt->makemovie) { - -@@ -990,34 +1188,49 @@ static void *motion_loop(void *arg) - gettimeofday(&tv1, NULL); - timenow = tv1.tv_usec + 1000000L * tv1.tv_sec; - -- /* since we don't have sanity checks done when options are set, -+ /* -+ * Calculate detection rate limit. Above 5fps we limit the detection -+ * rate to 3fps to reduce load at higher framerates. -+ */ -+ cnt->process_thisframe = 0; -+ rate_limit++; -+ if (rate_limit >= (cnt->lastrate / 3)) { -+ rate_limit = 0; -+ cnt->process_thisframe = 1; -+ } -+ -+ /* -+ * Since we don't have sanity checks done when options are set, - * this sanity check must go in the main loop :(, before pre_captures -- * are attempted. */ -+ * are attempted. -+ */ - if (cnt->conf.minimum_motion_frames < 1) - cnt->conf.minimum_motion_frames = 1; -- -+ - if (cnt->conf.pre_capture < 0) - cnt->conf.pre_capture = 0; - -- /* Check if our buffer is still the right size -+ /* -+ * Check if our buffer is still the right size - * If pre_capture or minimum_motion_frames has been changed - * via the http remote control we need to re-size the ring buffer - */ - frame_buffer_size = cnt->conf.pre_capture + cnt->conf.minimum_motion_frames; -- -+ - if (cnt->imgs.image_ring_size != frame_buffer_size) - image_ring_resize(cnt, frame_buffer_size); - -- - /* Get time for current frame */ - cnt->currenttime = time(NULL); - -- /* localtime returns static data and is not threadsafe -+ /* -+ * localtime returns static data and is not threadsafe - * so we use localtime_r which is reentrant and threadsafe - */ - localtime_r(&cnt->currenttime, cnt->currenttime_tm); - -- /* If we have started on a new second we reset the shots variable -+ /* -+ * If we have started on a new second we reset the shots variable - * lastrate is updated to be the number of the last frame. last rate - * is used as the ffmpeg framerate when motion is detected. - */ -@@ -1025,6 +1238,7 @@ static void *motion_loop(void *arg) - cnt->lastrate = cnt->shots + 1; - cnt->shots = -1; - lastframetime = cnt->currenttime; -+ - if (cnt->conf.minimum_frame_time) { - minimum_frame_time_downcounter--; - if (minimum_frame_time_downcounter == 0) -@@ -1041,7 +1255,7 @@ static void *motion_loop(void *arg) - if (cnt->startup_frames > 0) - cnt->startup_frames--; - -- if (get_image){ -+ if (get_image) { - if (cnt->conf.minimum_frame_time) { - minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; - get_image = 0; -@@ -1058,17 +1272,11 @@ static void *motion_loop(void *arg) - } - - /* cnt->current_image points to position in ring where to store image, diffs etc. */ -+ old_image = cnt->current_image; - cnt->current_image = &cnt->imgs.image_ring[cnt->imgs.image_ring_in]; - - /* Init/clear current_image */ -- { -- /* Store time with pre_captured image */ -- cnt->current_image->timestamp = cnt->currenttime; -- localtime_r(&cnt->current_image->timestamp, &cnt->current_image->timestamp_tm); -- -- /* Store shot number with pre_captured image */ -- cnt->current_image->shot = cnt->shots; -- -+ if (cnt->process_thisframe) { - /* set diffs to 0 now, will be written after we calculated diffs in new image */ - cnt->current_image->diffs = 0; - -@@ -1079,31 +1287,52 @@ static void *motion_loop(void *arg) - /* Clear location data */ - memset(&cnt->current_image->location, 0, sizeof(cnt->current_image->location)); - cnt->current_image->total_labels = 0; -- } -+ } else if (cnt->current_image && old_image) { -+ /* not processing this frame: save some important values for next image */ -+ cnt->current_image->diffs = old_image->diffs; -+ cnt->current_image->timestamp = old_image->timestamp; -+ cnt->current_image->timestamp_tm = old_image->timestamp_tm; -+ cnt->current_image->shot = old_image->shot; -+ cnt->current_image->cent_dist = old_image->cent_dist; -+ cnt->current_image->flags = old_image->flags & (~IMAGE_SAVED); -+ cnt->current_image->location = old_image->location; -+ cnt->current_image->total_labels = old_image->total_labels; -+ } -+ -+ /* Store time with pre_captured image */ -+ cnt->current_image->timestamp = cnt->currenttime; -+ localtime_r(&cnt->current_image->timestamp, &cnt->current_image->timestamp_tm); -+ -+ /* Store shot number with pre_captured image */ -+ cnt->current_image->shot = cnt->shots; - - /***** MOTION LOOP - RETRY INITIALIZING SECTION *****/ -- /* If a camera is not available we keep on retrying every 10 seconds -+ /* -+ * If a camera is not available we keep on retrying every 10 seconds - * until it shows up. - */ - if (cnt->video_dev < 0 && - cnt->currenttime % 10 == 0 && cnt->shots == 0) { -- motion_log(LOG_ERR, 0, -- "Retrying until successful connection with camera"); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, -+ "%s: Retrying until successful connection with camera"); - cnt->video_dev = vid_start(cnt); - -- /* if the netcam has different dimensions than in the config file -+ /* -+ * If the netcam has different dimensions than in the config file - * we need to restart Motion to re-allocate all the buffers - */ - if (cnt->imgs.width != cnt->conf.width || cnt->imgs.height != cnt->conf.height) { -- motion_log(LOG_ERR, 0, "Camera has finally become available"); -- motion_log(LOG_ERR, 0, "Camera image has different width and height " -- "from what is in the config file. You should fix that"); -- motion_log(LOG_ERR, 0, "Restarting Motion thread to reinitialize all " -- "image buffers to new picture dimensions"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Camera has finally become available\n" -+ "Camera image has different width and height" -+ "from what is in the config file. You should fix that\n" -+ "Restarting Motion thread to reinitialize all " -+ "image buffers to new picture dimensions"); - cnt->conf.width = cnt->imgs.width; - cnt->conf.height = cnt->imgs.height; -- /* Break out of main loop terminating thread -- * watchdog will start us again */ -+ /* -+ * Break out of main loop terminating thread -+ * watchdog will start us again -+ */ - break; - } - } -@@ -1111,7 +1340,8 @@ static void *motion_loop(void *arg) - - /***** MOTION LOOP - IMAGE CAPTURE SECTION *****/ - -- /* Fetch next frame from camera -+ /* -+ * Fetch next frame from camera - * If vid_next returns 0 all is well and we got a new picture - * Any non zero value is an error. - * 0 = OK, valid picture -@@ -1129,27 +1359,27 @@ static void *motion_loop(void *arg) - cnt->connectionlosttime = 0; - - /* If all is well reset missing_frame_counter */ -- if (cnt->missing_frame_counter >= MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) -+ if (cnt->missing_frame_counter >= MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) { - /* If we previously logged starting a grey image, now log video re-start */ -- motion_log(LOG_ERR, 0, "Video signal re-acquired"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Video signal re-acquired"); - // event for re-acquired video signal can be called here -- -- -+ } - cnt->missing_frame_counter = 0; - - #ifdef HAVE_FFMPEG - /* Deinterlace the image with ffmpeg, before the image is modified. */ - if (cnt->conf.ffmpeg_deinterlace) - ffmpeg_deinterlace(cnt->current_image->image, cnt->imgs.width, cnt->imgs.height); -- - #endif - -- /* save the newly captured still virgin image to a buffer -+ /* -+ * Save the newly captured still virgin image to a buffer - * which we will not alter with text and location graphics - */ - memcpy(cnt->imgs.image_virgin, cnt->current_image->image, cnt->imgs.size); - -- /* If the camera is a netcam we let the camera decide the pace. -+ /* -+ * If the camera is a netcam we let the camera decide the pace. - * Otherwise we will keep on adding duplicate frames. - * By resetting the timer the framerate becomes maximum the rate - * of the Netcam. -@@ -1161,9 +1391,10 @@ static void *motion_loop(void *arg) - // FATAL ERROR - leave the thread by breaking out of the main loop - } else if (vid_return_code < 0) { - /* Fatal error - Close video device */ -- motion_log(LOG_ERR, 0, "Video device fatal error - Closing video device"); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video device fatal error - Closing video device"); - vid_close(cnt); -- /* Use virgin image, if we are not able to open it again next loop -+ /* -+ * Use virgin image, if we are not able to open it again next loop - * a gray image with message is applied - * flag lost_connection - */ -@@ -1178,37 +1409,44 @@ static void *motion_loop(void *arg) - */ - } else { - -- if (debug_level >= CAMERA_VERBOSE) -- motion_log(-1, 0, "vid_return_code %d", vid_return_code); -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: vid_return_code %d", -+ vid_return_code); - -- /* Netcams that change dimensions while Motion is running will -+ /* -+ * Netcams that change dimensions while Motion is running will - * require that Motion restarts to reinitialize all the many - * buffers inside Motion. It will be a mess to try and recover any - * other way - */ - if (vid_return_code == NETCAM_RESTART_ERROR) { -- motion_log(LOG_ERR, 0, "Restarting Motion thread to reinitialize all " -- "image buffers"); -- /* Break out of main loop terminating thread -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Restarting Motion thread to reinitialize all " -+ "image buffers"); -+ /* -+ * Break out of main loop terminating thread - * watchdog will start us again -- * Set lost_connection flag on */ -+ * Set lost_connection flag on -+ */ - - cnt->lost_connection = 1; - break; - } - -- /* First missed frame - store timestamp -- * Don't reset time when thread restarts*/ -+ /* -+ * First missed frame - store timestamp -+ * Don't reset time when thread restarts -+ */ - if (cnt->connectionlosttime == 0) - cnt->connectionlosttime = cnt->currenttime; - -- /* Increase missing_frame_counter -+ /* -+ * Increase missing_frame_counter - * The first MISSING_FRAMES_TIMEOUT seconds we copy previous virgin image - * After MISSING_FRAMES_TIMEOUT seconds we put a grey error image in the buffer - * If we still have not yet received the initial image from a camera - * we go straight for the grey error image. - */ - ++cnt->missing_frame_counter; -+ - if (cnt->video_dev >= 0 && - cnt->missing_frame_counter < (MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit)) { - memcpy(cnt->current_image->image, cnt->imgs.image_virgin, cnt->imgs.size); -@@ -1231,17 +1469,20 @@ static void *motion_loop(void *arg) - - /* Write error message only once */ - if (cnt->missing_frame_counter == MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) { -- motion_log(LOG_ERR, 0, "Video signal lost - Adding grey image"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Video signal lost - Adding grey image"); - // Event for lost video signal can be called from here - event(cnt, EVENT_CAMERA_LOST, NULL, NULL, - NULL, cnt->currenttime_tm); - } - -- /* If we don't get a valid frame for a long time, try to close/reopen device -- * Only try this when a device is open */ -+ /* -+ * If we don't get a valid frame for a long time, try to close/reopen device -+ * Only try this when a device is open -+ */ - if ((cnt->video_dev > 0) && - (cnt->missing_frame_counter == (MISSING_FRAMES_TIMEOUT * 4) * cnt->conf.frame_limit)) { -- motion_log(LOG_ERR, 0, "Video signal still lost - Trying to close video device"); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video signal still lost - " -+ "Trying to close video device"); - vid_close(cnt); - } - } -@@ -1249,95 +1490,99 @@ static void *motion_loop(void *arg) - - /***** MOTION LOOP - MOTION DETECTION SECTION *****/ - -- /* The actual motion detection takes place in the following -+ /* -+ * The actual motion detection takes place in the following - * diffs is the number of pixels detected as changed - * Make a differences picture in image_out - * - * alg_diff_standard is the slower full feature motion detection algorithm - * alg_diff first calls a fast detection algorithm which only looks at a -- * fraction of the pixels. If this detects possible motion alg_diff_standard -- * is called. -+ * fraction of the pixels. If this detects possible motion alg_diff_standard -+ * is called. - */ -- if (cnt->threshold && !cnt->pause) { -- /* if we've already detected motion and we want to see if there's -- * still motion, don't bother trying the fast one first. IF there's -- * motion, the alg_diff will trigger alg_diff_standard -- * anyway -- */ -- if (cnt->detecting_motion || cnt->conf.setup_mode) -- cnt->current_image->diffs = alg_diff_standard(cnt, cnt->imgs.image_virgin); -- else -- cnt->current_image->diffs = alg_diff(cnt, cnt->imgs.image_virgin); -+ if (cnt->process_thisframe) { -+ if (cnt->threshold && !cnt->pause) { -+ /* -+ * If we've already detected motion and we want to see if there's -+ * still motion, don't bother trying the fast one first. IF there's -+ * motion, the alg_diff will trigger alg_diff_standard -+ * anyway -+ */ -+ if (cnt->detecting_motion || cnt->conf.setup_mode) -+ cnt->current_image->diffs = alg_diff_standard(cnt, cnt->imgs.image_virgin); -+ else -+ cnt->current_image->diffs = alg_diff(cnt, cnt->imgs.image_virgin); - -- /* Lightswitch feature - has light intensity changed? -- * This can happen due to change of light conditions or due to a sudden change of the camera -- * sensitivity. If alg_lightswitch detects lightswitch we suspend motion detection the next -- * 5 frames to allow the camera to settle. -- * Don't check if we have lost connection, we detect "Lost signal" frame as lightswitch -- */ -- if (cnt->conf.lightswitch && !cnt->lost_connection) { -- if (alg_lightswitch(cnt, cnt->current_image->diffs)) { -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Lightswitch detected"); -+ /* Lightswitch feature - has light intensity changed? -+ * This can happen due to change of light conditions or due to a sudden change of the camera -+ * sensitivity. If alg_lightswitch detects lightswitch we suspend motion detection the next -+ * 5 frames to allow the camera to settle. -+ * Don't check if we have lost connection, we detect "Lost signal" frame as lightswitch -+ */ -+ if (cnt->conf.lightswitch > 1 && !cnt->lost_connection) { -+ if (alg_lightswitch(cnt, cnt->current_image->diffs)) { -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Lightswitch detected"); - -- if (cnt->moved < 5) -- cnt->moved = 5; -+ if (cnt->moved < 5) -+ cnt->moved = 5; - -- cnt->current_image->diffs = 0; -- alg_update_reference_frame(cnt, RESET_REF_FRAME); -+ cnt->current_image->diffs = 0; -+ alg_update_reference_frame(cnt, RESET_REF_FRAME); -+ } - } -- } - -- /* Switchfilter feature tries to detect a change in the video signal -- * from one camera to the next. This is normally used in the Round -- * Robin feature. The algorithm is not very safe. -- * The algorithm takes a little time so we only call it when needed -- * ie. when feature is enabled and diffs>threshold. -- * We do not suspend motion detection like we did for lightswitch -- * because with Round Robin this is controlled by roundrobin_skip. -- */ -- if (cnt->conf.switchfilter && cnt->current_image->diffs > cnt->threshold) { -- cnt->current_image->diffs = alg_switchfilter(cnt, cnt->current_image->diffs, -- cnt->current_image->image); -+ /* -+ * Switchfilter feature tries to detect a change in the video signal -+ * from one camera to the next. This is normally used in the Round -+ * Robin feature. The algorithm is not very safe. -+ * The algorithm takes a little time so we only call it when needed -+ * ie. when feature is enabled and diffs>threshold. -+ * We do not suspend motion detection like we did for lightswitch -+ * because with Round Robin this is controlled by roundrobin_skip. -+ */ -+ if (cnt->conf.switchfilter && cnt->current_image->diffs > cnt->threshold) { -+ cnt->current_image->diffs = alg_switchfilter(cnt, cnt->current_image->diffs, -+ cnt->current_image->image); - -- if (cnt->current_image->diffs <= cnt->threshold) { -- cnt->current_image->diffs = 0; -- -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Switchfilter detected"); -+ if (cnt->current_image->diffs <= cnt->threshold) { -+ cnt->current_image->diffs = 0; -+ -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Switchfilter detected"); -+ } - } -- } - -- /* Despeckle feature -- * First we run (as given by the despeckle option iterations -- * of erode and dilate algorithms. -- * Finally we run the labelling feature. -- * All this is done in the alg_despeckle code. -- */ -- cnt->current_image->total_labels = 0; -- cnt->imgs.largest_label = 0; -- olddiffs = 0; -- -- if (cnt->conf.despeckle && cnt->current_image->diffs > 0) { -- olddiffs = cnt->current_image->diffs; -- cnt->current_image->diffs = alg_despeckle(cnt, olddiffs); -- } else if (cnt->imgs.labelsize_max) { -- cnt->imgs.labelsize_max = 0; /* Disable labeling if enabled */ -- } -+ /* -+ * Despeckle feature -+ * First we run (as given by the despeckle_filter option iterations -+ * of erode and dilate algorithms. -+ * Finally we run the labelling feature. -+ * All this is done in the alg_despeckle code. -+ */ -+ cnt->current_image->total_labels = 0; -+ cnt->imgs.largest_label = 0; -+ olddiffs = 0; -+ -+ if (cnt->conf.despeckle_filter && cnt->current_image->diffs > 0) { -+ olddiffs = cnt->current_image->diffs; -+ cnt->current_image->diffs = alg_despeckle(cnt, olddiffs); -+ } else if (cnt->imgs.labelsize_max) { -+ cnt->imgs.labelsize_max = 0; /* Disable labeling if enabled */ -+ } - -- } else if (!cnt->conf.setup_mode) { -- cnt->current_image->diffs = 0; -+ } else if (!cnt->conf.setup_mode) { -+ cnt->current_image->diffs = 0; -+ } - } - - /* Manipulate smart_mask sensitivity (only every smartmask_ratio seconds) */ -- if (cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) { -- if (!--smartmask_count) { -- alg_tune_smartmask(cnt); -- smartmask_count = smartmask_ratio; -- } -+ if ((cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) && -+ (!--smartmask_count)) { -+ alg_tune_smartmask(cnt); -+ smartmask_count = smartmask_ratio; - } - -- /* cnt->moved is set by the tracking code when camera has been asked to move. -+ /* -+ * cnt->moved is set by the tracking code when camera has been asked to move. - * When camera is moving we do not want motion to detect motion or we will - * get our camera chasing itself like crazy and we will get motion detected - * which is not really motion. So we pretend there is no motion by setting -@@ -1352,57 +1597,61 @@ static void *motion_loop(void *arg) - - /***** MOTION LOOP - TUNING SECTION *****/ - -- /* if noise tuning was selected, do it now. but only when -+ /* -+ * If noise tuning was selected, do it now. but only when - * no frames have been recorded and only once per second - */ -- if (cnt->conf.noise_tune && cnt->shots == 0) { -- if (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold)) -- alg_noise_tune(cnt, cnt->imgs.image_virgin); -- } -+ if ((cnt->conf.noise_tune && cnt->shots == 0) && -+ (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold))) -+ alg_noise_tune(cnt, cnt->imgs.image_virgin); -+ - -- /* if we are not noise tuning lets make sure that remote controlled -+ /* -+ * If we are not noise tuning lets make sure that remote controlled - * changes of noise_level are used. - */ -- if (!cnt->conf.noise_tune) -- cnt->noise = cnt->conf.noise; -+ if (cnt->process_thisframe) { -+ if (!cnt->conf.noise_tune) -+ cnt->noise = cnt->conf.noise; -+ -+ /* -+ * threshold tuning if enabled -+ * if we are not threshold tuning lets make sure that remote controlled -+ * changes of threshold are used. -+ */ -+ if (cnt->conf.threshold_tune) -+ alg_threshold_tune(cnt, cnt->current_image->diffs, cnt->detecting_motion); -+ else -+ cnt->threshold = cnt->conf.max_changes; - -- /* threshold tuning if enabled -- * if we are not threshold tuning lets make sure that remote controlled -- * changes of threshold are used. -- */ -- if (cnt->conf.threshold_tune) -- alg_threshold_tune(cnt, cnt->current_image->diffs, cnt->detecting_motion); -- else -- cnt->threshold = cnt->conf.max_changes; -+ /* -+ * If motion is detected (cnt->current_image->diffs > cnt->threshold) and before we add text to the pictures -+ * we find the center and size coordinates of the motion to be used for text overlays and later -+ * for adding the locate rectangle -+ */ -+ if (cnt->current_image->diffs > cnt->threshold) -+ alg_locate_center_size(&cnt->imgs, cnt->imgs.width, cnt->imgs.height, &cnt->current_image->location); - -- /* If motion is detected (cnt->current_image->diffs > cnt->threshold) and before we add text to the pictures -- we find the center and size coordinates of the motion to be used for text overlays and later -- for adding the locate rectangle */ -- if (cnt->current_image->diffs > cnt->threshold) -- alg_locate_center_size(&cnt->imgs, cnt->imgs.width, cnt->imgs.height, -- &cnt->current_image->location); -- -- /* Update reference frame. */ -- /* micro-lighswitch: e.g. neighbors cat switched on the motion sensitive * -- * frontdoor illumination. Updates are rate-limited to 3 per second at * -- * framerates above 5fps to save CPU resources and to keep sensitivity * -- * at a constant level. * -- */ -- ref_frame_limit++; -- if (ref_frame_limit >= (cnt->lastrate / 3)) { -- ref_frame_limit = 0; -+ /* -+ * Update reference frame. -+ * micro-lighswitch: trying to auto-detect lightswitch events. -+ * frontdoor illumination. Updates are rate-limited to 3 per second at -+ * framerates above 5fps to save CPU resources and to keep sensitivity -+ * at a constant level. -+ */ - -- if ((cnt->current_image->diffs > cnt->threshold) && -- (cnt->lightswitch_framecounter < (cnt->lastrate * 2)) && /* two seconds window */ -+ if ((cnt->current_image->diffs > cnt->threshold) && (cnt->conf.lightswitch == 1) && -+ (cnt->lightswitch_framecounter < (cnt->lastrate * 2)) && /* two seconds window only */ -+ /* number of changed pixels almost the same in two consecutive frames and */ - ((abs(previous_diffs - cnt->current_image->diffs)) < (previous_diffs / 15)) && -+ /* center of motion in about the same place ? */ - ((abs(cnt->current_image->location.x - previous_location_x)) <= (cnt->imgs.width / 150)) && - ((abs(cnt->current_image->location.y - previous_location_y)) <= (cnt->imgs.height / 150))) { - alg_update_reference_frame(cnt, RESET_REF_FRAME); - cnt->current_image->diffs = 0; - cnt->lightswitch_framecounter = 0; -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "micro-lightswitch!"); - -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: micro-lightswitch!"); - } else { - alg_update_reference_frame(cnt, UPDATE_REF_FRAME); - } -@@ -1414,23 +1663,26 @@ static void *motion_loop(void *arg) - - /***** MOTION LOOP - TEXT AND GRAPHICS OVERLAY SECTION *****/ - -- /* Some overlays on top of the motion image -+ /* -+ * Some overlays on top of the motion image - * Note that these now modifies the cnt->imgs.out so this buffer - * can no longer be used for motion detection features until next - * picture frame is captured. - */ - - /* Smartmask overlay */ -- if (cnt->smartmask_speed && (cnt->conf.motion_img || cnt->conf.ffmpeg_cap_motion || cnt->conf.setup_mode)) -+ if (cnt->smartmask_speed && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || -+ cnt->conf.setup_mode)) - overlay_smartmask(cnt, cnt->imgs.out); - - /* Largest labels overlay */ -- if (cnt->imgs.largest_label && (cnt->conf.motion_img || cnt->conf.ffmpeg_cap_motion || cnt->conf.setup_mode)) -+ if (cnt->imgs.largest_label && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || -+ cnt->conf.setup_mode)) - overlay_largest_label(cnt, cnt->imgs.out); - -- - /* Fixed mask overlay */ -- if (cnt->imgs.mask && (cnt->conf.motion_img || cnt->conf.ffmpeg_cap_motion || cnt->conf.setup_mode)) -+ if (cnt->imgs.mask && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || -+ cnt->conf.setup_mode)) - overlay_fixed_mask(cnt, cnt->imgs.out); - - /* Initialize the double sized characters if needed. */ -@@ -1450,15 +1702,18 @@ static void *motion_loop(void *arg) - else - sprintf(tmp, "-"); - -- draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10, cnt->imgs.width, -- tmp, cnt->conf.text_double); -+ draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10, -+ cnt->imgs.width, tmp, cnt->conf.text_double); - } - -- /* Add changed pixels to motion-images (for webcam) in setup_mode -- and always overlay smartmask (not only when motion is detected) */ -+ /* -+ * Add changed pixels to motion-images (for stream) in setup_mode -+ * and always overlay smartmask (not only when motion is detected) -+ */ - if (cnt->conf.setup_mode) { - char tmp[PATH_MAX]; -- sprintf(tmp, "D:%5d L:%3d N:%3d", cnt->current_image->diffs, cnt->current_image->total_labels, cnt->noise); -+ sprintf(tmp, "D:%5d L:%3d N:%3d", cnt->current_image->diffs, -+ cnt->current_image->total_labels, cnt->noise); - draw_text(cnt->imgs.out, cnt->imgs.width - 10, cnt->imgs.height - 30 * text_size_factor, - cnt->imgs.width, tmp, cnt->conf.text_double); - sprintf(tmp, "THREAD %d SETUP", cnt->threadnr); -@@ -1469,16 +1724,19 @@ static void *motion_loop(void *arg) - /* Add text in lower left corner of the pictures */ - if (cnt->conf.text_left) { - char tmp[PATH_MAX]; -- mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left, &cnt->current_image->timestamp_tm, NULL, 0); -- draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 * text_size_factor, cnt->imgs.width, -- tmp, cnt->conf.text_double); -+ mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left, -+ &cnt->current_image->timestamp_tm, NULL, 0); -+ draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 * text_size_factor, -+ cnt->imgs.width, tmp, cnt->conf.text_double); - } - - /* Add text in lower right corner of the pictures */ - if (cnt->conf.text_right) { - char tmp[PATH_MAX]; -- mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right, &cnt->current_image->timestamp_tm, NULL, 0); -- draw_text(cnt->current_image->image, cnt->imgs.width - 10, cnt->imgs.height - 10 * text_size_factor, -+ mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right, -+ &cnt->current_image->timestamp_tm, NULL, 0); -+ draw_text(cnt->current_image->image, cnt->imgs.width - 10, -+ cnt->imgs.height - 10 * text_size_factor, - cnt->imgs.width, tmp, cnt->conf.text_double); - } - -@@ -1489,24 +1747,36 @@ static void *motion_loop(void *arg) - /* flag this image, it have motion */ - cnt->current_image->flags |= IMAGE_MOTION; - cnt->lightswitch_framecounter++; /* micro lightswitch */ -- } else { -+ } else { - cnt->lightswitch_framecounter = 0; - } - -- /* If motion has been detected we take action and start saving -+ /* -+ * If motion has been detected we take action and start saving - * pictures and movies etc by calling motion_detected(). -- * Is output_all enabled we always call motion_detected() -+ * Is emulate_motion enabled we always call motion_detected() - * If post_capture is enabled we also take care of this in the this - * code section. - */ -- if (cnt->conf.output_all && (cnt->startup_frames == 0)) { -+ if (cnt->conf.emulate_motion && (cnt->startup_frames == 0)) { - cnt->detecting_motion = 1; -- /* Setup the postcap counter */ -- cnt->postcap = cnt->conf.post_capture; -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Emulating motion"); -+#ifdef HAVE_FFMPEG -+ if (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe)) { -+#else -+ if (cnt->conf.useextpipe && cnt->extpipe) { -+#endif -+ /* Setup the postcap counter */ -+ cnt->postcap = cnt->conf.post_capture; -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: (Em) Init post capture %d", -+ 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)) { -- /* Did we detect motion (like the cat just walked in :) )? -+ /* -+ * Did we detect motion (like the cat just walked in :) )? - * If so, ensure the motion is sustained if minimum_motion_frames - */ - -@@ -1514,7 +1784,8 @@ static void *motion_loop(void *arg) - int frame_count = 0; - int pos = cnt->imgs.image_ring_in; - -- for(i = 0; i < cnt->conf.minimum_motion_frames; i++) { -+ for (i = 0; i < cnt->conf.minimum_motion_frames; i++) { -+ - if (cnt->imgs.image_ring[pos].flags & IMAGE_MOTION) - frame_count++; - -@@ -1522,34 +1793,56 @@ static void *motion_loop(void *arg) - pos = cnt->imgs.image_ring_size-1; - else - pos--; -- - } - - 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; -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Setup post capture %d", -+ cnt->postcap); -+ - /* Mark all images in image_ring to be saved */ -- for(i = 0; i < cnt->imgs.image_ring_size; i++) -+ 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) && -+#ifdef HAVE_FFMPEG -+ (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { -+#else -+ (cnt->conf.useextpipe && cnt->extpipe)) { -+#endif -+ /* we have motion in this frame, but not enought frames for trigger. Check postcap */ - cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); - cnt->postcap--; -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", -+ 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) && -+#ifdef HAVE_FFMPEG -+ (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { -+#else -+ (cnt->conf.useextpipe && cnt->extpipe)) { -+#endif - /* No motion, doing postcap */ - cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); - cnt->postcap--; -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", -+ cnt->postcap); - } else { - /* Done with postcap, so just have the image in the precap buffer */ - cnt->current_image->flags |= IMAGE_PRECAP; -+ /* gapless movie feature */ -+ if ((cnt->conf.event_gap == 0) && (cnt->detecting_motion == 1)) -+ cnt->makemovie = 1; - cnt->detecting_motion = 0; - } - -@@ -1558,16 +1851,16 @@ static void *motion_loop(void *arg) - cnt->lasttime = cnt->current_image->timestamp; - - -- /* Simple hack to recognize motion in a specific area */ -- /* Do we need a new coversion specifier as well?? */ -+ /* -+ * Simple hack to recognize motion in a specific area -+ * Do we need a new coversion specifier as well?? -+ */ - if ((cnt->conf.area_detect) && (cnt->event_nr != area_once) && - (cnt->current_image->flags & IMAGE_TRIGGER)) { -- - j = strlen(cnt->conf.area_detect); -- -+ - for (i = 0; i < j; i++) { - z = cnt->conf.area_detect[i] - 49; /* 1 becomes 0 */ -- - if ((z >= 0) && (z < 9)) { - if (cnt->current_image->location.x > area_minx[z] && - cnt->current_image->location.x < area_maxx[z] && -@@ -1576,27 +1869,29 @@ static void *motion_loop(void *arg) - event(cnt, EVENT_AREA_DETECTED, NULL, NULL, - NULL, cnt->currenttime_tm); - area_once = cnt->event_nr; /* Fire script only once per event */ -- -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Motion in area %d detected.\n", z+1); - -+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Motion in area %d detected.", -+ z + 1); - break; - } - } - } - } - -- /* Is the mpeg movie to long? Then make movies -- * First test for max mpegtime -- */ -- if (cnt->conf.maxmpegtime && cnt->event_nr == cnt->prev_event) -- if (cnt->currenttime - cnt->eventtime >= cnt->conf.maxmpegtime) -- cnt->makemovie = 1; -+ /* -+ * Is the movie too long? Then make movies -+ * First test for max_movie_time -+ */ -+ if ((cnt->conf.max_movie_time && cnt->event_nr == cnt->prev_event) && -+ (cnt->currenttime - cnt->eventtime >= cnt->conf.max_movie_time)) -+ cnt->makemovie = 1; - -- /* Now test for quiet longer than 'gap' OR make movie as decided in -+ /* -+ * Now test for quiet longer than 'gap' OR make movie as decided in - * previous statement. - */ -- if (((cnt->currenttime - cnt->lasttime >= cnt->conf.gap) && cnt->conf.gap > 0) || cnt->makemovie) { -+ if (((cnt->currenttime - cnt->lasttime >= cnt->conf.event_gap) && cnt->conf.event_gap > 0) || -+ cnt->makemovie) { - if (cnt->event_nr == cnt->prev_event || cnt->makemovie) { - - /* Flush image buffer */ -@@ -1610,14 +1905,15 @@ static void *motion_loop(void *arg) - - event(cnt, EVENT_ENDMOTION, NULL, NULL, NULL, cnt->currenttime_tm); - -- /* if tracking is enabled we center our camera so it does not -+ /* -+ * If tracking is enabled we center our camera so it does not - * point to a place where it will miss the next action - */ - if (cnt->track.type) - cnt->moved = track_center(cnt, cnt->video_dev, 0, 0, 0); - -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "End of event %d", cnt->event_nr); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: End of event %d", -+ cnt->event_nr); - - cnt->makemovie = 0; - /* Reset post capture */ -@@ -1627,7 +1923,8 @@ static void *motion_loop(void *arg) - cnt->event_nr++; - cnt->lightswitch_framecounter = 0; - -- /* And we unset the text_event_string to avoid that buffered -+ /* -+ * And we unset the text_event_string to avoid that buffered - * images get a timestamp from previous event. - */ - cnt->text_event_string[0] = '\0'; -@@ -1639,17 +1936,16 @@ static void *motion_loop(void *arg) - - /***** MOTION LOOP - SETUP MODE CONSOLE OUTPUT SECTION *****/ - -- /* If setup_mode enabled output some numbers to console */ -+ /* If CAMERA_VERBOSE enabled output some numbers to console */ - if (cnt->conf.setup_mode) { - char msg[1024] = "\0"; - char part[100]; - -- if (cnt->conf.despeckle) { -+ if (cnt->conf.despeckle_filter) { - snprintf(part, 99, "Raw changes: %5d - changes after '%s': %5d", -- olddiffs, cnt->conf.despeckle, cnt->current_image->diffs); -+ olddiffs, cnt->conf.despeckle_filter, cnt->current_image->diffs); - strcat(msg, part); -- -- if (strchr(cnt->conf.despeckle, 'l')){ -+ if (strchr(cnt->conf.despeckle_filter, 'l')) { - sprintf(part, " - labels: %3d", cnt->current_image->total_labels); - strcat(msg, part); - } -@@ -1668,14 +1964,15 @@ static void *motion_loop(void *arg) - strcat(msg, part); - } - -- motion_log(-1, 0, "%s", msg); -+ MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: %s", msg); - } - - } /* get_image end */ - - /***** MOTION LOOP - SNAPSHOT FEATURE SECTION *****/ - -- /* Did we get triggered to make a snapshot from control http? Then shoot a snap -+ /* -+ * Did we get triggered to make a snapshot from control http? Then shoot a snap - * If snapshot_interval is not zero and time since epoch MOD snapshot_interval = 0 then snap - * We actually allow the time to run over the interval in case we have a delay - * from slow camera. -@@ -1687,10 +1984,9 @@ static void *motion_loop(void *arg) - time_current_frame = cnt->currenttime; - - if ((cnt->conf.snapshot_interval > 0 && cnt->shots == 0 && -- time_current_frame % cnt->conf.snapshot_interval <= time_last_frame % cnt->conf.snapshot_interval) || -- cnt->snapshot) { -- event(cnt, EVENT_IMAGE_SNAPSHOT, cnt->current_image->image, NULL, NULL, -- &cnt->current_image->timestamp_tm); -+ time_current_frame % cnt->conf.snapshot_interval <= time_last_frame % cnt->conf.snapshot_interval) || -+ cnt->snapshot) { -+ event(cnt, EVENT_IMAGE_SNAPSHOT, cnt->current_image->image, NULL, NULL, &cnt->current_image->timestamp_tm); - cnt->snapshot = 0; - } - -@@ -1699,11 +1995,10 @@ static void *motion_loop(void *arg) - - #ifdef HAVE_FFMPEG - -- -- - if (cnt->conf.timelapse) { - -- /* Check to see if we should start a new timelapse file. We start one when -+ /* -+ * Check to see if we should start a new timelapse file. We start one when - * we are on the first shot, and and the seconds are zero. We must use the seconds - * to prevent the timelapse file from getting reset multiple times during the minute. - */ -@@ -1711,53 +2006,56 @@ static void *motion_loop(void *arg) - (time_current_frame % 60 < time_last_frame % 60) && - cnt->shots == 0) { - -- if (strcasecmp(cnt->conf.timelapse_mode,"manual") == 0) { -+ if (strcasecmp(cnt->conf.timelapse_mode, "manual") == 0) { - ;/* No action */ - - /* If we are daily, raise timelapseend event at midnight */ - } else if (strcasecmp(cnt->conf.timelapse_mode, "daily") == 0) { - if (cnt->current_image->timestamp_tm.tm_hour == 0) -- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, -- &cnt->current_image->timestamp_tm); -+ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); - - /* handle the hourly case */ - } else if (strcasecmp(cnt->conf.timelapse_mode, "hourly") == 0) { -- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, -- &cnt->current_image->timestamp_tm); -- -- /* If we are weekly-sunday, raise timelapseend event at midnight on sunday */ -+ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); -+ -+ /* If we are weekly-sunday, raise timelapseend event at midnight on sunday */ - } else if (strcasecmp(cnt->conf.timelapse_mode, "weekly-sunday") == 0) { -- if (cnt->current_image->timestamp_tm.tm_wday == 0 && cnt->current_image->timestamp_tm.tm_hour == 0) -- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); -- -+ if (cnt->current_image->timestamp_tm.tm_wday == 0 && -+ cnt->current_image->timestamp_tm.tm_hour == 0) -+ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, -+ &cnt->current_image->timestamp_tm); - /* If we are weekly-monday, raise timelapseend event at midnight on monday */ - } else if (strcasecmp(cnt->conf.timelapse_mode, "weekly-monday") == 0) { -- if (cnt->current_image->timestamp_tm.tm_wday == 1 && cnt->current_image->timestamp_tm.tm_hour == 0) -- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); -- -+ if (cnt->current_image->timestamp_tm.tm_wday == 1 && -+ cnt->current_image->timestamp_tm.tm_hour == 0) -+ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, -+ &cnt->current_image->timestamp_tm); - /* If we are monthly, raise timelapseend event at midnight on first day of month */ - } else if (strcasecmp(cnt->conf.timelapse_mode, "monthly") == 0) { -- if (cnt->current_image->timestamp_tm.tm_mday == 1 && cnt->current_image->timestamp_tm.tm_hour == 0) -- event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); -- -+ if (cnt->current_image->timestamp_tm.tm_mday == 1 && -+ cnt->current_image->timestamp_tm.tm_hour == 0) -+ event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, -+ &cnt->current_image->timestamp_tm); - /* If invalid we report in syslog once and continue in manual mode */ - } else { -- motion_log(LOG_ERR, 0, "Invalid timelapse_mode argument '%s'", -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Invalid timelapse_mode argument '%s'", - cnt->conf.timelapse_mode); -- motion_log(LOG_ERR, 0, "Defaulting to manual timelapse mode"); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%:s Defaulting to manual timelapse mode"); - conf_cmdparse(&cnt, (char *)"ffmpeg_timelapse_mode",(char *)"manual"); - } - } - -- /* If ffmpeg timelapse is enabled and time since epoch MOD ffmpeg_timelaps = 0 -- * add a timelapse frame to the timelapse mpeg. -+ /* -+ * If ffmpeg timelapse is enabled and time since epoch MOD ffmpeg_timelaps = 0 -+ * add a timelapse frame to the timelapse movie. - */ -- if (cnt->shots == 0 && -- time_current_frame % cnt->conf.timelapse <= time_last_frame % cnt->conf.timelapse) -+ if (cnt->shots == 0 && time_current_frame % cnt->conf.timelapse <= -+ time_last_frame % cnt->conf.timelapse) - event(cnt, EVENT_TIMELAPSE, cnt->current_image->image, NULL, NULL, - &cnt->current_image->timestamp_tm); - } else if (cnt->ffmpeg_timelapse) { -- /* if timelapse mpeg is in progress but conf.timelapse is zero then close timelapse file -+ /* -+ * If timelapse movie is in progress but conf.timelapse is zero then close timelapse file - * This is an important feature that allows manual roll-over of timelapse file using the http - * remote control via a cron job. - */ -@@ -1771,25 +2069,35 @@ static void *motion_loop(void *arg) - - /***** MOTION LOOP - VIDEO LOOPBACK SECTION *****/ - -- /* feed last image and motion image to video device pipes and the webcam clients -- * In setup mode we send the special setup mode image to both webcam and vloopback pipe -+ /* -+ * Feed last image and motion image to video device pipes and the stream clients -+ * In setup mode we send the special setup mode image to both stream and vloopback pipe - * In normal mode we feed the latest image to vloopback device and we send -- * the image to the webcam. We always send the first image in a second to the webcam. -- * Other image are sent only when the config option webcam_motion is off -- * The result is that with webcam_motion on the webcam stream is normally at the minimal -+ * the image to the stream. We always send the first image in a second to the stream. -+ * Other image are sent only when the config option stream_motion is off -+ * The result is that with stream_motion on the stream stream is normally at the minimal - * 1 frame per second but the minute motion is detected the motion_detected() function -- * sends all detected pictures to the webcam except the 1st per second which is already sent. -+ * sends all detected pictures to the stream except the 1st per second which is already sent. - */ - if (cnt->conf.setup_mode) { - event(cnt, EVENT_IMAGE, cnt->imgs.out, NULL, &cnt->pipe, cnt->currenttime_tm); -- event(cnt, EVENT_WEBCAM, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); -+ event(cnt, EVENT_STREAM, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); -+#ifdef HAVE_SDL -+ if (cnt_list[0]->conf.sdl_threadnr == cnt->threadnr) -+ event(cnt, EVENT_SDL_PUT, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); -+#endif - } else { -- event(cnt, EVENT_IMAGE, cnt->current_image->image, NULL, &cnt->pipe, -- &cnt->current_image->timestamp_tm); -+ event(cnt, EVENT_IMAGE, cnt->current_image->image, NULL, -+ &cnt->pipe, &cnt->current_image->timestamp_tm); - -- if (!cnt->conf.webcam_motion || cnt->shots == 1) -- event(cnt, EVENT_WEBCAM, cnt->current_image->image, NULL, NULL, -+ if (!cnt->conf.stream_motion || cnt->shots == 1) -+ event(cnt, EVENT_STREAM, cnt->current_image->image, NULL, NULL, -+ &cnt->current_image->timestamp_tm); -+#ifdef HAVE_SDL -+ if (cnt_list[0]->conf.sdl_threadnr == cnt->threadnr) -+ event(cnt, EVENT_SDL_PUT, cnt->current_image->image, NULL, NULL, - &cnt->current_image->timestamp_tm); -+#endif - } - - event(cnt, EVENT_IMAGEM, cnt->imgs.out, NULL, &cnt->mpipe, cnt->currenttime_tm); -@@ -1798,52 +2106,69 @@ static void *motion_loop(void *arg) - /***** MOTION LOOP - ONCE PER SECOND PARAMETER UPDATE SECTION *****/ - - /* Check for some config parameter changes but only every second */ -- if (cnt->shots == 0){ -- if (strcasecmp(cnt->conf.output_normal, "on") == 0) -+ if (cnt->shots == 0) { -+ if (strcasecmp(cnt->conf.output_pictures, "on") == 0) - cnt->new_img = NEWIMG_ON; -- else if (strcasecmp(cnt->conf.output_normal, "first") == 0) -+ else if (strcasecmp(cnt->conf.output_pictures, "first") == 0) - cnt->new_img = NEWIMG_FIRST; -- else if (strcasecmp(cnt->conf.output_normal, "best") == 0) -+ else if (strcasecmp(cnt->conf.output_pictures, "best") == 0) - cnt->new_img = NEWIMG_BEST; -- else if (strcasecmp(cnt->conf.output_normal, "center") == 0) -+ else if (strcasecmp(cnt->conf.output_pictures, "center") == 0) - cnt->new_img = NEWIMG_CENTER; - else - cnt->new_img = NEWIMG_OFF; - -- if (strcasecmp(cnt->conf.locate, "on") == 0) -- cnt->locate = LOCATE_ON; -- else if (strcasecmp(cnt->conf.locate, "preview") == 0) -- cnt->locate = LOCATE_PREVIEW; -+ if (strcasecmp(cnt->conf.locate_motion_mode, "on") == 0) -+ cnt->locate_motion_mode = LOCATE_ON; -+ else if (strcasecmp(cnt->conf.locate_motion_mode, "preview") == 0) -+ cnt->locate_motion_mode = LOCATE_PREVIEW; - else -- cnt->locate = LOCATE_OFF; -+ cnt->locate_motion_mode = LOCATE_OFF; -+ -+ if (strcasecmp(cnt->conf.locate_motion_style, "box") == 0) -+ cnt->locate_motion_style = LOCATE_BOX; -+ else if (strcasecmp(cnt->conf.locate_motion_style, "redbox") == 0) -+ cnt->locate_motion_style = LOCATE_REDBOX; -+ else if (strcasecmp(cnt->conf.locate_motion_style, "cross") == 0) -+ cnt->locate_motion_style = LOCATE_CROSS; -+ else if (strcasecmp(cnt->conf.locate_motion_style, "redcross") == 0) -+ cnt->locate_motion_style = LOCATE_REDCROSS; -+ else -+ cnt->locate_motion_style = LOCATE_BOX; - - /* Sanity check for smart_mask_speed, silly value disables smart mask */ - if (cnt->conf.smart_mask_speed < 0 || cnt->conf.smart_mask_speed > 10) - cnt->conf.smart_mask_speed = 0; - - /* Has someone changed smart_mask_speed or framerate? */ -- if (cnt->conf.smart_mask_speed != cnt->smartmask_speed || smartmask_lastrate != cnt->lastrate){ -- if (cnt->conf.smart_mask_speed == 0){ -+ if (cnt->conf.smart_mask_speed != cnt->smartmask_speed || -+ smartmask_lastrate != cnt->lastrate) { -+ if (cnt->conf.smart_mask_speed == 0) { - memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); - memset(cnt->imgs.smartmask_final, 255, cnt->imgs.motionsize); - } -+ - smartmask_lastrate = cnt->lastrate; - cnt->smartmask_speed = cnt->conf.smart_mask_speed; -- /* Decay delay - based on smart_mask_speed (framerate independent) -- This is always 5*smartmask_speed seconds */ -+ /* -+ * Decay delay - based on smart_mask_speed (framerate independent) -+ * This is always 5*smartmask_speed seconds -+ */ - smartmask_ratio = 5 * cnt->lastrate * (11 - cnt->smartmask_speed); - } - --#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) -- /* Set the sql mask file according to the SQL config options -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) -+ -+ /* -+ * Set the sql mask file according to the SQL config options - * We update it for every frame in case the config was updated - * via remote control. - */ - cnt->sql_mask = cnt->conf.sql_log_image * (FTYPE_IMAGE + FTYPE_IMAGE_MOTION) + - cnt->conf.sql_log_snapshot * FTYPE_IMAGE_SNAPSHOT + -- cnt->conf.sql_log_mpeg * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + -+ cnt->conf.sql_log_movie * (FTYPE_MPEG + FTYPE_MPEG_MOTION) + - cnt->conf.sql_log_timelapse * FTYPE_MPEG_TIMELAPSE; --#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) */ -+#endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ - - } - -@@ -1851,8 +2176,10 @@ static void *motion_loop(void *arg) - /***** MOTION LOOP - FRAMERATE TIMING AND SLEEPING SECTION *****/ - - -- /* Work out expected frame rate based on config setting which may -- have changed from http-control */ -+ /* -+ * Work out expected frame rate based on config setting which may -+ * have changed from http-control -+ */ - if (cnt->conf.frame_limit) - required_frame_time = 1000000L / cnt->conf.frame_limit; - else -@@ -1862,8 +2189,9 @@ static void *motion_loop(void *arg) - gettimeofday(&tv2, NULL); - elapsedtime = (tv2.tv_usec + 1000000L * tv2.tv_sec) - timenow; - -- /* Update history buffer but ignore first pass as timebefore -- variable will be inaccurate -+ /* -+ * Update history buffer but ignore first pass as timebefore -+ * variable will be inaccurate - */ - if (passflag) - rolling_average_data[rolling_frame] = timenow-timebefore; -@@ -1899,7 +2227,8 @@ static void *motion_loop(void *arg) - } - } - -- /* END OF MOTION MAIN LOOP -+ /* -+ * END OF MOTION MAIN LOOP - * If code continues here it is because the thread is exiting or restarting - */ - err: -@@ -1907,7 +2236,7 @@ err: - free(rolling_average_data); - - cnt->lost_connection = 1; -- motion_log(-1, 0, "Thread exiting"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread exiting"); - - motion_cleanup(cnt); - -@@ -1916,7 +2245,7 @@ err: - pthread_mutex_unlock(&global_lock); - - if (!cnt->restart) -- cnt->watchdog=WATCHDOG_OFF; -+ cnt->watchdog = WATCHDOG_OFF; - - cnt->running = 0; - cnt->finish = 0; -@@ -1956,33 +2285,38 @@ static void become_daemon(void) - - /* fork */ - if (fork()) { -- motion_log(-1, 0, "Motion going to daemon mode"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion going to daemon mode"); - exit(0); - } - -- /* Create the pid file if defined, if failed exit -+ /* -+ * Create the pid file if defined, if failed exit - * If we fail we report it. If we succeed we postpone the log entry till - * later when we have closed stdout. Otherwise Motion hangs in the terminal waiting - * for an enter. - */ - if (cnt_list[0]->conf.pid_file) { -- pidf = fopen(cnt_list[0]->conf.pid_file, "w+"); -+ pidf = myfopen(cnt_list[0]->conf.pid_file, "w+", 0); - -- if (pidf ) { -+ if (pidf) { - (void)fprintf(pidf, "%d\n", getpid()); -- fclose(pidf); -+ myfclose(pidf); - } else { -- motion_log(LOG_ERR, 1, "Exit motion, cannot create process id file (pid file) %s", -- cnt_list[0]->conf.pid_file); -+ MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Exit motion, cannot create process" -+ " id file (pid file) %s", cnt_list[0]->conf.pid_file); -+ if (ptr_logfile) -+ myfclose(ptr_logfile); - exit(0); - } - } - -- /* changing dir to root enables people to unmount a disk -- without having to stop Motion */ -- if (chdir("/")) { -- motion_log(LOG_ERR, 1, "Could not change directory"); -- } -+ /* -+ * Changing dir to root enables people to unmount a disk -+ * without having to stop Motion -+ */ -+ if (chdir("/")) -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not change directory"); -+ - - #if (defined(BSD)) - setpgrp(0, getpid()); -@@ -2013,8 +2347,8 @@ static void become_daemon(void) - } - - /* Now it is safe to add the PID creation to the logs */ -- if (pidf ) -- motion_log(LOG_INFO, 0, "Created process id file %s. Process ID is %d", -+ if (pidf) -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Created process id file %s. Process ID is %d", - cnt_list[0]->conf.pid_file, getpid()); - - sigaction(SIGTTOU, &sig_ign_action, NULL); -@@ -2037,7 +2371,8 @@ static void become_daemon(void) - */ - static void cntlist_create(int argc, char *argv[]) - { -- /* cnt_list is an array of pointers to the context structures cnt for each thread. -+ /* -+ * cnt_list is an array of pointers to the context structures cnt for each thread. - * First we reserve room for a pointer to thread 0's context structure - * and a NULL pointer which indicates that end of the array of pointers to - * thread context structures. -@@ -2053,7 +2388,8 @@ static void cntlist_create(int argc, cha - /* cnt_list[1] pointing to zero indicates no more thread context structures - they get added later */ - cnt_list[1] = NULL; - -- /* Command line arguments are being pointed to from cnt_list[0] and we call conf_load which loads -+ /* -+ * Command line arguments are being pointed to from cnt_list[0] and we call conf_load which loads - * the config options from motion.conf, thread config files and the command line. - */ - cnt_list[0]->conf.argv = argv; -@@ -2078,8 +2414,8 @@ static void motion_shutdown(void) - int i = -1; - - motion_remove_pid(); -- -- while (cnt_list[++i]) -+ -+ while (cnt_list[++i]) - context_destroy(cnt_list[i]); - - free(cnt_list); -@@ -2109,22 +2445,72 @@ static void motion_startup(int daemonize - /* Initialize our global mutex */ - pthread_mutex_init(&global_lock, NULL); - -- /* Create the list of context structures and load the -+ /* -+ * Create the list of context structures and load the - * configuration. - */ - cntlist_create(argc, argv); - -- motion_log(LOG_INFO, 0, "Motion "VERSION" Started"); -+ if ((cnt_list[0]->conf.log_level > ALL) || -+ (cnt_list[0]->conf.log_level == 0)) { -+ cnt_list[0]->conf.log_level = LEVEL_DEFAULT; -+ cnt_list[0]->log_level = cnt_list[0]->conf.log_level; -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log level (%s) (%d)", -+ get_log_level_str(cnt_list[0]->log_level), SHOW_LEVEL_VALUE(cnt_list[0]->log_level)); -+ } else { -+ cnt_list[0]->log_level = cnt_list[0]->conf.log_level - 1; // Let's make syslog compatible -+ } -+ -+ //set_log_level(cnt_list[0]->log_level); -+ -+#ifdef HAVE_SDL -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion "VERSION" Started with SDL support"); -+#else -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion "VERSION" Started"); -+#endif -+ -+ if ((cnt_list[0]->conf.log_file) && (strncmp(cnt_list[0]->conf.log_file, "syslog", 6))) { -+ set_log_mode(LOGMODE_FILE); -+ ptr_logfile = set_logfile(cnt_list[0]->conf.log_file); -+ -+ if (ptr_logfile) { -+ set_log_mode(LOGMODE_SYSLOG); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to file (%s)", -+ cnt_list[0]->conf.log_file); -+ set_log_mode(LOGMODE_FILE); -+ } else { -+ MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Exit motion, cannot create log file %s", -+ cnt_list[0]->conf.log_file); -+ exit(0); -+ } -+ } else { -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to syslog"); -+ } -+ -+ if ((cnt_list[0]->conf.log_type_str == NULL) || -+ !(cnt_list[0]->log_type = get_log_type(cnt_list[0]->conf.log_type_str))) { -+ cnt_list[0]->log_type = TYPE_DEFAULT; -+ cnt_list[0]->conf.log_type_str = mystrcpy(cnt_list[0]->conf.log_type_str, "ALL"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log type (%s)", -+ get_log_type_str(cnt_list[0]->log_type)); -+ } -+ -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using log type (%s) log level (%s)", -+ get_log_type_str(cnt_list[0]->log_type), get_log_level_str(cnt_list[0]->log_level)); -+ -+ set_log_level(cnt_list[0]->log_level); -+ set_log_type(cnt_list[0]->log_type); - - initialize_chars(); - - if (daemonize) { -- /* If daemon mode is requested, and we're not going into setup mode, -+ /* -+ * If daemon mode is requested, and we're not going into setup mode, - * become daemon. - */ - if (cnt_list[0]->daemon && cnt_list[0]->conf.setup_mode == 0) { - become_daemon(); -- motion_log(LOG_INFO, 0, "Motion running as daemon process"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion running as daemon process"); - } - } - -@@ -2163,8 +2549,8 @@ static void setup_signals(struct sigacti - sigaction(SIGCHLD, sigchild_action, NULL); - sigaction(SIGPIPE, sigchild_action, NULL); - sigaction(SIGALRM, sig_handler_action, NULL); -- sigaction(SIGHUP, sig_handler_action, NULL); -- sigaction(SIGINT, sig_handler_action, NULL); -+ sigaction(SIGHUP, sig_handler_action, NULL); -+ sigaction(SIGINT, sig_handler_action, NULL); - sigaction(SIGQUIT, sig_handler_action, NULL); - sigaction(SIGTERM, sig_handler_action, NULL); - sigaction(SIGUSR1, sig_handler_action, NULL); -@@ -2186,40 +2572,44 @@ static void start_motion_thread(struct c - { - int i; - -- /* Check the webcam port number for conflicts. -+ /* -+ * Check the stream port number for conflicts. - * First we check for conflict with the control port. - * Second we check for that two threads does not use the same port number -- * for the webcam. If a duplicate port is found the webcam feature gets disabled (port =0) -+ * for the stream. If a duplicate port is found the stream feature gets disabled (port = 0) - * for this thread and a warning is written to console and syslog. - */ - -- if (cnt->conf.webcam_port != 0) { -+ if (cnt->conf.stream_port != 0) { - /* Compare against the control port. */ -- if (cnt_list[0]->conf.control_port == cnt->conf.webcam_port) { -- motion_log(LOG_ERR, 0, -- "Webcam port number %d for thread %d conflicts with the control port", -- cnt->conf.webcam_port, cnt->threadnr); -- motion_log(LOG_ERR, 0, "Webcam feature for thread %d is disabled.", cnt->threadnr); -- cnt->conf.webcam_port = 0; -+ if (cnt_list[0]->conf.webcontrol_port == cnt->conf.stream_port) { -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, -+ "%s: Stream port number %d for thread %d conflicts with the control port", -+ cnt->conf.stream_port, cnt->threadnr); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Stream feature for thread %d is disabled.", -+ cnt->threadnr); -+ cnt->conf.stream_port = 0; - } - -- /* Compare against webcam ports of other threads. */ -+ /* Compare against stream ports of other threads. */ - for (i = 1; cnt_list[i]; i++) { - if (cnt_list[i] == cnt) - continue; - -- if (cnt_list[i]->conf.webcam_port == cnt->conf.webcam_port) { -- motion_log(LOG_ERR, 0, -- "Webcam port number %d for thread %d conflicts with thread %d", -- cnt->conf.webcam_port, cnt->threadnr, cnt_list[i]->threadnr); -- motion_log(LOG_ERR, 0, -- "Webcam feature for thread %d is disabled.", cnt->threadnr); -- cnt->conf.webcam_port = 0; -+ if (cnt_list[i]->conf.stream_port == cnt->conf.stream_port) { -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, -+ "%s: Stream port number %d for thread %d conflicts with thread %d", -+ cnt->conf.stream_port, cnt->threadnr, cnt_list[i]->threadnr); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, -+ "%s: Stream feature for thread %d is disabled.", -+ cnt->threadnr); -+ cnt->conf.stream_port = 0; - } - } - } - -- /* Update how many threads we have running. This is done within a -+ /* -+ * Update how many threads we have running. This is done within a - * mutex lock to prevent multiple simultaneous updates to - * 'threads_running'. - */ -@@ -2230,10 +2620,11 @@ static void start_motion_thread(struct c - /* Set a flag that we want this thread running */ - cnt->restart = 1; - -- /* Give the thread WATCHDOG_TMO seconds to start */ -+ /* Give the thread WATCHDOG_TMO to start */ - cnt->watchdog = WATCHDOG_TMO; - -- /* Create the actual thread. Use 'motion_loop' as the thread -+ /* -+ * Create the actual thread. Use 'motion_loop' as the thread - * function. - */ - pthread_create(&cnt->thread_id, thread_attr, &motion_loop, cnt); -@@ -2258,7 +2649,8 @@ int main (int argc, char **argv) - pthread_attr_t thread_attr; - pthread_t thread_id; - -- /* Setup signals and do some initialization. 1 in the call to -+ /* -+ * Setup signals and do some initialization. 1 in the call to - * 'motion_startup' means that Motion will become a daemon if so has been - * requested, and argc and argc are necessary for reading the command - * line options. -@@ -2270,20 +2662,23 @@ int main (int argc, char **argv) - motion_startup(1, argc, argv); - - #ifdef HAVE_FFMPEG -- /* FFMpeg initialization is only performed if FFMpeg support was found -+ /* -+ * FFMpeg initialization is only performed if FFMpeg support was found - * and not disabled during the configure phase. - */ - ffmpeg_init(); - #endif /* HAVE_FFMPEG */ - -- /* In setup mode, Motion is very communicative towards the user, which -+ /* -+ * In setup mode, Motion is very communicative towards the user, which - * allows the user to experiment with the config parameters in order to - * optimize motion detection and stuff. - */ - if (cnt_list[0]->conf.setup_mode) -- motion_log(-1, 0, "Motion running in setup mode."); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion running in setup mode."); - -- /* Create and a thread attribute for the threads we spawn later on. -+ /* -+ * Create and a thread attribute for the threads we spawn later on. - * PTHREAD_CREATE_DETACHED means to create threads detached, i.e. - * their termination cannot be synchronized through 'pthread_join'. - */ -@@ -2295,92 +2690,109 @@ int main (int argc, char **argv) - - do { - if (restart) { -- /* Handle the restart situation. Currently the approach is to -+ /* -+ * Handle the restart situation. Currently the approach is to - * cleanup everything, and then initialize everything again - * (including re-reading the config file(s)). - */ -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Restarting motion."); - motion_shutdown(); - restart = 0; /* only one reset for now */ -- motion_log(LOG_INFO,0,"motion restarted"); - #ifndef WITHOUT_V4L -- SLEEP(5,0); // maybe some cameras needs less time -+ SLEEP(5, 0); // maybe some cameras needs less time - #endif - motion_startup(0, argc, argv); /* 0 = skip daemon init */ -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Motion restarted"); - } - -- -- /* Start the motion threads. First 'cnt_list' item is global if 'thread' -+ /* -+ * Start the motion threads. First 'cnt_list' item is global if 'thread' - * option is used, so start at 1 then and 0 otherwise. - */ - for (i = cnt_list[1] != NULL ? 1 : 0; cnt_list[i]; i++) { - /* If i is 0 it means no thread files and we then set the thread number to 1 */ - cnt_list[i]->threadnr = i ? i : 1; - -- if (strcmp(cnt_list[i]->conf_filename,"") ) -- motion_log(LOG_INFO, 0, "Thread %d is from %s", cnt_list[i]->threadnr, cnt_list[i]->conf_filename ); -+ if (strcmp(cnt_list[i]->conf_filename, "")) -+ { -+ cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; - -- if (cnt_list[0]->conf.setup_mode) { -- motion_log(-1, 0, "Thread %d is device: %s input %d", cnt_list[i]->threadnr, -- cnt_list[i]->conf.netcam_url ? cnt_list[i]->conf.netcam_url : cnt_list[i]->conf.video_device, -- cnt_list[i]->conf.netcam_url ? -1 : cnt_list[i]->conf.input -- ); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", -+ cnt_list[i]->threadnr, cnt_list[i]->conf_filename); - } - -- if (cnt_list[0]->conf.setup_mode) -- motion_log(LOG_ERR, 0, "Webcam port %d", cnt_list[i]->conf.webcam_port); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", -+ cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? -+ cnt_list[i]->conf.netcam_url : cnt_list[i]->conf.video_device, -+ cnt_list[i]->conf.netcam_url ? -1 : cnt_list[i]->conf.input); -+ -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Stream port %d", -+ cnt_list[i]->conf.stream_port); - - start_motion_thread(cnt_list[i], &thread_attr); - } - -- /* Create a thread for the control interface if requested. Create it -+#ifdef HAVE_SDL -+ if (cnt_list[0]->conf.sdl_threadnr > 0) -+ sdl_start(cnt_list[cnt_list[1] != NULL ? cnt_list[0]->conf.sdl_threadnr : 0]->conf.width, -+ cnt_list[cnt_list[1] != NULL ? cnt_list[0]->conf.sdl_threadnr : 0]->conf.height); -+#endif -+ -+ /* -+ * Create a thread for the control interface if requested. Create it - * detached and with 'motion_web_control' as the thread function. - */ -- if (cnt_list[0]->conf.control_port) -+ if (cnt_list[0]->conf.webcontrol_port) - pthread_create(&thread_id, &thread_attr, &motion_web_control, cnt_list); - -- if (cnt_list[0]->conf.setup_mode) -- motion_log(-1, 0,"Waiting for threads to finish, pid: %d", getpid()); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Waiting for threads to finish, pid: %d", -+ getpid()); - -- /* Crude way of waiting for all threads to finish - check the thread -+ /* -+ * Crude way of waiting for all threads to finish - check the thread - * counter (because we cannot do join on the detached threads). - */ - while (1) { -- SLEEP(1,0); -+ SLEEP(1, 0); - -- /* Calculate how many threads runnig or wants to run -+ /* -+ * Calculate how many threads runnig or wants to run - * if zero and we want to finish, break out - */ - int motion_threads_running = 0; -+ - for (i = (cnt_list[1] != NULL ? 1 : 0); cnt_list[i]; i++) { - if (cnt_list[i]->running || cnt_list[i]->restart) - motion_threads_running++; - } - -- if (((motion_threads_running == 0 ) && finish ) || -- ((motion_threads_running == 0 ) && (threads_running == 0)) ){ -- if (debug_level >= CAMERA_DEBUG){ -- motion_log(LOG_INFO, 0, "DEBUG-1 threads_running %d motion_threads_running %d , finish %d", -- threads_running, motion_threads_running, finish); -- } -+ if (((motion_threads_running == 0) && finish) || -+ ((motion_threads_running == 0) && (threads_running == 0))) { -+ MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-1 threads_running %d motion_threads_running %d " -+ ", finish %d", threads_running, motion_threads_running, finish); - break; -- } -+ } - - for (i = (cnt_list[1] != NULL ? 1 : 0); cnt_list[i]; i++) { - /* Check if threads wants to be restarted */ -- if ((!cnt_list[i]->running) && (cnt_list[i]->restart) ) { -- motion_log(LOG_INFO, 0, "Motion thread %d restart", cnt_list[i]->threadnr); -+ if ((!cnt_list[i]->running) && (cnt_list[i]->restart)) { -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion thread %d restart", -+ cnt_list[i]->threadnr); - start_motion_thread(cnt_list[i], &thread_attr); - } -+ - if (cnt_list[i]->watchdog > WATCHDOG_OFF) { - cnt_list[i]->watchdog--; -+ - if (cnt_list[i]->watchdog == 0) { -- motion_log(LOG_ERR, 0, "Thread %d - Watchdog timeout, trying to do a graceful restart", -- cnt_list[i]->threadnr); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, trying to do " -+ "a graceful restart", cnt_list[i]->threadnr); - cnt_list[i]->finish = 1; - } -+ - if (cnt_list[i]->watchdog == -60) { -- motion_log(LOG_ERR, 0, "Thread %d - Watchdog timeout, did NOT restart graceful," -- "killing it!", cnt_list[i]->threadnr); -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, did NOT restart graceful," -+ "killing it!", cnt_list[i]->threadnr); - pthread_cancel(cnt_list[i]->thread_id); - pthread_mutex_lock(&global_lock); - threads_running--; -@@ -2392,27 +2804,29 @@ int main (int argc, char **argv) - } - } - -- if (debug_level >= CAMERA_DEBUG){ -- motion_log(LOG_INFO, 0, "DEBUG-2 threads_running %d motion_threads_running %d , finish %d", -- threads_running, motion_threads_running, finish); -- } -+ MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d", -+ threads_running, motion_threads_running, finish); - } - /* Reset end main loop flag */ - finish = 0; - -- if (cnt_list[0]->conf.setup_mode) -- motion_log(LOG_DEBUG, 0, "Threads finished"); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Threads finished"); - - /* Rest for a while if we're supposed to restart. */ - if (restart) -- SLEEP(2,0); -+ SLEEP(2, 0); - - } while (restart); /* loop if we're supposed to restart */ - -+#ifdef HAVE_SDL -+ sdl_stop(); -+#endif -+ -+ - // Be sure that http control exits fine - cnt_list[0]->finish = 1; -- SLEEP(1,0); -- motion_log(LOG_INFO, 0, "Motion terminating"); -+ SLEEP(1, 0); -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion terminating"); - - /* Perform final cleanup. */ - pthread_key_delete(tls_key_threadnr); -@@ -2444,9 +2858,11 @@ int main (int argc, char **argv) - */ - void * mymalloc(size_t nbytes) - { -- void *dummy = malloc(nbytes); -+ void *dummy = calloc(nbytes, 1); -+ - if (!dummy) { -- motion_log(LOG_EMERG, 1, "Could not allocate %llu bytes of memory!", (unsigned long long)nbytes); -+ MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Could not allocate %llu bytes of memory!", -+ (unsigned long long)nbytes); - motion_remove_pid(); - exit(1); - } -@@ -2476,14 +2892,14 @@ void *myrealloc(void *ptr, size_t size, - - if (size == 0) { - free(ptr); -- motion_log(LOG_WARNING, 0, -- "Warning! Function %s tries to resize memoryblock at %p to 0 bytes!", -- desc, ptr); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, -+ "%s: Warning! Function %s tries to resize memoryblock at %p to 0 bytes!", -+ desc, ptr); - } else { - dummy = realloc(ptr, size); - if (!dummy) { -- motion_log(LOG_EMERG, 0, -- "Could not resize memory-block at offset %p to %llu bytes (function %s)!", -+ MOTION_LOG(EMG, TYPE_ALL, NO_ERRNO, -+ "%s: Could not resize memory-block at offset %p to %llu bytes (function %s)!", - ptr, (unsigned long long)size, desc); - motion_remove_pid(); - exit(1); -@@ -2493,6 +2909,7 @@ void *myrealloc(void *ptr, size_t size, - return dummy; - } - -+ - /** - * create_path - * -@@ -2519,23 +2936,34 @@ int create_path(const char *path) - start = strchr(path, '/'); - - while (start) { -- char *buffer = strdup(path); -+ char *buffer = mystrdup(path); - buffer[start-path] = 0x00; - - if (mkdir(buffer, mode) == -1 && errno != EEXIST) { -- motion_log(LOG_ERR, 1, "Problem creating directory %s", buffer); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem creating directory %s", -+ buffer); - free(buffer); - return -1; - } - -- free(buffer); -- - start = strchr(start + 1, '/'); -+ -+ if (!start) -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: creating directory %s", buffer); -+ -+ free(buffer); - } - - return 0; - } - -+#define MYBUFCOUNT 32 -+struct MyBuffer { -+ FILE* fh; -+ char* buffer; -+ size_t bufsize; -+} buffers[MYBUFCOUNT]; -+ - /** - * myfopen - * -@@ -2543,17 +2971,25 @@ int create_path(const char *path) - * (which is: path does not exist), the path is created and then things are - * tried again. This is faster then trying to create that path over and over - * again. If someone removes the path after it was created, myfopen will -- * recreate the path automatically. -+ * recreate the path automatically. If the bufsize is set to > 0, we will -+ * allocate (or re-use) write buffers to use instead of the default ones. -+ * This gives us much higher throughput in many cases. - * - * Parameters: - * - * path - path to the file to open - * mode - open mode -+ * bufsize - size of write buffers, 0 == OS default - * - * Returns: the file stream object - */ --FILE * myfopen(const char *path, const char *mode) -+FILE * myfopen(const char *path, const char *mode, size_t bufsize) - { -+ static int bufferInit = 0; -+ if (!bufferInit) { -+ bufferInit = 1; -+ memset(buffers, 0x00, sizeof(buffers)); -+ } - /* first, just try to open the file */ - FILE *dummy = fopen(path, mode); - -@@ -2568,28 +3004,109 @@ FILE * myfopen(const char *path, const c - - /* and retry opening the file */ - dummy = fopen(path, mode); -- if (dummy) -- return dummy; - } -+ } -+ -+ if (dummy) { -+ if (bufsize > 0) { -+ int i = 0; -+ for (i = 0; i < MYBUFCOUNT; i++) { -+ int first = -1; -+ if (!buffers[i].fh) { -+ if (first == -1) -+ first = i; -+ if (buffers[i].buffer == NULL || -+ buffers[i].bufsize >= bufsize || -+ (i == (MYBUFCOUNT - 1) && first >= 0)) { -+ if (buffers[i].buffer == NULL) { -+ /* We are allocating a new buffer */ -+ buffers[i].fh = dummy; -+ buffers[i].buffer = mymalloc(bufsize); -+ buffers[i].bufsize = bufsize; -+ } -+ else if (buffers[i].bufsize >= bufsize) { -+ /* We are using an old buffer */ -+ buffers[i].fh = dummy; -+ } -+ else { -+ /* -+ * We are reusing an old buffer, but it is too -+ * small, realloc it -+ */ -+ i = first; -+ buffers[i].fh = dummy; -+ buffers[i].buffer = myrealloc(buffers[i].buffer, -+ bufsize, "myfopen"); -+ buffers[i].bufsize = bufsize; -+ } - -- /* two possibilities -- * 1: there was an other error while trying to open the file for the first time -+ if (buffers[i].buffer == NULL) { -+ /* -+ * Our allocation failed, so just use the default -+ * OS buffers -+ */ -+ buffers[i].fh = NULL; -+ buffers[i].bufsize = 0; -+ } -+ else { -+ setvbuf(buffers[i].fh, buffers[i].buffer, -+ _IOFBF, buffers[i].bufsize); -+ } -+ break; -+ } -+ } -+ } -+ } -+ } else { -+ /* -+ * Two possibilities -+ * 1: there was an other error while trying to open the file for the -+ * first time - * 2: could still not open the file after the path was created - */ -- motion_log(LOG_ERR, 1, "Error opening file %s with mode %s", path, mode); -- -- return NULL; -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening file %s with mode %s", -+ path, mode); - } - - return dummy; - } - - /** -+ * myfclose -+ * -+ * Motion-specific variant of fclose() -+ * -+ * Returns: fclose() return value -+ */ -+int myfclose(FILE* fh) -+{ -+ int i = 0; -+ int rval = fclose(fh); -+ -+ if (rval != 0) -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error closing file"); -+ -+ for (i = 0; i < MYBUFCOUNT; i++) { -+ if (buffers[i].fh == fh) { -+ buffers[i].fh = NULL; -+ if ( finish ) { -+ /* Free the buffers */ -+ if (buffers[i].buffer) -+ free(buffers[i].buffer); -+ buffers[i].buffer = NULL; -+ buffers[i].bufsize = 0; -+ } -+ } -+ } -+ return rval; -+} -+ -+/** - * mystrftime - * - * Motion-specific variant of strftime(3) that supports additional format - * specifiers in the format string. -- * -+ * - * Parameters: - * - * cnt - current thread's context structure -@@ -2603,7 +3120,7 @@ FILE * myfopen(const char *path, const c - * - * Returns: number of bytes written to the string s - */ --size_t mystrftime(struct context *cnt, char *s, size_t max, const char *userformat, -+size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *userformat, - const struct tm *tm, const char *filename, int sqltype) - { - char formatstring[PATH_MAX] = ""; -@@ -2622,85 +3139,107 @@ size_t mystrftime(struct context *cnt, c - for (pos_userformat = userformat; *pos_userformat; ++pos_userformat) { - - if (*pos_userformat == '%') { -- /* Reset 'tempstr' to point to the beginning of 'tempstring', -+ /* -+ * Reset 'tempstr' to point to the beginning of 'tempstring', - * otherwise we will eat up tempstring if there are many - * format specifiers. - */ - tempstr = tempstring; - tempstr[0] = '\0'; -+ - switch (*++pos_userformat) { -- case '\0': // end of string -- --pos_userformat; -- break; -+ case '\0': // end of string -+ --pos_userformat; -+ break; - -- case 'v': // event -- sprintf(tempstr, "%02d", cnt->event_nr); -- break; -+ case 'v': // event -+ sprintf(tempstr, "%02d", cnt->event_nr); -+ break; - -- case 'q': // shots -- sprintf(tempstr, "%02d", cnt->current_image->shot); -- break; -+ case 'q': // shots -+ sprintf(tempstr, "%02d", cnt->current_image->shot); -+ break; - -- case 'D': // diffs -- sprintf(tempstr, "%d", cnt->current_image->diffs); -- break; -+ case 'D': // diffs -+ sprintf(tempstr, "%d", cnt->current_image->diffs); -+ break; - -- case 'N': // noise -- sprintf(tempstr, "%d", cnt->noise); -- break; -+ case 'N': // noise -+ sprintf(tempstr, "%d", cnt->noise); -+ break; - -- case 'i': // motion width -- sprintf(tempstr, "%d", cnt->current_image->location.width); -- break; -+ case 'i': // motion width -+ sprintf(tempstr, "%d", cnt->current_image->location.width); -+ break; - -- case 'J': // motion height -- sprintf(tempstr, "%d", cnt->current_image->location.height); -- break; -+ case 'J': // motion height -+ sprintf(tempstr, "%d", cnt->current_image->location.height); -+ break; - -- case 'K': // motion center x -- sprintf(tempstr, "%d", cnt->current_image->location.x); -- break; -+ case 'K': // motion center x -+ sprintf(tempstr, "%d", cnt->current_image->location.x); -+ break; - -- case 'L': // motion center y -- sprintf(tempstr, "%d", cnt->current_image->location.y); -- break; -+ case 'L': // motion center y -+ sprintf(tempstr, "%d", cnt->current_image->location.y); -+ break; - -- case 'o': // threshold -- sprintf(tempstr, "%d", cnt->threshold); -- break; -+ case 'o': // threshold -+ sprintf(tempstr, "%d", cnt->threshold); -+ break; - -- case 'Q': // number of labels -- sprintf(tempstr, "%d", cnt->current_image->total_labels); -- break; -- case 't': // thread number -- sprintf(tempstr, "%d",(int)(unsigned long) -- pthread_getspecific(tls_key_threadnr)); -- break; -- case 'C': // text_event -- if (cnt->text_event_string && cnt->text_event_string[0]) -- snprintf(tempstr, PATH_MAX, "%s", cnt->text_event_string); -- else -- ++pos_userformat; -- break; -- case 'f': // filename -- if (filename) -- snprintf(tempstr, PATH_MAX, "%s", filename); -- else -- ++pos_userformat; -- break; -- case 'n': // sqltype -- if (sqltype) -- sprintf(tempstr, "%d", sqltype); -- else -- ++pos_userformat; -+ case 'Q': // number of labels -+ sprintf(tempstr, "%d", cnt->current_image->total_labels); -+ break; -+ -+ case 't': // thread number -+ sprintf(tempstr, "%d",(int)(unsigned long) -+ pthread_getspecific(tls_key_threadnr)); -+ break; -+ -+ case 'C': // text_event -+ if (cnt->text_event_string && cnt->text_event_string[0]) -+ snprintf(tempstr, PATH_MAX, "%s", cnt->text_event_string); -+ else -+ ++pos_userformat; -+ break; -+ -+ case 'w': // picture width -+ sprintf(tempstr, "%d", cnt->imgs.width); -+ break; -+ -+ case 'h': // picture height -+ sprintf(tempstr, "%d", cnt->imgs.height); -+ break; -+ -+ case 'f': // filename -- or %fps -+ if ((*(pos_userformat+1) == 'p') && (*(pos_userformat+2) == 's')) { -+ sprintf(tempstr, "%d", cnt->movie_fps); -+ pos_userformat += 2; - break; -- default: // Any other code is copied with the %-sign -- *format++ = '%'; -- *format++ = *pos_userformat; -- continue; -+ } -+ -+ if (filename) -+ snprintf(tempstr, PATH_MAX, "%s", filename); -+ else -+ ++pos_userformat; -+ break; -+ -+ case 'n': // sqltype -+ if (sqltype) -+ sprintf(tempstr, "%d", sqltype); -+ else -+ ++pos_userformat; -+ break; -+ -+ default: // Any other code is copied with the %-sign -+ *format++ = '%'; -+ *format++ = *pos_userformat; -+ continue; - } - -- /* If a format specifier was found and used, copy the result from -+ /* -+ * If a format specifier was found and used, copy the result from - * 'tempstr' to 'format'. - */ - if (tempstr[0]) { -@@ -2720,86 +3259,3 @@ size_t mystrftime(struct context *cnt, c - return strftime(s, max, format, tm); - } - --/** -- * motion_log -- * -- * This routine is used for printing all informational, debug or error -- * messages produced by any of the other motion functions. It always -- * produces a message of the form "[n] {message}", and (if the param -- * 'errno_flag' is set) follows the message with the associated error -- * message from the library. -- * -- * Parameters: -- * -- * level logging level for the 'syslog' function -- * (-1 implies no syslog message should be produced) -- * errno_flag if set, the log message should be followed by the -- * error message. -- * fmt the format string for producing the message -- * ap variable-length argument list -- * -- * Returns: -- * Nothing -- */ --void motion_log(int level, int errno_flag, const char *fmt, ...) --{ -- int errno_save, n; -- char buf[1024]; --#if (!defined(BSD)) && (!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) -- char msg_buf[100]; --#endif -- va_list ap; -- int threadnr; -- -- /* 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, -- * which is nice because that's what we want in that case. -- */ -- threadnr = (unsigned long)pthread_getspecific(tls_key_threadnr); -- -- /* -- * First we save the current 'error' value. This is required because -- * the subsequent calls to vsnprintf could conceivably change it! -- */ -- errno_save = errno; -- -- /* Prefix the message with the thread number */ -- n = snprintf(buf, sizeof(buf), "[%d] ", threadnr); -- -- /* Next add the user's message */ -- va_start(ap, fmt); -- n += vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); -- -- /* If errno_flag is set, add on the library error message */ -- if (errno_flag) { -- strncat(buf, ": ", 1024 - strlen(buf)); -- n += 2; -- -- /* -- * this is bad - apparently gcc/libc wants to use the non-standard GNU -- * version of strerror_r, which doesn't actually put the message into -- * my buffer :-(. I have put in a 'hack' to get around this. -- */ --#if (defined(BSD)) -- strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */ --#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE -- strerror_r(errno_save, buf + n, sizeof(buf) - n); --#else -- strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf)); --#endif -- } -- /* If 'level' is not negative, send the message to the syslog */ -- if (level >= 0) -- syslog(level, "%s", buf); -- -- /* For printing to stderr we need to add a newline */ -- strcat(buf, "\n"); -- fputs(buf, stderr); -- fflush(stderr); -- -- /* Clean up the argument list routine */ -- va_end(ap); --} -- -- -- ---- motion-3.2.12.orig/motion.h -+++ motion-3.2.12/motion.h -@@ -12,11 +12,24 @@ - - #include "config.h" - -+#if defined(__FreeBSD__) || defined(__NetBSD__) -+#define BSD -+#endif -+ - /* Includes */ - #ifdef HAVE_MYSQL - #include - #endif - -+#ifdef HAVE_SQLITE3 -+#include -+#endif -+ -+#ifdef HAVE_PGSQL -+#include -+#endif -+ -+ - #include - #include - #ifndef __USE_GNU -@@ -27,7 +40,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -39,20 +51,22 @@ - #include - - #define _LINUX_TIME_H 1 --#if !defined(WITHOUT_V4L) && !defined(BSD) -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) && (!defined(BSD)) - #include - #endif - - #include - --#ifdef HAVE_PGSQL --#include --#endif -- -+#include "logger.h" - #include "conf.h" --#include "webcam.h" -+#include "stream.h" - #include "webhttpd.h" - -+#ifdef HAVE_SDL -+#include "sdl.h" -+#endif -+ -+ - /** - * ATTRIBUTE_UNUSED: - * -@@ -69,7 +83,14 @@ - #define ATTRIBUTE_UNUSED - #endif - --/* The macro below defines a version of sleep using nanosleep -+/* strerror_r() XSI vs GNU */ -+#if (defined(BSD)) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) -+#define XSI_STRERROR_R -+#endif -+ -+ -+/* -+ * The macro below defines a version of sleep using nanosleep - * If a signal such as SIG_CHLD interrupts the sleep we just continue sleeping - */ - #define SLEEP(seconds, nanoseconds) { \ -@@ -79,9 +100,8 @@ - while (nanosleep(&tv, &tv) == -1); \ - } - -+#define CLEAR(x) memset(&(x), 0, sizeof(x)) - --#if defined(WITHOUT_V4L) || defined(BSD) -- - #define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ - #define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ - #define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ -@@ -100,17 +120,8 @@ - #define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ - #define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ - #define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ --#endif -- -- --/* Debug levels FIXME */ --#define CAMERA_WARNINGS 3 /* warnings only */ --#define CAMERA_INFO 5 /* info debug */ --#define CAMERA_VIDEO 6 /* video debug */ --#define CAMERA_DEBUG 7 /* debug but not verbose */ --#define CAMERA_VERBOSE 8 /* verbose level */ --#define CAMERA_ALL 9 /* everything */ - -+#define DEF_PALETTE 17 - - /* Default picture settings */ - #define DEF_WIDTH 352 -@@ -122,8 +133,8 @@ - #define DEF_NOISELEVEL 32 - - /* Minimum time between two 'actions' (email, sms, external) */ --#define DEF_GAP 60 /* 1 minutes */ --#define DEF_MAXMPEGTIME 3600 /* 60 minutes */ -+#define DEF_EVENT_GAP 60 /* 1 minutes */ -+#define DEF_MAXMOVIETIME 3600 /* 60 minutes */ - - #define DEF_FFMPEG_BPS 400000 - #define DEF_FFMPEG_VBR 0 -@@ -132,26 +143,26 @@ - #define THRESHOLD_TUNE_LENGTH 256 - - #define MISSING_FRAMES_TIMEOUT 30 /* When failing to get picture frame from camera -- * we reuse the previous frame until -- * MISSING_FRAMES_TIMEOUT seconds has passed -- * and then we show a grey image instead -+ we reuse the previous frame until -+ MISSING_FRAMES_TIMEOUT seconds has passed -+ and then we show a grey image instead - */ - --#define WATCHDOG_TMO 30 /* 10 sec max motion_loop interval */ --#define WATCHDOG_OFF -127 /* Turn off watchdog, used when we wants to quit a thread */ -+#define WATCHDOG_TMO 30 /* 30 sec max motion_loop interval */ -+#define WATCHDOG_OFF -127 /* Turn off watchdog, used when we wants to quit a thread */ - --#define CONNECTION_KO "Lost connection" --#define CONNECTION_OK "Connection OK" -+#define CONNECTION_KO "Lost connection" -+#define CONNECTION_OK "Connection OK" - --#define DEF_MAXSTREAMS 10 /* Maximum number of webcam clients per camera */ --#define DEF_MAXWEBQUEUE 10 /* Maximum number of webcam client in queue */ -+#define DEF_MAXSTREAMS 10 /* Maximum number of stream clients per camera */ -+#define DEF_MAXWEBQUEUE 10 /* Maximum number of stream client in queue */ - - #define DEF_TIMESTAMP "%Y-%m-%d\\n%T" - #define DEF_EVENTSTAMP "%Y%m%d%H%M%S" - - #define DEF_SNAPPATH "%v-%Y%m%d%H%M%S-snapshot" --#define DEF_JPEGPATH "%v-%Y%m%d%H%M%S-%q" --#define DEF_MPEGPATH "%v-%Y%m%d%H%M%S" -+#define DEF_IMAGEPATH "%v-%Y%m%d%H%M%S-%q" -+#define DEF_MOVIEPATH "%v-%Y%m%d%H%M%S" - #define DEF_TIMEPATH "%Y%m%d-timelapse" - - #define DEF_TIMELAPSE_MODE "daily" -@@ -159,33 +170,44 @@ - /* Do not break this line into two or more. Must be ONE line */ - #define DEF_SQL_QUERY "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')" - -+ -+/* OUTPUT Image types */ -+#define IMAGE_TYPE_JPEG 0 -+#define IMAGE_TYPE_PPM 1 -+ - /* Filetype defines */ --#define FTYPE_IMAGE 1 --#define FTYPE_IMAGE_SNAPSHOT 2 --#define FTYPE_IMAGE_MOTION 4 --#define FTYPE_MPEG 8 --#define FTYPE_MPEG_MOTION 16 --#define FTYPE_MPEG_TIMELAPSE 32 -+#define FTYPE_IMAGE 1 -+#define FTYPE_IMAGE_SNAPSHOT 2 -+#define FTYPE_IMAGE_MOTION 4 -+#define FTYPE_MPEG 8 -+#define FTYPE_MPEG_MOTION 16 -+#define FTYPE_MPEG_TIMELAPSE 32 - - #define FTYPE_MPEG_ANY (FTYPE_MPEG | FTYPE_MPEG_MOTION | FTYPE_MPEG_TIMELAPSE) - #define FTYPE_IMAGE_ANY (FTYPE_IMAGE | FTYPE_IMAGE_SNAPSHOT | FTYPE_IMAGE_MOTION) - --/* What types of jpeg files do we want to have */ --#define NEWIMG_OFF 0 --#define NEWIMG_ON 1 --#define NEWIMG_FIRST 2 --#define NEWIMG_BEST 4 --#define NEWIMG_CENTER 8 -- --#define LOCATE_OFF 0 --#define LOCATE_ON 1 --#define LOCATE_PREVIEW 2 -+/* What types of images files do we want to have */ -+#define NEWIMG_OFF 0 -+#define NEWIMG_ON 1 -+#define NEWIMG_FIRST 2 -+#define NEWIMG_BEST 4 -+#define NEWIMG_CENTER 8 -+ -+#define LOCATE_OFF 0 -+#define LOCATE_ON 1 -+#define LOCATE_PREVIEW 2 -+#define LOCATE_BOX 1 -+#define LOCATE_REDBOX 2 -+#define LOCATE_CROSS 4 -+#define LOCATE_REDCROSS 8 -+ -+#define LOCATE_NORMAL 1 -+#define LOCATE_BOTH 2 - --#define LOCATE_NORMAL 0 --#define LOCATE_BOTH 1 -+#define UPDATE_REF_FRAME 1 -+#define RESET_REF_FRAME 2 - --#define UPDATE_REF_FRAME 1 --#define RESET_REF_FRAME 2 -+#define BUFSIZE_1MEG (1024 * 1024) - - /* Forward declaration, used in track.h */ - struct images; -@@ -193,39 +215,44 @@ struct images; - #include "track.h" - #include "netcam.h" - --/* Structure to hold images information -+/* -+ * Structure to hold images information - * The idea is that this should have all information about a picture e.g. diffs, timestamp etc. - * The exception is the label information, it uses a lot of memory - * When the image is stored all texts motion marks etc. is written to the image - * so we only have to send it out when/if we want. - */ -+ - /* A image can have detected motion in it, but dosn't trigger an event, if we use minimum_motion_frames */ --#define IMAGE_MOTION 1 --#define IMAGE_TRIGGER 2 --#define IMAGE_SAVE 4 --#define IMAGE_SAVED 8 --#define IMAGE_PRECAP 16 --#define IMAGE_POSTCAP 32 -+#define IMAGE_MOTION 1 -+#define IMAGE_TRIGGER 2 -+#define IMAGE_SAVE 4 -+#define IMAGE_SAVED 8 -+#define IMAGE_PRECAP 16 -+#define IMAGE_POSTCAP 32 - - struct image_data { - unsigned char *image; - int diffs; -- time_t timestamp; /* Timestamp when image was captured */ -+ time_t timestamp; /* Timestamp when image was captured */ - struct tm timestamp_tm; -- int shot; /* Sub second timestamp count */ -+ int shot; /* Sub second timestamp count */ - -- /* movement center to img center distance -- * Note Dist is calculated distX*distX + distY*distY */ -+ /* -+ * Movement center to img center distance -+ * Note: Dist is calculated distX*distX + distY*distY -+ */ - unsigned long cent_dist; - -- unsigned int flags; /* Se IMAGE_* defines */ -+ unsigned int flags; /* Se IMAGE_* defines */ - -- struct coord location; /* coordinates for center and size of last motion detection*/ -+ struct coord location; /* coordinates for center and size of last motion detection*/ - - int total_labels; - }; - --/* DIFFERENCES BETWEEN imgs.width, conf.width AND rotate_data.cap_width -+/* -+ * DIFFERENCES BETWEEN imgs.width, conf.width AND rotate_data.cap_width - * (and the corresponding height values, of course) - * =========================================================================== - * Location Purpose -@@ -251,7 +278,7 @@ struct image_data { - */ - - /* date/time drawing, draw.c */ --int draw_text (unsigned char *image, int startx, int starty, int width, const char *text, unsigned short int factor); -+int draw_text(unsigned char *image, unsigned int startx, unsigned int starty, unsigned int width, const char *text, unsigned int factor); - int initialize_chars(void); - - struct images { -@@ -275,6 +302,7 @@ struct images { - int width; - int height; - int type; -+ int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ - int size; - int motionsize; - int labelgroup_max; -@@ -287,36 +315,47 @@ struct images { - struct rotdata { - /* Temporary buffer for 90 and 270 degrees rotation. */ - unsigned char *temp_buf; -- /* Degrees to rotate; copied from conf.rotate_deg. This is the value -+ /* -+ * Degrees to rotate; copied from conf.rotate_deg. This is the value - * that is actually used. The value of conf.rotate_deg cannot be used - * because it can be changed by motion-control, and changing rotation - * while Motion is running just causes problems. - */ - int degrees; -- /* Capture width and height - different from output width and height if -- * rotating 90 or 270 degrees. */ -+ /* -+ * Capture width and height - different from output width and height if -+ * rotating 90 or 270 degrees. -+ */ - int cap_width; - int cap_height; - }; - - /* -- these used to be global variables but now each thread will have its -- own context -+ * These used to be global variables but now each thread will have its -+ * own context - */ - struct context { -+ FILE *extpipe; -+ int extpipe_open; - char conf_filename[PATH_MAX]; - int threadnr; -- unsigned short int daemon; -+ unsigned int daemon; - char pid_file[PATH_MAX]; -+ char log_file[PATH_MAX]; -+ char log_type_str[6]; -+ int log_level; -+ unsigned int log_type; - - struct config conf; - struct images imgs; - struct trackoptions track; - struct netcam_context *netcam; - struct image_data *current_image; /* Pointer to a structure where the image, diffs etc is stored */ -- unsigned short int new_img; -+ unsigned int new_img; - -- int locate; -+ int locate_motion_mode; -+ int locate_motion_style; -+ int process_thisframe; - struct rotdata rotate_data; /* rotation data is thread-specific */ - - int noise; -@@ -325,39 +364,39 @@ struct context { - int smartmask_speed; - - /* Commands to the motion thread */ -- volatile unsigned short int snapshot; /* Make a snapshot */ -- volatile unsigned short int makemovie; /* End a movie */ -- volatile unsigned short int finish; /* End the thread */ -- volatile unsigned short int restart; /* Restart the thread when it ends */ -+ volatile unsigned int snapshot; /* Make a snapshot */ -+ volatile unsigned int makemovie; /* End a movie */ -+ volatile unsigned int finish; /* End the thread */ -+ volatile unsigned int restart; /* Restart the thread when it ends */ - /* Is the motion thread running */ -- volatile unsigned short int running; -+ volatile unsigned int running; - volatile int watchdog; - - pthread_t thread_id; - - int event_nr; - int prev_event; -- int lightswitch_framecounter; -- char text_event_string[PATH_MAX]; /* The text for conv. spec. %C - -- we assume PATH_MAX normally 4096 characters is fine */ -- int postcap; /* downcounter, frames left to to send post event */ -+ unsigned int lightswitch_framecounter; -+ char text_event_string[PATH_MAX]; /* The text for conv. spec. %C - -+ we assume PATH_MAX normally 4096 characters is fine */ -+ int postcap; /* downcounter, frames left to to send post event */ - -- short int shots; -- unsigned short int detecting_motion; -+ int shots; -+ unsigned int detecting_motion; - struct tm *currenttime_tm; - struct tm *eventtime_tm; - - time_t currenttime; - time_t lasttime; - time_t eventtime; -- time_t connectionlosttime; /* timestamp from connection lost */ -+ time_t connectionlosttime; /* timestamp from connection lost */ - -- int lastrate; -- unsigned short int startup_frames; -- unsigned short int moved; -- unsigned short int pause; -- int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ -- unsigned short int lost_connection; -+ unsigned int lastrate; -+ unsigned int startup_frames; -+ unsigned int moved; -+ unsigned int pause; -+ int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ -+ unsigned int lost_connection; - - #if (defined(BSD)) - int tuner_dev; -@@ -366,13 +405,17 @@ struct context { - int pipe; - int mpipe; - -- struct webcam webcam; -+ struct stream stream; - int stream_count; - --#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) -+#if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) - int sql_mask; - #endif - -+#ifdef HAVE_SQLITE3 -+ sqlite3 *database_sqlite3; -+#endif -+ - #ifdef HAVE_MYSQL - MYSQL *database; - #endif -@@ -381,29 +424,33 @@ struct context { - PGconn *database_pg; - #endif - -+ int movie_fps; -+ char newfilename[PATH_MAX]; -+ char extpipefilename[PATH_MAX]; -+ int movie_last_shot; -+ - #ifdef HAVE_FFMPEG -- struct ffmpeg *ffmpeg_new; -- struct ffmpeg *ffmpeg_motion; -+ struct ffmpeg *ffmpeg_output; -+ struct ffmpeg *ffmpeg_output_debug; - struct ffmpeg *ffmpeg_timelapse; - struct ffmpeg *ffmpeg_smartmask; -- char newfilename[PATH_MAX]; -- char motionfilename[PATH_MAX]; - char timelapsefilename[PATH_MAX]; -+ char motionfilename[PATH_MAX]; - #endif - }; - - extern pthread_mutex_t global_lock; - extern volatile int threads_running; --extern unsigned short int debug_level; -+extern FILE *ptr_logfile; - - /* TLS keys below */ - extern pthread_key_t tls_key_threadnr; /* key for thread number */ - --int http_bindsock(int, int); -+int http_bindsock(int, int, int); - void * mymalloc(size_t); - void * myrealloc(void *, size_t, const char *); --FILE * myfopen(const char *, const char *); --size_t mystrftime(struct context *, char *, size_t, const char *, const struct tm *, const char *, int); -+FILE * myfopen(const char *, const char *, size_t); -+int myfclose(FILE *); -+size_t mystrftime(const struct context *, char *, size_t, const char *, const struct tm *, const char *, int); - int create_path(const char *); --void motion_log(int, int, const char *, ...); - #endif /* _INCLUDE_MOTION_H */ ---- /dev/null -+++ motion-3.2.12/motion.init-Debian -@@ -0,0 +1,69 @@ -+#! /bin/bash -+# -+# motion 3.2.12-4ppa01 -+# Start the motion detection . -+# -+ -+NAME=motion -+PATH=/bin:/usr/bin:/sbin:/usr/sbin -+DAEMON=/home/dave/motion_build/bin/motion -+PIDFILE=/var/run/motion/$NAME.pid -+ -+ -+trap "" 1 -+export LANG=C -+export PATH -+ -+test -f $DAEMON || exit 0 -+ -+ -+case "$1" in -+ start) -+ echo "Starting motion detection : $NAME" -+ start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --chuid motion -+ ;; -+ -+ stop) -+ echo "Stopping motion detection : $NAME" -+ start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON --retry 30 -+ ;; -+ -+ status) -+ echo "Status motion detection : $NAME" -+ if (test -f $PIDFILE); then -+ echo -n "Running process for $NAME : " -+ pidof $NAME -+ else -+ echo "Stopped" -+ fi -+ ;; -+ -+ reload-config) -+ echo "Reloading $NAME configuration" -+ start-stop-daemon --stop --pidfile $PIDFILE --signal HUP --exec $DAEMON -+ ;; -+ -+ restart-motion) -+ echo "Restarting $NAME" -+ start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON --retry 30 -+ start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --chuid motion -+ ;; -+ -+ restart) -+ $0 restart-motion -+ exit $? -+ ;; -+ -+ *) -+ echo "Usage: /etc/init.d/$NAME {start|stop|status|reload-config|restart}" -+ exit 1 -+ ;; -+esac -+ -+if [ $? == 0 ]; then -+ echo . -+ exit 0 -+else -+ echo failed -+ exit 1 -+fi ---- /dev/null -+++ motion-3.2.12/motion.init-Fedora -@@ -0,0 +1,118 @@ -+#!/bin/bash -+# -+# motion Startup script for the Motion Detection System -+# -+# chkconfig: - 85 15 -+# description: Motion detection system. It is used to detect movement based \ -+# on compare images. -+# processname: motion -+# pidfile: /var/run/motion.pid -+# config: /etc/motion.conf -+# -+### BEGIN INIT INFO -+# Provides: motion -+# Required-Start: $local_fs -+# Required-Stop: $local_fs -+# Default-Start: -+# Default-Stop: -+# Short-Description: Start and stop motion detection system -+# Description: The Motion detection system is used to detect movement based -+# on image comparison. -+### END INIT INFO -+ -+# Source function library. -+. /etc/rc.d/init.d/functions -+ -+motion=${MOTION-/usr/bin/motion} -+prog=motion -+pidfile=/var/run/motion.pid -+lockfile=/var/lock/subsys/motion -+ -+start() { -+ [ -x $exec ] || exit 5 -+ [ -f $config ] || exit 6 -+ echo -n $"Starting $prog: " -+ # We try to determine which architecture we have so we can -+ # load libv4l to support more USB cameras. x86_64 and ppc64 -+ # are both supported by rpmfusion. -+ case $(uname -i) in -+ "x86_64" ) -+ #We load libv4l for 64 Bit x86 architectures -+ LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; -+ "ppc64" ) -+ #We load libv4l for 64 Bit PPC architectures -+ LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; -+ * ) -+ #Default case, we load libv4l for all 32 Bit architectures -+ LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; -+ esac -+ retval=$? -+ echo -+ [ $retval -eq 0 ] && touch $lockfile -+ return $retval -+} -+ -+stop() { -+ echo -n $"Stopping $prog: " -+ killproc $motion -+ retval=$? -+ echo -+ [ $retval = 0 ] && rm -f $lockfile -+} -+ -+restart() { -+ stop -+ start -+} -+ -+reload() { -+ echo -n $"Reloading $prog configuration: " -+ killproc $motion -HUP -+ retval=$? -+ echo -+ return $retval -+} -+ -+rh_status() { -+ # run checks to determine if the service is running or use generic status -+ status $prog -+} -+ -+rh_status_q() { -+ rh_status >/dev/null 2>&1 -+} -+ -+ -+# See how we were called. -+case "$1" in -+ start) -+ rh_status_q && exit 0 -+ $1 -+ ;; -+ stop) -+ rh_status_q || exit 0 -+ $1 -+ ;; -+ restart) -+ $1 -+ ;; -+ reload) -+ rh_status_q || exit 7 -+ $1 -+ ;; -+ force-reload) -+ #force_reload -+ reload -+ ;; -+ status) -+ rh_status -+ ;; -+ condrestart|try-restart) -+ rh_status_q || exit 0 -+ restart -+ ;; -+ *) -+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" -+ exit 1 -+esac -+exit $? ---- /dev/null -+++ motion-3.2.12/motion.init-FreeBSD.sh -@@ -0,0 +1,26 @@ -+#!/bin/sh -+# -+# motion.sh for rc.d usage 2006 Angel Carpintero -+# -+# Add the following line in /etc/rc.conf to enable motion at startup -+# -+# motion_enable="YES" -+# -+ -+# PROVIDE: motion -+# REQUIRE: DAEMON -+# KEYWORD: shutdown -+ -+. /etc/rc.subr -+ -+motion_enable="${motion_enable-NO}" -+ -+name="motion" -+rcvar=`set_rcvar` -+ -+command="/home/dave/motion_build/bin/${name}" -+pidfile="/var/run/${name}.pid" -+required_files="/usr/local/etc/${name}.conf" -+ -+load_rc_config $name -+run_rc_command "$1" ---- /dev/null -+++ motion-3.2.12/motion.spec -@@ -0,0 +1,134 @@ -+Name: motion -+Version: 3.2.12-4ppa01 -+Release: 1%{?dist} -+Summary: A motion detection system -+ -+Group: Applications/Multimedia -+License: GPLv2+ -+URL: http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome -+Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz -+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -+ -+BuildRequires: libjpeg-devel ffmpeg-devel zlib-devel -+#This requires comes from the startup script, it will be there until motion supports libv4l calls in the code -+Requires: libv4l -+Requires(post): chkconfig -+Requires(preun): chkconfig initscripts -+Requires(postun): initscripts -+ -+%description -+Motion is a software motion detector. It grabs images from video4linux devices -+and/or from webcams (such as the axis network cameras). Motion is the perfect -+tool for keeping an eye on your property keeping only those images that are -+interesting. Motion is strictly command line driven and can run as a daemon -+with a rather small footprint. This version is built with ffmpeg support but -+without MySQL and PostgreSQL support. -+ -+%prep -+%setup -q -+ -+%build -+%configure --sysconfdir=%{_sysconfdir}/%{name} --without-optimizecpu --with-ffmpeg --without-mysql --without-pgsql -+make %{?_smp_mflags} -+ -+%install -+rm -rf %{buildroot} -+make install DESTDIR=%{buildroot} -+#We rename the configuration file -+mv %{buildroot}%{_sysconfdir}/%{name}/motion-dist.conf %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+#We change the PID file path to match the one in the startup script -+sed -i 's|/var/run/motion/motion.pid|/var/run/motion.pid|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+#We remove SQL directives in the configuration file, as we don't use them -+sed -i 's|sql_log_image|; sql_log_image|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+sed -i 's|sql_log_snapshot|; sql_log_snapshot|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+sed -i 's|sql_log_mpeg|; sql_log_mpeg|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+sed -i 's|sql_log_timelapse|; sql_log_timelapse|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+sed -i 's|sql_query|; sql_query|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+#We set the log file and target directory - logging is for 3.3 branch -+sed -i 's|;logfile|logfile /var/log/motion.log|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+sed -i 's|target_dir /usr/local/apache2/htdocs/cam1|target_dir /var/motion|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+#We install our startup script -+install -D -m 0755 motion.init-Fedora %{buildroot}%{_initrddir}/%{name} -+ -+%post -+#We add the motion init script to the services when installing -+/sbin/chkconfig --add %{name} -+ -+%preun -+#We stop the service and remove it from init scripts when erasing -+if [ $1 = 0 ] ; then -+ /sbin/service %{name} stop >/dev/null 2>&1 -+ /sbin/chkconfig --del %{name} -+fi -+ -+%postun -+#We restart the service during an upgrade -+if [ "$1" -ge "1" ] ; then -+ /sbin/service %{name} condrestart >/dev/null 2>&1 -+fi -+ -+%clean -+rm -rf %{buildroot} -+ -+%files -+#Permissions are bogus upstream, we need to be sure to set them here -+%defattr (-,root,root,-) -+%dir %{_sysconfdir}/%{name} -+%dir %{_datadir}/%{name}-%{version} -+%dir %{_datadir}/%{name}-%{version}/examples -+%doc CHANGELOG COPYING CREDITS INSTALL README motion_guide.html -+%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/motion-dist.conf -+%attr(0755,root,root) %{_datadir}/%{name}-%{version}/examples/motion.init-Debian -+%attr(0755,root,root) %{_datadir}/%{name}-%{version}/examples/motion.init-FreeBSD.sh -+%attr(0755,root,root) %{_datadir}/%{name}-%{version}/examples/motion.init-Fedora -+%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread1.conf -+%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread2.conf -+%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread3.conf -+%attr(0644,root,root) %{_datadir}/%{name}-%{version}/examples/thread4.conf -+%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/motion.conf -+%attr(0755,root,root) %{_bindir}/motion -+%attr(0644,root,root) %{_mandir}/man1/motion.1* -+%attr(0755,root,root) %{_initrddir}/%{name} -+ -+%changelog -+* Thu Mar 06 2010 Steven Moix - 3.2.12-1 -+- New upstream release, important bugfixes only -+ -+* Wed Oct 21 2009 Thorsten Leemhuis - 3.2.11.1-3 -+- rebuild for new ffmpeg -+ -+* Tue Aug 11 2009 Steven Moix - 3.2.11.1-1 -+- Drop patch for ffmpeg 0.5 compatibility -+- Drop ffmpeg detection patch -+- Moved default output directory to /var/motion -+- New startup script with added v4l2convert to support more cameras - https://bugzilla.rpmfusion.org/show_bug.cgi?id=681 -+- Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) -+- Fix fd leaks in external pipe -+- Avoid possible stack smashing in v4l_open_vidpipe() -+- Fix segfault for new libjpeg v7 -+ -+* Mon Jul 06 2009 Steven Moix - 3.3.0-1 -+- SPEC Preparation for the 3.3 branch -+ -+* Sun Jun 05 2009 Steven Moix - 3.2.11-5 -+- Patch and rebuild for ffmpeg 0.5 -+ -+* Sun Mar 29 2009 Thorsten Leemhuis - 3.2.11-4 -+- rebuild for new F11 features -+ -+* Wed Mar 18 2009 Steven Moix - 3.2.11-3 -+- Even more corrected init script thanks to Stewart Adam -+ -+* Sun Mar 15 2009 Steven Moix - 3.2.11-2 -+- Removed the ffmpeg requires -+- Corrected the spec file -+- New init script with a corrected start() function and LSB header support -+ -+* Tue Mar 03 2009 Steven Moix - 3.2.11-1 -+- Updated to Fedora 10 standard -+ -+* Sun Sep 18 2005 Kenneth Lavrsen - 3.2.4-1 -+- Generic version of livna spec file replacing the old less optimal specfile. -+ -+* Thu Sep 15 2005 Dams - 3.2.3-0.lvn.1 -+- Initial released based upon upstream spec file ---- motion-3.2.12.orig/motion.spec.in -+++ motion-3.2.12/motion.spec.in -@@ -5,7 +5,7 @@ Summary: A motion detection syste - - Group: Applications/Multimedia - License: GPLv2+ --URL: http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome -+URL: http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome - Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz - BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -@@ -45,7 +45,7 @@ sed -i 's|sql_log_mpeg|; sql_log_mpeg|g' - sed -i 's|sql_log_timelapse|; sql_log_timelapse|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf - sed -i 's|sql_query|; sql_query|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf - #We set the log file and target directory - logging is for 3.3 branch --#sed -i 's|;logfile|logfile /var/log/motion.log|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf -+sed -i 's|;logfile|logfile /var/log/motion.log|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf - sed -i 's|target_dir /usr/local/apache2/htdocs/cam1|target_dir /var/motion|g' %{buildroot}%{_sysconfdir}/%{name}/motion.conf - #We install our startup script - install -D -m 0755 motion.init-Fedora %{buildroot}%{_initrddir}/%{name} ---- motion-3.2.12.orig/motion_guide.html -+++ motion-3.2.12/motion_guide.html -@@ -1,13 +1,13 @@ --

                                                            Motion Guide - One Large Document.

                                                            -+

                                                            Motion Guide - One Large Document.

                                                            - This version of the Guide is made for inclusion in the Motion download package for off line reading. -

                                                            --If you read this document from the distribution package of Motion or from some not up to date mirror you should know that the URL for the always up to date version is http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide. If you are already on the Foswiki based Motion site clicking the link just mentioned will lead you to the index page for the Motion Guide documents. -+If you read this document from the distribution package of Motion or from some not up to date mirror you should know that the URL for the always up to date version is http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide. If you are already on the new TWiki based Motion site clicking the link just mentioned will lead you to the index page for the Motion Guide documents. -


                                                            - This topic consists of the following subtopics: --MotionOverview, KnownProblems, InstallOverview, PrepareInstall, ConfigureScript, MakeInstall, UpgradingFromOlderVersion, RunningMotionConfigFiles, CommandLineOptions, ConfigFileOptions, SignalsKill, ErrorLogging, CaptureDeviceOptions, MotionDetectionSettings, ImageFileOutput, TuningMotion, MpegFilmsFFmpeg, SnapshotsWebCam, TextFeatures, AdvancedFilenames, ConversionSpecifiers, WebcamServer, RemoteControlHttp, ExternalCommands, TrackingControl, UsingDatabases, LoopbackDevice. -+MotionOverview, KnownProblems, InstallOverview, PrepareInstall, ConfigureScript, MakeInstall, UpgradingFromOlderVersion, RunningMotionConfigFiles, CommandLineOptions, ConfigFileOptions, SignalsKill, ErrorLogging, CaptureDeviceOptions, MotionDetectionSettings, ImageFileOutput, TuningMotion, MpegFilmsFFmpeg, SnapshotsWebCam, TextFeatures, AdvancedFilenames, ConversionSpecifiers, WebcamServer, RemoteControlHttp, ExternalCommands, TrackingControl, UsingDatabases, LoopbackDevice. -
                                                            -

                                                            --

                                                              -+
                                                                -
                                                              • Motion Guide - Installation -
                                                              • Motion Detection Settings -
                                                              • External Commands
                                                                  --
                                                                • on_area_detected --
                                                                • on_camera_lost --
                                                                • on_event_end -+
                                                                • on_event_end -
                                                                • on_event_start -
                                                                • on_motion_detected -
                                                                • on_movie_end -@@ -205,10 +201,10 @@ This topic consists of the following sub -

                                                                  -

                                                                  Motion Guide - Installation

                                                                  -

                                                                  --

                                                                  Motion Overview

                                                                  -+

                                                                  Motion Overview

                                                                  -

                                                                  --

                                                                  What is Motion?

                                                                  -- Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. Or in other words, it can detect motion. -+

                                                                  What is Motion?

                                                                  -+Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. Or in other words, it can detect motion. -

                                                                  - The program is written in C and is made for the Linux operating system. -

                                                                  -@@ -218,18 +214,18 @@ The output from motion can be: -

                                                                    -
                                                                  • jpg files -
                                                                  • ppm format files --
                                                                  • mpeg video sequences -+
                                                                  • mpeg video sequences -
                                                                  -

                                                                  -

                                                                  How do I get Motion and what does it cost?

                                                                  -- Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project. -+Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project. -

                                                                  -

                                                                  Maintenance and Support

                                                                  -- Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day. -+Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day. -

                                                                  --To get motion direct your browser to the Motion Homepage. -+To get motion direct your browser to the Motion Homepage. -

                                                                  --On the Download Files page you will find a links to the latest stable version both as sources and binaries for some of the most popular Linux distributions. You will also find links to development versions. Snapshot releases are special test releases that are normally very stable. Every day a Motion Daily Source Snap is created from the Motion Subversion -+On the Download Files page you will find a links to the latest stable version both as sources and binaries for some of the most popular Linux distributions. You will also find links to development versions. Snapshot releases are special test releases that are normally very stable. Every day a Motion Daily Source Snap is created from the Motion Subversion -

                                                                  - Motion was originally written by Jeroen Vreeken who still actively participates in the development of Motion and later Folkert van Heusden continued as a lead programmer with Kenneth Lavrsen responsible for Motion Guide, website and releases on Sourceforge. -

                                                                  -@@ -238,14 +234,14 @@ From version 3.1.12 Motion is now projec - For support we encourage you to join the mailing list instead of writing to Jeroen, Folkert or Kenneth directly. We are all very active on the mailing list and by using the mailing list much more users will have benefit of the answers. Newbies and stupid questions are welcome on the list. Contributions in the form of patches are also very welcome on the mailing list. -

                                                                  -

                                                                  Which version to download and use?

                                                                  -- Versions 3.2.X are the current version. There is at the moment no development branch. The versions 3.1.X ended at 3.1.20 and there will be no more 3.1.X releases. If you use use a version older than 3.2.X you are encouraged to update. -+Versions 3.2.X are the current version. There is at the moment no development branch. The versions 3.1.X ended at 3.1.20 and there will be no more 3.1.X releases. If you use use a version older than 3.2.X you are encouraged to update. -

                                                                  --Since 3.1.13 quite many options have been renamed to make setting up Motion easier. From 3.1.17-18 some unfinished features have been removed. The Berkeley mpeg feature is now removed because the ffmpeg feature is now mature and much better working. At version 3.1.18 a new network camera feature was introduced replacing the old cURL based netcam code and introducing support of mjpeg streaming cameras. However this new code was quite difficult to get stable. During the development of 3.2.2 the network camera code was totally rewritten again learning from our experience and now finally it seems to be stable. -+Since 3.1.13 quite many options have been renamed to make setting up Motion easier. From 3.1.17-18 some unfinished features have been removed. The Berkeley mpeg feature is now removed because the ffmpeg feature is now mature and much better working. At version 3.1.18 a new network camera feature was introduced replacing the old cURL based netcam code and introducing support of mjpeg streaming cameras. However this new code was quite difficult to get stable. During the development of 3.2.2 the network camera code was totally rewritten again learning from our experience and now finally it seems to be stable. -

                                                                  --Motion is included in Debian, while Ubuntu and RPM users can find binary packages on the Motion Sourceforge file download page. -+Since 3.2.3 Debian users can find binary packages on the Motion Sourceforge file download page. You can find Debian versions of Motion in different Debian repositories but they are all out of date and hardly ever get updated. -

                                                                  --

                                                                  What features does Motion have?

                                                                  -- See more description at the Motion Homepage.
                                                                    -+

                                                                    What features does Motion have?

                                                                    -+See more description at the Motion Homepage.
                                                                      -
                                                                    • Taking snapshots of movement -
                                                                    • Watch multiple video devices at the same time -
                                                                    • Watch multiple inputs on one capture card at the same time -@@ -253,63 +249,65 @@ Motion is included in Debian, while Ubun -
                                                                    • Real time creation of mpeg movies using libraries from ffmpeg -
                                                                    • Take automated snapshots on regular intervals -
                                                                    • Take automated snapshots at irregular intervals using cron --
                                                                    • Executing external program when detecting movement --
                                                                    • Execute external program at the beginning of an event of several motion detections. -+
                                                                    • Executing external program when detecting movement -+
                                                                    • Execute external program at the beginning of an event of several motion detections. -
                                                                    • Execute external program at the end of an event of several motion detections. --
                                                                    • Execute external program when a picture is saved. --
                                                                    • Execute external program when a movie mpeg is created (opened) -+
                                                                    • Execute external program when a picture is saved. -+
                                                                    • Execute external program when a movie mpeg is created (opened) -
                                                                    • Execite external program when a movie mpeg ends (closed) -
                                                                    • Motion tracking -
                                                                    • Feed events to an MySQL or PostgreSQL database. -
                                                                    • Feed video back to a video4linux loopback for real time viewing --
                                                                    • Web interface using Motion Related Projects such as motion.cgi, Kenneths Webcam Package, Kevins Webpage, X-Motion and many more. --
                                                                    • User configurable and user defined on screen display. --
                                                                    • Control via simple web interface. --
                                                                    • Automatic noise and threshold control --
                                                                    • Ability to control the pan/tilt of a Logitech Sphere (or Orbit) camera --
                                                                    • Highly configurable display of text on images. --
                                                                    • High configurable definition of path and file names of the stored images and films. -+
                                                                    • Web interface using Motion Related Projects such as motion.cgi, Kenneths Webcam Package, Kevins Webpage, X-Motion and many more. -+
                                                                    • User configurable and user defined on screen display. -+
                                                                    • Control via simple web interface. -+
                                                                    • Automatic noise and threshold control -+
                                                                    • Ability to control the pan/tilt of a Logitech Sphere (or Orbit) camera -+
                                                                    • Highly configurable display of text on images. -+
                                                                    • High configurable definition of path and file names of the stored images and films. -
                                                                    -

                                                                    --You can find more information and links at the Motion Homepage. -+You can find more information and links at the Motion Homepage. -

                                                                    --

                                                                    FreeBSD

                                                                    -+

                                                                    FreeBSD

                                                                    -

                                                                    --Motion is originally developed for Linux and it is still mainly developed and supported for this platform. From version 3.1.15 an experimental port has been made by Angel Carpintero. Not all features of Motion are supported at this time and it still needs a lot of test time on different hardware. Angel is very interested in feedback. Join the Motion Mailing List and give your feedback there. Patches for bugfixes and for enabling the missing features are very welcome. The rest of this guide is still mainly targeted for Linux users. Follow this topic to Install FreeBSD. -+Motion is originally developed for Linux and it is still mainly developed and supported for this platform. From version 3.1.15 an experimental port has been made by Angel Carpintero. Not all features of Motion are supported at this time and it still needs a lot of test time on different hardware. Angel is very interested in feedback. Join the Motion Mailing List and give your feedback there. Patches for bugfixes and for enabling the missing features are very welcome. The rest of this guide is still mainly targeted for Linux users. Follow this topic to Install FreeBSD. -

                                                                    --

                                                                    MacOSX

                                                                    -+

                                                                    MacOSX

                                                                    -

                                                                    --From Motion version 3.2.4 it is now also possible to build and install Motion under MacOSX. Feature set it the same as for FreeBSD. See the MacOSX topic for specific help how to install Motion and its dependencies on MacOSX. Again this port has been contributed by Angel Carpintero. -+From Motion version 3.2.4 it is now also possible to build and install Motion under MacOSX. Feature set it the same as for FreeBSD. See the MacOSX topic for specific help how to install Motion and its dependencies on MacOSX. Again this port has been contributed by Angel Carpintero. -

                                                                    -

                                                                    Documentation

                                                                    -- You have the following sources of information: -+You have the following sources of information: -

                                                                    -

                                                                    -

                                                                    Supported Hardware

                                                                    -- Input devices: Here we are thinking about the cameras. -+Input devices: Here we are thinking about the cameras. -

                                                                    - Motion supports video input from two kinds of sources. -

                                                                    - Standard video4linux devices (e.g. /dev/video0). Motion has no drivers for cameras. Installing the camera itself is outside the scope of this document. But here are some nice links.

                                                                    -+Network cameras (which are actually cameras with a built in web server that can be connected directory to your network). -

                                                                    -

                                                                    --

                                                                    Known Problems

                                                                    --See also the Frequently Asked Questions and Bug Reports for known open bugs. -+

                                                                    Known Problems

                                                                    -+See also the Frequently Asked Questions and Bug Reports for known open bugs. -

                                                                    --Kernel 2.6 and pwc. Note that for kernel 2.6 there is a new release of the Philips WebCam (pwc) drivers 10.0.X. It is recommended to install this. At the time of this being written the 2.6.12+ kernels have a version of pwc built-in but it is a cripled version which can only support very small picture size. You can however download the latest source code of the pwc driver (at this time 10.0.11) and build it without having to rebuild your kernel. But you will need to have either the kernel sources or a special kernel-header package installed to compile it. See Installation of PWC page which is also hosted in this wiki. -+Kernel 2.6 and pwc. Note that for kernel 2.6 there is a new release of the Philips WebCam (pwc) drivers 10.0.X. It is recommended to install this. At the time of this being written the 2.6.12+ kernels have a version of pwc built-in but it is a cripled version which can only support very small picture size. You can however download the latest source code of the pwc driver (at this time 10.0.11) and build it without having to rebuild your kernel. But you will need to have either the kernel sources or a special kernel-header package installed to compile it. See Installation of PWC page which is also hosted in this wiki. -

                                                                    - If you use use a Logitech Quickcam Orbit or Sphere using the driver pwc/pwcx and kernel 2.6.X you should replace the file in the Motion sources called pwc-ioctl.h with the one that comes with the your pwc version. Motion is shipped with 3 versions of pwc-ioctl.h-VERSION. Rename the one that fits your major pwc version number best to pwc-ioctl.h (after renaming the current to something else). There has been some small adjustments in the API that requires that you have the right header file. -

                                                                    -@@ -323,8 +321,7 @@ The 3.2.5 release contains a motion_guid - A bug in 3.2.5 and 3.2.5.1 where a bugfix related to snapshot feature has created a new bug when you compile Motion without ffmpeg libs installed. This is fixed in 3.2.6. -

                                                                    -

                                                                    --

                                                                    --

                                                                    How do I install Motion?

                                                                    -+

                                                                    How do I install Motion?

                                                                    - Motion is mainly distributed as source files that you must compile yourself. There is also an RPM made on Fedora Core 3. And Debian packages are available for selected versions. -

                                                                    - The short overview of the steps to install Motion from sources.

                                                                      -@@ -389,60 +386,28 @@ motion -
                                                                    -

                                                                    -

                                                                    --

                                                                    Preparation For Install

                                                                    -+

                                                                    Preparation For Install

                                                                    -

                                                                    --Note: If you're using SuSE 9.2, you might want to ADDITIONALLY have a look at Compiling on SuSE 9.2. As mentioned on that page as well, you will still need to read the instructions here as well. -+Note: If you're using SuSE 9.2, you might want to ADDITIONALLY have a look at Compiling on SuSE 9.2. As mentioned on that page as well, you will still need to read the instructions here as well. -

                                                                    - Before you start you may need to install a number of shared libraries that Motion uses. If they are missing the feature will simply normally not be included. Most of these libraries can be found on the CDs of your distribution. A few will have to be downloaded from the Internet. Note that when you install software using pre-compiled binaries (Redhat type RPMs, Debian debs etc) you normally only get what is needed to run the programs themselves. In order to compile other programs from source that uses these pre-compiled libraries you also need to installed the development packages. These are normally called the same name as the package suffixed by -devel or -dev. These development packages contains the header files (xxx.h) that Motion needs to build with the shared libraries. If you build a library from sources you already have these header files. It is recommended to simply install the pre-compiled binary packages and their development brothers. -

                                                                    - This is a list of shared libraries used by Motion and the RPM packages that provides them. -

                                                                    - Motion will always need these libraries to be built and work -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                                    Library RPM Packages Debian Packages
                                                                    libm, libresolv, libdl, libpthread, libc, ld-linux, libcrypt, and libnsl glibc and glibc-devel libc6 , libc6-dev ,libglib1.2
                                                                    libjpeg libjpeg and libjpeg-devel libjpeg62 and libjpeg62-dev ( optional libjpeg-mmx-dev )
                                                                    libz zlib and zlib-devel zlib1g and zlib1g-dev
                                                                    -+ -+ -+ -+ -+
                                                                    Library RPM Packages Debian Packages
                                                                    libm, libresolv, libdl, libpthread, libc, ld-linux, libcrypt, and libnsl glibc and glibc-devel libc6 , libc6-dev ,libglib1.2
                                                                    libjpeg libjpeg and libjpeg-devel libjpeg62 and libjpeg62-dev ( optional libjpeg-mmx-dev )
                                                                    libz zlib and zlib-devel zlib1g and zlib1g-dev
                                                                    -

                                                                    - For generating mpeg films with ffmpeg you need this library:
                                                                    --(See also the section Generating MPEG films with ffmpeg for how to install ffmpeg and libavformat/libavcodec)
                                                                    -+(See also the section Generating MPEG films with ffmpeg for how to install ffmpeg and libavformat/libavcodec)
                                                                    - Motion must be installed with revision 0.4.8 or 0.4.9pre1 of ffmpeg. Motion will also work with later CVS snapshots of ffmpeg but the API of the ffmpeg libraries changes all the time and without warning. If you have problems compiling Motion or with running an RPM of Motion you may try with an older CVS snapshot of ffmpeg. The Motion developers will like to know when ffmpeg changes and breaks Motion so we can fix it. Please file a bug report then with the exact date of the ffmpeg CVS version you have trouble with. -

                                                                    -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                                    Library RPM Packages Debian Packages
                                                                    libavcodec, libavformat ffmpeg and ffmpeg-devel or install from source libavcodec-dev libavcodec0d libavformat-dev libavformat0d (*)
                                                                    -+ -+ -+
                                                                    Library RPM Packages Debian Packages
                                                                    libavcodec, libavformat ffmpeg and ffmpeg-devel or install from source libavcodec-dev libavcodec0d libavformat-dev libavformat0d (*)
                                                                    -

                                                                    - Debian has not provided deb packages for ffmpeg due patent issues. However this is about to change so checkout for availability of newer versions of debian ffmpeg debs. You can build yourself from source or from Christian Marillat website or apt repository. -

                                                                    -@@ -457,41 +422,17 @@ apt-get update ; apt-get -y install liba
                                                                    - 
                                                                    -

                                                                    - For logging in MySQL you need this library: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                                    Library RPM Packages Debian Packages
                                                                    libmysqlclient mysql and mysql-devel libmysqlclient15-off and libmysqlclient15-dev
                                                                    -+ -+ -+
                                                                    Library RPM Packages Debian Packages
                                                                    libmysqlclient mysql and mysql-devel libmysqlclient15-off and libmysqlclient15-dev
                                                                    -

                                                                    - For logging in PostgreSQL you need this library: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                                    Library RPM Packages Debian Packages
                                                                    libpq postgresql-libs and postgresql-devel libpq-dev and libpq4
                                                                    -+ -+ -+
                                                                    Library RPM Packages Debian Packages
                                                                    libpq postgresql-libs and postgresql-devel libpq-dev and libpq4
                                                                    -

                                                                    -

                                                                    --

                                                                    Configure Script

                                                                    -+

                                                                    Configure Script

                                                                    - Configure is script that you run to setup the build environment for the C-compiler. It generates the "Makefile" which the program "make" uses to compile and install the software. -

                                                                    - To run configure your current directory must be the motion directory. You type -@@ -503,238 +444,61 @@ You can add the parameter ./config - This is walk through of the options. -

                                                                    - --

                                                                    --
                                                                    -+ -+
                                                                    - - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                                    Option Description
                                                                    Defaults for the options
                                                                    are specified in brackets [ ]
                                                                    Editors comment
                                                                    -h, --help display this help and exit  
                                                                    --help=short display options specific to this package This command shows the options special to motion. Recommended
                                                                    --help=recursive display the short help of all the included packages  
                                                                    -V, --version display version information and exit Gives no useful information
                                                                    -q, --quiet, --silent do not print `checking...' messages Not very useful. Output to screen is only a few lines anyway.
                                                                    --cache-file=FILE cache test results in FILE. [disabled] No function
                                                                    -C, --config-cach alias for `--cache-file=config.cache' No function
                                                                    -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk
                                                                    --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory.
                                                                    Installation directories:    
                                                                    --prefix=PREFIX install architecture-independent files in PREFIX
                                                                    [/usr/local]
                                                                    The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
                                                                    If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                                    This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                                    If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                                    Example: --prefix=$HOME
                                                                    --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
                                                                    [PREFIX]
                                                                    If you set this it only defines an alternative installation directory for the executable binary.
                                                                    Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
                                                                    Editor recommends leaving this as default (i.e. not setting it).
                                                                    --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control.
                                                                    --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it.
                                                                    --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it.
                                                                    --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it.
                                                                    --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
                                                                    Motion searches for the configuration file "motion.conf" in the following order:

                                                                      1. Current directory from where motion was invoked
                                                                      2. $HOME/.motion
                                                                      3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/

                                                                    Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again.
                                                                    --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it.
                                                                    --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it.
                                                                    --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it.
                                                                    --includedir=DIR C header files [PREFIX/include] Not used by motion. Ignore it.
                                                                    --oldincludedir=DIR C header files for non-gcc [/usr/include] Not used by motion. Ignore it.
                                                                    --infodir=DIR info documentation [PREFIX/info] Not used by motion. Ignore it.
                                                                    --mandir=DIR man documentation [PREFIX/man] Editor recommends the default.
                                                                    Optional Packages:    
                                                                    --with-linuxthreads Use linuxthreads in BSD instead of native phtreads Only relevant for BSD. In Linux we always use this per default.
                                                                    --with-pwcbsd Use pwcbsd based webcams ( only BSD ) This option allow to build motion to support V4L/V4L2 in BSD.
                                                                    HowtoMotionPwcFreeBSD
                                                                    --without-bktr Exclude to use bktr subsystem , that usually useful for devices as network cameras ONLY used in *BSD
                                                                    --without-v4l Exclude using v4l (video4linux) subsystem. Makes Motion so it only supports network cameras. Can be used if you do not need V4L support and maybe lack some of the libraries for it.
                                                                    --with-jpeg-mmx=DIR Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling (optional). If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. Considered experimental
                                                                    --with-ffmpeg=DIR Specify the path for the directory prefix in which the library and headers are installed.
                                                                    If not specified configure will search in /usr/ and /usr/local/
                                                                    DIR is the directory PREFIX in which the ffmpeg shared libraries and their headers are installed.
                                                                    If you install ffmpeg from sources and use the default directories or if ffmpeg is installed as a binary package (RPM or deb) you do not need to specify the directory prefix. Configure will find the libraries automatically. If you installed ffmpeg from sources and specified a different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR).
                                                                    For more information on FFmpeg see the FFmpeg project home page.
                                                                    FFmpeg is a package that enables streamed video mpeg signal from your web camera to a browser.
                                                                    Editor recommends installing ffmpeg from source and in the directory /usr/local/ffmpeg and build ffmpeg with ./configure --enable-shared.
                                                                    This places libraries in /usr/local/lib and headers in /usr/local/include.
                                                                    --without-ffmpeg Do not compile with ffmpeg Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg.
                                                                    --with-mysql-lib=DIR Lib directory of MySQL Normally, configure will scan all possible default installation paths for MySQL libs. When its fail, use this command to tell configure where MySQL libs installation root directory is.
                                                                    --with-mysql-include=DIR Include directory with headers for MySQL Normally, configure will scan all possible default installation paths for MySQL include. When its fail, use this command to tell configure where MySQL include installation directory is. This is the directory with the MySQL header files.
                                                                    --without-mysql Do not compile with MySQL support Use this if you do not want to include MySQL support in the package.
                                                                    This can also be useful if you get compilation errors related to MySQL and you actually do not need the feature anyway.
                                                                    --without-pgsql Do not compile with PostgreSQL support Use this if you do not want to include PostgreSQL support in the package.
                                                                    This can also be useful if you get compilation errors related to PostgreSQL and you actually do not need the feature anyway.
                                                                    --with-pgsql-include=DIR Normally, configure will scan all possible default installation paths for pgsql include. When it fails, use this command to tell configure where pgsql include installation root directory is.  
                                                                    --with-pgsql-lib=DIR Normally, configure will scan all possible default installation paths for pgsql libs. When it fails, use
                                                                    this command to tell configure where pgsql libs installation root directory is.
                                                                     
                                                                    --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. Use this if the optimization causes problems. Typically if you build on some non X386 compatible CPU.
                                                                    Developers options    
                                                                    --with-developer-flags Add additional warning flags for the compiler. This option is for developers only. It produces a flood of warnings that helps the developer to write more robust code. These warnings are normally harmless but can sometimes be a latent defect.
                                                                    For more information about these flags, see CompileWithDeveloperFlags
                                                                    -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
                                                                    Option Description
                                                                    Defaults for the options
                                                                    are specified in brackets [ ]
                                                                    Editors comment
                                                                    -h, --help display this help and exit  
                                                                    --help=short display options specific to this package This command shows the options special to motion. Recommended
                                                                    --help=recursive display the short help of all the included packages  
                                                                    -V, --version display version information and exit Gives no useful information
                                                                    -q, --quiet, --silent do not print `checking...' messages Not very useful. Output to screen is only a few lines anyway.
                                                                    --cache-file=FILE cache test results in FILE. [disabled] No function
                                                                    -C, --config-cach alias for `--cache-file=config.cache' No function
                                                                    -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk
                                                                    --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory.
                                                                    Installation directories:    
                                                                    --prefix=PREFIX install architecture-independent files in PREFIX
                                                                    [/usr/local]
                                                                    The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
                                                                    If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                                    This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                                    If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                                    Example: --prefix=$HOME
                                                                    --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
                                                                    [PREFIX]
                                                                    If you set this it only defines an alternative installation directory for the executable binary.
                                                                    Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
                                                                    Editor recommends leaving this as default (i.e. not setting it).
                                                                    --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control.
                                                                    --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it.
                                                                    --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it.
                                                                    --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it.
                                                                    --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
                                                                    Motion searches for the configuration file "motion.conf" in the following order:

                                                                      1. Current directory from where motion was invoked
                                                                      2. $HOME/.motion
                                                                      3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/

                                                                    Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again.
                                                                    --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it.
                                                                    --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it.
                                                                    --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it.
                                                                    --includedir=DIR C header files [PREFIX/include] Not used by motion. Ignore it.
                                                                    --oldincludedir=DIR C header files for non-gcc [/usr/include] Not used by motion. Ignore it.
                                                                    --infodir=DIR info documentation [PREFIX/info] Not used by motion. Ignore it.
                                                                    --mandir=DIR man documentation [PREFIX/man] Editor recommends the default.
                                                                    Optional Packages:    
                                                                    --with-ffmpeg=DIR Specify the path for the directory prefix in which the library and headers are installed.
                                                                    If not specified configure will search in /usr/ and /usr/local/
                                                                    DIR is the directory PREFIX in which the ffmpeg shared libraries and their headers are installed.
                                                                    If you install ffmpeg from sources and use the default directories or if ffmpeg is installed as a binary package (RPM or deb) you do not need to specify the directory prefix. Configure will find the libraries automatically. If you installed ffmpeg from sources and specified a different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR).
                                                                    For more information on FFmpeg see the FFmpeg project home page.
                                                                    FFmpeg is a package that enables streamed video mpeg signal from your web camera to a browser.
                                                                    Editor recommends installing ffmpeg from source and in the directory /usr/local/ffmpeg and build ffmpeg with ./configure --enable-shared.
                                                                    This places libraries in /usr/local/lib and headers in /usr/local/include.
                                                                    --without-ffmpeg Do not compile with ffmpeg Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg.
                                                                    --with-mysql-lib=DIR Lib directory of MySQL Normally, configure will scan all possible default installation paths for MySQL libs. When its fail, use this command to tell configure where MySQL libs installation root directory is.
                                                                    --with-mysql-include=DIR Include directory with headers for MySQL Normally, configure will scan all possible default installation paths for MySQL include. When its fail, use this command to tell configure where MySQL include installation directory is. This is the directory with the MySQL header files.
                                                                    --without-mysql Do not compile with MySQL support Use this if you do not want to include MySQL support in the package.
                                                                    This can also be useful if you get compilation errors related to MySQL and you actually do not need the feature anyway.
                                                                    --with-pgsql=DIR Include PostgreSQL support. DIR is the PostgreSQL base install directory, defaults to /usr/local/pgsql.
                                                                    Set DIR to "shared" to build as a dynamic library, or "shared,DIR" to build as a dynamic library and still specify DIR.
                                                                    Default is that make searches in the normal installation directories of most distributions.
                                                                    See section later about PostgreSQL about potential problem during compilation. There is an easy workaround for it.
                                                                    --without-pgsql Do not compile with PostgreSQL support Use this if you do not want to include PostgreSQL support in the package.
                                                                    This can also be useful if you get compilation errors related to PostgreSQL and you actually do not need the feature anyway.
                                                                    --without-v4l Exclude using v4l (video4linux) subsystem. Makes Motion so it only supports network cameras. Can be used if you do not need V4L support and maybe lack some of the libraries for it.
                                                                    --with-linuxthreads Use linuxthreads in BSD instead of native phtreads Only relevant for BSD. In Linux we always use this per default.
                                                                    --without-bktr Exclude to use bktr subsystem , that usually useful for devices as network cameras ONLY used in *BSD
                                                                    --with-jpeg-mmx=DIR Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling (optional). If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. Considered experimental
                                                                    --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. Use this if the optimization causes problems. Typically if you build on some non X386 compatible CPU.
                                                                    Developers options    
                                                                    --with-developer-flags Add additional warning flags for the compiler. This option is for developers only. It produces a flood of warnings that helps the developer to write more robust code. These warnings are normally harmless but can sometimes be a latent defect.
                                                                    For more information about these flags, see CompileWithDeveloperFlags
                                                                    -+ -+ -
                                                                    -

                                                                    --

                                                                    --

                                                                    Make

                                                                    -+

                                                                    Make

                                                                    - When you run make, all the C-source files are automatically compiled and linked. Just look out for error messages. -

                                                                    - Make uses a file called "Makefile" which is generated by the "configure" script you just ran. If you have special needs you can manually edit this file. Next time you run configure a new Makefile will be generated and your changes are lost. -

                                                                    --ALERT! Attention! -+ALERT! Attention! -

                                                                    - If you have run make before, you should run a make clean before running make again. This cleans out all the object files that were generated the previous time you ran make. If you do not run make clean first before you rebuild Motion you may not get the additional feature included. For example: If you built Motion without ffmpeg support and then add it later - and rebuild Motion without running make clean first - the ffmpeg feature does not get compiled into the Motion binary. -

                                                                    -@@ -775,8 +539,9 @@ The make command can be run with several - -

                                                                    -

                                                                    --

                                                                    Upgrading From Older Version

                                                                    -- If you are upgrading from motion 3.0.X or from an older version of 3.1.X you should note that many options have been removed from version 3.1.13 and forward and many new have arrived. You still have most of the old features. The options have been changed for two reasons. New more flexible features and to simplify getting started with Motion. With 3.2.1 the changes are significant. You should also note these major differences.
                                                                      -+

                                                                      Upgrading From Older Version

                                                                      -+If you are upgrading from motion 3.0.X or from an older version of 3.1.X you should note that many options have been removed from version 3.1.13 and forward and many new have arrived. You still have most of the old features. The options have been changed for two reasons. New more flexible features and to simplify getting started with Motion. With 3.2.1 the changes are significant. -+You should also note these major differences.
                                                                        -
                                                                      • The use of thread files has completely changed. Read the section "The Config Files" carefully. -
                                                                      • The mask file format has changed. Read the section about "Mask File" -
                                                                      • Pre_capture feature introduced in 3.1.12 -@@ -807,213 +572,67 @@ The make command can be run with several -
                                                                      • New feature: ffmpeg_deinterlace which can de-interlace using the ffmpeg libs (3.2.5) -
                                                                      • New feature: minimum_frame_time which enables Motion to run at frame rates below 2. minimum_gap feature was removed since this was useless and the new minimum_frame_time feature replaces it with much better function. (3.2.7) -
                                                                      • New feature: process_id_file which writes a PID file when started and removes it when stopped (3.2.7) --
                                                                      • V4L2 support with many new supported palettes : V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_UYVY (3.2.8) -+
                                                                      • V4L2 support with many new supported palettes : V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_UYVY (3.2.8) -
                                                                      • ffmpeg_video_codec allow swf (3.2.8) --
                                                                      • V4L2 fix support for : V4L2_PIX_FMT_MJPEG (3.2.9) -+
                                                                      • V4L2 fix support for : V4L2_PIX_FMT_MJPEG (3.2.9) -
                                                                      • ffmpeg_video_codec allow flv and ffv1(3.2.9) --
                                                                      • v4l2_palette: allow to choose preferable palette to be use by motion to capture from those supported by your videodevice. --
                                                                      • netcam_http: setup keep_alive , 1.1 or 1.0 http method to be used by netcam. --
                                                                      • on_camera_lost: Command to be executed when a camera can't be opened or if it is lost. --
                                                                      • AreaDetect, on_area_detected: Command to be executed by area_detect trigger. --
                                                                      • ConfigOptionNetcamTolerantCheck , netcam_tolerant_check less strict jpeg checks for network cameras with a poor/buggy firmware ( 3.2.11 ). -
                                                                      -

                                                                      --The table below shows the new options in the left column, and obsolete options in the right column. If the there are options on both sides in a row it means that the options in the left column replaced the options in the right column. -

                                                                      -+The table below shows the new options in the left column, and obsolete options in the right column. If the there are options on both sides in a row it means that the options in the left column replaced the options in the right column. -

                                                                      --

                                                                      --
                                                                      -+ -+
                                                                      - - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                                      New Options Obsolete Options
                                                                      text_left (3.1.13)
                                                                      text_right (3.1.13)
                                                                      text_changes (3.1.13)
                                                                      drawtext_user (3.1.13)
                                                                      drawtext_shots (3.1.13)
                                                                      drawtext_changes (3.1.13)
                                                                      jpeg_filename (3.1.13)
                                                                      ffmpeg_filename (3.1.13)
                                                                      snapshot_filename (3.1.13)
                                                                      timelapse_filename (3.1.13)
                                                                      predict_filename (3.1.13)
                                                                      (predict_filename removed in 3.1.18)
                                                                      oldlayout (3.1.13)
                                                                      snapshots_overwrite (3.1.13)
                                                                      snapshot_interval (3.1.13) snapshots (3.1.13)
                                                                        realmotion (3.1.13)
                                                                      despeckle (3.1.13)  
                                                                      pre_capture (3.1.12)  
                                                                      ffmpeg_timelapse (v. 3.1.14) ffmpeg_timelaps (renamed v 3.1.14)
                                                                      ffmpeg_timelapse_mode (3.1.14)  
                                                                      sql_log_image (3.1.14)
                                                                      sql_log_snapshot (3.1.14)
                                                                      sql_log_mpeg (3.1.14)
                                                                      sql_log_timelapse (3.1.14)
                                                                      sql_log_prediction (3.1.14)
                                                                       
                                                                      minimum_motion_frames (3.1.14)  
                                                                      rotate (3.1.15)  
                                                                      ffmpeg_variable_bitrate (3.1.15)
                                                                      ffmpeg_video_codec (3.1.15)
                                                                       
                                                                        berkeley_single_directory (3.1.18)
                                                                      mpeg_encode (3.1.18)
                                                                      mpeg_encode_bin (3.1.18)
                                                                      adjust_rate off (3.1.18)
                                                                      jpg_cleanup (3.1.18)
                                                                        predict_filename (3.1.18)
                                                                      predict_enable (3.1.18)
                                                                      predict_threshold (3.1.18)
                                                                      predict_description (3.1.18)
                                                                      sql_log_prediction (3.1.18)
                                                                      brightness (3.1.18)
                                                                      contrast (3.1.18)
                                                                      saturation (3.1.18)
                                                                      hue (3.1.18)
                                                                       
                                                                      smart_mask_speed (3.1.18)  
                                                                      output_normal
                                                                      valid values are now "on", "off", "first" (3.1.18) and "best" (3.2.1)
                                                                       
                                                                      setup_mode (3.2.1) always_changes (3.2.1)
                                                                      locate
                                                                      valid values are now "on", "off", "preview" (3.2.1)
                                                                       
                                                                      jpeg_filename
                                                                      Besides normal path names the value "preview" has speciel meaning together with output_normal = "best" (3.2.1)
                                                                       
                                                                      control_html_output (3.2.1)  
                                                                      on_event_start (3.2.1) execute (3.2.1)
                                                                      sms (3.2.1)
                                                                      mail (3.2.1)
                                                                      on_event_end (3.2.1)  
                                                                      on_motion_detected (3.2.1)  
                                                                      on_picture_save (3.2.1) onsave (3.2.1)
                                                                      on_movie_start (3.2.1)
                                                                      on_movie_end (3.2.1)
                                                                      onmpeg (3.2.1)
                                                                      onffmpegclose (introduced 3.1.13)(renamed to on_movie_end 3.2.1)
                                                                      netcam_proxy (3.2.2)  
                                                                      text_double (3.2.2)  
                                                                      webcam_motion
                                                                      Feature has been heavily improved so it is actually usefull now (3.2.2).
                                                                       
                                                                      netcam_url
                                                                      Now also supports fetching single frame jpeg pictures via ftp using ftp:// syntax (3.2.4)
                                                                       
                                                                      track_step_angle_x (3.2.4)
                                                                      track_step_angle_y (3.2.4)
                                                                      Add better configuration of auto tracking with a Logitech Sphere/Orbit camera.
                                                                       
                                                                      track_move_wait (3.2.4)
                                                                      track_auto (3.2.4)
                                                                      Adds better configuration of auto tracking feature
                                                                       
                                                                      sql_query (3.2.4)
                                                                      Adds full flexibility of defining fields when using the SQL database features.
                                                                       
                                                                      track_maxy (3.2.5)
                                                                      track_motory (3.2.5)
                                                                       
                                                                      movie_filename (3.2.5) ffmpeg_filename (3.2.5)
                                                                      ffmpeg_deinterlace (3.2.5)  
                                                                      minimum_frame_time (3.2.7) minimum_gap (3.2.7)
                                                                      process_id_file (3.2.7)  
                                                                      ffmpeg_video_codec allow swf (3.2.8)  
                                                                      ffmpeg_video_codec allow flv and ffv1 (3.2.9)  
                                                                      v4l2_palette (3.2.10)
                                                                      netcam_http (3.2.10)
                                                                      on_camera_lost (3.2.10)
                                                                      area_detect, on_area_detected(3.2.10)
                                                                      ffmpeg_video_codec mov(3.2.10)
                                                                      output_normal center(3.2.10)
                                                                       
                                                                        night_compensate (3.2.10)
                                                                      low_cpu (3.2.10)
                                                                      netcam_tolerant_check (3.2.11)  
                                                                      -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
                                                                      New Options Obsolete Options
                                                                      text_left (3.1.13)
                                                                      text_right (3.1.13)
                                                                      text_changes (3.1.13)
                                                                      drawtext_user (3.1.13)
                                                                      drawtext_shots (3.1.13)
                                                                      drawtext_changes (3.1.13)
                                                                      jpeg_filename (3.1.13)
                                                                      ffmpeg_filename (3.1.13)
                                                                      snapshot_filename (3.1.13)
                                                                      timelapse_filename (3.1.13)
                                                                      predict_filename (3.1.13)
                                                                      (predict_filename removed in 3.1.18)
                                                                      oldlayout (3.1.13)
                                                                      snapshots_overwrite (3.1.13)
                                                                      snapshot_interval (3.1.13) snapshots (3.1.13)
                                                                        realmotion (3.1.13)
                                                                      despeckle (3.1.13)  
                                                                      pre_capture (3.1.12)  
                                                                      ffmpeg_timelapse (v. 3.1.14) ffmpeg_timelaps (renamed v 3.1.14)
                                                                      ffmpeg_timelapse_mode (3.1.14)  
                                                                      sql_log_image (3.1.14)
                                                                      sql_log_snapshot (3.1.14)
                                                                      sql_log_mpeg (3.1.14)
                                                                      sql_log_timelapse (3.1.14)
                                                                      sql_log_prediction (3.1.14)
                                                                       
                                                                      minimum_motion_frames (3.1.14)  
                                                                      rotate (3.1.15)  
                                                                      ffmpeg_variable_bitrate (3.1.15)
                                                                      ffmpeg_video_codec (3.1.15)
                                                                       
                                                                        berkeley_single_directory (3.1.18)
                                                                      mpeg_encode (3.1.18)
                                                                      mpeg_encode_bin (3.1.18)
                                                                      adjust_rate off (3.1.18)
                                                                      jpg_cleanup (3.1.18)
                                                                        predict_filename (3.1.18)
                                                                      predict_enable (3.1.18)
                                                                      predict_threshold (3.1.18)
                                                                      predict_description (3.1.18)
                                                                      sql_log_prediction (3.1.18)
                                                                      brightness (3.1.18)
                                                                      contrast (3.1.18)
                                                                      saturation (3.1.18)
                                                                      hue (3.1.18)
                                                                       
                                                                      smart_mask_speed (3.1.18)  
                                                                      output_normal
                                                                      valid values are now "on", "off", "first" (3.1.18) and "best" (3.2.1)
                                                                       
                                                                      setup_mode (3.2.1) always_changes (3.2.1)
                                                                      locate
                                                                      valid values are now "on", "off", "preview" (3.2.1)
                                                                       
                                                                      jpeg_filename
                                                                      Besides normal path names the value "preview" has speciel meaning together with output_normal = "best" (3.2.1)
                                                                       
                                                                      control_html_output (3.2.1)  
                                                                      on_event_start (3.2.1)
                                                                      execute (3.2.1)
                                                                      sms (3.2.1)
                                                                      mail (3.2.1)
                                                                      on_event_end (3.2.1)
                                                                       
                                                                      on_motion_detected (3.2.1)
                                                                       
                                                                      on_picture_save (3.2.1)
                                                                      onsave (3.2.1)
                                                                      on_movie_start (3.2.1)
                                                                      on_movie_end (3.2.1)
                                                                      onmpeg (3.2.1)
                                                                      onffmpegclose (introduced 3.1.13)(renamed to on_movie_end 3.2.1)
                                                                      netcam_proxy (3.2.2)  
                                                                      text_double (3.2.2)  
                                                                      webcam_motion
                                                                      Feature has been heavily improved so it is actually usefull now (3.2.2).
                                                                       
                                                                      netcam_url
                                                                      Now also supports fetching single frame jpeg pictures via ftp using ftp:// syntax (3.2.4)
                                                                       
                                                                      track_step_angle_x (3.2.4)
                                                                      track_step_angle_y (3.2.4)
                                                                      Add better configuration of auto tracking with a Logitech Sphere/Orbit camera.
                                                                       
                                                                      track_move_wait (3.2.4)
                                                                      track_auto (3.2.4)
                                                                      Adds better configuration of auto tracking feature
                                                                       
                                                                      sql_query (3.2.4)
                                                                      Adds full flexibility of defining fields when using the SQL database features.
                                                                       
                                                                      track_maxy (3.2.5)
                                                                      track_motory (3.2.5)
                                                                       
                                                                      movie_filename (3.2.5) ffmpeg_filename (3.2.5)
                                                                      ffmpeg_deinterlace (3.2.5)  
                                                                      minimum_frame_time (3.2.7) minimum_gap (3.2.7)
                                                                      process_id_file (3.2.7)  
                                                                      ffmpeg_video_codec allow swf (3.2.8)  
                                                                      ffmpeg_video_codec allow flv and ffv1 (3.2.9)  
                                                                        night_compensate (3.2.10)
                                                                      low_cpu (3.2.10)
                                                                      -+ -+ -
                                                                      -

                                                                      --

                                                                      --

                                                                      Running Motion

                                                                      -+

                                                                      Running Motion

                                                                      -

                                                                      -

                                                                      Important Definitions

                                                                      - Motion is invoked from the command line. It has no GUI. Everything is controlled from config files. From version 3.2 the command line is only used to define location of config file and a few special runtime modes (setup and non-daemon). -@@ -1063,75 +682,40 @@ Motion reads its configuration parameter -
    - So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. -

    --Nearly all config options can be unique for a specific camera and placed in a thread config file. There are a few options that must be in motion.conf and cannot be in a thread config file: control_authentication, control_html_output, control_localhost, control_port, daemon, and thread. -+Nearly all config options can be unique for a specific camera and placed in a thread config file. There are a few options that must be in motion.conf and cannot be in a thread config file: control_authentication, control_html_output, control_localhost, control_port, daemon, and thread. -

    - If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. -

    - If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. -

    -

    --

    Command Line Options

    -+

    Command Line Options

    -

    --ALERT! In Motion 3.2.1 and forward most command line options have been removed and replaced them by an option to specify location to motion.conf and a few options related to setting up motion. There are now only few command line options left and they are basically all new. -+ALERT! In Motion 3.2.1 and forward most command line options have been removed and replaced them by an option to specify location to motion.conf and a few options related to setting up motion. There are now only few command line options left and they are basically all new. -

    - SYNOPSIS -

    --motion [ -hns ] [ -c config file path ] [ -d level ]  [ -p process_id_file ]
    -+motion [ -hns ] [ -c config file path]
    - 
    -

    --

    --
    -+ -+
    - - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    Option Description Editors comment
    -n Run in non-daemon mode. Instead of running Motion in the background Motion runs in the terminal window writing messages when things happen. If you have problems getting Motion to start or work, run Motion in this mode to get more messages that can help you solve the problem.
    -s Run in setup mode. Also forces non-daemon mode
    -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default
    -h Show help screen.  
    -d level Debugging mode This mode is used for developers to enable debug messages. Normal users will not need to use this mode unless a developer request to get additional information in the attempt to resolve a bug. Mainly the netcam code has debugging features. The level defines how much debugging info you get. A high number displays all debugging.
    -p process_id_file Full path of process ID file Full path and filename of process id file (PID file). This is optional. If none is given as command line option or in motion.conf (process_id_file) Motion will not create a PID file.
    -- -- -- -- -+ -+ -+ -+ -+ -+ -+ -+
    Option Description Editors comment
    -n Run in non-daemon mode. Instead of running Motion in the background Motion runs in the terminal window writing messages when things happen. If you have problems getting Motion to start or work, run Motion in this mode to get more messages that can help you solve the problem.
    -s Run in setup mode. Also forces non-daemon mode
    -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default
    -h Show help screen.  
    -d level Debugging mode This mode is used for developers to enable debug messages. Normal users will not need to use this mode unless a developer request to get additional information in the attempt to resolve a bug. Mainly the netcam code has debugging features. The level defines how much debugging info you get. A high number displays all debugging.
    -p process_id_file Full path of process ID file Full path and filename of process id file (PID file). This is optional. If none is given as command line option or in motion.conf (process_id_file) Motion will not create a PID file.
    -+ -+ -
    -

    -

    --

    --

    Config File Options

    -+

    Config File Options

    - These are the options that can be used in the config file. -

    - All number values are integer numbers (no decimals allowed). Boolean options can be on or off. -@@ -1150,663 +734,138 @@ FFMPEG (libavcodec)

      -
    • ffmpeg_cap_new, ffmpeg_cap_motion, ffmpeg_filename, ffmpeg_timelapse, ffmpeg_timelapse_mode, ffmpeg_bps, ffmpeg_variable_bitrate, ffmpeg_video_codec -
    -

    --

    Options in Alphabetical Order.

    -+

    Options in Alphabetical Order.

    -

    - The table below lists all the Motion options in alphabetical order. Click on the option name to see a longer description of each. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    Option Range/Values
    Default
    Description
    area_detect Values: 1 - 999999999
    Default: Not defined
    Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area.
    auto_brightness Values: on, off
    Default: off
    Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness
    brightness Values: 0 - 255
    Default: 0 (disabled)
    The brightness level for the video device.
    contrast Values: 0 - 255
    Default: 0 (disabled)
    The contrast level for the video device.
    control_authentication Values: Max 4096 characters
    Default: Not defined
    To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file.
    control_html_output Values: on, off
    Default: on
    Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file.
    control_localhost Values: on, off
    Default: on
    Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file.
    control_port Values: 0 - 65535
    Default: 0 (disabled)
    Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file.
    daemon Values: on, off
    Default: off
    Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file.
    despeckle Values: EedDl
    Default: Not defined
    Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling.
    ffmpeg_bps Values: 0 - 9999999
    Default: 400000
    Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed.
    ffmpeg_cap_motion Values: on, off
    Default: off
    Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes.
    ffmpeg_cap_new Values: on, off
    Default: off
    Use ffmpeg libraries to encode mpeg movies in realtime.
    ffmpeg_deinterlace Values: on, off
    Default: off
    Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures.
    ffmpeg_filename (now called movie_filename) Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S
    File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution.
    ffmpeg_timelapse Values: 0 - 2147483647
    Default: 0 (disabled)
    Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
    ffmpeg_timelapse_mode Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual
    Default: daily
    The file rollover mode of the timelapse video.
    ffmpeg_variable_bitrate Values: 0, 2 - 31
    Default: 0 (disabled)
    Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst.
    ffmpeg_video_codec Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1, mov
    Default: mpeg4
    Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option.
    framerate Values: 2 - 100
    Default: 100 (no limit)
    Maximum number of frames to be captured from the camera per second.
    frequency Values: 0 - 999999
    Default: 0 (Not set)
    The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it)
    gap Values: 0 - 2147483647
    Default: 60
    Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe.
    height Values: Device Dependent
    Default: 288
    The height of each frame in pixels.
    hue Values: 0 - 255
    Default: 0 (disabled)
    The hue level for the video device.
    input Values: 0 - 7, 8 = disabled
    Default: 8 (disabled)
    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.
    jpeg_filename Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S-%q
    File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file.
    lightswitch Values: 0 - 100
    Default: 0 (disabled)
    Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity.
    locate Values: on, off, preview
    Default: off
    Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie.
    mask_file Values: Max 4095 characters
    Default: Not defined
    PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format.
    max_mpeg_time Values: 0 (infinite) - 2147483647
    Default: 3600
    The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length.
    minimum_frame_time Values: 0 - 2147483647
    Default: 0
    Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate.
    minimum_motion_frames Values: 1 - 1000s
    Default: 1
    Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5.
    motion_video_pipe Values: Max 4095 characters
    Default: Not defined
    The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set
    movie_filename Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S
    File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename.
    mysql_db Values: Max 4095 characters
    Default: Not defined
    Name of the MySQL database.
    mysql_host Values: Max 4095 characters
    Default: localhost
    IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server.
    mysql_password Values: Max 4095 characters
    Default: Not defined
    The MySQL password.
    mysql_user Values: Max 4095 characters
    Default: Not defined
    The MySQL user name.
    netcam_http Values: 1.0, keep_alive, 1.1
    Default: 1.0
    The setting for keep-alive of network socket, should improve performance on compatible net cameras. ( new in 3.2.10 )
    netcam_proxy Values: Max 4095 characters
    Default: Not defined
    URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber
    netcam_tolerant_check Values: on, off
    Default: off
    Set less strict jpeg checks for network cameras with a poor/buggy firmware.
    netcam_url Values: Max 4095 characters
    Default: Not defined
    Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera.
    netcam_userpass Values: Max 4095 characters
    Default: Not defined
    For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication.
    noise_level Values: 1 - 255
    Default: 32
    The noise level is used as a threshold for distinguishing between noise and motion.
    noise_tune Values: on, off
    Default: on
    Activates the automatic tuning of noise level.
    norm Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour)
    Default: 0 (PAL)
    Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
    on_area_detected Values: Max 4095 characters
    Default: Not defined
    Command to be executed when motion in a predefined area is detected. Check option area_detect.
    on_camera_lost Values: Max 4095 characters
    Default: Not defined
    Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10)
    on_event_end Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.
    on_event_start Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command.
    on_motion_detected Values: Max 4095 characters
    Default: Not defined
    Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command.
    on_movie_end Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
    on_movie_start Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
    on_picture_save Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
    output_all Values: on, off
    Default: off
    Picture are saved continuously as if motion was detected all the time.
    output_motion Values: on, off
    Default: off
    Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red.
    output_normal Values: on, off, first, best, center (since 3.2.10)
    Default: on
    Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored.
    pgsql_db Values: Max 4095 characters
    Default: Not defined
    Name of the PostgreSQL database.
    pgsql_host Values: Max 4095 characters
    Default: localhost
    IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server.
    pgsql_password Values: Max 4095 characters
    Default: Not defined
    The PostgreSQL password.
    pgsql_port Values: 0 - 65535
    Default: 5432
    The PostgreSQL server port number.
    pgsql_user Values: Max 4095 characters
    Default: Not defined
    The PostgreSQL user name.
    post_capture Values: 0 - 2147483647
    Default: 0 (disabled)
    Specifies the number of frames to be captured after motion has been detected.
    ppm Values: on, off
    Default: off
    Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg.
    pre_capture Values: 0 - 100s
    Default: 0 (disabled)
    Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.
    process_id_file Values: Max 4095 characters
    Default: Not defined
    File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid
    quality Values: 1 - 100
    Default: 75
    The quality for the jpeg images in percent.
    quiet Values: on, off
    Default: off
    Be quiet, don't output beeps when detecting motion.
    rotate Values: 0, 90, 180, 270
    Default: 0 (not rotated)
    Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies.
    roundrobin_frames Values: 1 - 2147483647
    Default: 1
    Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible.
    roundrobin_skip Values: 1 - 2147483647
    Default: 1
    Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe).
    saturation Values: 0 - 255
    Default: 0 (disabled)
    The colour saturation level for the video device.
    setup_mode Values: on, off
    Default: off
    Run Motion in setup mode.
    smart_mask_speed Values: 0 - 10
    Default: 0 (disabled)
    Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast.
    snapshot_filename Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S-snapshot
    File path for snapshots (jpeg or ppm) relative to target_dir.
    snapshot_interval Values: 0 - 2147483647
    Default: 0 (disabled)
    Make automated snapshots every 'snapshot_interval' seconds.
    sql_log_image Values: on, off
    Default: on
    Log to the database when creating motion triggered image file.
    sql_log_mpeg Values: on, off
    Default: off
    Log to the database when creating motion triggered mpeg file.
    sql_log_snapshot Values: on, off
    Default: on
    Log to the database when creating a snapshot image file.
    sql_log_timelapse Values: on, off
    Default: off
    Log to the database when creating timelapse mpeg file
    sql_query Values: Max 4095 characters
    Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
    SQL query string that is sent to the database. The values for each field are given by using convertion specifiers
    switchfilter Values: on, off
    Default: off
    Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection.
    target_dir Values: Max 4095 characters
    Default: Not defined = current working directory
    Target directory for picture and movie files.
    text_changes Values: on, off
    Default: off
    Turns the text showing changed pixels on/off.
    text_double Values: on, off
    Default: off
    Draw characters at twice normal size on images.
    text_event Values: Max 4095 characters
    Default: %Y%m%d%H%M%S
    This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event.
    text_left Values: Max 4095 characters
    Default: Not defined
    User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %).
    text_right Values: Max 4095 characters
    Default: %Y-%m-%d\n%T
    User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
    thread Values: Max 4095 characters
    Default: Not defined
    Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file.
    threshold Values: 1 - 2147483647
    Default: 1500
    Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling.
    threshold_tune Values: on, off
    Default: off
    Activates the automatic tuning of threshold level. ( It's broken )
    timelapse_filename Values: Max 4095 characters
    Default: %v-%Y%m%d-timelapse
    File path for timelapse mpegs relative to target_dir (ffmpeg only).
    track_auto Values: on, off
    Default: off
    Enable auto tracking
    track_iomojo_id Values: 0 - 65535
    Default: 0
    Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller.
    track_maxx Values: 0 - 65535
    Default: 0
    The maximum position for servo x.
    track_maxy Values: 0 - 65535
    Default: 0
    The maximum position for servo y.
    track_motorx Values: 0 - 65535
    Default: 0
    The motor number that is used for controlling the x-axis.
    track_motory Values: 0 - 65535
    Default: 0
    The motor number that is used for controlling the y-axis.
    track_move_wait Values: 0 - 65535
    Default: 10
    Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames.
    track_port Values: Max 4095 characters
    Default: Not defined
    This is the device name of the serial port to which the stepper motor interface is connected.
    track_speed Values: 0 - 255
    Default: 255
    Speed to set the motor to.
    track_step_angle_x Values: 0-90
    Default: 10
    Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras.
    track_step_angle_y Values: 0-40
    Default: 10
    Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras.
    track_stepsize Values: 0 - 255
    Default: 40
    Number of steps to make.
    track_type Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo)
    Default: 0 (None)
    Type of tracker.
    tunerdevice Values: Max 4095 characters
    Default: /dev/tuner0
    The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD.
    v4l2_palette Values: 0 - 8
    Default: 8
    Allow to choose preferable palette to be use by motion
    to capture from those supported by your videodevice. ( new in 3.2.10 )
    video_pipe Values: Max 4095 characters
    Default: Not defined
    The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe.
    videodevice Values: Max 4095 characters
    Default: /dev/video0 (FreeBSD: /dev/bktr0)
    The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0.
    webcam_limit Values: 0 - 2147483647
    Default: 0 (unlimited)
    Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited.
    webcam_localhost Values: on, off
    Default: on
    Limits the access to the webcam to the localhost.
    webcam_maxrate Values: 1 - 100
    Default: 1
    Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited.
    webcam_motion Values: on, off
    Default: off
    If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate.
    webcam_port Values: 0 - 65535
    Default: 0 (disabled)
    TCP port on which motion will listen for incoming connects with its webcam server.
    webcam_quality Values: 1 - 100
    Default: 50
    Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth.
    width Values: Device Dependent
    Default: 352
    The width in pixels of each frame. Valid range is camera dependent.
    --

    --

    Obsolete Options

    --

    -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    Option Range/Values
    Default
    Description
    low_cpu Values: 0 - 100
    Default: 0 (disabled)
    When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. ( DEPRECATED )
    minimum_gap Values: 0 - 2147483647
    Default: 0 (no minimum)
    The minimum time between two shots in seconds. ( DEPRECATED )
    night_compensate Values: on, off
    Default: off
    When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. ( DEPRECATED )
    --

    --

    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    Option Range/Values
    Default
    Description
    auto_brightness Values: on, off
    Default: off
    Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness
    brightness Values: 0 - 255
    Default: 0 (disabled)
    The brightness level for the video device.
    contrast Values: 0 - 255
    Default: 0 (disabled)
    The contrast level for the video device.
    control_authentication Values: Max 4096 characters
    Default: Not defined
    To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file.
    control_html_output Values: on, off
    Default: on
    Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file.
    control_localhost Values: on, off
    Default: on
    Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file.
    control_port Values: 0 - 65535
    Default: 0 (disabled)
    Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file.
    daemon Values: on, off
    Default: off
    Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file.
    despeckle Values: EedDl
    Default: Not defined
    Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling.
    ffmpeg_bps Values: 0 - 9999999
    Default: 400000
    Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed.
    ffmpeg_cap_motion Values: on, off
    Default: off
    Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes.
    ffmpeg_cap_new Values: on, off
    Default: off
    Use ffmpeg libraries to encode mpeg movies in realtime.
    ffmpeg_deinterlace Values: on, off
    Default: off
    Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures.
    ffmpeg_filename (now called movie_filename) Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S
    File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution.
    ffmpeg_timelapse Values: 0 - 2147483647
    Default: 0 (disabled)
    Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
    ffmpeg_timelapse_mode Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual
    Default: daily
    The file rollover mode of the timelapse video.
    ffmpeg_variable_bitrate Values: 0, 2 - 31
    Default: 0 (disabled)
    Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst.
    ffmpeg_video_codec Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1
    Default: mpeg4
    Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option.
    framerate Values: 2 - 100
    Default: 100 (no limit)
    Maximum number of frames to be captured from the camera per second.
    frequency Values: 0 - 999999
    Default: 0 (Not set)
    The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it)
    gap Values: 0 - 2147483647
    Default: 60
    Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe.
    height Values: Device Dependent
    Default: 288
    The height of each frame in pixels.
    hue Values: 0 - 255
    Default: 0 (disabled)
    The hue level for the video device.
    input Values: 0 - 7, 8 = disabled
    Default: 8 (disabled)
    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.
    jpeg_filename Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S-%q
    File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file.
    lightswitch Values: 0 - 100
    Default: 0 (disabled)
    Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity.
    locate Values: on, off, preview
    Default: off
    Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie.
    low_cpu Values: 0 - 100
    Default: 0 (disabled)
    When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled.
    mask_file Values: Max 4095 characters
    Default: Not defined
    PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format.
    max_mpeg_time Values: 0 (infinite) - 2147483647
    Default: 3600
    The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length.
    minimum_frame_time Values: 0 - 2147483647
    Default: 0
    Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate.
    minimum_gap Values: 0 - 2147483647
    Default: 0 (no minimum)
    The minimum time between two shots in seconds.
    minimum_motion_frames Values: 1 - 1000s
    Default: 1
    Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5.
    motion_video_pipe Values: Max 4095 characters
    Default: Not defined
    The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set
    movie_filename Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S
    File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename.
    mysql_db Values: Max 4095 characters
    Default: Not defined
    Name of the MySQL database.
    mysql_host Values: Max 4095 characters
    Default: localhost
    IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server.
    mysql_password Values: Max 4095 characters
    Default: Not defined
    The MySQL password.
    mysql_user Values: Max 4095 characters
    Default: Not defined
    The MySQL user name.
    netcam_proxy Values: Max 4095 characters
    Default: Not defined
    URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber
    netcam_url Values: Max 4095 characters
    Default: Not defined
    Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera.
    netcam_userpass Values: Max 4095 characters
    Default: Not defined
    For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication.
    night_compensate Values: on, off
    Default: off
    When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise.
    noise_level Values: 1 - 255
    Default: 32
    The noise level is used as a threshold for distinguishing between noise and motion.
    noise_tune Values: on, off
    Default: on
    Activates the automatic tuning of noise level.
    norm Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour)
    Default: 0 (PAL)
    Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
    on_event_end Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.
    on_event_start Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command.
    on_motion_detected Values: Max 4095 characters
    Default: Not defined
    Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command.
    on_movie_end Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
    on_movie_start Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
    on_picture_save Values: Max 4095 characters
    Default: Not defined
    Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
    output_all Values: on, off
    Default: off
    Picture are saved continuously as if motion was detected all the time.
    output_motion Values: on, off
    Default: off
    Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red.
    output_normal Values: on, off, first, best
    Default: on
    Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored.
    pgsql_db Values: Max 4095 characters
    Default: Not defined
    Name of the PostgreSQL database.
    pgsql_host Values: Max 4095 characters
    Default: localhost
    IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server.
    pgsql_password Values: Max 4095 characters
    Default: Not defined
    The PostgreSQL password.
    pgsql_port Values: 0 - 65535
    Default: 5432
    The PostgreSQL server port number.
    pgsql_user Values: Max 4095 characters
    Default: Not defined
    The PostgreSQL user name.
    post_capture Values: 0 - 2147483647
    Default: 0 (disabled)
    Specifies the number of frames to be captured after motion has been detected.
    ppm Values: on, off
    Default: off
    Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg.
    pre_capture Values: 0 - 100s
    Default: 0 (disabled)
    Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.
    process_id_file Values: Max 4095 characters
    Default: Not defined
    File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid
    quality Values: 1 - 100
    Default: 75
    The quality for the jpeg images in percent.
    quiet Values: on, off
    Default: off
    Be quiet, don't output beeps when detecting motion.
    rotate Values: 0, 90, 180, 270
    Default: 0 (not rotated)
    Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies.
    roundrobin_frames Values: 1 - 2147483647
    Default: 1
    Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible.
    roundrobin_skip Values: 1 - 2147483647
    Default: 1
    Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe).
    saturation Values: 0 - 255
    Default: 0 (disabled)
    The colour saturation level for the video device.
    setup_mode Values: on, off
    Default: off
    Run Motion in setup mode.
    smart_mask_speed Values: 0 - 10
    Default: 0 (disabled)
    Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast.
    snapshot_filename Values: Max 4095 characters
    Default: %v-%Y%m%d%H%M%S-snapshot
    File path for snapshots (jpeg or ppm) relative to target_dir.
    snapshot_interval Values: 0 - 2147483647
    Default: 0 (disabled)
    Make automated snapshots every 'snapshot_interval' seconds.
    sql_log_image Values: on, off
    Default: on
    Log to the database when creating motion triggered image file.
    sql_log_mpeg Values: on, off
    Default: off
    Log to the database when creating motion triggered mpeg file.
    sql_log_snapshot Values: on, off
    Default: on
    Log to the database when creating a snapshot image file.
    sql_log_timelapse Values: on, off
    Default: off
    Log to the database when creating timelapse mpeg file
    sql_query Values: Max 4095 characters
    Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
    SQL query string that is sent to the database. The values for each field are given by using convertion specifiers
    switchfilter Values: on, off
    Default: off
    Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection.
    target_dir Values: Max 4095 characters
    Default: Not defined = current working directory
    Target directory for picture and movie files.
    text_changes Values: on, off
    Default: off
    Turns the text showing changed pixels on/off.
    text_double Values: on, off
    Default: off
    Draw characters at twice normal size on images.
    text_event Values: Max 4095 characters
    Default: %Y%m%d%H%M%S
    This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event.
    text_left Values: Max 4095 characters
    Default: Not defined
    User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers (codes starting by a %).
    text_right Values: Max 4095 characters
    Default: %Y-%m-%d\n%T
    User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
    thread Values: Max 4095 characters
    Default: Not defined
    Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file.
    threshold Values: 1 - 2147483647
    Default: 1500
    Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling.
    threshold_tune Values: on, off
    Default: off
    Activates the automatic tuning of threshold level.
    timelapse_filename Values: Max 4095 characters
    Default: %v-%Y%m%d-timelapse
    File path for timelapse mpegs relative to target_dir (ffmpeg only).
    track_auto Values: on, off
    Default: off
    Enable auto tracking
    track_iomojo_id Values: 0 - 2147483647
    Default: 0
    Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller.
    track_maxx Values: 0 - 2147483647
    Default: 0
    The maximum position for servo x.
    track_maxy Values: 0 - 2147483647
    Default: 0
    The maximum position for servo y.
    track_motorx Values: -1 - 2147483647
    Default: -1
    The motor number that is used for controlling the x-axis.
    track_motory Values: -1 - 2147483647
    Default: -1
    The motor number that is used for controlling the y-axis.
    track_move_wait Values: 0 - 2147483647
    Default: 10
    Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames.
    track_port Values: Max 4095 characters
    Default: Not defined
    This is the device name of the serial port to which the stepper motor interface is connected.
    track_speed Values: 0 - 255
    Default: 255
    Speed to set the motor to.
    track_step_angle_x Values: 0-90
    Default: 10
    Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras.
    track_step_angle_y Values: 0-40
    Default: 10
    Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras.
    track_stepsize Values: 0 - 255
    Default: 40
    Number of steps to make.
    track_type Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo)
    Default: 0 (None)
    Type of tracker.
    tunerdevice Values: Max 4095 characters
    Default: /dev/tuner0
    The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD.
    video_pipe Values: Max 4095 characters
    Default: Not defined
    The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe.
    videodevice Values: Max 4095 characters
    Default: /dev/video0 (FreeBSD: /dev/bktr0)
    The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0.
    webcam_limit Values: 0 - 2147483647
    Default: 0 (unlimited)
    Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited.
    webcam_localhost Values: on, off
    Default: on
    Limits the access to the webcam to the localhost.
    webcam_maxrate Values: 1 - 100
    Default: 1
    Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited.
    webcam_motion Values: on, off
    Default: off
    If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate.
    webcam_port Values: 0 - 65535
    Default: 0 (disabled)
    TCP port on which motion will listen for incoming connects with its webcam server.
    webcam_quality Values: 1 - 100
    Default: 50
    Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth.
    width Values: Device Dependent
    Default: 352
    The width in pixels of each frame. Valid range is camera dependent.
    -

    -

    --

    Signals (sent with e.g. kill command)

    -+

    Signals (sent with e.g. kill command)

    - A signal can be sent from the command line by typing e.g. kill -s SIGHUP pid, where the last parameter is the process ID which you get by typing ps -ef ¦ grep motion. The PID is the first on the list which is the parent process for the threads. - Motion responds to the following signals: -

    -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    Signal Description Editors comment
    SIGHUP The config file will be reread. This is a very useful signal when you experiment with settings in the config file.
    SIGTERM If needed motion will create an mpeg file of the last event and exit  
    SIGUSR1 Motion will create an mpeg file of the current event.  
    -+ -+ -+ -+ -+
    Signal Description Editors comment
    SIGHUP The config file will be reread. This is a very useful signal when you experiment with settings in the config file.
    SIGTERM If needed motion will create an mpeg file of the last event and exit  
    SIGUSR1 Motion will create an mpeg file of the current event.  
    -

    -

    --

    Error Logging

    -+

    Error Logging

    - Motion reports errors to the console when it runs in non-daemon mode. And it outputs even more information when run in setup mode. -

    - Error logging has been implemented so that errors during daemon (background) mode are logged in the syslog. -@@ -1816,76 +875,70 @@ The syslog is in most Linux systems the -

    -

    Motion Guide - Basic Features

    -

    --

    Capture Device Options - The Basic Setup

    -+

    Capture Device Options - The Basic Setup

    - Before you can start using motion you need to know some basics about your camera. - Either you have a camera connected directly to your computer. In this case it is a video4linux type of camera. Or you connect to a network camera using a normal web URL. -

    --

    video4linux (V4L) devices

    -+

    video4linux (V4L) devices

    - You need to install your camera with the right driver. It is out of scope of this document to tell you how to do this and it depends on which type of camera. -

    - Once installed the camera(s) will have the device names /dev/video0, /dev/video1, /dev/video2... -

    - FreeBSD has a different naming of devices. When you build Motion for FreeBSD the default device name is /dev/bktr0. Under FreeBSD a TV card has a special device for controlling the tuner (e.g. /dev/tuner0). The option tunerdevice is only valid when Motion is built and running under FreeBSD. For Linux do not include this option in the config file (remove or comment out). -

    --USB cameras take a lot of bandwidth. A USB camera connected to a USB 1.1 port or hub consumes all the bandwidth. Even with a small framesize and low framerate you should not expect to have more than one camera per USB 1.1 controller. If you need more than 1 USB camera add extra USB PCI cards to your computer. There exists cards that have 4 inputs each with their own controller and with full bandwidth. Many 4-input cards only have 1 controller. USB cameras do not have the feature of selecting input channels. To disable the input selection the option input must be set to the value 8 for USB cameras. -+USB cameras take a lot of bandwidth. A USB camera connected to a USB 1.1 port or hub consumes all the bandwidth. Even with a small framesize and low framerate you should not expect to have more than one camera per USB 1.1 controller. If you need more than 1 USB camera add extra USB PCI cards to your computer. There exists cards that have 4 inputs each with their own controller and with full bandwidth. Many 4-input cards only have 1 controller. USB cameras do not have the feature of selecting input channels. To disable the input selection the option input must be set to the value 8 for USB cameras. -

    - Composite video cards are normally made with a chip called BT878 (older cards have a BT848). They all use the Linux driver called 'bttv'. -

    --There are cards with more then one video input but still only one BT878 chip. They have a video multiplexer which input is selected with the config option input. Input channel numbers start at 0 (which is why the value 8 and not 0 disables input selection). There are video capture cards available with 4 or 8 inputs but only one chip. They present themselves as one single video device and you select input using the 'input' option. If you define e.g. 4 thread config files with the same videodevice name but different input numbers Motion automatically goes into round robin mode. See the round robin section for more information. Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. For video capture cards input 1 is normally the composite video input. -+There are cards with more then one video input but still only one BT878 chip. They have a video multiplexer which input is selected with the config option input. Input channel numbers start at 0 (which is why the value 8 and not 0 disables input selection). There are video capture cards available with 4 or 8 inputs but only one chip. They present themselves as one single video device and you select input using the 'input' option. If you define e.g. 4 thread config files with the same videodevice name but different input numbers Motion automatically goes into round robin mode. See the round robin section for more information. Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. For video capture cards input 1 is normally the composite video input. -

    - Some capture cards are specially made for surveillance with for example 4 inputs. Others have a TV tuner, a composite input (phono socket) and perhaps also a S-VHS input. For all these cards the inputs are numbered. The numbering varies from card to card so the easiest is to experiment for 5 minutes with a program that can show the videostream. Use a program such as Camstream or xawtv to experiment with the values. -

    --If you use the TV tuner input you also need to set the frequency of the TV channel using the option frequency. Otherwise set 'frequency' to 0. -+If you use the TV tuner input you also need to set the frequency of the TV channel using the option frequency. Otherwise set 'frequency' to 0. -

    - Finally you need to set the TV norm. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default is 0 (PAL). If your camera is a PAL black and white you may get a better result with norm=3 (PAL no colour). -

    --If the netcam_url option is defined all the video4linux options are ignored so make sure the netcam_url option is commented out if you do not need it. -+If the netcam_url option is defined all the video4linux options are ignored so make sure the netcam_url option is commented out if you do not need it. -

    - These are the parameters used for video4linux devices -

    -

    --

    -

    auto_brightness

    -

    -

    - Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness -

    - Motion will try to adjust the brightness of the video device if the images captured are too dark or too light. This option will be most useful for video devices like web cams, which sometimes don't have such an option in hardware. -

    --The auto_brightness feature will adjust the brightness of the device up or down until the value defined by the option brightness is reached (1 = dark, 255 = bright). If brightness is zero auto_brightness will try to adjust to the average brightness level 128. -+The auto_brightness feature will adjust the brightness of the device up or down until the value defined by the option brightness is reached (1 = dark, 255 = bright). If brightness is zero auto_brightness will try to adjust to the average brightness level 128. -

    - You need to know if the camera supports auto brightness. Most cameras have auto everything. If your video device already does this for you this option might cause oscillations. If you do not know assume that it has and do not use the Motion auto brightness feature. At least not to start with. -

    -

    --

    --

    --

    -

    brightness

    -

    - The brightness level for the video device. -

    - Value 0 means that Motion does not set the brightness value but leaves it unchanged. -

    --If this setting is used in conjunction with the auto_brightness feature then this setting is the average brightness level in the range 1 (dark) to 255 (bright) that the auto_brightness feature will try to achieve by adjusting the device brightness up and down. --

    --

    -+If this setting is used in conjunction with the auto_brightness feature then this setting is the average brightness level in the range 1 (dark) to 255 (bright) that the auto_brightness feature will try to achieve by adjusting the device brightness up and down. -

    -

    -

    contrast

    -

    - The contrast level for the video device. -@@ -1893,14 +946,12 @@ The contrast level for the video device. - Disabled (Value 0) means that Motion does not set the contrast value. -

    -

    --

    --

    -

    framerate

    -

    -

    - Maximum number of frames to be captured from the camera per second. -@@ -1914,14 +965,12 @@ Set this parameter to the maximum number - To set intervals longer than one second use the 'minimum_gap' option instead. -

    -

    --

    --

    -

    frequency

    -

    -

    - The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) -@@ -1929,14 +978,12 @@ The frequency to set the tuner to (kHz). - This option is only relevant if you have a TV tuner card where you can select the tuner frequency. Your tuner card must support this feature. -

    -

    --

    --

    -

    height

    -

    -

    - The height of each frame in pixels. -@@ -1952,14 +999,12 @@ For some device drivers like pwc (driver - Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. -

    -

    --

    --

    -

    hue

    -

    -

    - The hue level for the video device. -@@ -1967,14 +1012,12 @@ The hue level for the video device. - Normally only relevant for NTSC cameras. -

    -

    --

    --

    -

    input

    -

    -

    - 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. -@@ -1985,9 +1028,7 @@ However if you set the input number to e -

    - If you have a video capture card you can define the channel to tune to using this option. If you are using a USB device, network camera or a capture card without tuner you should set the value to the default 8. -

    --Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. It is recommended to set the parameter to 8 for USB cameras as your first try. For video capture cards input 1 is normally the composite video input. --

    --

    -+Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. It is recommended to set the parameter to 8 for USB cameras as your first try. For video capture cards input 1 is normally the composite video input. -

    -

    -

    minimum_frame_time

    -@@ -1995,7 +1036,7 @@ Many TV tuner cards have the input chann -
  • Type: Integer -
  • Range / Valid values: 0 - 2147483647 -
  • Default: 0 --
  • Option Topic -+
  • Option Topic -
  • -

    - Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. -@@ -2004,21 +1045,19 @@ This option is used when you want to cap -

    - When this is enabled the framerate option is used only to set the pace the Motion service the webcam port etc. Running Motion at framerate 2 is normally fine. -

    --ALERT! This feature is introduced in Motion 3.2.7 -+ALERT! This feature is introduced in Motion 3.2.7 -

    - -

    -

    --

    --

    -

    norm

    -

      -
    • Type: Discrete Strings -
    • Range / Valid values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) -
    • Default: 0 (PAL) --
    • Option Topic -+
    • Option Topic -
    -

    - Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) -@@ -2026,14 +1065,12 @@ Select the norm of the video device. Val - This value is only used for capture cards using the BTTV driver. -

    -

    --

    --

    -

    rotate

    -

      -
    • Type: Discrete Strings -
    • Range / Valid values: 0, 90, 180, 270 -
    • Default: 0 (not rotated) --
    • Option Topic -+
    • Option Topic -
    -

    - Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. -@@ -2043,91 +1080,49 @@ The rotation feature is used when the ca - Note that the CPU load increases when using this feature with a value other than 0. Also note that Motion automatically swaps width and height if you rotate 90 or 270 degrees, so you don't have to touch these options. -

    -

    --

    --

    -

    saturation

    -

    -

    - The colour saturation level for the video device. -

    -

    --

    --

    --

    --

    -

    tunerdevice

    -

    -

    --The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. -+The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. -

    - Make sure to remove or comment out this option when running Motion under Linux. -

    -

    --

    --

    --

    v4l2_palette

    --

      --
    • Type: Integer --
    • Range / Valid values: 0 - 8 --
    • Default: 8 --
    • Option Topic --
    --

    --Allow to choose preferable palette to be use by motion -- to capture from those supported by your videodevice. ( new in 3.2.10 ) --

    -- --

    --i.ex if your videodevice supports V4L2 _PIX_FMT_SBGGR8 and V4L2 _PIX_FMT_MJPEG by default motion will use V4L2 _PIX_FMT_MJPEG so set v4l2_palette 1 to force motion use V4L2 _PIX_FMT_SBGGR8 instead. --

    --Values : --

    V4L2_PIX_FMT_SN9C10X : 0 'S910'
    --V4L2_PIX_FMT_SBGGR8 : 1 'BA81'
    --V4L2_PIX_FMT_MJPEG : 2 'MJPEG'
    --V4L2_PIX_FMT_JPEG : 3 'JPEG'
    --V4L2_PIX_FMT_RGB24 : 4 'RGB3'
    --V4L2_PIX_FMT_UYVY : 5 'UYVY'
    --V4L2_PIX_FMT_YUYV : 6 'YUYV'
    --V4L2_PIX_FMT_YUV422P : 7 '422P'
    --V4L2_PIX_FMT_YUV420 : 8 'YU12'
    --
    --

    --

    --

    --

    -

    videodevice

    -

    -

    --The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. -+The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. -

    - This is the video4linux device name. Ignore this for net cameras. -

    -

    --

    --

    -

    width

    -

    -

    - The width in pixels of each frame. Valid range is camera dependent. -@@ -2145,7 +1140,6 @@ For some device drivers like pwc (driver - Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. -

    -

    --

    -

    Network Cameras

    - Motion can connect to a network camera through a normal TCP socket. All you need to give it is the URL. The URL given must return either one single jpeg picture or an mjpeg stream. For the time being Motion cannot connect to a video stream such a mpeg, mpeg4, divx. The URL must return one single jpeg image or an mjpeg stream! You can connect through a proxy server. -

    -@@ -2157,31 +1151,7 @@ If the connection to a network camera is -

    - Note that Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. But if you intend to monitor a network camera which is saving jpeg images you may have to pay attention to the dimensions of the picture. -

    --The network camera feature has been completely re-written in Motion 3.2.2. We believe the netcam feature is much more stable now that it was in previous versions. Motion tries to reconnect to the camera if the connection is lost. There is no official standard for mjpeg and we know that there are probably still some cameras that are not yet supported. If you run into a problem please file a Bug Report with as much information about the format as possible. A binary raw dump of the first 2-3 frames with headers and boundary strings is very useful. You can see how to make it on the special topic NetcamMjpegStreamDumps. When you have the file you can upload it to the same topic. --

    --

    --

    --

    netcam_http

    --

      --
    • Type: Discrete Strings --
    • Range / Valid values: 1.0, keep_alive, 1.1 --
    • Default: 1.0 --
    • Option Topic --
    --

    --The setting for keep-alive of network socket, should improve performance on compatible net cameras. ( new in 3.2.10 ) --

    --

      --
    • 1.0: the historical implementation using HTTP/1.0, closing the socket after each http request. --
    • keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection. --
    • 1.1: Use HTTP/1.1 requests that support keep alive as default. --
    --

    -- --

    --

    -+The network camera feature has been completely re-written in Motion 3.2.2. We believe the netcam feature is much more stable now that it was in previous versions. Motion tries to reconnect to the camera if the connection is lost. There is no official standard for mjpeg and we know that there are probably still some cameras that are not yet supported. If you run into a problem please file a Bug Report with as much information about the format as possible. A binary raw dump of the first 2-3 frames with headers and boundary strings is very useful. You can see how to make it on the special topic NetcamMjpegStreamDumps. When you have the file you can upload it to the same topic. -

    -

    -

    netcam_proxy

    -@@ -2189,7 +1159,7 @@ Add Additional Description Below -
  • Type: String -
  • Range / Valid values: Max 4095 characters -
  • Default: Not defined --
  • Option Topic -+
  • Option Topic -
  • -

    - URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber -@@ -2203,32 +1173,14 @@ If the proxy port number is 80 you can o - Leave this option undefined if you do not use a proxy server. -

    -

    --

    --

    --

    netcam_tolerant_check

    --

      --
    • Type: Boolean --
    • Range / Valid values: on, off --
    • Default: off --
    • Option Topic --
    --

    --Set less strict jpeg checks for network cameras with a poor/buggy firmware. --

    -- --

    --

    --

    --

    -

    netcam_url

    -

    -+

    - Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. -

    - Example of URL: http://www.gate.com/pe1rxq/jeroen.jpg. -@@ -2242,14 +1194,12 @@ When the netcam_url is defined all the v - Motion can also fetch jpeg pictures via ftp. You then use the ftp:// syntax instead. -

    -

    --

    --

    -

    netcam_userpass

    -

    -

    - For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. -@@ -2258,30 +1208,28 @@ To use no authentication simply remove t -

    -

    -

    --

    - -

    Round Robin feature

    --This feature is automatically activated where multiple threads are sharing the same video device (for example /dev/video0). Each thread can then set different input channels to change camera with the input option or by tuning the tuner with frequency option. -+This feature is automatically activated where multiple threads are sharing the same video device (for example /dev/video0). Each thread can then set different input channels to change camera with the input option or by tuning the tuner with frequency option. -

    --ALERT! Round Robin is not relevant for Network cameras or standard USB web cameras. The Round Robin feature is used with video capture cards which have multiple inputs per video chip. -+ALERT! Round Robin is not relevant for Network cameras or standard USB web cameras. The Round Robin feature is used with video capture cards which have multiple inputs per video chip. -

    --ALERT! Note that round robin is not the ideal way to run multiple cameras. When the capture card changes input it takes a little while before the decoder chip has syncronized to the new camera. You can improve this if you have expensive cameras with a syncronize input. Only one camera can be decoded at a time so if you have 4 cameras connected 3 of the camera threads will need to wait for their turn. The fact that cameras have to take turns and the fact that you have to skip a few frames after each turn dramatically lowers the possible framerate. You can get a high framerate by viewing each camera for a long time. But then you may miss the action on one of the inactive cameras. If you can affort it avoid Round Robin and buy the more expensive type of capture cards that has one decoder chip per input. If you only need 2 or 3 cameras you can also simply put 2 or 3 cheap TV cards in the computer. Linux has no problem working with multiple TV cards. -+ALERT! Note that round robin is not the ideal way to run multiple cameras. When the capture card changes input it takes a little while before the decoder chip has syncronized to the new camera. You can improve this if you have expensive cameras with a syncronize input. Only one camera can be decoded at a time so if you have 4 cameras connected 3 of the camera threads will need to wait for their turn. The fact that cameras have to take turns and the fact that you have to skip a few frames after each turn dramatically lowers the possible framerate. You can get a high framerate by viewing each camera for a long time. But then you may miss the action on one of the inactive cameras. If you can affort it avoid Round Robin and buy the more expensive type of capture cards that has one decoder chip per input. If you only need 2 or 3 cameras you can also simply put 2 or 3 cheap TV cards in the computer. Linux has no problem working with multiple TV cards. -

      --
    • If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. --
    • When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. --
    • The last option switch_filter is supposed to prevent the change of camera from being detected as Motion. Its function is not perfect and sometimes prevents detection of real motion. You should start with having the option disabled and then try with the option enabled to see if you can skip less frames without loosing the detection of the type of motion you normally want to detect. -+
    • If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. -+
    • When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. -+
    • The last option switch_filter is supposed to prevent the change of camera from being detected as Motion. Its function is not perfect and sometimes prevents detection of real motion. You should start with having the option disabled and then try with the option enabled to see if you can skip less frames without loosing the detection of the type of motion you normally want to detect. -
    -

    - These are the special Round Robin options -

    -

    --

    -

    roundrobin_frames

    -

    -

    - Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. -@@ -2291,14 +1239,12 @@ The Round Robin feature is automatically - If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. -

    -

    --

    --

    -

    roundrobin_skip

    -

    -

    - Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). -@@ -2308,65 +1254,31 @@ The Round Robin feature is automatically - When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. -

    -

    --

    --

    -

    switchfilter

    -

    -

    - Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. -

    - This is a round robin related feature used when you have a capture card with multiple inputs (controlled by the 'input' option) on the same videodevice. -

    --ALERT! This feature was seriously broken until Motion 3.2.4 -+ALERT! This feature was seriously broken until Motion 3.2.4 -

    -

    --

    --

    --

    --

    Motion Detection Settings

    -+

    Motion Detection Settings

    - These are the options that controls the detection of motion. Further details follows after. -

    -

    --

    --

    area_detect

    --

      --
    • Type: String --
    • Range / Valid values: 1 - 999999999 --
    • Default: Not defined --
    • Option Topic --
    --

    --Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. --

    -- --

    --Areas are numbered like that: --

    --

          1    2    3
    --      4    5    6
    --      7    8    9
    --
    --

    -- One or more areas can be specified with this option. --

    --Example: You want to monitor if the center of motion occurrs in the lower third of the image - that is area 7, 8 and 9. Simply set 'area_detect' to '789' and 'on_area_detect' will be executed as soon as the center of motion was detected in area 7, 8 or 9. If you want to monitor area 2, 3, 5 and 6, set '2356'. --

    --

    --

    --

    -

    despeckle

    -

    -

    - Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. -@@ -2385,14 +1297,12 @@ If you have very few problems with false - A very detailed technical explanation of the despeckle part can be found at the webpage of the author of this feature Ian McConnell's Webcam: Motion Web Page -

    -

    --

    --

    -

    gap

    -

    -

    - Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. -@@ -2426,15 +1336,14 @@ The gap value impacts many functions in - Note that 'gap' and 'minimum_gap' have nothing to do with each other. -

    -

    --

    --

    -

    lightswitch

    -

    -+

    - Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. -

    - Experiment to see what works best for your application. -@@ -2444,6 +1353,17 @@ Note: From version 3.1.17 (snap release - The value defines the picture areas in percent that will trigger the lightswitch condition. When lightswitch is detected motion detection is disabled for 5 picture frames. This is to avoid false detection when light conditions change and when a camera changes sensitivity at low light. -

    -

    -+

    low_cpu

    -+

      -+
    • Type: Integer -+
    • Range / Valid values: 0 - 100 -+
    • Default: 0 (disabled) -+
    • Option Topic -+
    -+

    -+When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. -+

    -+This is smart for running a server that also does other tasks such as running Apache, MySQL etc. Motion grabs this lower number of frames per second until it detects motion. Then it speeds up to normal speed and take pictures as set by the option "framerate". -

    -

    -

    mask_file

    -@@ -2451,7 +1371,7 @@ The value defines the picture areas in p -
  • Type: String -
  • Range / Valid values: Max 4095 characters -
  • Default: Not defined --
  • Option Topic -+
  • Option Topic -
  • -

    - PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. -@@ -2486,18 +1406,12 @@ Below are an example of a webcam picture -

    - Normal picture. Notice the street is visible through the hedge. -

    --normal.jpg -+normal.jpg -

    - Mask file (converted to png format so it can be shown by your web browser) -

    -- -- -- -- -- --
    mask1.png
    --

    --

    -+ -+
    mask1.png
    -

    -

    -

    max_mpeg_time

    -@@ -2505,7 +1419,7 @@ Mask file (converted to png format so it -
  • Type: Integer -
  • Range / Valid values: 0 (infinite) - 2147483647 -
  • Default: 3600 --
  • Option Topic -+
  • Option Topic -
  • -

    - The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. -@@ -2517,6 +1431,23 @@ Add Additional Description Below - --> -

    -

    -+

    minimum_gap

    -+

      -+
    • Type: Integer -+
    • Range / Valid values: 0 - 2147483647 -+
    • Default: 0 (no minimum) -+
    • Option Topic -+
    -+

    -+The minimum time between two shots in seconds. -+

    -+This is the minimum gap between the storing pictures while detecting motion. -+

    -+The value zero means that pictures can be stored almost at the framerate of the camera. Normally you will set this to 0 -+

    -+This option has nothing to do with the 'gap' option. -+

    -+ALERT! From motion 3.2.7 this feature has been removed because it was in practical a useless feature. It prevented saving more than one picture per minimum_gap seconds but the capturing and motion detect was still run at full framerate loading the CPU heavily. From 3.2.7 a new feature called minimum_frame_time has been introduced which lower the capture rate. So it gives the same effect as minimum_gap did but additionally lower the CPU load significantly. -

    -

    -

    minimum_motion_frames

    -@@ -2524,7 +1455,7 @@ Add Additional Description Below -
  • Type: Boolean -
  • Range / Valid values: 1 - 1000s -
  • Default: 1 --
  • Option Topic -+
  • Option Topic -
  • -

    - Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. -@@ -2536,6 +1467,17 @@ The feature is used when you get many fa - Experiment for best setting. Even though Motion accepts large values you should set this to a relatively low number (below 10). For each step larger than 1 Motion reserves space in RAM for the picture frame buffer. If you have a large value Motion will miss many frames from the camera while it is processing the all the pictures in the buffer. -

    -

    -+

    night_compensate

    -+

      -+
    • Type: Boolean -+
    • Range / Valid values: on, off -+
    • Default: off -+
    • Option Topic -+
    -+

    -+When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. -+

    -+It has normally been the advice not to use this with 'noise_tune' turned on. However the latest experience is that with the new improved noise_tune algorithm it actually works fine in combination with 'night_compensate'. -

    -

    -

    noise_level

    -@@ -2543,7 +1485,7 @@ Experiment for best setting. Even though -
  • Type: Integer -
  • Range / Valid values: 1 - 255 -
  • Default: 32 --
  • Option Topic -+
  • Option Topic -
  • -

    - The noise level is used as a threshold for distinguishing between noise and motion. -@@ -2551,14 +1493,12 @@ The noise level is used as a threshold f - This is different from the threshold parameter. This is changes at pixel level. The purpose is to eliminate the changes generated by electric noise in the camera. Especially in complete darkness you can see the noise as small grey dots that come randomly in the picture. This noise can create false motion detection. What this parameter means is that the intensity of a pixel must change more than +/- the noise threshold parameter to be counted. -

    -

    --

    --

    -

    noise_tune

    -

    -

    - Activates the automatic tuning of noise level. -@@ -2566,14 +1506,12 @@ Activates the automatic tuning of noise - This feature makes Motion continuously adjust the noise threshold for distinguishing between noise and motion. The 'noise_level' setting is ignored when activating this feature. This is a new feature and new algorithm. It may give different results depending on camera and light conditions. Report your experience with it on the Motion mailing list. If it does not work well, deactivate the 'noise_tune' option and use the manual setting of 'noise_level' instead. -

    -

    --

    --

    -

    output_all

    -

    -

    - Picture are saved continuously as if motion was detected all the time. -@@ -2587,14 +1525,12 @@ It does all the normal actions that are - The idea of this feature is that you can turn the feature on and off for a short period of time to test or to generate continuous mpeg films when needed. -

    -

    --

    --

    -

    post_capture

    -

    -

    - Specifies the number of frames to be captured after motion has been detected. -@@ -2606,14 +1542,12 @@ This option is the preferred way to crea - If you only store mpegs movies and do not have output_normal on, then the recommended post_capture value is what is equivalent to 1-5 seconds of movie. -

    -

    --

    --

    -

    pre_capture

    -

    -

    - Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. -@@ -2630,9 +1564,7 @@ Motion will not grab another image until -

    - If you wish to create smooth mpegs during events using large pre_capture values will do the opposite! It will create a long pause where a lot of action is missed. -

    --To get a smooth mpeg use a large value for post_capture which does not cost any performance hit or RAM space. --

    --

    -+To get a smooth mpeg use a large value for post_capture which does not cost any performance hit or RAM space. -

    -

    -

    smart_mask_speed

    -@@ -2640,7 +1572,7 @@ To get a smooth mpeg use a large value f -
  • Type: Integer -
  • Range / Valid values: 0 - 10 -
  • Default: 0 (disabled) --
  • Option Topic -+
  • Option Topic -
  • -

    - Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. -@@ -2649,11 +1581,11 @@ Smartmask is a dynamic, self-learning ma -

    - smart_mask_speed - tunes the slugginess of the mask. It accepts values from 0 (turned off) to 10 (fast). Fast means here that the mask is built quick, but it is also not staying very long with no more motion. Slow means that it takes a while until the mask is built but it also stays longer. A good start value for smart_mask_speed is 5. This setting is independent from the framerate. The attack and decay time is constant over all available framerates. -

    --When smartmask is enabled and motion is also configured to either write motion-images or motion-mpegs, the current smartmask is copied as an overlay into the black/white motion-pictures/mpegs in red colour. Same thing happens to the webcam stream when Motion runs in setup_mode. That way you can easily adjust smart_mask_speed. -+When smartmask is enabled and motion is also configured to either write motion-images or motion-mpegs, the current smartmask is copied as an overlay into the black/white motion-pictures/mpegs in red colour. Same thing happens to the webcam stream when Motion runs in setup_mode. That way you can easily adjust smart_mask_speed. -

    - Detailed Description -

    --The mask_file option provides a static mask to turn off sensitivity in certain areas. This is very usefull to mask a street with cars passing by all day long etc... -+The mask_file option provides a static mask to turn off sensitivity in certain areas. This is very usefull to mask a street with cars passing by all day long etc... -

    - But imagine a scenario with large bushes and big trees where all the leaves are moving in the wind also triggering motion from time to time even with despeckle turned on. Of course you can also define a static mask here, but what if the bushes are growing during spring and summer? Well, you have to adapt the mask from time to time. What if the camera position moves slightly? What if someone grows new plants in your garden? You always have to setup a new static mask. -

    -@@ -2662,15 +1594,12 @@ The answer to this problem is the smart - Smart mask will disable sensitivity in areas with frequent motion (like trees in the wind). Sensitivity is turned on again after some time of no more motion in this area. The built mask is a bit larger at the borders than the actual motion. This way smartmask works more reliably when sudden moves occur under windy conditions. -

    -

    --

    --

    --

    -

    threshold

    -

    -

    - Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. -@@ -2680,37 +1609,31 @@ The 'threshold' option is the most impor - Use the -s (setup mode) command line option and/or the text_changes config file option to experiment to find the right threshold value. If you do not get small movements detected (see the mouse on the kitchen floor) lower the value. If motion detects too many birds or moving trees, increase the number. Practical values would be from a few hundred to 2000 indoors and 1000-10000 outdoors. -

    -

    --

    --

    -

    threshold_tune

    -

    -

    --Activates the automatic tuning of threshold level. ( It's broken ) -+Activates the automatic tuning of threshold level. -

    - This feature makes Motion continuously adjust the threshold for declaring motion. -

    --The threshold setting is ignored when activating this feature. It may give different results depending on your camera, light conditions, indoor/outdoor, the motion to be detected etc. If it does not work well, deactivate the 'threshold_tune' option and use the manual setting of threshold instead. --

    --

    -+The threshold setting is ignored when activating this feature. It may give different results depending on your camera, light conditions, indoor/outdoor, the motion to be detected etc. If it does not work well, deactivate the 'threshold_tune' option and use the manual setting of threshold instead. -

    -

    --

    --

    Image File Output

    -+

    Image File Output

    - The following options controls how Motion generates images when detection motion. -

    -

    --

    -

    output_motion

    -

    -

    - Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. -@@ -2720,14 +1643,12 @@ Motion images shows the motion content o - Default is not to store motion images. Motion pictures are stored the same place and with the same filename as normal motion triggered pictures except they have an "m" appended at the end of the filename before the .jpg or .ppm. E.g. the name can be 01-20020424232936-00m.jpg. -

    -

    --

    --

    -

    output_normal

    -

      -
    • Type: Discrete Strings --
    • Range / Valid values: on, off, first, best, center (since 3.2.10) -+
    • Range / Valid values: on, off, first, best -
    • Default: on --
    • Option Topic -+
    • Option Topic -
    -

    - Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. -@@ -2736,11 +1657,7 @@ If you set the value to 'first' Motion s -

    - If you set it to "best" Motion saves the picture with most changed pixels during the event. This is useful if you store mpegs on a webserver and want to present a jpeg to show the content of the mpeg on a webpage. "best" requires a little more CPU power and resources compared to "first". -

    --Picture with motion nearest center of picture is saved when set to 'center' (since 3.2.10). --

    --Set to 'off' to not write pictures (jpeg or ppm). --

    --

    -+Set to 'off' to don't write pictures ( jpeg or ppm ). -

    -

    -

    ppm

    -@@ -2748,7 +1665,7 @@ Set to 'off' to not write pictures (jpeg -
  • Type: Boolean -
  • Range / Valid values: on, off -
  • Default: off --
  • Option Topic -+
  • Option Topic -
  • -

    - Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. -@@ -2756,14 +1673,12 @@ Output ppm images instead of jpeg. This - The recommendation is to always use jpg except if you have a specific need to store high quality pictures without any quality loss. For web cameras you should always choose jpg. Note that the built in webcam server requires that this parameter is set to off. -

    -

    --

    --

    -

    quality

    -

    -

    - The quality for the jpeg images in percent. -@@ -2771,11 +1686,7 @@ The quality for the jpeg images in perce - 100 means hardly compressed. A small number means a much smaller file size but also a less nice quality image to look at. 50 is a good compromise for most. -

    -

    --

    --

    --

    --

    --

    Tuning Motion

    -+

    Tuning Motion

    -

    - Motion 3.2 introduces a new feature Setup Mode. This is a great new feature with really make tuning all the settings of Motion much more easy and transparent. In setup mode two things happen: -

      -@@ -2801,26 +1712,26 @@ In normal mode you can use the same sett - From the web interface you can ask Motion to write all your changes back to the config files (motion.conf and thread config files). It will even tidy them up for you so they look nice. -

      - There are two sets of options to adjust.

      -

      -


      -

      - Normal picture frame -

      --outputnormal1.jpg -+outputnormal1.jpg -

      -


      - Motion type picture frame with despeckle. Note that the largest area is blue and only this is counted as Motion. -

      - The Motion image shows how Motion maintains a "reference frame" which is not just the last picture frame but a matematical calculation of the past images. This enlarges real Motion and ensures that it is not easy to sneak in slowly. -

      --outputmotion1.jpg -+outputmotion1.jpg -


      -

      -

      --

      Generating MPEG films with ffmpeg

      -+

      Generating MPEG films with ffmpeg

      - The ffmpeg option can generate mpeg films very fast and "on the fly". This means that the mpeg film is growing each time motion is detected. -

      - Some people on the Motion mailing list have had trouble building the ffmpeg package because they did not have the NASM assembler package installed. So pay attention to this if you run into problems. -@@ -2835,14 +1746,14 @@ Motion works with the following versions -

    1. ffmpeg-0.4.8. With this release Motion supports mpeg1, mpeg4 and msmpeg4. Lately newer distributions have problems building this 2003 release of ffmpeg so many of you no longer have this option. -
    2. ffmpeg-0.4.9pre1. Is supported starting from Motion version 3.1.18. With this release Motion supports mpeg4 and msmpeg4 but not mpeg1. The reason is that the ffmpeg team has decided no longer to support non-standard framerates in their mpeg1 encoder library. Also ffmpeg-0.4.9pre1 gives people problems on newer distributions. -
    3. ffmpeg from CVS. This may work. We cannot continuously monitor and try every time a new source file is checked into ffmpeg. You will have to try. --
    4. ffmpeg RPMs. Currently each Motion release is tested with the current Livna ffmpeg rpm package for Fedora. See the Download Files page for direct links to the version which has been certified with the latest Motion release. -+
    5. ffmpeg RPMs. Currently each Motion release is tested with the current Livna ffmpeg rpm package for Fedora. See the Download Files page for direct links to the version which has been certified with the latest Motion release. -
    6. ffmpeg debian binaries. Latest versions from the debian repository for Debian Sarge works fine with Motion. -
    7. Certified ffmpeg CVS snapshot for latest Motion release is available from the Motion Sourceforge Related Projects file area -
    8. -

      - The timelapse feature always runs mpeg1 with both ffmpeg 0.4.8 and 0.4.9 and newer. Motion simply creates the timelapse film with a standard mpeg1 framerate. Note : maximum size for timelapse files is 2GB. -

      --In principle Motion can be made to support many other formats. It requires additional coding in Motion. You are welcome to submit patches. All ffmpeg related code is in the source file ffmpeg.c. It is not trivial to do because the ffmpeg libraries not documented at all. All you have is a couple of code examples. -+In principle Motion can be made to support many other formats. It requires additional coding in Motion. You are welcome to submit patches. All ffmpeg related code is in the source file ffmpeg.c. It is not trivial to do because the ffmpeg libraries not documented at all. All you have is a couple of code examples. -

      - To build ffpmeg from source follow these steps: -

      -@@ -2881,13 +1792,12 @@ Note that if you install ffmpeg from sou - These are the config file options related to ffmpeg. -

      -

      --

      -

      ffmpeg_bps

      -

      -

      - Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. -@@ -2897,14 +1807,12 @@ To use this feature you need to install - Experiment to get the desired quality. The better quality the bigger files. This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled). -

      -

      --

      --

      -

      ffmpeg_cap_motion

      -

      -

      - Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. -@@ -2916,14 +1824,12 @@ This feature generates the special motio - To use this feature you need to install the FFmpeg Streaming Multimedia System -

      -

      --

      --

      -

      ffmpeg_cap_new

      -

      -

      - Use ffmpeg libraries to encode mpeg movies in realtime. -@@ -2935,14 +1841,12 @@ To use this feature you need to install - Must not be included in config file without having ffmpeg installed. -

      -

      --

      --

      -

      ffmpeg_deinterlace

      -

      -

      - Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. -@@ -2957,14 +1861,12 @@ Add Additional Description Below - --> -

      -

      --

      --

      -

      ffmpeg_timelapse

      -

      -

      - Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. -@@ -2980,14 +1882,12 @@ To use this feature you need to install - (renamed from ffmpeg_timelaps to ffmpeg_timelapse in 3.1.14) -

      -

      --

      --

      -

      ffmpeg_timelapse_mode

      -

        -
      • Type: Discrete Strings -
      • Range / Valid values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual -
      • Default: daily --
      • Option Topic -+
      • Option Topic -
      -

      - The file rollover mode of the timelapse video. -@@ -2997,14 +1897,12 @@ Note that it is important that you use t - The value 'Manual' means that Motion does not automatically rollover to a new filename. You can do it manually using the http control interface by setting the option 'ffmpeg_timelapse' to 0 and then back to your chosen value. Value 'hourly' rolls over on the full hour. Value 'daily' which is the default rolls over at midnight. There are two weekly options because depending on where you come from a week may either start on Sunday or Monday. And 'monthly' naturally rolls over on the 1st of the month. -

      -

      --

      --

      -

      ffmpeg_variable_bitrate

      -

      -

      - Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. -@@ -3012,63 +1910,61 @@ Enables and defines variable bitrate for - Experiment for the value that gives you the desired compromise between size and quality. -

      -

      --

      --

      -

      ffmpeg_video_codec

      -

        -
      • Type: Discrete Strings --
      • Range / Valid values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1, mov -+
      • Range / Valid values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1 -
      • Default: mpeg4 --
      • Option Topic -+
      • Option Topic -
      -

      - Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. --

        --
      • mpeg1 - gives you mpeg1 files with extension .mpg. It is only supported by the old ffmpeg version 0.4.8. The ffmpeg team decided no longer to support non-standard framerates for mpeg1 from ffmpeg version 0.4.9pre1. --
      • mpeg4 - gives you mpeg4 files with extension .avi --
      • msmpeg4 - also gives you mpeg4 files. It is s recommended for use with Windows Media Player because it requires with no installation of codec on the Windows client. --
      • swf - gives you a flash film with extension .swf --
      • flv - gives you a flash video with extension .flv --
      • ffv1 - FF video codec 1 for Lossless Encoding (experimental) --
      • mov - QuickTime (since 3.2.10). --
      -

      --This option does not affect the timelapse feature. Timelapse is always recorded in mpeg1 format because we need to be able to append to an existing file. mpeg4 does not easily allow this. -+mpeg1 gives you files with extension .mpg. It is only supported by the old ffmpeg version 0.4.8. The ffmpeg team decided no longer to support non-standard framerates for mpeg1 from ffmpeg version 0.4.9pre1. -+

      -+mpeg4 or msmpeg4 give you files with extension .avi -+

      -+msmpeg4 is recommended for use with Windows Media Player because it requires with no installation of codec on the Windows client. -+

      -+swf gives you a flash film with extension .swf -

      -+flv gives you a flash video with extension .flv -+

      -+ffv1 , FF video codec 1 for Lossless Encoding ( experimental ) -+

      -+This option does not affect the timelapse feature. Timelapse is always recorded in mpeg1 format because we need to be able to append to an existing file. mpeg4 does not easily allow this. -

      -

      -


      -

      --See also the section Advanced Filenames where the two additional options ffmpeg_filename and timelapse_filename are defined. -+See also the section Advanced Filenames where the two additional options ffmpeg_filename and timelapse_filename are defined. -

      - If you want to use this feature you can read about the FFmpeg Streaming Multimedia System -

      -

      --

      Snapshots - The Traditional Periodic Web Camera

      -+

      Snapshots - The Traditional Periodic Web Camera

      - Motion can also act like a traditional web camera. -

      -

      --

      -

      snapshot_interval

      -

      -

      - Make automated snapshots every 'snapshot_interval' seconds. -

      --The snapshots are stored in the target directory + the directory/filename specified by the snapshot_filename option. -+The snapshots are stored in the target directory + the directory/filename specified by the snapshot_filename option. -

      - This is the traditional web camera feature where a picture is taken at a regular interval independently of motion in the picture. -

      -

      --

      --See the also snapshot_filename option in the section Advanced Filenames. -+See the also snapshot_filename option in the section Advanced Filenames. -

      -

      --

      Text Features

      -+

      Text Features

      - Text features are highly flexible. You can taylor the text displayed on the images and films to your taste and you can add your own user defined text. -

      - This is how the overlayed text is located. -@@ -3105,13 +2001,12 @@ Below are the options that controls the - The text_event feature is special in that it defines the conversion specifier %C which can be used both for text display and for filenames. -

      -

      --

      -

      locate

      -

      -

      - Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. -@@ -3119,14 +2014,12 @@ Locate and draw a box around the moving - The value 'preview' only works when 'output_normal' is set to either 'first' or 'best'. -

      -

      --

      --

      -

      text_changes

      -

      -

      - Turns the text showing changed pixels on/off. -@@ -3134,8 +2027,6 @@ Turns the text showing changed pixels on - By setting this option to 'on' the number of pixels that changed compared to the reference frame is displayed in the upper right corner of the pictures. This is good for calibration and test. Maybe not so interesting for a greater public. Set it to your personal taste. -

      -

      --

      --

      -

      text_double

      -

        -
      • Type: Boolean -@@ -3152,14 +2043,12 @@ Add Additional Description Below - --> -

        -

        --

        --

        -

        text_event

        -

        -

        - This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. -@@ -3169,17 +2058,15 @@ The idea is that %C can be used filename - Option text_event defines the value %C which then can be used in filenames and text_right/text_left. The text_event/%C uses the time stamp for the first image detected in a new event. %C is an empty string when no event is in progress (gap period expired). Pre_captured and minimum_motion_frames images are time stamped before the event happens so %C in text_left/right does not have any effect on those images. -

        -

        --

        --

        -

        text_left

        -

        -

        --User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). -+User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers (codes starting by a %). -

        - text_left is displayed in the lower left corner of the pictures. If the option is not defined no text is displayed at this position. -

        -@@ -3187,7 +2074,7 @@ You can place the text in quotation mark -

        - Detailed Description -

        --A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

          -+A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
            -
          • %Y = year -
          • %m = month as two digits -
          • %d = date -@@ -3212,10 +2099,7 @@ These are unique to motion
              -

              - With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. -

              --For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. --

              --

              --

              -+For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. -

              -

              -

              text_right

              -@@ -3223,10 +2107,10 @@ For a full list of conversion specifiers -
            • Type: String -
            • Range / Valid values: Max 4095 characters -
            • Default: %Y-%m-%d\n%T --
            • Option Topic -+
            • Option Topic -
            -

            --User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -+User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -

            - text_right is displayed in the lower right corner of the pictures. If the option is not defined no text is displayed at this position. -

            -@@ -3236,7 +2120,7 @@ A major difference from text_left is tha -

            - Detailed Description -

            --A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

              -+A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                -
              • %Y = year -
              • %m = month as two digits -
              • %d = date -@@ -3261,22 +2145,19 @@ These are unique to motion
                  -

                  - With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. -

                  --For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. --

                  -+For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. -

                  -

                  --

                  --

                  --

                  Advanced Filenames

                  -+

                  Advanced Filenames

                  - Motion has a very advanced and flexible automated filenaming feature. -

                  --By using conversion specifiers (codes that consist of a '%' followed by a letter) you can build up the filenames including sub directories for pictures and movies using any combination of letters, numbers and conversion specifiers which are codes that represents time, date, event number and frame numbers. -+By using conversion specifiers (codes that consist of a '%' followed by a letter) you can build up the filenames including sub directories for pictures and movies using any combination of letters, numbers and conversion specifiers which are codes that represents time, date, event number and frame numbers. -

                  - The option target_dir is the target directory for all snapshots, motion images and normal images. The default is the current working directory (current working directory of the terminal from which motion was started). You will normally always want to specify this parameter. -

                  - Note that the options snapshot_filename, jpeg_filename, ffmpeg_filename, and timelapse_filename all allow specifying directories by using '/' in the filename. These will all be relative to target_dir. This means in principle that you can specify target_dir as '/' and be 100% flexible. It also means that Motion can write files all over your harddisk if you make a mistake. It is recommended to specify the target_dir as deep or detailed as possible for this reason. And note that targer_dir does not allow conversion specifiers. -

                  --The conversion specifier %C which is defined by the option text_event is interesting in connection with filenames because it can be used to create files and directories for each event in a very flexible way. -+The conversion specifier %C which is defined by the option text_event is interesting in connection with filenames because it can be used to create files and directories for each event in a very flexible way. -

                  - The convertion specifier %t (thread/camera number) is also very useful. Here is an example of filename definitions in motion.conf: -

                  -@@ -3292,7 +2173,7 @@ The smart thing is that this defines the -

                  - NOTE: Unless you use the minimum_gap option to limit the number of shots to less then one per second - you must use the frame modifier %q as part of the jpeg_filename. Otherwise the pictures saved within the same second will overwrite each other. The %q in jpeg_filename ensures that each jpeg (or ppm) picture saved gets a unique filename. -

                  --ALERT! Security Warning! Note that the flexibility of this feature also means you have to pay attention to the following.

                    -+ALERT! Security Warning! Note that the flexibility of this feature also means you have to pay attention to the following.
                      -
                    • Anyone with access to the remote control port (http) can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. -
                    • Anyone with local access to the computer and edit rights to the motion.conf file can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Make sure the motion.conf file is maximum readonly to anyone else but the user running Motion. -
                    • It is a good idea to run Motion as a harmless user. Not as root. -@@ -3301,15 +2182,14 @@ NOTE: Unless you use the minimum_g - These are the advanced filename options in motion.conf -

                      -

                      --

                      -

                      ffmpeg_filename (now called movie_filename)

                      -

                      --ALERT! This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. -+ALERT! This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. -

                        -
                      • Type: String -
                      • Range / Valid values: Max 4095 characters -
                      • Default: %v-%Y%m%d%H%M%S --
                      • Option Topic -+
                      • Option Topic -
                      -

                      - File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. -@@ -3319,7 +2199,7 @@ For Motion 3.0 compatible mode (director -

                      - File extension .mpg or .avi is automatically added so do not include this. -

                      --This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                        -+This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                          -
                        • %Y = year -
                        • %m = month as two digits -
                        • %d = date -@@ -3345,21 +2225,19 @@ These are unique to motion
                            - If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and %Y/%m/%d/%H%M%S for 'oldlayout off'. -

                            -

                            --

                            --

                            -

                            jpeg_filename

                            -

                              -
                            • Type: String -
                            • Range / Valid values: Max 4095 characters -
                            • Default: %v-%Y%m%d%H%M%S-%q --
                            • Option Topic -+
                            • Option Topic -
                            -

                            - File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. -

                            - Default value is equivalent to legacy 'oldlayout' option. For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H/%M/%S-%q -

                            --This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                              -+This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                -
                              • %Y = year -
                              • %m = month as two digits -
                              • %d = date -@@ -3387,26 +2265,24 @@ If you are happy with the directory stru - The value 'preview' only works when 'output_normal' is set to 'best'. It makes Motion name the best preview jpeg file (image with most changed pixels during the event) with the same body name as the mpeg movie created during the same event. The purpose is to create a good single image that represents the saved mpeg moview so you can decide if you want to see it and spend time downloading it from a web page. -

                                -

                                --

                                --

                                -

                                movie_filename

                                -

                                  -
                                • Type: String -
                                • Range / Valid values: Max 4095 characters -
                                • Default: %v-%Y%m%d%H%M%S --
                                • Option Topic -+
                                • Option Topic -
                                -

                                - File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. -

                                --ALERT! This option was renamed from ffmpeg_filename to movie_filename in Motion 3.2.5. -+ALERT! This option was renamed from ffmpeg_filename to movie_filename in Motion 3.2.5. -

                                - Default value is equivalent to legacy 'oldlayout' option - For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H%M%S -

                                - File extension .mpg or .avi is automatically added so do not include this. -

                                --This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                  -+This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                    -
                                  • %Y = year -
                                  • %m = month as two digits -
                                  • %d = date -@@ -3432,14 +2308,12 @@ These are unique to motion
                                      - If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and %Y/%m/%d/%H%M%S for 'oldlayout off'. -

                                      -

                                      --

                                      --

                                      -

                                      snapshot_filename

                                      -

                                        -
                                      • Type: String -
                                      • Range / Valid values: Max 4095 characters -
                                      • Default: %v-%Y%m%d%H%M%S-snapshot --
                                      • Option Topic -+
                                      • Option Topic -
                                      -

                                      - File path for snapshots (jpeg or ppm) relative to target_dir. -@@ -3449,7 +2323,7 @@ Default value is equivalent to legacy 'o - File extension .jpg or .ppm is automatically added so do not include this - A symbolic link called lastsnap.jpg (or lastsnap.ppm) created in the target_dir will always point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -

                                      --This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                        -+This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                          -
                                        • %Y = year -
                                        • %m = month as two digits -
                                        • %d = date -@@ -3477,14 +2351,12 @@ If you are happy with the directory stru - For the equivalent of the now obsolete option 'snap_overwrite' use the value 'lastsnap'. -

                                          -

                                          --

                                          --

                                          -

                                          target_dir

                                          -

                                            -
                                          • Type: String -
                                          • Range / Valid values: Max 4095 characters -
                                          • Default: Not defined = current working directory --
                                          • Option Topic -+
                                          • Option Topic -
                                          -

                                          - Target directory for picture and movie files. -@@ -3494,14 +2366,12 @@ This is the target directory for all sna - Note that the options snapshot_filename, jpeg_filename, ffmpeg_filename, and timelapse_filename all allows specifying directories. These will all be relative to 'target_dir'. This means in principle that you can specify target_dir as '/' and be 100% flexible. It also means that Motion can write files all over your harddisk if you make a mistake. It is recommended to specify the target_dir as deep or detailed as possible for this reason. -

                                          -

                                          --

                                          --

                                          -

                                          timelapse_filename

                                          -

                                            -
                                          • Type: String -
                                          • Range / Valid values: Max 4095 characters -
                                          • Default: %v-%Y%m%d-timelapse --
                                          • Option Topic -+
                                          • Option Topic -
                                          -

                                          - File path for timelapse mpegs relative to target_dir (ffmpeg only). -@@ -3512,7 +2382,7 @@ For Motion 3.0 compatible mode (director -

                                          - File extension .mpg is automatically added so do not include this. -

                                          --This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                            -+This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:
                                              -
                                            • %Y = year -
                                            • %m = month as two digits -
                                            • %d = date -@@ -3538,219 +2408,68 @@ These are unique to motion
                                                - If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d-timelapse for 'oldlayout on' and %Y/%m/%d-timelapse for 'oldlayout off'. -

                                                -

                                                --

                                                --

                                                --

                                                --

                                                Conversion Specifiers for Advanced Filename and Text Features

                                                -+

                                                Conversion Specifiers for Advanced Filename and Text Features

                                                - The table below shows all the supported Conversion Specifiers you can use in the options text_event, text_left, text_right, sql_query, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. -

                                                - In text_left and text_right you can additionally use '\n' for new line. -

                                                -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                Conversion Specifier Description
                                                %a The abbreviated weekday name according to the current locale.
                                                %A The full weekday name according to the current locale.
                                                %b The abbreviated month name according to the current locale.
                                                %B The full month name according to the current locale.
                                                %c The preferred date and time representation for the current locale.
                                                %C Text defined by the text_event feature
                                                %d The day of the month as a decimal number (range 01 to 31).
                                                %D Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area.
                                                %E Modifier: use alternative format, see below.
                                                %f File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %F Equivalent to %Y-%m-%d (the ISO 8601 date format).
                                                %H The hour as a decimal number using a 24-hour clock (range 00 to 23).
                                                %i Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %I The hour as a decimal number using a 12-hour clock (range 01 to 12).
                                                %j The day of the year as a decimal number (range 001 to 366).
                                                %J Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.)
                                                %K X coordinate in pixels of the center point of motion. Origin is upper left corner.
                                                %l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.)
                                                %L Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon).
                                                %m The month as a decimal number (range 01 to 12).
                                                %M The minute as a decimal number (range 00 to 59).
                                                %n Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %N Noise level.
                                                %o Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold.
                                                %p Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'.
                                                %P Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
                                                %q Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs.
                                                %Q Number of detected labels found by the despeckle feature
                                                %r The time in a.m. or p.m. notation.
                                                %R The time in 24-hour notation (%H:%M).
                                                %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
                                                %S The second as a decimal number (range 00 to 61).
                                                %t Thread number (camera number)
                                                %T The time in 24-hour notation (%H:%M:%S).
                                                %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
                                                %U The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
                                                %v Event number. An event is a series of motion detections happening with less than 'gap' seconds between them.
                                                %V The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W.
                                                %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
                                                %W The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
                                                %x The preferred date representation for the current locale without the time.
                                                %X The preferred time representation for the current locale without the date.
                                                %y The year as a decimal number without a century (range 00 to 99).
                                                %Y The year as a decimal number including the century.
                                                %z The time-zone as hour offset from GMT.
                                                %Z The time zone or name or abbreviation.
                                                -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
                                                Conversion Specifier Description
                                                %a The abbreviated weekday name according to the current locale.
                                                %A The full weekday name according to the current locale.
                                                %b The abbreviated month name according to the current locale.
                                                %B The full month name according to the current locale.
                                                %c The preferred date and time representation for the current locale.
                                                %C Text defined by the text_event feature
                                                %d The day of the month as a decimal number (range 01 to 31).
                                                %D Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area.
                                                %E Modifier: use alternative format, see below.
                                                %f File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %F Equivalent to %Y-%m-%d (the ISO 8601 date format).
                                                %H The hour as a decimal number using a 24-hour clock (range 00 to 23).
                                                %i Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %I The hour as a decimal number using a 12-hour clock (range 01 to 12).
                                                %j The day of the year as a decimal number (range 001 to 366).
                                                %J Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                %k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.)
                                                %K X coordinate in pixels of the center point of motion. Origin is upper left corner.
                                                %l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.)
                                                %L Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon).
                                                %m The month as a decimal number (range 01 to 12).
                                                %M The minute as a decimal number (range 00 to 59).
                                                %n Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                %N Noise level.
                                                %o Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold.
                                                %p Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'.
                                                %P Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
                                                %q Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs.
                                                %Q Number of detected labels found by the despeckle feature
                                                %r The time in a.m. or p.m. notation.
                                                %R The time in 24-hour notation (%H:%M).
                                                %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
                                                %S The second as a decimal number (range 00 to 61).
                                                %t Thread number (camera number)
                                                %T The time in 24-hour notation (%H:%M:%S).
                                                %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
                                                %U The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
                                                %v Event number. An event is a series of motion detections happening with less than 'gap' seconds between them.
                                                %V The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W.
                                                %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
                                                %W The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
                                                %x The preferred date representation for the current locale without the time.
                                                %X The preferred time representation for the current locale without the date.
                                                %y The year as a decimal number without a century (range 00 to 99).
                                                %Y The year as a decimal number including the century.
                                                %z The time-zone as hour offset from GMT.
                                                %Z The time zone or name or abbreviation.
                                                -

                                                -

                                                --

                                                Webcam Server

                                                -+

                                                Webcam Server

                                                - Motion has simple webcam server built in. The video stream is in mjpeg format. -

                                                - Each thread can have its own webcam server. If you enable the webcam server (option webcam_port to a number different from 0) and you have more than one camera, you must make sure to include webcam_port in each thread config file and set webcam_port to different and unique port numbers or zero (disable). Otherwise each webcam server will use the setting from the motion.conf file and try to bind to the same port. If the webcam_port numbers are not different from each other Motion will disable the webcam feature. -

                                                --Note: The webcam server feature requires that the option ppm is set to off. -+Note: The webcam server feature requires that the option ppm is set to off. (I.e. saved images are jpeg images). -

                                                - The webcam_maxrate and webcam_quality options are important to limit the load on your server and link. Don't set them too high unless you only use it on the localhost or on an internal LAN. The option webcam_quality is equivalent to the quality level for jpeg pictures. -

                                                -@@ -3790,20 +2509,17 @@ Note that the stream.mjpg p - These are the special webcam parameters. -

                                                -

                                                --

                                                -

                                                webcam_limit

                                                -

                                                -

                                                - Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. -

                                                --Number can be defined by multiplying actual webcam rate by desired number of seconds. Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate. --

                                                --

                                                -+Number can be defined by multiplying actual webcam rate by desired number of seconds. Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate. -

                                                -

                                                -

                                                webcam_localhost

                                                -@@ -3811,7 +2527,7 @@ Number can be defined by multiplying act -
                                              • Type: Boolean -
                                              • Range / Valid values: on, off -
                                              • Default: on --
                                              • Option Topic -+
                                              • Option Topic -
                                              -

                                              - Limits the access to the webcam to the localhost. -@@ -3819,14 +2535,12 @@ Limits the access to the webcam to the l - By setting this to on, the webcam can only be accessed on the same machine on which Motion is running. -

                                              -

                                              --

                                              --

                                              -

                                              webcam_maxrate

                                              -

                                              -

                                              - Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. -@@ -3834,14 +2548,12 @@ Limit the framerate of the webcam in fra - Don't set 'webcam_maxrate' too high unless you only use it on the localhost or on an internal LAN. -

                                              -

                                              --

                                              --

                                              -

                                              webcam_motion

                                              -

                                              -

                                              - If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. -@@ -3852,13 +2564,12 @@ Note that this feature was greatly impro -

                                              -

                                              -

                                              --

                                              -

                                              webcam_port

                                              -

                                              -

                                              - TCP port on which motion will listen for incoming connects with its webcam server. -@@ -3868,23 +2579,19 @@ Note that each camera thread must have i - A good value to select is 8081 for camera 1, 8082 for camera 2, 8083 for camera 3 etc etc. -

                                              -

                                              --

                                              --

                                              -

                                              webcam_quality

                                              -

                                              -

                                              - Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. -

                                              - The mjpeg stream consists of a header followed by jpeg frames separated by content-length and boundary string. The quality level defines the size of the individual jpeg pictures in the mjpeg stream. If you set it too high you need quite a high bandwidth to view the stream. -

                                              --

                                              --

                                              --

                                              Remote Control with http

                                              -+

                                              Remote Control with http

                                              -

                                              - Motion can be remote controlled via a simple http interface. http is the language a normal web browser talks when it requests a web page. The web server answers back with some simple http headers followed by a webpage coded in HTML. -

                                              -@@ -3892,9 +2599,9 @@ Most Motion config options can be change -

                                              - So the most obvious tool to use to remote control Motion is any web browser. All commands are sent using the http GET method which simply means that the information is sent via the URL and maybe a query string. You can use any browser (Firefox, Mozilla, Internet Explorer, Konquerer, Opera etc). You can also use the text based browser lynx to control Motion from a console. It navigates fine through the very simple and minimalistic http control interface of Motion. -

                                              --The details about how to control Motion via the URL is described in detail in the Motion http API topic. -+The details about how to control Motion via the URL is described in detail in the Motion http API topic. -

                                              --But it is probably simpler to connect to the control port with a browser, navigate to the function you want, and copy the URL from the browser URL entry line. If your control_port is 8080 and you browse from the same machine on which Motion runs simply look up http://localhost:8080/ and navigate around. Connecting from a remote machine is done by using a domain name (example http://mydomain.com:8080/) or the IP address of the machine (example http://192.168.1.4:8080/). The option control_localhost must be off to allow connection from a remote machine. -+But it is probably simpler to connect to the control port with a browser, navigate to the function you want, and copy the URL from the browser URL entry line. If your control_port is 8080 and you browse from the same machine on which Motion runs simply look up http://localhost:8080/ and navigate around. Connecting from a remote machine is done by using a domain name (example http://mydomain.com:8080/) or the IP address of the machine (example http://192.168.1.4:8080/). The option control_localhost must be off to allow connection from a remote machine. -

                                              - If you want to use a script or cron to automatically change Motion settings while Motion runs you use a program that can fetch a webpage. We simply just throw away the html page that Motion returns. Programs commonly available on Linux machines are wget and lwp-request. Here is an example of how to start and stop motion detection via cron. These two lines are added to /etc/crontab. -

                                              -@@ -3913,7 +2620,7 @@ What happened to XMLRPC? -

                                              - XMLRPC is replaced by a simpler http remote control interface. It is still being worked on but it is absolutely useable now and much nicer to work with than xmlrpc. Another advantage is that you do not need to install xmlrpc libraries. It is all written in standard C. -

                                              --ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.

                                                -+ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.
                                                  -
                                                • Anyone with access to the remote control port (http) can alter the values of any options and save files anywhere on your server with the same privileges as the user running Motion. They can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. -
                                                • If you limit control port to localhost you still need to take care of any user logging into the server with any kind of terminal session. -
                                                • It is a good idea to run Motion as a harmless user. Not as root!! -@@ -3924,13 +2631,12 @@ XMLRPC is replaced by a simpler http rem - These must be placed in motion.conf and not in a thread config file. -

                                                  -

                                                  --

                                                  -

                                                  control_authentication

                                                  -

                                                  -

                                                  - To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. -@@ -3944,14 +2650,12 @@ Add Additional Description Below - --> -

                                                  -

                                                  --

                                                  --

                                                  -

                                                  control_html_output

                                                  -

                                                  -

                                                  - Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. -@@ -3959,14 +2663,12 @@ Enable HTML in the answer sent back to a - The recommended value for most is "on" which means that you can navigate and control Motion with a normal browser. By setting this option to "off" the replies are in plain text which may be easier to parse for 3rd party programs that control Motion. -

                                                  -

                                                  --

                                                  --

                                                  -

                                                  control_localhost

                                                  -

                                                  -

                                                  - Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. -@@ -3974,14 +2676,12 @@ Limits the http (html) control to the lo - By setting this to on, the control using http (browser) can only be accessed on the same machine on which Motion is running. -

                                                  -

                                                  --

                                                  --

                                                  -

                                                  control_port

                                                  -

                                                  -

                                                  - Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. -@@ -3990,68 +2690,29 @@ This sets the TCP/IP port number to be u -

                                                  -

                                                  -

                                                  -+-- KennethLavrsen - 12 Apr 2005 -

                                                  ---- KennethLavrsen - 12 Apr 2005 -

                                                  --

                                                  External Commands

                                                  -+

                                                  External Commands

                                                  - Motion can execute external commands based on the motion detection and related events. They are all described in this section. The option quiet is also included in this section. -

                                                  - A redesign of the external commands was due. They were not very easy to understand, not all were flexible enough and some were missing. So a new external command feature set was made for 3.2.1 and on. -

                                                  - This is how the new script commands look like: -

                                                  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                  Function Old Option New Option Argument Appended
                                                  Start of event (first motion) execute on_event_start None
                                                  End of event (no motion for gap seconds) New! on_event_end None
                                                  Picture saved (jpg or ppm) onsave on_picture_save Filename of picture
                                                  Movie starts (mpeg file opened) onmpeg on_movie_start Filename of movie
                                                  Movie ends (mpeg file closed) onffmpegclose on_movie_end Filename of movie
                                                  Motion detected (each single frame with Motion detected) New! on_motion_detected None
                                                  -+ -+ -+ -+ -+ -+ -+ -+
                                                  Function Old Option New Option Argument Appended
                                                  Start of event (first motion) execute on_event_start None
                                                  End of event (no motion for gap seconds) New! on_event_end None
                                                  Picture saved (jpg or ppm) onsave on_picture_save Filename of picture
                                                  Movie starts (mpeg file opened) onmpeg on_movie_start Filename of movie
                                                  Movie ends (mpeg file closed) onffmpegclose on_movie_end Filename of movie
                                                  Motion detected (each single frame with Motion detected) New! on_motion_detected None
                                                  -

                                                  --Mail and sms has been removed because they were not configurable. If you want to send event-based mails or sms, just use one of those commands above and send the mail from that script. See What happened to mail and sms? -+Mail and sms has been removed because they were not configurable. If you want to send event-based mails or sms, just use one of those commands above and send the mail from that script. See What happened to mail and sms? -

                                                  -

                                                  --ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.

                                                    -+ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.
                                                      -
                                                    • Anyone with access to the remote control port (http) can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. -
                                                    • If you limit control port to localhost you still need to take care of any user logging into the server with any kind of GUI or terminal session. All it takes is a browser or single command line execution to change settings in Motion. -
                                                    • It is a good idea to run Motion as a harmless user. Not as root!! -@@ -4060,52 +2721,15 @@ Mail and sms has been removed because th - These are the options -

                                                      -

                                                      --

                                                      --

                                                      on_area_detected

                                                      --

                                                        --
                                                      • Type: String --
                                                      • Range / Valid values: Max 4095 characters --
                                                      • Default: Not defined --
                                                      • Option Topic --
                                                      --

                                                      --Command to be executed when motion in a predefined area is detected. Check option area_detect. --

                                                      -- --

                                                      --

                                                      --

                                                      --

                                                      --

                                                      on_camera_lost

                                                      --

                                                        --
                                                      • Type: String --
                                                      • Range / Valid values: Max 4095 characters --
                                                      • Default: Not defined --
                                                      • Option Topic --
                                                      --

                                                      --Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10) --

                                                      -- --

                                                      --NOTE: There is situations when motion don't detect a lost camera!
                                                      It depends on the driver, some drivers dosn't detect a lost camera at all
                                                      Some hangs the motion thread. Some even hangs the PC! --

                                                      --

                                                      --

                                                      --

                                                      -

                                                      on_event_end

                                                      -

                                                      -

                                                      --Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. -+Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. -

                                                      - Full path name of the program/script. -

                                                      -@@ -4114,17 +2738,15 @@ This can be any type of program or scrip - The command is run when an event is over. I.e. the number of seconds defined by the time 'gap' has passed since the last detection of motion and motion closes the mpeg file. -

                                                      -

                                                      --

                                                      --

                                                      -

                                                      on_event_start

                                                      -

                                                      -

                                                      --Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. -+Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. -

                                                      - Full path name of the program/script. -

                                                      -@@ -4135,31 +2757,28 @@ The command is run when an event starts. - This option replaces the former options 'mail', 'sms' and 'execute'. -

                                                      -

                                                      --

                                                      --

                                                      -

                                                      on_motion_detected

                                                      -

                                                      -

                                                      --Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. -+Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. -

                                                      - Do not write "none" if you do not want to execute commands. Simply do not include the option in the file or comment it out by placing a "#" or ";" as the first character on the line before the execute command. -

                                                      -

                                                      --

                                                      -

                                                      on_movie_end

                                                      -

                                                      -

                                                      --Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -+Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -

                                                      - Full path name of the program/script. -

                                                      -@@ -4171,7 +2790,7 @@ This option was previously called onffmp -

                                                      - Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. -

                                                      --Most common conversion specifiers -+Most common conversion specifiers -

                                                        -
                                                      • %Y = year, %m = month, %d = date -
                                                      • %H = hour, %M = minute, %S = second -@@ -4188,28 +2807,25 @@ Most common on_movie_start -

                                                        -

                                                        --Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -+Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -

                                                        - Full path name of the program/script. -

                                                        --This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. When you use ffmpeg the film is generated on the fly and on_movie_start then runs when the new mpeg file is created. Often you will want to use the on_movie_end option which runs when the mpeg file is closed and the event is over. -+This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. When you use ffmpeg the film is generated on the fly and on_movie_start then runs when the new mpeg file is created. Often you will want to use the on_movie_end option which runs when the mpeg file is closed and the event is over. -

                                                        - This option was previously called onmpeg. -

                                                        - Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. -

                                                        --Most common conversion specifiers -+Most common conversion specifiers -

                                                          -
                                                        • %Y = year, %m = month, %d = date -
                                                        • %H = hour, %M = minute, %S = second -@@ -4226,18 +2842,15 @@ Most common on_picture_save -

                                                          -

                                                          --Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -+Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -

                                                          - Full path name of the program/script. -

                                                          -@@ -4245,7 +2858,7 @@ This can be any type of program or scrip -

                                                          - Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. -

                                                          --Most common conversion specifiers -+Most common conversion specifiers -

                                                            -
                                                          • %Y = year, %m = month, %d = date -
                                                          • %H = hour, %M = minute, %S = second -@@ -4262,15 +2875,12 @@ Most common quiet -

                                                            -

                                                            - Be quiet, don't output beeps when detecting motion. -@@ -4279,15 +2889,14 @@ Only works in non-daemon mode. -

                                                            -

                                                            -

                                                            --

                                                            - --

                                                            What happened to mail and sms?

                                                            -+

                                                            What happened to mail and sms?

                                                            - The 6 new on_xxxxx options replace the former execute, mail and sms options. -

                                                            - They are quite generic and flexible. These small bash scripts gives to the same functionality as mail and sms BUT you have all the flexibility you want to extend the messages, change the 'from' email address etc. -

                                                            -

                                                            Sending email at start of event

                                                            --Script written by JoergWeber -+Script written by JoergWeber -
                                                            - #!/bin/sh
                                                            - 
                                                            -@@ -4309,7 +2918,7 @@ echo -e "This is an automated messag
                                                            - 
                                                            -

                                                            -

                                                            Sending SMS at start of event

                                                            --Script written by JoergWeber -+Script written by JoergWeber -

                                                            - If you uncomment the line #/usr/local/bin/send_mail $1 you can combine both sending email and sms. -

                                                            -@@ -4337,28 +2946,26 @@ $SMS_CLIENT $TO "Motion detected
                                                            - 
                                                            -

                                                            -

                                                            --

                                                            -

                                                            Motion Guide - Special Features

                                                            -

                                                            --

                                                            Tracking Control

                                                            --This is still at the experimental stage. Read more about it motion tracking page. -+

                                                            Tracking Control

                                                            -+This is still at the experimental stage. Read more about it motion tracking page. -

                                                            -

                                                            Tracking Feature with Logitech Quickcam Sphere/Orbit

                                                            - Motion supports controlling the pan and tilt feature of a Logitech Quickcam Sphere/Orbit. -

                                                            --Motion can move the camera to a fixed position given in degrees pan (left-right) and tilt (down-up). Movement can be set with absolute coordinates or relative to current position. There is also an auto tracking feature for the Logitech Quickcam Sphere/Orbit but it is not very mature. It is fun to play with but not very useful yet. See this topic of how KennethLavrsen controls his Sphere: LogitechSphereControl. -+Motion can move the camera to a fixed position given in degrees pan (left-right) and tilt (down-up). Movement can be set with absolute coordinates or relative to current position. There is also an auto tracking feature for the Logitech Quickcam Sphere/Orbit but it is not very mature. It is fun to play with but not very useful yet. See this topic of how KennethLavrsen controls his Sphere: LogitechSphereControl. -

                                                            --For a detailed description of http remote control see the section Remote Control with http. -+For a detailed description of http remote control see the section Remote Control with http. -

                                                            - List of tracking options -

                                                            --

                                                            -

                                                            track_auto

                                                            -

                                                            -

                                                            - Enable auto tracking -@@ -4366,14 +2973,12 @@ Enable auto tracking - Requires a tracking camera type supported by Motion. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_iomojo_id

                                                            -

                                                              -
                                                            • Type: Integer --
                                                            • Range / Valid values: 0 - 65535 -+
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 --
                                                            • Option Topic -+
                                                            • Option Topic -
                                                            -

                                                            - Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. -@@ -4381,14 +2986,12 @@ Use this option if you have an iomojo sm - Only used for iomojo camera. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_maxx

                                                            -

                                                              -
                                                            • Type: Integer --
                                                            • Range / Valid values: 0 - 65535 --
                                                            • Default: 0 --
                                                            • Option Topic -+
                                                            • Range / Valid values: 0 - 2147483647 -+
                                                            • Default: 0 -+
                                                            • Option Topic -
                                                            -

                                                            - The maximum position for servo x. -@@ -4396,14 +2999,12 @@ The maximum position for servo x. - Only used for stepper motor tracking. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_maxy

                                                            -

                                                              -
                                                            • Type: Integer --
                                                            • Range / Valid values: 0 - 65535 -+
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 --
                                                            • Option Topic -+
                                                            • Option Topic -
                                                            -

                                                            - The maximum position for servo y. -@@ -4415,14 +3016,12 @@ Add Additional Description Below - --> -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_motorx

                                                            -

                                                              -
                                                            • Type: Integer --
                                                            • Range / Valid values: 0 - 65535 --
                                                            • Default: 0 --
                                                            • Option Topic -+
                                                            • Range / Valid values: -1 - 2147483647 -+
                                                            • Default: -1 -+
                                                            • Option Topic -
                                                            -

                                                            - The motor number that is used for controlling the x-axis. -@@ -4430,14 +3029,12 @@ The motor number that is used for contro - Only used for stepper motor tracking. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_motory

                                                            -

                                                              -
                                                            • Type: Integer --
                                                            • Range / Valid values: 0 - 65535 --
                                                            • Default: 0 --
                                                            • Option Topic -+
                                                            • Range / Valid values: -1 - 2147483647 -+
                                                            • Default: -1 -+
                                                            • Option Topic -
                                                            -

                                                            - The motor number that is used for controlling the y-axis. -@@ -4449,14 +3046,12 @@ Add Additional Description Below - --> -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_move_wait

                                                            -

                                                              -
                                                            • Type: Integer --
                                                            • Range / Valid values: 0 - 65535 -+
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 10 --
                                                            • Option Topic -+
                                                            • Option Topic -
                                                            -

                                                            - Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. -@@ -4464,14 +3059,12 @@ Delay during which tracking is disabled - The actual delay is depending on the chosen framerate. If you want the camera to move maximum once every 2 seconds and the framerate is 10 then you need to set the track_move_wait value to 2 * 10 = 20. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_port

                                                            -

                                                            -

                                                            - This is the device name of the serial port to which the stepper motor interface is connected. -@@ -4479,14 +3072,12 @@ This is the device name of the serial po - Only used for stepper motor tracking. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_speed

                                                            -

                                                            -

                                                            - Speed to set the motor to. -@@ -4494,14 +3085,12 @@ Speed to set the motor to. - Only used for stepper motor tracking. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_step_angle_x

                                                            -

                                                            -

                                                            - Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. -@@ -4509,14 +3098,12 @@ Angle in degrees the camera moves per st - Requires a tracking camera type pwc. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_step_angle_y

                                                            -

                                                            -

                                                            - Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. -@@ -4528,14 +3115,12 @@ Add Additional Description Below - --> -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_stepsize

                                                            -

                                                            -

                                                            - Number of steps to make. -@@ -4543,52 +3128,45 @@ Number of steps to make. - Only used for stepper motor tracking. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            track_type

                                                            -

                                                              -
                                                            • Type: Discrete Strings -
                                                            • Range / Valid values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) -
                                                            • Default: 0 (None) --
                                                            • Option Topic -+
                                                            • Option Topic -
                                                            -

                                                            - Type of tracker. -

                                                            --Motion has special tracking options which use either a serial stepper motor controller, an iomojo smile cam or a Philips WebCam driver compatible pan/tilt camera such as the Logitech Quickcam Sphere or Orbit. -+Motion has special tracking options which use either a serial stepper motor controller, an iomojo smile cam or a Philips WebCam driver compatible pan/tilt camera such as the Logitech Quickcam Sphere or Orbit. -

                                                            - To disable tracking, set this to 0 and the other track options are ignored. -

                                                            --Value 1 is for the special Motion Tracking project using a stepper motor and a home made controller. -+Value 1 is for the special Motion Tracking project using a stepper motor and a home made controller. -

                                                            - Value 2 is for the iomojo smilecam -

                                                            --Value 3 is for pwc type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit which is driven by the pwc (Philips WebCam) driver. To use this camera your version of pwc must be at least 8.12. -+Value 3 is for pwc type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit which is driven by the pwc (Philips WebCam) driver. To use this camera your version of pwc must be at least 8.12. -

                                                            - Value 4 is the generic track type. Currently it has no other function than enabling some of the internal Motion features related to tracking. Eventually more functionality will be implemented for this type. -

                                                            - Value 5 is for uvcvideo type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit MP (new Model) which is driven by the uvcvideo driver. This option was added in Motion 3.2.8. -

                                                            -

                                                            --

                                                            --

                                                            --

                                                            --

                                                            --

                                                            Using Databases

                                                            --Motion can be compiled with both MySQL and PostgreSQL database support. When enabled Motion adds a record to a table in the database as specified by the sql_query. The query contains the fields that are used and the value are given by using conversion specifiers for dynamic data like filename, time, number of detected pixels etc. Motion does not place any binary images in the database and it cannot remove old records. -+

                                                            Using Databases

                                                            -+Motion can be compiled with both MySQL and PostgreSQL database support. When enabled Motion adds a record to a table in the database as specified by the sql_query. The query contains the fields that are used and the value are given by using conversion specifiers for dynamic data like filename, time, number of detected pixels etc. Motion does not place any binary images in the database and it cannot remove old records. -

                                                            - Motion only adds records to the database when files are created. The database contains records of saved files which means to get a record in the database the feature that enables for example motion detection, timelapse, snapshots etc must be enabled. The sql_log options defines which types of files are logged in the database. -

                                                            - The following sql_log options are common to both MySQL and PostgreSQL. -

                                                            -

                                                            --

                                                            -

                                                            sql_log_image

                                                            -

                                                            -

                                                            - Log to the database when creating motion triggered image file. -@@ -4596,14 +3174,12 @@ Log to the database when creating motion - Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            sql_log_mpeg

                                                            -

                                                            -

                                                            - Log to the database when creating motion triggered mpeg file. -@@ -4611,14 +3187,12 @@ Log to the database when creating motion - Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            sql_log_snapshot

                                                            -

                                                            -

                                                            - Log to the database when creating a snapshot image file. -@@ -4626,14 +3200,12 @@ Log to the database when creating a snap - Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            sql_log_timelapse

                                                            -

                                                            -

                                                            - Log to the database when creating timelapse mpeg file -@@ -4641,19 +3213,17 @@ Log to the database when creating timela - Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                            -

                                                            --

                                                            --

                                                            -

                                                            sql_query

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') --
                                                            • Option Topic -+
                                                            • Option Topic -
                                                            -

                                                            --SQL query string that is sent to the database. The values for each field are given by using convertion specifiers -+SQL query string that is sent to the database. The values for each field are given by using convertion specifiers -

                                                            --Most common conversion specifiers -+Most common conversion specifiers -

                                                              -
                                                            • %Y = year, %m = month, %d = date -
                                                            • %H = hour, %M = minute, %S = second -@@ -4670,13 +3240,12 @@ Most common --

                                                              MySQL

                                                              -+

                                                              MySQL

                                                              - You can use the MySQL database to register each file that is stored by motion. -

                                                              --You need to generate a new database with a name of your own choice. You must enter this name in the config file (mysql_db option). The default value for the option sql_query requires that you create a new database in MySQL with a new table called "security" with the following fields: -+You need to generate a new database with a name of your own choice. You must enter this name in the config file (mysql_db option). The default value for the option sql_query requires that you create a new database in MySQL with a new table called "security" with the following fields: -

                                                              - insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -

                                                                -@@ -4688,37 +3257,17 @@ insert into security(camera, filename, f -
                                                              • text_event (timestamp) - The text from the text_event option which by default is compatible with timestamps in SQL. -
                                                              -

                                                              --Note from version 3.2.4 the introduction of sql_query completely redefines the way you setup the SQL feature. It is now 100% flexible and can easily be made compatible with your existing Motion database from earlier versions of Motion. -+Note from version 3.2.4 the introduction of sql_query completely redefines the way you setup the SQL feature. It is now 100% flexible and can easily be made compatible with your existing Motion database from earlier versions of Motion. -

                                                              - These are the file type descriptions and the file type numbers stored in the database. -

                                                              -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
                                                              Normal image 1
                                                              Snapshot image 2
                                                              Motion image (showing only pixels defined as motion) 4
                                                              Normal mpeg image 8
                                                              Motion mpeg (showing only pixels defined as motion) 16
                                                              Timelapse mpeg 32
                                                              -+ -+ -+ -+ -+ -+ -+
                                                              Normal image 1
                                                              Snapshot image 2
                                                              Motion image (showing only pixels defined as motion) 4
                                                              Normal mpeg image 8
                                                              Motion mpeg (showing only pixels defined as motion) 16
                                                              Timelapse mpeg 32
                                                              -

                                                              - You can create the table using the following SQL statement. -

                                                              -@@ -4742,13 +3291,12 @@ The The options for MySQL -

                                                              -

                                                              --

                                                              -

                                                              mysql_db

                                                              -

                                                              -

                                                              - Name of the MySQL database. -@@ -4758,14 +3306,12 @@ MySQL CONFIG FILE OPTION. Motion must be - If you compiled motion with MySQL support you will need to set the mysql options if you want motion to log events to the database. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              mysql_host

                                                              -

                                                              -

                                                              - IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. -@@ -4773,14 +3319,12 @@ IP address or domain name for the MySQL - MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              mysql_password

                                                              -

                                                              -

                                                              - The MySQL password. -@@ -4788,14 +3332,12 @@ The MySQL password. - MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              mysql_user

                                                              -

                                                              -

                                                              - The MySQL user name. -@@ -4804,20 +3346,18 @@ MySQL CONFIG FILE OPTION. Motion must be -

                                                              -

                                                              -

                                                              --

                                                              --

                                                              PostgreSQL

                                                              -+

                                                              PostgreSQL

                                                              - Same/similar as for MySQL above. -

                                                              - The options for PostgreSQL -

                                                              -

                                                              --

                                                              -

                                                              pgsql_db

                                                              -

                                                              -

                                                              - Name of the PostgreSQL database. -@@ -4827,14 +3367,12 @@ PostgreSQL CONFIG FILE OPTION. Motion mu - If you compiled motion with PostgreSQL support you will need to set all the pgsql_ options if you want motion to log events to the database. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              pgsql_host

                                                              -

                                                              -

                                                              - IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. -@@ -4842,14 +3380,12 @@ IP address or domain name for the Postgr - PostgreSQL CONFIG FILE OPTION. Motion must be built with pgsql_db libraries to use this feature. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              pgsql_password

                                                              -

                                                              -

                                                              - The PostgreSQL password. -@@ -4857,14 +3393,12 @@ The PostgreSQL password. - PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              pgsql_port

                                                              -

                                                              -

                                                              - The PostgreSQL server port number. -@@ -4872,14 +3406,12 @@ The PostgreSQL server port number. - PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -

                                                              --

                                                              --

                                                              -

                                                              pgsql_user

                                                              -

                                                              -

                                                              - The PostgreSQL user name. -@@ -4887,12 +3419,8 @@ The PostgreSQL user name. - PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -

                                                              --

                                                              --

                                                              --

                                                              --

                                                              --

                                                              Video4Linux Loopback Device

                                                              --You can use this driver for looking at motion in realtime. The video4linux driver is written by the same author that first created Motion. You can find the source and a brief description at the video4linux loopback device web page. -+

                                                              Video4Linux Loopback Device

                                                              -+You can use this driver for looking at motion in realtime. The video4linux driver is written by the same author that first created Motion. You can find the source and a brief description at the video4linux loopback device web page. -

                                                              - The video4linux device is a Kernel module which installs itself as a video pipe. It has an input and an output. The module simply takes anything that comes on its input and send it out at the output. The purpose of this is to create a standard video4linux type video device that other programs can then use. You may now ask: "What do I need that for?". -

                                                              -@@ -4925,7 +3453,7 @@ You may need to set the ownership and pe -

                                                              - Now you need to install the video loopback device. -

                                                              --Download the latest video4linux loopback device . Place the file in a place of your own choice. -+Download the latest video4linux loopback device . Place the file in a place of your own choice. -

                                                              - Untar and uncompress the file to the place you want the program installed. Editor recommends /usr/local/vloopback. -

                                                              -@@ -4979,13 +3507,12 @@ De-activating should be done with this c - Description of the motion.conf options related to video loopback device. -

                                                              -

                                                              --

                                                              -

                                                              motion_video_pipe

                                                              -

                                                              -

                                                              - The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set -@@ -4995,15 +3522,12 @@ Using this you can view the results in r - Disable this option by not having it in the config file (or comment it out with "#" or ";"). -

                                                              -

                                                              --

                                                              --

                                                              --

                                                              -

                                                              video_pipe

                                                              -

                                                              -

                                                              - The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. -@@ -5015,7 +3539,4 @@ Disable this option by not having it in -

                                                              -

                                                              -

                                                              --

                                                              --

                                                              --

                                                              ---- KennethLavrsen - 13 Apr 2005 -\ No newline at end of file -+-- KennethLavrsen - 13 Apr 2005 -\ No newline at end of file ---- motion-3.2.12.orig/netcam.c -+++ motion-3.2.12/netcam.c -@@ -41,46 +41,38 @@ - - #include - #include --#include /* For parsing of the URL */ -+#include /* For parsing of the URL */ - #include - - #include "netcam_ftp.h" -+#include "netcam_rtsp.h" - --#define CONNECT_TIMEOUT 10 /* timeout on remote connection attempt */ --#define READ_TIMEOUT 5 /* default timeout on recv requests */ --#define POLLING_TIMEOUT READ_TIMEOUT /* file polling timeout [s] */ --#define POLLING_TIME 500*1000*1000 /* file polling time quantum [ns] (500ms) */ --#define MAX_HEADER_RETRIES 5 /* Max tries to find a header record */ -+#define CONNECT_TIMEOUT 10 /* Timeout on remote connection attempt */ -+#define READ_TIMEOUT 5 /* Default timeout on recv requests */ -+#define POLLING_TIMEOUT READ_TIMEOUT /* File polling timeout [s] */ -+#define POLLING_TIME 500*1000*1000 /* File polling time quantum [ns] (500ms) */ -+#define MAX_HEADER_RETRIES 5 /* Max tries to find a header record */ - #define MINVAL(x, y) ((x) < (y) ? (x) : (y)) - --/* -- * The macro NETCAM_DEBUG is for development testing of this module. -- * The macro SETUP is to assure that "configuration-setup" type messages -- * are also printed when NETCAM_DEBUG is set. Set the following #if to -- * 1 to enable it, or 0 (normal setting) to disable it. -- */ --#define SETUP ((cnt->conf.setup_mode) || (debug_level >= CAMERA_INFO)) -- -- - tfile_context *file_new_context(void); - void file_free_context(tfile_context* ctxt); - --/* These strings are used for the HTTP connection */ --static const char *connect_req; -+/* These strings are used for the HTTP connection. */ -+static const char *connect_req; - --static const char *connect_req_http10 = "GET %s HTTP/1.0\r\n" -- "Host: %s\r\n" -- "User-Agent: Motion-netcam/" VERSION "\r\n"; -+static const char *connect_req_http10 = "GET %s HTTP/1.0\r\n" -+ "Host: %s\r\n" -+ "User-Agent: Motion-netcam/" VERSION "\r\n"; - --static const char *connect_req_http11 = "GET %s HTTP/1.1\r\n" -- "Host: %s\r\n" -- "User-Agent: Motion-netcam/" VERSION "\r\n"; -+static const char *connect_req_http11 = "GET %s HTTP/1.1\r\n" -+ "Host: %s\r\n" -+ "User-Agent: Motion-netcam/" VERSION "\r\n"; - --static const char *connect_req_close = "Connection: close\r\n"; -+static const char *connect_req_close = "Connection: close\r\n"; - --static const char *connect_req_keepalive = "Connection: Keep-Alive\r\n"; -+static const char *connect_req_keepalive = "Connection: Keep-Alive\r\n"; - --static const char *connect_auth_req = "Authorization: Basic %s\r\n"; -+static const char *connect_auth_req = "Authorization: Basic %s\r\n"; - - /* - * The following three routines (netcam_url_match, netcam_url_parse and -@@ -129,7 +121,7 @@ static char *netcam_url_match(regmatch_t - if (m.rm_so != -1) { - len = m.rm_eo - m.rm_so; - -- if ((match = (char *) malloc(len + 1)) != NULL) { -+ if ((match = (char *) mymalloc(len + 1)) != NULL) { - strncpy(match, input + m.rm_so, len); - match[len] = '\0'; - } -@@ -155,17 +147,18 @@ static void netcam_url_parse(struct url_ - { - char *s; - int i; -- const char *re = "(http|ftp)://(((.*):(.*))@)?" -+ -+ const char *re = "(http|ftp|mjpg|mjpeg|rtsp)://(((.*):(.*))@)?" - "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))"; - regex_t pattbuf; - regmatch_t matches[10]; - -- if (!strncmp( text_url, "file", 4 ) ) -+ if (!strncmp(text_url, "file", 4)) - re = "(file)://(((.*):(.*))@)?" - "([^/:]|[-.a-z0-9]*)(:([0-9]*))?($|(/[^:][/-_.a-z0-9]+))"; - -- if (debug_level > CAMERA_DEBUG) -- motion_log(-1, 0, "Entry netcam_url_parse data %s", text_url ); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Entry netcam_url_parse data %s", -+ text_url); - - memset(parse_url, 0, sizeof(struct url_t)); - /* -@@ -173,14 +166,14 @@ static void netcam_url_parse(struct url_ - * suitable for regexec searches - * regexec matches the URL string against the regular expression - * and returns an array of pointers to strings matching each match -- * within (). The results that we need are finally placed in parse_url -+ * within (). The results that we need are finally placed in parse_url. - */ - if (!regcomp(&pattbuf, re, REG_EXTENDED | REG_ICASE)) { - if (regexec(&pattbuf, text_url, 10, matches, 0) != REG_NOMATCH) { - for (i = 0; i < 10; i++) { - if ((s = netcam_url_match(matches[i], text_url)) != NULL) { -- if (debug_level > CAMERA_DEBUG) -- motion_log(-1, 0, "Parse case %d data %s", i, s ); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Parse case %d" -+ " data %s", i, s); - switch (i) { - case 1: - parse_url->service = s; -@@ -198,7 +191,7 @@ static void netcam_url_parse(struct url_ - case 9: - parse_url->path = s; - break; -- /* other components ignored */ -+ /* Other components ignored */ - default: - free(s); - break; -@@ -207,11 +200,13 @@ static void netcam_url_parse(struct url_ - } - } - } -- if ((!parse_url->port) && (parse_url->service)){ -+ if ((!parse_url->port) && (parse_url->service)) { - if (!strcmp(parse_url->service, "http")) - parse_url->port = 80; - else if (!strcmp(parse_url->service, "ftp")) - parse_url->port = 21; -+ else if (!strcmp(parse_url->service, "rtsp") && parse_url->port == 0) -+ parse_url->port = 554; - } - - regfree(&pattbuf); -@@ -224,12 +219,12 @@ static void netcam_url_parse(struct url_ - * - * Parameters: - * -- * parse_url Structure containing the parsed data -+ * parse_url Structure containing the parsed data. - * - * Returns: Nothing - * - */ --static void netcam_url_free(struct url_t *parse_url) -+void netcam_url_free(struct url_t *parse_url) - { - if (parse_url->service) { - free(parse_url->service); -@@ -260,9 +255,9 @@ static void netcam_url_free(struct url_t - * - * Parameters: - * -- * str Pointer to a string -+ * str Pointer to a string. - * -- * Returns: Nothing, but updates the target if necessary -+ * Returns: Nothing, but updates the target if necessary. - * - */ - static void check_quote(char *str) -@@ -284,20 +279,20 @@ static void check_quote(char *str) - /** - * netcam_check_content_length - * -- * Analyse an HTTP-header line to see if it is a Content-length -+ * Analyse an HTTP-header line to see if it is a Content-length. - * - * Parameters: - * -- * header Pointer to a string containing the header line -+ * header Pointer to a string containing the header line. - * - * Returns: -- * -1 Not a Content-length line -- * >=0 Value of Content-length field -+ * -1 Not a Content-length line. -+ * >=0 Value of Content-length field. - * - */ - static long netcam_check_content_length(char *header) - { -- long length = -1; /* note this is a long, not an int */ -+ long length = -1; /* Note this is a long, not an int. */ - - if (!header_process(header, "Content-Length", header_extract_number, &length)) { - /* -@@ -306,10 +301,13 @@ static long netcam_check_content_length( - * number we might as well try to use it. - */ - if (length > 0) -- return length; -- return -1; -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: malformed token" -+ " Content-Length but value %ld", length); - } - -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length %ld", -+ length); -+ - return length; - } - -@@ -320,11 +318,11 @@ static long netcam_check_content_length( - * - * Parameters: - * -- * header Pointer to a string containing the header line -+ * header Pointer to a string containing the header line. - * - * Returns: -- * -1 Not a Keep-Alive line -- * 1 Is a Keep-Alive line -+ * -1 Not a Keep-Alive line. -+ * 1 Is a Keep-Alive line. - * - */ - static int netcam_check_keepalive(char *header) -@@ -335,7 +333,6 @@ static int netcam_check_keepalive(char * - return -1; - - /* We do not detect the second field or other case mixes at present. */ -- - if (content_type) - free(content_type); - -@@ -345,15 +342,15 @@ static int netcam_check_keepalive(char * - /** - * netcam_check_close - * -- * Analyse an HTTP-header line to see if it is a Connection: close -+ * Analyse an HTTP-header line to see if it is a Connection: close. - * - * Parameters: - * -- * header Pointer to a string containing the header line -+ * header Pointer to a string containing the header line. - * - * Returns: -- * -1 Not a Connection: close -- * 1 Is a Connection: close -+ * -1 Not a Connection: close. -+ * 1 Is a Connection: close. - * - */ - static int netcam_check_close(char *header) -@@ -364,7 +361,7 @@ static int netcam_check_close(char *head - if (!header_process(header, "Connection", http_process_type, &type)) - return -1; - -- if (!strcmp(type, "close")) /* strcmp returns 0 for match */ -+ if (!strcmp(type, "close")) /* strcmp returns 0 for match. */ - ret = 1; - - if (type) -@@ -376,17 +373,18 @@ static int netcam_check_close(char *head - /** - * netcam_check_content_type - * -- * Analyse an HTTP-header line to see if it is a Content-type -+ * Analyse an HTTP-header line to see if it is a Content-type. - * - * Parameters: - * -- * header Pointer to a string containing the header line -+ * header Pointer to a string containing the header line. - * - * Returns: - * -1 Not a Content-type line - * 0 Content-type not recognized - * 1 image/jpeg - * 2 multipart/x-mixed-replace or multipart/mixed -+ * 3 application/octet-stream (used by WVC200 Linksys IP Camera) - * - */ - static int netcam_check_content_type(char *header) -@@ -397,15 +395,20 @@ static int netcam_check_content_type(cha - if (!header_process(header, "Content-type", http_process_type, &content_type)) - return -1; - -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Content-type %s", -+ content_type); -+ - if (!strcmp(content_type, "image/jpeg")) { - ret = 1; - } else if (!strcmp(content_type, "multipart/x-mixed-replace") || - !strcmp(content_type, "multipart/mixed")) { - ret = 2; -+ } else if (!strcmp(content_type, "application/octet-stream")) { -+ ret = 3; - } else { - ret = 0; - } -- -+ - if (content_type) - free(content_type); - -@@ -420,9 +423,9 @@ static int netcam_check_content_type(cha - * - * Parameters - * -- * netcam pointer to a netcam_context -+ * netcam pointer to a netcam_context. - * -- * Returns: 0 for success, -1 if any error -+ * Returns: 0 for success, -1 if any error. - * - */ - static int netcam_read_next_header(netcam_context_ptr netcam) -@@ -430,9 +433,7 @@ static int netcam_read_next_header(netca - int retval; - char *header; - -- /* -- * return if not connected -- */ -+ /* Return if not connected */ - if (netcam->sock == -1) - return -1; - /* -@@ -444,25 +445,26 @@ static int netcam_read_next_header(netca - * - */ - netcam->caps.content_length = 0; -+ - /* - * If this is a "streaming" camera, the stream header must be -- * preceded by a "boundary" string -+ * preceded by a "boundary" string. - */ -- if (netcam->caps.streaming) { -+ if (netcam->caps.streaming == NCS_MULTIPART) { - while (1) { - retval = header_get(netcam, &header, HG_NONE); - - if (retval != HG_OK) { -- /* Header reported as not-OK, check to see if it's null */ -+ /* Header reported as not-OK, check to see if it's null. */ - if (strlen(header) == 0) { -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "Error reading image header, streaming mode (1). Null header."); -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " -+ "streaming mode (1). Null header."); - } else { - /* Header is not null. Output it in case it's a new camera with unknown headers. */ -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_ERR, 0, "Error reading image header, streaming mode (1). " -- "Unknown header '%s'", header ); -- } -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header, " -+ "streaming mode (1). Unknown header '%s'", -+ header); -+ } - - free(header); - return -1; -@@ -480,7 +482,7 @@ static int netcam_read_next_header(netca - retval = header_get(netcam, &header, HG_NONE); - - if (retval != HG_OK) { -- motion_log(LOG_ERR, 0, "Error reading image header (2)"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading image header (2)"); - free(header); - return -1; - } -@@ -490,22 +492,28 @@ static int netcam_read_next_header(netca - - if ((retval = netcam_check_content_type(header)) >= 0) { - if (retval != 1) { -- motion_log(LOG_ERR, 0, "Header not JPEG"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Header not JPEG"); - free(header); - return -1; - } - } - -- if ((retval = (int) netcam_check_content_length(header)) > 0) { -- netcam->caps.content_length = 1; /* set flag */ -- netcam->receiving->content_length = (int) retval; -- } -+ if ((retval = (int) netcam_check_content_length(header)) >= 0) { -+ if (retval > 0) { -+ netcam->caps.content_length = 1; /* Set flag */ -+ netcam->receiving->content_length = retval; -+ } else { -+ netcam->receiving->content_length = 0; -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-Length 0"); -+ free(header); -+ return -1; -+ } -+ } - - free(header); - } - -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "Found image header record"); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Found image header record"); - - free(header); - return 0; -@@ -528,26 +536,26 @@ static int netcam_read_next_header(netca - * After this processing, the routine returns to the caller. - * - * Parameters: -- * netcam Pointer to the netcam_context structure -+ * netcam Pointer to the netcam_context structure. - * - * Returns: Content-type code if successful, -1 if not -- * -+ * -2 if Content-length = 0 - */ - static int netcam_read_first_header(netcam_context_ptr netcam) - { -- int retval = -2; /* "Unknown err" */ -+ int retval = -3; /* "Unknown err" */ - int ret; - int firstflag = 1; -- int aliveflag = 0; /* If we have seen a Keep-Alive header from cam */ -- int closeflag = 0; /* If we have seen a Connection: close header from cam */ -+ int aliveflag = 0; /* If we have seen a Keep-Alive header from cam. */ -+ int closeflag = 0; /* If we have seen a Connection: close header from cam. */ - char *header; - char *boundary; -- struct context *cnt = netcam->cnt; /* for conf debug_level */ - -- /* Send the initial command to the camera */ -+ /* Send the initial command to the camera. */ - if (send(netcam->sock, netcam->connect_request, - strlen(netcam->connect_request), 0) < 0) { -- motion_log(LOG_ERR, 1, "Error sending 'connect' request"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: Error sending" -+ " 'connect' request"); - return -1; - } - -@@ -573,47 +581,49 @@ static int netcam_read_first_header(netc - * there may be a Content-length. - * - */ -- while (1) { /* 'Do forever' */ -+ while (1) { /* 'Do forever' */ - ret = header_get(netcam, &header, HG_NONE); - -- if (debug_level > CAMERA_INFO) /* Changed criterion and moved up from below to catch headers that cause returns */ -- motion_log(LOG_DEBUG, 0, "Received first header ('%s')", header); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received first header ('%s')", -+ header); - - if (ret != HG_OK) { -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_ERR, 0, "Error reading first header (%s)", header); -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header (%s)", -+ header); - free(header); - return -1; - } - - if (firstflag) { - if ((ret = http_result_code(header)) != 200) { -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "HTTP Result code %d", ret); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: HTTP Result code %d", -+ ret); - - free(header); -- - if (netcam->connect_keepalive) { -- /* Cannot unset netcam->cnt->conf.netcam_http as it is assigned const */ -- /* But we do unset the netcam keepalive flag which was set in netcam_start */ -- /* This message is logged as Information as it would be useful to know */ -- /* if your netcam often returns bad HTTP result codes */ -- netcam->connect_keepalive = 0; -- motion_log(LOG_INFO, 0, "Removed netcam Keep-Alive flag" -- "due to apparent closed HTTP connection."); -+ /* -+ * Cannot unset netcam->cnt->conf.netcam_keepalive as it is assigned const -+ * But we do unset the netcam keepalive flag which was set in netcam_start -+ * This message is logged as Information as it would be useful to know -+ * if your netcam often returns bad HTTP result codes. -+ */ -+ netcam->connect_keepalive = FALSE; -+ free((void *)netcam->cnt->conf.netcam_keepalive); -+ netcam->cnt->conf.netcam_keepalive = strdup("off"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag" -+ "due to apparent closed HTTP connection."); - } - return ret; - } -- - firstflag = 0; - free(header); - continue; - } - -- if (*header == 0) /* blank line received */ -+ if (*header == 0) /* Blank line received */ - break; - -- /* Check if this line is the content type */ -+ /* Check if this line is the content type. */ - if ((ret = netcam_check_content_type(header)) >= 0) { - retval = ret; - /* -@@ -624,113 +634,144 @@ static int netcam_read_first_header(netc - * camera which provides a single frame only. - */ - switch (ret) { -- case 1: /* not streaming */ -- if (SETUP) { -- if (netcam->connect_keepalive) -- motion_log(LOG_DEBUG, 0, "Non-streaming camera (keep-alive set)"); -- else -- motion_log(LOG_DEBUG, 0, "Non-streaming camera (keep-alive not set)"); -- } -- netcam->caps.streaming = 0; -+ case 1: /* Not streaming */ -+ if (netcam->connect_keepalive) -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " -+ "(keep-alive set)"); -+ else -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Non-streaming camera " -+ "(keep-alive not set)"); -+ -+ netcam->caps.streaming = NCS_UNSUPPORTED; - break; - -- case 2: /* streaming */ -- if (SETUP) -- motion_log(LOG_DEBUG, 0, "Streaming camera"); -+ case 2: /* Streaming */ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera"); - -- netcam->caps.streaming = 1; -+ netcam->caps.streaming = NCS_MULTIPART; - - if ((boundary = strstr(header, "boundary="))) { -- /* -- * on error recovery this -- * may already be set -- * */ -+ /* On error recovery this may already be set. */ - if (netcam->boundary) - free(netcam->boundary); - -- netcam->boundary = strdup(boundary + 9); -+ netcam->boundary = mystrdup(boundary + 9); - /* - * HTTP protocol apparently permits the boundary string - * to be quoted (the Lumenera does this, which caused - * trouble) so we need to get rid of any surrounding -- * quotes -+ * quotes. - */ -- check_quote(netcam->boundary); -- netcam->boundary_length = strlen(netcam->boundary); -+ check_quote(netcam->boundary); -+ netcam->boundary_length = strlen(netcam->boundary); - -- if (SETUP) -- motion_log(LOG_DEBUG, 0, "Boundary string [%s]", -- netcam->boundary); -- -- } -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Boundary string [%s]", -+ netcam->boundary); -+ } -+ break; -+ case 3: /* MJPG-Block style streaming. */ -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Streaming camera probably using MJPG-blocks," -+ " consider using mjpg:// netcam_url."); - break; - -- default: /* error */ -- motion_log(LOG_ERR, 0, "Unrecognized content type"); -+ default: -+ /* Error */ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized content type"); - free(header); - return -1; - - } - } else if ((ret = (int) netcam_check_content_length(header)) >= 0) { -- if (SETUP) -- motion_log(LOG_DEBUG, 0, "Content-length present"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Content-length present"); - -- netcam->caps.content_length = 1; /* set flag */ -- netcam->receiving->content_length = ret; -+ if (ret > 0) { -+ netcam->caps.content_length = 1; /* Set flag */ -+ netcam->receiving->content_length = ret; -+ } else { -+ netcam->receiving->content_length = 0; -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Content-length 0"); -+ retval = -2; -+ } - } else if (netcam_check_keepalive(header) == TRUE) { -- /* Note that we have received a Keep-Alive header, and thus the socket can be left open */ -- aliveflag=TRUE; -+ /* Note that we have received a Keep-Alive header, and thus the socket can be left open. */ -+ aliveflag = TRUE; - netcam->keepalive_thisconn = TRUE; -- /* This flag will not be set when a Streaming cam is in use, but that */ -- /* does not matter as the test below looks at Streaming state also. */ -+ /* -+ * This flag will not be set when a Streaming cam is in use, but that -+ * does not matter as the test below looks at Streaming state also. -+ */ - } else if (netcam_check_close(header) == TRUE) { -- /* Note that we have received a Connection: close header */ -- closeflag=TRUE; -- /* This flag is acted upon below */ -- if (debug_level > CAMERA_INFO) /* Changed criterion and moved up from below to catch headers that cause returns */ -- motion_log(LOG_DEBUG, 0, "Found Conn:close header ('%s')", header); -+ /* Note that we have received a Connection: close header. */ -+ closeflag = TRUE; -+ /* -+ * This flag is acted upon below. -+ * Changed criterion and moved up from below to catch headers that cause returns. -+ */ -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Found Conn: close header ('%s')", -+ header); - } - free(header); - } - free(header); - -- if (!netcam->caps.streaming && netcam->connect_keepalive) { -+ if (netcam->caps.streaming == NCS_UNSUPPORTED && netcam->connect_keepalive) { - -- /* -- * If we are a non-streaming (ie. Jpeg) netcam and keepalive is configured -- */ -+ /* If we are a non-streaming (ie. Jpeg) netcam and keepalive is configured. */ - - if (aliveflag) { - if (closeflag) { -+ netcam->warning_count++; -+ if (netcam->warning_count > 3) { -+ netcam->warning_count = 0; -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Both 'Connection: Keep-Alive' and " -+ "'Connection: close' header received. Motion removes keepalive."); -+ netcam->connect_keepalive = FALSE; -+ free((void *)netcam->cnt->conf.netcam_keepalive); -+ netcam->cnt->conf.netcam_keepalive = strdup("off"); -+ } else { - /* - * If not a streaming cam, and keepalive is set, and the flag shows we - * did not see a Keep-Alive field returned from netcam and a Close field. - * Not quite sure what the correct course of action is here. In for testing. - */ -- motion_log(LOG_INFO, 0, "Info: Both 'Connection: Keep-Alive' and 'Connection: close' " -- "header received. Motion continues unchanged."); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Both 'Connection: Keep-Alive' and " -+ "'Connection: close' header received. Motion continues unchanged."); -+ } - } else { -- /* aliveflag && !closeflag -- * -- * If not a streaming cam, and keepalive is set, and the flag shows we -- * just got a Keep-Alive field returned from netcam and no Close field. -- * No action, as this is the normal case. In debug we print a notification. -- */ -+ /* -+ * aliveflag && !closeflag -+ * -+ * If not a streaming cam, and keepalive is set, and the flag shows we -+ * just got a Keep-Alive field returned from netcam and no Close field. -+ * No action, as this is the normal case. In debug we print a notification. -+ */ - -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_INFO, 0, "Info: Received a Keep-Alive field in this set of headers."); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Received a Keep-Alive field in this" -+ "set of headers."); - } - } else { /* !aliveflag */ - if (!closeflag) { -+ netcam->warning_count++; -+ -+ if (netcam->warning_count > 3) { -+ netcam->warning_count = 0; -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: No 'Connection: Keep-Alive' nor 'Connection: close'" -+ " header received.\n Motion removes keepalive."); -+ netcam->connect_keepalive = FALSE; -+ free((void *)netcam->cnt->conf.netcam_keepalive); -+ netcam->cnt->conf.netcam_keepalive = strdup("off"); -+ } else { - /* - * If not a streaming cam, and keepalive is set, and the flag shows we - * did not see a Keep-Alive field returned from netcam nor a Close field. - * Not quite sure what the correct course of action is here. In for testing. - */ -- motion_log(LOG_INFO, 0, "Info: No 'Connection: Keep-Alive' nor 'Connection: close' " -- "header received. Motion continues unchanged."); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: No 'Connection: Keep-Alive' nor 'Connection: close'" -+ " header received.\n Motion continues unchanged."); -+ } - } else { -- /* !aliveflag & closeflag -+ /* -+ * !aliveflag & closeflag - * If not a streaming cam, and keepalive is set, and the flag shows we - * received a 'Connection: close' field returned from netcam. It is not likely - * we will get a Keep-Alive and Close header together - this is picked up by -@@ -753,13 +794,15 @@ static int netcam_read_first_header(netc - */ - if (!netcam->keepalive_thisconn) { - netcam->connect_keepalive = FALSE; /* No further attempts at keep-alive */ -- motion_log(LOG_INFO, 0, "Removed netcam Keep-Alive flag because 'Connection: close' " -- "header received. Netcam does not support Keep-Alive. Motion " -- "continues in non-Keep-Alive."); -+ free((void *)netcam->cnt->conf.netcam_keepalive); -+ netcam->cnt->conf.netcam_keepalive = strdup("off"); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Removed netcam Keep-Alive flag because" -+ " 'Connection: close' header received.\n Netcam does not support " -+ "Keep-Alive. Motion continues in non-Keep-Alive."); - } else { - netcam->keepalive_timeup = TRUE; /* We will close and re-open keep-alive */ -- motion_log(LOG_INFO, 0, "Keep-Alive has reached end of valid period. Motion will close " -- "netcam, then resume Keep-Alive with a new socket."); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "Keep-Alive has reached end of valid period.\n" -+ "Motion will close netcam, then resume Keep-Alive with a new socket."); - } - } - } -@@ -784,7 +827,7 @@ static void netcam_disconnect(netcam_con - { - if (netcam->sock > 0) { - if (close(netcam->sock) < 0) -- motion_log(LOG_ERR, 1, "netcam_disconnect"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: netcam_disconnect"); - - netcam->sock = -1; - } -@@ -809,93 +852,88 @@ static void netcam_disconnect(netcam_con - */ - static int netcam_connect(netcam_context_ptr netcam, int err_flag) - { -- struct sockaddr_in server; /* for connect */ -- struct addrinfo *res; /* for getaddrinfo */ -+ struct sockaddr_in server; /* For connect */ -+ struct addrinfo *res; /* For getaddrinfo */ - int ret; - int saveflags; - int back_err; - int optval; -- socklen_t optlen=sizeof(optval); -+ socklen_t optlen = sizeof(optval); - socklen_t len; - fd_set fd_w; - struct timeval selecttime; - -- /* Assure any previous connection has been closed - IF we are not in keepalive */ -+ /* Assure any previous connection has been closed - IF we are not in keepalive. */ - if (!netcam->connect_keepalive) { -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_connect, disconnecting netcam since keep-alive not set." ); -- -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam " -+ "since keep-alive not set."); -+ - netcam_disconnect(netcam); - -- /* create a new socket */ -+ /* Create a new socket. */ - if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { -- motion_log(LOG_ERR, 1, "netcam_connect with no keepalive, attempt to create socket failed."); -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with no keepalive, attempt " -+ "to create socket failed."); - return -1; - } - -- if (debug_level > CAMERA_INFO ) -- motion_log(LOG_DEBUG, 0, "netcam_connect with no keepalive, new socket created fd %d", netcam->sock); -- -- } else { /* We are in keepalive mode, check for invalid socket */ -- if (netcam->sock == -1) { -- /* Must be first time, or closed, create a new socket */ -- if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { -- motion_log(LOG_ERR, 1, "netcam_connect with keepalive set, invalid socket." -- "This could be the first time. Creating a new one failed."); -- return -1; -- } -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: with no keepalive, " -+ "new socket created fd %d", netcam->sock); - -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_connect with keepalive set, invalid socket." -- "This could be first time, created a new one with fd %d", netcam->sock); -- -- /* Record that this connection has not yet received a Keep-Alive header */ -- netcam->keepalive_thisconn = FALSE; -- -- /* Check the socket status for the keepalive option */ -- if (getsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen) < 0) { -- motion_log(LOG_ERR, 1, "netcam_connect : getsockopt()"); -- return -1; -- } -+ } else if (netcam->sock == -1) { /* We are in keepalive mode, check for invalid socket. */ -+ /* Must be first time, or closed, create a new socket. */ -+ if ((netcam->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: with keepalive set, invalid socket." -+ "This could be the first time. Creating a new one failed."); -+ return -1; -+ } - -- if (debug_level > CAMERA_INFO) { -- if (optval == 1) -- motion_log(LOG_DEBUG, 0, "netcam_connect: SO_KEEPALIVE is ON"); -- else -- motion_log(LOG_DEBUG, 0, "netcam_connect: SO_KEEPALIVE is OFF"); -- } -- -- /* Set the option active */ -- optval = 1; -- optlen = sizeof(optval); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: with keepalive set, invalid socket." -+ "This could be first time, created a new one with fd %d", -+ netcam->sock); -+ -+ /* Record that this connection has not yet received a Keep-Alive header. */ -+ netcam->keepalive_thisconn = FALSE; -+ -+ /* Check the socket status for the keepalive option. */ -+ if (getsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen) < 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: getsockopt()"); -+ return -1; -+ } - -- if (setsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) { -- motion_log(LOG_ERR, 1, "netcam_connect : setsockopt()"); -- return -1; -- } -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE is %s", -+ optval ? "ON":"OFF"); - -- if (debug_level > CAMERA_INFO ) -- motion_log(LOG_DEBUG, 0, "netcam_connect: SO_KEEPALIVE set on socket."); -+ /* Set the option active. */ -+ optval = 1; -+ optlen = sizeof(optval); - -- } else if (debug_level > CAMERA_INFO) { -- motion_log(LOG_DEBUG, 0, "netcam_connect re-using socket %d since keepalive is set.", netcam->sock); -+ if (setsockopt(netcam->sock, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: setsockopt()"); -+ return -1; - } -- } - -- /* lookup the hostname given in the netcam URL */ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: SO_KEEPALIVE set on socket."); -+ } -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: re-using socket %d since keepalive is set.", -+ netcam->sock); -+ -+ /* Lookup the hostname given in the netcam URL. */ - if ((ret = getaddrinfo(netcam->connect_host, NULL, NULL, &res)) != 0) { - if (!err_flag) -- motion_log(LOG_ERR, 0, "getaddrinfo() failed (%s): %s", -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: getaddrinfo() failed (%s): %s", - netcam->connect_host, gai_strerror(ret)); -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (1)"); -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (1)"); -+ - netcam_disconnect(netcam); - return -1; - } - - /* - * Fill the hostname details into the 'server' structure and -- * attempt to connect to the remote server -+ * attempt to connect to the remote server. - */ - memset(&server, 0, sizeof(server)); - memcpy(&server, res->ai_addr, sizeof(server)); -@@ -910,49 +948,48 @@ static int netcam_connect(netcam_context - */ - - if ((saveflags = fcntl(netcam->sock, F_GETFL, 0)) < 0) { -- motion_log(LOG_ERR, 1, "fcntl(1) on socket"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: fcntl(1) on socket"); - netcam_disconnect(netcam); - return -1; - } - -- /* Set the socket non-blocking */ -+ /* Set the socket non-blocking. */ - if (fcntl(netcam->sock, F_SETFL, saveflags | O_NONBLOCK) < 0) { -- motion_log(LOG_ERR, 1, "fcntl(2) on socket"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: fcntl(2) on socket"); - netcam_disconnect(netcam); - return -1; - } - -- /* Now the connect call will return immediately */ -+ /* Now the connect call will return immediately. */ - ret = connect(netcam->sock, (struct sockaddr *) &server, - sizeof(server)); -- back_err = errno; /* save the errno from connect */ -+ back_err = errno; /* Save the errno from connect */ - -- /* If the connect failed with anything except EINPROGRESS, error */ -+ /* If the connect failed with anything except EINPROGRESS, error. */ - if ((ret < 0) && (back_err != EINPROGRESS)) { - if (!err_flag) -- motion_log(LOG_ERR, 1, "connect() failed (%d)", back_err); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect() failed (%d)", -+ back_err); - -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (4)"); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (4)"); - - netcam_disconnect(netcam); - return -1; - } - -- /* Now we do a 'select' with timeout to wait for the connect */ -+ /* Now we do a 'select' with timeout to wait for the connect. */ - FD_ZERO(&fd_w); - FD_SET(netcam->sock, &fd_w); - selecttime.tv_sec = CONNECT_TIMEOUT; - selecttime.tv_usec = 0; - ret = select(FD_SETSIZE, NULL, &fd_w, NULL, &selecttime); - -- if (ret == 0) { /* 0 means timeout */ -+ if (ret == 0) { /* 0 means timeout. */ - if (!err_flag) -- motion_log(LOG_ERR, 0, "timeout on connect()"); -- -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (2)"); -- -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: timeout on connect()"); -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (2)"); -+ - netcam_disconnect(netcam); - return -1; - } -@@ -965,25 +1002,26 @@ static int netcam_connect(netcam_context - len = sizeof(ret); - - if (getsockopt(netcam->sock, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) { -- motion_log(LOG_ERR, 0, "getsockopt after connect"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: getsockopt after connect"); - netcam_disconnect(netcam); - return -1; - } - -- /* If the return code is anything except 0, error on connect */ -+ /* If the return code is anything except 0, error on connect. */ - if (ret) { - if (!err_flag) -- motion_log(LOG_ERR, 1, "connect returned error"); -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_connect disconnecting netcam (3)"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: connect returned error"); -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting netcam (3)"); -+ - netcam_disconnect(netcam); - return -1; - } - -- /* The socket info is stored in the rbuf structure of our context */ -+ /* The socket info is stored in the rbuf structure of our context. */ - rbuf_initialize(netcam); - -- return 0; /* success */ -+ return 0; /* Success */ - } - - -@@ -995,23 +1033,35 @@ static int netcam_connect(netcam_context - * the buffer and adjust it's size. - * - * Parameters: -- * buff Pointer to a netcam_image_buffer structure -- * numbytes The number of bytes to be copied -+ * buff Pointer to a netcam_image_buffer structure. -+ * numbytes The number of bytes to be copied. - * - * Returns: Nothing - */ - static void netcam_check_buffsize(netcam_buff_ptr buff, size_t numbytes) - { -+ int min_size_to_alloc; -+ int real_alloc; -+ int new_size; -+ - if ((buff->size - buff->used) >= numbytes) - return; - -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "expanding buffer from %d to %d bytes", -- (int) buff->size, (int) buff->size + NETCAM_BUFFSIZE); -+ min_size_to_alloc = numbytes - (buff->size - buff->used); -+ real_alloc = ((min_size_to_alloc / NETCAM_BUFFSIZE) * NETCAM_BUFFSIZE); -+ -+ if ((min_size_to_alloc - real_alloc) > 0) -+ real_alloc += NETCAM_BUFFSIZE; -+ -+ new_size = buff->size + real_alloc; -+ -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", -+ (int) buff->used, (int) buff->size, -+ (int) buff->used, new_size); - -- buff->ptr = myrealloc(buff->ptr, buff->size + NETCAM_BUFFSIZE, -+ buff->ptr = myrealloc(buff->ptr, new_size, - "netcam_check_buf_size"); -- buff->size += NETCAM_BUFFSIZE; -+ buff->size = new_size; - } - - /** -@@ -1042,6 +1092,8 @@ static void netcam_check_buffsize(netcam - * 1) If a Content-Length is present, set the variable "remaining" - * to be equal to that value, else set it to a "very large" - * number. -+ * WARNING !!! Content-Length *must* to be greater than 0, even more -+ * a jpeg image cannot be less than 300 bytes or so. - * 2) While there is more data available from the camera: - * a) If there is a "boundary string" specified (from the initial - * header): -@@ -1074,27 +1126,27 @@ static int netcam_read_html_jpeg(netcam_ - netcam_buff_ptr buffer; - size_t remaining; /* # characters to read */ - size_t maxflush; /* # chars before boundary */ -- size_t rem, rlen, ix; /* working vars */ -+ size_t rem, rlen, ix; /* Working vars */ - int retval; - char *ptr, *bptr, *rptr; - netcam_buff *xchg; - struct timeval curtime; - /* - * Initialisation - set our local pointers to the context -- * information -+ * information. - */ - buffer = netcam->receiving; -- /* Assure the target buffer is empty */ -+ /* Assure the target buffer is empty. */ - buffer->used = 0; -- /* Prepare for read loop */ -+ /* Prepare for read loop. */ - if (buffer->content_length != 0) - remaining = buffer->content_length; - else - remaining = 999999; - -- /* Now read in the data */ -+ /* Now read in the data. */ - while (remaining) { -- /* Assure data in input buffer */ -+ /* Assure data in input buffer. */ - if (netcam->response->buffer_left <= 0) { - retval = rbuf_read_bufferful(netcam); - -@@ -1105,14 +1157,14 @@ static int netcam_read_html_jpeg(netcam_ - netcam->response->buffer_pos = netcam->response->buffer; - } - -- /* If a boundary string is present, take it into account */ -+ /* If a boundary string is present, take it into account. */ - bptr = netcam->boundary; - - if (bptr) { - rptr = netcam->response->buffer_pos; - rlen = netcam->response->buffer_left; - -- /* Loop through buffer looking for start of boundary */ -+ /* Loop through buffer looking for start of boundary. */ - while (1) { - /* - * Logic gets a little complicated here. The -@@ -1130,11 +1182,11 @@ static int netcam_read_html_jpeg(netcam_ - break; - - if ((ptr = memchr(rptr, *bptr, rlen)) == NULL) -- /* boundary not here (normal path) */ -+ /* Boundary not here (normal path) */ - break; - /* - * At least the first char was found in the -- * buffer - check for the rest -+ * buffer - check for the rest. - */ - rem = rlen - (ptr - rptr); - for (ix = 1; (ix < rem) && (ix < netcam->boundary_length); ix++) { -@@ -1145,19 +1197,18 @@ static int netcam_read_html_jpeg(netcam_ - if ((ix != netcam->boundary_length) && (ix != rem)) { - /* - * Not pointing at a boundary string - -- * step along input -+ * step along input. - */ - ix = ptr - rptr + 1; - rptr += ix; - rlen -= ix; - - if (rlen <= 0) -- /* boundary not in buffer - go copy out -- */ -+ /* boundary not in buffer - go copy out */ - break; - /* -- * not yet decided - continue -- * through input -+ * Not yet decided - continue -+ * through input. - */ - continue; - } -@@ -1172,7 +1223,7 @@ static int netcam_read_html_jpeg(netcam_ - if ((ptr - netcam->response->buffer) < (int) remaining) - remaining = ptr - netcam->response->buffer; - -- /* go copy everything up to boundary */ -+ /* Go copy everything up to boundary. */ - break; - } - -@@ -1183,7 +1234,7 @@ static int netcam_read_html_jpeg(netcam_ - * problem mentioned above. - * - * Assure there is data before potential -- * boundary string -+ * boundary string. - */ - if (ptr != netcam->response->buffer) { - /* -@@ -1195,7 +1246,7 @@ static int netcam_read_html_jpeg(netcam_ - * beginning and get some more input - * data. First we flush the input - * buffer up to the beginning of the -- * (potential) boundary string -+ * (potential) boundary string. - */ - ix = ptr - netcam->response->buffer_pos; - netcam_check_buffsize(buffer, ix); -@@ -1211,45 +1262,43 @@ static int netcam_read_html_jpeg(netcam_ - * module netcam_wget.c to do this job! - */ - -- if (debug_level > CAMERA_INFO) { -- motion_log(-1, 0, -- "Potential split boundary - " -- "%d chars flushed, %d " -- "re-positioned", ix, -- (int) netcam->response->buffer_left); -- } -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, -+ "%s: Potential split boundary - " -+ "%d chars flushed, %d " -+ "re-positioned", ix, -+ (int) netcam->response->buffer_left); - - memmove(netcam->response->buffer, ptr, - netcam->response->buffer_left); -- } /* end of boundary split over buffer */ -+ } /* End of boundary split over buffer. */ - - retval = netcam_recv(netcam, netcam->response->buffer + - netcam->response->buffer_left, - sizeof(netcam->response->buffer) - - netcam->response->buffer_left); - -- if (retval <= 0) { /* this is a fatal error */ -- motion_log(LOG_ERR, 1, "recv() fail after boundary string"); -+ if (retval <= 0) { /* This is a fatal error. */ -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: recv() fail after boundary string"); - return -1; - } - -- /* Reset the input buffer pointers */ -+ /* Reset the input buffer pointers. */ - netcam->response->buffer_left = retval + netcam->response->buffer_left; - netcam->response->buffer_pos = netcam->response->buffer; - -- /* This will cause a 'continue' of the main loop */ -+ /* This will cause a 'continue' of the main loop. */ - bptr = NULL; - -- /* Return to do the boundary compare from the start */ -+ /* Return to do the boundary compare from the start. */ - break; -- } /* end of while(1) input buffer search */ -+ } /* End of while(1) input buffer search. */ - -- /* !bptr shows we're processing split boundary */ -+ /* !bptr shows we're processing split boundary. */ - if (!bptr) - continue; -- } /* end of if (bptr) */ -+ } /* end of if (bptr) */ - -- /* boundary string not present, so just write out as much data as possible */ -+ /* boundary string not present, so just write out as much data as possible. */ - if (remaining) { - maxflush = MINVAL(netcam->response->buffer_left, remaining); - netcam_check_buffsize(buffer, maxflush); -@@ -1260,14 +1309,13 @@ static int netcam_read_html_jpeg(netcam_ - } - - /* -- * read is complete - set the current 'receiving' buffer atomically -+ * Read is complete - set the current 'receiving' buffer atomically - * as 'latest', and make the buffer previously in 'latest' become -- * the new 'receiving' -+ * the new 'receiving'. - */ - if (gettimeofday(&curtime, NULL) < 0) -- motion_log(LOG_ERR, 1, "gettimeofday in netcam_read_jpeg"); -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - -- - netcam->receiving->image_time = curtime; - - /* -@@ -1280,8 +1328,8 @@ static int netcam_read_html_jpeg(netcam_ - 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + - (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "Calculated frame time %f", netcam->av_frame_time); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", -+ netcam->av_frame_time); - } - netcam->last_image = curtime; - -@@ -1300,20 +1348,290 @@ static int netcam_read_html_jpeg(netcam_ - - pthread_mutex_unlock(&netcam->mutex); - -- if (!netcam->caps.streaming) { -+ if (netcam->caps.streaming == NCS_UNSUPPORTED) { - if (!netcam->connect_keepalive) { -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "netcam_read_html_jpeg disconnecting netcam since keep-alive not set." ); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: disconnecting " -+ "netcam since keep-alive not set."); -+ - netcam_disconnect(netcam); -- } else if (debug_level > CAMERA_INFO) { -- motion_log(LOG_DEBUG, 0, "netcam_read_html_jpeg leaving netcam connected." ); -+ } -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: leaving netcam connected."); -+ } -+ -+ return 0; -+} -+ -+/** -+ * netcam_http_request -+ * -+ * This routine initiates a connection on the specified netcam, -+ * for which every parameter has already been set (url, etc). -+ * It uses the HTTP protocol, which is what many IP cameras use. -+ * If this function succeeds, the HTTP response along with the -+ * headers are already processed, and you can start reading contents -+ * from here. -+ * -+ * Parameters: -+ * netcam Pointer to a netcam_context structure -+ * -+ * Returns: 0 on success, -1 if an error occurs. -+ */ -+static int netcam_http_request(netcam_context_ptr netcam) -+{ -+ int ix; -+ -+ /* -+ * Our basic initialisation has been completed. Now we will attempt -+ * to connect with the camera so that we can then get a "header" -+ * in order to find out what kind of camera we are dealing with, -+ * as well as what are the picture dimensions. Note that for -+ * this initial connection, any failure will cause an error -+ * return from netcam_start (unlike later possible attempts at -+ * re-connecting, if the network connection is later interrupted). -+ */ -+ for (ix = 0; ix < MAX_HEADER_RETRIES; ix++) { -+ /* -+ * netcam_connect does an automatic netcam_close, so it's -+ * safe to include it as part of this loop -+ * (Not always true now Keep-Alive is implemented). -+ */ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: about to try to connect, time #%d", -+ ix); -+ -+ if (netcam_connect(netcam, 0) != 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "Failed to open camera - check your config " -+ "and that netcamera is online"); -+ -+ /* Fatal error on startup */ -+ ix = MAX_HEADER_RETRIES; -+ break;; - } -+ -+ if (netcam_read_first_header(netcam) >= 0) -+ break; -+ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error reading first header - re-trying"); -+ } -+ -+ if (ix == MAX_HEADER_RETRIES) { -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first camera header " -+ "- giving up for now"); -+ return -1; - } - - return 0; - } - - /** -+ * netcam_mjpg_buffer_refill -+ * -+ * This routing reads content from the MJPG-camera until the response -+ * buffer of the specified netcam_context is full. If the connection is -+ * lost during this operation, it tries to re-connect. -+ * -+ * Parameters: -+ * netcam Pointer to a netcam_context structure -+ * -+ * Returns: The number of read bytes, -+ * or -1 if an fatal connection error occurs. -+ */ -+static int netcam_mjpg_buffer_refill(netcam_context_ptr netcam) -+{ -+ int retval; -+ -+ if (netcam->response->buffer_left > 0) -+ return netcam->response->buffer_left; -+ -+ while (1) { -+ retval = rbuf_read_bufferful(netcam); -+ if (retval <= 0) { /* If we got 0, we timeoutted. */ -+ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Read error," -+ " trying to reconnect.."); -+ /* We may have lost the connexion */ -+ if (netcam_http_request(netcam) < 0) { -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: lost the cam."); -+ return -1; /* We REALLY lost the cam... bail out for now. */ -+ } -+ } -+ -+ if (retval > 0) -+ break; -+ } -+ -+ netcam->response->buffer_left = retval; -+ netcam->response->buffer_pos = netcam->response->buffer; -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Refilled buffer with [%d]" -+ " bytes from the network.", retval); -+ -+ return retval; -+} -+ -+/** -+ * netcam_read_mjpg_jpeg -+ * -+ * This routine reads from a netcam using a MJPG-chunk based -+ * protocol, used by Linksys WVC200 for example. -+ * This implementation has been made by reverse-engineering -+ * the protocol, so it may contain bugs and should be considered as -+ * experimental. -+ * -+ * Protocol explanation: -+ * -+ * The stream consists of JPG pictures, spanned across multiple -+ * MJPG chunks (in general 3 chunks, altough that's not guaranteed). -+ * -+ * Each data chunk can range from 1 to 65535 bytes + a header, altough -+ * i have not seen anything bigger than 20000 bytes + a header. -+ * -+ * One MJPG chunk is constituted by a header plus the chunk data. -+ * The chunk header is of fixed size, and the following data size -+ * and position in the frame is specified in the chunk header. -+ * -+ * From what i have seen on WVC200 cameras, the stream always begins -+ * on JPG frame boundary, so you don't have to worry about beginning -+ * in the middle of a frame. -+ * -+ * See netcam.h for the mjpg_header structure and more details. -+ * -+ * Parameters: -+ * netcam Pointer to a netcam_context structure -+ * -+ * Returns: 0 if an image was obtained from the camera, -+ * or -1 if an error occurred. -+ */ -+static int netcam_read_mjpg_jpeg(netcam_context_ptr netcam) -+{ -+ netcam_buff_ptr buffer; -+ netcam_buff *xchg; -+ struct timeval curtime; -+ mjpg_header mh; -+ size_t read_bytes; -+ int retval; -+ -+ /* -+ * Initialisation - set our local pointers to the context -+ * information. -+ */ -+ buffer = netcam->receiving; -+ /* Assure the target buffer is empty. */ -+ buffer->used = 0; -+ -+ if (netcam_mjpg_buffer_refill(netcam) < 0) -+ return -1; -+ -+ /* Loop until we have a complete JPG. */ -+ while (1) { -+ read_bytes = 0; -+ while (read_bytes < sizeof(mh)) { -+ -+ /* Transfer what we have in buffer in the header structure. */ -+ retval = rbuf_flush(netcam, ((char *)&mh) + read_bytes, sizeof(mh) - read_bytes); -+ -+ read_bytes += retval; -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] header bytes.", -+ read_bytes, sizeof(mh)); -+ -+ /* If we don't have received a full header, refill our buffer. */ -+ if (read_bytes < sizeof(mh)) { -+ if (netcam_mjpg_buffer_refill(netcam) < 0) -+ return -1; -+ } -+ } -+ -+ /* Now check the validity of our header. */ -+ if (strncmp(mh.mh_magic, MJPG_MH_MAGIC, MJPG_MH_MAGIC_SIZE)) { -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Invalid header received," -+ " reconnecting"); -+ /* -+ * We shall reconnect to restart the stream, and get a chance -+ * to resync. -+ */ -+ if (netcam_http_request(netcam) < 0) -+ return -1; /* We lost the cam... bail out. */ -+ /* Even there, we need to resync. */ -+ buffer->used = 0; -+ continue ; -+ } -+ -+ /* Make room for the chunk. */ -+ netcam_check_buffsize(buffer, (int) mh.mh_chunksize); -+ -+ read_bytes = 0; -+ while (read_bytes < mh.mh_chunksize) { -+ retval = rbuf_flush(netcam, buffer->ptr + buffer->used + read_bytes, -+ mh.mh_chunksize - read_bytes); -+ read_bytes += retval; -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Read [%d/%d] chunk bytes," -+ " [%d/%d] total", read_bytes, mh.mh_chunksize, -+ buffer->used + read_bytes, mh.mh_framesize); -+ -+ if (retval < (int) (mh.mh_chunksize - read_bytes)) { -+ /* MOTION_LOG(EMG, TYPE_NETCAM, NO_ERRNO, "Chunk incomplete, going to refill."); */ -+ if (netcam_mjpg_buffer_refill(netcam) < 0) -+ return -1; -+ -+ } -+ } -+ buffer->used += read_bytes; -+ -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Chunk complete," -+ " buffer used [%d] bytes.", buffer->used); -+ -+ /* Is our JPG image complete ? */ -+ if (mh.mh_framesize == buffer->used) { -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Image complete," -+ " buffer used [%d] bytes.", buffer->used); -+ break; -+ } -+ /* MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Rlen now at [%d] bytes", rlen); */ -+ } -+ -+ /* -+ * read is complete - set the current 'receiving' buffer atomically -+ * as 'latest', and make the buffer previously in 'latest' become -+ * the new 'receiving'. -+ */ -+ if (gettimeofday(&curtime, NULL) < 0) -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); -+ -+ netcam->receiving->image_time = curtime; -+ -+ /* -+ * Calculate our "running average" time for this netcam's -+ * frame transmissions (except for the first time). -+ * Note that the average frame time is held in microseconds. -+ */ -+ if (netcam->last_image.tv_sec) { -+ netcam->av_frame_time = (9.0 * netcam->av_frame_time + -+ 1000000.0 * (curtime.tv_sec - netcam->last_image.tv_sec) + -+ (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; -+ -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", -+ netcam->av_frame_time); -+ } -+ netcam->last_image = curtime; -+ -+ pthread_mutex_lock(&netcam->mutex); -+ -+ xchg = netcam->latest; -+ netcam->latest = netcam->receiving; -+ netcam->receiving = xchg; -+ netcam->imgcnt++; -+ /* -+ * We have a new frame ready. We send a signal so that -+ * any thread (e.g. the motion main loop) waiting for the -+ * next frame to become available may proceed. -+ */ -+ pthread_cond_signal(&netcam->pic_ready); -+ -+ pthread_mutex_unlock(&netcam->mutex); -+ -+ return 0; -+} -+ -+/** - * netcam_read_ftp_jpeg - * - * This routine reads from a netcam using the FTP protocol. -@@ -1328,19 +1646,19 @@ static int netcam_read_ftp_jpeg(netcam_c - netcam_buff *xchg; - struct timeval curtime; - -- /* Point to our working buffer */ -+ /* Point to our working buffer. */ - buffer = netcam->receiving; - buffer->used = 0; - -- /* Request the image from the remote server */ -+ /* Request the image from the remote server. */ - if (ftp_get_socket(netcam->ftp) <= 0) { -- motion_log(LOG_ERR, 0, "ftp_get_socket failed in netcam_read_jpeg"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: ftp_get_socket failed"); - return -1; - } - -- /* Now fetch the image using ftp_read. Note this is a blocking call */ -+ /* Now fetch the image using ftp_read. Note this is a blocking call. */ - do { -- /* Assure there's enough room in the buffer */ -+ /* Assure there's enough room in the buffer. */ - netcam_check_buffsize(buffer, FTP_BUF_SIZE); - - /* Do the read */ -@@ -1351,9 +1669,8 @@ static int netcam_read_ftp_jpeg(netcam_c - } while (len > 0); - - if (gettimeofday(&curtime, NULL) < 0) -- motion_log(LOG_ERR, 1, "gettimeofday in netcam_read_jpeg"); -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - -- - netcam->receiving->image_time = curtime; - /* - * Calculate our "running average" time for this netcam's -@@ -1361,13 +1678,12 @@ static int netcam_read_ftp_jpeg(netcam_c - * Note that the average frame time is held in microseconds. - */ - if (netcam->last_image.tv_sec) { -- netcam->av_frame_time = -- ((9.0 * netcam->av_frame_time) + 1000000.0 * -- (curtime.tv_sec - netcam->last_image.tv_sec) + -- (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; -+ netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * -+ (curtime.tv_sec - netcam->last_image.tv_sec) + -+ (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "Calculated frame time %f", netcam->av_frame_time); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", -+ netcam->av_frame_time); - } - - netcam->last_image = curtime; -@@ -1375,7 +1691,7 @@ static int netcam_read_ftp_jpeg(netcam_c - /* - * read is complete - set the current 'receiving' buffer atomically - * as 'latest', and make the buffer previously in 'latest' become -- * the new 'receiving' -+ * the new 'receiving'. - */ - pthread_mutex_lock(&netcam->mutex); - -@@ -1390,6 +1706,7 @@ static int netcam_read_ftp_jpeg(netcam_c - * next frame to become available may proceed. - */ - pthread_cond_signal(&netcam->pic_ready); -+ - pthread_mutex_unlock(&netcam->mutex); - - return 0; -@@ -1406,77 +1723,80 @@ static int netcam_read_ftp_jpeg(netcam_c - */ - static int netcam_read_file_jpeg(netcam_context_ptr netcam) - { -- int loop_counter=0; -+ int loop_counter = 0; -+ -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Begin"); - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(-1,0,"Begin %s", __FUNCTION__); -- - netcam_buff_ptr buffer; - int len; - netcam_buff *xchg; - struct timeval curtime; - struct stat statbuf; - -- /* Point to our working buffer */ -+ /* Point to our working buffer. */ - buffer = netcam->receiving; - buffer->used = 0; - - /*int fstat(int filedes, struct stat *buf);*/ - do { -- -- if (stat( netcam->file->path, &statbuf)) { -- motion_log(-1, 0, "stat(%s) error", netcam->file->path ); -+ if (stat(netcam->file->path, &statbuf)) { -+ MOTION_LOG(CRT, TYPE_NETCAM, SHOW_ERRNO, "%s: stat(%s) error", -+ netcam->file->path); - return -1; - } - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(-1, 0, "statbuf.st_mtime[%d] != last_st_mtime[%d]", statbuf.st_mtime, netcam->file->last_st_mtime); -- -- if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { //its waits POLLING_TIMEOUT -- motion_log(-1, 0, "waiting new file image timeout" ); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: statbuf.st_mtime[%d]" -+ " != last_st_mtime[%d]", statbuf.st_mtime, -+ netcam->file->last_st_mtime); -+ -+ /* its waits POLLING_TIMEOUT */ -+ if (loop_counter>((POLLING_TIMEOUT*1000*1000)/(POLLING_TIME/1000))) { -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: waiting new file image" -+ " timeout"); - return -1; - } - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(-1, 0, "delay waiting new file image "); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: delay waiting new" -+ " file image "); - -- //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000 ); //its waits 5seconds - READ_TIMEOUT -- SLEEP( 0, POLLING_TIME ); // its waits 500ms -+ //its waits 5seconds - READ_TIMEOUT -+ //SLEEP(netcam->timeout.tv_sec, netcam->timeout.tv_usec*1000); -+ SLEEP(0, POLLING_TIME); // its waits 500ms - /*return -1;*/ - loop_counter++; - -- } while (statbuf.st_mtime==netcam->file->last_st_mtime); -+ } while (statbuf.st_mtime == netcam->file->last_st_mtime); - - netcam->file->last_st_mtime = statbuf.st_mtime; -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_INFO, 0, "processing new file image - st_mtime " -- "%d", netcam->file->last_st_mtime ); - -- -- /* Assure there's enough room in the buffer */ -- while (buffer->size < (size_t)statbuf.st_size) -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: processing new file image -" -+ " st_mtime %d", netcam->file->last_st_mtime); -+ -+ /* Assure there's enough room in the buffer. */ -+ while (buffer->size < (size_t)statbuf.st_size) - netcam_check_buffsize(buffer, statbuf.st_size); - - - /* Do the read */ -- netcam->file->control_file_desc = open( netcam->file->path, O_RDONLY); -- -+ netcam->file->control_file_desc = open(netcam->file->path, O_RDONLY); - if (netcam->file->control_file_desc < 0) { -- motion_log(-1, 0, "open(%s) error:%d", netcam->file->path, netcam->file->control_file_desc); -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: open(%s) error: %d", -+ netcam->file->path, netcam->file->control_file_desc); - return -1; - } - -- if ((len = read(netcam->file->control_file_desc, buffer->ptr + buffer->used, statbuf.st_size)) < 0) { -- motion_log(-1, 0, "read(%s) error:%d", netcam->file->control_file_desc, len ); -+ if ((len = read(netcam->file->control_file_desc, -+ buffer->ptr + buffer->used, statbuf.st_size)) < 0) { -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: read(%s) error: %d", -+ netcam->file->control_file_desc, len); - return -1; - } - - buffer->used += len; -+ close(netcam->file->control_file_desc); - -- close( netcam->file->control_file_desc ); -- -- if (gettimeofday(&curtime, NULL) < 0) -- motion_log(LOG_ERR, 1, "gettimeofday in netcam_read_jpeg"); -+ if (gettimeofday(&curtime, NULL) < 0) -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); - - netcam->receiving->image_time = curtime; - /* -@@ -1485,13 +1805,12 @@ static int netcam_read_file_jpeg(netcam_ - * Note that the average frame time is held in microseconds. - */ - if (netcam->last_image.tv_sec) { -- netcam->av_frame_time = -- ((9.0 * netcam->av_frame_time) + 1000000.0 * -- (curtime.tv_sec - netcam->last_image.tv_sec) + -- (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; -+ netcam->av_frame_time = ((9.0 * netcam->av_frame_time) + 1000000.0 * -+ (curtime.tv_sec - netcam->last_image.tv_sec) + -+ (curtime.tv_usec- netcam->last_image.tv_usec)) / 10.0; - -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "Calculated frame time %f", netcam->av_frame_time); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Calculated frame time %f", -+ netcam->av_frame_time); - } - - netcam->last_image = curtime; -@@ -1499,7 +1818,7 @@ static int netcam_read_file_jpeg(netcam_ - /* - * read is complete - set the current 'receiving' buffer atomically - * as 'latest', and make the buffer previously in 'latest' become -- * the new 'receiving' -+ * the new 'receiving'. - */ - pthread_mutex_lock(&netcam->mutex); - -@@ -1514,11 +1833,9 @@ static int netcam_read_file_jpeg(netcam_ - * next frame to become available may proceed. - */ - pthread_cond_signal(&netcam->pic_ready); -- - pthread_mutex_unlock(&netcam->mutex); - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(-1,0,"End %s", __FUNCTION__); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: End"); - - return 0; - } -@@ -1528,7 +1845,7 @@ tfile_context *file_new_context(void) - { - tfile_context *ret; - -- /* note that mymalloc will exit on any problem */ -+ /* Note that mymalloc will exit on any problem. */ - ret = mymalloc(sizeof(tfile_context)); - if (!ret) - return ret; -@@ -1537,7 +1854,8 @@ tfile_context *file_new_context(void) - return ret; - } - --void file_free_context(tfile_context* ctxt) { -+void file_free_context(tfile_context* ctxt) -+{ - if (ctxt == NULL) - return; - -@@ -1562,8 +1880,8 @@ static int netcam_setup_file(netcam_cont - netcam->file->path = url->path; - url->path = NULL; - -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_INFO, 0, "netcam_setup_file: netcam->file->path %s",netcam->file->path); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->file->path %s", -+ netcam->file->path); - - netcam_url_free(url); - -@@ -1579,7 +1897,7 @@ static int netcam_setup_file(netcam_cont - * - * Parameters - * -- * arg Pointer to the motion context for this camera -+ * arg Pointer to the motion context for this camera. - * - * Returns: NULL pointer - * -@@ -1589,16 +1907,15 @@ static void *netcam_handler_loop(void *a - int retval; - int open_error = 0; - netcam_context_ptr netcam = arg; -- struct context *cnt = netcam->cnt; /* needed for the SETUP macro :-( */ -+ struct context *cnt = netcam->cnt; /* Needed for the SETUP macro :-( */ - - /* Store the corresponding motion thread number in TLS also for this -- * thread (necessary for 'motion_log' to function properly). -+ * thread (necessary for 'MOTION_LOG' to function properly). - */ - pthread_setspecific(tls_key_threadnr, (void *)((unsigned long)cnt->threadnr)); - -- if (SETUP) -- motion_log(LOG_INFO, 0, "Camera handler thread [%d] started", netcam->threadnr); -- -+ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Camera handler thread [%d]" -+ " started", netcam->threadnr); - /* - * The logic of our loop is very simple. If this is a non- - * streaming camera, we re-establish connection with the camera -@@ -1611,97 +1928,137 @@ static void *netcam_handler_loop(void *a - */ - - while (!netcam->finish) { -- if (netcam->response) { /* if html input */ -- if (!netcam->caps.streaming) { -+ if (netcam->response) { /* If html input */ -+ if (netcam->caps.streaming == NCS_UNSUPPORTED) { - /* Non-streaming ie. jpeg */ -- if (!netcam->connect_keepalive || (netcam->connect_keepalive && netcam->keepalive_timeup)) { -- /* If keepalive flag set but time up, time to close this socket */ -+ if (!netcam->connect_keepalive || -+ (netcam->connect_keepalive && netcam->keepalive_timeup)) { -+ /* If keepalive flag set but time up, time to close this socket. */ - if (netcam->connect_keepalive && netcam->keepalive_timeup) { -- motion_log(LOG_INFO, 0, "Closing netcam socket as Keep-Alive time is up " -- "(camera sent Close field). A reconnect should happen."); -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Closing netcam socket" -+ " as Keep-Alive time is up (camera sent Close field). A reconnect" -+ " should happen."); - netcam_disconnect(netcam); - netcam->keepalive_timeup = FALSE; - } - -- /* And the netcam_connect call below will open a new one */ -+ /* And the netcam_connect call below will open a new one. */ - if (netcam_connect(netcam, open_error) < 0) { -- if (!open_error) { /* log first error */ -- motion_log(LOG_ERR, 0, -- "re-opening camera (non-streaming)"); -+ if (!open_error) { /* Log first error. */ -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, -+ "%s: re-opening camera (non-streaming)"); - open_error = 1; - } -- /* need to have a dynamic delay here */ -- SLEEP(5,0); -+ /* Need to have a dynamic delay here. */ -+ SLEEP(5, 0); - continue; - } - -- if (open_error) { /* log re-connection */ -- motion_log(LOG_ERR, 0, "camera re-connected"); -+ if (open_error) { /* Log re-connection */ -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, -+ "%s: camera re-connected"); - open_error = 0; - } - } -- /* Send our request and look at the response */ -+ /* Send our request and look at the response. */ - if ((retval = netcam_read_first_header(netcam)) != 1) { - if (retval > 0) { -- motion_log(LOG_ERR, 0, "Unrecognized image header (%d)", retval); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Unrecognized image" -+ " header (%d)", retval); - } else if (retval != -1) { -- motion_log(LOG_ERR, 0, "Error in header (%d)", retval); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error in header (%d)", -+ retval); - } -- /* need to have a dynamic delay here */ -+ /* Need to have a dynamic delay here. */ - continue; - } -- } else { /* Streaming */ -+ } else if (netcam->caps.streaming == NCS_MULTIPART) { /* Multipart Streaming */ - if (netcam_read_next_header(netcam) < 0) { - if (netcam_connect(netcam, open_error) < 0) { -- if (!open_error) { /* log first error */ -- motion_log(LOG_ERR, 0, "re-opening camera (streaming)"); -+ if (!open_error) { /* Log first error */ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, -+ "%s: re-opening camera (streaming)"); - open_error = 1; - } -- SLEEP(5,0); -+ SLEEP(5, 0); - continue; - } - - if ((retval = netcam_read_first_header(netcam) != 2)) { - if (retval > 0) { -- motion_log(LOG_ERR, 0, "Unrecognized image header (%d)", retval); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, -+ "%s: Unrecognized image header (%d)", -+ retval); - } else if (retval != -1) { -- motion_log(LOG_ERR, 0, "Error in header (%d)", retval); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, -+ "%s: Error in header (%d)", retval); - } -- /* FIXME need some limit */ -+ /* FIXME need some limit. */ - continue; - } - } -- if (open_error) { /* log re-connection */ -- motion_log(LOG_ERR, 0, "camera re-connected"); -+ if (open_error) { /* Log re-connection */ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, -+ "%s: camera re-connected"); - open_error = 0; - } -+ } else if (netcam->caps.streaming == NCS_BLOCK) { /* MJPG-Block streaming */ -+ /* -+ * Since we cannot move in the stream here, because we will read past the -+ * MJPG-block-header, error handling is done while reading MJPG blocks. -+ */ - } - } -- if (netcam->get_image(netcam) < 0) { -- motion_log(LOG_ERR, 0, "Error getting jpeg image"); -- /* if FTP connection, attempt to re-connect to server */ -- if (netcam->ftp) { -- close(netcam->ftp->control_file_desc); -- if (ftp_connect(netcam) < 0) -- motion_log(LOG_ERR, 0, "Trying to re-connect"); -- -+ -+ if (netcam->caps.streaming == NCS_RTSP) { -+ if (netcam->rtsp->format_context == NULL) { // We must have disconnected. Try to reconnect -+ if (netcam->rtsp->status == RTSP_CONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Reconnecting with camera...."); -+ } -+ netcam->rtsp->status = RTSP_RECONNECTING; -+ netcam_connect_rtsp(netcam); -+ continue; -+ } else { -+ // We think we are connected... -+ if (netcam->get_image(netcam) < 0) { -+ if (netcam->rtsp->status == RTSP_CONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Bad image. Reconnecting with camera...."); -+ } -+ //Nope. We are not or got bad image. Reconnect -+ netcam->rtsp->status = RTSP_RECONNECTING; -+ netcam_connect_rtsp(netcam); -+ continue; -+ } -+ } -+ } -+ -+ if (netcam->caps.streaming != NCS_RTSP) { -+ if (netcam->get_image(netcam) < 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error getting jpeg image"); -+ /* If FTP connection, attempt to re-connect to server. */ -+ if (netcam->ftp) { -+ close(netcam->ftp->control_file_desc); -+ if (ftp_connect(netcam) < 0) -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Trying to re-connect"); -+ } -+ continue; - } -- continue; - } -+ - /* - * FIXME - * Need to check whether the image was received / decoded -- * satisfactorily -+ * satisfactorily. - */ - - /* - * If non-streaming, want to synchronize our thread with the - * motion main-loop. - */ -- if (!netcam->caps.streaming) { -+ if (netcam->caps.streaming == NCS_UNSUPPORTED) { - pthread_mutex_lock(&netcam->mutex); - -- /* before anything else, check for system shutdown */ -+ /* Before anything else, check for system shutdown. */ - if (netcam->finish) { - pthread_mutex_unlock(&netcam->mutex); - break; -@@ -1722,21 +2079,22 @@ static void *netcam_handler_loop(void *a - - pthread_mutex_unlock(&netcam->mutex); - } -- /* the loop continues forever, or until motion shutdown */ -+ /* The loop continues forever, or until motion shutdown. */ - } - -- /* our thread is finished - decrement motion's thread count */ -+ /* Our thread is finished - decrement motion's thread count. */ - pthread_mutex_lock(&global_lock); - threads_running--; - pthread_mutex_unlock(&global_lock); - -- /* log out a termination message */ -- motion_log(LOG_INFO, 0, "netcam camera handler: finish set, exiting"); -+ /* Log out a termination message. */ -+ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: netcam camera handler:" -+ " finish set, exiting"); - -- /* setting netcam->thread_id to zero shows netcam_cleanup we're done */ -+ /* Setting netcam->thread_id to zero shows netcam_cleanup we're done. */ - netcam->thread_id = 0; - -- /* signal netcam_cleanup that we're all done */ -+ /* Signal netcam_cleanup that we're all done. */ - pthread_mutex_lock(&netcam->mutex); - pthread_cond_signal(&netcam->exiting); - pthread_mutex_unlock(&netcam->mutex); -@@ -1745,22 +2103,38 @@ static void *netcam_handler_loop(void *a - pthread_exit(NULL); - } - --static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) { -+/** -+ * netcam_http_build_url -+ * -+ * This routing takes care of the url-processing part of the http protocol. -+ * This includes url scheme and parsing, proxy handling, http-authentication -+ * preparation, response buffer allocation and so on. At the end of this -+ * routine, we are ready to call netcam_http_request(). -+ * -+ * Parameters: -+ * netcam Pointer to a netcam_context structure -+ * url Pointer to a netcam url structure -+ * -+ * Returns: 0 on success, -+ * or -1 if an fatal error occurs. -+ */ -+static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) -+{ - struct context *cnt = netcam->cnt; -- const char *ptr; /* working var */ -- char *userpass; /* temp pointer to config value */ -- char *encuserpass; /* temp storage for encoded ver */ -- char *request_pass = NULL; /* temp storage for base64 conv */ -+ const char *ptr; /* Working var */ -+ char *userpass; /* Temp pointer to config value */ -+ char *encuserpass; /* Temp storage for encoded ver */ -+ char *request_pass = NULL; /* Temp storage for base64 conv */ - int ix; - -- /* First the http context structure */ -+ /* First the http context structure. */ - netcam->response = (struct rbuf *) mymalloc(sizeof(struct rbuf)); - memset(netcam->response, 0, sizeof(struct rbuf)); - -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_INFO, 0, "netcam_setup_html: Netcam has flags: HTTP1.0: %s HTTP1.1: %s Keep-Alive %s.", -- netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", -- netcam->connect_keepalive ? "ON":"OFF"); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam has flags:" -+ " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", -+ netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", -+ netcam->connect_keepalive ? "ON":"OFF"); - - /* - * The network camera may require a username and password. If -@@ -1775,11 +2149,11 @@ static int netcam_setup_html(netcam_cont - else - ptr = url->userpass; - -- /* base64_encode needs up to 3 additional chars */ -+ /* base64_encode needs up to 3 additional chars. */ - if (ptr) { - userpass = mymalloc(strlen(ptr) + 3); - strcpy(userpass, ptr); -- } else { -+ } else { - userpass = NULL; - } - -@@ -1792,20 +2166,21 @@ static int netcam_setup_html(netcam_cont - * concatenate it with the request. - * - */ -- /* space for final \r\n plus string terminator */ -+ -+ /* Space for final \r\n plus string terminator. */ - ix = 3; - -- /* See if username / password is required */ -- if (userpass) { /* if either of the above are non-NULL */ -- /* Allocate space for the base64-encoded string */ -+ /* See if username / password is required. */ -+ if (userpass) { /* If either of the above are non-NULL. */ -+ /* Allocate space for the base64-encoded string. */ - encuserpass = mymalloc(BASE64_LENGTH(strlen(userpass)) + 1); -- /* Fill in the value */ -+ /* Fill in the value. */ - base64_encode(userpass, encuserpass, strlen(userpass)); -- /* Now create the last part (authorization) of the request */ -+ /* Now create the last part (authorization) of the request. */ - request_pass = mymalloc(strlen(connect_auth_req) + - strlen(encuserpass) + 1); - ix += sprintf(request_pass, connect_auth_req, encuserpass); -- /* free the working variables */ -+ /* Free the working variables. */ - free(encuserpass); - } - -@@ -1831,16 +2206,19 @@ static int netcam_setup_html(netcam_cont - ptr = mymalloc(strlen(url->service) + strlen(url->host) - + strlen(url->path) + 4); - sprintf((char *)ptr, "http://%s%s", url->host, url->path); -- netcam->connect_keepalive=0; /* Disable Keepalive if proxy */ -- -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_DEBUG, 0, "Removed netcam_keepalive flag due to proxy set." -- "Proxy is incompatible with Keep-Alive."); -+ -+ netcam->connect_keepalive = FALSE; /* Disable Keepalive if proxy */ -+ free((void *)netcam->cnt->conf.netcam_keepalive); -+ netcam->cnt->conf.netcam_keepalive = strdup("off"); -+ -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: " -+ "Removed netcam_keepalive flag due to proxy set." -+ "Proxy is incompatible with Keep-Alive."); - } else { -- /* if no proxy, set as netcam_url path */ -+ /* If no proxy, set as netcam_url path. */ - ptr = url->path; - /* -- * after generating the connect message the string -+ * After generating the connect message the string - * will be freed, so we don't want netcam_url_free - * to free it as well. - */ -@@ -1849,21 +2227,25 @@ static int netcam_setup_html(netcam_cont - - ix += strlen(ptr); - -- /* Now add the required number of characters for the close header -- * or Keep-Alive header. We test the flag which can be unset if -- * there is a problem (rather than the flag in the conf structure -- * which is read-only. -- */ -+ /* -+ * Now add the required number of characters for the close header -+ * or Keep-Alive header. We test the flag which can be unset if -+ * there is a problem (rather than the flag in the conf structure -+ * which is read-only. -+ */ - -- if (netcam->connect_keepalive) -+ if (netcam->connect_keepalive) - ix += strlen(connect_req_keepalive); -- else -+ else - ix += strlen(connect_req_close); - -- /* Point to either the HTTP 1.0 or 1.1 request header set */ -- /* If the configuration is anything other than 1.1, use 1.0 */ -- /* as a default. This avoids a chance of being left with none */ -- if (netcam->connect_http_11==TRUE) -+ -+ /* -+ * Point to either the HTTP 1.0 or 1.1 request header set -+ * If the configuration is anything other than 1.1, use 1.0 -+ * as a default. This avoids a chance of being left with none. -+ */ -+ if (netcam->connect_http_11 == TRUE) - connect_req = connect_req_http11; - else - connect_req = connect_req_http10; -@@ -1875,7 +2257,7 @@ static int netcam_setup_html(netcam_cont - netcam->connect_request = mymalloc(strlen(connect_req) + ix + - strlen(netcam->connect_host)); - -- /* Now create the request string with an sprintf */ -+ /* Now create the request string with an sprintf. */ - sprintf(netcam->connect_request, connect_req, ptr, - netcam->connect_host); - -@@ -1891,73 +2273,110 @@ static int netcam_setup_html(netcam_cont - free(userpass); - } - -- /* put on the final CRLF onto the request */ -+ /* Put on the final CRLF onto the request. */ - strcat(netcam->connect_request, "\r\n"); - free((void *)ptr); -- netcam_url_free(url); /* Cleanup the url data */ -+ netcam_url_free(url); /* Cleanup the url data. */ - -- if (debug_level > CAMERA_INFO) { -- motion_log(-1, 0, "Camera connect string is ''%s''", netcam->connect_request); -- motion_log(-1, 0, "End of camera connect string."); -- } -+ MOTION_LOG(INF , TYPE_NETCAM, NO_ERRNO, "%s: Camera connect" -+ " string is ''%s'' End of camera connect string.", -+ netcam->connect_request); -+ return 0; -+} - -+/** -+ * netcam_setup_html -+ * This function will parse the netcam url, connect to the camera, -+ * set its type to jpeg-based, detect multipart and keep-alive, -+ * and the get_image method accordingly. The cam can be non-streaming -+ * or multipart-streaming. -+ * -+ * Parameters -+ * -+ * netcam Pointer to the netcam_context for the camera -+ * url Pointer to the url of the camera -+ * -+ * Returns: 0 on success (camera link ok) or -1 if an error occurred. -+ * -+ */ -+static int netcam_setup_html(netcam_context_ptr netcam, struct url_t *url) -+{ - /* -- * Our basic initialisation has been completed. Now we will attempt -- * to connect with the camera so that we can then get a "header" -- * in order to find out what kind of camera we are dealing with, -- * as well as what are the picture dimensions. Note that for -- * this initial connection, any failure will cause an error -- * return from netcam_start (unlike later possible attempts at -- * re-connecting, if the network connection is later interrupted). -+ * This netcam is http-based, so build the required URL and -+ * structures, like the connection-string and so on. - */ -- for (ix = 0; ix < MAX_HEADER_RETRIES; ix++) { -- /* -- * netcam_connect does an automatic netcam_close, so it's -- * safe to include it as part of this loop -- * (Not always true now Keep-Alive is implemented) -- */ -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "netcam_setup_html: about to try to connect, time #%d", ix); -- -- if (netcam_connect(netcam, 0) != 0) { -- motion_log(LOG_ERR, 0,"Failed to open camera - check your config and that netcamera is online"); -- -- /* Fatal error on startup */ -- ix = MAX_HEADER_RETRIES; -- break;; -- } -- -- if (netcam_read_first_header(netcam) >= 0) -- break; -- -- motion_log(LOG_ERR, 0, "Error reading first header - re-trying"); -- } -- -- if (ix == MAX_HEADER_RETRIES) { -- motion_log(LOG_ERR, 0, "Failed to read first camera header - giving up for now"); -+ if (netcam_http_build_url(netcam, url) < 0) - return -1; -- } -+ -+ /* -+ * Then we will send our http request and get headers. -+ */ -+ if (netcam_http_request(netcam) < 0) -+ return -1; - - /* - * If this is a streaming camera, we need to position just -- * past the boundary string and read the image header -+ * past the boundary string and read the image header. - */ -- if (netcam->caps.streaming) { -+ if (netcam->caps.streaming == NCS_MULTIPART) { - if (netcam_read_next_header(netcam) < 0) { -- motion_log(LOG_ERR, 0, -- "Failed to read first stream header - giving up for now"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed " -+ "to read first stream header - " -+ "giving up for now"); - return -1; - } - } - -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "netcam_setup_html: connected, going on to read image.", ix ); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: connected," -+ " going on to read image."); - - netcam->get_image = netcam_read_html_jpeg; - return 0; - } - --static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) { -+/** -+ * netcam_setup_mjpg -+ * This function will parse the netcam url, connect to the camera, -+ * set its type to MJPG-Streaming, and the get_image method accordingly. -+ * -+ * Parameters -+ * -+ * netcam Pointer to the netcam_context for the camera -+ * url Pointer to the url of the camera -+ * -+ * Returns: 0 on success (camera link ok) or -1 if an error occurred. -+ * -+ */ -+static int netcam_setup_mjpg(netcam_context_ptr netcam, struct url_t *url) -+{ -+ /* -+ * This netcam is http-based, so build the required URL and -+ * structures, like the connection-string and so on. -+ */ -+ if (netcam_http_build_url(netcam, url) != 0) -+ return -1; -+ -+ /* Then we will send our http request and get headers. */ -+ if (netcam_http_request(netcam) < 0) -+ return -1; -+ -+ /* We have a special type of streaming camera. */ -+ netcam->caps.streaming = NCS_BLOCK; -+ -+ /* -+ * We are positionned right just at the start of the first MJPG -+ * header, so don't move anymore, initialization complete. -+ */ -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: connected," -+ " going on to read and decode MJPG chunks."); -+ -+ netcam->get_image = netcam_read_mjpg_jpeg; -+ -+ return 0; -+} -+ -+static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) -+{ - struct context *cnt = netcam->cnt; - const char *ptr; - -@@ -1972,21 +2391,21 @@ static int netcam_setup_ftp(netcam_conte - netcam->ftp->path = url->path; - url->path = NULL; - -- if (cnt->conf.netcam_userpass != NULL) -+ if (cnt->conf.netcam_userpass != NULL) { - ptr = cnt->conf.netcam_userpass; -- else -- ptr = url->userpass; /* don't set this one NULL, gets freed */ -- -+ } else { -+ ptr = url->userpass; /* Don't set this one NULL, gets freed. */ -+ } - - if (ptr != NULL) { - char *cptr; - - if ((cptr = strchr(ptr, ':')) == NULL) { -- netcam->ftp->user = strdup(ptr); -+ netcam->ftp->user = mystrdup(ptr); - } else { - netcam->ftp->user = mymalloc((cptr - ptr)); -- memcpy(netcam->ftp->user,ptr,(cptr - ptr)); -- netcam->ftp->passwd = strdup(cptr + 1); -+ memcpy(netcam->ftp->user, ptr,(cptr - ptr)); -+ netcam->ftp->passwd = mystrdup(cptr + 1); - } - } - -@@ -2002,7 +2421,8 @@ static int netcam_setup_ftp(netcam_conte - } - - if (ftp_send_type(netcam->ftp, 'I') < 0) { -- motion_log(LOG_ERR, 0, "Error sending TYPE I to ftp server"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error sending" -+ " TYPE I to ftp server"); - return -1; - } - -@@ -2028,19 +2448,23 @@ static int netcam_setup_ftp(netcam_conte - * error reply from the system call. - * - */ --ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) { -+ssize_t netcam_recv(netcam_context_ptr netcam, void *buffptr, size_t buffsize) -+{ - ssize_t retval; - fd_set fd_r; - struct timeval selecttime; - -+ if (netcam->sock < 0) -+ return -1; /* We are not connected, it's impossible to receive data. */ -+ - FD_ZERO(&fd_r); - FD_SET(netcam->sock, &fd_r); - selecttime = netcam->timeout; - - retval = select(FD_SETSIZE, &fd_r, NULL, NULL, &selecttime); -- if (retval == 0) /* 0 means timeout */ -+ if (retval == 0) /* 0 means timeout */ - return -1; -- -+ - return recv(netcam->sock, buffptr, buffsize, 0); - } - -@@ -2081,12 +2505,12 @@ void netcam_cleanup(netcam_context_ptr n - */ - pthread_mutex_lock(&netcam->mutex); - -- if (netcam->cnt->netcam == NULL) -+ if (netcam->cnt->netcam == NULL) - return; -- -+ - /* - * We set the netcam_context pointer in the motion main-loop context -- * to be NULL, so that this routine won't be called a second time -+ * to be NULL, so that this routine won't be called a second time. - */ - netcam->cnt->netcam = NULL; - -@@ -2103,9 +2527,10 @@ void netcam_cleanup(netcam_context_ptr n - * netcam->mutex locked. - */ - -- if (!netcam->caps.streaming) -+ if (netcam->caps.streaming == NCS_UNSUPPORTED) - pthread_cond_signal(&netcam->cap_cond); - -+ - /* - * Once the camera-handler gets to the end of it's loop (probably as - * soon as we release netcam->mutex), because netcam->finish has been -@@ -2131,28 +2556,30 @@ void netcam_cleanup(netcam_context_ptr n - pthread_cond_timedwait(&netcam->exiting, &netcam->mutex, &waittime) != 0) { - /* - * Although this shouldn't happen, if it *does* happen we will -- * log it (just for the programmer's information) -+ * log it (just for the programmer's information). - */ -- motion_log(-1, 0, "No response from camera " -- "handler - it must have already died"); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: No response from camera " -+ "handler - it must have already died"); - pthread_mutex_lock(&global_lock); - threads_running--; - pthread_mutex_unlock(&global_lock); - } - -- /* we don't need any lock anymore, so release it */ -+ /* We don't need any lock anymore, so release it. */ - pthread_mutex_unlock(&netcam->mutex); - -- /* and cleanup the rest of the netcam_context structure */ -+ /* and cleanup the rest of the netcam_context structure. */ - if (netcam->connect_host != NULL) - free(netcam->connect_host); -- -+ - if (netcam->connect_request != NULL) - free(netcam->connect_request); - -+ - if (netcam->boundary != NULL) - free(netcam->boundary); - -+ - if (netcam->latest != NULL) { - if (netcam->latest->ptr != NULL) - free(netcam->latest->ptr); -@@ -2170,7 +2597,7 @@ void netcam_cleanup(netcam_context_ptr n - if (netcam->jpegbuf != NULL) { - if (netcam->jpegbuf->ptr != NULL) - free(netcam->jpegbuf->ptr); -- -+ - free(netcam->jpegbuf); - } - -@@ -2179,9 +2606,14 @@ void netcam_cleanup(netcam_context_ptr n - else - netcam_disconnect(netcam); - -+ - if (netcam->response != NULL) - free(netcam->response); -- -+ -+ -+ if (netcam->caps.streaming == NCS_RTSP) -+ netcam_shutdown_rtsp(netcam); -+ - pthread_mutex_destroy(&netcam->mutex); - pthread_cond_destroy(&netcam->cap_cond); - pthread_cond_destroy(&netcam->pic_ready); -@@ -2216,9 +2648,7 @@ int netcam_next(struct context *cnt, uns - netcam = cnt->netcam; - - if (!netcam->latest->used) { -- if (debug_level) -- motion_log(LOG_INFO, 0, "netcam_next called with no data in buffer"); -- -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: called with no data in buffer"); - return NETCAM_NOTHING_NEW_ERROR; - } - -@@ -2227,23 +2657,34 @@ int netcam_next(struct context *cnt, uns - * motion main-loop with the camera-handling thread through a signal, - * together with a flag to say "start your next capture". - */ -- if (!netcam->caps.streaming) { -+ if (netcam->caps.streaming == NCS_UNSUPPORTED) { - pthread_mutex_lock(&netcam->mutex); - netcam->start_capture = 1; - pthread_cond_signal(&netcam->cap_cond); - pthread_mutex_unlock(&netcam->mutex); - } - -+ if (netcam->caps.streaming == NCS_RTSP) { -+ -+ if (netcam->rtsp->status == RTSP_RECONNECTING) -+ return NETCAM_NOTHING_NEW_ERROR; -+ -+ if (netcam_next_rtsp(image , netcam) < 0) -+ return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; -+ -+ return 0; -+ } -+ - /* - * If an error occurs in the JPEG decompression which follows this, - * jpeglib will return to the code within this 'if'. Basically, our - * approach is to just return a NULL (failed) to the caller (an -- * error message has already been produced by the libjpeg routines) -+ * error message has already been produced by the libjpeg routines). - */ - if (setjmp(netcam->setjmp_buffer)) - return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; - -- /* If there was no error, process the latest image buffer */ -+ /* If there was no error, process the latest image buffer. */ - return netcam_proc_jpeg(netcam, image); - } - -@@ -2258,25 +2699,24 @@ int netcam_next(struct context *cnt, uns - * - * Parameters: - * -- * cnt Pointer to the motion context structure for this device -+ * cnt Pointer to the motion context structure for this device. - * -- * Returns: 0 on success, -1 on any failure -+ * Returns: 0 on success -+ * -1 on any failure -+ * -3 image dimensions are not modulo 16 - */ - - int netcam_start(struct context *cnt) - { -- netcam_context_ptr netcam; /* local pointer to our context */ -- pthread_attr_t handler_attribute; /* attributes of our handler thread */ -- int retval; /* working var */ -- struct url_t url; /* for parsing netcam URL */ -- -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "entered netcam_start()"); -+ netcam_context_ptr netcam; /* Local pointer to our context. */ -+ pthread_attr_t handler_attribute; /* Attributes of our handler thread. */ -+ int retval; /* Working var. */ -+ struct url_t url; /* For parsing netcam URL. */ - - memset(&url, 0, sizeof(url)); -- if (SETUP) -- motion_log(LOG_INFO, 0, "Camera thread starting..."); - -+ MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Network Camera thread" -+ " starting... for url (%s)", cnt->conf.netcam_url); - /* - * Create a new netcam_context for this camera - * and clear all the entries. -@@ -2284,8 +2724,8 @@ int netcam_start(struct context *cnt) - cnt->netcam = (struct netcam_context *) - mymalloc(sizeof(struct netcam_context)); - memset(cnt->netcam, 0, sizeof(struct netcam_context)); -- netcam = cnt->netcam; /* Just for clarity in remaining code */ -- netcam->cnt = cnt; /* Fill in the "parent" info */ -+ netcam = cnt->netcam; /* Just for clarity in remaining code. */ -+ netcam->cnt = cnt; /* Fill in the "parent" info. */ - - /* - * Fill in our new netcam context with all known initial -@@ -2312,24 +2752,23 @@ int netcam_start(struct context *cnt) - pthread_cond_init(&netcam->pic_ready, NULL); - pthread_cond_init(&netcam->exiting, NULL); - -- /* Initialise the average frame time to the user's value */ -+ /* Initialise the average frame time to the user's value. */ - netcam->av_frame_time = 1000000.0 / cnt->conf.frame_limit; - -- /* -- * If a proxy has been specified, parse that URL. -- */ -+ /* If a proxy has been specified, parse that URL. */ - if (cnt->conf.netcam_proxy) { - netcam_url_parse(&url, cnt->conf.netcam_proxy); - - if (!url.host) { -- motion_log(LOG_ERR, 0, "Invalid netcam_proxy (%s)", -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_proxy (%s)", - cnt->conf.netcam_proxy); - netcam_url_free(&url); - return -1; - } - - if (url.userpass) { -- motion_log(LOG_ERR, 0, "Username/password not allowed on a proxy URL"); -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Username/password" -+ " not allowed on a proxy URL"); - netcam_url_free(&url); - return -1; - } -@@ -2345,13 +2784,12 @@ int netcam_start(struct context *cnt) - netcam_url_free(&url); /* Finished with proxy */ - } - -- /* -- * Parse the URL from the configuration data -- */ -+ /* Parse the URL from the configuration data */ - netcam_url_parse(&url, cnt->conf.netcam_url); - - if (!url.host) { -- motion_log(LOG_ERR, 0, "Invalid netcam_url (%s)", cnt->conf.netcam_url); -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", -+ cnt->conf.netcam_url); - netcam_url_free(&url); - return -1; - } -@@ -2362,7 +2800,7 @@ int netcam_start(struct context *cnt) - netcam->connect_port = url.port; - } - -- /* Get HTTP Mode (1.0 default, 1.0 Keep-Alive, 1.1) flag from config -+ /* Get HTTP Mode (1.0 default, 1.0 Keep-Alive, 1.1) flag from config - * and report its stata for debug reasons. - * The flags in the conf structure is read only and cannot be - * unset if the Keep-Alive needs to be switched off (ie. netcam does -@@ -2370,43 +2808,64 @@ int netcam_start(struct context *cnt) - * in the context structures (cnt->...) only. - */ - -- if (!strcmp(cnt->conf.netcam_http,"keep_alive")) { -+ if (!strcmp(cnt->conf.netcam_keepalive, "force")) { - netcam->connect_http_10 = TRUE; - netcam->connect_http_11 = FALSE; - netcam->connect_keepalive = TRUE; -- } else if (!strcmp(cnt->conf.netcam_http,"1.0") || !strcmp(cnt->conf.netcam_http,"1.0")) { -+ } else if (!strcmp(cnt->conf.netcam_keepalive, "off")) { - netcam->connect_http_10 = TRUE; - netcam->connect_http_11 = FALSE; - netcam->connect_keepalive = FALSE; -- } else if (!strcmp(cnt->conf.netcam_http,"1.1")) { -+ } else if (!strcmp(cnt->conf.netcam_keepalive, "on")) { - netcam->connect_http_10 = FALSE; - netcam->connect_http_11 = TRUE; -- netcam->connect_keepalive = TRUE; /* HTTP 1.1 has keepalive by default */ -+ netcam->connect_keepalive = TRUE; /* HTTP 1.1 has keepalive by default. */ - } -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_INFO, 0, "netcam_start: Netcam_http parameter '%s' converts to flags: HTTP1.0:" -- "%s HTTP1.1: %s Keep-Alive %s.", cnt->conf.netcam_http, -- netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", -- netcam->connect_keepalive ? "ON":"OFF"); - -- /* Initialise the netcam socket to -1 to trigger a connection by the keep-alive logic */ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam_http parameter '%s'" -+ " converts to flags: HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", -+ cnt->conf.netcam_keepalive, -+ netcam->connect_http_10 ? "1":"0", netcam->connect_http_11 ? "1":"0", -+ netcam->connect_keepalive ? "ON":"OFF"); -+ -+ /* Initialise the netcam socket to -1 to trigger a connection by the keep-alive logic. */ - netcam->sock = -1; - -- if ((url.service) && (!strcmp(url.service, "http")) ){ -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "netcam_start: now calling netcam_setup_html()"); -+ if ((url.service) && (!strcmp(url.service, "http"))) { -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" -+ " netcam_setup_html()"); -+ - retval = netcam_setup_html(netcam, &url); -- } else if ((url.service) && (!strcmp(url.service, "ftp")) ){ -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "netcam_start: now calling netcam_setup_ftp"); -+ } else if ((url.service) && (!strcmp(url.service, "ftp"))) { -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" -+ " netcam_setup_ftp"); -+ - retval = netcam_setup_ftp(netcam, &url); -- } else if ((url.service) && (!strcmp(url.service, "file")) ){ -- if (debug_level > CAMERA_INFO) -- motion_log(-1, 0, "netcam_start: now calling netcam_setup_file()"); -+ } else if ((url.service) && (!strcmp(url.service, "file"))) { -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" -+ " netcam_setup_file()"); -+ - retval = netcam_setup_file(netcam, &url); -+ } else if ((url.service) && (!strcmp(url.service, "mjpg"))) { -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" -+ " netcam_setup_mjpg()"); -+ -+ strcpy(url.service, "http"); /* Put back a real URL service. */ -+ retval = netcam_setup_mjpg(netcam, &url); -+ } else if ((url.service) && (!strcmp(url.service, "mjpeg"))) { -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" -+ " netcam_setup_mjpeg()"); -+ -+ strcpy(url.service, "http"); /* Put back a real URL service. */ -+ retval = netcam_setup_rtsp(netcam, &url); -+ } else if ((url.service) && (!strcmp(url.service, "rtsp"))) { -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: now calling" -+ " netcam_setup_rtsp()"); -+ -+ retval = netcam_setup_rtsp(netcam, &url); - } else { -- motion_log(LOG_ERR, 0, "Invalid netcam service '%s' - " -- "must be http or ftp", url.service); -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam service '%s' - " -+ "must be http, ftp, mjpg, mjpeg or file.", url.service); - netcam_url_free(&url); - return -1; - } -@@ -2422,41 +2881,48 @@ int netcam_start(struct context *cnt) - * these to set the required image buffer(s) in our netcam_struct. - */ - if ((retval = netcam->get_image(netcam)) != 0) { -- motion_log(LOG_ERR, 0, "Failed trying to read first image - retval:%d", retval ); -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Failed trying to " -+ "read first image - retval:%d", retval); -+ netcam->rtsp->status = RTSP_NOTCONNECTED; - return -1; - } - -- /* -- * If an error occurs in the JPEG decompression which follows this, -- * jpeglib will return to the code within this 'if'. If such an error -- * occurs during startup, we will just abandon this attempt. -- */ -- if (setjmp(netcam->setjmp_buffer)) { -- motion_log(LOG_ERR, 0, "libjpeg decompression failure " -- "on first frame - giving up!"); -- return -1; -- } - -- netcam->netcam_tolerant_check = cnt->conf.netcam_tolerant_check; -- netcam->JFIF_marker = 0; -- netcam_get_dimensions(netcam); -+ if (netcam->caps.streaming != NCS_RTSP) { - -- /* Motion currently requires that image height and width is a -- * multiple of 16. So we check for this. -- */ -+ /* -+ * If an error occurs in the JPEG decompression which follows this, -+ * jpeglib will return to the code within this 'if'. If such an error -+ * occurs during startup, we will just abandon this attempt. -+ */ -+ if (setjmp(netcam->setjmp_buffer)) { -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: libjpeg decompression failure " -+ "on first frame - giving up!"); -+ return -1; -+ } -+ -+ netcam->netcam_tolerant_check = cnt->conf.netcam_tolerant_check; -+ netcam->JFIF_marker = 0; -+ netcam_get_dimensions(netcam); -+ } -+ /* -+ * Motion currently requires that image height and width is a -+ * multiple of 16. So we check for this. -+ */ - if (netcam->width % 16) { -- motion_log(LOG_ERR, 0, "netcam image width (%d) is not modulo 16", -- netcam->width); -- return -1; -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" -+ " is not modulo 16", netcam->width); -+ return -3; - } - - if (netcam->height % 16) { -- motion_log(LOG_ERR, 0, "netcam image height (%d) is not modulo 16", -- netcam->height); -- return -1; -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" -+ " is not modulo 16", netcam->height); -+ return -3; - } -+ - -- /* Fill in camera details into context structure */ -+ /* Fill in camera details into context structure. */ - cnt->imgs.width = netcam->width; - cnt->imgs.height = netcam->height; - cnt->imgs.size = (netcam->width * netcam->height * 3) / 2; -@@ -2475,7 +2941,8 @@ int netcam_start(struct context *cnt) - - if ((retval = pthread_create(&netcam->thread_id, &handler_attribute, - &netcam_handler_loop, netcam)) < 0) { -- motion_log(LOG_ERR, 1, "Starting camera handler thread [%d]", netcam->threadnr); -+ MOTION_LOG(ALR, TYPE_NETCAM, SHOW_ERRNO, "%s: Starting camera" -+ " handler thread [%d]", netcam->threadnr); - return -1; - } - ---- motion-3.2.12.orig/netcam.h -+++ motion-3.2.12/netcam.h -@@ -102,6 +102,16 @@ typedef struct file_context { - time_t last_st_mtime; /* time this image was modified */ - } tfile_context; - -+#define NCS_UNSUPPORTED 0 /* streaming is not supported */ -+#define NCS_MULTIPART 1 /* streaming is done via multipart */ -+#define NCS_BLOCK 2 /* streaming is done via MJPG-block */ -+#define NCS_RTSP 3 /* streaming is done via RTSP */ -+ -+ -+#define RTSP_NOTCONNECTED 0 /* The camera has never connected */ -+#define RTSP_CONNECTED 1 /* The camera is currently connected */ -+#define RTSP_RECONNECTING 2 /* The camera is trying to reconnect*/ -+ - /* - * struct netcam_context contains all the structures and other data - * for an individual netcam. -@@ -154,13 +164,15 @@ typedef struct netcam_context { - specified as something else by - the user */ - -- int connect_http_10; /* set to TRUE if HTTP 1.0 connection */ -+ int connect_http_10; /* set to TRUE if HTTP 1.0 connection -+ (netcam_keepalive off) */ - -- int connect_http_11; /* set to TRUE if HTTP 1.1 connection */ -+ int connect_http_11; /* set to TRUE if HTTP 1.1 connection -+ (netcam_keepalive on) */ - -- int connect_keepalive; /* set to TRUE if connection maintained -- after a request, otherwise FALSE to -- close down the socket each time */ -+ int connect_keepalive; /* set to TRUE if connection maintained after -+ a request, otherwise FALSE to close down -+ the socket each time (netcam_keealive force) */ - - int keepalive_thisconn; /* set to TRUE if cam has sent 'Keep-Alive' in this connection */ - -@@ -193,6 +205,9 @@ typedef struct netcam_context { - struct file_context *file; /* this structure contains the - context for FILE connection */ - -+ struct rtsp_context *rtsp; /* this structure contains the -+ context for RTSP connection */ -+ - int (*get_image)(netcam_context_ptr); - /* Function to fetch the image from - the netcam. It is initialised in -@@ -202,7 +217,7 @@ typedef struct netcam_context { - - - struct netcam_caps { /* netcam capabilities: */ -- unsigned char streaming; /* 1 - supported */ -+ unsigned char streaming; /* See the NCS_* defines */ - unsigned char content_length; /* 0 - unsupported */ - } caps; - -@@ -229,6 +244,9 @@ typedef struct netcam_context { - int imgcnt_last; /* remember last count to check if a new - image arrived */ - -+ int warning_count; /* simple count of number of warnings -+ since last good frame was received */ -+ - int error_count; /* simple count of number of errors since - last good frame was received */ - -@@ -251,8 +269,29 @@ typedef struct netcam_context { - occurred during decompression*/ - } netcam_context; - -+#define MJPG_MH_MAGIC "MJPG" -+#define MJPG_MH_MAGIC_SIZE 4 - - /* -+ * MJPG Chunk header for MJPG streaming. -+ * Little-endian data is read from the network. -+ */ -+typedef struct { -+ char mh_magic[MJPG_MH_MAGIC_SIZE]; /* must contain the string MJP -+ not null-terminated. */ -+ unsigned int mh_framesize; /* Total size of the current -+ frame in bytes (~45kb on WVC200) */ -+ unsigned short mh_framewidth; /* Frame width in pixels */ -+ unsigned short mh_frameheight; /* Frame height in pixels */ -+ unsigned int mh_frameoffset; /* Offset of this chunk relative -+ to the beginning of frame. */ -+ unsigned short mh_chunksize; /* The size of the chunk data -+ following this header. */ -+ char mh_reserved[30]; /* Unknown data, seems to be -+ constant between all headers */ -+} mjpg_header; -+ -+/* - * Declare prototypes for our external entry points - */ - /* Within netcam_jpeg.c */ -@@ -263,5 +302,6 @@ int netcam_start (struct context *); - int netcam_next (struct context *, unsigned char *); - void netcam_cleanup (struct netcam_context *, int); - ssize_t netcam_recv(netcam_context_ptr, void *, size_t); -+void netcam_url_free(struct url_t *parse_url); - - #endif ---- motion-3.2.12.orig/netcam_ftp.c -+++ motion-3.2.12/netcam_ftp.c -@@ -1,56 +1,53 @@ --/** --* Much of the FTP code was inspired by the nanoftp.c module from --* libxml2 (Copyright Daniel Veillard, 2003). The routines have been --* modified to fit the needs of the Motion project. --* --* Copyright 2005, William M. Brack --* This software is distributed under the GNU Public license Version 2. --* See also the file 'COPYING'. --* --*/ --#include "motion.h" /* needs to come first, because _GNU_SOURCE_ set there */ -+/* -+ * Much of the FTP code was inspired by the nanoftp.c module from -+ * libxml2 (Copyright Daniel Veillard, 2003). The routines have been -+ * modified to fit the needs of the Motion project. -+ * -+ * Copyright 2005, William M. Brack -+ * This software is distributed under the GNU Public license Version 2. -+ * See also the file 'COPYING'. -+ * -+ */ -+#include "motion.h" /* Needs to come first, because _GNU_SOURCE_ set there. */ - - #include - #include --#include --#include - #include -- - #include "netcam_ftp.h" - - /** - * ftp_new_context - * --* Create a new FTP context structure -+* Create a new FTP context structure. - * - * Parameters - * - * None - * --* Returns: Pointer to the newly-created structure, NULL if error -+* Returns: Pointer to the newly-created structure, NULL if error. - * - */ - ftp_context_pointer ftp_new_context(void) - { - ftp_context_pointer ret; - -- /* note that mymalloc will exit on any problem */ -+ /* Note that mymalloc will exit on any problem. */ - ret = mymalloc(sizeof(ftp_context)); - - memset(ret, 0, sizeof(ftp_context)); -- ret->control_file_desc = -1; /* no control connection yet */ -- ret->data_file_desc = -1; /* no data connection yet */ -+ ret->control_file_desc = -1; /* No control connection yet. */ -+ ret->data_file_desc = -1; /* No data connection yet. */ - return ret; - } - - /** - * ftp_free_context - * --* Free the resources allocated for this context -+* Free the resources allocated for this context. - * - * Parameters - * --* ctxt Pointer to the ftp_context structure -+* ctxt Pointer to the ftp_context structure. - * - * Returns: Nothing - * -@@ -82,15 +79,16 @@ void ftp_free_context(ftp_context_pointe - * - * Parameters: - * --* buf the buffer containing the response --* len the buffer length -+* buf the buffer containing the response. -+* len the buffer length. - * - * Returns: - * 0 for errors - * +XXX for last line of response - * -XXX for response to be continued - */ --static int ftp_parse_response(char *buf, int len) { -+static int ftp_parse_response(char *buf, int len) -+{ - int val = 0; - - if (len < 3) -@@ -126,19 +124,20 @@ static int ftp_parse_response(char *buf, - /** - * ftp_get_more - * --* Read more information from the FTP control connection -+* Read more information from the FTP control connection. - * - * Parameters: - * --* ctxt pointer to an FTP context -+* ctxt pointer to an FTP context. - * - * Returns the number of bytes read, < 0 indicates an error - */ --static int ftp_get_more(ftp_context_pointer ctxt) { -+static int ftp_get_more(ftp_context_pointer ctxt) -+{ - int len; - int size; - -- /* Validate that our context structure is valid */ -+ /* Validate that our context structure is valid. */ - if ((ctxt == NULL) || (ctxt->control_file_desc < 0)) - return -1; - -@@ -151,29 +150,24 @@ static int ftp_get_more(ftp_context_poin - if (ctxt->control_buffer_index > ctxt->control_buffer_used) - return -1; - -- /* -- * First pack the control buffer -- */ -+ /* First pack the control buffer. */ - if (ctxt->control_buffer_index > 0) { - memmove(&ctxt->control_buffer[0], -- &ctxt->control_buffer[ctxt->control_buffer_index], -- ctxt->control_buffer_used - ctxt->control_buffer_index); -- -+ &ctxt->control_buffer[ctxt->control_buffer_index], -+ ctxt->control_buffer_used - ctxt->control_buffer_index); - ctxt->control_buffer_used -= ctxt->control_buffer_index; - ctxt->control_buffer_index = 0; - } -+ - size = FTP_BUF_SIZE - ctxt->control_buffer_used; - -- if (size == 0) -+ if (size == 0) - return 0; -- - -- /* -- * Read the amount left on the control connection -- */ -+ /* Read the amount left on the control connection. */ - if ((len = recv(ctxt->control_file_desc, -- &ctxt->control_buffer[ctxt->control_buffer_index], size, 0)) < 0) { -- motion_log(LOG_ERR, 1, "recv failed in ftp_get_more"); -+ &ctxt->control_buffer[ctxt->control_buffer_index], size, 0)) < 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: recv failed in ftp_get_more"); - close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; - return -1; -@@ -196,7 +190,8 @@ static int ftp_get_more(ftp_context_poin - * - * Returns the code number - */ --static int ftp_get_response(ftp_context_pointer ctxt) { -+static int ftp_get_response(ftp_context_pointer ctxt) -+{ - char *ptr, *end; - int len; - int res = -1, cur = -1; -@@ -206,17 +201,19 @@ static int ftp_get_response(ftp_context_ - - get_more: - /* -- * Assumes everything up to control_buffer[control_buffer_index] has been read -- * and analyzed. -- */ -+ * Assumes everything up to control_buffer[control_buffer_index] -+ * has been read and analyzed. -+ */ - len = ftp_get_more(ctxt); - -- if (len < 0) -+ if (len < 0) - return -1; -- -- if ((ctxt->control_buffer_used == 0) && (len == 0)) -+ -+ -+ if ((ctxt->control_buffer_used == 0) && (len == 0)) - return -1; -- -+ -+ - ptr = &ctxt->control_buffer[ctxt->control_buffer_index]; - end = &ctxt->control_buffer[ctxt->control_buffer_used]; - -@@ -224,23 +221,22 @@ static int ftp_get_response(ftp_context_ - cur = ftp_parse_response(ptr, end - ptr); - if (cur > 0) { - /* -- * Successfully scanned the control code, skip -- * till the end of the line, but keep the index to be -- * able to analyze the result if needed. -- */ -+ * Successfully scanned the control code, skip -+ * till the end of the line, but keep the index to be -+ * able to analyze the result if needed. -+ */ - res = cur; - ptr += 3; - ctxt->control_buffer_answer = ptr - ctxt->control_buffer; -- -- while ((ptr < end) && (*ptr != '\n')) -+ while ((ptr < end) && (*ptr != '\n')) - ptr++; -- -- if (*ptr == '\n') -+ -+ if (*ptr == '\n') - ptr++; -- -- if (*ptr == '\r') -+ -+ if (*ptr == '\r') - ptr++; -- -+ - break; - } - -@@ -252,7 +248,7 @@ static int ftp_get_response(ftp_context_ - goto get_more; - } - -- if (*ptr != '\r') -+ if (*ptr != '\r') - ptr++; - } - -@@ -265,10 +261,11 @@ static int ftp_get_response(ftp_context_ - } - - /** --* Send the user authentication -+* ftp_send_user -+* Sends the user authentication. - */ -- --static int ftp_send_user(ftp_context_pointer ctxt) { -+static int ftp_send_user(ftp_context_pointer ctxt) -+{ - char buf[200]; - int len; - int res; -@@ -281,20 +278,20 @@ static int ftp_send_user(ftp_context_poi - buf[sizeof(buf) - 1] = 0; - len = strlen(buf); - res = send(ctxt->control_file_desc, buf, len, 0); -- -+ - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_send_user"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_send_user"); - return res; - } -- - return 0; - } - - /** --* Send the password authentication -+* ftp_send_passwd -+* Sends the password authentication. - */ -- --static int ftp_send_passwd(ftp_context_pointer ctxt) { -+static int ftp_send_passwd(ftp_context_pointer ctxt) -+{ - char buf[200]; - int len; - int res; -@@ -303,13 +300,13 @@ static int ftp_send_passwd(ftp_context_p - snprintf(buf, sizeof(buf), "PASS anonymous@\r\n"); - else - snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); -- -+ - buf[sizeof(buf) - 1] = 0; - len = strlen(buf); - res = send(ctxt->control_file_desc, buf, len, 0); -- -+ - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_send_passwd"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_send_passwd"); - return res; - } - -@@ -327,9 +324,8 @@ static int ftp_send_passwd(ftp_context_p - * - * Returns -1 in case of error, 0 otherwise - */ -- -- --static int ftp_quit(ftp_context_pointer ctxt) { -+static int ftp_quit(ftp_context_pointer ctxt) -+{ - char buf[200]; - int len, res; - -@@ -341,7 +337,7 @@ static int ftp_quit(ftp_context_pointer - res = send(ctxt->control_file_desc, buf, len, 0); - - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_quit"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_quit"); - return res; - } - -@@ -351,16 +347,16 @@ static int ftp_quit(ftp_context_pointer - /** - * ftp_connect - * --* Tries to open a control connection -+* Tries to open a control connection. - * - * Parameters: - * - * ctxt an FTP context - * --* Returns -1 in case of error, 0 otherwise -+* Returns -1 in case of error, 0 otherwise. - */ -- --int ftp_connect(netcam_context_ptr netcam) { -+int ftp_connect(netcam_context_ptr netcam) -+{ - ftp_context_pointer ctxt; - struct hostent *hp; - int port; -@@ -378,11 +374,9 @@ int ftp_connect(netcam_context_ptr netca - if (netcam->connect_host == NULL) - return -1; - -- /* -- * do the blocking DNS query. -- */ -+ /* Do the blocking DNS query. */ - port = netcam->connect_port; -- -+ - if (port == 0) - port = 21; - -@@ -391,48 +385,39 @@ int ftp_connect(netcam_context_ptr netca - hp = gethostbyname (netcam->connect_host); - - if (hp == NULL) { -- motion_log(LOG_ERR, 1, "gethostbyname failed in ftp_connect"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gethostbyname failed in ftp_connect"); - return -1; - } - - if ((unsigned int) hp->h_length > -- sizeof(((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr)) { -- motion_log(LOG_ERR, 1, "gethostbyname address mismatch " -- "in ftp_connect"); -+ sizeof(((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr)) { -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gethostbyname address mismatch " -+ "in ftp_connect"); - return -1; - } - -- /* -- * Prepare the socket -- */ -+ /* Prepare the socket */ - ((struct sockaddr_in *)&ctxt->ftp_address)->sin_family = AF_INET; -- memcpy (&((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr, -- hp->h_addr_list[0], hp->h_length); -- -- ((struct sockaddr_in *)&ctxt->ftp_address)->sin_port = -- (u_short)htons ((unsigned short)port); -+ memcpy (&((struct sockaddr_in *)&ctxt->ftp_address)->sin_addr, hp->h_addr_list[0], hp->h_length); -+ ((struct sockaddr_in *)&ctxt->ftp_address)->sin_port = (u_short)htons ((unsigned short)port); - ctxt->control_file_desc = socket (AF_INET, SOCK_STREAM, 0); - addrlen = sizeof (struct sockaddr_in); - - if (ctxt->control_file_desc < 0) { -- motion_log(LOG_ERR, 1, "socket failed"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: socket failed"); - return -1; - } - -- /* -- * Do the connect. -- */ -+ /* Do the connect. */ - if (connect(ctxt->control_file_desc, (struct sockaddr *) &ctxt->ftp_address, - addrlen) < 0) { -- motion_log(LOG_ERR, 1, "Failed to create a connection"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: Failed to create a connection"); - close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; - return -1; - } - -- /* -- * Wait for the HELLO from the server. -- */ -+ /* Wait for the HELLO from the server. */ - res = ftp_get_response(ctxt); - - if (res != 2) { -@@ -441,10 +426,9 @@ int ftp_connect(netcam_context_ptr netca - return -1; - } - -- /* -- * Do the authentication -- */ -+ /* Do the authentication */ - res = ftp_send_user(ctxt); -+ - if (res < 0) { - close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; -@@ -469,7 +453,7 @@ int ftp_connect(netcam_context_ptr netca - } - - res = ftp_send_passwd(ctxt); -- -+ - if (res < 0) { - close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; -@@ -477,20 +461,20 @@ int ftp_connect(netcam_context_ptr netca - } - - res = ftp_get_response(ctxt); -- - switch (res) { - case 2: - break; - case 3: -- motion_log(LOG_ERR, 0, "FTP server asking for ACCT on anonymous"); -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: FTP server asking for ACCT on anonymous"); - case 1: - case 4: - case 5: - case -1: - default: -- close(ctxt->control_file_desc); ctxt->control_file_desc = -1; -+ close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; -- return -1; -+ ctxt->control_file_desc = -1; -+ return-1; - } - - return 0; -@@ -503,12 +487,12 @@ int ftp_connect(netcam_context_ptr netca - * - * Parameters: - * --* ctxt pointer to an FTP context -+* ctxt pointer to an FTP context. - * - * Returns -1 in case of error, 0 otherwise - */ -- --static int ftp_get_connection(ftp_context_pointer ctxt) { -+static int ftp_get_connection(ftp_context_pointer ctxt) -+{ - char buf[200], *cur; - int len, i; - int res; -@@ -519,16 +503,17 @@ static int ftp_get_connection(ftp_contex - unsigned int data_address_length; - - if (ctxt == NULL) -- return -1; -+ return -1; - -- /* set up a socket for our data address */ -+ /* Set up a socket for our data address. */ - if (ctxt->data_file_desc != -1) -- close(ctxt->data_file_desc); -+ close(ctxt->data_file_desc); -+ - memset (&data_address, 0, sizeof(data_address)); - ctxt->data_file_desc = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); -- -+ - if (ctxt->data_file_desc < 0) { -- motion_log(LOG_ERR, 1, "socket failed"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: socket failed"); - return -1; - } - -@@ -536,7 +521,7 @@ static int ftp_get_connection(ftp_contex - - if (setsockopt(ctxt->data_file_desc, SOL_SOCKET, SO_REUSEADDR, - (char *)&on, sizeof(on)) < 0) { -- motion_log(LOG_ERR, 1, "setting socket option SO_REUSEADDR"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: setting socket option SO_REUSEADDR"); - return -1; - } - -@@ -544,19 +529,18 @@ static int ftp_get_connection(ftp_contex - data_address_length = sizeof (struct sockaddr_in); - - if (ctxt->passive) { -- /* send PASV command over control channel */ -+ /* Send PASV command over control channel. */ - snprintf (buf, sizeof(buf), "PASV\r\n"); - len = strlen (buf); - res = send(ctxt->control_file_desc, buf, len, 0); -- -+ - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_get_connection"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_connection"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return res; - } -- -- /* check server's answer */ -+ /* Check server's answer */ - res = ftp_get_response(ctxt); - - if (res != 2) { -@@ -565,93 +549,89 @@ static int ftp_get_connection(ftp_contex - ctxt->data_file_desc = -1; - return -1; - } else { -- /* -- * retry with an active connection -- */ -+ /* Retry with an active connection. */ - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - ctxt->passive = 0; - } - } -- /* parse the IP address and port supplied by the server */ -+ /* Parse the IP address and port supplied by the server. */ - cur = &ctxt->control_buffer[ctxt->control_buffer_answer]; -+ - while (((*cur < '0') || (*cur > '9')) && *cur != '\0') - cur++; - -- if (sscanf (cur, "%u,%u,%u,%u,%u,%u", &temp[0], &temp[1], &temp[2], -+ if (sscanf(cur, "%u,%u,%u,%u,%u,%u", &temp[0], &temp[1], &temp[2], - &temp[3], &temp[4], &temp[5]) != 6) { -- motion_log(LOG_ERR, 0, "Invalid answer to PASV"); -- -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Invalid answer to PASV"); - if (ctxt->data_file_desc != -1) { - close (ctxt->data_file_desc); - ctxt->data_file_desc = -1; - } -- - return -1; - } - -- for (i=0; i<6; i++) -+ for (i = 0; i < 6; i++) - ad[i] = (unsigned char) (temp[i] & 0xff) ; - - memcpy (&((struct sockaddr_in *)&data_address)->sin_addr, &ad[0], 4); - memcpy (&((struct sockaddr_in *)&data_address)->sin_port, &ad[4], 2); - -- /* Now try to connect to the data port */ -+ /* Now try to connect to the data port. */ - if (connect(ctxt->data_file_desc, (struct sockaddr *) &data_address, - data_address_length) < 0) { -- motion_log(LOG_ERR, 1, "Failed to create a data connection"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: Failed to create a data connection"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return -1; - } -- - } else { - /* -- * We want to bind to a port to receive the data. To do this, -- * we need the address of our host. One easy way to get it is -- * to get the info from the control connection that we have -- * with the remote server -- */ -+ * We want to bind to a port to receive the data. To do this, -+ * we need the address of our host. One easy way to get it is -+ * to get the info from the control connection that we have -+ * with the remote server. -+ */ - getsockname(ctxt->control_file_desc, (struct sockaddr *)&data_address, - &data_address_length); - ((struct sockaddr_in *)&data_address)->sin_port = 0; - -- /* bind to the socket - should give us a unique port */ -+ /* Bind to the socket - should give us a unique port. */ - if (bind(ctxt->data_file_desc, (struct sockaddr *) &data_address, - data_address_length) < 0) { -- motion_log(LOG_ERR, 1, "bind failed"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: bind failed"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return -1; - } - -- /* we get the port number by reading back in the sockaddr */ -+ /* We get the port number by reading back in the sockaddr. */ - getsockname(ctxt->data_file_desc, (struct sockaddr *)&data_address, - &data_address_length); - -- /* set up a 'listen' on the port to get the server's connection */ -+ /* Set up a 'listen' on the port to get the server's connection. */ - if (listen(ctxt->data_file_desc, 1) < 0) { -- motion_log(LOG_ERR, 1, "listen failed"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: listen failed"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return -1; - } - -- /* now generate the PORT command */ -+ /* Now generate the PORT command. */ - adp = (unsigned char *) &((struct sockaddr_in *)&data_address)->sin_addr; - portp = (unsigned char *) &((struct sockaddr_in *)&data_address)->sin_port; -- snprintf (buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", -- adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, -- portp[0] & 0xff, portp[1] & 0xff); -+ snprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", -+ adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, -+ portp[0] & 0xff, portp[1] & 0xff); - - buf[sizeof(buf) - 1] = 0; - len = strlen(buf); - -- /* send the PORT command to the server */ -+ /* Send the PORT command to the server. */ - res = send(ctxt->control_file_desc, buf, len, 0); - - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_get_connection"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_connection"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return res; -@@ -672,16 +652,16 @@ static int ftp_get_connection(ftp_contex - /** - * ftp_close_connection - * --* Close the data connection from the server -+* Close the data connection from the server. - * - * Parameters: - * --* ctxt Pointer to an FTP context -+* ctxt Pointer to an FTP context. - * - * Returns -1 in case of error, 0 otherwise - */ -- --static int ftp_close_connection(ftp_context_pointer ctxt) { -+static int ftp_close_connection(ftp_context_pointer ctxt) -+{ - int res; - fd_set rfd, efd; - struct timeval tv; -@@ -692,7 +672,7 @@ static int ftp_close_connection(ftp_cont - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - -- /* Check for data on the control channel */ -+ /* Check for data on the control channel. */ - tv.tv_sec = 15; - tv.tv_usec = 0; - FD_ZERO(&rfd); -@@ -707,13 +687,13 @@ static int ftp_close_connection(ftp_cont - return -1; - } - -- if (res == 0) { /* timeout */ -+ if (res == 0) { /* Timeout */ - close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; -- } else { /* read the response */ -+ } else { /* Read the response */ - res = ftp_get_response(ctxt); - -- if (res != 2) { /* should be positive completion (2) */ -+ if (res != 2) { /* Should be positive completion (2) */ - close(ctxt->control_file_desc); - ctxt->control_file_desc = -1; - return -1; -@@ -734,9 +714,8 @@ static int ftp_close_connection(ftp_cont - * - * Returns the socket for the data connection, or <0 in case of error - */ -- -- --int ftp_get_socket(ftp_context_pointer ctxt) { -+int ftp_get_socket(ftp_context_pointer ctxt) -+{ - char buf[300]; - int res, len; - int acfd; -@@ -744,28 +723,28 @@ int ftp_get_socket(ftp_context_pointer c - if ((ctxt == NULL) || (ctxt->path == NULL)) - return -1; - -- /* Set up the data connection */ -+ /* Set up the data connection. */ - ctxt->data_file_desc = ftp_get_connection(ctxt); - - if (ctxt->data_file_desc == -1) - return -1; - -- /* generate a "retrieve" command for the file */ -+ /* Generate a "retrieve" command for the file. */ - snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path); - buf[sizeof(buf) - 1] = 0; - len = strlen(buf); - -- /* send it to the server */ -+ /* Send it to the server. */ - res = send(ctxt->control_file_desc, buf, len, 0); - - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_get_socket"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_socket"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return res; - } - -- /* check the answer */ -+ /* Check the answer */ - res = ftp_get_response(ctxt); - - if (res != 1) { -@@ -775,16 +754,16 @@ int ftp_get_socket(ftp_context_pointer c - } - - /* -- * if not a passive connection, need to do an accept to get the -- * connection from the server -- */ -+ * If not a passive connection, need to do an accept to get the -+ * connection from the server. -+ */ - if (!ctxt->passive) { - struct sockaddr_in data_address; - unsigned int data_address_length = sizeof(struct sockaddr_in); - - if ((acfd = accept(ctxt->data_file_desc, (struct sockaddr *)&data_address, - &data_address_length)) < 0) { -- motion_log(LOG_ERR, 1, "accept in ftp_get_socket"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: accept in ftp_get_socket"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return -1; -@@ -799,28 +778,29 @@ int ftp_get_socket(ftp_context_pointer c - /** - * ftp_send_type - * --* Send a TYPE (either 'I' or 'A') command to the server -+* Send a TYPE (either 'I' or 'A') command to the server. - * - * Parameters - * - * ctxt pointer to the ftp_context - * type ascii character ('I' or 'A') - * --* Returns 0 for success, negative error code for failure -+* Returns 0 for success, negative error code for failure. - * - */ --int ftp_send_type(ftp_context_pointer ctxt, char type) { -- char buf[100], utype; -+int ftp_send_type(ftp_context_pointer ctxt, char type) -+{ -+ char buf[100]; - int len, res; - -- utype = toupper(type); -- /* Assure transfer will be in "image" mode */ -+ toupper(type); -+ /* Assure transfer will be in "image" mode. */ - snprintf(buf, sizeof(buf), "TYPE I\r\n"); - len = strlen(buf); - res = send(ctxt->control_file_desc, buf, len, 0); - - if (res < 0) { -- motion_log(LOG_ERR, 1, "send failed in ftp_get_socket"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: send failed in ftp_get_socket"); - close(ctxt->data_file_desc); - ctxt->data_file_desc = -1; - return res; -@@ -852,7 +832,8 @@ int ftp_send_type(ftp_context_pointer ct - * 0 is an indication of an end of connection. - * -1 indicates a parameter error. - */ --int ftp_read(ftp_context_pointer ctxt, void *dest, int len) { -+int ftp_read(ftp_context_pointer ctxt, void *dest, int len) -+{ - if (ctxt == NULL) - return -1; - -@@ -869,7 +850,7 @@ int ftp_read(ftp_context_pointer ctxt, v - - if (len <= 0) { - if (len < 0) -- motion_log(LOG_ERR, 1, "recv failed in ftp_read"); -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: recv failed in ftp_read"); - ftp_close_connection(ctxt); - } - -@@ -880,15 +861,16 @@ int ftp_read(ftp_context_pointer ctxt, v - /** - * ftp_close - * --* Close the connection and both control and transport -+* Close the connection and both control and transport. - * - * Parameters: - * --* ctxt Pointer to an FTP context -+* ctxt Pointer to an FTP context. - * --* Returns -1 in case of error, 0 otherwise -+* Returns -1 in case of error, 0 otherwise. - */ --int ftp_close(ftp_context_pointer ctxt) { -+int ftp_close(ftp_context_pointer ctxt) -+{ - if (ctxt == NULL) - return -1; - -@@ -904,6 +886,5 @@ int ftp_close(ftp_context_pointer ctxt) - } - - ftp_free_context(ctxt); -- - return 0; - } ---- motion-3.2.12.orig/netcam_ftp.h -+++ motion-3.2.12/netcam_ftp.h -@@ -1,5 +1,4 @@ -- --/** -+/* - * Much of the FTP routines was inspired by the nanoftp.c module from - * libxml2 (Copyright Daniel Veillard, 2003). The routines have been - * modified to fit the needs of the Motion project. -@@ -7,7 +6,7 @@ - * Copyright 2005, William M. Brack - * This software is distributed under the GNU Public license Version 2. - * See also the file 'COPYING'. -- * -+ * - */ - #ifndef _INCLUDE_NETCAM_FTP_H - #define _INCLUDE_NETCAM_FTP_H ---- motion-3.2.12.orig/netcam_jpeg.c -+++ motion-3.2.12/netcam_jpeg.c -@@ -13,14 +13,13 @@ - */ - - #include "rotate.h" /* already includes motion.h */ -- - #include - #include - - /* - * netcam_source_mgr is a locally-defined structure to contain elements - * which are not present in the standard libjpeg (the element 'pub' is a -- * pointer to the standard information) -+ * pointer to the standard information). - */ - typedef struct { - struct jpeg_source_mgr pub; -@@ -48,13 +47,11 @@ static void netcam_error_exit(j_comm - - static void netcam_init_source(j_decompress_ptr cinfo) - { -- /* -- * Get our "private" structure from the libjpeg structure -- */ -+ /* Get our "private" structure from the libjpeg structure. */ - netcam_src_ptr src = (netcam_src_ptr) cinfo->src; - /* - * Set the 'start_of_file' flag in our private structure -- * (used by my_fill_input_buffer) -+ * (used by my_fill_input_buffer). - */ - src->start_of_file = TRUE; - } -@@ -84,8 +81,7 @@ static boolean netcam_fill_input_buffer( - src->buffer = (JOCTET *) src->data; - } else { - /* Insert a fake EOI marker - as per jpeglib recommendation */ -- if (debug_level > CAMERA_VERBOSE) -- motion_log(LOG_INFO, 0, "%s: **fake EOI inserted**", __FUNCTION__); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: **fake EOI inserted**"); - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; /* 0xD9 */ - nbytes = 2; -@@ -123,23 +119,23 @@ static void netcam_term_source(j_decompr - * JPEG library decompression routine. - * - * Parameters: -- * cinfo pointer to the jpeg decompression object -- * data pointer to the image data received from a netcam -- * length total size of the image -+ * cinfo pointer to the jpeg decompression object. -+ * data pointer to the image data received from a netcam. -+ * length total size of the image. - * - * Returns: Nothing -- * -+ * - */ - static void netcam_memory_src(j_decompress_ptr cinfo, char *data, int length) - { - netcam_src_ptr src; - -- if (cinfo->src == NULL) { -+ if (cinfo->src == NULL) - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_PERMANENT, - sizeof (netcam_source_mgr)); -- } -+ - - src = (netcam_src_ptr)cinfo->src; - src->data = data; -@@ -162,28 +158,27 @@ static void netcam_memory_src(j_decompre - * - * Parameters - * -- * cinfo pointer to the decompression control structure -+ * cinfo pointer to the decompression control structure. - * - * Returns: does an (ugly) longjmp to get back to netcam_jpeg -- * code -+ * code. - * - */ - static void netcam_error_exit(j_common_ptr cinfo) - { -- /* fetch our pre-stored pointer to the netcam context */ -+ /* Fetch our pre-stored pointer to the netcam context. */ - netcam_context_ptr netcam = cinfo->client_data; -- /* output the message associated with the error */ -+ /* Output the message associated with the error. */ - (*cinfo->err->output_message)(cinfo); -- /* set flag to show the decompression had errors */ -+ /* Set flag to show the decompression had errors. */ - netcam->jpeg_error |= 1; -- /* need to "cleanup" the aborted decompression */ -+ /* Need to "cleanup" the aborted decompression. */ - jpeg_destroy (cinfo); - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(LOG_ERR, 0, "%s: netcam->jpeg_error %d", -- __FUNCTION__, netcam->jpeg_error); -- -- /* jump back to wherever we started */ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: netcam->jpeg_error %d", -+ netcam->jpeg_error); -+ -+ /* Jump back to wherever we started. */ - longjmp(netcam->setjmp_buffer, 1); - } - -@@ -196,7 +191,7 @@ static void netcam_error_exit(j_common_p - * - * Parameters - * -- * cinfo pointer to the decompression control structure -+ * cinfo pointer to the decompression control structure. - * - * Returns Nothing - * -@@ -204,8 +199,8 @@ static void netcam_error_exit(j_common_p - static void netcam_output_message(j_common_ptr cinfo) - { - char buffer[JMSG_LENGTH_MAX]; -- -- /* fetch our pre-stored pointer to the netcam context */ -+ -+ /* Fetch our pre-stored pointer to the netcam context. */ - netcam_context_ptr netcam = cinfo->client_data; - - /* -@@ -213,30 +208,23 @@ static void netcam_output_message(j_comm - * that the jpeg data produced by the camera caused warning - * messages from libjpeg (JWRN_EXTRANEOUS_DATA). The following - * code is to assure that specific warning is ignored. -- * -+ * - * NOTE: It's likely that we will discover other error message - * codes which we want to ignore. In that case, we should have - * some sort of table-lookup to decide which messages we really - * care about. - */ -- if ((cinfo->err->msg_code != JWRN_EXTRANEOUS_DATA) && -- (cinfo->err->msg_code == JWRN_NOT_SEQUENTIAL) && (!netcam->netcam_tolerant_check)) -+ if ((cinfo->err->msg_code != JWRN_EXTRANEOUS_DATA) && -+ (cinfo->err->msg_code == JWRN_NOT_SEQUENTIAL) && (!netcam->netcam_tolerant_check)) - netcam->jpeg_error |= 2; /* Set flag to show problem */ -+ - /* -- * We only display and log errors when debug_level -- * is non-zero. The reasoning here is that these kinds -- * of errors are only produced when the input data is -- * wrong, and that indicates a network problem rather -- * than a problem with the content. -+ * Format the message according to library standards. -+ * Write it out to the motion log. - */ -- if (debug_level > CAMERA_VERBOSE) { -- /* -- * Format the message according to library standards. -- * Write it out to the motion log. -- */ -- (*cinfo->err->format_message)(cinfo, buffer); -- motion_log(LOG_ERR, 0, "%s: %s", __FUNCTION__, buffer); -- } -+ (*cinfo->err->format_message)(cinfo, buffer); -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: %s", buffer); -+ - } - - /** -@@ -246,10 +234,10 @@ static void netcam_output_message(j_comm - * decompression. - * - * Parameters: -- * netcam pointer to netcam_context -- * cinfo pointer to JPEG decompression context -+ * netcam pointer to netcam_context. -+ * cinfo pointer to JPEG decompression context. - * -- * Returns: Error code -+ * Returns: Error code. - */ - static int netcam_init_jpeg(netcam_context_ptr netcam, j_decompress_ptr cinfo) - { -@@ -263,11 +251,11 @@ static int netcam_init_jpeg(netcam_conte - */ - pthread_mutex_lock(&netcam->mutex); - -- if (netcam->imgcnt_last == netcam->imgcnt) { /* need to wait */ -+ if (netcam->imgcnt_last == netcam->imgcnt) { /* Need to wait */ - struct timespec waittime; - struct timeval curtime; - int retcode; -- -+ - /* - * We calculate the delay time (representing the desired frame - * rate). This delay time is in *nanoseconds*. -@@ -282,109 +270,121 @@ static int netcam_init_jpeg(netcam_conte - curtime.tv_usec -= 1000000; - curtime.tv_sec++; - } -- -+ - waittime.tv_sec = curtime.tv_sec; - waittime.tv_nsec = 1000L * curtime.tv_usec; -- -+ - do { - retcode = pthread_cond_timedwait(&netcam->pic_ready, -- &netcam->mutex, &waittime); -+ &netcam->mutex, &waittime); - } while (retcode == EINTR); -- -- if (retcode) { /* we assume a non-zero reply is ETIMEOUT */ -+ -+ if (retcode) { /* We assume a non-zero reply is ETIMEOUT */ - pthread_mutex_unlock(&netcam->mutex); -- -- if (debug_level > CAMERA_WARNINGS) -- motion_log(-1, 0, "%s: no new pic, no signal rcvd", __FUNCTION__); -- -+ -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, -+ "%s: no new pic, no signal rcvd"); -+ - return NETCAM_GENERAL_ERROR | NETCAM_NOTHING_NEW_ERROR; - } -- -- if (debug_level > CAMERA_VERBOSE) -- motion_log(-1, 0, "%s: ***new pic delay successful***", __FUNCTION__); -+ -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, -+ "%s: ***new pic delay successful***"); - } -- -+ - netcam->imgcnt_last = netcam->imgcnt; - -- /* set latest buffer as "current" */ -+ /* Set latest buffer as "current". */ - buff = netcam->latest; - netcam->latest = netcam->jpegbuf; - netcam->jpegbuf = buff; - pthread_mutex_unlock(&netcam->mutex); - -- /* clear any error flag from previous work */ -+ /* Clear any error flag from previous work. */ - netcam->jpeg_error = 0; -- -+ - buff = netcam->jpegbuf; -- /* prepare for the decompression */ -- /* Initialize the JPEG decompression object */ -+ /* -+ * Prepare for the decompression. -+ * Initialize the JPEG decompression object. -+ */ - jpeg_create_decompress(cinfo); - -- /* Set up own error exit routine */ -+ /* Set up own error exit routine. */ - cinfo->err = jpeg_std_error(&netcam->jerr); - cinfo->client_data = netcam; - netcam->jerr.error_exit = netcam_error_exit; - netcam->jerr.output_message = netcam_output_message; - -- /* Specify the data source as our own routine */ -+ /* Specify the data source as our own routine. */ - netcam_memory_src(cinfo, buff->ptr, buff->used); - -- /* Read file parameters (rejecting tables-only) */ -+ /* Read file parameters (rejecting tables-only). */ - jpeg_read_header(cinfo, TRUE); - -- /* Override the desired colour space */ -+ /* Override the desired colour space. */ - cinfo->out_color_space = JCS_YCbCr; - -- /* Start the decompressor */ -+ /* Start the decompressor. */ - jpeg_start_decompress(cinfo); - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(LOG_INFO, 0, "%s: jpeg_error %d", __FUNCTION__, netcam->jpeg_error); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: jpeg_error %d", -+ netcam->jpeg_error); - - return netcam->jpeg_error; - } - -+/** -+ * netcam_image_conv -+ * -+ * Parameters: -+ * netcam pointer to netcam_context -+ * cinfo pointer to JPEG decompression context -+ * image pointer to buffer of destination image (yuv420) -+ * -+ * Returns : netcam->jpeg_error -+ */ - static int netcam_image_conv(netcam_context_ptr netcam, -- struct jpeg_decompress_struct *cinfo, -- unsigned char *image) -+ struct jpeg_decompress_struct *cinfo, -+ unsigned char *image) - { -- JSAMPARRAY line; /* array of decomp data lines */ -- unsigned char *wline; /* will point to line[0] */ --/* Working variables */ -+ JSAMPARRAY line; /* Array of decomp data lines */ -+ unsigned char *wline; /* Will point to line[0] */ -+ /* Working variables */ - int linesize, i; - unsigned char *upic, *vpic; - unsigned char *pic = image; -- unsigned char y; /* switch for decoding YUV data */ -+ unsigned char y; /* Switch for decoding YUV data */ - unsigned int width, height; - - width = cinfo->output_width; - height = cinfo->output_height; - - if (width && ((width != netcam->width) || (height != netcam->height))) { -- motion_log(LOG_ERR, 0, -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, - "%s: JPEG image size %dx%d, JPEG was %dx%d", -- __FUNCTION__, netcam->width, netcam->height, width, height); -- jpeg_destroy_decompress (cinfo); -+ netcam->width, netcam->height, width, height); -+ jpeg_destroy_decompress(cinfo); - netcam->jpeg_error |= 4; - return netcam->jpeg_error; - } -- /* Set the output pointers (these come from YUV411P definition */ -+ /* Set the output pointers (these come from YUV411P definition. */ - upic = pic + width * height; - vpic = upic + (width * height) / 4; - - -- /* YCbCr format will give us one byte each for YUV */ -+ /* YCbCr format will give us one byte each for YUV. */ - linesize = cinfo->output_width * 3; - -- /* Allocate space for one line */ -+ /* Allocate space for one line. */ - line = (cinfo->mem->alloc_sarray)((j_common_ptr) cinfo, JPOOL_IMAGE, -- cinfo->output_width * cinfo->output_components, 1); -+ cinfo->output_width * cinfo->output_components, 1); - - wline = line[0]; - y = 0; - - while (cinfo->output_scanline < height) { -- jpeg_read_scanlines (cinfo, line, 1); -+ jpeg_read_scanlines(cinfo, line, 1); - - for (i = 0; i < linesize; i += 3) { - pic[i / 3] = wline[i]; -@@ -393,25 +393,25 @@ static int netcam_image_conv(netcam_cont - vpic[(i / 3) / 2] = wline[i + 2]; - } - } -+ - pic += linesize / 3; -+ - if (y++ & 1) { - upic += width / 2; - vpic += width / 2; - } - } - -- jpeg_finish_decompress (cinfo); -- jpeg_destroy_decompress (cinfo); -+ jpeg_finish_decompress(cinfo); -+ jpeg_destroy_decompress(cinfo); - -- /* rotate as specified */ -- if (netcam->cnt->rotate_data.degrees > 0) -+ if (netcam->cnt->rotate_data.degrees > 0) -+ /* Rotate as specified */ - rotate_map(netcam->cnt, image); -- - -- if (debug_level > CAMERA_VERBOSE) -- motion_log(LOG_INFO, 0, "%s: jpeg_error %d", -- __FUNCTION__, netcam->jpeg_error); -- -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: jpeg_error %d", -+ netcam->jpeg_error); -+ - return netcam->jpeg_error; - } - -@@ -422,10 +422,10 @@ static int netcam_image_conv(netcam_cont - * suitable for processing by motion. - * - * Parameters: -- * netcam pointer to the netcam_context structure -- * image Pointer to a buffer for the returned image -+ * netcam pointer to the netcam_context structure. -+ * image pointer to a buffer for the returned image. - * -- * Returns: -+ * Returns: - * - * 0 Success - * non-zero error code from other routines -@@ -434,55 +434,52 @@ static int netcam_image_conv(netcam_cont - */ - int netcam_proc_jpeg(netcam_context_ptr netcam, unsigned char *image) - { -- struct jpeg_decompress_struct cinfo; /* decompression control struct */ -- int retval = 0; /* value returned to caller */ -- int ret; /* working var */ -+ struct jpeg_decompress_struct cinfo; /* Decompression control struct. */ -+ int retval = 0; /* Value returned to caller. */ -+ int ret; /* Working var. */ - - /* - * This routine is only called from the main thread. - * We need to "protect" the "latest" image while we - * decompress it. netcam_init_jpeg uses -- * netcam->mutex to do this; -+ * netcam->mutex to do this. - */ -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_INFO, 0, "%s: processing jpeg image - content length " -- "%d", __FUNCTION__, netcam->latest->content_length); -- -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: processing jpeg image" -+ " - content length %d", netcam->latest->content_length); -+ - ret = netcam_init_jpeg(netcam, &cinfo); -- -+ - if (ret != 0) { -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_ERR, 0, "%s: ret %d", __FUNCTION__, ret); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: ret %d", ret); - return ret; -- } -+ } - -- /* Do a sanity check on dimensions -+ /* -+ * Do a sanity check on dimensions - * If dimensions have changed we throw an - * error message that will cause -- * restart of Motion -+ * restart of Motion. - */ - if (netcam->width) { /* 0 means not yet init'ed */ - if ((cinfo.output_width != netcam->width) || - (cinfo.output_height != netcam->height)) { - retval = NETCAM_RESTART_ERROR; -- motion_log(LOG_ERR, 0, -- "%s: Camera width/height mismatch " -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Camera width/height mismatch " - "with JPEG image - expected %dx%d, JPEG %dx%d", -- " retval %d", __FUNCTION__, netcam->width, netcam->height, -+ " retval %d", netcam->width, netcam->height, - cinfo.output_width, cinfo.output_height, retval); -- return retval; -+ return retval; - } - } - -- /* do the conversion */ -+ /* Do the conversion */ - ret = netcam_image_conv(netcam, &cinfo, image); -- -+ - if (ret != 0) { - retval |= NETCAM_JPEG_CONV_ERROR; -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_ERR, 0, "%s: ret %d retval %d", __FUNCTION__, -- ret, retval); -- } -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: ret %d retval %d", -+ ret, retval); -+ } - - return retval; - } -@@ -491,18 +488,18 @@ int netcam_proc_jpeg(netcam_context_ptr - * netcam_get_dimensions - * - * This function gets the height and width of the JPEG image -- * located in the supplied netcam_image_buffer -+ * located in the supplied netcam_image_buffer. - * - * Parameters - * -- * netcam pointer to the netcam context -+ * netcam pointer to the netcam context. - * -- * Returns: Nothing, but fills in width and height into context -+ * Returns: Nothing, but fills in width and height into context. - * - */ - void netcam_get_dimensions(netcam_context_ptr netcam) - { -- struct jpeg_decompress_struct cinfo; /* decompression control struct */ -+ struct jpeg_decompress_struct cinfo; /* Decompression control struct. */ - int ret; - - ret = netcam_init_jpeg(netcam, &cinfo); -@@ -513,7 +510,6 @@ void netcam_get_dimensions(netcam_contex - - jpeg_destroy_decompress(&cinfo); - -- if (debug_level > CAMERA_INFO) -- motion_log(LOG_ERR, 0, "%s: JFIF_marker %s PRESENT ret %d", -- __FUNCTION__, netcam->JFIF_marker ? "IS" : "NOT", ret); -+ MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: JFIF_marker %s PRESENT ret %d", -+ netcam->JFIF_marker ? "IS" : "NOT", ret); - } ---- /dev/null -+++ motion-3.2.12/netcam_rtsp.c -@@ -0,0 +1,926 @@ -+/*********************************************************** -+ * In the top section are the functions that are used -+ * when processing the RTSP camera feed. Since these functions -+ * are internal to the RTSP module, and many require FFmpeg -+ * structures in their declarations, they are within the -+ * HAVE_FFMPEG block that eliminates them entirely when -+ * FFmpeg is not present. -+ * -+ * The functions: -+ * netcam_setup_rtsp -+ * netcam_connect_rtsp -+ * netcam_shutdown_rtsp -+ * netcam_next_rtsp -+ * are called from netcam.c therefore must be defined even -+ * if FFmpeg is not present. They must also not have FFmpeg -+ * structures in the declarations. Simple error -+ * messages are raised if called when no FFmpeg is found. -+ * -+ ***********************************************************/ -+ -+#include -+#include "netcam_rtsp.h" -+#include "rotate.h" /* already includes motion.h */ -+ -+#ifdef HAVE_FFMPEG -+ -+#include "ffmpeg.h" -+ -+/** -+ * netcam_check_pixfmt -+ * -+ * Determine whether pix_format is YUV420P -+ */ -+int netcam_check_pixfmt(netcam_context_ptr netcam){ -+ int retcd; -+ -+ retcd = -1; -+ -+ if ((netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUV420P) || -+ (netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUVJ420P)) retcd = 0; -+ -+ return retcd; -+ -+} -+/** -+ * netcam_rtsp_null_context -+ * -+ * Null all the context -+ */ -+void netcam_rtsp_null_context(netcam_context_ptr netcam){ -+ -+ netcam->rtsp->swsctx = NULL; -+ netcam->rtsp->swsframe_in = NULL; -+ netcam->rtsp->swsframe_out = NULL; -+ netcam->rtsp->frame = NULL; -+ netcam->rtsp->codec_context = NULL; -+ netcam->rtsp->format_context = NULL; -+ -+} -+/** -+ * netcam_rtsp_close_context -+ * -+ * Close all the context that could be open -+ */ -+void netcam_rtsp_close_context(netcam_context_ptr netcam){ -+ -+ if (netcam->rtsp->swsctx != NULL) sws_freeContext(netcam->rtsp->swsctx); -+ if (netcam->rtsp->swsframe_in != NULL) my_frame_free(netcam->rtsp->swsframe_in); -+ if (netcam->rtsp->swsframe_out != NULL) my_frame_free(netcam->rtsp->swsframe_out); -+ if (netcam->rtsp->frame != NULL) my_frame_free(netcam->rtsp->frame); -+ if (netcam->rtsp->codec_context != NULL) avcodec_close(netcam->rtsp->codec_context); -+ if (netcam->rtsp->format_context != NULL) avformat_close_input(&netcam->rtsp->format_context); -+ -+ netcam_rtsp_null_context(netcam); -+} -+ -+/** -+ * netcam_buffsize_rtsp -+ * -+ * This routine checks whether there is enough room in a buffer to copy -+ * some additional data. If there is not enough room, it will re-allocate -+ * the buffer and adjust it's size. -+ * -+ * Parameters: -+ * buff Pointer to a netcam_image_buffer structure. -+ * numbytes The number of bytes to be copied. -+ * -+ * Returns: Nothing -+ */ -+static void netcam_buffsize_rtsp(netcam_buff_ptr buff, size_t numbytes){ -+ -+ int min_size_to_alloc; -+ int real_alloc; -+ int new_size; -+ -+ if ((buff->size - buff->used) >= numbytes) -+ return; -+ -+ min_size_to_alloc = numbytes - (buff->size - buff->used); -+ real_alloc = ((min_size_to_alloc / NETCAM_BUFFSIZE) * NETCAM_BUFFSIZE); -+ -+ if ((min_size_to_alloc - real_alloc) > 0) -+ real_alloc += NETCAM_BUFFSIZE; -+ -+ new_size = buff->size + real_alloc; -+ -+ MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: expanding buffer from [%d/%d] to [%d/%d] bytes.", -+ (int) buff->used, (int) buff->size, -+ (int) buff->used, new_size); -+ -+ buff->ptr = myrealloc(buff->ptr, new_size, -+ "netcam_check_buf_size"); -+ buff->size = new_size; -+} -+ -+/** -+ * decode_packet -+ * -+ * This routine takes in the packet from the read and decodes it into -+ * the frame. It then takes the frame and copies it into the netcam -+ * buffer -+ * -+ * Parameters: -+ * packet The packet that was read from av_read -+ * buffer The buffer that is the final destination -+ * frame The frame into which we decode the packet -+ * -+ * -+ * Returns: -+ * Failure 0(zero) -+ * Success The size of the frame decoded -+ */ -+static int decode_packet(AVPacket *packet, netcam_buff_ptr buffer, AVFrame *frame, AVCodecContext *cc){ -+ int check = 0; -+ int frame_size = 0; -+ int ret = 0; -+ -+ ret = avcodec_decode_video2(cc, frame, &check, packet); -+ if (ret < 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error decoding video packet"); -+ return 0; -+ } -+ -+ if (check == 0) { -+ return 0; -+ } -+ -+ frame_size = avpicture_get_size(cc->pix_fmt, cc->width, cc->height); -+ -+ netcam_buffsize_rtsp(buffer, frame_size); -+ -+ avpicture_layout((const AVPicture*)frame,cc->pix_fmt,cc->width,cc->height -+ ,(unsigned char *)buffer->ptr,frame_size ); -+ -+ buffer->used = frame_size; -+ -+ return frame_size; -+} -+ -+/** -+ * netcam_open_codec -+ * -+ * This routine opens the codec context for the indicated stream -+ * -+ * Parameters: -+ * stream_idx The index of the stream that was found as "best" -+ * fmt_ctx The format context that was created upon opening the stream -+ * type The type of media type (This is a constant) -+ * -+ * -+ * Returns: -+ * Failure Error code from FFmpeg (Negative number) -+ * Success 0(Zero) -+ */ -+static int netcam_open_codec(int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type){ -+ int ret; -+ char errstr[128]; -+ AVStream *st; -+ AVCodecContext *dec_ctx = NULL; -+ AVCodec *dec = NULL; -+ -+ ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0); -+ if (ret < 0) { -+ av_strerror(ret, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Could not find stream in input!: %s",errstr); -+ return ret; -+ } -+ -+ *stream_idx = ret; -+ st = fmt_ctx->streams[*stream_idx]; -+ -+ /* find decoder for the stream */ -+ dec_ctx = st->codec; -+ dec = avcodec_find_decoder(dec_ctx->codec_id); -+ if (dec == NULL) { -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to find codec!"); -+ return -1; -+ } -+ -+ /* Open the codec */ -+ ret = avcodec_open2(dec_ctx, dec, NULL); -+ if (ret < 0) { -+ av_strerror(ret, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+/** -+* rtsp_new_context -+* -+* Create a new RTSP context structure. -+* -+* Parameters -+* -+* None -+* -+* Returns: Pointer to the newly-created structure, NULL if error. -+* -+*/ -+struct rtsp_context *rtsp_new_context(void){ -+ struct rtsp_context *ret; -+ -+ /* Note that mymalloc will exit on any problem. */ -+ ret = mymalloc(sizeof(struct rtsp_context)); -+ -+ memset(ret, 0, sizeof(struct rtsp_context)); -+ -+ return ret; -+} -+/** -+* netcam_interrupt_rtsp -+* -+* This function is called during the FFmpeg blocking functions. -+* These include the opening of the format context as well as the -+* reading of the packets from the stream. Since this is called -+* during all blocking functions, the process uses the readingframe -+* flag to determine whether to timeout the process. -+* -+* Parameters -+* -+* ctx We pass in the rtsp context to use it to look for the -+* readingframe flag as well as the time that we started -+* the read attempt. -+* -+* Returns: -+* Failure -1(which triggers an interupt) -+* Success 0(zero which indicates to let process continue) -+* -+*/ -+static int netcam_interrupt_rtsp(void *ctx){ -+ struct rtsp_context *rtsp = (struct rtsp_context *)ctx; -+ -+ if (rtsp->readingframe != 1) { -+ return 0; -+ } else { -+ struct timeval interrupttime; -+ if (gettimeofday(&interrupttime, NULL) < 0) { -+ MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time failed"); -+ } -+ if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){ -+ MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Reading picture timed out for %s",rtsp->path); -+ return 1; -+ } else{ -+ return 0; -+ } -+ } -+ -+ //should not be possible to get here -+ return 0; -+} -+/** -+* netcam_read_rtsp_image -+* -+* This function reads the packet from the camera. -+* It is called extensively so only absolutely essential -+* functions and allocations are performed. -+* -+* Parameters -+* -+* netcam The netcam context to read from -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_read_rtsp_image(netcam_context_ptr netcam){ -+ struct timeval curtime; -+ netcam_buff_ptr buffer; -+ AVPacket packet; -+ int size_decoded; -+ -+ /* Point to our working buffer. */ -+ buffer = netcam->receiving; -+ buffer->used = 0; -+ -+ av_init_packet(&packet); -+ packet.data = NULL; -+ packet.size = 0; -+ -+ size_decoded = 0; -+ -+ if (gettimeofday(&curtime, NULL) < 0) { -+ MOTION_LOG(ERR, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); -+ } -+ netcam->rtsp->startreadtime = curtime; -+ -+ netcam->rtsp->readingframe = 1; -+ while (size_decoded == 0 && av_read_frame(netcam->rtsp->format_context, &packet) >= 0) { -+ if(packet.stream_index != netcam->rtsp->video_stream_index) { -+ av_free_packet(&packet); -+ av_init_packet(&packet); -+ packet.data = NULL; -+ packet.size = 0; -+ // not our packet, skip -+ continue; -+ } -+ size_decoded = decode_packet(&packet, buffer, netcam->rtsp->frame, netcam->rtsp->codec_context); -+ -+ av_free_packet(&packet); -+ av_init_packet(&packet); -+ packet.data = NULL; -+ packet.size = 0; -+ } -+ netcam->rtsp->readingframe = 0; -+ -+ // at this point, we are finished with the packet -+ av_free_packet(&packet); -+ -+ if (size_decoded == 0) { -+ // something went wrong, end of stream? Interupted? -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ /* -+ * read is complete - set the current 'receiving' buffer atomically -+ * as 'latest', and make the buffer previously in 'latest' become -+ * the new 'receiving' and signal pic_ready. -+ */ -+ netcam->receiving->image_time = curtime; -+ netcam->last_image = curtime; -+ netcam_buff *xchg; -+ -+ pthread_mutex_lock(&netcam->mutex); -+ xchg = netcam->latest; -+ netcam->latest = netcam->receiving; -+ netcam->receiving = xchg; -+ netcam->imgcnt++; -+ pthread_cond_signal(&netcam->pic_ready); -+ pthread_mutex_unlock(&netcam->mutex); -+ -+ return 0; -+} -+/** -+* netcam_rtsp_resize_ntc -+* -+* This function notifies the user of the need to transcode -+* the netcam image which uses a lot of CPU resources -+* -+* Parameters -+* -+* netcam The netcam context to read from -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_rtsp_resize_ntc(netcam_context_ptr netcam){ -+ -+ if ((netcam->width != netcam->rtsp->codec_context->width) || -+ (netcam->height != netcam->rtsp->codec_context->height) || -+ (netcam_check_pixfmt(netcam) != 0) ){ -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: "); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: ****************************************************************"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: The network camera is sending pictures in a different"); -+ if ((netcam->width != netcam->rtsp->codec_context->width) || -+ (netcam->height != netcam->rtsp->codec_context->height)) { -+ if (netcam_check_pixfmt(netcam) != 0) { -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: size than specified in the config and also a "); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: different picture format. The picture is being"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: transcoded to YUV420P and into the size requested"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: in the config file. If possible change netcam to"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: be in YUV420P format and the size requested in the"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: config to possibly lower CPU usage."); -+ } else { -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: size than specified in the configuration file."); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: The picture is being transcoded into the size "); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: requested in the configuration. If possible change"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: netcam or configuration to indicate the same size"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: to possibly lower CPU usage."); -+ } -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Netcam: %d x %d => Config: %d x %d" -+ ,netcam->rtsp->codec_context->width,netcam->rtsp->codec_context->height -+ ,netcam->width,netcam->height); -+ } else { -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: format than YUV420P. The image sent is being "); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: trancoded to YUV420P. If possible change netcam "); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: picture format to YUV420P to possibly lower CPU usage."); -+ } -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: ****************************************************************"); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: "); -+ } -+ -+ return 0; -+ -+} -+/** -+* netcam_rtsp_open_context -+* -+* This function opens the format context for the camera. -+* -+* Parameters -+* -+* netcam The netcam context to read from -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_rtsp_open_context(netcam_context_ptr netcam){ -+ -+ int retcd; -+ char errstr[128]; -+ -+ if (netcam->rtsp->path == NULL) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path); -+ } -+ return -1; -+ } -+ -+ // open the network connection -+ AVDictionary *opts = 0; -+ netcam->rtsp->format_context = avformat_alloc_context(); -+ netcam->rtsp->format_context->interrupt_callback.callback = netcam_interrupt_rtsp; -+ netcam->rtsp->format_context->interrupt_callback.opaque = netcam->rtsp; -+ -+ if (strncmp(netcam->rtsp->path, "http", 4) == 0 ){ -+ netcam->rtsp->format_context->iformat = av_find_input_format("mjpeg"); -+ } else { -+ if (netcam->cnt->conf.rtsp_uses_tcp) { -+ av_dict_set(&opts, "rtsp_transport", "tcp", 0); -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED) -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using tcp transport"); -+ } else { -+ av_dict_set(&opts, "rtsp_transport", "udp", 0); -+ av_dict_set(&opts, "max_delay", "500000", 0); //100000 is the default -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED) -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Using udp transport"); -+ } -+ } -+ -+ retcd = avformat_open_input(&netcam->rtsp->format_context, netcam->rtsp->path, NULL, &opts); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr); -+ } -+ av_dict_free(&opts); -+ //The format context gets freed upon any error from open_input. -+ return retcd; -+ } -+ av_dict_free(&opts); -+ -+ // fill out stream information -+ retcd = avformat_find_stream_info(netcam->rtsp->format_context, NULL); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to find stream info: %s", errstr); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ retcd = netcam_open_codec(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open codec context: %s", errstr); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ netcam->rtsp->codec_context = netcam->rtsp->format_context->streams[netcam->rtsp->video_stream_index]->codec; -+ -+ netcam->rtsp->frame = my_frame_alloc(); -+ if (netcam->rtsp->frame == NULL) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ /* -+ * Validate that the previous steps opened the camera -+ */ -+ retcd = netcam_read_rtsp_image(netcam); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to read first image"); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ return 0; -+ -+} -+/** -+* netcam_rtsp_open_sws -+* -+* This function opens the rescaling context components. -+* -+* Parameters -+* -+* netcam The netcam context to read from -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_rtsp_open_sws(netcam_context_ptr netcam){ -+ -+ netcam->width = ((netcam->cnt->conf.width / 8) * 8); -+ netcam->height = ((netcam->cnt->conf.height / 8) * 8); -+ -+ -+ netcam->rtsp->swsframe_in = my_frame_alloc(); -+ if (netcam->rtsp->swsframe_in == NULL) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ netcam->rtsp->swsframe_out = my_frame_alloc(); -+ if (netcam->rtsp->swsframe_out == NULL) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate frame. Fatal error. Check FFmpeg/Libav configuration"); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ /* -+ * The scaling context is used to change dimensions to config file and -+ * also if the format sent by the camera is not YUV420. -+ */ -+ netcam->rtsp->swsctx = sws_getContext( -+ netcam->rtsp->codec_context->width -+ ,netcam->rtsp->codec_context->height -+ ,netcam->rtsp->codec_context->pix_fmt -+ ,netcam->width -+ ,netcam->height -+ ,PIX_FMT_YUV420P -+ ,SWS_BICUBIC,NULL,NULL,NULL); -+ if (netcam->rtsp->swsctx == NULL) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to allocate scaling context. Fatal error. Check FFmpeg/Libav configuration"); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ netcam->rtsp->swsframe_size = avpicture_get_size( -+ PIX_FMT_YUV420P -+ ,netcam->width -+ ,netcam->height); -+ if (netcam->rtsp->swsframe_size <= 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error determining size of frame out"); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ return 0; -+ -+} -+/** -+* netcam_rtsp_resize -+* -+* This function reencodes the image to yuv420p with the desired size -+* -+* Parameters -+* -+* netcam The netcam context to read from -+* image The destination image. -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ -+ -+ int retcd; -+ char errstr[128]; -+ uint8_t *buffer_out; -+ -+ retcd = avpicture_fill( -+ (AVPicture*)netcam->rtsp->swsframe_in -+ ,(uint8_t*)netcam->latest->ptr -+ ,netcam->rtsp->codec_context->pix_fmt -+ ,netcam->rtsp->codec_context->width -+ ,netcam->rtsp->codec_context->height); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error allocating picture in: %s", errstr); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ -+ buffer_out=(uint8_t *)av_malloc(netcam->rtsp->swsframe_size*sizeof(uint8_t)); -+ -+ retcd = avpicture_fill( -+ (AVPicture*)netcam->rtsp->swsframe_out -+ ,buffer_out -+ ,PIX_FMT_YUV420P -+ ,netcam->width -+ ,netcam->height); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error allocating picture out: %s", errstr); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ retcd = sws_scale( -+ netcam->rtsp->swsctx -+ ,(const uint8_t* const *)netcam->rtsp->swsframe_in->data -+ ,netcam->rtsp->swsframe_in->linesize -+ ,0 -+ ,netcam->rtsp->codec_context->height -+ ,netcam->rtsp->swsframe_out->data -+ ,netcam->rtsp->swsframe_out->linesize); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error resizing/reformatting: %s", errstr); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ retcd = avpicture_layout( -+ (const AVPicture*)netcam->rtsp->swsframe_out -+ ,PIX_FMT_YUV420P -+ ,netcam->width -+ ,netcam->height -+ ,(unsigned char *)image -+ ,netcam->rtsp->swsframe_size ); -+ if (retcd < 0) { -+ if (netcam->rtsp->status == RTSP_NOTCONNECTED){ -+ av_strerror(retcd, errstr, sizeof(errstr)); -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Error putting frame into output buffer: %s", errstr); -+ } -+ netcam_rtsp_close_context(netcam); -+ return -1; -+ } -+ -+ av_free(buffer_out); -+ -+ return 0; -+ -+} -+/********************************************************* -+ * This ends the section of functions that rely upon FFmpeg -+ ***********************************************************/ -+#endif /* End HAVE_FFMPEG */ -+ -+/** -+* netcam_connect_rtsp -+* -+* This function initiates the connection to the rtsp camera. -+* -+* Parameters -+* -+* netcam The netcam context to open. -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_connect_rtsp(netcam_context_ptr netcam){ -+#ifdef HAVE_FFMPEG -+ -+ if (netcam_rtsp_open_context(netcam) < 0) return -1; -+ -+ if (netcam_rtsp_open_sws(netcam) < 0) return -1; -+ -+ if (netcam_rtsp_resize_ntc(netcam) < 0 ) return -1; -+ -+ if (netcam_read_rtsp_image(netcam) < 0) return -1; -+ -+ netcam->rtsp->status = RTSP_CONNECTED; -+ -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO, "%s: Camera connected"); -+ -+ return 0; -+ -+#else /* No FFmpeg/Libav */ -+ netcam->rtsp->status = RTSP_NOTCONNECTED; -+ netcam->rtsp->format_context = NULL; -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); -+ return -1; -+#endif /* End #ifdef HAVE_FFMPEG */ -+} -+ -+/** -+* netcam_shutdown_rtsp -+* -+* This function closes and frees all the items for rtsp -+* -+* Parameters -+* -+* netcam The netcam context to free. -+* -+* Returns: -+* Failure nothing -+* Success nothing -+* -+*/ -+void netcam_shutdown_rtsp(netcam_context_ptr netcam){ -+#ifdef HAVE_FFMPEG -+ -+ if (netcam->rtsp->status == RTSP_CONNECTED) { -+ netcam_rtsp_close_context(netcam); -+ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: netcam shut down"); -+ } -+ -+ if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); -+ if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); -+ if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); -+ -+ free(netcam->rtsp); -+ netcam->rtsp = NULL; -+ -+#else /* No FFmpeg/Libav */ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); -+#endif /* End #ifdef HAVE_FFMPEG */ -+} -+ -+/** -+* netcam_setup_rtsp -+* -+* This function sets up all the necessary items for the -+* rtsp camera. -+* -+* Parameters -+* -+* netcam The netcam context to free. -+* url The URL of the camera -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ -+#ifdef HAVE_FFMPEG -+ -+ struct context *cnt = netcam->cnt; -+ const char *ptr; -+ int ret = -1; -+ -+ netcam->caps.streaming = NCS_RTSP; -+ -+ netcam->rtsp = rtsp_new_context(); -+ -+ netcam_rtsp_null_context(netcam); -+ -+ if (netcam->rtsp == NULL) { -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to create rtsp context"); -+ netcam_shutdown_rtsp(netcam); -+ return -1; -+ } -+ -+ /* -+ * Allocate space for a working string to contain the path. -+ * The extra 5 is for "://", ":" and string terminator. -+ */ -+ -+ // force port to a sane value -+ if (netcam->connect_port > 65536) { -+ netcam->connect_port = 65536; -+ } else if (netcam->connect_port < 0) { -+ netcam->connect_port = 0; -+ } -+ -+ if (cnt->conf.netcam_userpass != NULL) { -+ ptr = cnt->conf.netcam_userpass; -+ } else { -+ ptr = url->userpass; /* Don't set this one NULL, gets freed. */ -+ } -+ -+ if (ptr != NULL) { -+ char *cptr; -+ if ((cptr = strchr(ptr, ':')) == NULL) { -+ netcam->rtsp->user = mystrdup(ptr); -+ } else { -+ netcam->rtsp->user = mymalloc((cptr - ptr)+2); //+2 for string terminator -+ memcpy(netcam->rtsp->user, ptr,(cptr - ptr)); -+ netcam->rtsp->pass = mystrdup(cptr + 1); -+ } -+ } -+ -+ /* -+ * Need a method to query the path and -+ * determine the authentication type -+ */ -+ if ((netcam->rtsp->user != NULL) && (netcam->rtsp->pass != NULL)) { -+ ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) -+ + 5 + strlen(url->path) + 5 -+ + strlen(netcam->rtsp->user) + strlen(netcam->rtsp->pass) + 4 ); -+ sprintf((char *)ptr, "%s://%s:%s@%s:%d%s", -+ url->service,netcam->rtsp->user,netcam->rtsp->pass, -+ netcam->connect_host, netcam->connect_port, url->path); -+ } -+ else { -+ ptr = mymalloc(strlen(url->service) + strlen(netcam->connect_host) -+ + 5 + strlen(url->path) + 5); -+ sprintf((char *)ptr, "%s://%s:%d%s", url->service, -+ netcam->connect_host, netcam->connect_port, url->path); -+ } -+ netcam->rtsp->path = (char *)ptr; -+ -+ netcam_url_free(url); -+ -+ /* -+ * Now we need to set some flags -+ */ -+ netcam->rtsp->readingframe = 0; -+ netcam->rtsp->status = RTSP_NOTCONNECTED; -+ -+ /* -+ * Warn and fix dimensions as needed. -+ */ -+ if (netcam->cnt->conf.width % 16) { -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image width (%d) requested is not modulo 16.", netcam->cnt->conf.width); -+ netcam->cnt->conf.width = netcam->cnt->conf.width - (netcam->cnt->conf.width % 16) + 16; -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting width to next higher multiple of 16 (%d).", netcam->cnt->conf.width); -+ } -+ if (netcam->cnt->conf.height % 16) { -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image height (%d) requested is not modulo 16.", netcam->cnt->conf.height); -+ netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 16) + 16; -+ MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 16 (%d).", netcam->cnt->conf.height); -+ } -+ -+ av_register_all(); -+ avformat_network_init(); -+ avcodec_register_all(); -+ -+ /* -+ * The RTSP context should be all ready to attempt a connection with -+ * the server, so we try .... -+ */ -+ ret = netcam_connect_rtsp(netcam); -+ if (ret < 0){ -+ return ret; -+ } -+ -+ netcam->get_image = netcam_read_rtsp_image; -+ -+ return 0; -+ -+#else /* No FFmpeg/Libav */ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); -+ return -1; -+#endif /* End #ifdef HAVE_FFMPEG */ -+} -+ -+/** -+* netcam_next_rtsp -+* -+* This function moves the picture to the image buffer. -+* If the picture is not in the correct format for size -+* it will put it into the requested format -+* -+* Parameters -+* -+* netcam The netcam context to free. -+* url The URL of the camera -+* -+* Returns: -+* Failure -1 -+* Success 0(zero) -+* -+*/ -+int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam){ -+#ifdef HAVE_FFMPEG -+ -+ if ((netcam->width != netcam->rtsp->codec_context->width) || -+ (netcam->height != netcam->rtsp->codec_context->height) || -+ (netcam_check_pixfmt(netcam) != 0) ){ -+ netcam_rtsp_resize(image ,netcam); -+ } else { -+ memcpy(image, netcam->latest->ptr, netcam->latest->used); -+ } -+ if (netcam->cnt->rotate_data.degrees > 0) -+ /* Rotate as specified */ -+ rotate_map(netcam->cnt, image); -+ -+ return 0; -+#else /* No FFmpeg/Libav */ -+ MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: FFmpeg/Libav not found on computer. No RTSP support"); -+ return -1; -+#endif /* End #ifdef HAVE_FFMPEG */ -+} ---- /dev/null -+++ motion-3.2.12/netcam_rtsp.h -@@ -0,0 +1,43 @@ -+#include "netcam.h" -+ -+#ifdef HAVE_FFMPEG -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#endif /* end HAVE_FFMPEG */ -+ -+struct rtsp_context { -+#ifdef HAVE_FFMPEG -+ AVFormatContext* format_context; -+ AVCodecContext* codec_context; -+ AVFrame* frame; -+ AVFrame* swsframe_in; -+ AVFrame* swsframe_out; -+ int swsframe_size; -+ int video_stream_index; -+ char* path; -+ char* user; -+ char* pass; -+ int readingframe; -+ int status; -+ struct timeval startreadtime; -+ struct SwsContext* swsctx; -+ -+#else /* Do not have FFmpeg */ -+ int* format_context; -+ int readingframe; -+ int status; -+#endif /* end HAVE_FFMPEG */ -+}; -+ -+struct rtsp_context *rtsp_new_context(void); -+void netcam_shutdown_rtsp(netcam_context_ptr netcam); -+int netcam_connect_rtsp(netcam_context_ptr netcam); -+int netcam_read_rtsp_image(netcam_context_ptr netcam); -+int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); -+int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam); ---- motion-3.2.12.orig/netcam_wget.c -+++ motion-3.2.12/netcam_wget.c -@@ -63,14 +63,15 @@ Foundation, Inc., 675 Mass Ave, Cambridg - `:', thus you can use it to retrieve, say, HTTP status line. - - All trailing whitespace is stripped from the header, and it is -- zero-terminated. */ -- -+ zero-terminated. -+ */ - int header_get(netcam_context_ptr netcam, char **hdr, enum header_get_flags flags) - { - int i; - int bufsize = 80; - - *hdr = (char *)mymalloc(bufsize); -+ - for (i = 0; 1; i++) { - int res; - /* #### Use DO_REALLOC? */ -@@ -84,9 +85,11 @@ int header_get(netcam_context_ptr netcam - if (!((flags & HG_NO_CONTINUATIONS) || i == 0 - || (i == 1 && (*hdr)[0] == '\r'))) { - char next; -- /* If the header is non-empty, we need to check if -- it continues on to the other line. We do that by -- peeking at the next character. */ -+ /* -+ * If the header is non-empty, we need to check if -+ * it continues on to the other line. We do that by -+ * peeking at the next character. -+ */ - res = rbuf_peek(netcam, &next); - - if (res == 0) { -@@ -96,24 +99,23 @@ int header_get(netcam_context_ptr netcam - (*hdr)[i] = '\0'; - return HG_ERROR; - } -- /* If the next character is HT or SP, just continue. */ -- -+ /* If the next character is HT or SP, just continue. */ - if (next == '\t' || next == ' ') - continue; - } - -- /* Strip trailing whitespace. (*hdr)[i] is the newline; -- decrement I until it points to the last available -- whitespace. */ -+ /* -+ * Strip trailing whitespace. (*hdr)[i] is the newline; -+ * decrement I until it points to the last available -+ * whitespace. -+ */ - while (i > 0 && isspace((*hdr)[i - 1])) - --i; - - (*hdr)[i] = '\0'; - break; - } -- - } else if (res == 0) { -- - (*hdr)[i] = '\0'; - return HG_EOF; - } else { -@@ -125,14 +127,17 @@ int header_get(netcam_context_ptr netcam - return HG_OK; - } - --/* Check whether HEADER begins with NAME and, if yes, skip the `:' and -- the whitespace, and call PROCFUN with the arguments of HEADER's -- contents (after the `:' and space) and ARG. Otherwise, return 0. */ --int header_process (const char *header, const char *name, -- int (*procfun)(const char *, void *), -- void *arg) -+/** -+ * header_process -+ * -+ * Check whether HEADER begins with NAME and, if yes, skip the `:' and -+ * the whitespace, and call PROCFUN with the arguments of HEADER's -+ * contents (after the `:' and space) and ARG. Otherwise, return 0. -+ */ -+int header_process(const char *header, const char *name, -+ int (*procfun)(const char *, void *), void *arg) - { -- /* Check whether HEADER matches NAME. */ -+ /* Check whether HEADER matches NAME. */ - while (*name && (tolower (*name) == tolower (*header))) - ++name, ++header; - -@@ -143,10 +148,14 @@ int header_process (const char *header, - return ((*procfun) (header, arg)); - } - --/* Helper functions for use with header_process(). */ -+/* Helper functions for use with header_process(). */ - --/* Extract a long integer from HEADER and store it to CLOSURE. If an -- error is encountered, return 0, else 1. */ -+/** -+ * header_extract_number -+ * -+ * Extract a long integer from HEADER and store it to CLOSURE. If an -+ * error is encountered, return 0, else 1. -+ */ - int header_extract_number(const char *header, void *closure) - { - const char *p = header; -@@ -162,7 +171,7 @@ int header_extract_number(const char *he - /* Skip trailing whitespace. */ - p += skip_lws (p); - -- /* We return the value, even if a format error follows */ -+ /* We return the value, even if a format error follows. */ - *(long *)closure = result; - - /* Indicate failure if trailing garbage is present. */ -@@ -172,16 +181,23 @@ int header_extract_number(const char *he - return 1; - } - --/* Strdup HEADER, and place the pointer to CLOSURE. */ -+/** -+ * header_strdup -+ * -+ * Strdup HEADER, and place the pointer to CLOSURE. -+ */ - int header_strdup(const char *header, void *closure) - { -- *(char **)closure = strdup(header); -+ *(char **)closure = mystrdup(header); - return 1; - } - - --/* Skip LWS (linear white space), if present. Returns number of -- characters to skip. */ -+/** -+ * skip_lws -+ * Skip LWS (linear white space), if present. Returns number of -+ * characters to skip. -+ */ - int skip_lws(const char *string) - { - const char *p = string; -@@ -193,11 +209,13 @@ int skip_lws(const char *string) - } - - --/* -- Encode the string S of length LENGTH to base64 format and place it -- to STORE. STORE will be 0-terminated, and must point to a writable -- buffer of at least 1+BASE64_LENGTH(length) bytes. --*/ -+/** -+ * base64_encode -+ * -+ * Encode the string S of length LENGTH to base64 format and place it -+ * to STORE. STORE will be 0-terminated, and must point to a writable -+ * buffer of at least 1+BASE64_LENGTH(length) bytes. -+ */ - void base64_encode(const char *s, char *store, int length) - { - /* Conversion table. */ -@@ -215,7 +233,7 @@ void base64_encode(const char *s, char * - int i; - unsigned char *p = (unsigned char *)store; - -- /* Transform the 3x8 bits to 4x6 bits, as required by base64. */ -+ /* Transform the 3x8 bits to 4x6 bits, as required by base64. */ - for (i = 0; i < length; i += 3) { - *p++ = tbl[s[0] >> 2]; - *p++ = tbl[((s[0] & 3) << 4) + (s[1] >> 4)]; -@@ -224,7 +242,7 @@ void base64_encode(const char *s, char * - s += 3; - } - -- /* Pad the result if necessary... */ -+ /* Pad the result if necessary... */ - if (i == length + 1) - *(p - 1) = '='; - else if (i == length + 2) -@@ -234,6 +252,9 @@ void base64_encode(const char *s, char * - *p = '\0'; - } - -+/** -+ * strdupdelim -+ */ - char *strdupdelim(const char *beg, const char *end) - { - char *res = (char *)mymalloc(end - beg + 1); -@@ -243,6 +264,9 @@ char *strdupdelim(const char *beg, const - return res; - } - -+/** -+ * http_process_type -+ */ - int http_process_type(const char *hdr, void *arg) - { - char **result = (char **)arg; -@@ -259,8 +283,11 @@ int http_process_type(const char *hdr, v - return 1; - } - --/* This is a simple implementation of buffering IO-read functions. */ -- -+/** -+ * rbuf_initialize -+ * -+ * This is a simple implementation of buffering IO-read functions. -+ */ - void rbuf_initialize(netcam_context_ptr netcam) - { - netcam->response->buffer_pos = netcam->response->buffer; -@@ -273,7 +300,11 @@ int rbuf_read_bufferful(netcam_context_p - sizeof (netcam->response->buffer)); - } - --/* Like rbuf_readchar(), only don't move the buffer position. */ -+/** -+ * rbuf_peek -+ * -+ * Like rbuf_readchar(), only don't move the buffer position. -+ */ - int rbuf_peek(netcam_context_ptr netcam, char *store) - { - if (!netcam->response->buffer_left) { -@@ -282,8 +313,10 @@ int rbuf_peek(netcam_context_ptr netcam, - res = netcam_recv (netcam, netcam->response->buffer, - sizeof (netcam->response->buffer)); - -- if (res <= 0) -+ if (res <= 0) { -+ *store = '\0'; - return res; -+ } - - netcam->response->buffer_left = res; - } -@@ -292,11 +325,13 @@ int rbuf_peek(netcam_context_ptr netcam, - return 1; - } - --/* -- Flush RBUF's buffer to WHERE. Flush MAXSIZE bytes at most. -- Returns the number of bytes actually copied. If the buffer is -- empty, 0 is returned. --*/ -+/** -+ * rbuf_flush -+ * -+ * Flush RBUF's buffer to WHERE. Flush MAXSIZE bytes at most. -+ * Returns the number of bytes actually copied. If the buffer is -+ * empty, 0 is returned. -+ */ - int rbuf_flush(netcam_context_ptr netcam, char *where, int maxsize) - { - if (!netcam->response->buffer_left) { -@@ -313,16 +348,20 @@ int rbuf_flush(netcam_context_ptr netcam - } - } - --/* Get the HTTP result code */ -+/** -+ * http_result_code -+ * -+ * Get the HTTP result code -+ */ - int http_result_code(const char *header) - { - char *cptr; - -- /* assure the header starts out right */ -+ /* Assure the header starts out right. */ - if (strncmp(header, "HTTP", 4)) - return -1; - -- /* find the space following the HTTP/1.x */ -+ /* Find the space following the HTTP/1.x */ - if ((cptr = strchr(header+4, ' ')) == NULL) - return -1; - ---- motion-3.2.12.orig/netcam_wget.h -+++ motion-3.2.12/netcam_wget.h -@@ -76,15 +76,15 @@ void base64_encode(const char *, char *, - char *strdupdelim(const char *, const char *); - int http_process_type(const char *, void *); - --enum { -+enum { - HG_OK, - HG_ERROR, - HG_EOF - }; - --enum header_get_flags { -+enum header_get_flags{ - HG_NONE = 0, -- HG_NO_CONTINUATIONS = 0x2 -+ HG_NO_CONTINUATIONS = 0x2 - }; - - int header_get (netcam_context_ptr, char **, enum header_get_flags); ---- motion-3.2.12.orig/picture.c -+++ motion-3.2.12/picture.c -@@ -3,6 +3,7 @@ - * Various funtions for saving/loading pictures. - * Copyright 2002 by Jeroen Vreeken (pe1rxq@amsat.org) - * Portions of this file are Copyright by Lionnel Maugis -+ * Portions of this file are Copyright 2010 by Wim Lewis (wiml@hhhh.org) - * This software is distributed under the GNU public license version 2 - * See also the file 'COPYING'. - * -@@ -11,12 +12,15 @@ - #include "picture.h" - #include "event.h" - -+#include -+ - #undef HAVE_STDLIB_H - #include - #include - --/* The following declarations and 5 functions are jpeg related -- * functions used by put_jpeg_grey_memory and put_jpeg_yuv420p_memory -+/* -+ * The following declarations and 5 functions are jpeg related -+ * functions used by put_jpeg_grey_memory and put_jpeg_yuv420p_memory. - */ - typedef struct { - struct jpeg_destination_mgr pub; -@@ -59,7 +63,7 @@ static GLOBAL(void) _jpeg_mem_dest(j_com - if (cinfo->dest == NULL) { - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_PERMANENT, -- sizeof(mem_destination_mgr)); -+ sizeof(mem_destination_mgr)); - } - - dest = (mem_dest_ptr) cinfo->dest; -@@ -79,20 +83,340 @@ static GLOBAL(int) _jpeg_mem_size(j_comp - return dest->jpegsize; - } - -+/* EXIF image data is always in TIFF format, even if embedded in another -+ * file type. This consists of a constant header (TIFF file header, -+ * IFD header) followed by the tags in the IFD and then the data -+ * from any tags which do not fit inline in the IFD. -+ * -+ * The tags we write in the main IFD are: -+ * 0x010E Image description -+ * 0x8769 Exif sub-IFD -+ * 0x882A Time zone of time stamps -+ * and in the Exif sub-IFD: -+ * 0x9000 Exif version -+ * 0x9003 File date and time -+ * 0x9291 File date and time subsecond info -+ * But we omit any empty IFDs. -+ */ -+ -+#define TIFF_TAG_IMAGE_DESCRIPTION 0x010E -+#define TIFF_TAG_DATETIME 0x0132 -+#define TIFF_TAG_EXIF_IFD 0x8769 -+#define TIFF_TAG_TZ_OFFSET 0x882A -+ -+#define EXIF_TAG_EXIF_VERSION 0x9000 -+#define EXIF_TAG_ORIGINAL_DATETIME 0x9003 -+#define EXIF_TAG_SUBJECT_AREA 0x9214 -+#define EXIF_TAG_TIFF_DATETIME_SS 0x9290 -+#define EXIF_TAG_ORIGINAL_DATETIME_SS 0x9291 -+ -+#define TIFF_TYPE_ASCII 2 /* ASCII text */ -+#define TIFF_TYPE_USHORT 3 /* Unsigned 16-bit int */ -+#define TIFF_TYPE_LONG 4 /* Unsigned 32-bit int */ -+#define TIFF_TYPE_UNDEF 7 /* Byte blob */ -+#define TIFF_TYPE_SSHORT 8 /* Signed 16-bit int */ -+ -+static const char exif_marker_start[14] = { -+ 'E', 'x', 'i', 'f', 0, 0, /* EXIF marker signature */ -+ 'M', 'M', 0, 42, /* TIFF file header (big-endian) */ -+ 0, 0, 0, 8, /* Offset to first toplevel IFD */ -+}; -+ -+static const char exif_version_tag[12] = { -+ 0x90, 0x00, /* EXIF version tag, 0x9000 */ -+ 0x00, 0x07, /* Data type 7 = "unknown" (raw byte blob) */ -+ 0x00, 0x00, 0x00, 0x04, /* Data length */ -+ 0x30, 0x32, 0x32, 0x30 /* Inline data, EXIF version 2.2 */ -+}; -+ -+static const char exif_subifd_tag[8] = { -+ 0x87, 0x69, /* EXIF Sub-IFD tag */ -+ 0x00, 0x04, /* Data type 4 = uint32 */ -+ 0x00, 0x00, 0x00, 0x01, /* Number of values */ -+}; -+ -+static const char exif_tzoffset_tag[12] = { -+ 0x88, 0x2A, /* TIFF/EP time zone offset tag */ -+ 0x00, 0x08, /* Data type 8 = sint16 */ -+ 0x00, 0x00, 0x00, 0x01, /* Number of values */ -+ 0, 0, 0, 0 /* Dummy data */ -+}; -+ -+static void put_uint16(JOCTET *buf, unsigned value) -+{ -+ buf[0] = ( value & 0xFF00 ) >> 8; -+ buf[1] = ( value & 0x00FF ); -+} -+ -+static void put_sint16(JOCTET *buf, int value) -+{ -+ buf[0] = ( value & 0xFF00 ) >> 8; -+ buf[1] = ( value & 0x00FF ); -+} -+ -+static void put_uint32(JOCTET *buf, unsigned value) -+{ -+ buf[0] = ( value & 0xFF000000 ) >> 24; -+ buf[1] = ( value & 0x00FF0000 ) >> 16; -+ buf[2] = ( value & 0x0000FF00 ) >> 8; -+ buf[3] = ( value & 0x000000FF ); -+} -+ -+struct tiff_writing { -+ JOCTET * const base; -+ JOCTET *buf; -+ unsigned data_offset; -+}; -+ -+static void put_direntry(struct tiff_writing *into, const char *data, unsigned length) -+{ -+ if (length <= 4) { -+ /* Entries that fit in the directory entry are stored there */ -+ memset(into->buf, 0, 4); -+ memcpy(into->buf, data, length); -+ } else { -+ /* Longer entries are stored out-of-line */ -+ unsigned offset = into->data_offset; -+ -+ while ((offset & 0x03) != 0) { /* Alignment */ -+ into->base[offset] = 0; -+ offset ++; -+ } -+ -+ put_uint32(into->buf, offset); -+ memcpy(into->base + offset, data, length); -+ into->data_offset = offset + length; -+ } -+} -+ -+static void put_stringentry(struct tiff_writing *into, unsigned tag, const char *str, int with_nul) -+{ -+ unsigned stringlength = strlen(str) + (with_nul?1:0); -+ -+ put_uint16(into->buf, tag); -+ put_uint16(into->buf + 2, TIFF_TYPE_ASCII); -+ put_uint32(into->buf + 4, stringlength); -+ into->buf += 8; -+ put_direntry(into, str, stringlength); -+ into->buf += 4; -+} -+ -+static void put_subjectarea(struct tiff_writing *into, const struct coord *box) -+{ -+ put_uint16(into->buf , EXIF_TAG_SUBJECT_AREA); -+ put_uint16(into->buf + 2, TIFF_TYPE_USHORT); -+ put_uint32(into->buf + 4, 4 /* Four USHORTs */); -+ put_uint32(into->buf + 8, into->data_offset); -+ into->buf += 12; -+ JOCTET *ool = into->base + into->data_offset; -+ put_uint16(ool , box->x); /* Center.x */ -+ put_uint16(ool+2, box->y); /* Center.y */ -+ put_uint16(ool+4, box->width); -+ put_uint16(ool+6, box->height); -+ into->data_offset += 8; -+} -+ -+/* -+ * put_jpeg_exif writes the EXIF APP1 chunk to the jpeg file. -+ * It must be called after jpeg_start_compress() but before -+ * any image data is written by jpeg_write_scanlines(). -+ */ -+static void put_jpeg_exif(j_compress_ptr cinfo, -+ const struct context *cnt, -+ const struct tm *timestamp, -+ const struct coord *box) -+{ -+ /* description, datetime, and subtime are the values that are actually -+ * put into the EXIF data -+ */ -+ char *description, *datetime, *subtime; -+ char datetime_buf[22]; -+ -+ if (timestamp) { -+ /* Exif requires this exact format */ -+ snprintf(datetime_buf, 21, "%04d:%02d:%02d %02d:%02d:%02d", -+ timestamp->tm_year + 1900, -+ timestamp->tm_mon + 1, -+ timestamp->tm_mday, -+ timestamp->tm_hour, -+ timestamp->tm_min, -+ timestamp->tm_sec); -+ datetime = datetime_buf; -+ } else { -+ datetime = NULL; -+ } -+ -+ // TODO: Extract subsecond timestamp from somewhere, but only -+ // use as much of it as is indicated by conf->frame_limit -+ subtime = NULL; -+ -+ if (cnt->conf.exif_text) { -+ description = malloc(PATH_MAX); -+ mystrftime(cnt, description, PATH_MAX-1, -+ cnt->conf.exif_text, -+ timestamp, NULL, 0); -+ } else { -+ description = NULL; -+ } -+ -+ /* Calculate an upper bound on the size of the APP1 marker so -+ * we can allocate a buffer for it. -+ */ -+ -+ /* Count up the number of tags and max amount of OOL data */ -+ int ifd0_tagcount = 0; -+ int ifd1_tagcount = 0; -+ unsigned datasize = 0; -+ -+ if (description) { -+ ifd0_tagcount ++; -+ datasize += 5 + strlen(description); /* Add 5 for NUL and alignment */ -+ } -+ -+ if (datetime) { -+ /* We write this to both the TIFF datetime tag (which most programs -+ * treat as "last-modified-date") and the EXIF "time of creation of -+ * original image" tag (which many programs ignore). This is -+ * redundant but seems to be the thing to do. -+ */ -+ ifd0_tagcount++; -+ ifd1_tagcount++; -+ /* We also write the timezone-offset tag in IFD0 */ -+ ifd0_tagcount++; -+ /* It would be nice to use the same offset for both tags' values, -+ * but I don't want to write the bookkeeping for that right now */ -+ datasize += 2 * (5 + strlen(datetime)); -+ } -+ -+ if (subtime) { -+ ifd1_tagcount++; -+ datasize += 5 + strlen(subtime); -+ } -+ -+ if (box) { -+ ifd1_tagcount++; -+ datasize += 2 * 4; /* Four 16-bit ints */ -+ } -+ -+ if (ifd1_tagcount > 0) { -+ /* If we're writing the Exif sub-IFD, account for the -+ * two tags that requires */ -+ ifd0_tagcount ++; /* The tag in IFD0 that points to IFD1 */ -+ ifd1_tagcount ++; /* The EXIF version tag */ -+ } -+ -+ /* Each IFD takes 12 bytes per tag, plus six more (the tag count and the -+ * pointer to the next IFD, always zero in our case) -+ */ -+ unsigned int ifds_size = -+ ( ifd1_tagcount > 0 ? ( 12 * ifd1_tagcount + 6 ) : 0 ) + -+ ( ifd0_tagcount > 0 ? ( 12 * ifd0_tagcount + 6 ) : 0 ); -+ -+ if (ifds_size == 0) { -+ /* We're not actually going to write any information. */ -+ return; -+ } -+ -+ unsigned int buffer_size = 6 /* EXIF marker signature */ + -+ 8 /* TIFF file header */ + -+ ifds_size /* the tag directories */ + -+ datasize; -+ -+ JOCTET *marker = malloc(buffer_size); -+ memcpy(marker, exif_marker_start, 14); /* EXIF and TIFF headers */ -+ -+ struct tiff_writing writing = (struct tiff_writing) { -+ .base = marker + 6, /* base address for intra-TIFF offsets */ -+ .buf = marker + 14, /* current write position */ -+ .data_offset = 8 + ifds_size, /* where to start storing data */ -+ }; -+ -+ /* Write IFD 0 */ -+ /* Note that tags are stored in numerical order */ -+ put_uint16(writing.buf, ifd0_tagcount); -+ writing.buf += 2; -+ -+ if (description) -+ put_stringentry(&writing, TIFF_TAG_IMAGE_DESCRIPTION, description, 0); -+ -+ if (datetime) -+ put_stringentry(&writing, TIFF_TAG_DATETIME, datetime, 1); -+ -+ if (ifd1_tagcount > 0) { -+ /* Offset of IFD1 - TIFF header + IFD0 size. */ -+ unsigned ifd1_offset = 8 + 6 + ( 12 * ifd0_tagcount ); -+ memcpy(writing.buf, exif_subifd_tag, 8); -+ put_uint32(writing.buf + 8, ifd1_offset); -+ writing.buf += 12; -+ } -+ -+ if (datetime) { -+ memcpy(writing.buf, exif_tzoffset_tag, 12); -+ put_sint16(writing.buf+8, timestamp->tm_gmtoff / 3600); -+ writing.buf += 12; -+ } -+ -+ put_uint32(writing.buf, 0); /* Next IFD offset = 0 (no next IFD) */ -+ writing.buf += 4; -+ -+ /* Write IFD 1 */ -+ if (ifd1_tagcount > 0) { -+ /* (remember that the tags in any IFD must be in numerical order -+ * by tag) */ -+ put_uint16(writing.buf, ifd1_tagcount); -+ memcpy(writing.buf + 2, exif_version_tag, 12); /* tag 0x9000 */ -+ writing.buf += 14; -+ -+ if (datetime) -+ put_stringentry(&writing, EXIF_TAG_ORIGINAL_DATETIME, datetime, 1); -+ -+ if (box) -+ put_subjectarea(&writing, box); -+ -+ if (subtime) -+ put_stringentry(&writing, EXIF_TAG_ORIGINAL_DATETIME_SS, subtime, 0); - --/* put_jpeg_yuv420p_memory converts an input image in the YUV420P format into a jpeg image and puts -- * it in a memory buffer. -+ put_uint32(writing.buf, 0); /* Next IFD = 0 (no next IFD) */ -+ writing.buf += 4; -+ } -+ -+ /* We should have met up with the OOL data */ -+ assert( (writing.buf - writing.base) == 8 + ifds_size ); -+ -+ /* The buffer is complete; write it out */ -+ unsigned marker_len = 6 + writing.data_offset; -+ -+ /* assert we didn't underestimate the original buffer size */ -+ assert(marker_len <= buffer_size); -+ -+ /* EXIF data lives in a JPEG APP1 marker */ -+ jpeg_write_marker(cinfo, JPEG_APP0 + 1, marker, marker_len); -+ -+ if (description) -+ free(description); -+ -+ free(marker); -+} -+ -+/** -+ * put_jpeg_yuv420p_memory -+ * Converts an input image in the YUV420P format into a jpeg image and puts -+ * it in a memory buffer. - * Inputs: - * - image_size is the size of the input image buffer. - * - input_image is the image in YUV420P format. - * - width and height are the dimensions of the image - * - quality is the jpeg encoding quality 0-100% -+ * - * Output: - * - dest_image is a pointer to the jpeg image buffer -- * Returns buffer size of jpeg image -+ * -+ * Returns buffer size of jpeg image - */ - static int put_jpeg_yuv420p_memory(unsigned char *dest_image, int image_size, -- unsigned char *input_image, int width, int height, int quality) -+ unsigned char *input_image, int width, int height, int quality, -+ struct context *cnt, struct tm *tm, struct coord *box) -+ - { - int i, j, jpeg_image_size; - -@@ -106,21 +430,20 @@ static int put_jpeg_yuv420p_memory(unsig - data[1] = cb; - data[2] = cr; - -- cinfo.err = jpeg_std_error(&jerr); // errors get written to stderr -- -+ cinfo.err = jpeg_std_error(&jerr); // Errors get written to stderr -+ - jpeg_create_compress(&cinfo); - cinfo.image_width = width; - cinfo.image_height = height; - cinfo.input_components = 3; -- jpeg_set_defaults (&cinfo); -+ jpeg_set_defaults(&cinfo); - - jpeg_set_colorspace(&cinfo, JCS_YCbCr); - -- cinfo.raw_data_in = TRUE; // supply downsampled data -+ cinfo.raw_data_in = TRUE; // Supply downsampled data - #if JPEG_LIB_VERSION >= 70 --#warning using JPEG_LIB_VERSION >= 70 -- cinfo.do_fancy_downsampling = FALSE; // fix segfaulst with v7 --#endif -+ cinfo.do_fancy_downsampling = FALSE; // Fix segfault with v7 -+#endif - cinfo.comp_info[0].h_samp_factor = 2; - cinfo.comp_info[0].v_samp_factor = 2; - cinfo.comp_info[1].h_samp_factor = 1; -@@ -131,16 +454,19 @@ static int put_jpeg_yuv420p_memory(unsig - jpeg_set_quality(&cinfo, quality, TRUE); - cinfo.dct_method = JDCT_FASTEST; - -- _jpeg_mem_dest(&cinfo, dest_image, image_size); // data written to mem -- -- jpeg_start_compress (&cinfo, TRUE); -+ _jpeg_mem_dest(&cinfo, dest_image, image_size); // Data written to mem -+ -+ jpeg_start_compress(&cinfo, TRUE); -+ -+ put_jpeg_exif(&cinfo, cnt, tm, box); - - for (j = 0; j < height; j += 16) { - for (i = 0; i < 16; i++) { - y[i] = input_image + width * (i + j); -- if (i%2 == 0) { -- cb[i/2] = input_image + width * height + width / 2 * ((i + j) / 2); -- cr[i/2] = input_image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); -+ -+ if (i % 2 == 0) { -+ cb[i / 2] = input_image + width * height + width / 2 * ((i + j) /2); -+ cr[i / 2] = input_image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); - } - } - jpeg_write_raw_data(&cinfo, data, 16); -@@ -149,22 +475,26 @@ static int put_jpeg_yuv420p_memory(unsig - jpeg_finish_compress(&cinfo); - jpeg_image_size = _jpeg_mem_size(&cinfo); - jpeg_destroy_compress(&cinfo); -- -+ - return jpeg_image_size; - } - --/* put_jpeg_grey_memory converts an input image in the grayscale format into a jpeg image -+/** -+ * put_jpeg_grey_memory -+ * Converts an input image in the grayscale format into a jpeg image. -+ * - * Inputs: - * - image_size is the size of the input image buffer. - * - input_image is the image in grayscale format. - * - width and height are the dimensions of the image - * - quality is the jpeg encoding quality 0-100% -+ * - * Output: - * - dest_image is a pointer to the jpeg image buffer -- * Returns buffer size of jpeg image -+ * -+ * Returns buffer size of jpeg image. - */ --static int put_jpeg_grey_memory(unsigned char *dest_image, int image_size, -- unsigned char *input_image, int width, int height, int quality) -+static int put_jpeg_grey_memory(unsigned char *dest_image, int image_size, unsigned char *input_image, int width, int height, int quality) - { - int y, dest_image_size; - JSAMPROW row_ptr[1]; -@@ -175,24 +505,26 @@ static int put_jpeg_grey_memory(unsigned - jpeg_create_compress(&cjpeg); - cjpeg.image_width = width; - cjpeg.image_height = height; -- cjpeg.input_components = 1; /* one colour component */ -+ cjpeg.input_components = 1; /* One colour component */ - cjpeg.in_color_space = JCS_GRAYSCALE; - - jpeg_set_defaults(&cjpeg); - - jpeg_set_quality(&cjpeg, quality, TRUE); - cjpeg.dct_method = JDCT_FASTEST; -- _jpeg_mem_dest(&cjpeg, dest_image, image_size); // data written to mem -+ _jpeg_mem_dest(&cjpeg, dest_image, image_size); // Data written to mem - - jpeg_start_compress (&cjpeg, TRUE); - -+ put_jpeg_exif(&cjpeg, NULL, NULL, NULL); -+ - row_ptr[0] = input_image; -- -+ - for (y = 0; y < height; y++) { - jpeg_write_scanlines(&cjpeg, row_ptr, 1); - row_ptr[0] += width; - } -- -+ - jpeg_finish_compress(&cjpeg); - dest_image_size = _jpeg_mem_size(&cjpeg); - jpeg_destroy_compress(&cjpeg); -@@ -200,20 +532,27 @@ static int put_jpeg_grey_memory(unsigned - return dest_image_size; - } - --/* put_jpeg_yuv420p_file converts an YUV420P coded image to a jpeg image and writes -- * it to an already open file. -+/** -+ * put_jpeg_yuv420p_file -+ * Converts an YUV420P coded image to a jpeg image and writes -+ * it to an already open file. -+ * - * Inputs: - * - image is the image in YUV420P format. - * - width and height are the dimensions of the image - * - quality is the jpeg encoding quality 0-100% -+ * - * Output: - * - The jpeg is written directly to the file given by the file pointer fp -+ * - * Returns nothing - */ --static void put_jpeg_yuv420p_file(FILE *fp, unsigned char *image, int width, -- int height, int quality) -+static void put_jpeg_yuv420p_file(FILE *fp, -+ unsigned char *image, int width, int height, -+ int quality, -+ struct context *cnt, struct tm *tm, struct coord *box) - { -- int i,j; -+ int i, j; - - JSAMPROW y[16],cb[16],cr[16]; // y[2][5] = color sample of row 2 and pixel column 5; (one plane) - JSAMPARRAY data[3]; // t[0][2][5] = color sample 0 of row 2 and column 5 -@@ -225,8 +564,8 @@ static void put_jpeg_yuv420p_file(FILE * - data[1] = cb; - data[2] = cr; - -- cinfo.err = jpeg_std_error(&jerr); // errors get written to stderr -- -+ cinfo.err = jpeg_std_error(&jerr); // Errors get written to stderr -+ - jpeg_create_compress(&cinfo); - cinfo.image_width = width; - cinfo.image_height = height; -@@ -235,11 +574,10 @@ static void put_jpeg_yuv420p_file(FILE * - - jpeg_set_colorspace(&cinfo, JCS_YCbCr); - -- cinfo.raw_data_in = TRUE; // supply downsampled data -+ cinfo.raw_data_in = TRUE; // Supply downsampled data - #if JPEG_LIB_VERSION >= 70 --#warning using JPEG_LIB_VERSION >= 70 -- cinfo.do_fancy_downsampling = FALSE; // fix segfaulst with v7 --#endif -+ cinfo.do_fancy_downsampling = FALSE; // Fix segfault with v7 -+#endif - cinfo.comp_info[0].h_samp_factor = 2; - cinfo.comp_info[0].v_samp_factor = 2; - cinfo.comp_info[1].h_samp_factor = 1; -@@ -250,15 +588,17 @@ static void put_jpeg_yuv420p_file(FILE * - jpeg_set_quality(&cinfo, quality, TRUE); - cinfo.dct_method = JDCT_FASTEST; - -- jpeg_stdio_dest(&cinfo, fp); // data written to file -+ jpeg_stdio_dest(&cinfo, fp); // Data written to file - jpeg_start_compress(&cinfo, TRUE); - -+ put_jpeg_exif(&cinfo, cnt, tm, box); -+ - for (j = 0; j < height; j += 16) { - for (i = 0; i < 16; i++) { - y[i] = image + width * (i + j); - if (i % 2 == 0) { - cb[i / 2] = image + width * height + width / 2 * ((i + j) / 2); -- cr[i / 2] = image + width * height + width * height / 4 + width / 2 * ((i + j) /2); -+ cr[i / 2] = image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); - } - } - jpeg_write_raw_data(&cinfo, data, 16); -@@ -269,14 +609,18 @@ static void put_jpeg_yuv420p_file(FILE * - } - - --/* put_jpeg_grey_file converts an greyscale image to a jpeg image and writes -- * it to an already open file. -+/** -+ * put_jpeg_grey_file -+ * Converts an greyscale image to a jpeg image and writes -+ * it to an already open file. -+ * - * Inputs: - * - image is the image in greyscale format. - * - width and height are the dimensions of the image - * - quality is the jpeg encoding quality 0-100% - * Output: - * - The jpeg is written directly to the file given by the file pointer fp -+ * - * Returns nothing - */ - static void put_jpeg_grey_file(FILE *picture, unsigned char *image, int width, int height, int quality) -@@ -290,7 +634,7 @@ static void put_jpeg_grey_file(FILE *pic - jpeg_create_compress(&cjpeg); - cjpeg.image_width = width; - cjpeg.image_height = height; -- cjpeg.input_components = 1; /* one colour component */ -+ cjpeg.input_components = 1; /* One colour component */ - cjpeg.in_color_space = JCS_GRAYSCALE; - - jpeg_set_defaults(&cjpeg); -@@ -301,6 +645,8 @@ static void put_jpeg_grey_file(FILE *pic - - jpeg_start_compress(&cjpeg, TRUE); - -+ put_jpeg_exif(&cjpeg, NULL, NULL, NULL); -+ - row_ptr[0] = image; - - for (y = 0; y < height; y++) { -@@ -313,13 +659,17 @@ static void put_jpeg_grey_file(FILE *pic - } - - --/* put_ppm_bgr24_file converts an greyscale image to a PPM image and writes -- * it to an already open file. -+/** -+ * put_ppm_bgr24_file -+ * Converts an greyscale image to a PPM image and writes -+ * it to an already open file. - * Inputs: - * - image is the image in YUV420P format. - * - width and height are the dimensions of the image -+ * - * Output: - * - The PPM is written directly to the file given by the file pointer fp -+ * - * Returns nothing - */ - static void put_ppm_bgr24_file(FILE *picture, unsigned char *image, int width, int height) -@@ -329,25 +679,25 @@ static void put_ppm_bgr24_file(FILE *pic - unsigned char *u = image + width * height; - unsigned char *v = u + (width * height) / 4; - int r, g, b; -- int warningkiller; - unsigned char rgb[3]; -- -- /* ppm header -- * width height -- * maxval -+ -+ /* -+ * ppm header -+ * width height -+ * maxval - */ - fprintf(picture, "P6\n"); - fprintf(picture, "%d %d\n", width, height); - fprintf(picture, "%d\n", 255); - for (y = 0; y < height; y++) { -- -+ - for (x = 0; x < width; x++) { -- r = 76283* (((int)*l) - 16) + 104595 * (((int)*u) - 128); -- g = 76283* (((int)*l) - 16)- 53281 * (((int)*u) - 128)-25625*(((int)*v)-128); -- b = 76283* (((int)*l) - 16) + 132252 * (((int)*v) - 128); -- r = r>>16; -- g = g>>16; -- b = b>>16; -+ r = 76283 * (((int)*l) - 16)+104595*(((int)*u) - 128); -+ g = 76283 * (((int)*l) - 16)- 53281*(((int)*u) - 128) - 25625 * (((int)*v) - 128); -+ b = 76283 * (((int)*l) - 16) + 132252 * (((int)*v) - 128); -+ r = r >> 16; -+ g = g >> 16; -+ b = b >> 16; - if (r < 0) - r = 0; - else if (r > 255) -@@ -371,7 +721,7 @@ static void put_ppm_bgr24_file(FILE *pic - v++; - } - /* ppm is rgb not bgr */ -- warningkiller = fwrite(rgb, 1, 3, picture); -+ fwrite(rgb, 1, 3, picture); - } - if (y & 1) { - u -= width / 2; -@@ -380,97 +730,131 @@ static void put_ppm_bgr24_file(FILE *pic - } - } - --/* copy smartmask as an overlay into motion images and movies */ -+/** -+ * overlay_smartmask -+ * Copies smartmask as an overlay into motion images and movies. -+ * -+ * Returns nothing. -+ */ - void overlay_smartmask(struct context *cnt, unsigned char *out) - { - int i, x, v, width, height, line; - struct images *imgs = &cnt->imgs; - unsigned char *smartmask = imgs->smartmask_final; - unsigned char *out_y, *out_u, *out_v; -- -+ - i = imgs->motionsize; - v = i + ((imgs->motionsize) / 4); - width = imgs->width; - height = imgs->height; - -- /* set V to 255 to make smartmask appear red */ -+ /* Set V to 255 to make smartmask appear red. */ - out_v = out + v; - out_u = out + i; -- for (i = 0; i < height; i += 2){ -+ for (i = 0; i < height; i += 2) { - line = i * width; -- for (x = 0; x < width; x += 2){ -- if (smartmask[line + x] == 0 || -- smartmask[line + x + 1] == 0 || -+ for (x = 0; x < width; x += 2) { -+ if (smartmask[line + x] == 0 || smartmask[line + x + 1] == 0 || - smartmask[line + width + x] == 0 || -- smartmask[line + width + x + 1] == 0){ -- *out_v = 255; -- *out_u = 128; -+ smartmask[line + width + x + 1] == 0) { -+ -+ *out_v = 255; -+ *out_u = 128; - } - out_v++; - out_u++; - } - } - out_y = out; -- /* set colour intensity for smartmask */ -- for (i = 0; i < imgs->motionsize; i++){ -+ /* Set colour intensity for smartmask. */ -+ for (i = 0; i < imgs->motionsize; i++) { - if (smartmask[i] == 0) - *out_y = 0; - out_y++; - } - } - --/* copy fixed mask as an overlay into motion images and movies */ -+/** -+ * overlay_fixed_mask -+ * Copies fixed mask as green overlay into motion images and movies. -+ * -+ * Returns nothing. -+ */ - void overlay_fixed_mask(struct context *cnt, unsigned char *out) - { -- int i; -+ int i, x, v, width, height, line; - struct images *imgs = &cnt->imgs; -- unsigned char *motion_img = imgs->out; - unsigned char *mask = imgs->mask; -- int pixel; -- -- /* set y to mask + motion-pixel to keep motion pixels visible on grey background*/ -- for (i = 0; i < imgs->motionsize; i++){ -- pixel = 255 - mask[i] + motion_img[i]; -- if (pixel > 255) -- *out = 255; -- else -- *out = pixel; -- out++; -+ unsigned char *out_y, *out_u, *out_v; -+ -+ i = imgs->motionsize; -+ v = i + ((imgs->motionsize) / 4); -+ width = imgs->width; -+ height = imgs->height; -+ -+ /* Set U and V to 0 to make fixed mask appear green. */ -+ out_v = out + v; -+ out_u = out + i; -+ for (i = 0; i < height; i += 2) { -+ line = i * width; -+ for (x = 0; x < width; x += 2) { -+ if (mask[line + x] == 0 || mask[line + x + 1] == 0 || -+ mask[line + width + x] == 0 || -+ mask[line + width + x + 1] == 0) { -+ -+ *out_v = 0; -+ *out_u = 0; -+ } -+ out_v++; -+ out_u++; -+ } -+ } -+ out_y = out; -+ /* Set colour intensity for mask. */ -+ for (i = 0; i < imgs->motionsize; i++) { -+ if (mask[i] == 0) -+ *out_y = 0; -+ out_y++; - } - } - --/* copy largest label as an overlay into motion images and movies */ -+/** -+ * overlay_largest_label -+ * Copies largest label as an overlay into motion images and movies. -+ * -+ * Returns nothing. -+ */ - void overlay_largest_label(struct context *cnt, unsigned char *out) - { - int i, x, v, width, height, line; - struct images *imgs = &cnt->imgs; - int *labels = imgs->labels; - unsigned char *out_y, *out_u, *out_v; -- -+ - i = imgs->motionsize; - v = i + ((imgs->motionsize) / 4); - width = imgs->width; - height = imgs->height; - -- /* set U to 255 to make label appear blue */ -+ /* Set U to 255 to make label appear blue. */ - out_u = out + i; - out_v = out + v; -- for (i = 0; i < height; i += 2){ -+ for (i = 0; i < height; i += 2) { - line = i * width; -- for (x = 0; x < width; x += 2){ -- if (labels[line + x] & 32768 || -- labels[line + x + 1] & 32768 || -+ for (x = 0; x < width; x += 2) { -+ if (labels[line + x] & 32768 || labels[line + x + 1] & 32768 || - labels[line + width + x] & 32768 || - labels[line + width + x + 1] & 32768) { -- *out_u = 255; -- *out_v = 128; -+ -+ *out_u = 255; -+ *out_v = 128; - } - out_u++; - out_v++; - } - } - out_y = out; -- /* set intensity for coloured label to have better visibility */ -+ /* Set intensity for coloured label to have better visibility. */ - for (i = 0; i < imgs->motionsize; i++) { - if (*labels++ & 32768) - *out_y = 0; -@@ -478,30 +862,35 @@ void overlay_largest_label(struct contex - } - } - --/* put_picture_mem is used for the webcam feature. Depending on the image type -- * (colour YUV420P or greyscale) the corresponding put_jpeg_X_memory function is called. -+/** -+ * put_picture_mem -+ * Is used for the webcam feature. Depending on the image type -+ * (colour YUV420P or greyscale) the corresponding put_jpeg_X_memory function is called. - * Inputs: - * - cnt is the global context struct and only cnt->imgs.type is used. - * - image_size is the size of the input image buffer - * - *image points to the image buffer that contains the YUV420P or Grayscale image about to be put - * - quality is the jpeg quality setting from the config file. -+ * - * Output: - * - **dest_image is a pointer to a pointer that points to the destination buffer in which the - * converted image it put -- * Function returns the dest_image_size if successful. Otherwise 0. -- */ -+ * -+ * Returns the dest_image_size if successful. Otherwise 0. -+ */ - int put_picture_memory(struct context *cnt, unsigned char* dest_image, int image_size, - unsigned char *image, int quality) - { - switch (cnt->imgs.type) { - case VIDEO_PALETTE_YUV420P: - return put_jpeg_yuv420p_memory(dest_image, image_size, image, -- cnt->imgs.width, cnt->imgs.height, quality); -+ cnt->imgs.width, cnt->imgs.height, quality, cnt, &(cnt->current_image->timestamp_tm), &(cnt->current_image->location)); - case VIDEO_PALETTE_GREY: - return put_jpeg_grey_memory(dest_image, image_size, image, - cnt->imgs.width, cnt->imgs.height, quality); - default: -- motion_log(LOG_ERR, 0, "Unknow image type %d", cnt->imgs.type); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknow image type %d", -+ cnt->imgs.type); - } - - return 0; -@@ -509,18 +898,19 @@ int put_picture_memory(struct context *c - - void put_picture_fd(struct context *cnt, FILE *picture, unsigned char *image, int quality) - { -- if (cnt->conf.ppm) { -+ if (cnt->imgs.picture_type == IMAGE_TYPE_PPM) { - put_ppm_bgr24_file(picture, image, cnt->imgs.width, cnt->imgs.height); - } else { - switch (cnt->imgs.type) { - case VIDEO_PALETTE_YUV420P: -- put_jpeg_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); -+ put_jpeg_yuv420p_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality, cnt, &(cnt->current_image->timestamp_tm), &(cnt->current_image->location)); - break; - case VIDEO_PALETTE_GREY: - put_jpeg_grey_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); - break; -- default : -- motion_log(LOG_ERR, 0, "Unknow image type %d", cnt->imgs.type); -+ default: -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknow image type %d", -+ cnt->imgs.type); - } - } - } -@@ -530,61 +920,67 @@ void put_picture(struct context *cnt, ch - { - FILE *picture; - -- picture = myfopen(file, "w"); -+ picture = myfopen(file, "w", BUFSIZE_1MEG); - if (!picture) { -- /* Report to syslog - suggest solution if the problem is access rights to target dir */ -+ /* Report to syslog - suggest solution if the problem is access rights to target dir. */ - if (errno == EACCES) { -- motion_log(LOG_ERR, 1, -- "Can't write picture to file %s - check access rights to target directory", file); -- motion_log(LOG_ERR, 1, "Thread is going to finish due to this fatal error"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, -+ "%s: Can't write picture to file %s - check access rights to target directory\n" -+ "Thread is going to finish due to this fatal error", file); - cnt->finish = 1; - cnt->restart = 0; - return; - } else { -- /* If target dir is temporarily unavailable we may survive */ -- motion_log(LOG_ERR, 1, "Can't write picture to file %s", file); -+ /* If target dir is temporarily unavailable we may survive. */ -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Can't write picture to file %s", file); - return; - } - } - - put_picture_fd(cnt, picture, image, cnt->conf.quality); -- fclose(picture); -+ myfclose(picture); - event(cnt, EVENT_FILECREATE, NULL, file, (void *)(unsigned long)ftype, NULL); - } - --/* Get the pgm file used as fixed mask */ -+/** -+ * get_pgm -+ * Get the pgm file used as fixed mask -+ * -+ */ - unsigned char *get_pgm(FILE *picture, int width, int height) - { -- int x = 0 ,y = 0, maxval; -+ int x = 0 , y = 0, maxval; - char line[256]; - unsigned char *image; - -- line[255]=0; -- -+ line[255] = 0; -+ - if (!fgets(line, 255, picture)) { -- motion_log(LOG_ERR, 1, "Could not read from ppm file"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not read from ppm file"); - return NULL; - } -- -+ - if (strncmp(line, "P5", 2)) { -- motion_log(LOG_ERR, 1, "This is not a ppm file, starts with '%s'", line); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: This is not a ppm file, starts with '%s'", -+ line); - return NULL; - } -- -- /* skip comment */ -+ -+ /* Skip comment */ - line[0] = '#'; - while (line[0] == '#') - if (!fgets(line, 255, picture)) - return NULL; - -- /* check size */ -+ /* Check size */ - if (sscanf(line, "%d %d", &x, &y) != 2) { -- motion_log(LOG_ERR, 1, "Failed reading size in pgm file"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading size in pgm file"); - return NULL; - } -- -+ - if (x != width || y != height) { -- motion_log(LOG_ERR, 1, "Wrong image size %dx%d should be %dx%d", x, y, width, height); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Wrong image size %dx%d should be %dx%d", -+ x, y, width, height); - return NULL; - } - -@@ -593,119 +989,137 @@ unsigned char *get_pgm(FILE *picture, in - while (line[0] == '#') - if (!fgets(line, 255, picture)) - return NULL; -- -+ - if (sscanf(line, "%d", &maxval) != 1) { -- motion_log(LOG_ERR, 1, "Failed reading maximum value in pgm file"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading maximum value in pgm file"); - return NULL; - } -- -- /* read data */ -- -+ -+ /* Read data */ -+ - image = mymalloc(width * height); -- -+ - for (y = 0; y < height; y++) { - if ((int)fread(&image[y * width], 1, width, picture) != width) -- motion_log(LOG_ERR, 1, "Failed reading image data from pgm file"); -- -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading image data from pgm file"); -+ - for (x = 0; x < width; x++) - image[y * width + x] = (int)image[y * width + x] * 255 / maxval; -- -- } -+ -+ } - - return image; - } - --/* If a mask file is asked for but does not exist this function -- * creates an empty mask file in the right binary pgm format and -- * and the right size - easy to edit with Gimp or similar tool. -+/** -+ * put_fixed_mask -+ * If a mask file is asked for but does not exist this function -+ * creates an empty mask file in the right binary pgm format and -+ * and the right size - easy to edit with Gimp or similar tool. -+ * -+ * Returns nothing. - */ - void put_fixed_mask(struct context *cnt, const char *file) - { - FILE *picture; - -- picture = myfopen(file, "w"); -- -+ picture = myfopen(file, "w", BUFSIZE_1MEG); - if (!picture) { -- /* Report to syslog - suggest solution if the problem is access rights to target dir */ -+ /* Report to syslog - suggest solution if the problem is access rights to target dir. */ - if (errno == EACCES) { -- motion_log(LOG_ERR, 1, -- "can't write mask file %s - check access rights to target directory", file); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, -+ "%s: can't write mask file %s - check access rights to target directory", -+ file); - } else { -- /* If target dir is temporarily unavailable we may survive */ -- motion_log(LOG_ERR, 1, "can't write mask file %s", file); -+ /* If target dir is temporarily unavailable we may survive. */ -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: can't write mask file %s", file); - } - return; - } -+ memset(cnt->imgs.out, 255, cnt->imgs.motionsize); /* Initialize to unset */ - -- memset(cnt->imgs.out, 255, cnt->imgs.motionsize); /* initialize to unset */ -- -- /* Write pgm-header */ -+ /* Write pgm-header. */ - fprintf(picture, "P5\n"); - fprintf(picture, "%d %d\n", cnt->conf.width, cnt->conf.height); - fprintf(picture, "%d\n", 255); -- -- /* write pgm image data at once */ -+ -+ /* Write pgm image data at once. */ - if ((int)fwrite(cnt->imgs.out, cnt->conf.width, cnt->conf.height, picture) != cnt->conf.height) { -- motion_log(LOG_ERR, 1, "Failed writing default mask as pgm file"); -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed writing default mask as pgm file"); - return; - } -- -- fclose(picture); - -- motion_log(LOG_ERR, 0, "Creating empty mask %s",cnt->conf.mask_file); -- motion_log(LOG_ERR, 0, "Please edit this file and re-run motion to enable mask feature"); -+ myfclose(picture); -+ -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Creating empty mask %s\nPlease edit this file and " -+ "re-run motion to enable mask feature", cnt->conf.mask_file); - } - --/* save preview_shot */ -+/** -+ * preview_save -+ * save preview_shot -+ * -+ * Returns nothing. -+ */ - void preview_save(struct context *cnt) - { --#ifdef HAVE_FFMPEG -- int use_jpegpath; -+ int use_imagepath; - int basename_len; --#endif /* HAVE_FFMPEG */ -- const char *jpegpath; -+ const char *imagepath; - char previewname[PATH_MAX]; - char filename[PATH_MAX]; - struct image_data *saved_current_image; - - if (cnt->imgs.preview_image.diffs) { -- /* Save current global context */ -+ /* Save current global context. */ - saved_current_image = cnt->current_image; -- /* Set global context to the image we are processing */ -+ /* Set global context to the image we are processing. */ - cnt->current_image = &cnt->imgs.preview_image; - -+ /* Use filename of movie i.o. jpeg_filename when set to 'preview'. */ -+ use_imagepath = strcmp(cnt->conf.imagepath, "preview"); -+ - #ifdef HAVE_FFMPEG -- /* Use filename of movie i.o. jpeg_filename when set to 'preview' */ -- use_jpegpath = strcmp(cnt->conf.jpegpath, "preview"); -- -- if (cnt->ffmpeg_new && !use_jpegpath) { -- /* 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) { -+#else -+ if ((cnt->conf.useextpipe && cnt->extpipe) && !use_imagepath) { -+#endif -+ 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 */ -- { -- /* Save best preview-shot also when no movies are recorded or jpegpath -- * is used. Filename has to be generated - nothing available to reuse! */ -- //printf("preview_shot: different filename or picture only!\n"); -- -- /* conf.jpegpath would normally be defined but if someone deleted it by control interface -- * it is better to revert to the default than fail */ -- if (cnt->conf.jpegpath) -- jpegpath = cnt->conf.jpegpath; -+ } else { -+ /* -+ * Save best preview-shot also when no movies are recorded or imagepath -+ * is used. Filename has to be generated - nothing available to reuse! -+ */ -+ MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: different filename or picture only!"); -+ /* -+ * conf.imagepath would normally be defined but if someone deleted it by -+ * control interface it is better to revert to the default than fail. -+ */ -+ if (cnt->conf.imagepath) -+ imagepath = cnt->conf.imagepath; - else -- jpegpath = (char *)DEF_JPEGPATH; -- -- mystrftime(cnt, filename, sizeof(filename), jpegpath, &cnt->imgs.preview_image.timestamp_tm, NULL, 0); -+ imagepath = (char *)DEF_IMAGEPATH; -+ -+ mystrftime(cnt, filename, sizeof(filename), imagepath, &cnt->imgs.preview_image.timestamp_tm, NULL, 0); - snprintf(previewname, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filename, imageext(cnt)); - - put_picture(cnt, previewname, cnt->imgs.preview_image.image, FTYPE_IMAGE); - } - -- /* restore global context values */ -+ /* Restore global context values. */ - cnt->current_image = saved_current_image; - } - } ---- motion-3.2.12.orig/picture.h -+++ motion-3.2.12/picture.h -@@ -18,7 +18,7 @@ void put_fixed_mask(struct context *, co - void overlay_largest_label(struct context *, unsigned char *); - void put_picture_fd(struct context *, FILE *, unsigned char *, int); - int put_picture_memory(struct context *, unsigned char*, int, unsigned char *, int); --void put_picture(struct context *, char *, unsigned char *, int ); -+void put_picture(struct context *, char *, unsigned char *, int); - unsigned char *get_pgm(FILE *, int, int); - void preview_save(struct context *); - ---- motion-3.2.12.orig/pwc-ioctl.h -+++ motion-3.2.12/pwc-ioctl.h -@@ -45,11 +45,11 @@ - specified in the Video4Linux API. - - The #define names are built up like follows: -- VIDIOC VIDeo IOCtl prefix -- PWC Philps WebCam -+ VIDIOC VIDeo IOCtl prefix -+ PWC Philps WebCam - G optional: Get - S optional: Set -- ... the function -+ ... the function - */ - - #if (!defined(BSD)) -@@ -64,13 +64,13 @@ typedef __u16 __le16; - #endif /* ( !BSD ) */ - - /* Enumeration of image sizes */ --#define PSZ_SQCIF 0x00 --#define PSZ_QSIF 0x01 --#define PSZ_QCIF 0x02 --#define PSZ_SIF 0x03 --#define PSZ_CIF 0x04 --#define PSZ_VGA 0x05 --#define PSZ_MAX 6 -+#define PSZ_SQCIF 0x00 -+#define PSZ_QSIF 0x01 -+#define PSZ_QCIF 0x02 -+#define PSZ_SIF 0x03 -+#define PSZ_CIF 0x04 -+#define PSZ_VGA 0x05 -+#define PSZ_MAX 6 - - - /* The frame rate is encoded in the video_window.flags parameter using -@@ -82,40 +82,40 @@ typedef __u16 __le16; - In 'Snapshot' mode the camera freezes its automatic exposure and colour - balance controls. - */ --#define PWC_FPS_SHIFT 16 --#define PWC_FPS_MASK 0x00FF0000 --#define PWC_FPS_FRMASK 0x003F0000 --#define PWC_FPS_SNAPSHOT 0x00400000 --#define PWC_QLT_MASK 0x03000000 --#define PWC_QLT_SHIFT 24 -+#define PWC_FPS_SHIFT 16 -+#define PWC_FPS_MASK 0x00FF0000 -+#define PWC_FPS_FRMASK 0x003F0000 -+#define PWC_FPS_SNAPSHOT 0x00400000 -+#define PWC_QLT_MASK 0x03000000 -+#define PWC_QLT_SHIFT 24 - - - /* structure for transferring x & y coordinates */ - struct pwc_coord - { -- int x, y; /* guess what */ -- int size; /* size, or offset */ -+ int x, y; /* guess what */ -+ int size; /* size, or offset */ - }; - - - /* Used with VIDIOCPWCPROBE */ - struct pwc_probe - { -- char name[32]; -- int type; -+ char name[32]; -+ int type; - }; - - struct pwc_serial - { -- char serial[30]; /* String with serial number. Contains terminating 0 */ -+ char serial[30]; /* String with serial number. Contains terminating 0 */ - }; -- -+ - /* pwc_whitebalance.mode values */ --#define PWC_WB_INDOOR 0 --#define PWC_WB_OUTDOOR 1 --#define PWC_WB_FL 2 --#define PWC_WB_MANUAL 3 --#define PWC_WB_AUTO 4 -+#define PWC_WB_INDOOR 0 -+#define PWC_WB_OUTDOOR 1 -+#define PWC_WB_FL 2 -+#define PWC_WB_MANUAL 3 -+#define PWC_WB_AUTO 4 - - /* Used with VIDIOCPWC[SG]AWB (Auto White Balance). - Set mode to one of the PWC_WB_* values above. -@@ -127,9 +127,9 @@ struct pwc_serial - */ - struct pwc_whitebalance - { -- int mode; -- int manual_red, manual_blue; /* R/W */ -- int read_red, read_blue; /* R/O */ -+ int mode; -+ int manual_red, manual_blue; /* R/W */ -+ int read_red, read_blue; /* R/O */ - }; - - /* -@@ -139,29 +139,29 @@ struct pwc_whitebalance - */ - struct pwc_wb_speed - { -- int control_speed; -- int control_delay; -+ int control_speed; -+ int control_delay; - - }; - - /* Used with VIDIOCPWC[SG]LED */ - struct pwc_leds - { -- int led_on; /* Led on-time; range = 0..25000 */ -- int led_off; /* Led off-time; range = 0..25000 */ -+ int led_on; /* Led on-time; range = 0..25000 */ -+ int led_off; /* Led off-time; range = 0..25000 */ - }; - - /* Image size (used with GREALSIZE) */ - struct pwc_imagesize - { -- int width; -- int height; -+ int width; -+ int height; - }; - - /* Defines and structures for Motorized Pan & Tilt */ --#define PWC_MPT_PAN 0x01 --#define PWC_MPT_TILT 0x02 --#define PWC_MPT_TIMEOUT 0x04 /* for status */ -+#define PWC_MPT_PAN 0x01 -+#define PWC_MPT_TILT 0x02 -+#define PWC_MPT_TIMEOUT 0x04 /* for status */ - - /* Set angles; when absolute != 0, the angle is absolute and the - driver calculates the relative offset for you. This can only -@@ -170,24 +170,24 @@ struct pwc_imagesize - */ - struct pwc_mpt_angles - { -- int absolute; /* write-only */ -- int pan; /* degrees * 100 */ -- int tilt; /* degress * 100 */ -+ int absolute; /* write-only */ -+ int pan; /* degrees * 100 */ -+ int tilt; /* degress * 100 */ - }; - - /* Range of angles of the camera, both horizontally and vertically. - */ - struct pwc_mpt_range - { -- int pan_min, pan_max; /* degrees * 100 */ -- int tilt_min, tilt_max; -+ int pan_min, pan_max; /* degrees * 100 */ -+ int tilt_min, tilt_max; - }; - - struct pwc_mpt_status - { -- int status; -- int time_pan; -- int time_tilt; -+ int status; -+ int time_pan; -+ int time_tilt; - }; - - -@@ -197,30 +197,30 @@ struct pwc_mpt_status - */ - struct pwc_video_command - { -- int type; /* camera type (645, 675, 730, etc.) */ -- int release; /* release number */ -+ int type; /* camera type (645, 675, 730, etc.) */ -+ int release; /* release number */ - -- int size; /* one of PSZ_* */ -- int alternate; -- int command_len; /* length of USB video command */ -- unsigned char command_buf[13]; /* Actual USB video command */ -- int bandlength; /* >0 = compressed */ -- int frame_size; /* Size of one (un)compressed frame */ -+ int size; /* one of PSZ_* */ -+ int alternate; -+ int command_len; /* length of USB video command */ -+ unsigned char command_buf[13]; /* Actual USB video command */ -+ int bandlength; /* >0 = compressed */ -+ int frame_size; /* Size of one (un)compressed frame */ - }; - - /* Flags for PWCX subroutines. Not all modules honour all flags. */ --#define PWCX_FLAG_PLANAR 0x0001 --#define PWCX_FLAG_BAYER 0x0008 -+#define PWCX_FLAG_PLANAR 0x0001 -+#define PWCX_FLAG_BAYER 0x0008 - - - /* IOCTL definitions */ - - /* Restore user settings */ --#define VIDIOCPWCRUSER _IO('v', 192) -+#define VIDIOCPWCRUSER _IO('v', 192) - /* Save user settings */ --#define VIDIOCPWCSUSER _IO('v', 193) -+#define VIDIOCPWCSUSER _IO('v', 193) - /* Restore factory settings */ --#define VIDIOCPWCFACTORY _IO('v', 194) -+#define VIDIOCPWCFACTORY _IO('v', 194) - - /* You can manipulate the compression factor. A compression preference of 0 - means use uncompressed modes when available; 1 is low compression, 2 is -@@ -230,13 +230,13 @@ struct pwc_video_command - the preferred mode is not available. - */ - /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ --#define VIDIOCPWCSCQUAL _IOW('v', 195, int) -+#define VIDIOCPWCSCQUAL _IOW('v', 195, int) - /* Get preferred compression quality */ --#define VIDIOCPWCGCQUAL _IOR('v', 195, int) -+#define VIDIOCPWCGCQUAL _IOR('v', 195, int) - - - /* Retrieve serial number of camera */ --#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) -+#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) - - /* This is a probe function; since so many devices are supported, it - becomes difficult to include all the names in programs that want to -@@ -248,61 +248,60 @@ struct pwc_video_command - same. If so, you can be assured it is a Philips (OEM) cam and the type - is valid. - */ --#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) -+#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) - - /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ --#define VIDIOCPWCSAGC _IOW('v', 200, int) -+#define VIDIOCPWCSAGC _IOW('v', 200, int) - /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ --#define VIDIOCPWCGAGC _IOR('v', 200, int) -+#define VIDIOCPWCGAGC _IOR('v', 200, int) - /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ --#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) -+#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) - - /* Color compensation (Auto White Balance) */ --#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) --#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) -+#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) -+#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) - - /* Auto WB speed */ --#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) --#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) -+#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) -+#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) - - /* LEDs on/off/blink; int range 0..65535 */ --#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) --#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) -+#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) -+#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) - - /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ --#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) --#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) -+#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) -+#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) - - /* Backlight compensation; 0 = off, otherwise on */ --#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) --#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) -+#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) -+#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) - - /* Flickerless mode; = 0 off, otherwise on */ --#define VIDIOCPWCSFLICKER _IOW('v', 208, int) --#define VIDIOCPWCGFLICKER _IOR('v', 208, int) -+#define VIDIOCPWCSFLICKER _IOW('v', 208, int) -+#define VIDIOCPWCGFLICKER _IOR('v', 208, int) - - /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ --#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) --#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) -+#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) -+#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) - - /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ --#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) -+#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) - - /* Motorized pan & tilt functions */ --#define VIDIOCPWCMPTRESET _IOW('v', 211, int) --#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) --#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) --#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) --#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) -+#define VIDIOCPWCMPTRESET _IOW('v', 211, int) -+#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) -+#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) -+#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) -+#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) - - /* Get the USB set-video command; needed for initializing libpwcx */ --#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) -+#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) - struct pwc_table_init_buffer { - int len; - char *buffer; -- - }; --#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) -+#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) - - /* - * This is private command used when communicating with v4l2. -@@ -323,13 +322,13 @@ struct pwc_table_init_buffer { - #define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8) - - struct pwc_raw_frame { -- __le16 type; /* type of the webcam */ -- __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ -- __u8 cmd[4]; /* the four byte of the command (in case of nala, -- only the first 3 bytes is filled) */ -- __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ -+ __le16 type; /* type of the webcam */ -+ __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ -+ __u8 cmd[4]; /* the four byte of the command (in case of nala, -+ only the first 3 bytes is filled) */ -+ __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ - } __attribute__ ((packed)); - --#endif /* MOTION_V4L2 && (! BSD ) */ -+#endif /* MOTION_V4L2 && (! BSD ) */ - - #endif ---- motion-3.2.12.orig/pwc-ioctl.h-10.0.10 -+++ motion-3.2.12/pwc-ioctl.h-10.0.10 -@@ -45,13 +45,14 @@ - specified in the Video4Linux API. - - The #define names are built up like follows: -- VIDIOC VIDeo IOCtl prefix -- PWC Philps WebCam -+ VIDIOC VIDeo IOCtl prefix -+ PWC Philps WebCam - G optional: Get - S optional: Set -- ... the function -+ ... the function - */ - -+#if (!defined(BSD)) - #include - #include - -@@ -60,14 +61,16 @@ - typedef __u16 __le16; - #endif - -+#endif /* ( !BSD ) */ -+ - /* Enumeration of image sizes */ --#define PSZ_SQCIF 0x00 --#define PSZ_QSIF 0x01 --#define PSZ_QCIF 0x02 --#define PSZ_SIF 0x03 --#define PSZ_CIF 0x04 --#define PSZ_VGA 0x05 --#define PSZ_MAX 6 -+#define PSZ_SQCIF 0x00 -+#define PSZ_QSIF 0x01 -+#define PSZ_QCIF 0x02 -+#define PSZ_SIF 0x03 -+#define PSZ_CIF 0x04 -+#define PSZ_VGA 0x05 -+#define PSZ_MAX 6 - - - /* The frame rate is encoded in the video_window.flags parameter using -@@ -79,40 +82,40 @@ typedef __u16 __le16; - In 'Snapshot' mode the camera freezes its automatic exposure and colour - balance controls. - */ --#define PWC_FPS_SHIFT 16 --#define PWC_FPS_MASK 0x00FF0000 --#define PWC_FPS_FRMASK 0x003F0000 --#define PWC_FPS_SNAPSHOT 0x00400000 --#define PWC_QLT_MASK 0x03000000 --#define PWC_QLT_SHIFT 24 -+#define PWC_FPS_SHIFT 16 -+#define PWC_FPS_MASK 0x00FF0000 -+#define PWC_FPS_FRMASK 0x003F0000 -+#define PWC_FPS_SNAPSHOT 0x00400000 -+#define PWC_QLT_MASK 0x03000000 -+#define PWC_QLT_SHIFT 24 - - - /* structure for transferring x & y coordinates */ - struct pwc_coord - { -- int x, y; /* guess what */ -- int size; /* size, or offset */ -+ int x, y; /* guess what */ -+ int size; /* size, or offset */ - }; - - - /* Used with VIDIOCPWCPROBE */ - struct pwc_probe - { -- char name[32]; -- int type; -+ char name[32]; -+ int type; - }; - - struct pwc_serial - { -- char serial[30]; /* String with serial number. Contains terminating 0 */ -+ char serial[30]; /* String with serial number. Contains terminating 0 */ - }; -- -+ - /* pwc_whitebalance.mode values */ --#define PWC_WB_INDOOR 0 --#define PWC_WB_OUTDOOR 1 --#define PWC_WB_FL 2 --#define PWC_WB_MANUAL 3 --#define PWC_WB_AUTO 4 -+#define PWC_WB_INDOOR 0 -+#define PWC_WB_OUTDOOR 1 -+#define PWC_WB_FL 2 -+#define PWC_WB_MANUAL 3 -+#define PWC_WB_AUTO 4 - - /* Used with VIDIOCPWC[SG]AWB (Auto White Balance). - Set mode to one of the PWC_WB_* values above. -@@ -124,9 +127,9 @@ struct pwc_serial - */ - struct pwc_whitebalance - { -- int mode; -- int manual_red, manual_blue; /* R/W */ -- int read_red, read_blue; /* R/O */ -+ int mode; -+ int manual_red, manual_blue; /* R/W */ -+ int read_red, read_blue; /* R/O */ - }; - - /* -@@ -136,29 +139,29 @@ struct pwc_whitebalance - */ - struct pwc_wb_speed - { -- int control_speed; -- int control_delay; -+ int control_speed; -+ int control_delay; - - }; - - /* Used with VIDIOCPWC[SG]LED */ - struct pwc_leds - { -- int led_on; /* Led on-time; range = 0..25000 */ -- int led_off; /* Led off-time; range = 0..25000 */ -+ int led_on; /* Led on-time; range = 0..25000 */ -+ int led_off; /* Led off-time; range = 0..25000 */ - }; - - /* Image size (used with GREALSIZE) */ - struct pwc_imagesize - { -- int width; -- int height; -+ int width; -+ int height; - }; - - /* Defines and structures for Motorized Pan & Tilt */ --#define PWC_MPT_PAN 0x01 --#define PWC_MPT_TILT 0x02 --#define PWC_MPT_TIMEOUT 0x04 /* for status */ -+#define PWC_MPT_PAN 0x01 -+#define PWC_MPT_TILT 0x02 -+#define PWC_MPT_TIMEOUT 0x04 /* for status */ - - /* Set angles; when absolute != 0, the angle is absolute and the - driver calculates the relative offset for you. This can only -@@ -167,24 +170,24 @@ struct pwc_imagesize - */ - struct pwc_mpt_angles - { -- int absolute; /* write-only */ -- int pan; /* degrees * 100 */ -- int tilt; /* degress * 100 */ -+ int absolute; /* write-only */ -+ int pan; /* degrees * 100 */ -+ int tilt; /* degress * 100 */ - }; - - /* Range of angles of the camera, both horizontally and vertically. - */ - struct pwc_mpt_range - { -- int pan_min, pan_max; /* degrees * 100 */ -- int tilt_min, tilt_max; -+ int pan_min, pan_max; /* degrees * 100 */ -+ int tilt_min, tilt_max; - }; - - struct pwc_mpt_status - { -- int status; -- int time_pan; -- int time_tilt; -+ int status; -+ int time_pan; -+ int time_tilt; - }; - - -@@ -194,30 +197,30 @@ struct pwc_mpt_status - */ - struct pwc_video_command - { -- int type; /* camera type (645, 675, 730, etc.) */ -- int release; /* release number */ -+ int type; /* camera type (645, 675, 730, etc.) */ -+ int release; /* release number */ - -- int size; /* one of PSZ_* */ -- int alternate; -- int command_len; /* length of USB video command */ -- unsigned char command_buf[13]; /* Actual USB video command */ -- int bandlength; /* >0 = compressed */ -- int frame_size; /* Size of one (un)compressed frame */ -+ int size; /* one of PSZ_* */ -+ int alternate; -+ int command_len; /* length of USB video command */ -+ unsigned char command_buf[13]; /* Actual USB video command */ -+ int bandlength; /* >0 = compressed */ -+ int frame_size; /* Size of one (un)compressed frame */ - }; - - /* Flags for PWCX subroutines. Not all modules honour all flags. */ --#define PWCX_FLAG_PLANAR 0x0001 --#define PWCX_FLAG_BAYER 0x0008 -+#define PWCX_FLAG_PLANAR 0x0001 -+#define PWCX_FLAG_BAYER 0x0008 - - - /* IOCTL definitions */ - - /* Restore user settings */ --#define VIDIOCPWCRUSER _IO('v', 192) -+#define VIDIOCPWCRUSER _IO('v', 192) - /* Save user settings */ --#define VIDIOCPWCSUSER _IO('v', 193) -+#define VIDIOCPWCSUSER _IO('v', 193) - /* Restore factory settings */ --#define VIDIOCPWCFACTORY _IO('v', 194) -+#define VIDIOCPWCFACTORY _IO('v', 194) - - /* You can manipulate the compression factor. A compression preference of 0 - means use uncompressed modes when available; 1 is low compression, 2 is -@@ -227,13 +230,13 @@ struct pwc_video_command - the preferred mode is not available. - */ - /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ --#define VIDIOCPWCSCQUAL _IOW('v', 195, int) -+#define VIDIOCPWCSCQUAL _IOW('v', 195, int) - /* Get preferred compression quality */ --#define VIDIOCPWCGCQUAL _IOR('v', 195, int) -+#define VIDIOCPWCGCQUAL _IOR('v', 195, int) - - - /* Retrieve serial number of camera */ --#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) -+#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) - - /* This is a probe function; since so many devices are supported, it - becomes difficult to include all the names in programs that want to -@@ -245,61 +248,60 @@ struct pwc_video_command - same. If so, you can be assured it is a Philips (OEM) cam and the type - is valid. - */ --#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) -+#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) - - /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ --#define VIDIOCPWCSAGC _IOW('v', 200, int) -+#define VIDIOCPWCSAGC _IOW('v', 200, int) - /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ --#define VIDIOCPWCGAGC _IOR('v', 200, int) -+#define VIDIOCPWCGAGC _IOR('v', 200, int) - /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ --#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) -+#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) - - /* Color compensation (Auto White Balance) */ --#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) --#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) -+#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) -+#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) - - /* Auto WB speed */ --#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) --#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) -+#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) -+#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) - - /* LEDs on/off/blink; int range 0..65535 */ --#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) --#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) -+#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) -+#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) - - /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ --#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) --#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) -+#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) -+#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) - - /* Backlight compensation; 0 = off, otherwise on */ --#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) --#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) -+#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) -+#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) - - /* Flickerless mode; = 0 off, otherwise on */ --#define VIDIOCPWCSFLICKER _IOW('v', 208, int) --#define VIDIOCPWCGFLICKER _IOR('v', 208, int) -+#define VIDIOCPWCSFLICKER _IOW('v', 208, int) -+#define VIDIOCPWCGFLICKER _IOR('v', 208, int) - - /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ --#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) --#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) -+#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) -+#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) - - /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ --#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) -+#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) - - /* Motorized pan & tilt functions */ --#define VIDIOCPWCMPTRESET _IOW('v', 211, int) --#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) --#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) --#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) --#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) -+#define VIDIOCPWCMPTRESET _IOW('v', 211, int) -+#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) -+#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) -+#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) -+#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) - - /* Get the USB set-video command; needed for initializing libpwcx */ --#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) -+#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) - struct pwc_table_init_buffer { - int len; - char *buffer; -- - }; --#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) -+#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) - - /* - * This is private command used when communicating with v4l2. -@@ -307,6 +309,8 @@ struct pwc_table_init_buffer { - * use interface offer by v4l2. - */ - -+#if (defined(MOTION_V4L2)) && (!defined(BSD)) -+ - #define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0) - #define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1) - #define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2) -@@ -318,12 +322,13 @@ struct pwc_table_init_buffer { - #define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8) - - struct pwc_raw_frame { -- __le16 type; /* type of the webcam */ -- __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ -- __u8 cmd[4]; /* the four byte of the command (in case of nala, -- only the first 3 bytes is filled) */ -- __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ -+ __le16 type; /* type of the webcam */ -+ __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ -+ __u8 cmd[4]; /* the four byte of the command (in case of nala, -+ only the first 3 bytes is filled) */ -+ __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ - } __attribute__ ((packed)); - -+#endif /* MOTION_V4L2 && (! BSD ) */ - - #endif ---- motion-3.2.12.orig/rotate.c -+++ motion-3.2.12/rotate.c -@@ -4,13 +4,13 @@ - * Module for handling image rotation. - * - * Copyright 2004-2005, Per Jonsson (per@pjd.nu) -- * -+ * - * This software is distributed under the GNU Public license - * Version 2. See also the file 'COPYING'. - * - * Image rotation is a feature of Motion that can be used when the - * camera is mounted upside-down or on the side. The module only -- * supports rotation in multiples of 90 degrees. Using rotation -+ * supports rotation in multiples of 90 degrees. Using rotation - * increases the Motion CPU usage slightly. - * - * Version history: -@@ -21,8 +21,8 @@ - * - fix for __bswap_32 macro collision - * - fixed bug where initialization would be - * incomplete for invalid degrees of rotation -- * - now uses motion_log for error reporting -- * v4 (26-Oct-2004) - new fix for width/height from imgs/conf due to -+ * - now uses MOTION_LOG for error reporting -+ * v4 (26-Oct-2004) - new fix for width/height from imgs/conf due to - * earlier misinterpretation - * v3 (11-Oct-2004) - cleanup of width/height from imgs/conf - * v2 (26-Sep-2004) - separation of capture/internal dimensions -@@ -49,30 +49,30 @@ typedef unsigned TYPE_32BIT __uint32; - - /** - * The code below is copied (with modification) from bits/byteswap.h. It provides -- * a macro/function named rot__bswap_32 that swaps the bytes in a 32-bit integer, -+ * a macro/function named rot__bswap_32 that swaps the bytes in a 32-bit integer, - * preferably using the bswap assembler instruction if configure found support - * for it. - * - * It would be neater to simply include byteswap.h and use the bswap_32 macro - * defined there, but the problem is that the bswap asm instruction would then -- * only be used for certain processor architectures, excluding athlon (and -+ * only be used for certain processor architectures, excluding athlon (and - * probably athlon64 as well). Moreover, byteswap.h doesn't seem to exist on - * FreeBSD. So, we rely on the HAVE_BSWAP macro defined by configure instead. - * -- * Note that the macro names have been prefixed with "rot" in order to avoid -- * collision since we have the include chain rotate.h -> motion.h -> netcam.h -> -+ * Note that the macro names have been prefixed with "rot" in order to avoid -+ * collision since we have the include chain rotate.h -> motion.h -> netcam.h -> - * netinet/in.h -> ... -> byteswap.h -> bits/byteswap.h. - */ - - /* Swap bytes in 32 bit value. This is used as a fallback and for constants. */ --#define rot__bswap_constant_32(x) \ -- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ -+#define rot__bswap_constant_32(x) \ -+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) - - #ifdef __GNUC__ - # if (__GNUC__ >= 2) && (i386 || __i386 || __i386__) --/* We're on an Intel-compatible platform, so we can use inline Intel assembler -- * for the swapping. -+/* We're on an Intel-compatible platform, so we can use inline Intel assembler -+ * for the swapping. - */ - # ifndef HAVE_BSWAP - /* Bswap is not available, we have to use three instructions instead. */ -@@ -108,7 +108,7 @@ typedef unsigned TYPE_32BIT __uint32; - # endif - #else - /* Not a GNU compiler. */ --static inline __uint32 rot__bswap_32(__uint32 __bsx) -+static inline __uint32 rot__bswap_32(__uint32 __bsx) - { - return __bswap_constant_32 (__bsx); - } -@@ -123,18 +123,18 @@ static inline __uint32 rot__bswap_32(__u - - /** - * reverse_inplace_quad -- * -+ * - * Reverses a block of memory in-place, 4 bytes at a time. This function - * requires the __uint32 type, which is 32 bits wide. - * - * Parameters: -- * -+ * - * src - the memory block to reverse - * size - the size (in bytes) of the memory block - * - * Returns: nothing - */ --static void reverse_inplace_quad(unsigned char *src, int size) -+static void reverse_inplace_quad(unsigned char *src, int size) - { - __uint32 *nsrc = (__uint32 *)src; /* first quad */ - __uint32 *ndst = (__uint32 *)(src + size - 4); /* last quad */ -@@ -149,13 +149,13 @@ static void reverse_inplace_quad(unsigne - - /** - * rot90cw -- * -- * Performs a 90 degrees clockwise rotation of the memory block pointed to -- * by src. The rotation is NOT performed in-place; dst must point to a -+ * -+ * Performs a 90 degrees clockwise rotation of the memory block pointed to -+ * by src. The rotation is NOT performed in-place; dst must point to a - * receiving memory block the same size as src. - * - * Parameters: -- * -+ * - * src - pointer to the memory block (image) to rotate clockwise - * dst - where to put the rotated memory block - * size - the size (in bytes) of the memory blocks (both src and dst) -@@ -165,7 +165,7 @@ static void reverse_inplace_quad(unsigne - * Returns: nothing - */ - static void rot90cw(unsigned char *src, register unsigned char *dst, int size, -- int width, int height) -+ int width, int height) - { - unsigned char *endp; - register unsigned char *base; -@@ -174,21 +174,21 @@ static void rot90cw(unsigned char *src, - endp = src + size; - for (base = endp - width; base < endp; base++) { - src = base; -- for (j = 0; j < height; j++, src -= width) -+ for (j = 0; j < height; j++, src -= width) - *dst++ = *src; -- -+ - } - } - - /** - * rot90ccw -- * -+ * - * Performs a 90 degrees counterclockwise rotation of the memory block pointed -- * to by src. The rotation is not performed in-place; dst must point to a -- * receiving memory block the same size as src. -+ * to by src. The rotation is not performed in-place; dst must point to a -+ * receiving memory block the same size as src. - * - * Parameters: -- * -+ * - * src - pointer to the memory block (image) to rotate counterclockwise - * dst - where to put the rotated memory block - * size - the size (in bytes) of the memory blocks (both src and dst) -@@ -198,7 +198,7 @@ static void rot90cw(unsigned char *src, - * Returns: nothing - */ - static inline void rot90ccw(unsigned char *src, register unsigned char *dst, -- int size, int width, int height) -+ int size, int width, int height) - { - unsigned char *endp; - register unsigned char *base; -@@ -206,48 +206,50 @@ static inline void rot90ccw(unsigned cha - - endp = src + size; - dst = dst + size - 1; -- for(base = endp - width; base < endp; base++) { -+ for (base = endp - width; base < endp; base++) { - src = base; -- for(j = 0; j < height; j++, src -= width) -+ for (j = 0; j < height; j++, src -= width) - *dst-- = *src; -- -+ - } - } - - /** - * rotate_init -- * -+ * - * Initializes rotation data - allocates memory and determines which function - * to use for 180 degrees rotation. - * - * Parameters: -- * -+ * - * cnt - the current thread's context structure - * - * Returns: nothing - */ --void rotate_init(struct context *cnt) -+void rotate_init(struct context *cnt) - { - int size; -- -+ - /* Make sure temp_buf isn't freed if it hasn't been allocated. */ - cnt->rotate_data.temp_buf = NULL; - -- /* Assign the value in conf.rotate_deg to rotate_data.degrees. This way, -+ /* -+ * Assign the value in conf.rotate_deg to rotate_data.degrees. This way, - * we have a value that is safe from changes caused by motion-control. - */ - if ((cnt->conf.rotate_deg % 90) > 0) { -- motion_log(LOG_ERR, 0, "Config option \"rotate\" not a multiple of 90: %d", -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Config option \"rotate\" not a multiple of 90: %d", - cnt->conf.rotate_deg); -- cnt->conf.rotate_deg = 0; /* disable rotation */ -- cnt->rotate_data.degrees = 0; /* force return below */ -+ cnt->conf.rotate_deg = 0; /* Disable rotation. */ -+ cnt->rotate_data.degrees = 0; /* Force return below. */ - } else { -- cnt->rotate_data.degrees = cnt->conf.rotate_deg % 360; /* range: 0..359 */ -+ cnt->rotate_data.degrees = cnt->conf.rotate_deg % 360; /* Range: 0..359 */ - } - -- /* Upon entrance to this function, imgs.width and imgs.height contain the -- * capture dimensions (as set in the configuration file, or read from a -- * netcam source). -+ /* -+ * Upon entrance to this function, imgs.width and imgs.height contain the -+ * capture dimensions (as set in the configuration file, or read from a -+ * netcam source). - * - * If rotating 90 or 270 degrees, the capture dimensions and output dimensions - * are not the same. Capture dimensions will be contained in cap_width and -@@ -265,86 +267,88 @@ void rotate_init(struct context *cnt) - cnt->imgs.height = cnt->rotate_data.cap_width; - } - -- /* If we're not rotating, let's exit once we have setup the capture dimensions -+ /* -+ * If we're not rotating, let's exit once we have setup the capture dimensions - * and output dimensions properly. - */ -- if (cnt->rotate_data.degrees == 0) -+ if (cnt->rotate_data.degrees == 0) - return; -- - -- switch(cnt->imgs.type) { -+ switch (cnt->imgs.type) { - case VIDEO_PALETTE_YUV420P: -- /* For YUV 4:2:0 planar, the memory block used for 90/270 degrees -- * rotation needs to be width x height x 1.5 bytes large. -+ /* -+ * For YUV 4:2:0 planar, the memory block used for 90/270 degrees -+ * rotation needs to be width x height x 1.5 bytes large. - */ - size = cnt->imgs.width * cnt->imgs.height * 3 / 2; - break; - case VIDEO_PALETTE_GREY: -- /* For greyscale, the memory block used for 90/270 degrees rotation -+ /* -+ * For greyscale, the memory block used for 90/270 degrees rotation - * needs to be width x height bytes large. - */ - size = cnt->imgs.width * cnt->imgs.height; - break; - default: - cnt->rotate_data.degrees = 0; -- motion_log(LOG_ERR, 0, "Unsupported palette (%d), rotation is disabled", -- cnt->imgs.type); -+ MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unsupported palette (%d), rotation is disabled", -+ cnt->imgs.type); - return; - } - -- /* Allocate memory if rotating 90 or 270 degrees, because those rotations -+ /* -+ * Allocate memory if rotating 90 or 270 degrees, because those rotations - * cannot be performed in-place (they can, but it would be too slow). - */ -- if ((cnt->rotate_data.degrees == 90) || (cnt->rotate_data.degrees == 270)) -+ if ((cnt->rotate_data.degrees == 90) || (cnt->rotate_data.degrees == 270)) - cnt->rotate_data.temp_buf = mymalloc(size); -- - } - --/** -+/** - * rotate_deinit -- * -- * Frees resources previously allocated by rotate_init. -+ * -+ * Frees resources previously allocated by rotate_init. - * - * Parameters: -- * -+ * - * cnt - the current thread's context structure - * - * Returns: nothing - */ --void rotate_deinit(struct context *cnt) -+void rotate_deinit(struct context *cnt) - { -- if (cnt->rotate_data.temp_buf) -+ if (cnt->rotate_data.temp_buf) - free(cnt->rotate_data.temp_buf); -- - } - - /** - * rotate_map -- * -+ * - * Main entry point for rotation. This is the function that is called from - * video.c/video_freebsd.c to perform the rotation. - * - * Parameters: -- * -+ * - * map - pointer to the image/data to rotate - * cnt - the current thread's context structure - * -- * Returns: -- * -+ * Returns: -+ * - * 0 - success - * -1 - failure (shouldn't happen) - */ - int rotate_map(struct context *cnt, unsigned char *map) - { -- /* The image format is either YUV 4:2:0 planar, in which case the pixel -+ /* -+ * The image format is either YUV 4:2:0 planar, in which case the pixel - * data is divided in three parts: - * Y - width x height bytes - * U - width x height / 4 bytes - * V - as U -- * or, it is in greyscale, in which case the pixel data simply consists -+ * or, it is in greyscale, in which case the pixel data simply consists - * of width x height bytes. - */ -- int wh, wh4 = 0, w2 = 0, h2 = 0; /* width*height, width*height/4 etc. */ -+ int wh, wh4 = 0, w2 = 0, h2 = 0; /* width * height, width * height / 4 etc. */ - int size, deg; - int width, height; - -@@ -352,7 +356,8 @@ int rotate_map(struct context *cnt, unsi - width = cnt->rotate_data.cap_width; - height = cnt->rotate_data.cap_height; - -- /* Pre-calculate some stuff: -+ /* -+ * Pre-calculate some stuff: - * wh - size of the Y plane, or the entire greyscale image - * size - size of the entire memory block - * wh4 - size of the U plane, and the V plane -@@ -360,7 +365,6 @@ int rotate_map(struct context *cnt, unsi - * h2 - as w2, but height instead - */ - wh = width * height; -- - if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { - size = wh * 3 / 2; - wh4 = wh / 4; -@@ -372,26 +376,25 @@ int rotate_map(struct context *cnt, unsi - - switch (deg) { - case 90: -- /* first do the Y part */ -+ /* First do the Y part */ - rot90cw(map, cnt->rotate_data.temp_buf, wh, width, height); -- - if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { -- /* then do U and V */ -+ /* Then do U and V */ - rot90cw(map + wh, cnt->rotate_data.temp_buf + wh, wh4, w2, h2); - rot90cw(map + wh + wh4, cnt->rotate_data.temp_buf + wh + wh4, - wh4, w2, h2); - } -- -- /* then copy back from the temp buffer to map */ -+ -+ /* Then copy back from the temp buffer to map. */ - memcpy(map, cnt->rotate_data.temp_buf, size); - break; -- -+ - case 180: -- /* 180 degrees is easy - just reverse the data within -+ /* -+ * 180 degrees is easy - just reverse the data within - * Y, U and V. - */ - reverse_inplace_quad(map, wh); -- - if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { - reverse_inplace_quad(map + wh, wh4); - reverse_inplace_quad(map + wh + wh4, wh4); -@@ -399,25 +402,25 @@ int rotate_map(struct context *cnt, unsi - break; - - case 270: -- /* first do the Y part */ -- rot90ccw(map, cnt->rotate_data.temp_buf, wh, width, height); - -+ /* First do the Y part */ -+ rot90ccw(map, cnt->rotate_data.temp_buf, wh, width, height); - if (cnt->imgs.type == VIDEO_PALETTE_YUV420P) { -- /* then do U and V */ -+ /* Then do U and V */ - rot90ccw(map + wh, cnt->rotate_data.temp_buf + wh, wh4, w2, h2); -- rot90ccw(map + wh + wh4, cnt->rotate_data.temp_buf + wh + wh4, -+ rot90ccw(map + wh + wh4, cnt->rotate_data.temp_buf + wh + wh4, - wh4, w2, h2); - } -- -- /* then copy back from the temp buffer to map */ -+ -+ /* Then copy back from the temp buffer to map. */ - memcpy(map, cnt->rotate_data.temp_buf, size); - break; -- -+ - default: -- /* invalid */ -+ /* Invalid */ - return -1; - } -- -+ - return 0; - } - ---- /dev/null -+++ motion-3.2.12/sdl.c -@@ -0,0 +1,181 @@ -+/* -+ * sdl.c -+ * -+ * sdl functions for motion. -+ * Copyright 2009 by Peter Holik (peter@holik.at) -+ * This software is distributed under the GNU public license version 2 -+ * See also the file 'COPYING'. -+ */ -+#include "sdl.h" -+#include -+ -+static int cur_width; -+static int cur_height; -+static int is_full_screen; -+static int fs_screen_width; -+static int fs_screen_height; -+ -+static SDL_Surface *screen; -+static SDL_Overlay *overlay; -+ -+static int sdl_video_open(int width, int height) -+{ -+ int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; -+ int w,h; -+ -+ if (is_full_screen) flags |= SDL_FULLSCREEN; -+ else flags |= SDL_RESIZABLE; -+ -+ if (is_full_screen && fs_screen_width) { -+ w = fs_screen_width; -+ h = fs_screen_height; -+ } else if (width > fs_screen_width || height > fs_screen_height) { -+ w = fs_screen_width; -+ h = fs_screen_height; -+ } else { -+ w = width; -+ h = height; -+ } -+ /* 32 because framebuffer is usually initalized to 8 and -+ you have to use fbset with -depth to make it working */ -+ screen = SDL_SetVideoMode(w, h, 32, flags); -+ -+ if (!screen) { -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO,"%s: Unable to set video mode: %s", -+ SDL_GetError()); -+ return -1; -+ } -+ -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL dimension %d x %d fullscreen %d BytesPerPixel %d", -+ screen->w, screen->h, is_full_screen, -+ screen->format->BytesPerPixel); -+ -+ SDL_WM_SetCaption("motion", "motion"); -+ SDL_ShowCursor(SDL_DISABLE); -+ -+ if (cur_width != width || cur_height != height) { -+ cur_width = width; -+ cur_height = height; -+ -+ if (overlay) SDL_FreeYUVOverlay(overlay); -+ -+ overlay = SDL_CreateYUVOverlay(cur_width, cur_height, -+ SDL_YV12_OVERLAY, screen); -+ if (!overlay) { -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not create overlay: %s", -+ SDL_GetError()); -+ sdl_stop(); -+ } else -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL created %dx%dx%d %s overlay", -+ overlay->w,overlay->h,overlay->planes, -+ overlay->hw_overlay?"hardware":"software"); -+ } -+ return overlay == NULL; -+} -+ -+int sdl_start(int width, int height) -+{ -+ //putenv("SDL_NOMOUSE=1"); -+ setenv("SDL_NOMOUSE", "1", 1); -+ -+ if (screen) return 0; -+ -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL start"); -+ -+ if (SDL_Init(SDL_INIT_VIDEO)) { -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not initialize SDL - %s", -+ SDL_GetError()); -+ return -1; -+ } -+ const SDL_VideoInfo *vi = SDL_GetVideoInfo(); -+ fs_screen_width = vi->current_w; -+ fs_screen_height = vi->current_h; -+ -+ if (sdl_video_open(width, height)) return -1; -+ -+ SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); -+ SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); -+ SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); -+ SDL_EventState(SDL_USEREVENT, SDL_IGNORE); -+ SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); -+ SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); -+ SDL_EventState(SDL_KEYUP, SDL_IGNORE); -+ SDL_EventState(SDL_JOYBUTTONDOWN, SDL_IGNORE); -+ SDL_EventState(SDL_JOYBUTTONUP, SDL_IGNORE); -+ SDL_EventState(SDL_JOYAXISMOTION, SDL_IGNORE); -+ SDL_EventState(SDL_JOYBALLMOTION, SDL_IGNORE); -+ SDL_EventState(SDL_JOYHATMOTION, SDL_IGNORE); -+ SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE); -+ -+ return 0; -+} -+ -+void sdl_put(unsigned char *image, int width, int height) -+{ -+ SDL_Event event; -+ -+ if (screen && overlay) { -+ SDL_Rect rect; -+ float aspect_ratio = (float)width / height; -+ int pic_width, pic_height; -+ -+ if (width != cur_width || height != cur_height) -+ sdl_video_open(width, height); -+ -+ if (SDL_MUSTLOCK(screen)) -+ if (SDL_LockSurface(screen) < 0) return; -+ -+ SDL_LockYUVOverlay(overlay); -+ memcpy(overlay->pixels[0], image, width * height); -+ memcpy(overlay->pixels[2], image + (width * height), (width * height / 4)); -+ memcpy(overlay->pixels[1], image + (width * height * 5 / 4), (width * height / 4)); -+ SDL_UnlockYUVOverlay(overlay); -+ -+ if (SDL_MUSTLOCK(screen)) -+ SDL_UnlockSurface(screen); -+ -+ pic_height = screen->h; -+ pic_width = pic_height * aspect_ratio; -+ if (pic_width > screen->w) { -+ pic_width = screen->w; -+ pic_height = pic_width / aspect_ratio; -+ } -+ rect.x = (screen->w - pic_width) / 2; -+ rect.y = (screen->h - pic_height) / 2; -+ rect.w = pic_width; -+ rect.h = pic_height; -+ -+ if (SDL_DisplayYUVOverlay(overlay, &rect)) -+ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: SDL_DisplayYUVOverlay: %s", -+ SDL_GetError()); -+ -+ if (SDL_PollEvent(&event)) { -+ if ((event.type == SDL_QUIT || -+ (event.type == SDL_KEYDOWN && -+ event.key.keysym.sym == SDLK_ESCAPE))) -+ sdl_stop(); -+ else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_f) { -+ is_full_screen = !is_full_screen; -+ sdl_video_open(width, height); -+ } -+ else if (event.type == SDL_VIDEORESIZE) -+ screen = SDL_SetVideoMode(event.resize.w, event.resize.h, -+ screen->format->BitsPerPixel, -+ screen->flags); -+ } -+ } -+} -+ -+void sdl_stop(void) -+{ -+ if (screen) { -+ MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL quit"); -+ SDL_ShowCursor(SDL_ENABLE); -+ if (overlay) { -+ SDL_FreeYUVOverlay(overlay); -+ overlay = NULL; -+ } -+ SDL_Quit(); -+ screen = NULL; -+ } -+} ---- /dev/null -+++ motion-3.2.12/sdl.h -@@ -0,0 +1,17 @@ -+/* sdl.h -+ * -+ * Include file for sdl.c -+ * Copyright 2009 by Peter Holik (peter@holik.at) -+ * This software is distributed under the GNU public license version 2 -+ * See also the file 'COPYING'. -+ */ -+#ifndef _INCLUDE_SDL_H -+#define _INCLUDE_SDL_H -+ -+#include "motion.h" -+ -+int sdl_start(int width, int height); -+void sdl_put(unsigned char *image, int width, int height); -+void sdl_stop(void); -+ -+#endif ---- /dev/null -+++ motion-3.2.12/stream.c -@@ -0,0 +1,1221 @@ -+/* -+ * stream.c (based in webcam.c) -+ * Streaming using jpeg images over a multipart/x-mixed-replace stream -+ * Copyright (C) 2002 Jeroen Vreeken (pe1rxq@amsat.org) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+ -+#include "md5.h" -+#include "picture.h" -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define STREAM_REALM "Motion Stream Security Access" -+#define KEEP_ALIVE_TIMEOUT 100 -+ -+typedef void* (*auth_handler)(void*); -+struct auth_param { -+ struct context *cnt; -+ int sock; -+ int sock_flags; -+ int* thread_count; -+ struct config *conf; -+}; -+ -+pthread_mutex_t stream_auth_mutex; -+ -+/** -+ * set_sock_timeout -+ * -+ * Returns : 0 or 1 on timeout -+ */ -+static int set_sock_timeout(int sock, int sec) -+{ -+ struct timeval tv; -+ -+ tv.tv_sec = sec; -+ tv.tv_usec = 0; -+ -+ if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*) &tv, sizeof(tv))) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: set socket timeout failed"); -+ return 1; -+ } -+ return 0; -+} -+ -+/** -+ * read_http_request -+ * -+ * -+ * Returns : 1 on success or 0 if any error happens -+ */ -+static int read_http_request(int sock, char* buffer, int buflen, char* uri, int uri_len) -+{ -+ int nread = 0; -+ int ret,readb = 1; -+ char method[10] = {'\0'}; -+ char url[512] = {'\0'}; -+ char protocol[10] = {'\0'}; -+ -+ static const char *bad_request_response_raw = -+ "HTTP/1.0 400 Bad Request\r\n" -+ "Content-type: text/plain\r\n\r\n" -+ "Bad Request\n"; -+ -+ static const char *bad_method_response_template_raw = -+ "HTTP/1.0 501 Method Not Implemented\r\n" -+ "Content-type: text/plain\r\n\r\n" -+ "Method Not Implemented\n"; -+ -+ static const char *timeout_response_template_raw = -+ "HTTP/1.0 408 Request Timeout\r\n" -+ "Content-type: text/plain\r\n\r\n" -+ "Request Timeout\n"; -+ -+ buffer[0] = '\0'; -+ -+ while ((strstr(buffer, "\r\n\r\n") == NULL) && (readb != 0) && (nread < buflen)) { -+ -+ readb = read(sock, buffer+nread, buflen - nread); -+ -+ if (readb == -1) { -+ nread = -1; -+ break; -+ } -+ -+ nread += readb; -+ -+ if (nread > buflen) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream End buffer reached" -+ " waiting for buffer ending"); -+ break; -+ } -+ -+ buffer[nread] = '\0'; -+ } -+ -+ /* -+ * Make sure the last read didn't fail. If it did, there's a -+ * problem with the connection, so give up. -+ */ -+ if (nread == -1) { -+ if(errno == EAGAIN) { // Timeout -+ ret = write(sock, timeout_response_template_raw, strlen(timeout_response_template_raw)); -+ return 0; -+ } -+ -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream READ give up!"); -+ return 0; -+ } -+ -+ ret = sscanf(buffer, "%9s %511s %9s", method, url, protocol); -+ -+ if (ret != 3) { -+ ret = write(sock, bad_request_response_raw, sizeof(bad_request_response_raw)); -+ return 0; -+ } -+ -+ /* Check Protocol */ -+ if (strcmp(protocol, "HTTP/1.0") && strcmp (protocol, "HTTP/1.1")) { -+ /* We don't understand this protocol. Report a bad response. */ -+ ret = write(sock, bad_request_response_raw, sizeof(bad_request_response_raw)); -+ return 0; -+ } -+ -+ if (strcmp(method, "GET")) { -+ /* -+ * This server only implements the GET method. If client -+ * uses other method, report the failure. -+ */ -+ char response[1024]; -+ snprintf(response, sizeof(response), bad_method_response_template_raw, method); -+ ret = write(sock, response, strlen (response)); -+ -+ return 0; -+ } -+ -+ if(uri) -+ strncpy(uri, url, uri_len); -+ -+ return 1; -+} -+ -+static void stream_add_client(struct stream *list, int sc); -+ -+/** -+ * handle_basic_auth -+ * -+ * -+ */ -+static void* handle_basic_auth(void* param) -+{ -+ struct auth_param *p = (struct auth_param*)param; -+ char buffer[1024] = {'\0'}; -+ ssize_t length = 1023; -+ char *auth, *h, *authentication; -+ static const char *request_auth_response_template= -+ "HTTP/1.0 401 Authorization Required\r\n" -+ "Server: Motion/"VERSION"\r\n" -+ "Max-Age: 0\r\n" -+ "Expires: 0\r\n" -+ "Cache-Control: no-cache, private\r\n" -+ "Pragma: no-cache\r\n" -+ "WWW-Authenticate: Basic realm=\""STREAM_REALM"\"\r\n\r\n"; -+ -+ pthread_mutex_lock(&stream_auth_mutex); -+ p->thread_count++; -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ if (!read_http_request(p->sock,buffer, length, NULL, 0)) -+ goto Invalid_Request; -+ -+ -+ auth = strstr(buffer, "Authorization: Basic"); -+ -+ if (!auth) -+ goto Error; -+ -+ auth += sizeof("Authorization: Basic"); -+ h = strstr(auth, "\r\n"); -+ -+ if(!h) -+ goto Error; -+ -+ *h='\0'; -+ -+ if (p->conf->stream_authentication != NULL) { -+ -+ char *userpass = NULL; -+ size_t auth_size = strlen(p->conf->stream_authentication); -+ -+ authentication = (char *) mymalloc(BASE64_LENGTH(auth_size) + 1); -+ userpass = mymalloc(auth_size + 4); -+ /* base64_encode can read 3 bytes after the end of the string, initialize it. */ -+ memset(userpass, 0, auth_size + 4); -+ strcpy(userpass, p->conf->stream_authentication); -+ base64_encode(userpass, authentication, auth_size); -+ free(userpass); -+ -+ if (strcmp(auth, authentication)) { -+ free(authentication); -+ goto Error; -+ } -+ free(authentication); -+ } -+ -+ // OK - Access -+ -+ /* Set socket to non blocking */ -+ if (fcntl(p->sock, F_SETFL, p->sock_flags) < 0) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); -+ goto Error; -+ } -+ -+ /* Lock the mutex */ -+ pthread_mutex_lock(&stream_auth_mutex); -+ -+ stream_add_client(&p->cnt->stream, p->sock); -+ p->cnt->stream_count++; -+ p->thread_count--; -+ -+ /* Unlock the mutex */ -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ free(p); -+ pthread_exit(NULL); -+ -+Error: -+ if (write(p->sock, request_auth_response_template, strlen (request_auth_response_template)) < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 1:handle_basic_auth"); -+ -+Invalid_Request: -+ close(p->sock); -+ -+ pthread_mutex_lock(&stream_auth_mutex); -+ p->thread_count--; -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ free(p); -+ pthread_exit(NULL); -+} -+ -+ -+#define HASHLEN 16 -+typedef char HASH[HASHLEN]; -+#define HASHHEXLEN 32 -+typedef char HASHHEX[HASHHEXLEN+1]; -+#define IN -+#define OUT -+/** -+ * CvtHex -+ * Calculates H(A1) as per HTTP Digest spec -- taken from RFC 2617. -+ */ -+static void CvtHex(IN HASH Bin, OUT HASHHEX Hex) -+{ -+ unsigned short i; -+ unsigned char j; -+ -+ for (i = 0; i < HASHLEN; i++) { -+ j = (Bin[i] >> 4) & 0xf; -+ if (j <= 9) -+ Hex[i*2] = (j + '0'); -+ else -+ Hex[i*2] = (j + 'a' - 10); -+ j = Bin[i] & 0xf; -+ if (j <= 9) -+ Hex[i*2+1] = (j + '0'); -+ else -+ Hex[i*2+1] = (j + 'a' - 10); -+ }; -+ Hex[HASHHEXLEN] = '\0'; -+}; -+ -+/** -+ * DigestCalcHA1 -+ * Calculates H(A1) as per spec. -+ */ -+static void DigestCalcHA1( -+ IN char * pszAlg, -+ IN char * pszUserName, -+ IN char * pszRealm, -+ IN char * pszPassword, -+ IN char * pszNonce, -+ IN char * pszCNonce, -+ OUT HASHHEX SessionKey -+ ) -+{ -+ MD5_CTX Md5Ctx; -+ HASH HA1; -+ -+ MD5Init(&Md5Ctx); -+ MD5Update(&Md5Ctx, (unsigned char *)pszUserName, strlen(pszUserName)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszRealm, strlen(pszRealm)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszPassword, strlen(pszPassword)); -+ MD5Final((unsigned char *)HA1, &Md5Ctx); -+ -+ if (strcmp(pszAlg, "md5-sess") == 0) { -+ MD5Init(&Md5Ctx); -+ MD5Update(&Md5Ctx, (unsigned char *)HA1, HASHLEN); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszNonce, strlen(pszNonce)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszCNonce, strlen(pszCNonce)); -+ MD5Final((unsigned char *)HA1, &Md5Ctx); -+ }; -+ CvtHex(HA1, SessionKey); -+}; -+ -+/** -+ * DigestCalcResponse -+ * Calculates request-digest/response-digest as per HTTP Digest spec. -+ */ -+static void DigestCalcResponse( -+ IN HASHHEX HA1, /* H(A1) */ -+ IN char * pszNonce, /* nonce from server */ -+ IN char * pszNonceCount, /* 8 hex digits */ -+ IN char * pszCNonce, /* client nonce */ -+ IN char * pszQop, /* qop-value: "", "auth", "auth-int" */ -+ IN char * pszMethod, /* method from the request */ -+ IN char * pszDigestUri, /* requested URL */ -+ IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */ -+ OUT HASHHEX Response /* request-digest or response-digest */ -+ ) -+{ -+ MD5_CTX Md5Ctx; -+ HASH HA2; -+ HASH RespHash; -+ HASHHEX HA2Hex; -+ -+ // Calculate H(A2) -+ MD5Init(&Md5Ctx); -+ MD5Update(&Md5Ctx, (unsigned char *)pszMethod, strlen(pszMethod)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszDigestUri, strlen(pszDigestUri)); -+ -+ if (strcmp(pszQop, "auth-int") == 0) { -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)HEntity, HASHHEXLEN); -+ } -+ MD5Final((unsigned char *)HA2, &Md5Ctx); -+ CvtHex(HA2, HA2Hex); -+ -+ // Calculate response -+ MD5Init(&Md5Ctx); -+ MD5Update(&Md5Ctx, (unsigned char *)HA1, HASHHEXLEN); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszNonce, strlen(pszNonce)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ -+ if (*pszQop) { -+ MD5Update(&Md5Ctx, (unsigned char *)pszNonceCount, strlen(pszNonceCount)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszCNonce, strlen(pszCNonce)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ MD5Update(&Md5Ctx, (unsigned char *)pszQop, strlen(pszQop)); -+ MD5Update(&Md5Ctx, (unsigned char *)":", 1); -+ } -+ MD5Update(&Md5Ctx, (unsigned char *)HA2Hex, HASHHEXLEN); -+ MD5Final((unsigned char *)RespHash, &Md5Ctx); -+ CvtHex(RespHash, Response); -+}; -+ -+ -+/** -+ * handle_md5_digest -+ * -+ * -+ */ -+static void* handle_md5_digest(void* param) -+{ -+ struct auth_param *p = (struct auth_param*)param; -+ char buffer[1024] = {'\0'}; -+ ssize_t length = 1023; -+ char *auth, *h, *username, *realm, *uri, *nonce, *response; -+ int username_len, realm_len, uri_len, nonce_len, response_len; -+#define SERVER_NONCE_LEN 17 -+ char server_nonce[SERVER_NONCE_LEN]; -+#define SERVER_URI_LEN 512 -+ char server_uri[SERVER_URI_LEN]; -+ char* server_user = NULL, *server_pass = NULL; -+ unsigned int rand1,rand2; -+ HASHHEX HA1; -+ HASHHEX HA2 = ""; -+ HASHHEX server_response; -+ static const char *request_auth_response_template= -+ "HTTP/1.0 401 Authorization Required\r\n" -+ "Server: Motion/"VERSION"\r\n" -+ "Max-Age: 0\r\n" -+ "Expires: 0\r\n" -+ "Cache-Control: no-cache, private\r\n" -+ "Pragma: no-cache\r\n" -+ "WWW-Authenticate: Digest"; -+ static const char *auth_failed_html_template= -+ "\r\n" -+ "\r\n" -+ "401 Authorization Required\r\n" -+ "\r\n" -+ "

                                                              Authorization Required

                                                              \r\n" -+ "This server could not verify that you are authorized to access the document " -+ "requested. Either you supplied the wrong credentials (e.g., bad password), " -+ "or your browser doesn't understand how to supply the credentials required.\r\n" -+ "\r\n"; -+ static const char *internal_error_template= -+ "HTTP/1.0 500 Internal Server Error\r\n" -+ "Server: Motion/"VERSION"\r\n" -+ "Content-Type: text/html\r\n" -+ "Connection: Close\r\n\r\n" -+ "\r\n" -+ "\r\n" -+ "500 Internal Server Error\r\n" -+ "\r\n" -+ "

                                                              500 Internal Server Error

                                                              \r\n" -+ "\r\n"; -+ -+ pthread_mutex_lock(&stream_auth_mutex); -+ p->thread_count++; -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ set_sock_timeout(p->sock, KEEP_ALIVE_TIMEOUT); -+ srand(time(NULL)); -+ rand1 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); -+ rand2 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); -+ snprintf(server_nonce, SERVER_NONCE_LEN, "%08x%08x", rand1, rand2); -+ -+ if (!p->conf->stream_authentication) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error no authentication data"); -+ goto InternalError; -+ } -+ h = strstr(p->conf->stream_authentication, ":"); -+ -+ if (!h) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error no authentication data (no ':' found)"); -+ goto InternalError; -+ } -+ -+ server_user = (char*)malloc((h - p->conf->stream_authentication) + 1); -+ server_pass = (char*)malloc(strlen(h) + 1); -+ -+ if (!server_user || !server_pass) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error malloc failed"); -+ goto InternalError; -+ } -+ -+ strncpy(server_user, p->conf->stream_authentication, h-p->conf->stream_authentication); -+ server_user[h - p->conf->stream_authentication] = '\0'; -+ strncpy(server_pass, h + 1, strlen(h + 1)); -+ server_pass[strlen(h + 1)] = '\0'; -+ -+ while(1) { -+ if(!read_http_request(p->sock, buffer, length, server_uri, SERVER_URI_LEN - 1)) -+ goto Invalid_Request; -+ -+ auth = strstr(buffer, "Authorization: Digest"); -+ if(!auth) -+ goto Error; -+ -+ auth += sizeof("Authorization: Digest"); -+ h = strstr(auth, "\r\n"); -+ -+ if (!h) -+ goto Error; -+ *h = '\0'; -+ -+ // Username -+ h=strstr(auth, "username=\""); -+ -+ if (!h) -+ goto Error; -+ -+ username = h + 10; -+ h = strstr(username + 1, "\""); -+ -+ if (!h) -+ goto Error; -+ -+ username_len = h - username; -+ -+ // Realm -+ h = strstr(auth, "realm=\""); -+ if (!h) -+ goto Error; -+ -+ realm = h + 7; -+ h = strstr(realm + 1, "\""); -+ -+ if (!h) -+ goto Error; -+ -+ realm_len = h - realm; -+ -+ // URI -+ h = strstr(auth, "uri=\""); -+ -+ if (!h) -+ goto Error; -+ -+ uri = h + 5; -+ h = strstr(uri + 1, "\""); -+ -+ if (!h) -+ goto Error; -+ -+ uri_len = h - uri; -+ -+ // Nonce -+ h = strstr(auth, "nonce=\""); -+ -+ if (!h) -+ goto Error; -+ -+ nonce = h + 7; -+ h = strstr(nonce + 1, "\""); -+ -+ if (!h) -+ goto Error; -+ -+ nonce_len = h - nonce; -+ -+ // Response -+ h = strstr(auth, "response=\""); -+ -+ if (!h) -+ goto Error; -+ -+ response = h + 10; -+ h = strstr(response + 1, "\""); -+ -+ if (!h) -+ goto Error; -+ -+ response_len = h - response; -+ -+ username[username_len] = '\0'; -+ realm[realm_len] = '\0'; -+ uri[uri_len] = '\0'; -+ nonce[nonce_len] = '\0'; -+ response[response_len] = '\0'; -+ -+ DigestCalcHA1((char*)"md5", server_user, (char*)STREAM_REALM, server_pass, (char*)server_nonce, (char*)NULL, HA1); -+ DigestCalcResponse(HA1, server_nonce, NULL, NULL, (char*)"", (char*)"GET", server_uri, HA2, server_response); -+ -+ if (strcmp(server_response, response) == 0) -+ break; -+Error: -+ rand1 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); -+ rand2 = (unsigned int)(42000000.0 * rand() / (RAND_MAX + 1.0)); -+ snprintf(server_nonce, SERVER_NONCE_LEN, "%08x%08x", rand1, rand2); -+ snprintf(buffer, length, "%s realm=\""STREAM_REALM"\", nonce=\"%s\"\r\n" -+ "Content-Type: text/html\r\n" -+ "Keep-Alive: timeout=%i\r\n" -+ "Connection: keep-alive\r\n" -+ "Content-Length: %Zu\r\n\r\n", -+ request_auth_response_template, server_nonce, -+ KEEP_ALIVE_TIMEOUT, strlen(auth_failed_html_template)); -+ if (write(p->sock, buffer, strlen(buffer)) < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 1:handle_md5_digest"); -+ if (write(p->sock, auth_failed_html_template, strlen(auth_failed_html_template)) < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 2:handle_md5_digest"); -+ } -+ -+ // OK - Access -+ -+ /* Set socket to non blocking */ -+ if (fcntl(p->sock, F_SETFL, p->sock_flags) < 0) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); -+ goto Error; -+ } -+ -+ if(server_user) -+ free(server_user); -+ -+ if(server_pass) -+ free(server_pass); -+ -+ /* Lock the mutex */ -+ pthread_mutex_lock(&stream_auth_mutex); -+ -+ stream_add_client(&p->cnt->stream, p->sock); -+ p->cnt->stream_count++; -+ -+ p->thread_count--; -+ /* Unlock the mutex */ -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ free(p); -+ pthread_exit(NULL); -+ -+InternalError: -+ if(server_user) -+ free(server_user); -+ -+ if(server_pass) -+ free(server_pass); -+ -+ if (write(p->sock, internal_error_template, strlen(internal_error_template)) < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 3:handle_md5_digest"); -+ -+Invalid_Request: -+ close(p->sock); -+ -+ pthread_mutex_lock(&stream_auth_mutex); -+ p->thread_count--; -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ free(p); -+ pthread_exit(NULL); -+} -+ -+/** -+ * do_client_auth -+ * -+ * -+ */ -+static void do_client_auth(struct context *cnt, int sc) -+{ -+ pthread_t thread_id; -+ pthread_attr_t attr; -+ auth_handler handle_func; -+ struct auth_param* handle_param = NULL; -+ int flags; -+ static int first_call = 0; -+ static int thread_count = 0; -+ -+ if(first_call == 0) { -+ first_call = 1; -+ /* Initialize the mutex */ -+ pthread_mutex_init(&stream_auth_mutex, NULL); -+ } -+ -+ switch(cnt->conf.stream_auth_method) -+ { -+ case 1: // Basic -+ handle_func = handle_basic_auth; -+ break; -+ case 2: // MD5 Digest -+ handle_func = handle_md5_digest; -+ break; -+ default: -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error unknown stream authentication method"); -+ goto Error; -+ break; -+ } -+ -+ handle_param = mymalloc(sizeof(struct auth_param)); -+ handle_param->cnt = cnt; -+ handle_param->sock = sc; -+ handle_param->conf = &cnt->conf; -+ handle_param->thread_count = &thread_count; -+ -+ /* Set socket to blocking */ -+ if ((flags = fcntl(sc, F_GETFL, 0)) < 0) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); -+ goto Error; -+ } -+ handle_param->sock_flags = flags; -+ -+ if (fcntl(sc, F_SETFL, flags & (~O_NONBLOCK)) < 0) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: fcntl"); -+ goto Error; -+ } -+ -+ if (thread_count >= DEF_MAXSTREAMS) -+ goto Error; -+ -+ if (pthread_attr_init(&attr)) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error pthread_attr_init"); -+ goto Error; -+ } -+ -+ if (pthread_create(&thread_id, &attr, handle_func, handle_param)) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error pthread_create"); -+ goto Error; -+ } -+ pthread_detach(thread_id); -+ -+ if (pthread_attr_destroy(&attr)) -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error pthread_attr_destroy"); -+ -+ return; -+ -+Error: -+ close(sc); -+ if(handle_param) -+ free(handle_param); -+} -+ -+/** -+ * http_bindsock -+ * Sets up a TCP/IP socket for incoming requests. It is called only during -+ * initialisation of Motion from the function stream_init -+ * The function sets up a a socket on the port number given by _port_. -+ * If the parameter _local_ is not zero the socket is setup to only accept connects from localhost. -+ * Otherwise any client IP address is accepted. The function returns an integer representing the socket. -+ * -+ * Returns: socket descriptor or -1 if any error happens -+ */ -+int http_bindsock(int port, int local, int ipv6_enabled) -+{ -+ int sl = -1, optval; -+ struct addrinfo hints, *res = NULL, *ressave = NULL; -+ char portnumber[10], hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; -+ -+ snprintf(portnumber, sizeof(portnumber), "%u", port); -+ memset(&hints, 0, sizeof(struct addrinfo)); -+ -+ /* Use the AI_PASSIVE flag, which indicates we are using this address for a listen() */ -+ hints.ai_flags = AI_PASSIVE; -+#if defined(BSD) -+ hints.ai_family = AF_INET; -+#else -+ if (!ipv6_enabled) -+ hints.ai_family = AF_INET; -+ else -+ hints.ai_family = AF_UNSPEC; -+#endif -+ hints.ai_socktype = SOCK_STREAM; -+ -+ optval = getaddrinfo(local ? "localhost" : NULL, portnumber, &hints, &res); -+ -+ if (optval != 0) { -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: getaddrinfo() for motion-stream socket failed: %s", -+ gai_strerror(optval)); -+ -+ if (res != NULL) -+ freeaddrinfo(res); -+ return -1; -+ } -+ -+ ressave = res; -+ -+ while (res) { -+ /* Create socket */ -+ sl = socket(res->ai_family, res->ai_socktype, res->ai_protocol); -+ -+ getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, -+ sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV); -+ -+ if (sl >= 0) { -+ optval = 1; -+ /* Reuse Address */ -+ setsockopt(sl, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)); -+ -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-stream testing : %s addr: %s port: %s", -+ res->ai_family == AF_INET ? "IPV4":"IPV6", hbuf, sbuf); -+ -+ if (bind(sl, res->ai_addr, res->ai_addrlen) == 0) { -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-stream Bound : %s addr: %s port: %s", -+ res->ai_family == AF_INET ? "IPV4":"IPV6", hbuf, sbuf); -+ break; -+ } -+ -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream bind() failed, retrying"); -+ close(sl); -+ sl = -1; -+ } -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream socket failed, retrying"); -+ res = res->ai_next; -+ } -+ -+ freeaddrinfo(ressave); -+ -+ if (sl < 0) { -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream creating socket/bind ERROR"); -+ return -1; -+ } -+ -+ -+ if (listen(sl, DEF_MAXWEBQUEUE) == -1) { -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream listen() ERROR"); -+ close(sl); -+ sl = -1; -+ } -+ -+ return sl; -+} -+ -+/** -+ * http_acceptsock -+ * -+ * -+ * Returns: socket descriptor or -1 if any error happens. -+ */ -+static int http_acceptsock(int sl) -+{ -+ int sc; -+ unsigned long i; -+ struct sockaddr_storage sin; -+ socklen_t addrlen = sizeof(sin); -+ -+ if ((sc = accept(sl, (struct sockaddr *)&sin, &addrlen)) >= 0) { -+ i = 1; -+ ioctl(sc, FIONBIO, &i); -+ return sc; -+ } -+ -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-stream accept()"); -+ -+ return -1; -+} -+ -+ -+/** -+ * stream_flush -+ * Sends any outstanding data to all connected clients. -+ * It continuously goes through the client list until no data is able -+ * to be sent (either because there isn't any, or because the clients -+ * are not able to accept it). -+ */ -+static void stream_flush(struct stream *list, int *stream_count, int lim) -+{ -+ int written; /* The number of bytes actually written. */ -+ struct stream *client; /* Pointer to the client being served. */ -+ int workdone = 0; /* Flag set any time data is successfully -+ written. */ -+ -+ client = list->next; -+ -+ while (client) { -+ -+ /* If data waiting for client, try to send it. */ -+ if (client->tmpbuffer) { -+ -+ /* -+ * We expect that list->filepos < list->tmpbuffer->size -+ * should always be true. The check is more for safety, -+ * in case of trouble is some other part of the code. -+ * Note that if it is false, the following section will -+ * clean up. -+ */ -+ if (client->filepos < client->tmpbuffer->size) { -+ -+ /* -+ * Here we are finally ready to write out the -+ * data. Remember that (because the socket -+ * has been set non-blocking) we may only -+ * write out part of the buffer. The var -+ * 'filepos' contains how much of the buffer -+ * has already been written. -+ */ -+ written = write(client->socket, -+ client->tmpbuffer->ptr + client->filepos, -+ client->tmpbuffer->size - client->filepos); -+ -+ /* -+ * If any data has been written, update the -+ * data pointer and set the workdone flag. -+ */ -+ if (written > 0) { -+ client->filepos += written; -+ workdone = 1; -+ } -+ } else -+ written = 0; -+ -+ /* -+ * If we have written the entire buffer to the socket, -+ * or if there was some error (other than EAGAIN, which -+ * means the system couldn't take it), this request is -+ * finished. -+ */ -+ if ((client->filepos >= client->tmpbuffer->size) || -+ (written < 0 && errno != EAGAIN)) { -+ /* If no other clients need this buffer, free it. */ -+ if (--client->tmpbuffer->ref <= 0) { -+ free(client->tmpbuffer->ptr); -+ free(client->tmpbuffer); -+ } -+ -+ /* Mark this client's buffer as empty. */ -+ client->tmpbuffer = NULL; -+ client->nr++; -+ } -+ -+ /* -+ * If the client is no longer connected, or the total -+ * number of frames already sent to this client is -+ * greater than our configuration limit, disconnect -+ * the client and free the stream struct. -+ */ -+ if ((written < 0 && errno != EAGAIN) || -+ (lim && !client->tmpbuffer && client->nr > lim)) { -+ void *tmp; -+ -+ close(client->socket); -+ -+ if (client->next) -+ client->next->prev = client->prev; -+ -+ client->prev->next = client->next; -+ tmp = client; -+ client = client->prev; -+ free(tmp); -+ (*stream_count)--; -+ } -+ } /* End if (client->tmpbuffer) */ -+ -+ /* -+ * Step the the next client in the list. If we get to the -+ * end of the list, check if anything was written during -+ * that loop; (if so) reset the 'workdone' flag and go back -+ * to the beginning. -+ */ -+ client = client->next; -+ -+ if (!client && workdone) { -+ client = list->next; -+ workdone = 0; -+ } -+ } /* End while (client) */ -+} -+ -+/** -+ * stream_tmpbuffer -+ * Routine to create a new "tmpbuffer", which is a common -+ * object used by all clients connected to a single camera. -+ * -+ * Returns: new allocated stream_buffer. -+ */ -+static struct stream_buffer *stream_tmpbuffer(int size) -+{ -+ struct stream_buffer *tmpbuffer = mymalloc(sizeof(struct stream_buffer)); -+ tmpbuffer->ref = 0; -+ tmpbuffer->ptr = mymalloc(size); -+ -+ return tmpbuffer; -+} -+ -+/** -+ * stream_add_client -+ * -+ * -+ */ -+static void stream_add_client(struct stream *list, int sc) -+{ -+ struct stream *new = mymalloc(sizeof(struct stream)); -+ static const char header[] = "HTTP/1.0 200 OK\r\n" -+ "Server: Motion/"VERSION"\r\n" -+ "Connection: close\r\n" -+ "Max-Age: 0\r\n" -+ "Expires: 0\r\n" -+ "Cache-Control: no-cache, private\r\n" -+ "Pragma: no-cache\r\n" -+ "Content-Type: multipart/x-mixed-replace; " -+ "boundary=BoundaryString\r\n\r\n"; -+ -+ memset(new, 0, sizeof(struct stream)); -+ new->socket = sc; -+ -+ if ((new->tmpbuffer = stream_tmpbuffer(sizeof(header))) == NULL) { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error creating tmpbuffer in stream_add_client"); -+ } else { -+ memcpy(new->tmpbuffer->ptr, header, sizeof(header)-1); -+ new->tmpbuffer->size = sizeof(header)-1; -+ } -+ -+ new->prev = list; -+ new->next = list->next; -+ -+ if (new->next) -+ new->next->prev = new; -+ -+ list->next = new; -+} -+ -+/** -+ * stream_add_write -+ * -+ * -+ */ -+static void stream_add_write(struct stream *list, struct stream_buffer *tmpbuffer, unsigned int fps) -+{ -+ struct timeval curtimeval; -+ unsigned long int curtime; -+ -+ gettimeofday(&curtimeval, NULL); -+ curtime = curtimeval.tv_usec + 1000000L * curtimeval.tv_sec; -+ -+ while (list->next) { -+ list = list->next; -+ -+ if (list->tmpbuffer == NULL && ((curtime - list->last) >= 1000000L / fps)) { -+ list->last = curtime; -+ list->tmpbuffer = tmpbuffer; -+ tmpbuffer->ref++; -+ list->filepos = 0; -+ } -+ } -+ -+ if (tmpbuffer->ref <= 0) { -+ free(tmpbuffer->ptr); -+ free(tmpbuffer); -+ } -+} -+ -+ -+/** -+ * stream_check_write -+ * We walk through the chain of stream structs until we reach the end. -+ * Here we check if the tmpbuffer points to NULL. -+ * We return 1 if it finds a list->tmpbuffer which is a NULL pointer which would -+ * be the next client ready to be sent a new image. If not a 0 is returned. -+ * -+ * Returns: -+ */ -+static int stream_check_write(struct stream *list) -+{ -+ while (list->next) { -+ list = list->next; -+ -+ if (list->tmpbuffer == NULL) -+ return 1; -+ } -+ return 0; -+} -+ -+ -+/** -+ * stream_init -+ * This function is called from motion.c for each motion thread starting up. -+ * The function setup the incoming tcp socket that the clients connect to. -+ * The function returns an integer representing the socket. -+ * -+ * Returns: stream socket descriptor. -+ */ -+int stream_init(struct context *cnt) -+{ -+ cnt->stream.socket = http_bindsock(cnt->conf.stream_port, cnt->conf.stream_localhost, -+ cnt->conf.ipv6_enabled); -+ cnt->stream.next = NULL; -+ cnt->stream.prev = NULL; -+ return cnt->stream.socket; -+} -+ -+/** -+ * stream_stop -+ * This function is called from the motion_loop when it ends -+ * and motion is terminated or restarted. -+ */ -+void stream_stop(struct context *cnt) -+{ -+ struct stream *list; -+ struct stream *next = cnt->stream.next; -+ -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: Closing motion-stream listen socket" -+ " & active motion-stream sockets"); -+ -+ close(cnt->stream.socket); -+ cnt->stream.socket = -1; -+ -+ while (next) { -+ list = next; -+ next = list->next; -+ -+ if (list->tmpbuffer) { -+ free(list->tmpbuffer->ptr); -+ free(list->tmpbuffer); -+ } -+ -+ close(list->socket); -+ free(list); -+ } -+ -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: Closed motion-stream listen socket" -+ " & active motion-stream sockets"); -+} -+ -+/* -+ * stream_put -+ * Is the starting point of the stream loop. It is called from -+ * the motion_loop with the argument 'image' pointing to the latest frame. -+ * If config option 'stream_motion' is 'on' this function is called once -+ * per second (frame 0) and when Motion is detected excl pre_capture. -+ * If config option 'stream_motion' is 'off' this function is called once -+ * per captured picture frame. -+ * It is always run in setup mode for each picture frame captured and with -+ * the special setup image. -+ * The function does two things: -+ * It looks for possible waiting new clients and adds them. -+ * It sends latest picture frame to all connected clients. -+ * Note: Clients that have disconnected are handled in the stream_flush() -+ * function. -+ */ -+void stream_put(struct context *cnt, unsigned char *image) -+{ -+ struct timeval timeout; -+ struct stream_buffer *tmpbuffer; -+ fd_set fdread; -+ int sl = cnt->stream.socket; -+ int sc; -+ /* Tthe following string has an extra 16 chars at end for length. */ -+ const char jpeghead[] = "--BoundaryString\r\n" -+ "Content-type: image/jpeg\r\n" -+ "Content-Length: "; -+ int headlength = sizeof(jpeghead) - 1; /* Don't include terminator. */ -+ char len[20]; /* Will be used for sprintf, must be >= 16 */ -+ -+ /* -+ * Timeout struct used to timeout the time we wait for a client -+ * and we do not wait at all. -+ */ -+ timeout.tv_sec = 0; -+ timeout.tv_usec = 0; -+ FD_ZERO(&fdread); -+ FD_SET(cnt->stream.socket, &fdread); -+ -+ /* -+ * If we have not reached the max number of allowed clients per -+ * thread we will check to see if new clients are waiting to connect. -+ * If this is the case we add the client as a new stream struct and -+ * add this to the end of the chain of stream structs that are linked -+ * to each other. -+ */ -+ if ((cnt->stream_count < DEF_MAXSTREAMS) && -+ (select(sl + 1, &fdread, NULL, NULL, &timeout) > 0)) { -+ sc = http_acceptsock(sl); -+ if (cnt->conf.stream_auth_method == 0) { -+ stream_add_client(&cnt->stream, sc); -+ cnt->stream_count++; -+ } else { -+ do_client_auth(cnt, sc); -+ } -+ } -+ -+ /* Lock the mutex */ -+ if (cnt->conf.stream_auth_method != 0) -+ pthread_mutex_lock(&stream_auth_mutex); -+ -+ -+ /* Call flush to send any previous partial-sends which are waiting. */ -+ stream_flush(&cnt->stream, &cnt->stream_count, cnt->conf.stream_limit); -+ -+ /* Check if any clients have available buffers. */ -+ if (stream_check_write(&cnt->stream)) { -+ /* -+ * Yes - create a new tmpbuffer for current image. -+ * Note that this should create a buffer which is *much* larger -+ * than necessary, but it is difficult to estimate the -+ * minimum size actually required. -+ */ -+ tmpbuffer = stream_tmpbuffer(cnt->imgs.size); -+ -+ /* Check if allocation was ok. */ -+ if (tmpbuffer) { -+ int imgsize; -+ -+ /* -+ * We need a pointer that points to the picture buffer -+ * just after the mjpeg header. We create a working pointer wptr -+ * to be used in the call to put_picture_memory which we can change -+ * and leave tmpbuffer->ptr intact. -+ */ -+ unsigned char *wptr = tmpbuffer->ptr; -+ -+ /* -+ * For web protocol, our image needs to be preceded -+ * with a little HTTP, so we put that into the buffer -+ * first. -+ */ -+ memcpy(wptr, jpeghead, headlength); -+ -+ /* Update our working pointer to point past header. */ -+ wptr += headlength; -+ -+ /* Create a jpeg image and place into tmpbuffer. */ -+ tmpbuffer->size = put_picture_memory(cnt, wptr, cnt->imgs.size, image, -+ cnt->conf.stream_quality); -+ -+ /* Fill in the image length into the header. */ -+ imgsize = sprintf(len, "%9ld\r\n\r\n", tmpbuffer->size); -+ memcpy(wptr - imgsize, len, imgsize); -+ -+ /* Append a CRLF for good measure. */ -+ memcpy(wptr + tmpbuffer->size, "\r\n", 2); -+ -+ /* -+ * Now adjust tmpbuffer->size to reflect the -+ * header at the beginning and the extra CRLF -+ * at the end. -+ */ -+ tmpbuffer->size += headlength + 2; -+ -+ /* -+ * And finally put this buffer to all clients with -+ * no outstanding data from previous frames. -+ */ -+ stream_add_write(&cnt->stream, tmpbuffer, cnt->conf.stream_maxrate); -+ } else { -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: Error creating tmpbuffer"); -+ } -+ } -+ -+ /* -+ * Now we call flush again. This time (assuming some clients were -+ * ready for the new frame) the new data will be written out. -+ */ -+ stream_flush(&cnt->stream, &cnt->stream_count, cnt->conf.stream_limit); -+ -+ /* Unlock the mutex */ -+ if (cnt->conf.stream_auth_method != 0) -+ pthread_mutex_unlock(&stream_auth_mutex); -+ -+ return; -+} ---- /dev/null -+++ motion-3.2.12/stream.h -@@ -0,0 +1,45 @@ -+/* -+ * stream.h -+ * -+ * Include file for stream.c -+ * Copyright (C) 2002 Jeroen Vreeken (pe1rxq@amsat.org) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+#ifndef _INCLUDE_STREAM_H_ -+#define _INCLUDE_STREAM_H_ -+ -+struct stream_buffer { -+ unsigned char *ptr; -+ int ref; -+ long size; -+}; -+ -+struct stream { -+ int socket; -+ FILE *fwrite; -+ struct stream_buffer *tmpbuffer; -+ long filepos; -+ int nr; -+ unsigned long int last; -+ struct stream *prev; -+ struct stream *next; -+}; -+ -+int stream_init(struct context *); -+void stream_put(struct context *, unsigned char *); -+void stream_stop(struct context *); -+ -+#endif /* _INCLUDE_STREAM_H_ */ ---- /dev/null -+++ motion-3.2.12/thread1.conf -@@ -0,0 +1,57 @@ -+# /usr/local/etc/thread1.conf -+# -+# This config file was generated by motion 3.2.12-4ppa01 -+ -+ -+ -+########################################################### -+# Capture device options -+############################################################ -+ -+# Videodevice to be used for capturing (default /dev/video0) -+# for FreeBSD default is /dev/bktr0 -+videodevice /dev/video0 -+ -+# 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 -+# Text is placed in lower left corner -+text_left CAMERA 1 -+ -+ -+############################################################ -+# Target Directories and filenames For Images And Films -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename -+# you can use conversion specifiers -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event -+# Quotation marks round string are allowed. -+############################################################ -+ -+# Target base directory for pictures and films -+# Recommended to use absolute patch. (Default: current working directory) -+target_dir /usr/local/apache2/htdocs/cam1 -+ -+ -+############################################################ -+# Live Stream Server -+############################################################ -+ -+# The mini-http server listens to this port for requests (default: 0 = disabled) -+stream_port 8081 -+ -+# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -+# The filename of the picture is appended as an argument for the command. -+on_picture_save /usr/local/motion-extras/camparse1.pl -+ -+# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -+# Filename of movie is appended as an argument for the command. -+on_movie_end /usr/local/motion-extras/mpegparse1.pl ---- motion-3.2.12.orig/thread1.conf.in -+++ motion-3.2.12/thread1.conf.in -@@ -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 -@@ -24,7 +24,7 @@ text_left CAMERA 1 - - ############################################################ - # Target Directories and filenames For Images And Films --# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename - # you can use conversion specifiers - # %Y = year, %m = month, %d = date, - # %H = hour, %M = minute, %S = second, -@@ -42,11 +42,11 @@ target_dir /usr/local/apache2/htdocs/cam - - - ############################################################ --# Live Webcam Server -+# Live Stream Server - ############################################################ - - # The mini-http server listens to this port for requests (default: 0 = disabled) --webcam_port 8081 -+stream_port 8081 - - # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) - # The filename of the picture is appended as an argument for the command. ---- /dev/null -+++ motion-3.2.12/thread2.conf -@@ -0,0 +1,58 @@ -+# /usr/local/etc/thread2.conf -+# -+# This config file was generated by motion 3.2.12-4ppa01 -+ -+ -+ -+########################################################### -+# Capture device options -+############################################################ -+ -+# Videodevice to be used for capturing (default /dev/video0) -+# for FreeBSD default is /dev/bktr0 -+videodevice /dev/video1 -+ -+# 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 -+# Text is placed in lower left corner -+text_left CAMERA 2 -+ -+ -+############################################################ -+# Target Directories and filenames For Images And Films -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename -+# you can use conversion specifiers -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event -+# Quotation marks round string are allowed. -+############################################################ -+ -+# Target base directory for pictures and films -+# Recommended to use absolute patch. (Default: current working directory) -+target_dir /usr/local/apache2/htdocs/cam2 -+ -+ -+############################################################ -+# Live Stream Server -+############################################################ -+ -+# The mini-http server listens to this port for requests (default: 0 = disabled) -+stream_port 8082 -+ -+# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -+# The filename of the picture is appended as an argument for the command. -+on_picture_save /usr/local/motion-extras/camparse2.pl -+ -+# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -+# Filename of movie is appended as an argument for the command. -+on_movie_end /usr/local/motion-extras/mpegparse2.pl -+ ---- motion-3.2.12.orig/thread2.conf.in -+++ motion-3.2.12/thread2.conf.in -@@ -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) -@@ -24,7 +24,7 @@ text_left CAMERA 2 - - ############################################################ - # Target Directories and filenames For Images And Films --# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename - # you can use conversion specifiers - # %Y = year, %m = month, %d = date, - # %H = hour, %M = minute, %S = second, -@@ -42,11 +42,11 @@ target_dir /usr/local/apache2/htdocs/cam - - - ############################################################ --# Live Webcam Server -+# Live Stream Server - ############################################################ - - # The mini-http server listens to this port for requests (default: 0 = disabled) --webcam_port 8082 -+stream_port 8082 - - # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) - # The filename of the picture is appended as an argument for the command. ---- /dev/null -+++ motion-3.2.12/thread3.conf -@@ -0,0 +1,60 @@ -+# /usr/local/etc/thread3.conf -+# -+# This config file was generated by motion 3.2.12-4ppa01 -+ -+ -+ -+########################################################### -+# Capture device options -+############################################################ -+ -+# Videodevice to be used for capturing (default /dev/video0) -+# for FreeBSD default is /dev/bktr0 -+videodevice /dev/video2 -+ -+# 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 -+# Text is placed in lower left corner -+text_left CAMERA 3 -+ -+ -+############################################################ -+# Target Directories and filenames For Images And Films -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename -+# you can use conversion specifiers -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event -+# Quotation marks round string are allowed. -+############################################################ -+ -+# Target base directory for pictures and films -+# Recommended to use absolute patch. (Default: current working directory) -+target_dir /usr/local/apache2/htdocs/cam3 -+ -+ -+############################################################ -+# Live Stream Server -+############################################################ -+ -+# The mini-http server listens to this port for requests (default: 0 = disabled) -+stream_port 8083 -+ -+# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -+# The filename of the picture is appended as an argument for the command. -+on_picture_save /usr/local/motion-extras/camparse3.pl -+ -+# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -+# Filename of movie is appended as an argument for the command. -+on_movie_end /usr/local/motion-extras/mpegparse3.pl -+ -+ -+ ---- motion-3.2.12.orig/thread3.conf.in -+++ motion-3.2.12/thread3.conf.in -@@ -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 -@@ -24,7 +24,7 @@ text_left CAMERA 3 - - ############################################################ - # Target Directories and filenames For Images And Films --# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename - # you can use conversion specifiers - # %Y = year, %m = month, %d = date, - # %H = hour, %M = minute, %S = second, -@@ -42,11 +42,11 @@ target_dir /usr/local/apache2/htdocs/cam - - - ############################################################ --# Live Webcam Server -+# Live Stream Server - ############################################################ - - # The mini-http server listens to this port for requests (default: 0 = disabled) --webcam_port 8083 -+stream_port 8083 - - # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) - # The filename of the picture is appended as an argument for the command. ---- /dev/null -+++ motion-3.2.12/thread4.conf -@@ -0,0 +1,62 @@ -+# /usr/local/etc/thread4.conf -+# -+# This config file was generated by motion 3.2.12-4ppa01 -+ -+########################################################### -+# Capture device options -+############################################################ -+ -+# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) -+# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -+netcam_url http://192.168.1.6:8093/ -+ -+# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -+# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -+# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -+# on: Use HTTP/1.1 requests that support keep alive as default. -+# Default: off -+netcam_keepalive force -+ -+# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -+# Default: off -+netcam_tolerant_check on -+ -+# Draw a user defined text on the images using same options as C function strftime(3) -+# Default: Not defined = no text -+# Text is placed in lower left corner -+text_left CAMERA 4 -+ -+############################################################ -+# Target Directories and filenames For Images And Films -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename -+# you can use conversion specifiers -+# %Y = year, %m = month, %d = date, -+# %H = hour, %M = minute, %S = second, -+# %v = event, %q = frame number, %t = thread (camera) number, -+# %D = changed pixels, %N = noise level, -+# %i and %J = width and height of motion area, -+# %K and %L = X and Y coordinates of motion center -+# %C = value defined by text_event -+# Quotation marks round string are allowed. -+############################################################ -+ -+# Target base directory for pictures and films -+# Recommended to use absolute patch. (Default: current working directory) -+target_dir /usr/local/apache2/htdocs/cam4 -+ -+ -+############################################################ -+# Live Stream Server -+############################################################ -+ -+# The mini-http server listens to this port for requests (default: 0 = disabled) -+stream_port 8084 -+ -+# Command to be executed when a picture (.ppm|.jpg) is saved (default: none) -+# The filename of the picture is appended as an argument for the command. -+on_picture_save /usr/local/motion-extras/camparse4.pl -+ -+# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) -+# Filename of movie is appended as an argument for the command. -+on_movie_end /usr/local/motion-extras/mpegparse4.pl -+ ---- motion-3.2.12.orig/thread4.conf.in -+++ motion-3.2.12/thread4.conf.in -@@ -11,11 +11,11 @@ - netcam_url http://192.168.1.6:8093/ - - # The setting for keep-alive of network socket, should improve performance on compatible net cameras. --# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request. --# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection. --# 1.1: Use HTTP/1.1 requests that support keep alive as default. --# Default: 1.0 --netcam_http keep_alive -+# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -+# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -+# on: Use HTTP/1.1 requests that support keep alive as default. -+# Default: off -+netcam_keepalive force - - # Set less strict jpeg checks for network cameras with a poor/buggy firmware. - # Default: off -@@ -26,10 +26,9 @@ netcam_tolerant_check on - # Text is placed in lower left corner - text_left CAMERA 4 - -- - ############################################################ - # Target Directories and filenames For Images And Films --# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename -+# For the options snapshot_, picture_, mpeg_ and timelapse_filename - # you can use conversion specifiers - # %Y = year, %m = month, %d = date, - # %H = hour, %M = minute, %S = second, -@@ -47,11 +46,11 @@ target_dir /usr/local/apache2/htdocs/cam - - - ############################################################ --# Live Webcam Server -+# Live Stream Server - ############################################################ - - # The mini-http server listens to this port for requests (default: 0 = disabled) --webcam_port 8084 -+stream_port 8084 - - # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) - # The filename of the picture is appended as an argument for the command. ---- motion-3.2.12.orig/track.c -+++ motion-3.2.12/track.c -@@ -7,10 +7,9 @@ - */ - - #include --#include - #include "motion.h" - --#ifndef WITHOUT_V4L -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) - #include "pwc-ioctl.h" - #endif - -@@ -22,50 +21,67 @@ struct trackoptions track_template = { - motory: 0, /* int motory */ - maxx: 0, /* int maxx; */ - maxy: 0, /* int maxy; */ -+ minx: 0, /* int minx; */ -+ miny: 0, /* int miny; */ -+ homex: 128, /* int homex; */ -+ homey: 128, /* int homey; */ -+ motorx_reverse: 0, /* int reversed x servo; */ -+ motory_reverse: 0, /* int reversed y servo; */ - speed: TRACK_SPEED, /* speed */ - stepsize: TRACK_STEPSIZE, /* stepsize */ - active: 0, /* auto tracking active */ - minmaxfound: 0, /* flag for minmax values stored for pwc based camera */ -- step_angle_x: 10, /* step angle in degrees X-axis that camera moves during auto tracking */ -- step_angle_y: 10, /* step angle in degrees Y-axis that camera moves during auto tracking */ -+ step_angle_x: 10, /* UVC step angle in degrees X-axis that camera moves during auto tracking */ -+ step_angle_y: 10, /* UVC step angle in degrees Y-axis that camera moves during auto tracking */ - move_wait: 10 /* number of frames to disable motion detection after camera moving */ - }; - - -+ -+ - /* Add your own center and move functions here: */ --static unsigned short int stepper_center(struct context *, int xoff, int yoff ATTRIBUTE_UNUSED); --static unsigned short int stepper_move(struct context *, struct coord *, struct images *); --static unsigned short int iomojo_center(struct context *, int xoff, int yoff); --static unsigned short int iomojo_move(struct context *, int dev, struct coord *, struct images *); --#ifndef WITHOUT_V4L --static unsigned short int lqos_center(struct context *, int dev, int xoff, int yoff); --static unsigned short int lqos_move(struct context *, int dev, struct coord *, struct images *, -- unsigned short int); -+ -+static unsigned int servo_position(struct context *cnt, unsigned int motor); -+ -+static unsigned int servo_center(struct context *cnt, int xoff, int yoff ATTRIBUTE_UNUSED); -+static unsigned int stepper_center(struct context *cnt, int xoff, int yoff ATTRIBUTE_UNUSED); -+static unsigned int iomojo_center(struct context *cnt, int xoff, int yoff); -+ -+static unsigned int stepper_move(struct context *cnt, struct coord *cent, struct images *imgs); -+static unsigned int servo_move(struct context *cnt, struct coord *cent, -+ struct images *imgs, unsigned int manual); -+static unsigned int iomojo_move(struct context *cnt, int dev, struct coord *cent, struct images *imgs); -+ -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) -+static unsigned int lqos_center(struct context *cnt, int dev, int xoff, int yoff); -+static unsigned int lqos_move(struct context *cnt, int dev, struct coord *cent, -+ struct images *imgs, unsigned int manual); - #ifdef MOTION_V4L2 --static unsigned short int uvc_center(struct context *, int dev, int xoff, int yoff); --static unsigned short int uvc_move(struct context *, int dev, struct coord *, struct images *, -- unsigned short int); -+static unsigned int uvc_center(struct context *cnt, int dev, int xoff, int yoff); -+static unsigned int uvc_move(struct context *cnt, int dev, struct coord *cent, -+ struct images *imgs, unsigned int manual); - #endif /* MOTION_V4L2 */ - #endif /* WITHOUT_V4L */ - - /* Add a call to your functions here: */ --unsigned short int track_center(struct context *cnt, int dev ATTRIBUTE_UNUSED, -- unsigned short int manual, int xoff, int yoff) -+unsigned int track_center(struct context *cnt, int dev ATTRIBUTE_UNUSED, -+ unsigned int manual, int xoff, int yoff) - { - if (!manual && !cnt->track.active) - return 0; - - if (cnt->track.type == TRACK_TYPE_STEPPER) { -- unsigned short int ret; -+ unsigned int ret; - ret = stepper_center(cnt, xoff, yoff); - if (!ret) { -- motion_log(LOG_ERR, 1, "track_center: internal error (stepper_center)"); -- return 0; -- } else { -- return ret; -- } -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: internal error"); -+ return 0; -+ } -+ else return ret; -+ } else if (cnt->track.type == TRACK_TYPE_SERVO) { -+ return servo_center(cnt, xoff, yoff); - } --#ifndef WITHOUT_V4L -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) - else if (cnt->track.type == TRACK_TYPE_PWC) - return lqos_center(cnt, dev, xoff, yoff); - #ifdef MOTION_V4L2 -@@ -78,22 +94,25 @@ unsigned short int track_center(struct c - else if (cnt->track.type == TRACK_TYPE_GENERIC) - return 10; // FIX ME. I chose to return something reasonable. - -- motion_log(LOG_ERR, 1, "track_center: internal error, %hu is not a known track-type", -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: internal error, %hu is not a known track-type", - cnt->track.type); - - return 0; - } - - /* Add a call to your functions here: */ --unsigned short int track_move(struct context *cnt, int dev, struct coord *cent, -- struct images *imgs, unsigned short int manual) -+unsigned int track_move(struct context *cnt, int dev, struct coord *cent, struct images *imgs, -+ unsigned int manual) - { -+ - if (!manual && !cnt->track.active) - return 0; - - if (cnt->track.type == TRACK_TYPE_STEPPER) - return stepper_move(cnt, cent, imgs); --#ifndef WITHOUT_V4L -+ else if (cnt->track.type == TRACK_TYPE_SERVO) -+ return servo_move(cnt, cent, imgs, manual); -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) - else if (cnt->track.type == TRACK_TYPE_PWC) - return lqos_move(cnt, dev, cent, imgs, manual); - #ifdef MOTION_V4L2 -@@ -106,22 +125,20 @@ unsigned short int track_move(struct con - else if (cnt->track.type == TRACK_TYPE_GENERIC) - return cnt->track.move_wait; // FIX ME. I chose to return something reasonable. - -- motion_log(LOG_ERR, 1, "track_move: internal error, %hu is not a known track-type", -+ MOTION_LOG(WRN, TYPE_TRACK, SHOW_ERRNO, "%s: internal error, %hu is not a known track-type", - cnt->track.type); - - return 0; - } - -- - /****************************************************************************** - Stepper motor on serial port -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionTracking -- http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionTrackerAPI -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTracking -+ http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTrackerAPI - ******************************************************************************/ - -- --static unsigned short int stepper_command(struct context *cnt, unsigned short int motor, -- unsigned short int command, unsigned short int data) -+static unsigned int stepper_command(struct context *cnt, unsigned int motor, -+ unsigned int command, unsigned int data) - { - char buffer[3]; - time_t timeout = time(NULL); -@@ -131,15 +148,15 @@ static unsigned short int stepper_comman - buffer[2] = data; - - if (write(cnt->track.dev, buffer, 3) != 3) { -- motion_log(LOG_ERR, 1, "stepper_command port %s dev fd %i, motor %hu command %hu data %hu", -- cnt->track.port, cnt->track.dev, motor, command, data); -+ MOTION_LOG(NTC, TYPE_TRACK, SHOW_ERRNO, "%s: port %s dev fd %i, motor %hu command %hu data %hu", -+ cnt->track.port, cnt->track.dev, motor, command, data); - return 0; - } - - while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 1); - - if (time(NULL) >= timeout + 2) { -- motion_log(LOG_ERR, 1, "Status byte timeout!"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Status byte timeout!"); - return 0; - } - -@@ -147,43 +164,46 @@ static unsigned short int stepper_comman - } - - --static unsigned short int stepper_status(struct context *cnt, unsigned short int motor) -+static unsigned int stepper_status(struct context *cnt, unsigned int motor) - { - return stepper_command(cnt, motor, STEPPER_COMMAND_STATUS, 0); - } - - --static unsigned short int stepper_center(struct context *cnt, int x_offset, int y_offset) -+static unsigned int stepper_center(struct context *cnt, int x_offset, int y_offset) - { - struct termios adtio; - - if (cnt->track.dev < 0) { -- motion_log(LOG_INFO, 0, "Try to open serial device %s", cnt->track.port); -- -- if ((cnt->track.dev=open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { -- motion_log(LOG_ERR, 1, "Unable to open serial device %s", cnt->track.port); -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Try to open serial device %s", cnt->track.port); -+ -+ if ((cnt->track.dev = open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to open serial device %s", -+ cnt->track.port); - return 0; - } - - bzero (&adtio, sizeof(adtio)); -- adtio.c_cflag = STEPPER_BAUDRATE | CS8 | CLOCAL | CREAD; -- adtio.c_iflag = IGNPAR; -- adtio.c_oflag = 0; -- adtio.c_lflag = 0; /* non-canon, no echo */ -+ adtio.c_cflag= STEPPER_BAUDRATE | CS8 | CLOCAL | CREAD; -+ adtio.c_iflag= IGNPAR; -+ adtio.c_oflag= 0; -+ adtio.c_lflag= 0; /* non-canon, no echo */ - adtio.c_cc[VTIME] = 0; /* timer unused */ - adtio.c_cc[VMIN] = 0; /* blocking read until 1 char */ - tcflush (cnt->track.dev, TCIFLUSH); - - if (tcsetattr(cnt->track.dev, TCSANOW, &adtio) < 0) { -- motion_log(LOG_ERR, 1, "Unable to initialize serial device %s", cnt->track.port); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to initialize serial device %s", -+ cnt->track.port); -+ cnt->track.dev = -1; - return 0; - } -- motion_log(LOG_INFO, 0, "Opened serial device %s and initialize, fd %i", -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Opened serial device %s and initialize, fd %i", - cnt->track.port, cnt->track.dev); - } - - /* x-axis */ -- -+ - stepper_command(cnt, cnt->track.motorx, STEPPER_COMMAND_SPEED, cnt->track.speed); - stepper_command(cnt, cnt->track.motorx, STEPPER_COMMAND_LEFT_N, cnt->track.maxx); - -@@ -200,33 +220,36 @@ static unsigned short int stepper_center - stepper_command(cnt, cnt->track.motory, STEPPER_COMMAND_UP_N, cnt->track.maxy); - - while (stepper_status(cnt, cnt->track.motory) & STEPPER_STATUS_UP) -- -+ - stepper_command(cnt, cnt->track.motory, STEPPER_COMMAND_DOWN_N, - cnt->track.maxy / 2 + y_offset * cnt->track.stepsize); -- -+ - while (stepper_status(cnt, cnt->track.motory) & STEPPER_STATUS_DOWN); -- -+ - return cnt->track.move_wait; - } - --static unsigned short int stepper_move(struct context *cnt, struct coord *cent, -- struct images *imgs) -+static unsigned int stepper_move(struct context *cnt, -+ struct coord *cent, struct images *imgs) - { -- unsigned short int command = 0, data = 0; -+ unsigned int command = 0, data = 0; - - if (cnt->track.dev < 0) { -- motion_log(LOG_INFO, 0, "No device %s started yet , trying stepper_center()", cnt->track.port); -- if (!stepper_center(cnt, 0, 0)){ -- motion_log(LOG_ERR, 1, "Stepper_center() failed to initialize stepper device on %s , fd [%i].", -- cnt->track.port, cnt->track.dev); -+ MOTION_LOG(WRN, TYPE_TRACK, NO_ERRNO, "%s: No device %s started yet , trying stepper_center()", -+ cnt->track.port); -+ -+ if (!stepper_center(cnt, 0, 0)) { -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: failed to initialize stepper device on %s , fd [%i].", -+ cnt->track.port, cnt->track.dev); - return 0; - } -- motion_log(LOG_INFO, 0, "stepper_center() succeed , device started %s , fd [%i]", -- cnt->track.port, cnt->track.dev); -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: succeed , device started %s , fd [%i]", -+ cnt->track.port, cnt->track.dev); - } - - /* x-axis */ -- -+ - if (cent->x < imgs->width / 2) { - command = STEPPER_COMMAND_LEFT_N; - data = imgs->width / 2 - cent->x; -@@ -239,8 +262,7 @@ static unsigned short int stepper_move(s - - data = data * cnt->track.stepsize / imgs->width; - -- if (data) -- stepper_command(cnt, cnt->track.motorx, command, data); -+ if (data) stepper_command(cnt, cnt->track.motorx, command, data); - - /* y-axis */ - -@@ -253,24 +275,347 @@ static unsigned short int stepper_move(s - command = STEPPER_COMMAND_DOWN_N; - data = cent->y - imgs->height / 2; - } -- -+ - data = data * cnt->track.stepsize / imgs->height; - -- if (data) -- stepper_command(cnt, cnt->track.motory, command, data); -- -- -+ if (data) -+ stepper_command(cnt, cnt->track.motory, command, data); -+ -+ -+ return cnt->track.move_wait; -+} -+ -+/****************************************************************************** -+ * Servo motor on serial port -+ * http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTracking -+ * http://www.lavrsen.dk/twiki/bin/view/Motion/MotionTrackerServoAPI -+ ******************************************************************************/ -+ -+static int servo_open(struct context *cnt) -+{ -+ struct termios adtio; -+ -+ if ((cnt->track.dev = open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to open serial device %s", -+ cnt->track.port); -+ return 0; -+ } -+ -+ bzero (&adtio, sizeof(adtio)); -+ adtio.c_cflag= SERVO_BAUDRATE | CS8 | CLOCAL | CREAD; -+ adtio.c_iflag= IGNPAR; -+ adtio.c_oflag= 0; -+ adtio.c_lflag= 0; /* non-canon, no echo */ -+ adtio.c_cc[VTIME] = 0; /* timer unused */ -+ adtio.c_cc[VMIN] = 0; /* blocking read until 1 char */ -+ tcflush (cnt->track.dev, TCIFLUSH); -+ -+ if (tcsetattr(cnt->track.dev, TCSANOW, &adtio) < 0) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Unable to initialize serial device %s", -+ cnt->track.port); -+ cnt->track.dev = -1; -+ return 0; -+ } -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Opened serial device %s and initialize, fd %i", -+ cnt->track.port, cnt->track.dev); -+ -+ return 1; -+} -+ -+ -+static unsigned int servo_command(struct context *cnt, unsigned int motor, -+ unsigned int command, unsigned int data) -+{ -+ unsigned char buffer[3]; -+ time_t timeout = time(NULL); -+ -+ buffer[0] = motor; -+ buffer[1] = command; -+ buffer[2] = data; -+ -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: SENDS port %s dev fd %i, motor %hu command %hu data %hu", -+ cnt->track.port, cnt->track.dev, buffer[0], buffer[1], buffer[2]); -+ -+ if (write(cnt->track.dev, buffer, 3) != 3) { -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: port %s dev fd %i, motor %hu command %hu data %hu", -+ cnt->track.port, cnt->track.dev, motor, command, data); -+ return 0; -+ } -+ -+ while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 1); -+ -+ if (time(NULL) >= timeout + 2) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Status byte timeout!"); -+ return 0; -+ } -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Command return %d", buffer[0]); -+ -+ -+ return buffer[0]; -+} -+ -+ -+static unsigned int servo_position(struct context *cnt, unsigned int motor) -+{ -+ unsigned int ret = 0; -+ -+ ret = servo_command(cnt, motor, SERVO_COMMAND_POSITION, 0); -+ -+ return ret; -+} -+ -+ -+/** -+ * servo_move -+ * Does relative movements to current position. -+ * -+ */ -+static unsigned int servo_move(struct context *cnt, struct coord *cent, -+ struct images *imgs, unsigned int manual) -+{ -+ unsigned int command = 0; -+ unsigned int data = 0; -+ unsigned int position; -+ -+ /* If device is not open yet , open and center */ -+ if (cnt->track.dev < 0) { -+ if (!servo_center(cnt, 0, 0)) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Problem opening servo!"); -+ return 0; -+ } -+ } -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: cent->x %d, cent->y %d, reversex %d," -+ "reversey %d manual %d", cent->x , cent->y, -+ cnt->track.motorx_reverse, cnt->track.motory_reverse, manual); -+ -+ if (manual) { -+ int offset; -+ -+ if (cent->x) { -+ position = servo_position(cnt, cnt->track.motorx); -+ offset = cent->x * cnt->track.stepsize; -+ -+ -+ if ((cnt->track.motorx_reverse && (offset > 0)) || -+ (!cnt->track.motorx_reverse && (offset < 0))) -+ command = SERVO_COMMAND_LEFT_N; -+ else -+ command = SERVO_COMMAND_RIGHT_N; -+ -+ data = abs(offset); -+ -+ if ((data + position > (unsigned)cnt->track.maxx) || -+ (position - offset < (unsigned)cnt->track.minx)) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: x %d value out of range! (%d - %d)", -+ data, cnt->track.minx, cnt->track.maxx); -+ return 0; -+ } -+ -+ /* Set Speed , TODO : it should be done only when speed changes */ -+ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); -+ servo_command(cnt, cnt->track.motorx, command, data); -+ } -+ -+ -+ if (cent->y) { -+ position = servo_position(cnt, cnt->track.motory); -+ offset = cent->y * cnt->track.stepsize; -+ -+ if ((cnt->track.motory_reverse && (offset > 0)) || -+ (!cnt->track.motory_reverse && (offset < 0))) -+ command = SERVO_COMMAND_UP_N; -+ else -+ command = SERVO_COMMAND_DOWN_N; -+ -+ data = abs(offset); -+ -+ if ((data + position > (unsigned)cnt->track.maxy) || -+ (position - offset < (unsigned)cnt->track.miny)) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: y %d value out of range! (%d - %d)", -+ data, cnt->track.miny, cnt->track.maxy); -+ return 0; -+ } -+ -+ /* Set Speed , TODO : it should be done only when speed changes */ -+ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); -+ servo_command(cnt, cnt->track.motory, command, data); -+ } -+ -+ } else { -+ /***** x-axis *****/ -+ -+ /* Move left */ -+ if (cent->x < imgs->width / 2) { -+ if (cnt->track.motorx_reverse) -+ command = SERVO_COMMAND_RIGHT_N; -+ else -+ command = SERVO_COMMAND_LEFT_N; -+ data = imgs->width / 2 - cent->x; -+ } -+ -+ /* Move right */ -+ if (cent->x > imgs->width / 2) { -+ if (cnt->track.motorx_reverse) -+ command = SERVO_COMMAND_LEFT_N; -+ else -+ command = SERVO_COMMAND_RIGHT_N; -+ data = cent->x - imgs->width / 2; -+ } -+ -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: X offset %d", data); -+ -+ data = data * cnt->track.stepsize / imgs->width; -+ -+ if (data && command) { -+ -+ // TODO: need to get position to avoid overflow limits -+ position = servo_position(cnt, cnt->track.motorx); -+ -+ if ((position + data > (unsigned)cnt->track.maxx) || -+ (position - data < (unsigned)cnt->track.minx)) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: x %d value out of range! (%d - %d)", -+ data, cnt->track.minx, cnt->track.maxx); -+ return 0; -+ } -+ -+ /* Set Speed , TODO : it should be done only when speed changes */ -+ -+ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); -+ servo_command(cnt, cnt->track.motorx, command, data); -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: X cent->x %d, cent->y %d, reversex %d," -+ "reversey %d motorx %d data %d command %d", -+ cent->x, cent->y, cnt->track.motorx_reverse, -+ cnt->track.motory_reverse, cnt->track.motorx, data, command); -+ } -+ -+ /***** y-axis *****/ -+ -+ /* Move down */ -+ if (cent->y < imgs->height / 2) { -+ if (cnt->track.motory_reverse) -+ command = SERVO_COMMAND_UP_N; -+ else -+ command = SERVO_COMMAND_DOWN_N; -+ data = imgs->height / 2 - cent->y; -+ } -+ -+ /* Move up */ -+ if (cent->y > imgs->height / 2) { -+ if (cnt->track.motory_reverse) -+ command = SERVO_COMMAND_DOWN_N; -+ else -+ command = SERVO_COMMAND_UP_N; -+ data = cent->y - imgs->height / 2; -+ } -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Y offset %d", data); -+ -+ data = data * cnt->track.stepsize / imgs->height; -+ -+ if (data && command) { -+ -+ // TODO: need to get position to avoid overflow limits -+ position = servo_position(cnt, cnt->track.motory); -+ -+ if ((position + data > (unsigned)cnt->track.maxy) || -+ (position - data < (unsigned)cnt->track.miny)) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: y %d value out of range! (%d - %d)", -+ data, cnt->track.miny, cnt->track.maxy); -+ return 0; -+ } -+ -+ /* Set Speed , TODO : it should be done only when speed changes */ -+ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); -+ servo_command(cnt, cnt->track.motory, command, data); -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Y cent->x %d, cent->y %d, reversex %d," -+ "reversey %d motory %d data %d command %d", -+ cent->x, cent->y, cnt->track.motorx_reverse, -+ cnt->track.motory_reverse, cnt->track.motory, command); -+ } -+ } -+ - return cnt->track.move_wait; - } - -+#if 0 -+static unsigned int servo_status(struct context *cnt, unsigned int motor) -+{ -+ return servo_command(cnt, motor, SERVO_COMMAND_STATUS, 0); -+} -+#endif -+ -+/** -+ * servo_center -+ * Moves servo to home position. -+ * Does absolute movements ( offsets relative to home position ). -+ * -+ * Note : Using Clockwise as a convention for right , left , up , down -+ * so left minx , right maxx , down miny , up maxy -+ * -+ */ -+ -+static unsigned int servo_center(struct context *cnt, int x_offset, int y_offset) -+{ -+ int x_offset_abs; -+ int y_offset_abs; -+ -+ /* If device is not open yet */ -+ if (cnt->track.dev < 0) { -+ if (!servo_open(cnt)) { -+ MOTION_LOG(ERR, TYPE_TRACK, NO_ERRNO, "%s: Problem opening servo!"); -+ return 0; -+ } -+ } -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: X-offset %d, Y-offset %d, x-position %d. y-position %d," -+ "reversex %d, reversey %d , stepsize %d", x_offset, y_offset, -+ cnt->track.homex + (x_offset * cnt->track.stepsize), -+ cnt->track.homey + (y_offset * cnt->track.stepsize), -+ cnt->track.motorx_reverse, cnt->track.motory_reverse, -+ cnt->track.stepsize); -+ -+ /* x-axis */ -+ if (cnt->track.motorx_reverse) -+ x_offset_abs = (128 - cnt->track.homex) - (x_offset * cnt->track.stepsize) + 128; -+ else -+ x_offset_abs = cnt->track.homex + (x_offset * cnt->track.stepsize); -+ -+ if (x_offset_abs <= cnt->track.maxx && x_offset_abs >= cnt->track.minx) { -+ /* Set Speed , TODO : it should be done only when speed changes */ -+ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_SPEED, cnt->track.speed); -+ servo_command(cnt, cnt->track.motorx, SERVO_COMMAND_ABSOLUTE, x_offset_abs); -+ } -+ -+ /* y-axis */ -+ if (cnt->track.motory_reverse) -+ y_offset_abs = (128 - cnt->track.homey) - (y_offset * cnt->track.stepsize) + 128; -+ else -+ y_offset_abs = cnt->track.homey + (y_offset * cnt->track.stepsize); -+ -+ if (y_offset_abs <= cnt->track.maxy && y_offset_abs >= cnt->track.minx) { -+ /* Set Speed , TODO : it should be done only when speed changes */ -+ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_SPEED, cnt->track.speed); -+ servo_command(cnt, cnt->track.motory, SERVO_COMMAND_ABSOLUTE, y_offset_abs); -+ } -+ -+ return cnt->track.move_wait; -+} -+ -+ - /****************************************************************************** - - Iomojo Smilecam on serial port - - ******************************************************************************/ - --static char iomojo_command(struct context *cnt, char *command, -- unsigned short int len, unsigned short int ret) -+static char iomojo_command(struct context *cnt, char *command, int len, unsigned int ret) - { - char buffer[1]; - time_t timeout = time(NULL); -@@ -280,9 +625,9 @@ static char iomojo_command(struct contex - - if (ret) { - while (read(cnt->track.dev, buffer, 1) != 1 && time(NULL) < timeout + 2); -- -+ - if (time(NULL) >= timeout + 2) { -- motion_log(LOG_ERR, 1, "Return byte timeout!"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Return byte timeout!"); - return 0; - } - } -@@ -290,36 +635,37 @@ static char iomojo_command(struct contex - return buffer[0]; - } - --static void iomojo_setspeed(struct context *cnt, unsigned short int speed) -+static void iomojo_setspeed(struct context *cnt, unsigned int speed) - { - char command[3]; -- -+ - command[0] = IOMOJO_SETSPEED_CMD; - command[1] = cnt->track.iomojo_id; - command[2] = speed; -- -+ - if (iomojo_command(cnt, command, 3, 1) != IOMOJO_SETSPEED_RET) -- motion_log(LOG_ERR, 1, "Unable to set camera speed"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to set camera speed"); - } - - static void iomojo_movehome(struct context *cnt) - { - char command[2]; -- -+ - command[0] = IOMOJO_MOVEHOME; - command[1] = cnt->track.iomojo_id; - - iomojo_command(cnt, command, 2, 0); - } - --static unsigned short int iomojo_center(struct context *cnt, int x_offset, int y_offset) -+static unsigned int iomojo_center(struct context *cnt, int x_offset, int y_offset) - { - struct termios adtio; - char command[5], direction = 0; - -- if (cnt->track.dev<0) { -- if ((cnt->track.dev=open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { -- motion_log(LOG_ERR, 1, "Unable to open serial device %s", cnt->track.port); -+ if (cnt->track.dev < 0) { -+ if ((cnt->track.dev = open(cnt->track.port, O_RDWR | O_NOCTTY)) < 0) { -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to open serial device %s", -+ cnt->track.port); - return 0; - } - -@@ -332,7 +678,8 @@ static unsigned short int iomojo_center( - adtio.c_cc[VMIN] = 0; /* blocking read until 1 char */ - tcflush(cnt->track.dev, TCIFLUSH); - if (tcsetattr(cnt->track.dev, TCSANOW, &adtio) < 0) { -- motion_log(LOG_ERR, 1, "Unable to initialize serial device %s", cnt->track.port); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Unable to initialize serial device %s", -+ cnt->track.port); - return 0; - } - } -@@ -341,16 +688,16 @@ static unsigned short int iomojo_center( - iomojo_movehome(cnt); - - if (x_offset || y_offset) { -- if (x_offset > 0) -+ if (x_offset > 0) { - direction |= IOMOJO_DIRECTION_RIGHT; -- else { -+ } else { - direction |= IOMOJO_DIRECTION_LEFT; - x_offset *= -1; - } - -- if (y_offset > 0) -+ if (y_offset > 0) { - direction |= IOMOJO_DIRECTION_UP; -- else { -+ } else { - direction |= IOMOJO_DIRECTION_DOWN; - y_offset *= -1; - } -@@ -369,19 +716,19 @@ static unsigned short int iomojo_center( - iomojo_command(cnt, command, 5, 0); - } - -- motion_log(LOG_INFO, 0, "iomojo_center() succeed"); -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: succeed"); - - return cnt->track.move_wait; - } - --static unsigned short int iomojo_move(struct context *cnt, int dev, -- struct coord *cent, struct images *imgs) -+static unsigned int iomojo_move(struct context *cnt, int dev, struct coord *cent, -+ struct images *imgs) - { - char command[5]; - int direction = 0; - int nx = 0, ny = 0; - int i; -- -+ - if (dev < 0) - if (!iomojo_center(cnt, 0, 0)) - return 0; -@@ -428,7 +775,6 @@ static unsigned short int iomojo_move(st - i = 25 * ny / 90; - else - i = 25 * nx / 90; -- - return i; - } - -@@ -440,8 +786,8 @@ static unsigned short int iomojo_move(st - Logitech QuickCam Orbit camera tracking code by folkert@vanheusden.com - - ******************************************************************************/ --#ifndef WITHOUT_V4L --static unsigned short int lqos_center(struct context *cnt, int dev, int x_angle, int y_angle) -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) -+static unsigned int lqos_center(struct context *cnt, int dev, int x_angle, int y_angle) - { - int reset = 3; - struct pwc_mpt_angles pma; -@@ -450,48 +796,48 @@ static unsigned short int lqos_center(st - if (cnt->track.dev == -1) { - - if (ioctl(dev, VIDIOCPWCMPTRESET, &reset) == -1) { -- motion_log(LOG_ERR, 1, "Failed to reset pwc camera to starting position! Reason"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to reset pwc camera to starting position! Reason"); - return 0; - } - -- SLEEP(6,0) -+ SLEEP(6, 0); - - if (ioctl(dev, VIDIOCPWCMPTGRANGE, &pmr) == -1) { -- motion_log(LOG_ERR, 1, "failed VIDIOCPWCMPTGRANGE"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: failed VIDIOCPWCMPTGRANGE"); - return 0; - } - - cnt->track.dev = dev; - cnt->track.minmaxfound = 1; -- cnt->track.panmin = pmr.pan_min; -- cnt->track.panmax = pmr.pan_max; -- cnt->track.tiltmin = pmr.tilt_min; -- cnt->track.tiltmax = pmr.tilt_max; -+ cnt->track.minx = pmr.pan_min; -+ cnt->track.maxx = pmr.pan_max; -+ cnt->track.miny = pmr.tilt_min; -+ cnt->track.maxy = pmr.tilt_max; - } - - if (ioctl(dev, VIDIOCPWCMPTGANGLE, &pma) == -1) -- motion_log(LOG_ERR, 1, "ioctl VIDIOCPWCMPTGANGLE"); -- -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: ioctl VIDIOCPWCMPTGANGLE"); -+ - pma.absolute = 1; - -- if (x_angle * 100 < cnt->track.panmax && x_angle * 100 > cnt->track.panmin) -+ if (x_angle * 100 < cnt->track.maxx && x_angle * 100 > cnt->track.minx) - pma.pan = x_angle * 100; - -- if (y_angle * 100 < cnt->track.tiltmax && y_angle * 100 > cnt->track.tiltmin) -+ if (y_angle * 100 < cnt->track.maxy && y_angle * 100 > cnt->track.miny) - pma.tilt = y_angle * 100; - - if (ioctl(dev, VIDIOCPWCMPTSANGLE, &pma) == -1) { -- motion_log(LOG_ERR, 1, "Failed to pan/tilt pwc camera! Reason"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to pan/tilt pwc camera! Reason"); - return 0; - } - -- motion_log(LOG_INFO, 0, "lqos_center succeed"); -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: succeed"); - - return cnt->track.move_wait; - } - --static unsigned short int lqos_move(struct context *cnt, int dev, struct coord *cent, -- struct images *imgs, unsigned short int manual) -+static unsigned int lqos_move(struct context *cnt, int dev, struct coord *cent, -+ struct images *imgs, unsigned int manual) - { - int delta_x = cent->x - (imgs->width / 2); - int delta_y = cent->y - (imgs->height / 2); -@@ -501,9 +847,9 @@ static unsigned short int lqos_move(stru - - /* If we are on auto track we calculate delta, otherwise we use user input in degrees times 100 */ - if (!manual) { -- if (delta_x > imgs->width * 3 / 8 && delta_x < imgs->width * 5 / 8) -+ if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8) - return 0; -- if (delta_y > imgs->height * 3 / 8 && delta_y < imgs->height * 5 / 8) -+ if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8) - return 0; - - move_x_degrees = delta_x * cnt->track.step_angle_x * 100 / (imgs->width / 2); -@@ -512,46 +858,48 @@ static unsigned short int lqos_move(stru - move_x_degrees = cent->x * 100; - move_y_degrees = cent->y * 100; - } -- -+ - /* If we never checked for the min/max values for pan/tilt we do it now */ - if (cnt->track.minmaxfound == 0) { - if (ioctl(dev, VIDIOCPWCMPTGRANGE, &pmr) == -1) { -- motion_log(LOG_ERR, 1, "failed VIDIOCPWCMPTGRANGE"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: failed VIDIOCPWCMPTGRANGE"); - return 0; - } - cnt->track.minmaxfound = 1; -- cnt->track.panmin = pmr.pan_min; -- cnt->track.panmax = pmr.pan_max; -- cnt->track.tiltmin = pmr.tilt_min; -- cnt->track.tiltmax = pmr.tilt_max; -+ cnt->track.minx = pmr.pan_min; -+ cnt->track.maxx = pmr.pan_max; -+ cnt->track.miny = pmr.tilt_min; -+ cnt->track.maxy = pmr.tilt_max; - } - - /* Get current camera position */ - if (ioctl(dev, VIDIOCPWCMPTGANGLE, &pma) == -1) -- motion_log(LOG_ERR, 1, "ioctl VIDIOCPWCMPTGANGLE"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: ioctl VIDIOCPWCMPTGANGLE"); -+ - -+ /* -+ * Check current position of camera and see if we need to adjust -+ * values down to what is left to move -+ */ -+ if (move_x_degrees < 0 && (cnt->track.minx - pma.pan) > move_x_degrees) -+ move_x_degrees = (cnt->track.minx - pma.pan); - -- /* Check current position of camera and see if we need to adjust -- values down to what is left to move */ -- if (move_x_degrees<0 && (cnt->track.panmin - pma.pan) > move_x_degrees) -- move_x_degrees = (cnt->track.panmin - pma.pan); -+ if (move_x_degrees > 0 && (cnt->track.maxx - pma.pan) < move_x_degrees) -+ move_x_degrees = (cnt->track.maxx - pma.pan); - -- if (move_x_degrees>0 && (cnt->track.panmax - pma.pan) < move_x_degrees) -- move_x_degrees = (cnt->track.panmax - pma.pan); -+ if (move_y_degrees < 0 && (cnt->track.miny - pma.tilt) > move_y_degrees) -+ move_y_degrees = (cnt->track.miny - pma.tilt); - -- if (move_y_degrees<0 && (cnt->track.tiltmin - pma.tilt) > move_y_degrees) -- move_y_degrees = (cnt->track.tiltmin - pma.tilt); -+ if (move_y_degrees > 0 && (cnt->track.maxy - pma.tilt) < move_y_degrees) -+ move_y_degrees = (cnt->track.maxy - pma.tilt); - -- if (move_y_degrees>0 && (cnt->track.tiltmax - pma.tilt) < move_y_degrees) -- move_y_degrees = (cnt->track.tiltmax - pma.tilt); -- - /* Move camera relative to current position */ - pma.absolute = 0; - pma.pan = move_x_degrees; - pma.tilt = move_y_degrees; - - if (ioctl(dev, VIDIOCPWCMPTSANGLE, &pma) == -1) { -- motion_log(LOG_ERR, 1, "Failed to pan/tilt pwc camera! Reason"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to pan/tilt pwc camera! Reason"); - return 0; - } - -@@ -560,14 +908,14 @@ static unsigned short int lqos_move(stru - /****************************************************************************** - - Logitech QuickCam Sphere camera tracking code by oBi -- -- Modify by Dirk Wesenberg(Munich) 30.03.07 -- - for new API in uvcvideo -+ -+ Modify by Dirk Wesenberg(Munich) 30.03.07 -+ - for new API in uvcvideo - - add Trace-steps for investigation - ******************************************************************************/ - #ifdef MOTION_V4L2 - --static unsigned short int uvc_center(struct context *cnt, int dev, int x_angle, int y_angle) -+static unsigned int uvc_center(struct context *cnt, int dev, int x_angle, int y_angle) - { - /* CALC ABSOLUTE MOVING : Act.Position +/- delta to request X and Y */ - int move_x_degrees = 0, move_y_degrees = 0; -@@ -590,41 +938,40 @@ static unsigned short int uvc_center(str - control_s.value = (unsigned char) reset; - - if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -- motion_log(LOG_ERR, 1, "Failed to reset UVC camera to starting position! Reason"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to reset UVC camera to starting position! Reason"); - return 0; - } -- motion_log(LOG_DEBUG, 0, "Reseting UVC camera to starting position"); - -- SLEEP(8, 0) -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Reseting UVC camera to starting position"); -+ -+ SLEEP(8, 0); - - /* Get camera range */ - struct v4l2_queryctrl queryctrl; -- - queryctrl.id = V4L2_CID_PAN_RELATIVE; - - if (ioctl(dev, VIDIOC_QUERYCTRL, &queryctrl) < 0) { -- motion_log(LOG_ERR, 1, "ioctl querycontrol"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: ioctl querycontrol"); - return 0; - } - -- motion_log(LOG_DEBUG, 0, "Getting camera range"); -- -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Getting camera range"); - -- /* DWe 30.03.07 The orig request failed : -- * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual -- * Range X = -70 to +70 degrees -- * Y = -30 to +30 degrees -- */ -- --// //get mininum --// pan.value = queryctrl.minimum; -- -- cnt->track.panmin = -4480 / INCPANTILT; -- cnt->track.tiltmin = -1920 / INCPANTILT; --// //get maximum -- cnt->track.panmax = 4480 / INCPANTILT; -- cnt->track.tiltmax = 1920 / INCPANTILT; --// pan.value = queryctrl.maximum; -+ /* DWe 30.03.07 The orig request failed : -+ * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual -+ * Range X = -70 to +70 degrees -+ * Y = -30 to +30 degrees -+ */ -+ -+ //get mininum -+ //pan.value = queryctrl.minimum; -+ -+ cnt->track.minx = -4480 / INCPANTILT; -+ cnt->track.miny = -1920 / INCPANTILT; -+ //get maximum -+ cnt->track.maxx = 4480 / INCPANTILT; -+ cnt->track.maxy = 1920 / INCPANTILT; -+ //pan.value = queryctrl.maximum; - - cnt->track.dev = dev; - cnt->track.pan_angle = 0; -@@ -635,130 +982,139 @@ static unsigned short int uvc_center(str - - struct v4l2_control control_s; - -- motion_log(LOG_DEBUG, 0, "INPUT_PARAM_ABS pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ", -- cnt->track.panmin, cnt->track.panmax, cnt->track.tiltmin, cnt->track.tiltmax ); -- motion_log(LOG_DEBUG, 0, "INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ", x_angle, y_angle); -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: INPUT_PARAM_ABS pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ", -+ cnt->track.minx, cnt->track.maxx, cnt->track.miny, cnt->track.maxy); -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: INPUT_PARAM_ABS X_Angel %d, Y_Angel %d ", -+ x_angle, y_angle); - -- if (x_angle <= cnt->track.panmax && x_angle >= cnt->track.panmin) -+ if (x_angle <= cnt->track.maxx && x_angle >= cnt->track.minx) - move_x_degrees = x_angle - (cnt->track.pan_angle); - -- if (y_angle <= cnt->track.tiltmax && y_angle >= cnt->track.tiltmin) -+ if (y_angle <= cnt->track.maxy && y_angle >= cnt->track.miny) - move_y_degrees = y_angle - (cnt->track.tilt_angle); -- -+ - - /* -- tilt up: - value -- tilt down: + value -- pan left: - value -- pan right: + value -- */ -+ * tilt up: - value -+ * tilt down: + value -+ * pan left: - value -+ * pan right: + value -+ */ - pan.s16.pan = -move_x_degrees * INCPANTILT; - pan.s16.tilt = -move_y_degrees * INCPANTILT; -- -- motion_log(LOG_DEBUG, 0, "For_SET_ABS move_X %d,move_Y %d", move_x_degrees, move_y_degrees); -- -- /* DWe 30.03.07 Must be broken in diff calls, because -- - one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS -- - The Webcam or uvcvideo does not like a call with a zero-move -- */ -- -+ -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: For_SET_ABS move_X %d,move_Y %d", -+ move_x_degrees, move_y_degrees); -+ -+ /* DWe 30.03.07 Must be broken in diff calls, because -+ * one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS -+ * The Webcam or uvcvideo does not like a call with a zero-move -+ */ -+ - if (move_x_degrees != 0) { - control_s.id = V4L2_CID_PAN_RELATIVE; -- // control_s.value = pan.value; -+ //control_s.value = pan.value; - control_s.value = pan.s16.pan; -+ - if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); - return 0; - } - } - -- /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ -- if ((move_x_degrees != 0) && (move_y_degrees != 0)) -- SLEEP (1,0); -- -- -+ /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ -+ if ((move_x_degrees != 0) && (move_y_degrees != 0)) -+ SLEEP(1, 0); -+ - if (move_y_degrees != 0) { - control_s.id = V4L2_CID_TILT_RELATIVE; -- // control_s.value = pan.value; -+ //control_s.value = pan.value; - control_s.value = pan.s16.tilt; -+ - if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); - return 0; -- } -- -+ } - } - -- motion_log(LOG_DEBUG, 0,"Found MINMAX = %d", cnt->track.minmaxfound); -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Found MINMAX = %d", -+ cnt->track.minmaxfound); - - if (cnt->track.dev != -1) { -- motion_log(LOG_DEBUG, 0," Before_ABS_Y_Angel : x= %d , Y= %d , ", -- cnt->track.pan_angle, cnt->track.tilt_angle ); -- if (move_x_degrees != -1) -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: Before_ABS_Y_Angel : x= %d , Y= %d, ", -+ cnt->track.pan_angle, cnt->track.tilt_angle); -+ -+ if (move_x_degrees != -1) { - cnt->track.pan_angle += move_x_degrees; -- -- if (move_x_degrees != -1) -+ } -+ -+ if (move_x_degrees != -1) { - cnt->track.tilt_angle += move_y_degrees; -- -- motion_log(LOG_DEBUG, 0," After_ABS_Y_Angel : x= %d , Y= %d , ", -- cnt->track.pan_angle, cnt->track.tilt_angle ); -+ } -+ -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: After_ABS_Y_Angel : x= %d , Y= %d", -+ cnt->track.pan_angle, cnt->track.tilt_angle); - } - - return cnt->track.move_wait; - } - --static unsigned short int uvc_move(struct context *cnt, int dev, struct coord *cent, -- struct images *imgs, unsigned short int manual) -+static unsigned int uvc_move(struct context *cnt, int dev, struct coord *cent, -+ struct images *imgs, unsigned int manual) - { - /* RELATIVE MOVING : Act.Position +/- X and Y */ -- -+ - int delta_x = cent->x - (imgs->width / 2); - int delta_y = cent->y - (imgs->height / 2); - int move_x_degrees, move_y_degrees; -- -- /* DWe 30.03.07 Does the request of act.position from WebCam work ? luvcview shows at every position 180 :( */ -- /* Now we init the Web by call Reset, so we can sure, that we are at x/y = 0,0 */ -- /* Don't worry, if the WebCam make a sound - over End at PAN - hmmm, should it be normal ...? */ -- /* PAN Value 7777 in relative will init also a want reset for CAM - it will be "0" after that */ -+ -+ /* -+ * DWe 30.03.07 Does the request of act.position from WebCam work ? luvcview shows at every position 180 :( -+ * Now we init the Web by call Reset, so we can sure, that we are at x/y = 0,0 -+ * Don't worry, if the WebCam make a sound - over End at PAN - hmmm, should it be normal ...? -+ * PAN Value 7777 in relative will init also a want reset for CAM - it will be "0" after that -+ */ - if ((cnt->track.minmaxfound != 1) || (cent->x == 7777)) { -- unsigned short int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt -+ unsigned int reset = 3; //0-non reset, 1-reset pan, 2-reset tilt, 3-reset pan&tilt - struct v4l2_control control_s; - - control_s.id = V4L2_CID_PANTILT_RESET; - control_s.value = (unsigned char) reset; - - if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -- motion_log(LOG_ERR, 1, "Failed to reset UVC camera to starting position! Reason"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to reset UVC camera to starting position! Reason"); - return 0; - } - -- motion_log(LOG_DEBUG, 0, "Reseting UVC camera to starting position"); -- -+ MOTION_LOG(NTC, TYPE_TRACK, NO_ERRNO, "%s: Reseting UVC camera to starting position"); -+ - /* set the "helpvalue" back to null because after reset CAM should be in x=0 and not 70 */ - cent->x = 0; -- SLEEP(8,0); -- -- /* DWe 30.03.07 The orig request failed : -- * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual -- * Range X = -70 to +70 degrees -- * Y = -30 to +30 degrees -- */ -- -- cnt->track.panmin = -4480 / INCPANTILT; -- cnt->track.tiltmin = -1920 / INCPANTILT; -- cnt->track.panmax = 4480 / INCPANTILT; -- cnt->track.tiltmax = 1920 / INCPANTILT; -+ SLEEP(8, 0); -+ -+ /* -+ * DWe 30.03.07 The orig request failed : -+ * must be VIDIOC_G_CTRL separate for pan and tilt or via VIDIOC_G_EXT_CTRLS - now for 1st manual -+ * Range X = -70 to +70 degrees -+ * Y = -30 to +30 degrees -+ */ -+ -+ cnt->track.minx = -4480 / INCPANTILT; -+ cnt->track.miny = -1920 / INCPANTILT; -+ cnt->track.maxx = 4480 / INCPANTILT; -+ cnt->track.maxy = 1920 / INCPANTILT; - cnt->track.dev = dev; - cnt->track.pan_angle = 0; - cnt->track.tilt_angle = 0; - cnt->track.minmaxfound = 1; - } - -- -+ - /* If we are on auto track we calculate delta, otherwise we use user input in degrees */ - if (!manual) { -- if (delta_x > imgs->width * 3 / 8 && delta_x < imgs->width * 5 / 8) -+ if (delta_x > imgs->width * 3/8 && delta_x < imgs->width * 5/8) - return 0; -- if (delta_y > imgs->height * 3 / 8 && delta_y < imgs->height * 5 / 8) -+ if (delta_y > imgs->height * 3/8 && delta_y < imgs->height * 5/8) - return 0; - - move_x_degrees = delta_x * cnt->track.step_angle_x / (imgs->width / 2); -@@ -780,91 +1136,92 @@ static unsigned short int uvc_move(struc - union pantilt pan; - - if (cnt->track.minmaxfound == 1) { -- /* Check current position of camera and see if we need to adjust -- values down to what is left to move */ -- if (move_x_degrees<0 && (cnt->track.panmin - cnt->track.pan_angle) > move_x_degrees) -- move_x_degrees = (cnt->track.panmin - cnt->track.pan_angle); -- -- if (move_x_degrees>0 && (cnt->track.panmax - cnt->track.pan_angle) < move_x_degrees) -- move_x_degrees = (cnt->track.panmax - cnt->track.pan_angle); -- -- if (move_y_degrees<0 && (cnt->track.tiltmin - cnt->track.tilt_angle) > move_y_degrees) -- move_y_degrees = (cnt->track.tiltmin - cnt->track.tilt_angle); -- -- if (move_y_degrees>0 && (cnt->track.tiltmax - cnt->track.tilt_angle) < move_y_degrees) -- move_y_degrees = (cnt->track.tiltmax - cnt->track.tilt_angle); -- } -- -+ /* -+ * Check current position of camera and see if we need to adjust -+ * values down to what is left to move -+ */ -+ if (move_x_degrees < 0 && (cnt->track.minx - cnt->track.pan_angle) > move_x_degrees) -+ move_x_degrees = cnt->track.minx - cnt->track.pan_angle; -+ -+ if (move_x_degrees > 0 && (cnt->track.maxx - cnt->track.pan_angle) < move_x_degrees) -+ move_x_degrees = cnt->track.maxx - cnt->track.pan_angle; -+ -+ if (move_y_degrees < 0 && (cnt->track.miny - cnt->track.tilt_angle) > move_y_degrees) -+ move_y_degrees = cnt->track.miny - cnt->track.tilt_angle; -+ -+ if (move_y_degrees > 0 && (cnt->track.maxy - cnt->track.tilt_angle) < move_y_degrees) -+ move_y_degrees = cnt->track.maxy - cnt->track.tilt_angle; -+ } -+ -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "For_SET_REL pan_min %d,pan_max %d,tilt_min %d,tilt_max %d", -+ cnt->track.minx, cnt->track.maxx, cnt->track.miny, cnt->track.maxy); -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "For_SET_REL track_pan_Angel %d, track_tilt_Angel %d", -+ cnt->track.pan_angle, cnt->track.tilt_angle); -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "For_SET_REL move_X %d,move_Y %d", move_x_degrees, move_y_degrees); - -- motion_log(LOG_DEBUG, 0, "For_SET_REL pan_min %d,pan_max %d,tilt_min %d,tilt_max %d ", -- cnt->track.panmin, cnt->track.panmax, cnt->track.tiltmin, cnt->track.tiltmax ); -- motion_log(LOG_DEBUG, 0, "For_SET_REL track_pan_Angel %d, track_tilt_Angel %d ", -- cnt->track.pan_angle, cnt->track.tilt_angle); -- motion_log(LOG_DEBUG, 0, "For_SET_REL move_X %d,move_Y %d", -- move_x_degrees, move_y_degrees); - /* -- tilt up: - value -- tilt down: + value -- pan left: - value -- pan right: + value -- */ -+ * tilt up: - value -+ * tilt down: + value -+ * pan left: - value -+ * pan right: + value -+ */ - - pan.s16.pan = -move_x_degrees * INCPANTILT; - pan.s16.tilt = -move_y_degrees * INCPANTILT; -- -- /* DWe 30.03.07 Must be broken in diff calls, because -- - one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS -- - The Webcam or uvcvideo does not like a call with a zero-move -- */ -+ -+ /* DWe 30.03.07 Must be broken in diff calls, because -+ * one call for both is not accept via VIDIOC_S_CTRL -> maybe via VIDIOC_S_EXT_CTRLS -+ * The Webcam or uvcvideo does not like a call with a zero-move -+ */ - - if (move_x_degrees != 0) { - - control_s.id = V4L2_CID_PAN_RELATIVE; - - control_s.value = pan.s16.pan; -- motion_log(LOG_DEBUG, 0," dev %d,addr= %d, control_S= %d,Wert= %d,", -- dev,VIDIOC_S_CTRL, &control_s, pan.s16.pan ); -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, " dev %d, addr= %d, control_S= %d, Wert= %d", -+ dev, VIDIOC_S_CTRL, &control_s, pan.s16.pan); - -- if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); -+ if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); - return 0; - } - } -- -- /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ -- if ((move_x_degrees != 0) && (move_y_degrees != 0)) -- SLEEP (1,0); -- -+ -+ /* DWe 30.03.07 We must wait a little,before we set the next CMD, otherwise PAN is mad ... */ -+ if ((move_x_degrees != 0) && (move_y_degrees != 0)) -+ SLEEP (1, 0); - - - if (move_y_degrees != 0) { - - control_s.id = V4L2_CID_TILT_RELATIVE; -+ - control_s.value = pan.s16.tilt; -- motion_log(LOG_DEBUG, 0," dev %d,addr= %d, control_S= %d, Wert= %d, ", -- dev,VIDIOC_S_CTRL, &control_s, pan.s16.tilt); -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, " dev %d,addr= %d, control_S= %d, Wert= %d", -+ dev, VIDIOC_S_CTRL, &control_s, pan.s16.tilt); - - if (ioctl(dev, VIDIOC_S_CTRL, &control_s) < 0) { -- motion_log(LOG_ERR, 1, "Failed to move UVC camera!"); -+ MOTION_LOG(ERR, TYPE_TRACK, SHOW_ERRNO, "%s: Failed to move UVC camera!"); - return 0; - } - } -- -- -- motion_log(LOG_DEBUG, 0,"Found MINMAX = %d", cnt->track.minmaxfound); -- -+ -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "%s: Found MINMAX = %d", -+ cnt->track.minmaxfound); -+ - if (cnt->track.minmaxfound == 1) { -- motion_log(LOG_DEBUG, 0," Before_REL_Y_Angel : x= %d , Y= %d", -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "Before_REL_Y_Angel : x= %d , Y= %d", - cnt->track.pan_angle, cnt->track.tilt_angle); -- -- if (move_x_degrees != 0) -+ -+ if (move_x_degrees != 0) - cnt->track.pan_angle += -pan.s16.pan / INCPANTILT; -- -+ - if (move_y_degrees != 0) - cnt->track.tilt_angle += -pan.s16.tilt / INCPANTILT; -- -- motion_log(LOG_DEBUG, 0," After_REL_Y_Angel : x= %d , Y= %d", -- cnt->track.pan_angle, cnt->track.tilt_angle); -+ -+ MOTION_LOG(DBG, TYPE_TRACK, NO_ERRNO, "After_REL_Y_Angel : x= %d , Y= %d", -+ cnt->track.pan_angle, cnt->track.tilt_angle); - } - - return cnt->track.move_wait; ---- motion-3.2.12.orig/track.h -+++ motion-3.2.12/track.h -@@ -10,40 +10,43 @@ - #define _INCLUDE_TRACK_H - - #include "alg.h" -+#include - - struct trackoptions { - int dev; - /* Config options: */ -- unsigned short int type; -+ unsigned int type; - char *port; -- unsigned short int motorx; -- unsigned short int motory; -- unsigned short int maxx; -- unsigned short int maxy; -- unsigned short int stepsize; -- unsigned short int speed; -- unsigned short int iomojo_id; -- unsigned short int active; -- int panmin; -- int panmax; -- int tiltmin; -- int tiltmax; -- unsigned short int minmaxfound; -- unsigned short int step_angle_x; -- unsigned short int step_angle_y; -- unsigned short int move_wait; -- // UVC -+ unsigned int motorx; -+ unsigned int motory; -+ int maxx; -+ int maxy; -+ int minx; -+ int miny; -+ unsigned int stepsize; -+ unsigned int speed; -+ unsigned int homex; -+ unsigned int homey; -+ unsigned int iomojo_id; -+ unsigned int active; -+ unsigned int motorx_reverse; -+ unsigned int motory_reverse; -+ unsigned int minmaxfound; -+ unsigned int step_angle_x; -+ unsigned int step_angle_y; -+ unsigned int move_wait; -+ /* UVC */ - int pan_angle; // degrees - int tilt_angle; // degrees - }; - - extern struct trackoptions track_template; - --unsigned short int track_center(struct context *, int, unsigned short int, int, int); --unsigned short int track_move(struct context *, int, struct coord *, struct images *, unsigned short int); -+unsigned int track_center(struct context *, int, unsigned int, int, int); -+unsigned int track_move(struct context *, int, struct coord *, struct images *, unsigned int); - - /* -- Some default values: -+ * Some default values: - */ - #define TRACK_SPEED 255 - #define TRACK_STEPSIZE 40 -@@ -53,9 +56,10 @@ unsigned short int track_move(struct con - #define TRACK_TYPE_PWC 3 - #define TRACK_TYPE_GENERIC 4 - #define TRACK_TYPE_UVC 5 -+#define TRACK_TYPE_SERVO 6 - - /* -- Some defines for the Serial stepper motor: -+ * Some defines for the Serial stepper motor: - */ - - #define STEPPER_BAUDRATE B9600 -@@ -87,8 +91,53 @@ unsigned short int track_move(struct con - #define STEPPER_COMMAND_DOWN 4 - - -+ - /* -- Some defines for the Iomojo Smilecam: -+ * Some defines for the Serial servo motor: -+ */ -+ -+/* -+ * Controlling: -+ * Three bytes are sent to the servo - BYTE1=SERVO_COMMAND BYTE2=COMMAND BYTE3=DATA -+ * eg, sending the command 01 02 08 would Command SERVO_COMMAND1 to move LEFT a total of 8 STEPS -+ * -+ * An extra command 0x08 has been added but here is the basic command set. -+ * -+ * 0x00 STATUS - Current status byte will be returned, data byte ignored -+ * 0x01 LEFT_N - Servo will take N Steps to the Left until it reaches the Servos safety limit -+ * 0x02 RIGHT_N - Servo will take N Steps to the Right until it reaches the Servos safety limit -+ * 0x03 LEFT - Servo will move to Left most position, data byte ignored. -+ * 0x04 RIGHT - Servo will move to Right most position, data byte ignored. -+ * 0x05 SWEEP - Servo will sweep between its extremes, data byte ignored. -+ * 0x06 STOP - Servo will Stop, data byte ignored -+ * 0x07 SPEED - Set servos speed between 0 and 255. -+ * 0x08 ABSOLUTE - Set servo to absolute position between 0 and 255 -+ * 0x09 POSITION - Get servo to absolute position between 0 and 255 -+ * */ -+ -+#define SERVO_BAUDRATE B9600 -+ -+#define SERVO_COMMAND_STATUS 0 -+#define SERVO_COMMAND_LEFT_N 1 -+#define SERVO_COMMAND_RIGHT_N 2 -+#define SERVO_COMMAND_LEFT 3 -+#define SERVO_COMMAND_RIGHT 4 -+#define SERVO_COMMAND_SWEEP 5 -+#define SERVO_COMMAND_STOP 6 -+#define SERVO_COMMAND_SPEED 7 -+#define SERVO_COMMAND_ABSOLUTE 8 -+#define SERVO_COMMAND_POSITION 9 -+ -+ -+#define SERVO_COMMAND_UP_N 1 -+#define SERVO_COMMAND_DOWN_N 2 -+#define SERVO_COMMAND_UP 3 -+#define SERVO_COMMAND_DOWN 4 -+ -+ -+ -+/* -+ * Some defines for the Iomojo Smilecam: - */ - - #define IOMOJO_BAUDRATE B19200 -@@ -109,14 +158,14 @@ unsigned short int track_move(struct con - #ifndef WITHOUT_V4L - - /* -- Defines for the Logitech QuickCam Orbit/Sphere USB webcam --*/ -+ * Defines for the Logitech QuickCam Orbit/Sphere USB webcam -+ */ - - #define LQOS_VERTICAL_DEGREES 180 - #define LQOS_HORIZONAL_DEGREES 120 - - /* -- * UVC -+ * UVC - */ - - #ifdef MOTION_V4L2 ---- motion-3.2.12.orig/version.sh -+++ motion-3.2.12/version.sh -@@ -3,4 +3,6 @@ - SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` - test $SNV_VERSION || SNV_VERSION=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` - test $SNV_VERSION || SNV_VERSION=UNKNOWN --echo -n "3.2.12" -+SNV_VERSION=`git show -s --format=%h` -+echo -n "3.2.12-4ppa01" -+ ---- motion-3.2.12.orig/video.c -+++ motion-3.2.12/video.c -@@ -1,4 +1,5 @@ --/* video.c -+/* -+ * video.c - * - * Video stream functions for motion. - * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) -@@ -6,20 +7,15 @@ - * See also the file 'COPYING'. - * - */ --#ifndef WITHOUT_V4L -- - /* Common stuff: */ - #include "rotate.h" /* already includes motion.h */ - #include "video.h" - -+#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) - --/* for the v4l stuff: */ --#include --#include --#include --#include -- -- -+/** -+ * v4l_picture_controls -+ */ - static void v4l_picture_controls(struct context *cnt, struct video_dev *viddev) - { - int dev = viddev->fd; -@@ -29,7 +25,7 @@ static void v4l_picture_controls(struct - if (cnt->conf.contrast && cnt->conf.contrast != viddev->contrast) { - - if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); - - make_change = 1; - vid_pic.contrast = cnt->conf.contrast * 256; -@@ -39,8 +35,8 @@ static void v4l_picture_controls(struct - if (cnt->conf.saturation && cnt->conf.saturation != viddev->saturation) { - - if (!make_change) { -- if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); -+ if (ioctl(dev, VIDIOCGPICT, &vid_pic)==-1) -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); - } - - make_change = 1; -@@ -52,7 +48,7 @@ static void v4l_picture_controls(struct - - if (!make_change) { - if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); - } - - make_change = 1; -@@ -67,71 +63,72 @@ static void v4l_picture_controls(struct - int fps; - - if (ioctl(dev, VIDIOCGWIN, &vw) == -1) { -- motion_log(LOG_ERR, 1, "%s: ioctl VIDIOCGWIN", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl VIDIOCGWIN"); - } else { - fps = vw.flags >> PWC_FPS_SHIFT; -- motion_log(LOG_DEBUG, 0, "%s: Get Current framerate %d .. trying %d", -- __FUNCTION__, fps, cnt->conf.frame_limit); -+ MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: Get Current framerate %d .. trying %d", -+ fps, cnt->conf.frame_limit); - } - - fps = cnt->conf.frame_limit; - vw.flags = fps << PWC_FPS_SHIFT; -- -+ - if (ioctl(dev, VIDIOCSWIN, &vw) == -1) { -- motion_log(LOG_ERR, 1, "%s: ioctl VIDIOCSWIN", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl VIDIOCSWIN"); - } else if (ioctl(dev, VIDIOCGWIN, &vw) == -1) { -- motion_log(LOG_ERR, 1, "%s: ioctl VIDIOCGWIN", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl VIDIOCGWIN"); - } else { - fps = vw.flags >> PWC_FPS_SHIFT; -- motion_log(LOG_DEBUG, 0, "%s: Set new framerate %d", __FUNCTION__, fps); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set new framerate %d", fps); - } - - viddev->fps = fps; - } - #endif - -- - if (cnt->conf.autobright) { - - if (vid_do_autobright(cnt, viddev)) { -- /* If we already read the VIDIOGPICT - we should not do it again */ -+ /* If we already read the VIDIOGPICT - we should not do it again. */ - if (!make_change) { - if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); - } - - vid_pic.brightness = viddev->brightness * 256; - make_change = 1; - } - -- } else { -- if (cnt->conf.brightness && cnt->conf.brightness != viddev->brightness) { -- if (!make_change) { -- if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); -- } -- -- make_change = 1; -- vid_pic.brightness = cnt->conf.brightness * 256; -- viddev->brightness = cnt->conf.brightness; -- } -+ } else if (cnt->conf.brightness && cnt->conf.brightness != viddev->brightness) { -+ -+ if ((!make_change) && (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1)) -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); -+ -+ make_change = 1; -+ vid_pic.brightness = cnt->conf.brightness * 256; -+ viddev->brightness = cnt->conf.brightness; - } - - if (make_change) { - if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSPICT)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSPICT)"); - } - } - -- -- --/******************************************************************************************* -+/******************************************************************************* - Video4linux capture routines --*/ -+********************************************************************************/ - -- --unsigned char *v4l_start(struct context *cnt, struct video_dev *viddev, int width, int height, -- int input, int norm, unsigned long freq, int tuner_number) -+/** -+ * v4l_start -+ * Initialize video device to start capturing and allocates memory map -+ * for video device. -+ * -+ * Returns mmapped buffer for video device or NULL if any error happens. -+ * -+ */ -+unsigned char *v4l_start(struct video_dev *viddev, int width, int height,int input, -+ int norm, unsigned long freq, int tuner_number) - { - int dev = viddev->fd; - struct video_capability vid_caps; -@@ -142,7 +139,7 @@ unsigned char *v4l_start(struct context - void *map; - - if (ioctl (dev, VIDIOCGCAP, &vid_caps) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGCAP)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGCAP)"); - return NULL; - } - -@@ -154,12 +151,14 @@ unsigned char *v4l_start(struct context - vid_chnl.channel = input; - - if (ioctl (dev, VIDIOCGCHAN, &vid_chnl) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGCHAN)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGCHAN) Input %d", -+ input); - } else { - vid_chnl.channel = input; - vid_chnl.norm = norm; - if (ioctl (dev, VIDIOCSCHAN, &vid_chnl) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSCHAN)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSCHAN) Input %d" -+ " Standard method %d", input, norm); - return NULL; - } - } -@@ -169,28 +168,29 @@ unsigned char *v4l_start(struct context - memset(&vid_tuner, 0, sizeof(struct video_tuner)); - vid_tuner.tuner = tuner_number; - if (ioctl (dev, VIDIOCGTUNER, &vid_tuner) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGTUNER)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGTUNER) tuner %d", -+ tuner_number); - } else { -- if (vid_tuner.flags & VIDEO_TUNER_LOW) { -+ if (vid_tuner.flags & VIDEO_TUNER_LOW) - freq = freq * 16; /* steps of 1/16 KHz */ -- } else { -- freq = (freq * 10) / 625; -- } -- -+ else -+ freq = freq * 10 / 625; -+ - if (ioctl(dev, VIDIOCSFREQ, &freq) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSFREQ)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSFREQ)" -+ " Frequency %ul", freq); - return NULL; - } - -- if (cnt->conf.setup_mode) -- motion_log(-1, 0, "Frequency set"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Tuner to %d Frequency set to %ul", -+ tuner_number, freq); - } - } - - if (ioctl (dev, VIDIOCGMBUF, &vid_buf) == -1) { -- motion_log(LOG_ERR, 0, "ioctl(VIDIOCGMBUF) - Error device does not support memory map"); -- motion_log(LOG_ERR, 0, "V4L capturing using read is deprecated!"); -- motion_log(LOG_ERR, 0, "Motion only supports mmap."); -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: ioctl(VIDIOCGMBUF) - Error device" -+ " does not support memory map\n V4L capturing using read is deprecated!\n" -+ "Motion only supports mmap."); - return NULL; - } else { - map = mmap(0, vid_buf.size, PROT_READ|PROT_WRITE, MAP_SHARED, dev, 0); -@@ -206,7 +206,7 @@ unsigned char *v4l_start(struct context - } - - if (MAP_FAILED == map) { -- motion_log(LOG_ERR,1,"MAP_FAILED"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: MAP_FAILED"); - return NULL; - } - -@@ -215,32 +215,35 @@ unsigned char *v4l_start(struct context - vid_mmap.frame = viddev->v4l_curbuffer; - vid_mmap.width = width; - vid_mmap.height = height; -+ - if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { -- motion_log(LOG_DEBUG, 1, "Failed with YUV420P, trying YUV422 palette"); -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with YUV420P, " -+ "trying YUV422 palette"); - viddev->v4l_fmt = VIDEO_PALETTE_YUV422; - vid_mmap.format = viddev->v4l_fmt; -- - /* Try again... */ - if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { -- motion_log(LOG_DEBUG, 1, "Failed with YUV422, trying YUYV palette"); -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with YUV422," -+ " trying YUYV palette"); - viddev->v4l_fmt = VIDEO_PALETTE_YUYV; - vid_mmap.format = viddev->v4l_fmt; - - if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { -- motion_log(LOG_DEBUG, 1, "Failed with YUYV, trying RGB24 palette"); -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with YUYV, trying RGB24 palette"); - viddev->v4l_fmt = VIDEO_PALETTE_RGB24; - vid_mmap.format = viddev->v4l_fmt; -- - /* Try again... */ -+ - if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { -- motion_log(LOG_DEBUG, 1, "Failed with RGB24, trying GREYSCALE palette"); -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with RGB24, trying" -+ "GREYSCALE palette"); - viddev->v4l_fmt = VIDEO_PALETTE_GREY; - vid_mmap.format = viddev->v4l_fmt; - - /* Try one last time... */ - if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { -- motion_log(LOG_ERR, 1, "Failed with all supported palettes " -- "- giving up"); -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed with all supported palettes " -+ "- giving up"); - return NULL; - } - } -@@ -252,23 +255,23 @@ unsigned char *v4l_start(struct context - switch (viddev->v4l_fmt) { - case VIDEO_PALETTE_YUV420P: - viddev->v4l_bufsize = (width * height * 3) / 2; -- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_YUV420P palette"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_YUV420P palette"); - break; - case VIDEO_PALETTE_YUV422: - viddev->v4l_bufsize = (width * height * 2); -- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_YUV422 palette"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_YUV422 palette"); - break; - case VIDEO_PALETTE_YUYV: - viddev->v4l_bufsize = (width * height * 2); -- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_YUYV palette"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_YUYV palette"); - break; - case VIDEO_PALETTE_RGB24: - viddev->v4l_bufsize = (width * height * 3); -- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_RGB24 palette"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_RGB24 palette"); - break; - case VIDEO_PALETTE_GREY: - viddev->v4l_bufsize = width * height; -- motion_log(LOG_DEBUG, 0, "Using VIDEO_PALETTE_GREY palette"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using VIDEO_PALETTE_GREY palette"); - break; - } - -@@ -278,7 +281,7 @@ unsigned char *v4l_start(struct context - - /** - * v4l_next -- * v4l_next fetches a video frame from a v4l device -+ * Fetches a video frame from a v4l device - * - * Parameters: - * viddev Pointer to struct containing video device handle amd device parameters -@@ -299,7 +302,7 @@ int v4l_next(struct video_dev *viddev, u - struct video_mmap vid_mmap; - unsigned char *cap_map; - -- sigset_t set, old; -+ sigset_t set, old; - - /* MMAP method is used */ - vid_mmap.format = viddev->v4l_fmt; -@@ -324,7 +327,8 @@ int v4l_next(struct video_dev *viddev, u - vid_mmap.frame = viddev->v4l_curbuffer; - - if (ioctl(dev, VIDIOCMCAPTURE, &vid_mmap) == -1) { -- motion_log(LOG_ERR, 1, "mcapture error in proc %d", getpid()); -+ MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO, "%s: mcapture error in proc %d", -+ getpid()); - sigprocmask (SIG_UNBLOCK, &old, NULL); - return V4L_FATAL_ERROR; - } -@@ -332,11 +336,12 @@ int v4l_next(struct video_dev *viddev, u - vid_mmap.frame = frame; - - if (ioctl(dev, VIDIOCSYNC, &vid_mmap.frame) == -1) { -- motion_log(LOG_ERR, 1, "sync error in proc %d", getpid()); -+ MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO, "%s: sync error in proc %d", -+ getpid()); - sigprocmask (SIG_UNBLOCK, &old, NULL); - } - -- pthread_sigmask (SIG_UNBLOCK, &old, NULL); /*undo the signal blocking*/ -+ pthread_sigmask (SIG_UNBLOCK, &old, NULL); /*undo the signal blocking*/ - - switch (viddev->v4l_fmt) { - case VIDEO_PALETTE_RGB24: -@@ -353,35 +358,59 @@ int v4l_next(struct video_dev *viddev, u - return 0; - } - --void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, -- int height, int input, int norm, int skip, unsigned long freq, int tuner_number) -+/** -+ * v4l_set_input -+ * Sets input for video device, adjust picture controls. -+ * If needed skip frames for round robin. -+ * -+ * Parameters: -+ * cnt Pointer to context struct -+ * viddev Pointer to struct containing video device handle amd device parameters -+ * map Pointer to the buffer in which the function puts the new image -+ * width Width of image in pixels -+ * height Height of image in pixels -+ * conf Pointer to config struct -+ * -+ * Returns nothing -+ */ -+void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, -+ int width, int height, struct config *conf) - { - int dev = viddev->fd; -- int i; - struct video_channel vid_chnl; - struct video_tuner vid_tuner; -- unsigned long frequnits = freq; -+ unsigned long frequnits , freq; -+ int input = conf->input; -+ int norm = conf->norm; -+ int tuner_number = conf->tuner_number; - -- if (input != viddev->input || width != viddev->width || height != viddev->height || -- freq != viddev->freq || tuner_number != viddev->tuner_number) { -+ frequnits = freq = conf->frequency; - -+ if (input != viddev->input || width != viddev->width || height != viddev->height || -+ freq != viddev->freq || tuner_number != viddev->tuner_number || norm != viddev->norm) { -+ unsigned int skip = conf->roundrobin_skip, i; -+ - if (freq) { - memset(&vid_tuner, 0, sizeof(struct video_tuner)); -- - vid_tuner.tuner = tuner_number; -+ - if (ioctl (dev, VIDIOCGTUNER, &vid_tuner) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGTUNER)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGTUNER) tuner number %d", -+ tuner_number); - } else { - if (vid_tuner.flags & VIDEO_TUNER_LOW) - frequnits = freq * 16; /* steps of 1/16 KHz */ - else - frequnits = (freq * 10) / 625; - -- - if (ioctl(dev, VIDIOCSFREQ, &frequnits) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSFREQ)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSFREQ) Frequency %ul", -+ frequnits); - return; - } -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Tuner to %d Frequency to %ul", -+ tuner_number, frequnits); - } - } - -@@ -389,233 +418,35 @@ void v4l_set_input(struct context *cnt, - vid_chnl.channel = input; - - if (ioctl (dev, VIDIOCGCHAN, &vid_chnl) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGCHAN)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGCHAN) Input %d", -+ input); - } else { - vid_chnl.channel = input; - vid_chnl.norm = norm; -+ - if (ioctl (dev, VIDIOCSCHAN, &vid_chnl) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSCHAN)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSCHAN) Input %d" -+ " Standard method %d", input, norm); - return; -- } -+ } -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Input to %d Standard method to %d", -+ input, norm); - } - - v4l_picture_controls(cnt, viddev); -- viddev->input = input; -- viddev->width = width; -- viddev->height = height; -- viddev->freq =freq; -- viddev->tuner_number = tuner_number; -+ conf->input = viddev->input = input; -+ conf->width = viddev->width = width; -+ conf->height = viddev->height = height; -+ conf->frequency = viddev->freq = freq; -+ conf->tuner_number = viddev->tuner_number = tuner_number; -+ conf->norm = viddev->norm = norm; - /* skip a few frames if needed */ - for (i = 0; i < skip; i++) - v4l_next(viddev, map, width, height); -- - } else { - /* No round robin - we only adjust picture controls */ - v4l_picture_controls(cnt, viddev); - } - } -- --static int v4l_open_vidpipe(void) --{ -- int pipe_fd = -1; -- char pipepath[255]; -- char buffer[255]; -- char *major; -- char *minor; -- struct utsname uts; -- -- if (uname(&uts) < 0) { -- motion_log(LOG_ERR, 1, "Unable to execute uname"); -- return -1; -- } -- major = strtok(uts.release, "."); -- minor = strtok(NULL, "."); -- -- if ((major == NULL) || (minor == NULL) || (strcmp(major, "2"))) { -- motion_log(LOG_ERR, 1, "Unable to decipher OS version"); -- return -1; -- } -- -- if (strcmp(minor, "5") < 0) { -- FILE *vloopbacks; -- char *loop; -- char *input; -- char *istatus; -- char *output; -- char *ostatus; -- -- vloopbacks = fopen("/proc/video/vloopback/vloopbacks", "r"); -- -- if (!vloopbacks) { -- motion_log(LOG_ERR, 1, "Failed to open '/proc/video/vloopback/vloopbacks'"); -- return -1; -- } -- -- /* Read vloopback version*/ -- if (!fgets(buffer, 255, vloopbacks)) { -- motion_log(LOG_ERR, 1, "Unable to read vloopback version"); -- return -1; -- } -- -- fprintf(stderr,"\t%s", buffer); -- -- /* Read explanation line */ -- -- if (!fgets(buffer, 255, vloopbacks)) { -- motion_log(LOG_ERR, 1, "Unable to read vloopback explanation line"); -- return -1; -- } -- -- while (fgets(buffer, 255, vloopbacks)) { -- if (strlen(buffer) > 1) { -- buffer[strlen(buffer)-1] = 0; -- loop=strtok(buffer, "\t"); -- input=strtok(NULL, "\t"); -- istatus=strtok(NULL, "\t"); -- output=strtok(NULL, "\t"); -- ostatus=strtok(NULL, "\t"); -- if (istatus[0] == '-') { -- snprintf(pipepath, 255, "/dev/%s", input); -- pipe_fd = open(pipepath, O_RDWR); -- if (pipe_fd >= 0) { -- motion_log(-1, 0, "\tInput: /dev/%s", input); -- motion_log(-1, 0, "\tOutput: /dev/%s", output); -- break; -- } -- } -- } -- } -- fclose(vloopbacks); -- } else { -- DIR *dir; -- struct dirent *dirp; -- const char prefix[] = "/sys/class/video4linux/"; -- char *ptr, *io; -- int fd; -- int low = 9999; -- int tfd; -- int tnum; -- -- if ((dir=opendir(prefix)) == NULL) { -- motion_log(LOG_ERR, 1, "Failed to open '%s'", prefix); -- return -1; -- } -- -- while ((dirp=readdir(dir)) != NULL) { -- if (!strncmp(dirp->d_name, "video", 5)) { -- strncpy(buffer, prefix, sizeof(buffer)); -- strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); -- strncat(buffer, "/name", sizeof(buffer) - strlen(buffer)); -- if ((fd = open(buffer, O_RDONLY)) >= 0) { -- if ((read(fd, buffer, sizeof(buffer)-1)) < 0) { -- close(fd); -- continue; -- } -- -- ptr = strtok(buffer, " "); -- -- if (strcmp(ptr,"Video")) { -- close(fd); -- continue; -- } -- -- major = strtok(NULL, " "); -- minor = strtok(NULL, " "); -- io = strtok(NULL, " \n"); -- -- if (strcmp(major, "loopback") || strcmp(io, "input")) { -- close(fd); -- continue; -- } -- -- if ((ptr=strtok(buffer, " ")) == NULL) { -- close(fd); -- continue; -- } -- -- tnum = atoi(minor); -- -- if (tnum < low) { -- strcpy(buffer, "/dev/"); -- strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); -- if ((tfd=open(buffer, O_RDWR)) >= 0) { -- strncpy(pipepath, buffer, sizeof(pipepath)); -- -- if (pipe_fd >= 0) -- close(pipe_fd); -- -- pipe_fd = tfd; -- low = tnum; -- } -- } -- close(fd); -- } -- } -- } -- closedir(dir); -- -- if (pipe_fd >= 0) -- motion_log(-1, 0, "Opened input of %s", pipepath); -- } -- -- return pipe_fd; --} -- --static int v4l_startpipe(const char *dev_name, int width, int height, int type) --{ -- int dev; -- struct video_picture vid_pic; -- struct video_window vid_win; -- -- if (!strcmp(dev_name, "-")) -- dev = v4l_open_vidpipe(); -- else -- dev = open(dev_name, O_RDWR); -- -- if (dev < 0) -- return -1; -- -- if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGPICT)"); -- return -1; -- } -- -- vid_pic.palette = type; -- -- if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSPICT)"); -- return -1; -- } -- -- if (ioctl(dev, VIDIOCGWIN, &vid_win) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCGWIN)"); -- return -1; -- } -- -- vid_win.height = height; -- vid_win.width = width; -- -- if (ioctl(dev, VIDIOCSWIN, &vid_win) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSWIN)"); -- return -1; -- } -- -- return dev; --} -- --static int v4l_putpipe (int dev, unsigned char *image, int size) --{ -- return write(dev, image, size); --} -- -- --int vid_startpipe(const char *dev_name, int width, int height, int type) --{ -- return v4l_startpipe(dev_name, width, height, type); --} -- --int vid_putpipe (int dev, unsigned char *image, int size) --{ -- return v4l_putpipe(dev, image, size); --} --#endif /*WITHOUT_V4L*/ -+#endif /* !WITHOUT_V4L */ ---- motion-3.2.12.orig/video.h -+++ motion-3.2.12/video.h -@@ -1,6 +1,6 @@ --/* video.h -+/* video.h - * -- * Include file for video.c -+ * Include file for video.c - * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) - * This software is distributed under the GNU public license version 2 - * See also the file 'COPYING'. -@@ -11,30 +11,42 @@ - #define _INCLUDE_VIDEO_H - - #define _LINUX_TIME_H 1 --#ifndef WITHOUT_V4L --#include - #include -+ -+ -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) -+#include -+#include "vloopback_motion.h" - #include "pwc-ioctl.h" - #endif - - /* video4linux stuff */ --#define NORM_DEFAULT 0 --#define NORM_PAL 0 --#define NORM_NTSC 1 --#define NORM_SECAM 2 --#define NORM_PAL_NC 3 --#define IN_DEFAULT 8 --#define IN_TV 0 --#define IN_COMPOSITE 1 --#define IN_COMPOSITE2 2 --#define IN_SVIDEO 3 -+#define NORM_DEFAULT 0 -+#define NORM_PAL 0 -+#define NORM_NTSC 1 -+#define NORM_SECAM 2 -+#define NORM_PAL_NC 3 -+#define IN_DEFAULT -1 -+#define IN_TV 0 -+#define IN_COMPOSITE 1 -+#define IN_COMPOSITE2 2 -+#define IN_SVIDEO 3 - - /* video4linux error codes */ --#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ --#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ --#define V4L_FATAL_ERROR -1 -+#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ -+#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ -+#define V4L_FATAL_ERROR -1 -+ -+#define VIDEO_DEVICE "/dev/video0" -+ -+typedef struct video_image_buff { -+ unsigned char *ptr; -+ int content_length; -+ size_t size; /* total allocated size */ -+ size_t used; /* bytes already used */ -+ struct timeval image_time; /* time this image was received */ -+} video_buff; - --#define VIDEO_DEVICE "/dev/video0" - - struct video_dev { - struct video_dev *next; -@@ -42,6 +54,7 @@ struct video_dev { - int fd; - const char *video_device; - int input; -+ int norm; - int width; - int height; - int brightness; -@@ -62,7 +75,7 @@ struct video_dev { - /* v4l */ - int v4l2; - void *v4l2_private; -- -+ - int size_map; - int v4l_fmt; - unsigned char *v4l_buffers[2]; -@@ -73,39 +86,35 @@ struct video_dev { - }; - - /* video functions, video_common.c */ --int vid_start(struct context *); --int vid_next(struct context *, unsigned char *map); -+int vid_start(struct context *cnt); -+int vid_next(struct context *cnt, unsigned char *map); - void vid_close(struct context *cnt); - void vid_cleanup(void); - void vid_init(void); - void conv_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height); - void conv_uyvyto420p(unsigned char *map, unsigned char *cap_map, unsigned int width, unsigned int height); - void conv_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height); --int conv_jpeg2yuv420(struct context *cnt, unsigned char *dst, netcam_buff * buff, int width, int height); --int sonix_decompress(unsigned char *outp, unsigned char *inp,int width, int height); -+int sonix_decompress(unsigned char *outp, unsigned char *inp, int width, int height); - void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height); - int vid_do_autobright(struct context *cnt, struct video_dev *viddev); - int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size); - - #ifndef WITHOUT_V4L - /* video functions, video.c */ --int vid_startpipe(const char *dev_name, int width, int height, int); --int vid_putpipe(int dev, unsigned char *image, int); --unsigned char *v4l_start(struct context *cnt, struct video_dev *viddev, int width, int height, -+unsigned char *v4l_start(struct video_dev *viddev, int width, int height, - int input, int norm, unsigned long freq, int tuner_number); --void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, -- int height, int input, int norm, int skip, unsigned long freq, int tuner_number); -+void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, -+ struct config *conf); - int v4l_next(struct video_dev *viddev, unsigned char *map, int width, int height); - - /* video2.c */ - unsigned char *v4l2_start(struct context *cnt, struct video_dev *viddev, int width, int height, - int input, int norm, unsigned long freq, int tuner_number); --void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, -- int height, struct config *conf); -+void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, -+ struct config *conf); - int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height); - void v4l2_close(struct video_dev *viddev); - void v4l2_cleanup(struct video_dev *viddev); -- - #endif /* WITHOUT_V4L */ - --#endif /* _INCLUDE_VIDEO_H */ -+#endif /* _INCLUDE_VIDEO_H */ ---- motion-3.2.12.orig/video2.c -+++ motion-3.2.12/video2.c -@@ -3,35 +3,57 @@ - * - * V4L2 interface with basically JPEG decompression support and even more ... - * Copyright 2006 Krzysztof Blaszkowski (kb@sysmikro.com.pl) -- * 2007 Angel Carpintero (ack@telefonica.net) -- -+ * 2007 Angel Carpintero (motiondevelop@gmail.com) -+ - * Supported features and TODO -- * - preferred palette is JPEG which seems to be very popular for many 640x480 usb cams -- * - other supported palettes (NOT TESTED) -- * V4L2_PIX_FMT_SBGGR8 (sonix) -- * V4L2_PIX_FMT_SN9C10X (sonix) -- * V4L2_PIX_FMT_MJPEG, (tested) -- * V4L2_PIX_FMT_JPEG, (tested) -- V4L2_PIX_FMT_RGB24, -- V4L2_PIX_FMT_UYVY, (tested) -- V4L2_PIX_FMT_YUV422P, -- V4L2_PIX_FMT_YUV420, (tested) -- V4L2_PIX_FMT_YUYV (tested) -- -- * - setting tuner - NOT TESTED -+ - preferred palette is JPEG which seems to be very popular for many 640x480 usb cams -+ - other supported palettes (NOT TESTED) -+ V4L2_PIX_FMT_SN9C10X (sonix) -+ V4L2_PIX_FMT_SBGGR16, -+ V4L2_PIX_FMT_SBGGR8, (sonix) -+ V4L2_PIX_FMT_SPCA561, -+ V4L2_PIX_FMT_SGBRG8, -+ V4L2_PIX_FMT_SGRBG8, -+ V4L2_PIX_FMT_PAC207, -+ V4L2_PIX_FMT_PJPG, -+ V4L2_PIX_FMT_MJPEG, (tested) -+ V4L2_PIX_FMT_JPEG, (tested) -+ V4L2_PIX_FMT_RGB24, -+ V4L2_PIX_FMT_SPCA501, -+ V4L2_PIX_FMT_SPCA505, -+ V4L2_PIX_FMT_SPCA508, -+ V4L2_PIX_FMT_UYVY, (tested) -+ V4L2_PIX_FMT_YUV422P, -+ V4L2_PIX_FMT_YUV420, (tested) -+ V4L2_PIX_FMT_YUYV (tested) -+ -+ * - setting tuner - NOT TESTED - * - access to V4L2 device controls is missing. Partially added but requires some improvements likely. -- * - changing resolution at run-time may not work. -- * - ucvideo svn r75 or above to work with MJPEG ( i.ex Logitech 5000 pro ) -- -+ * - changing resolution at run-time may not work. -+ * - ucvideo svn r75 or above to work with MJPEG ( e.g. Logitech 5000 pro ) -+ - * This work is inspired by fswebcam and current design of motion. - * This interface has been tested with ZC0301 driver from kernel 2.6.17.3 and Labtec's usb camera (PAS202 sensor) -- -- * I'm very pleased by achieved image quality and cpu usage comparing to junky v4l1 spca5xx driver with -+ -+ * I'm very pleased by achieved image quality and cpu usage comparing to junky v4l1 spca5xx driver with - * it nonsensical kernel messy jpeg decompressor. - * Default sensor settings used by ZC0301 driver are very reasonable choosen. - * apparently brigthness should be controlled automatically by motion still for light compensation. - * it can be done by adjusting ADC gain and also exposure time. -- -+ -+ * Kernel 2.6.27 -+ -+ V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') YUYV per line -+ V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') YYUV per line -+ V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') YUVY per line -+ V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') 8 GBGB.. RGRG.. -+ V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') 8 GRGR.. BGBG.. -+ V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') 16 BGBG.. GRGR.. -+ V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') compressed GBRG bayer -+ V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') Pixart 73xx JPEG -+ V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') compressed BGGR bayer -+ -+ - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the -@@ -46,11 +68,9 @@ - let's go :) - */ - --#ifndef WITHOUT_V4L --#ifdef MOTION_V4L2 -+#if !defined(WITHOUT_V4L) && defined(MOTION_V4L2) - - #include "motion.h" --#include "netcam.h" - #include "video.h" - - #ifdef MOTION_V4L2_OLD -@@ -64,24 +84,60 @@ - #define u32 unsigned int - #define s32 signed int - --#define MMAP_BUFFERS 4 --#define MIN_MMAP_BUFFERS 2 -+#define MMAP_BUFFERS 4 -+#define MIN_MMAP_BUFFERS 2 - - #ifndef V4L2_PIX_FMT_SBGGR8 - /* see http://www.siliconimaging.com/RGB%20Bayer.htm */ --#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ -+#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ - #endif - - #ifndef V4L2_PIX_FMT_MJPEG --#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ -+#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ - #endif - - #ifndef V4L2_PIX_FMT_SN9C10X --#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ -+#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_SGBRG8 -+#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_SGRBG8 -+#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_SBGGR16 -+#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ - #endif - --#define ZC301_V4L2_CID_DAC_MAGN V4L2_CID_PRIVATE_BASE --#define ZC301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE+1) -+#ifndef V4L2_PIX_FMT_SPCA561 -+#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_PJPG -+#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_PAC207 -+#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_SPCA501 -+#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_SPCA505 -+#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */ -+#endif -+ -+#ifndef V4L2_PIX_FMT_SPCA508 -+#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */ -+#endif -+ -+#define ZC301_V4L2_CID_DAC_MAGN V4L2_CID_PRIVATE_BASE -+#define ZC301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE+1) - - static const u32 queried_ctrls[] = { - V4L2_CID_BRIGHTNESS, -@@ -103,15 +159,15 @@ static const u32 queried_ctrls[] = { - - typedef struct { - int fd; -- char map; - u32 fps; - - struct v4l2_capability cap; -- struct v4l2_format fmt; -+ struct v4l2_format src_fmt; -+ struct v4l2_format dst_fmt; - struct v4l2_requestbuffers req; - struct v4l2_buffer buf; - -- netcam_buff *buffers; -+ video_buff *buffers; - - s32 pframe; - -@@ -120,121 +176,130 @@ typedef struct { - - } src_v4l2_t; - -+/** -+ * xioctl -+ */ - static int xioctl(int fd, int request, void *arg) - { -- int r; -+ int ret; - - do -- r = ioctl(fd, request, arg); -- while (-1 == r && EINTR == errno); -+ ret = ioctl(fd, request, arg); -+ while (-1 == ret && EINTR == errno); - -- return r; -+ return ret; - } - --static int v4l2_get_capability(src_v4l2_t * s) -+/** -+ * v4l2_get_capability -+ */ -+static int v4l2_get_capability(src_v4l2_t * vid_source) - { -- if (xioctl(s->fd, VIDIOC_QUERYCAP, &s->cap) < 0) { -- motion_log(LOG_ERR, 0, "Not a V4L2 device?"); -+ if (xioctl(vid_source->fd, VIDIOC_QUERYCAP, &vid_source->cap) < 0) { -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Not a V4L2 device?"); - return -1; - } - -- motion_log(LOG_INFO, 0, "cap.driver: \"%s\"", s->cap.driver); -- motion_log(LOG_INFO, 0, "cap.card: \"%s\"", s->cap.card); -- motion_log(LOG_INFO, 0, "cap.bus_info: \"%s\"", s->cap.bus_info); -- motion_log(LOG_INFO, 0, "cap.capabilities=0x%08X", s->cap.capabilities); -- -- if (s->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) -- motion_log(LOG_INFO, 0, "- VIDEO_CAPTURE"); -- -- if (s->cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) -- motion_log(LOG_INFO, 0, "- VIDEO_OUTPUT"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \n------------------------\n" -+ "cap.driver: \"%s\"\n" -+ "cap.card: \"%s\"\n" -+ "cap.bus_info: \"%s\"\n" -+ "cap.capabilities=0x%08X\n------------------------", -+ vid_source->cap.driver, vid_source->cap.card, vid_source->cap.bus_info, -+ vid_source->cap.capabilities); -+ -+ if (vid_source->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VIDEO_CAPTURE"); -+ if (vid_source->cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VIDEO_OUTPUT"); -+ if (vid_source->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VIDEO_OVERLAY"); -+ if (vid_source->cap.capabilities & V4L2_CAP_VBI_CAPTURE) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VBI_CAPTURE"); -+ if (vid_source->cap.capabilities & V4L2_CAP_VBI_OUTPUT) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - VBI_OUTPUT"); -+ if (vid_source->cap.capabilities & V4L2_CAP_RDS_CAPTURE) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - RDS_CAPTURE"); -+ if (vid_source->cap.capabilities & V4L2_CAP_TUNER) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - TUNER"); -+ if (vid_source->cap.capabilities & V4L2_CAP_AUDIO) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - AUDIO"); -+ if (vid_source->cap.capabilities & V4L2_CAP_READWRITE) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - READWRITE"); -+ if (vid_source->cap.capabilities & V4L2_CAP_ASYNCIO) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - ASYNCIO"); -+ if (vid_source->cap.capabilities & V4L2_CAP_STREAMING) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - STREAMING"); -+ if (vid_source->cap.capabilities & V4L2_CAP_TIMEPERFRAME) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - TIMEPERFRAME"); - -- if (s->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) -- motion_log(LOG_INFO, 0, "- VIDEO_OVERLAY"); -- -- if (s->cap.capabilities & V4L2_CAP_VBI_CAPTURE) -- motion_log(LOG_INFO, 0, "- VBI_CAPTURE"); -- -- if (s->cap.capabilities & V4L2_CAP_VBI_OUTPUT) -- motion_log(LOG_INFO, 0, "- VBI_OUTPUT"); -- -- if (s->cap.capabilities & V4L2_CAP_RDS_CAPTURE) -- motion_log(LOG_INFO, 0, "- RDS_CAPTURE"); -- -- if (s->cap.capabilities & V4L2_CAP_TUNER) -- motion_log(LOG_INFO, 0, "- TUNER"); -- -- if (s->cap.capabilities & V4L2_CAP_AUDIO) -- motion_log(LOG_INFO, 0, "- AUDIO"); -- -- if (s->cap.capabilities & V4L2_CAP_READWRITE) -- motion_log(LOG_INFO, 0, "- READWRITE"); -- -- if (s->cap.capabilities & V4L2_CAP_ASYNCIO) -- motion_log(LOG_INFO, 0, "- ASYNCIO"); -- -- if (s->cap.capabilities & V4L2_CAP_STREAMING) -- motion_log(LOG_INFO, 0, "- STREAMING"); -- -- if (s->cap.capabilities & V4L2_CAP_TIMEPERFRAME) -- motion_log(LOG_INFO, 0, "- TIMEPERFRAME"); -- -- if (!(s->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { -- motion_log(LOG_ERR, 0, "Device does not support capturing."); -+ if (!(vid_source->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Device does not support capturing."); - return -1; - } - - return 0; - } - --static int v4l2_select_input(src_v4l2_t * s, int in, int norm, unsigned long freq_, int tuner_number ATTRIBUTE_UNUSED) -+/** -+ * v4l2_select_input -+ */ -+static int v4l2_select_input(struct config *conf, struct video_dev *viddev, -+ src_v4l2_t * vid_source, int in, int norm, -+ unsigned long freq_, int tuner_number ATTRIBUTE_UNUSED) - { - struct v4l2_input input; - struct v4l2_standard standard; - v4l2_std_id std_id; - -- if (in == 8) -- in = 0; -- - /* Set the input. */ -- memset (&input, 0, sizeof (input)); -- input.index = in; -- -- if (xioctl(s->fd, VIDIOC_ENUMINPUT, &input) == -1) { -- motion_log(LOG_ERR, 1, "Unable to query input %d VIDIOC_ENUMINPUT", in); -+ memset(&input, 0, sizeof (input)); -+ if (in == IN_DEFAULT) -+ input.index = IN_TV; -+ else input.index = in; -+ -+ if (xioctl(vid_source->fd, VIDIOC_ENUMINPUT, &input) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to query input %d." -+ " VIDIOC_ENUMINPUT, if you use a WEBCAM change input value in conf by -1", -+ input.index); - return -1; - } - -- if (debug_level > CAMERA_VIDEO) -- motion_log(LOG_INFO, 0, "%s: name = \"%s\", type 0x%08X, status %08x", __FUNCTION__, input.name, -- input.type, input.status); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: name = \"%s\", type 0x%08X," -+ " status %08x", input.name, input.type, input.status); - -- if ((input.type & V4L2_INPUT_TYPE_TUNER) && (debug_level > CAMERA_VIDEO)) -- motion_log(LOG_INFO, 0, "- TUNER"); -+ if (input.type & V4L2_INPUT_TYPE_TUNER) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - TUNER"); - -- if ((input.type & V4L2_INPUT_TYPE_CAMERA) && (debug_level > CAMERA_VIDEO)) -- motion_log(LOG_INFO, 0, "- CAMERA"); -+ if (input.type & V4L2_INPUT_TYPE_CAMERA) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - CAMERA"); - -- if (xioctl(s->fd, VIDIOC_S_INPUT, &in) == -1) { -- motion_log(LOG_ERR, 1, "Error selecting input %d VIDIOC_S_INPUT", in); -+ if (xioctl(vid_source->fd, VIDIOC_S_INPUT, &input.index) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error selecting input %d" -+ " VIDIOC_S_INPUT", input.index); - return -1; - } - -- /* Set video standard usually webcams doesn't support the ioctl or return V4L2_STD_UNKNOWN */ -- if (xioctl(s->fd, VIDIOC_G_STD, &std_id) == -1) { -- if (debug_level > CAMERA_VIDEO) -- motion_log(LOG_INFO, 0, "Device doesn't support VIDIOC_G_STD"); -- std_id = 0; // V4L2_STD_UNKNOWN = 0 -+ viddev->input = conf->input = in; -+ -+ /* -+ * Set video standard usually webcams doesn't support the ioctl or -+ * return V4L2_STD_UNKNOWN -+ */ -+ if (xioctl(vid_source->fd, VIDIOC_G_STD, &std_id) == -1) { -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Device doesn't support VIDIOC_G_STD"); -+ norm = std_id = 0; // V4L2_STD_UNKNOWN = 0 - } - - if (std_id) { - memset(&standard, 0, sizeof(standard)); - standard.index = 0; - -- while (xioctl(s->fd, VIDIOC_ENUMSTD, &standard) == 0) { -- if ((standard.id & std_id) && (debug_level > CAMERA_VIDEO)) -- motion_log(LOG_INFO, 0, "- video standard %s", standard.name); -- -+ while (xioctl(vid_source->fd, VIDIOC_ENUMSTD, &standard) == 0) { -+ if (standard.id & std_id) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - video standard %s", -+ standard.name); -+ - standard.index++; - } - -@@ -249,11 +314,16 @@ static int v4l2_select_input(src_v4l2_t - std_id = V4L2_STD_PAL; - } - -- if (xioctl(s->fd, VIDIOC_S_STD, &std_id) == -1) -- motion_log(LOG_ERR, 1, "Error selecting standard method %d VIDIOC_S_STD", std_id); -- -+ if (xioctl(vid_source->fd, VIDIOC_S_STD, &std_id) == -1) -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error selecting standard" -+ " method %d VIDIOC_S_STD", (int)std_id); -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set standard method %d", -+ (int)std_id); - } - -+ viddev->norm = conf->norm = norm; -+ - /* If this input is attached to a tuner, set the frequency. */ - if (input.type & V4L2_INPUT_TYPE_TUNER) { - struct v4l2_tuner tuner; -@@ -264,34 +334,47 @@ static int v4l2_select_input(src_v4l2_t - memset(&tuner, 0, sizeof(struct v4l2_tuner)); - tuner.index = input.tuner; - -- if (xioctl(s->fd, VIDIOC_G_TUNER, &tuner) == -1) { -- motion_log(LOG_ERR, 1, "tuner %d VIDIOC_G_TUNER", tuner.index); -+ if (xioctl(vid_source->fd, VIDIOC_G_TUNER, &tuner) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: tuner %d VIDIOC_G_TUNER", -+ tuner.index); - return 0; - } - -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set tuner %d", -+ tuner.index); -+ - /* Set the frequency. */ - memset(&freq, 0, sizeof(struct v4l2_frequency)); - freq.tuner = input.tuner; - freq.type = V4L2_TUNER_ANALOG_TV; - freq.frequency = (freq_ / 1000) * 16; - -- if (xioctl(s->fd, VIDIOC_S_FREQUENCY, &freq) == -1) { -- motion_log(LOG_ERR, 1, "freq %lu VIDIOC_S_FREQUENCY", freq.frequency); -+ if (xioctl(vid_source->fd, VIDIOC_S_FREQUENCY, &freq) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: freq %ul VIDIOC_S_FREQUENCY", -+ freq.frequency); - return 0; - } -+ -+ viddev->freq = conf->frequency = freq_; -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Set Frequency to %ul", -+ freq.frequency); -+ } else { -+ viddev->freq = conf->frequency = 0; - } - - return 0; - } - -+ - /* * - * v4l2_do_set_pix_format -- * -+ * - * This routine does the actual request to the driver -- * -+ * - * Returns: 0 Ok - * -1 Problems setting palette or not supported -- * -+ * - * Our algorithm for setting the picture format for the data which the - * driver returns to us will be as follows: - * -@@ -308,71 +391,95 @@ static int v4l2_select_input(src_v4l2_t - * We then request the driver to set the format we have chosen. That request - * should never fail, so if it does we log the fact and give up. - */ --static int v4l2_do_set_pix_format(u32 pixformat, src_v4l2_t * s, -- int *width, int *height) -+static int v4l2_do_set_pix_format(u32 pixformat, src_v4l2_t * vid_source, -+ int *width, int *height) - { -- memset(&s->fmt, 0, sizeof(struct v4l2_format)); -- s->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- s->fmt.fmt.pix.width = *width; -- s->fmt.fmt.pix.height = *height; -- s->fmt.fmt.pix.pixelformat = pixformat; -- s->fmt.fmt.pix.field = V4L2_FIELD_ANY; -- -- if (xioctl(s->fd, VIDIOC_TRY_FMT, &s->fmt) != -1 && -- s->fmt.fmt.pix.pixelformat == pixformat) { -- motion_log(LOG_INFO, 0, "Test palette %c%c%c%c (%dx%d)", -- pixformat >> 0, pixformat >> 8, pixformat >> 16, -- pixformat >> 24, *width, *height); -- -- if (s->fmt.fmt.pix.width != (unsigned int) *width || -- s->fmt.fmt.pix.height != (unsigned int) *height) { -- motion_log(LOG_INFO, 0, "Adjusting resolution from %ix%i to %ix%i.", -- *width, *height, s->fmt.fmt.pix.width, -- s->fmt.fmt.pix.height); -- *width = s->fmt.fmt.pix.width; -- *height = s->fmt.fmt.pix.height; -+ CLEAR(vid_source->dst_fmt); -+ vid_source->dst_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -+ vid_source->dst_fmt.fmt.pix.width = *width; -+ vid_source->dst_fmt.fmt.pix.height = *height; -+ vid_source->dst_fmt.fmt.pix.pixelformat = pixformat; -+ vid_source->dst_fmt.fmt.pix.field = V4L2_FIELD_ANY; -+ -+ if (xioctl(vid_source->fd, VIDIOC_TRY_FMT, &vid_source->dst_fmt) != -1 && -+ vid_source->dst_fmt.fmt.pix.pixelformat == pixformat) { -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Testing palette %c%c%c%c (%dx%d)", -+ pixformat >> 0, pixformat >> 8, -+ pixformat >> 16, pixformat >> 24, *width, *height); -+ -+ if (vid_source->dst_fmt.fmt.pix.width != (unsigned int) *width || -+ vid_source->dst_fmt.fmt.pix.height != (unsigned int) *height) { -+ -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Adjusting resolution " -+ "from %ix%i to %ix%i.", -+ *width, *height, vid_source->dst_fmt.fmt.pix.width, -+ vid_source->dst_fmt.fmt.pix.height); -+ -+ *width = vid_source->dst_fmt.fmt.pix.width; -+ *height = vid_source->dst_fmt.fmt.pix.height; - } - -- if (xioctl(s->fd, VIDIOC_S_FMT, &s->fmt) == -1) { -- motion_log(LOG_ERR, 1, "Error setting pixel format VIDIOC_S_FMT"); -+ if (xioctl(vid_source->fd, VIDIOC_S_FMT, &vid_source->dst_fmt) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error setting pixel " -+ "format.\nVIDIOC_S_FMT: "); - return -1; - } - -- motion_log(LOG_INFO, 0, "Using palette %c%c%c%c (%dx%d) bytesperlines " -- "%d sizeimage %d colorspace %08x", pixformat >> 0, -- pixformat >> 8, pixformat >> 16, pixformat >> 24, -- *width, *height, s->fmt.fmt.pix.bytesperline, -- s->fmt.fmt.pix.sizeimage, s->fmt.fmt.pix.colorspace); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using palette %c%c%c%c (%dx%d)" -+ " bytesperlines %d sizeimage %d colorspace %08x", pixformat >> 0, -+ pixformat >> 8, pixformat >> 16, pixformat >> 24, *width, -+ *height, vid_source->dst_fmt.fmt.pix.bytesperline, -+ vid_source->dst_fmt.fmt.pix.sizeimage, -+ vid_source->dst_fmt.fmt.pix.colorspace); -+ - return 0; - } -+ - return -1; - } - --/* This routine is called by the startup code to do the format setting */ --static int v4l2_set_pix_format(struct context *cnt, src_v4l2_t * s, -- int *width, int *height) -+/** -+ * v4l2_set_pix_format -+ * -+ * Returns: 0 Ok -+ * -1 Problems setting palette or not supported -+ */ -+static int v4l2_set_pix_format(struct context *cnt, src_v4l2_t * vid_source, -+ int *width, int *height) - { -- struct v4l2_fmtdesc fmt; -- short int v4l2_pal; -+ struct v4l2_fmtdesc fmtd; -+ int v4l2_pal; - -- /* -+ /* - * Note that this array MUST exactly match the config file list. -- * A higher index means better chance to be used -+ * A higher index means better chance to be used - */ - static const u32 supported_formats[] = { - V4L2_PIX_FMT_SN9C10X, -+ V4L2_PIX_FMT_SBGGR16, - V4L2_PIX_FMT_SBGGR8, -+ V4L2_PIX_FMT_SPCA561, -+ V4L2_PIX_FMT_SGBRG8, -+ V4L2_PIX_FMT_SGRBG8, -+ V4L2_PIX_FMT_PAC207, -+ V4L2_PIX_FMT_PJPG, - V4L2_PIX_FMT_MJPEG, - V4L2_PIX_FMT_JPEG, - V4L2_PIX_FMT_RGB24, -+ V4L2_PIX_FMT_SPCA501, -+ V4L2_PIX_FMT_SPCA505, -+ V4L2_PIX_FMT_SPCA508, - V4L2_PIX_FMT_UYVY, - V4L2_PIX_FMT_YUYV, - V4L2_PIX_FMT_YUV422P, -- V4L2_PIX_FMT_YUV420 /* most efficient for motion */ -+ V4L2_PIX_FMT_YUV420 /* most efficient for motion */ - }; -- -+ - int array_size = sizeof(supported_formats) / sizeof(supported_formats[0]); -- short int index_format = -1; /* -1 says not yet chosen */ -+ int index_format = -1; /* -1 says not yet chosen */ -+ CLEAR(fmtd); -+ fmtd.index = v4l2_pal = 0; -+ fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - /* First we try a shortcut of just setting the config file value */ - if (cnt->conf.v4l2_palette >= 0) { -@@ -380,38 +487,37 @@ static int v4l2_set_pix_format(struct co - supported_formats[cnt->conf.v4l2_palette] >> 8, - supported_formats[cnt->conf.v4l2_palette] >> 16, - supported_formats[cnt->conf.v4l2_palette] >> 24, 0}; -- -+ - if (v4l2_do_set_pix_format(supported_formats[cnt->conf.v4l2_palette], -- s, width, height) >= 0) -+ vid_source, width, height) >= 0) - return 0; -- -- motion_log(LOG_INFO, 0, "Config palette index %d (%s) doesn't work.", -- cnt->conf.v4l2_palette, name); -- } -- /* Well, that didn't work, so we enumerate what the driver can offer */ -- -- memset(&fmt, 0, sizeof(struct v4l2_fmtdesc)); -- fmt.index = v4l2_pal = 0; -- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- -- motion_log(LOG_INFO, 0, "Supported palettes:"); -- -- while (xioctl(s->fd, VIDIOC_ENUM_FMT, &fmt) != -1) { -- short int i; -- -- motion_log(LOG_INFO, 0, "%i: %c%c%c%c (%s)", v4l2_pal, -- fmt.pixelformat >> 0, fmt.pixelformat >> 8, -- fmt.pixelformat >> 16, fmt.pixelformat >> 24, -- fmt.description); - -- /* adjust index_format if larger value found */ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Config palette index %d (%s)" -+ " doesn't work.", cnt->conf.v4l2_palette, name); -+ } -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Supported palettes:"); -+ -+ while (xioctl(vid_source->fd, VIDIOC_ENUM_FMT, &fmtd) != -1) { -+ -+ int i; -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: (%i) %c%c%c%c (%s)", -+ v4l2_pal, fmtd.pixelformat >> 0, -+ fmtd.pixelformat >> 8, fmtd.pixelformat >> 16, -+ fmtd.pixelformat >> 24, fmtd.description); -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: %d - %s (compressed : %d) (%#x)", -+ fmtd.index, fmtd.description, fmtd.flags, fmtd.pixelformat); -+ -+ /* Adjust index_format if larger value found */ - for (i = index_format + 1; i < array_size; i++) -- if (supported_formats[i] == fmt.pixelformat) -+ if (supported_formats[i] == fmtd.pixelformat) - index_format = i; - -- memset(&fmt, 0, sizeof(struct v4l2_fmtdesc)); -- fmt.index = ++v4l2_pal; -- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -+ CLEAR(fmtd); -+ fmtd.index = ++v4l2_pal; -+ fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - } - - if (index_format >= 0) { -@@ -419,123 +525,140 @@ static int v4l2_set_pix_format(struct co - supported_formats[index_format] >> 8, - supported_formats[index_format] >> 16, - supported_formats[index_format] >> 24, 0}; -- -- motion_log(LOG_INFO, 0, "Selected palette %s", name); -- -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s Selected palette %s", name); -+ - if (v4l2_do_set_pix_format(supported_formats[index_format], -- s, width, height) >= 0) -+ vid_source, width, height) >= 0) - return 0; -- motion_log(LOG_ERR, 1, "VIDIOC_TRY_FMT failed for format %s", name); -+ -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "VIDIOC_TRY_FMT failed for " -+ "format %s", name); - } - -- motion_log(LOG_ERR, 0, "Unable to find a compatible palette format."); -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Unable to find a compatible" -+ " palette format."); -+ - return -1; - } - - #if 0 --static void v4l2_set_fps(src_v4l2_t * s){ -+static void v4l2_set_fps(src_v4l2_t * vid_source) { - struct v4l2_streamparm* setfps; - -- setfps=(struct v4l2_streamparm *) calloc(1, sizeof(struct v4l2_streamparm)); -+ setfps = (struct v4l2_streamparm *) calloc(1, sizeof(struct v4l2_streamparm)); - memset(setfps, 0, sizeof(struct v4l2_streamparm)); -- setfps->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- setfps->parm.capture.timeperframe.numerator=1; -- setfps->parm.capture.timeperframe.denominator=s->fps; -+ setfpvid_source->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -+ setfpvid_source->parm.capture.timeperframe.numerator = 1; -+ setfpvid_source->parm.capture.timeperframe.denominator = vid_source->fps; -+ -+ if (xioctl(vid_source->fd, VIDIOC_S_PARM, setfps) == -1) -+ MOTION_LOG(ERR, 1, "%s: v4l2_set_fps VIDIOC_S_PARM"); - -- if (xioctl(s->fd, VIDIOC_S_PARM, setfps) == -1) -- motion_log(LOG_ERR, 1, "v4l2_set_fps VIDIOC_S_PARM"); -- - - } - #endif - --static int v4l2_set_mmap(src_v4l2_t * s) -+/** -+ * v4l2_set_mmap -+ */ -+static int v4l2_set_mmap(src_v4l2_t * vid_source) - { - enum v4l2_buf_type type; -- u32 b; -+ u32 buffer_index; - - /* Does the device support streaming? */ -- if (!(s->cap.capabilities & V4L2_CAP_STREAMING)) -+ if (!(vid_source->cap.capabilities & V4L2_CAP_STREAMING)) - return -1; - -- memset(&s->req, 0, sizeof(struct v4l2_requestbuffers)); -- -- s->req.count = MMAP_BUFFERS; -- s->req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- s->req.memory = V4L2_MEMORY_MMAP; -+ memset(&vid_source->req, 0, sizeof(struct v4l2_requestbuffers)); - -- if (xioctl(s->fd, VIDIOC_REQBUFS, &s->req) == -1) { -- motion_log(LOG_ERR, 1, "Error requesting buffers %d for memory map. VIDIOC_REQBUFS", s->req.count); -+ vid_source->req.count = MMAP_BUFFERS; -+ vid_source->req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -+ vid_source->req.memory = V4L2_MEMORY_MMAP; -+ -+ if (xioctl(vid_source->fd, VIDIOC_REQBUFS, &vid_source->req) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error requesting buffers" -+ " %d for memory map. VIDIOC_REQBUFS", -+ vid_source->req.count); - return -1; - } - -- motion_log(LOG_DEBUG, 0, "mmap information:"); -- motion_log(LOG_DEBUG, 0, "frames=%d", s->req.count); -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: mmap information: frames=%d", -+ vid_source->req.count); - -- if (s->req.count < MIN_MMAP_BUFFERS) { -- motion_log(LOG_ERR, 0, "Insufficient buffer memory."); -+ if (vid_source->req.count < MIN_MMAP_BUFFERS) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Insufficient buffer memory" -+ " %d < MIN_MMAP_BUFFERS.", vid_source->req.count); - return -1; - } - -- s->buffers = calloc(s->req.count, sizeof(netcam_buff)); -- if (!s->buffers) { -- motion_log(LOG_ERR, 1, "%s: Out of memory.", __FUNCTION__); -+ vid_source->buffers = calloc(vid_source->req.count, sizeof(video_buff)); -+ -+ if (!vid_source->buffers) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Out of memory."); - return -1; - } - -- for (b = 0; b < s->req.count; b++) { -+ for (buffer_index = 0; buffer_index < vid_source->req.count; buffer_index++) { - struct v4l2_buffer buf; - - memset(&buf, 0, sizeof(struct v4l2_buffer)); - - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_MMAP; -- buf.index = b; -+ buf.index = buffer_index; - -- if (xioctl(s->fd, VIDIOC_QUERYBUF, &buf) == -1) { -- motion_log(LOG_ERR, 0, "Error querying buffer %d VIDIOC_QUERYBUF", b); -- free(s->buffers); -+ if (xioctl(vid_source->fd, VIDIOC_QUERYBUF, &buf) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error querying buffer" -+ " %i\nVIDIOC_QUERYBUF: ", buffer_index); -+ free(vid_source->buffers); - return -1; - } - -- s->buffers[b].size = buf.length; -- s->buffers[b].ptr = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, buf.m.offset); -- -- if (s->buffers[b].ptr == MAP_FAILED) { -- motion_log(LOG_ERR, 1, "Error mapping buffer %i mmap", b); -- free(s->buffers); -+ vid_source->buffers[buffer_index].size = buf.length; -+ vid_source->buffers[buffer_index].ptr = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, -+ MAP_SHARED, vid_source->fd, buf.m.offset); -+ -+ if (vid_source->buffers[buffer_index].ptr == MAP_FAILED) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error mapping buffer %i mmap", -+ buffer_index); -+ free(vid_source->buffers); - return -1; - } - -- motion_log(LOG_DEBUG, 0, "%i length=%d", b, buf.length); -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: %i length=%d Address (%x)", -+ buffer_index, buf.length, vid_source->buffers[buffer_index].ptr); - } - -- s->map = -1; -+ for (buffer_index = 0; buffer_index < vid_source->req.count; buffer_index++) { -+ memset(&vid_source->buf, 0, sizeof(struct v4l2_buffer)); - -- for (b = 0; b < s->req.count; b++) { -- memset(&s->buf, 0, sizeof(struct v4l2_buffer)); -+ vid_source->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -+ vid_source->buf.memory = V4L2_MEMORY_MMAP; -+ vid_source->buf.index = buffer_index; - -- s->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- s->buf.memory = V4L2_MEMORY_MMAP; -- s->buf.index = b; -- -- if (xioctl(s->fd, VIDIOC_QBUF, &s->buf) == -1) { -- motion_log(LOG_ERR, 1, "buffer index %d VIDIOC_QBUF", s->buf.index); -+ if (xioctl(vid_source->fd, VIDIOC_QBUF, &vid_source->buf) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_QBUF"); - return -1; - } - } - - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - -- if (xioctl(s->fd, VIDIOC_STREAMON, &type) == -1) { -- motion_log(LOG_ERR, 1, "Error starting stream VIDIOC_STREAMON"); -+ if (xioctl(vid_source->fd, VIDIOC_STREAMON, &type) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error starting stream." -+ " VIDIOC_STREAMON"); - return -1; - } - - return 0; - } - --static int v4l2_scan_controls(src_v4l2_t * s) -+/** -+ * v4l2_scan_controls -+ */ -+static int v4l2_scan_controls(src_v4l2_t * vid_source) - { - int count, i; - struct v4l2_queryctrl queryctrl; -@@ -544,40 +667,42 @@ static int v4l2_scan_controls(src_v4l2_t - - for (i = 0, count = 0; queried_ctrls[i]; i++) { - queryctrl.id = queried_ctrls[i]; -- if (xioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) -+ if (xioctl(vid_source->fd, VIDIOC_QUERYCTRL, &queryctrl)) - continue; - - count++; -- s->ctrl_flags |= 1 << i; -+ vid_source->ctrl_flags |= 1 << i; - } - - if (count) { -- struct v4l2_queryctrl *ctrl = s->controls = calloc(count, sizeof(struct v4l2_queryctrl)); -+ struct v4l2_queryctrl *ctrl = vid_source->controls -+ = calloc(count, sizeof(struct v4l2_queryctrl)); - - if (!ctrl) { -- motion_log(LOG_ERR, 1, "%s: Insufficient buffer memory.", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Insufficient buffer memory."); - return -1; - } - - for (i = 0; queried_ctrls[i]; i++) { -- if (s->ctrl_flags & (1 << i)) { -+ if (vid_source->ctrl_flags & (1 << i)) { - struct v4l2_control control; - - queryctrl.id = queried_ctrls[i]; -- if (xioctl(s->fd, VIDIOC_QUERYCTRL, &queryctrl)) -+ if (xioctl(vid_source->fd, VIDIOC_QUERYCTRL, &queryctrl)) - continue; - - memcpy(ctrl, &queryctrl, sizeof(struct v4l2_queryctrl)); - -- motion_log(LOG_INFO, 0, "found control 0x%08x, \"%s\", range %d,%d %s", ctrl->id, -- ctrl->name, ctrl->minimum, ctrl->maximum, -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: found control 0x%08x, \"%s\"," -+ " range %d,%d %s", -+ ctrl->id, ctrl->name, ctrl->minimum, ctrl->maximum, - ctrl->flags & V4L2_CTRL_FLAG_DISABLED ? "!DISABLED!" : ""); - -- memset (&control, 0, sizeof (control)); -+ memset(&control, 0, sizeof (control)); - control.id = queried_ctrls[i]; -- xioctl(s->fd, VIDIOC_G_CTRL, &control); -- motion_log(LOG_INFO, 0, "\t\"%s\", default %d, current %d", ctrl->name, -- ctrl->default_value, control.value); -+ xioctl(vid_source->fd, VIDIOC_G_CTRL, &control); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \t\"%s\", default %d, current %d", -+ ctrl->name, ctrl->default_value, control.value); - - ctrl++; - } -@@ -587,44 +712,46 @@ static int v4l2_scan_controls(src_v4l2_t - return 0; - } - --static int v4l2_set_control(src_v4l2_t * s, u32 cid, int value) -+/** -+ * v4l2_set_control -+ */ -+static int v4l2_set_control(src_v4l2_t * vid_source, u32 cid, int value) - { - int i, count; - -- if (!s->controls) -+ if (!vid_source->controls) - return -1; - - for (i = 0, count = 0; queried_ctrls[i]; i++) { -- if (s->ctrl_flags & (1 << i)) { -+ if (vid_source->ctrl_flags & (1 << i)) { - if (cid == queried_ctrls[i]) { -- struct v4l2_queryctrl *ctrl = s->controls + count; -+ struct v4l2_queryctrl *ctrl = vid_source->controls + count; - struct v4l2_control control; - int ret; - -- memset (&control, 0, sizeof (control)); -+ memset(&control, 0, sizeof (control)); - control.id = queried_ctrls[i]; - - switch (ctrl->type) { - case V4L2_CTRL_TYPE_INTEGER: - value = control.value = - (value * (ctrl->maximum - ctrl->minimum) / 256) + ctrl->minimum; -- ret = xioctl(s->fd, VIDIOC_S_CTRL, &control); -+ ret = xioctl(vid_source->fd, VIDIOC_S_CTRL, &control); - break; - - case V4L2_CTRL_TYPE_BOOLEAN: - value = control.value = value ? 1 : 0; -- ret = xioctl(s->fd, VIDIOC_S_CTRL, &control); -+ ret = xioctl(vid_source->fd, VIDIOC_S_CTRL, &control); - break; - - default: -- motion_log(LOG_ERR, 0, "%s: control type not supported yet"); -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: control type not supported yet"); - return -1; - } - -- if (debug_level > CAMERA_VIDEO) -- motion_log(LOG_INFO, 0, "setting control \"%s\" to %d (ret %d %s) %s", ctrl->name, -- value, ret, ret ? strerror(errno) : "", -- ctrl->flags & V4L2_CTRL_FLAG_DISABLED ? "Control is DISABLED!" : ""); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setting control \"%s\" to %d" -+ " (ret %d %s) %s", ctrl->name, value, ret, ret ? strerror(errno) : "", -+ ctrl->flags & V4L2_CTRL_FLAG_DISABLED ? "Control is DISABLED!" : ""); - - return 0; - } -@@ -635,76 +762,82 @@ static int v4l2_set_control(src_v4l2_t * - return -1; - } - -+/** -+ * v4l2_picture_controls -+ */ - static void v4l2_picture_controls(struct context *cnt, struct video_dev *viddev) - { -- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; -+ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; - - if (cnt->conf.contrast && cnt->conf.contrast != viddev->contrast) { - viddev->contrast = cnt->conf.contrast; -- v4l2_set_control(s, V4L2_CID_CONTRAST, viddev->contrast); -+ v4l2_set_control(vid_source, V4L2_CID_CONTRAST, viddev->contrast); - } - - if (cnt->conf.saturation && cnt->conf.saturation != viddev->saturation) { - viddev->saturation = cnt->conf.saturation; -- v4l2_set_control(s, V4L2_CID_SATURATION, viddev->saturation); -+ v4l2_set_control(vid_source, V4L2_CID_SATURATION, viddev->saturation); - } - - if (cnt->conf.hue && cnt->conf.hue != viddev->hue) { - viddev->hue = cnt->conf.hue; -- v4l2_set_control(s, V4L2_CID_HUE, viddev->hue); -+ v4l2_set_control(vid_source, V4L2_CID_HUE, viddev->hue); - } - - if (cnt->conf.autobright) { - if (vid_do_autobright(cnt, viddev)) { -- if (v4l2_set_control(s, V4L2_CID_BRIGHTNESS, viddev->brightness)) -- v4l2_set_control(s, V4L2_CID_GAIN, viddev->brightness); -+ if (v4l2_set_control(vid_source, V4L2_CID_BRIGHTNESS, viddev->brightness)) -+ v4l2_set_control(vid_source, V4L2_CID_GAIN, viddev->brightness); - } - } else { - if (cnt->conf.brightness && cnt->conf.brightness != viddev->brightness) { - viddev->brightness = cnt->conf.brightness; -- if (v4l2_set_control(s, V4L2_CID_BRIGHTNESS, viddev->brightness)) -- v4l2_set_control(s, V4L2_CID_GAIN, viddev->brightness); -+ if (v4l2_set_control(vid_source, V4L2_CID_BRIGHTNESS, viddev->brightness)) -+ v4l2_set_control(vid_source, V4L2_CID_GAIN, viddev->brightness); - } - } - - } - - /* public functions */ -- -+/** -+ * v4l2_start -+ */ - unsigned char *v4l2_start(struct context *cnt, struct video_dev *viddev, int width, int height, - int input, int norm, unsigned long freq, int tuner_number) - { -- src_v4l2_t *s; -+ src_v4l2_t *vid_source; - - /* Allocate memory for the state structure. */ -- if (!(s = calloc(sizeof(src_v4l2_t), 1))) { -- motion_log(LOG_ERR, 1, "%s: Out of memory.", __FUNCTION__); -+ if (!(vid_source = calloc(sizeof(src_v4l2_t), 1))) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Out of memory."); - goto err; - } - -- viddev->v4l2_private = s; -- s->fd = viddev->fd; -- s->fps = cnt->conf.frame_limit; -- s->pframe = -1; -+ viddev->v4l2_private = vid_source; -+ vid_source->fd = viddev->fd; -+ vid_source->fps = cnt->conf.frame_limit; -+ vid_source->pframe = -1; -+ struct config *conf = &cnt->conf; - -- if (v4l2_get_capability(s)) -+ if (v4l2_get_capability(vid_source)) - goto err; -- -- if (v4l2_select_input(s, input, norm, freq, tuner_number)) -+ -+ if (v4l2_select_input(conf, viddev, vid_source, input, norm, freq, tuner_number)) - goto err; -- -- if (v4l2_set_pix_format(cnt ,s, &width, &height)) -+ -+ if (v4l2_set_pix_format(cnt, vid_source, &width, &height)) - goto err; -- -- if (v4l2_scan_controls(s)) -+ -+ if (v4l2_scan_controls(vid_source)) - goto err; -- -+ - #if 0 -- v4l2_set_fps(s); -+ v4l2_set_fps(vid_source); - #endif -- if (v4l2_set_mmap(s)) -+ if (v4l2_set_mmap(vid_source)) - goto err; -- -+ - viddev->size_map = 0; - viddev->v4l_buffers[0] = NULL; - viddev->v4l_maxbuffer = 1; -@@ -721,86 +854,101 @@ unsigned char *v4l2_start(struct context - return (void *) 1; - - err: -- if (s) -- free(s); -+ if (vid_source) -+ free(vid_source); - - viddev->v4l2_private = NULL; - viddev->v4l2 = 0; - return NULL; - } - --void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, -- struct config *conf) -+/** -+ * v4l2_set_input -+ */ -+void v4l2_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, -+ int width, int height, struct config *conf) - { -- int i; - int input = conf->input; - int norm = conf->norm; -- int skip = conf->roundrobin_skip; - unsigned long freq = conf->frequency; - int tuner_number = conf->tuner_number; - - if (input != viddev->input || width != viddev->width || height != viddev->height || -- freq != viddev->freq || tuner_number != viddev->tuner_number) { -+ freq != viddev->freq || tuner_number != viddev->tuner_number || norm != viddev->norm) { - -+ unsigned int i; - struct timeval switchTime; -+ unsigned int skip = conf->roundrobin_skip; - -- v4l2_select_input((src_v4l2_t *) viddev->v4l2_private, input, norm, freq, tuner_number); -+ if (conf->roundrobin_skip < 0) -+ skip = 1; -+ -+ v4l2_select_input(conf, viddev, (src_v4l2_t *) viddev->v4l2_private, -+ input, norm, freq, tuner_number); - - gettimeofday(&switchTime, NULL); - - v4l2_picture_controls(cnt, viddev); - -+ viddev->width = width; -+ viddev->height = height; -+ -+ /* - viddev->input = input; -+ viddev->norm = norm; - viddev->width = width; - viddev->height = height; - viddev->freq = freq; - viddev->tuner_number = tuner_number; -- -+ */ - - /* Skip all frames captured before switchtime, capture 1 after switchtime */ - { -- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; -+ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; - unsigned int counter = 0; -- if (debug_level > CAMERA_VIDEO) -- motion_log(LOG_DEBUG, 0, "set_input_skip_frame switch_time=%ld:%ld", -- switchTime.tv_sec, switchTime.tv_usec); -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set_input_skip_frame " -+ "switch_time=%ld:%ld", switchTime.tv_sec, switchTime.tv_usec); - - /* Avoid hang using the number of mmap buffers */ -- while(counter < s->req.count) { -+ while(counter < vid_source->req.count) { - counter++; - if (v4l2_next(cnt, viddev, map, width, height)) - break; -- -- if (s->buf.timestamp.tv_sec > switchTime.tv_sec || -- (s->buf.timestamp.tv_sec == switchTime.tv_sec && s->buf.timestamp.tv_usec > -- switchTime.tv_usec)) -+ -+ if (vid_source->buf.timestamp.tv_sec > switchTime.tv_sec || -+ (vid_source->buf.timestamp.tv_sec == switchTime.tv_sec && -+ vid_source->buf.timestamp.tv_usec > switchTime.tv_usec)) - break; - -- if (debug_level > CAMERA_VIDEO) -- motion_log(LOG_DEBUG, 0, "got frame before switch timestamp=%ld:%ld", -- s->buf.timestamp.tv_sec, s->buf.timestamp.tv_usec); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: got frame before " -+ " switch timestamp=%ld:%ld", -+ vid_source->buf.timestamp.tv_sec, -+ vid_source->buf.timestamp.tv_usec); - } - } - - /* skip a few frames if needed */ - for (i = 1; i < skip; i++) - v4l2_next(cnt, viddev, map, width, height); -- - } else { - /* No round robin - we only adjust picture controls */ - v4l2_picture_controls(cnt, viddev); - } - } - --int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height) -+/** -+ * v4l2_next -+ */ -+int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, -+ int width, int height) - { - sigset_t set, old; -- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; -+ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; - - if (viddev->v4l_fmt != VIDEO_PALETTE_YUV420P) - return V4L_FATAL_ERROR; - -- - /* Block signals during IOCTL */ - sigemptyset(&set); - sigaddset(&set, SIGCHLD); -@@ -810,82 +958,109 @@ int v4l2_next(struct context *cnt, struc - sigaddset(&set, SIGHUP); - pthread_sigmask(SIG_BLOCK, &set, &old); - -- if (s->pframe >= 0) { -- if (xioctl(s->fd, VIDIOC_QBUF, &s->buf) == -1) { -- motion_log(LOG_ERR, 1, "%s: VIDIOC_QBUF", __FUNCTION__); -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: 1) vid_source->pframe %i", -+ vid_source->pframe); -+ -+ if (vid_source->pframe >= 0) { -+ if (xioctl(vid_source->fd, VIDIOC_QBUF, &vid_source->buf) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_QBUF"); -+ pthread_sigmask(SIG_UNBLOCK, &old, NULL); - return -1; - } - } - -- memset(&s->buf, 0, sizeof(struct v4l2_buffer)); -+ memset(&vid_source->buf, 0, sizeof(struct v4l2_buffer)); - -- s->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- s->buf.memory = V4L2_MEMORY_MMAP; -+ vid_source->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -+ vid_source->buf.memory = V4L2_MEMORY_MMAP; - -- if (xioctl(s->fd, VIDIOC_DQBUF, &s->buf) == -1) { -- -- /* some drivers return EIO when there is no signal, -- driver might dequeue an (empty) buffer despite -- returning an error, or even stop capturing. -- */ -+ if (xioctl(vid_source->fd, VIDIOC_DQBUF, &vid_source->buf) == -1) { -+ int ret; -+ /* -+ * Some drivers return EIO when there is no signal, -+ * driver might dequeue an (empty) buffer despite -+ * returning an error, or even stop capturing. -+ */ - if (errno == EIO) { -- s->pframe++; -- if ((u32)s->pframe >= s->req.count) s->pframe = 0; -- s->buf.index = s->pframe; -+ vid_source->pframe++; - -- motion_log(LOG_ERR, 1, "%s: VIDIOC_DQBUF: EIO (s->pframe %d)", __FUNCTION__, s->pframe); -+ if ((u32)vid_source->pframe >= vid_source->req.count) -+ vid_source->pframe = 0; - -- return 1; -+ vid_source->buf.index = vid_source->pframe; -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_DQBUF: EIO " -+ "(vid_source->pframe %d)", vid_source->pframe); -+ ret = 1; -+ } else if (errno == EAGAIN) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_DQBUF: EAGAIN" -+ " (vid_source->pframe %d)", vid_source->pframe); -+ ret = 1; -+ } else { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_DQBUF"); -+ ret = -1; - } - -- motion_log(LOG_ERR, 1, "%s: VIDIOC_DQBUF", __FUNCTION__); -- -- return -1; -+ pthread_sigmask(SIG_UNBLOCK, &old, NULL); -+ return ret; - } - -- s->pframe = s->buf.index; -- s->buffers[s->buf.index].used = s->buf.bytesused; -- s->buffers[s->buf.index].content_length = s->buf.bytesused; -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: 2) vid_source->pframe %i", -+ vid_source->pframe); -+ -+ vid_source->pframe = vid_source->buf.index; -+ vid_source->buffers[vid_source->buf.index].used = vid_source->buf.bytesused; -+ vid_source->buffers[vid_source->buf.index].content_length = vid_source->buf.bytesused; -+ -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: 3) vid_source->pframe %i " -+ "vid_source->buf.index %i", vid_source->pframe, vid_source->buf.index); -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: vid_source->buf.bytesused %i", -+ vid_source->buf.bytesused); - - pthread_sigmask(SIG_UNBLOCK, &old, NULL); /*undo the signal blocking */ - - { -- netcam_buff *the_buffer = &s->buffers[s->buf.index]; -+ video_buff *the_buffer = &vid_source->buffers[vid_source->buf.index]; - -- switch (s->fmt.fmt.pix.pixelformat) { -+ MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: the_buffer index %d Address (%x)", -+ vid_source->buf.index, the_buffer->ptr); -+ -+ switch (vid_source->dst_fmt.fmt.pix.pixelformat) { - case V4L2_PIX_FMT_RGB24: -- conv_rgb24toyuv420p(map, (unsigned char *) the_buffer->ptr, width, height); -+ conv_rgb24toyuv420p(map, the_buffer->ptr, width, height); - return 0; - - case V4L2_PIX_FMT_UYVY: -- conv_uyvyto420p(map, (unsigned char *) the_buffer->ptr, (unsigned)width, (unsigned)height); -+ conv_uyvyto420p(map, the_buffer->ptr, (unsigned)width, (unsigned)height); - return 0; - - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_YUV422P: -- conv_yuv422to420p(map, (unsigned char *) the_buffer->ptr, width, height); -+ conv_yuv422to420p(map, the_buffer->ptr, width, height); - return 0; - - case V4L2_PIX_FMT_YUV420: - memcpy(map, the_buffer->ptr, viddev->v4l_bufsize); - return 0; - -- case V4L2_PIX_FMT_JPEG: -- case V4L2_PIX_FMT_MJPEG: -- return mjpegtoyuv420p(map, (unsigned char *) the_buffer->ptr, width, height, -- s->buffers[s->buf.index].content_length); --/* -- return 0; -+ case V4L2_PIX_FMT_PJPG: - case V4L2_PIX_FMT_JPEG: -- return conv_jpeg2yuv420(cnt, map, the_buffer, width, height); --*/ -+ case V4L2_PIX_FMT_MJPEG: -+ return mjpegtoyuv420p(map, the_buffer->ptr, width, height, -+ vid_source->buffers[vid_source->buf.index].content_length); -+ -+ /* FIXME: quick hack to allow work all bayer formats */ -+ case V4L2_PIX_FMT_SBGGR16: -+ case V4L2_PIX_FMT_SGBRG8: -+ case V4L2_PIX_FMT_SGRBG8: -+ /* case V4L2_PIX_FMT_SPCA561: */ - case V4L2_PIX_FMT_SBGGR8: /* bayer */ -- bayer2rgb24(cnt->imgs.common_buffer, (unsigned char *) the_buffer->ptr, width, height); -+ bayer2rgb24(cnt->imgs.common_buffer, the_buffer->ptr, width, height); - conv_rgb24toyuv420p(map, cnt->imgs.common_buffer, width, height); - return 0; - -+ case V4L2_PIX_FMT_SPCA561: - case V4L2_PIX_FMT_SN9C10X: -- sonix_decompress(map, (unsigned char *) the_buffer->ptr, width, height); -+ sonix_decompress(map, the_buffer->ptr, width, height); - bayer2rgb24(cnt->imgs.common_buffer, map, width, height); - conv_rgb24toyuv420p(map, cnt->imgs.common_buffer, width, height); - return 0; -@@ -895,39 +1070,43 @@ int v4l2_next(struct context *cnt, struc - return 1; - } - -+/** -+ * v4l2_close -+ */ - void v4l2_close(struct video_dev *viddev) - { -- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; -+ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; - enum v4l2_buf_type type; - - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -- xioctl(s->fd, VIDIOC_STREAMOFF, &type); -- close(s->fd); -- s->fd = -1; -+ xioctl(vid_source->fd, VIDIOC_STREAMOFF, &type); -+ close(vid_source->fd); -+ vid_source->fd = -1; - } - -+/** -+ * v4l2_cleanup -+ */ - void v4l2_cleanup(struct video_dev *viddev) - { -- src_v4l2_t *s = (src_v4l2_t *) viddev->v4l2_private; -+ src_v4l2_t *vid_source = (src_v4l2_t *) viddev->v4l2_private; - -- if (s->buffers) { -+ if (vid_source->buffers) { - unsigned int i; - -- for (i = 0; i < s->req.count; i++) -- munmap(s->buffers[i].ptr, s->buffers[i].size); -+ for (i = 0; i < vid_source->req.count; i++) -+ munmap(vid_source->buffers[i].ptr, vid_source->buffers[i].size); - -- free(s->buffers); -- s->buffers = NULL; -+ free(vid_source->buffers); -+ vid_source->buffers = NULL; - } - -- if (s->controls) { -- free(s->controls); -- s->controls = NULL; -+ if (vid_source->controls) { -+ free(vid_source->controls); -+ vid_source->controls = NULL; - } - -- free(s); -+ free(vid_source); - viddev->v4l2_private = NULL; - } -- --#endif --#endif -+#endif /* !WITHOUT_V4L && MOTION_V4L2 */ ---- motion-3.2.12.orig/video_common.c -+++ motion-3.2.12/video_common.c -@@ -2,19 +2,18 @@ - * - * Video stream functions for motion. - * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) -- * 2006 by Krzysztof Blaszkowski (kb@sysmikro.com.pl) -- * 2007 by Angel Carpinteo (ack@telefonica.net) -+ * 2006 by Krzysztof Blaszkowski (kb@sysmikro.com.pl) -+ * 2007 by Angel Carpintero (motiondevelop@gmail.com) - * This software is distributed under the GNU public license version 2 - * See also the file 'COPYING'. - * - */ - --/* for rotation */ --#include "rotate.h" /* already includes motion.h */ -+/* For rotation */ -+#include "rotate.h" /* Already includes motion.h */ - #include "video.h" - #include "jpegutils.h" - -- - typedef unsigned char uint8_t; - typedef unsigned short int uint16_t; - typedef unsigned int uint32_t; -@@ -27,9 +26,8 @@ typedef struct { - int val; - } code_table_t; - --/* -- * sonix_decompress_init -- * ===================== -+/** -+ * sonix_decompress_init - * pre-calculates a locally stored table for efficient huffman-decoding. - * - * Each entry at index x in the table represents the codeword -@@ -89,10 +87,9 @@ static void sonix_decompress_init(code_t - } - } - --/* -- * sonix_decompress -- * ================ -- * decompresses an image encoded by a SN9C101 camera controller chip. -+/** -+ * sonix_decompress -+ * Decompresses an image encoded by a SN9C101 camera controller chip. - * - * IN width - * height -@@ -111,14 +108,14 @@ int sonix_decompress(unsigned char *outp - unsigned char code; - unsigned char *addr; - -- /* local storage */ -+ /* Local storage */ - static code_table_t table[256]; - static int init_done = 0; - - if (!init_done) { - init_done = 1; - sonix_decompress_init(table); -- /* do sonix_decompress_init first! */ -+ /* Do sonix_decompress_init first! */ - //return -1; // so it has been done and now fall through - } - -@@ -127,7 +124,7 @@ int sonix_decompress(unsigned char *outp - - col = 0; - -- /* first two pixels in first two rows are stored as raw 8-bit */ -+ /* First two pixels in first two rows are stored as raw 8-bit. */ - if (row < 2) { - addr = inp + (bitpos >> 3); - code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); -@@ -143,30 +140,30 @@ int sonix_decompress(unsigned char *outp - } - - while (col < width) { -- /* get bitcode from bitstream */ -+ /* Get bitcode from bitstream. */ - addr = inp + (bitpos >> 3); - code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); - -- /* update bit position */ -+ /* Update bit position. */ - bitpos += table[code].len; - -- /* calculate pixel value */ -+ /* Calculate pixel value. */ - val = table[code].val; - if (!table[code].is_abs) { -- /* value is relative to top and left pixel */ -+ /* Value is relative to top and left pixel. */ - if (col < 2) { -- /* left column: relative to top pixel */ -+ /* Left column: relative to top pixel. */ - val += outp[-2 * width]; - } else if (row < 2) { -- /* top row: relative to left pixel */ -+ /* Top row: relative to left pixel. */ - val += outp[-2]; - } else { -- /* main area: average of left pixel and top pixel */ -+ /* Main area: average of left pixel and top pixel. */ - val += (outp[-2] + outp[-2 * width]) / 2; - } - } - -- /* store pixel */ -+ /* Store pixel */ - *outp++ = CLAMP(val); - col++; - } -@@ -175,14 +172,14 @@ int sonix_decompress(unsigned char *outp - return 0; - } - --/* -+/** -+ * bayer2rgb24 - * BAYER2RGB24 ROUTINE TAKEN FROM: - * - * Sonix SN9C10x based webcam basic I/F routines - * Takafumi Mizuno - * - */ -- - void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height) - { - long int i; -@@ -199,12 +196,12 @@ void bayer2rgb24(unsigned char *dst, uns - /* B */ - if ((i > width) && ((i % width) > 0)) { - *scanpt++ = *rawpt; /* B */ -- *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + -+ *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + - *(rawpt + width) + *(rawpt - width)) / 4; /* G */ -- *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + -+ *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + - *(rawpt + width - 1) + *(rawpt + width + 1)) / 4; /* R */ - } else { -- /* first line or left column */ -+ /* First line or left column. */ - *scanpt++ = *rawpt; /* B */ - *scanpt++ = (*(rawpt + 1) + *(rawpt + width)) / 2; /* G */ - *scanpt++ = *(rawpt + width + 1); /* R */ -@@ -216,7 +213,7 @@ void bayer2rgb24(unsigned char *dst, uns - *scanpt++ = *rawpt; /* G */ - *scanpt++ = (*(rawpt + width) + *(rawpt - width)) / 2; /* R */ - } else { -- /* first line or right column */ -+ /* First line or right column. */ - *scanpt++ = *(rawpt - 1); /* B */ - *scanpt++ = *rawpt; /* G */ - *scanpt++ = *(rawpt + width); /* R */ -@@ -230,7 +227,7 @@ void bayer2rgb24(unsigned char *dst, uns - *scanpt++ = *rawpt; /* G */ - *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2; /* R */ - } else { -- /* bottom line or left column */ -+ /* Bottom line or left column. */ - *scanpt++ = *(rawpt - width); /* B */ - *scanpt++ = *rawpt; /* G */ - *scanpt++ = *(rawpt + 1); /* R */ -@@ -238,13 +235,13 @@ void bayer2rgb24(unsigned char *dst, uns - } else { - /* R */ - if (i < (width * (height - 1)) && ((i % width) < (width - 1))) { -- *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + -+ *scanpt++ = (*(rawpt - width - 1) + *(rawpt - width + 1) + - *(rawpt + width - 1) + *(rawpt + width + 1)) / 4; /* B */ -- *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt - width) + -- *(rawpt + width)) / 4; /* G */ -+ *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + -+ *(rawpt - width) + *(rawpt + width)) / 4; /* G */ - *scanpt++ = *rawpt; /* R */ - } else { -- /* bottom line or right column */ -+ /* Bottom line or right column. */ - *scanpt++ = *(rawpt - width - 1); /* B */ - *scanpt++ = (*(rawpt - 1) + *(rawpt - width)) / 2; /* G */ - *scanpt++ = *rawpt; /* R */ -@@ -256,19 +253,24 @@ void bayer2rgb24(unsigned char *dst, uns - - } - -+/** -+ * conv_yuv422to420p -+ * -+ * -+ */ - void conv_yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height) - { - unsigned char *src, *dest, *src2, *dest2; - int i, j; - -- /* Create the Y plane */ -+ /* Create the Y plane. */ - src = cap_map; - dest = map; - for (i = width * height; i > 0; i--) { - *dest++ = *src; - src += 2; - } -- /* Create U and V planes */ -+ /* Create U and V planes. */ - src = cap_map + 1; - src2 = cap_map + width * 2 + 1; - dest = map + width * height; -@@ -289,6 +291,11 @@ void conv_yuv422to420p(unsigned char *ma - } - } - -+/** -+ * conv_uyvyto420p -+ * -+ * -+ */ - void conv_uyvyto420p(unsigned char *map, unsigned char *cap_map, unsigned int width, unsigned int height) - { - uint8_t *pY = map; -@@ -300,26 +307,35 @@ void conv_uyvyto420p(unsigned char *map, - for (ix = 0; ix < height; ix++) { - for (jx = 0; jx < width; jx += 2) { - uint16_t calc; -+ - if ((ix&1) == 0) { - calc = *cap_map; - calc += *(cap_map + uv_offset); - calc /= 2; - *pU++ = (uint8_t) calc; - } -+ - cap_map++; - *pY++ = *cap_map++; -+ - if ((ix&1) == 0) { - calc = *cap_map; - calc += *(cap_map + uv_offset); - calc /= 2; - *pV++ = (uint8_t) calc; - } -+ - cap_map++; - *pY++ = *cap_map++; - } - } - } - -+/** -+ * conv_rgb24toyuv420p -+ * -+ * -+ */ - void conv_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height) - { - unsigned char *y, *u, *v; -@@ -360,67 +376,33 @@ void conv_rgb24toyuv420p(unsigned char * - } - } - --int conv_jpeg2yuv420(struct context *cnt, unsigned char *dst, netcam_buff * buff, int width, int height) --{ -- netcam_context netcam; -- -- if (!buff || !dst) -- return 3; -- -- if (!buff->ptr) -- return 2; /* Error decoding MJPEG frame */ -- -- memset(&netcam, 0, sizeof(netcam)); -- netcam.imgcnt_last = 1; -- netcam.latest = buff; -- netcam.width = width; -- netcam.height = height; -- netcam.cnt = cnt; -- -- pthread_mutex_init(&netcam.mutex, NULL); -- pthread_cond_init(&netcam.cap_cond, NULL); -- pthread_cond_init(&netcam.pic_ready, NULL); -- pthread_cond_init(&netcam.exiting, NULL); -- -- if (setjmp(netcam.setjmp_buffer)) -- return NETCAM_GENERAL_ERROR | NETCAM_JPEG_CONV_ERROR; -- -- -- return netcam_proc_jpeg(&netcam, dst); --} -- -- -- --/* -+/** - * mjpegtoyuv420p - * - * Return values - * -1 on fatal error - * 0 on success -- * 2 if jpeg lib threw a "corrupt jpeg data" warning. -+ * 2 if jpeg lib threw a "corrupt jpeg data" warning. - * in this case, "a damaged output image is likely." - */ -- - int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size) - { - uint8_t *yuv[3]; - unsigned char *y, *u, *v; - int loop, ret; - -- yuv[0] = malloc(width * height * sizeof(yuv[0][0])); -- yuv[1] = malloc(width * height / 4 * sizeof(yuv[1][0])); -- yuv[2] = malloc(width * height / 4 * sizeof(yuv[2][0])); -+ yuv[0] = mymalloc(width * height * sizeof(yuv[0][0])); -+ yuv[1] = mymalloc(width * height / 4 * sizeof(yuv[1][0])); -+ yuv[2] = mymalloc(width * height / 4 * sizeof(yuv[2][0])); - - - ret = decode_jpeg_raw(cap_map, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]); -- -+ - if (ret == 1) { -- if (debug_level >= CAMERA_WARNINGS) -- motion_log(LOG_ERR, 0, "%s: Corrupt image ... continue", __FUNCTION__); -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Corrupt image ... continue"); - ret = 2; - } - -- - y = map; - u = y + width * height; - v = u + (width * height) / 4; -@@ -429,13 +411,13 @@ int mjpegtoyuv420p(unsigned char *map, u - memset(v, 0, width * height / 4); - - for(loop = 0; loop < width * height; loop++) -- *map++=yuv[0][loop]; -+ *map++ = yuv[0][loop]; - - for(loop = 0; loop < width * height / 4; loop++) -- *map++=yuv[1][loop]; -+ *map++ = yuv[1][loop]; - - for(loop = 0; loop < width * height / 4; loop++) -- *map++=yuv[2][loop]; -+ *map++ = yuv[2][loop]; - - free(yuv[0]); - free(yuv[1]); -@@ -463,10 +445,13 @@ int mjpegtoyuv420p(unsigned char *map, u - * the camera device. - */ - #define AUTOBRIGHT_HYSTERESIS 10 --#define AUTOBRIGHT_DAMPER 5 --#define AUTOBRIGHT_MAX 255 --#define AUTOBRIGHT_MIN 0 -+#define AUTOBRIGHT_DAMPER 5 -+#define AUTOBRIGHT_MAX 255 -+#define AUTOBRIGHT_MIN 0 - -+/** -+ * vid_do_autobright -+ */ - int vid_do_autobright(struct context *cnt, struct video_dev *viddev) - { - -@@ -492,16 +477,18 @@ int vid_do_autobright(struct context *cn - } - avg = avg / j; - -- /* average is above window - turn down brightness - go for the target */ -+ /* Average is above window - turn down brightness - go for the target. */ - if (avg > brightness_window_high) { - step = MIN2((avg - brightness_target) / AUTOBRIGHT_DAMPER + 1, viddev->brightness - AUTOBRIGHT_MIN); -+ - if (viddev->brightness > step + 1 - AUTOBRIGHT_MIN) { - viddev->brightness -= step; - make_change = 1; - } - } else if (avg < brightness_window_low) { -- /* average is below window - turn up brightness - go for the target */ -+ /* Average is below window - turn up brightness - go for the target. */ - step = MIN2((brightness_target - avg) / AUTOBRIGHT_DAMPER + 1, AUTOBRIGHT_MAX - viddev->brightness); -+ - if (viddev->brightness < AUTOBRIGHT_MAX - step) { - viddev->brightness += step; - make_change = 1; -@@ -516,12 +503,14 @@ int vid_do_autobright(struct context *cn - *****************************************************************************/ - - #ifndef WITHOUT_V4L --/* big lock for vid_start to ensure exclusive access to viddevs while adding -- * devices during initialization of each thread -+/* -+ * Big lock for vid_start to ensure exclusive access to viddevs while adding -+ * devices during initialization of each thread. - */ - static pthread_mutex_t vid_mutex; - --/* Here we setup the viddevs structure which is used globally in the vid_* -+/* -+ * Here we setup the viddevs structure which is used globally in the vid_* - * functions. - */ - static struct video_dev *viddevs = NULL; -@@ -530,7 +519,7 @@ static struct video_dev *viddevs = NULL; - * vid_init - * - * Called from motion.c at the very beginning before setting up the threads. -- * Function prepares the vid_mutex -+ * Function prepares the vid_mutex. - */ - void vid_init(void) - { -@@ -540,7 +529,7 @@ void vid_init(void) - /** - * vid_cleanup - * -- * vid_cleanup is called from motion.c when Motion is stopped or restarted -+ * vid_cleanup is called from motion.c when Motion is stopped or restarted. - */ - void vid_cleanup(void) - { -@@ -552,18 +541,18 @@ void vid_cleanup(void) - /** - * vid_close - * -- * vid_close is called from motion.c when a Motion thread is stopped or restarted -+ * vid_close is called from motion.c when a Motion thread is stopped or restarted. - */ - void vid_close(struct context *cnt) - { - #ifndef WITHOUT_V4L - struct video_dev *dev = viddevs; - struct video_dev *prev = NULL; --#endif /* WITHOUT_V4L */ -+#endif /* WITHOUT_V4L */ - - /* Cleanup the netcam part */ - if (cnt->netcam) { -- motion_log(LOG_DEBUG, 0, "vid_close: calling netcam_cleanup"); -+ MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: calling netcam_cleanup"); - netcam_cleanup(cnt->netcam, 0); - cnt->netcam = NULL; - return; -@@ -581,16 +570,17 @@ void vid_close(struct context *cnt) - } - pthread_mutex_unlock(&vid_mutex); - -- /* Set it as closed in thread context */ -+ /* Set it as closed in thread context. */ - cnt->video_dev = -1; - - if (dev == NULL) { -- motion_log(LOG_ERR, 0, "vid_close: Unable to find video device"); -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Unable to find video device"); - return; - } - - if (--dev->usage_count == 0) { -- motion_log(LOG_INFO, 0, "Closing video device %s", dev->video_device); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Closing video device %s", -+ dev->video_device); - #ifdef MOTION_V4L2 - if (dev->v4l2) { - v4l2_close(dev); -@@ -604,23 +594,22 @@ void vid_close(struct context *cnt) - #endif - dev->fd = -1; - pthread_mutex_lock(&vid_mutex); -- - /* Remove from list */ - if (prev == NULL) - viddevs = dev->next; - else - prev->next = dev->next; -- - pthread_mutex_unlock(&vid_mutex); - - pthread_mutexattr_destroy(&dev->attr); - pthread_mutex_destroy(&dev->mutex); - free(dev); - } else { -- motion_log(LOG_INFO, 0, "Still %d users of video device %s, so we don't close it now", -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Still %d users of video device %s, so we don't close it now", - dev->usage_count, dev->video_device); -- /* There is still at least one thread using this device -- * If we own it, release it -+ /* -+ * There is still at least one thread using this device -+ * If we own it, release it. - */ - if (dev->owner == cnt->threadnr) { - dev->frames = 0; -@@ -628,7 +617,7 @@ void vid_close(struct context *cnt) - pthread_mutex_unlock(&dev->mutex); - } - } --#endif /* WITHOUT_V4L */ -+#endif /* !WITHOUT_V4L */ - } - - #ifndef WITHOUT_V4L -@@ -638,8 +627,8 @@ void vid_close(struct context *cnt) - * - * Called from vid_start setup the V4L/V4L2 capture device - * The function does the following: -- * -- * - Setup basic V4L/V4L2 properties incl palette incl setting -+ * -+ * - Setup basic V4L/V4L2 properties incl palette incl setting - * - Open the device - * - Returns the device number. - * -@@ -655,6 +644,7 @@ void vid_close(struct context *cnt) - * Returns - * device number - * -1 if failed to open device. -+ * -3 image dimensions are not modulo 8 - */ - static int vid_v4lx_start(struct context *cnt) - { -@@ -665,20 +655,23 @@ static int vid_v4lx_start(struct context - int width, height, input, norm, tuner_number; - unsigned long frequency; - -- /* We use width and height from conf in this function. They will be assigned -- * to width and height in imgs here, and cap_width and cap_height in -+ /* -+ * We use width and height from conf in this function. They will be assigned -+ * to width and height in imgs here, and cap_width and cap_height in - * rotate_data won't be set until in rotate_init. -- * Motion requires that width and height is a multiple of 16 so we check -+ * Motion requires that width and height is a multiple of 8 so we check - * for this first. - */ -- if (conf->width % 16) { -- motion_log(LOG_ERR, 0, "config image width (%d) is not modulo 16", conf->width); -- return -1; -+ if (conf->width % 8) { -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: config image width (%d) is not modulo 8", -+ conf->width); -+ return -3; - } - -- if (conf->height % 16) { -- motion_log(LOG_ERR, 0, "config image height (%d) is not modulo 16", conf->height); -- return -1; -+ if (conf->height % 8) { -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: config image height (%d) is not modulo 8", -+ conf->height); -+ return -3; - } - - width = conf->width; -@@ -690,24 +683,25 @@ static int vid_v4lx_start(struct context - - pthread_mutex_lock(&vid_mutex); - -- /* Transfer width and height from conf to imgs. The imgs values are the ones -+ /* -+ * Transfer width and height from conf to imgs. The imgs values are the ones - * that is used internally in Motion. That way, setting width and height via - * http remote control won't screw things up. - */ - cnt->imgs.width = width; - cnt->imgs.height = height; - -- /* First we walk through the already discovered video devices to see -+ /* -+ * First we walk through the already discovered video devices to see - * if we have already setup the same device before. If this is the case - * the device is a Round Robin device and we set the basic settings -- * and return the file descriptor -+ * and return the file descriptor. - */ - dev = viddevs; - while (dev) { - if (!strcmp(conf->video_device, dev->video_device)) { - dev->usage_count++; - cnt->imgs.type = dev->v4l_fmt; -- - switch (cnt->imgs.type) { - case VIDEO_PALETTE_GREY: - cnt->imgs.motionsize = width * height; -@@ -728,6 +722,9 @@ static int vid_v4lx_start(struct context - dev = dev->next; - } - -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using videodevice %s and input %d", -+ conf->video_device, conf->input); -+ - dev = mymalloc(sizeof(struct video_dev)); - memset(dev, 0, sizeof(struct video_dev)); - -@@ -736,7 +733,8 @@ static int vid_v4lx_start(struct context - fd = open(dev->video_device, O_RDWR); - - if (fd < 0) { -- motion_log(LOG_ERR, 1, "Failed to open video device %s", conf->video_device); -+ MOTION_LOG(ALR, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed to open video device %s", -+ conf->video_device); - free(dev); - pthread_mutex_unlock(&vid_mutex); - return -1; -@@ -748,12 +746,14 @@ static int vid_v4lx_start(struct context - dev->usage_count = 1; - dev->fd = fd; - dev->input = input; -+ dev->norm = norm; - dev->height = height; - dev->width = width; - dev->freq = frequency; - dev->tuner_number = tuner_number; - -- /* We set brightness, contrast, saturation and hue = 0 so that they only get -+ /* -+ * We set brightness, contrast, saturation and hue = 0 so that they only get - * set if the config is not zero. - */ - dev->brightness = 0; -@@ -764,19 +764,21 @@ static int vid_v4lx_start(struct context - dev->v4l_fmt = VIDEO_PALETTE_YUV420P; - dev->fps = 0; - #ifdef MOTION_V4L2 -- /* First lets try V4L2 and if it's not supported V4L1 */ -+ /* First lets try V4L2 and if it's not supported V4L1. */ - - dev->v4l2 = 1; - - if (!v4l2_start(cnt, dev, width, height, input, norm, frequency, tuner_number)) { -- /* restore width & height before test with v4l -- * because could be changed in v4l2_start () -+ /* -+ * Restore width & height before test with v4l -+ * because could be changed in v4l2_start(). - */ - dev->width = width; - dev->height = height; - #endif - -- if (!v4l_start(cnt, dev, width, height, input, norm, frequency, tuner_number)) { -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) -+ if (!v4l_start(dev, width, height, input, norm, frequency, tuner_number)) { - close(dev->fd); - pthread_mutexattr_destroy(&dev->attr); - pthread_mutex_destroy(&dev->mutex); -@@ -785,15 +787,17 @@ static int vid_v4lx_start(struct context - pthread_mutex_unlock(&vid_mutex); - return -1; - } -+#endif -+ - #ifdef MOTION_V4L2 - dev->v4l2 = 0; - } - #endif - if (dev->v4l2 == 0) { -- motion_log(-1, 0, "Using V4L1"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using V4L1"); - } else { -- motion_log(-1, 0, "Using V4L2"); -- /* Update width & height because could be changed in v4l2_start () */ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Using V4L2"); -+ /* Update width & height because could be changed in v4l2_start(). */ - width = dev->width; - height = dev->height; - cnt->imgs.width = width; -@@ -817,17 +821,15 @@ static int vid_v4lx_start(struct context - break; - } - -- /* Insert into linked list */ -+ /* Insert into linked list. */ - dev->next = viddevs; - viddevs = dev; - - pthread_mutex_unlock(&vid_mutex); - --return fd; -+ return fd; - } --#endif /*WITHOUT_V4L */ -- -- -+#endif /* !WITHOUT_V4L */ - - /** - * vid_start -@@ -835,13 +837,13 @@ return fd; - * vid_start setup the capture device. This will be either a V4L device or a netcam. - * The function does the following: - * - If the camera is a netcam - netcam_start is called and function returns -- * - Width and height are checked for valid value (multiple of 16) -+ * - Width and height are checked for valid value (multiple of 8) - * - Copy the config height and width to the imgs struct. Note that height and width are - * only copied to the from the conf struct to the imgs struct during program startup - * The width and height can no later be changed via http remote control as this would - * require major re-memory allocations of all image buffers. -- * -- * - if the camera is V4L/V4L2 vid_v4lx_start is called -+ * -+ * - if the camera is V4L/V4L2 vid_v4lx_start is called - * - * Parameters: - * cnt Pointer to the context for this thread -@@ -849,8 +851,8 @@ return fd; - * Returns - * device number - * -1 if failed to open device. -+ * -3 image dimensions are not modulo 8 - */ -- - int vid_start(struct context *cnt) - { - struct config *conf = &cnt->conf; -@@ -864,8 +866,8 @@ int vid_start(struct context *cnt) - } - } - #ifdef WITHOUT_V4L -- else -- motion_log(LOG_ERR, 0,"You must setup netcam_url"); -+ else -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: You must setup netcam_url"); - #else - else - dev = vid_v4lx_start(cnt); -@@ -891,7 +893,7 @@ int vid_start(struct context *cnt) - * -1 Fatal V4L error - * -2 Fatal Netcam error - * Positive numbers... -- * with bit 0 set Non fatal V4L error (not implemented) -+ * with bit 0 set Non fatal V4L error (copy grey image and discard this image) - * with bit 1 set Non fatal Netcam error - */ - int vid_next(struct context *cnt, unsigned char *map) -@@ -906,8 +908,9 @@ int vid_next(struct context *cnt, unsign - return netcam_next(cnt, map); - } - #ifndef WITHOUT_V4L -- /* We start a new block so we can make declarations without breaking -- * gcc 2.95 or older -+ /* -+ * We start a new block so we can make declarations without breaking -+ * gcc 2.95 or older. - */ - { - struct video_dev *dev; -@@ -940,10 +943,10 @@ int vid_next(struct context *cnt, unsign - ret = v4l2_next(cnt, dev, map, width, height); - } else { - #endif -- v4l_set_input(cnt, dev, map, width, height, conf->input, conf->norm, -- conf->roundrobin_skip, conf->frequency, conf->tuner_number); -- -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) -+ v4l_set_input(cnt, dev, map, width, height, conf); - ret = v4l_next(dev, map, width, height); -+#endif - #ifdef MOTION_V4L2 - } - #endif -@@ -953,11 +956,11 @@ int vid_next(struct context *cnt, unsign - pthread_mutex_unlock(&dev->mutex); - } - -- /* rotate the image as specified */ -+ /* Rotate the image as specified. */ - if (cnt->rotate_data.degrees > 0) - rotate_map(cnt, map); -- -+ - } --#endif /*WITHOUT_V4L */ -+#endif /*WITHOUT_V4L */ - return ret; - } ---- motion-3.2.12.orig/video_freebsd.c -+++ motion-3.2.12/video_freebsd.c -@@ -1,23 +1,22 @@ - /* video_freebsd.c - * - * BSD Video stream functions for motion. -- * Copyright 2004 by Angel Carpintero (ack@telefonica.net) -+ * Copyright 2004 by Angel Carpintero (motiondevelop@gmail.com) - * This software is distributed under the GNU public license version 2 - * See also the file 'COPYING'. - * - */ - --/* for rotation */ --#include "rotate.h" /* already includes motion.h */ -+/* For rotation */ -+#include "rotate.h" /* Already includes motion.h */ - #include "video_freebsd.h" - - #ifndef WITHOUT_V4L - --/* for the v4l stuff: */ -+/* For the v4l stuff: */ - #include - - /* Hack from xawtv 4.x */ -- - #define VIDEO_NONE 0 - #define VIDEO_RGB08 1 /* bt848 dithered */ - #define VIDEO_GRAY 2 -@@ -40,7 +39,7 @@ - #define VIDEO_MPEG 19 /* MPEG1/2 */ - #define VIDEO_FMT_COUNT 20 - --#define array_elem(x) (sizeof(x) / sizeof( (x)[0] )) -+#define array_elem(x) (sizeof(x) / sizeof((x)[0])) - - static const struct camparam_st { - int min, max, range, drv_min, drv_range, def; -@@ -56,7 +55,7 @@ static const struct camparam_st { - BT848_CONTRASTCENTER, }, - { - BT848_CHROMAMIN, (BT848_CHROMAMIN + BT848_CHROMARANGE), BT848_CHROMARANGE, -- BT848_CHROMAREGMIN, (BT848_CHROMAREGMAX - BT848_CHROMAREGMIN + 1 ), -+ BT848_CHROMAREGMIN, (BT848_CHROMAREGMAX - BT848_CHROMAREGMIN + 1), - BT848_CHROMACENTER, }, - }; - -@@ -68,13 +67,11 @@ volatile sig_atomic_t bktr_frame_waiting - - //sigset_t sa_mask; - -- - static void catchsignal(int sig) - { - bktr_frame_waiting++; - } - -- - /* Not tested yet */ - static void yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height) - { -@@ -110,8 +107,10 @@ static void yuv422to420p(unsigned char * - - } - --/* FIXME seems no work with METEOR_GEO_RGB24 , check BPP as well ? */ -- -+/** -+ * rgb24toyuv420p -+ * FIXME seems no work with METEOR_GEO_RGB24 , check BPP as well ? -+ */ - static void rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height) - { - unsigned char *y, *u, *v; -@@ -160,15 +159,15 @@ static void rgb24toyuv420p(unsigned char - /* NOT TESTED YET FIXME */ - - /* --static int camparam_normalize(int param, int cfg_value, int *ioctl_val) -+static int camparam_normalize(int param, int cfg_value, int *ioctl_val) - { - int val; - -- cfg_value = MIN(CamParams[ param ].max, MAX( CamParams[ param ].min, cfg_value)); -- val = (cfg_value - CamParams[ param ].min ) / -+ cfg_value = MIN(CamParams[ param ].max, MAX(CamParams[ param ].min, cfg_value)); -+ val = (cfg_value - CamParams[ param ].min) / - (CamParams[ param ].range + 0.01) * CamParams[param].drv_range + CamParams[param].drv_min; -- val = MAX(CamParams[param].min, -- MIN(CamParams[param].drv_min + CamParams[ param ].drv_range-1, val)); -+ val = MAX(CamParams[ param ].min, -+ MIN(CamParams[ param ].drv_min + CamParams[ param ].drv_range-1, val)); - *ioctl_val = val; - return cfg_value; - } -@@ -179,12 +178,12 @@ static int set_hue(int viddev, int new_h - signed char ioctlval = new_hue; - - if (ioctl(viddev, METEORSHUE, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORSHUE Error setting hue [%d]", __FUNCTION__, new_hue); -- return -1; -- } -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSHUE Error setting hue [%d]", -+ new_hue); -+ return -1; -+ } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); - - return ioctlval; - } -@@ -194,29 +193,27 @@ static int get_hue(int viddev , int *hue - signed char ioctlval; - - if (ioctl(viddev, METEORGHUE, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORGHUE Error getting hue", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGHUE Error getting hue"); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -- -- *hue = ioctlval; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); -+ -+ *hue = ioctlval; - return ioctlval; - } - --static int set_saturation(int viddev, int new_saturation) -+static int set_saturation(int viddev, int new_saturation) - { - unsigned char ioctlval= new_saturation; - - if (ioctl(viddev, METEORSCSAT, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORSCSAT Error setting saturation [%d]", -- __FUNCTION__, new_saturation); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSCSAT Error setting saturation [%d]", -+ new_saturation); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); - - return ioctlval; - } -@@ -226,30 +223,27 @@ static int get_saturation(int viddev , i - unsigned char ioctlval; - - if (ioctl(viddev, METEORGCSAT, &ioctlval) < 0) { -- -- motion_log(LOG_ERR, 1, "%s: METEORGCSAT Error getting saturation", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGCSAT Error getting saturation"); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); -+ - *saturation = ioctlval; - return ioctlval; - } - --static int set_contrast(int viddev, int new_contrast) -+static int set_contrast(int viddev, int new_contrast) - { - unsigned char ioctlval = new_contrast; - - if (ioctl(viddev, METEORSCONT, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORSCONT Error setting contrast [%d]", -- __FUNCTION__, new_contrast); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSCONT Error setting contrast [%d]", -+ new_contrast); - return 0; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); - - return ioctlval; - } -@@ -258,15 +252,14 @@ static int get_contrast(int viddev, int - { - unsigned char ioctlval; - -- if (ioctl (viddev, METEORGCONT, &ioctlval ) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORGCONT Error getting contrast", __FUNCTION__); -+ if (ioctl(viddev, METEORGCONT, &ioctlval) < 0) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGCONT Error getting contrast"); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -- -- *contrast = ioctlval; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); -+ -+ *contrast = ioctlval; - return ioctlval; - } - -@@ -276,13 +269,13 @@ static int set_brightness(int viddev, in - unsigned char ioctlval = new_bright; - - if (ioctl(viddev, METEORSBRIG, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORSBRIG brightness [%d]", __FUNCTION__, new_bright); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSBRIG brightness [%d]", -+ new_bright); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); -+ - return ioctlval; - } - -@@ -292,57 +285,57 @@ static int get_brightness(int viddev, in - unsigned char ioctlval; - - if (ioctl(viddev, METEORGBRIG, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORGBRIG getting brightness", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGBRIG getting brightness"); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, ioctlval); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", ioctlval); -+ - *brightness = ioctlval; - return ioctlval; - } - --// Set channel needed ? FIXME -+// Set channel needed ? FIXME - /* --static int set_channel(struct video_dev *viddev, int new_channel) -+static int set_channel(struct video_dev *viddev, int new_channel) - { - int ioctlval; - - ioctlval = new_channel; - if (ioctl(viddev->fd_tuner, TVTUNER_SETCHNL, &ioctlval) < 0) { -- motion_log(LOG_ERR, 1, "Error channel %d", ioctlval); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error channel %d", ioctlval); - return -1; - } else { -- motion_log(LOG_DEBUG, 0, "channel set to %d", ioctlval); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: channel set to %d", ioctlval); - } - - viddev->channel = new_channel; -- -+ - return 0; - } - */ - --/* set frequency to tuner */ -- -+/** -+ * set_freq -+ * Sets frequency to tuner -+ */ - static int set_freq(struct video_dev *viddev, unsigned long freq) - { - int tuner_fd = viddev->fd_tuner; - int old_audio; - -- motion_log(LOG_DEBUG, 0, "%s: Not implemented", __FUNCTION__); -- -- return 0; -- -- /* HACK maybe not need it , but seems that is needed to mute before changing frequency */ -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Not implemented"); -+ return 0; - -+ /* HACK maybe not need it , but seems that is needed to mute before changing frequency */ - if (ioctl(tuner_fd, BT848_GAUDIO, &old_audio) < 0) { -- motion_log(LOG_ERR, 1, "%s: BT848_GAUDIO", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848_GAUDIO"); - return -1; - } -- -+ - if (ioctl(tuner_fd, TVTUNER_SETFREQ, &freq) < 0) { -- motion_log(LOG_ERR, 1, "%s: Tuning (TVTUNER_SETFREQ) failed , freq [%lu]", __FUNCTION__, freq); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Tuning (TVTUNER_SETFREQ) failed, ", -+ "freq [%lu]", freq); - return -1; - } - -@@ -350,55 +343,58 @@ static int set_freq(struct video_dev *vi - if (old_audio) { - old_audio = AUDIO_MUTE; - if (ioctl(tuner_fd , BT848_SAUDIO, &old_audio) < 0) { -- motion_log(LOG_ERR, 1, "%s: BT848_SAUDIO %i", __FUNCTION__, old_audio); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848_SAUDIO %i", -+ old_audio); - return -1; - } - } -- -+ - return 0; - } - --/* -- set the input to capture images , could be tuner (METEOR_INPUT_DEV1) -- or any of others input : -- RCA/COMPOSITE1 (METEOR_INPUT_DEV0) -- COMPOSITE2/S-VIDEO (METEOR_INPUT_DEV2) -- S-VIDEO (METEOR_INPUT_DEV3) -- VBI ?! (METEOR_INPUT_DEV_SVIDEO) --*/ -- --static int set_input(struct video_dev *viddev, unsigned short input) -+/** -+ * set_input -+ * Sets the input to capture images , could be tuner (METEOR_INPUT_DEV1) -+ * or any of others input : -+ * RCA/COMPOSITE1 (METEOR_INPUT_DEV0) -+ * COMPOSITE2/S-VIDEO (METEOR_INPUT_DEV2) -+ * S-VIDEO (METEOR_INPUT_DEV3) -+ * VBI ?! (METEOR_INPUT_DEV_SVIDEO) -+ */ -+static int set_input(struct video_dev *viddev, unsigned input) - { - int actport; - int portdata[] = { METEOR_INPUT_DEV0, METEOR_INPUT_DEV1, - METEOR_INPUT_DEV2, METEOR_INPUT_DEV3, -- METEOR_INPUT_DEV_SVIDEO}; -+ METEOR_INPUT_DEV_SVIDEO }; - - if (input >= array_elem(portdata)) { -- motion_log(LOG_INFO, 0, "%s: Channel Port %d out of range (0-4)", __FUNCTION__, input); -+ MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Channel Port %d out of range (0-4)", -+ input); - return -1; - } - -- actport = portdata[input]; -+ actport = portdata[ input ]; - if (ioctl(viddev->fd_bktr, METEORSINPUT, &actport) < 0) { - if (input != IN_DEFAULT) { -- motion_log(LOG_INFO, 1, "%s: METEORSINPUT %d invalid - Trying default %d", -- __FUNCTION__, input, IN_DEFAULT); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSINPUT %d invalid -" -+ "Trying default %d", input, IN_DEFAULT); - input = IN_DEFAULT; -- actport = portdata[input]; -+ actport = portdata[ input ]; - if (ioctl(viddev->fd_bktr, METEORSINPUT, &actport) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORSINPUT %d init", __FUNCTION__, input); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSINPUT %d init", -+ input); - return -1; - } - } else { -- motion_log(LOG_ERR, 1, "%s: METEORSINPUT %d init", __FUNCTION__, input); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSINPUT %d init", -+ input); - return -1; - } - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d]", __FUNCTION__, input); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d]", input); -+ - return input; - } - -@@ -409,72 +405,70 @@ static int set_geometry(struct video_dev - - geom.columns = width; - geom.rows = height; -- - geom.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12; - -- - switch (viddev->norm) { -- case PAL: -- h_max = PAL_HEIGHT; -+ case PAL: -+ h_max = PAL_HEIGHT; - break; -- case NTSC: -- h_max = NTSC_HEIGHT; -+ case NTSC: -+ h_max = NTSC_HEIGHT; - break; -- case SECAM: -+ case SECAM: - h_max = SECAM_HEIGHT; - break; -- default: -+ default: - h_max = PAL_HEIGHT; - } - -- if (height <= h_max / 2) -+ if (height <= h_max / 2) - geom.oformat |= METEOR_GEO_EVEN_ONLY; - - geom.frames = 1; - - if (ioctl(viddev->fd_bktr, METEORSETGEO, &geom) < 0) { -- motion_log(LOG_ERR, 1, "%s: Couldn't set the geometry", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Couldn't set the geometry"); - return -1; - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to [%d/%d] Norm %d", __FUNCTION__, width, height, viddev->norm); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to [%d/%d] Norm %d", -+ width, height, viddev->norm); -+ - return 0; - } - --/* -- set input format ( PAL, NTSC, SECAM, etc ... ) --*/ -- --static int set_input_format(struct video_dev *viddev, unsigned short newformat) -+/** -+ * set_input_format -+ * Sets input format ( PAL, NTSC, SECAM, etc ... ) -+ */ -+static int set_input_format(struct video_dev *viddev, unsigned newformat) - { - int input_format[] = { NORM_PAL_NEW, NORM_NTSC_NEW, NORM_SECAM_NEW, NORM_DEFAULT_NEW}; - int format; -- -- if (newformat >= array_elem( input_format )) { -- motion_log(LOG_WARNING, 0, "%s: Input format %d out of range (0-2)", __FUNCTION__, newformat); -+ -+ if (newformat >= array_elem(input_format)) { -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Input format %d out of range (0-2)", -+ newformat); - return -1; -- } -+ } - -- format = input_format[newformat]; -+ format = input_format[newformat]; - -- if (ioctl( viddev->fd_bktr, BT848SFMT, &format) < 0) { -- motion_log(LOG_ERR, 1, "%s: BT848SFMT, Couldn't set the input format , try again with default", -- __FUNCTION__); -+ if (ioctl(viddev->fd_bktr, BT848SFMT, &format) < 0) { -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848SFMT, Couldn't set the input format, " -+ "try again with default"); - format = NORM_DEFAULT_NEW; - newformat = 3; -- -+ - if (ioctl(viddev->fd_bktr, BT848SFMT, &format) < 0) { -- motion_log(LOG_ERR, 1, "%s: BT848SFMT, Couldn't set the input format either default", -- __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848SFMT, Couldn't set the input format " -+ "either default"); - return -1; - } - } - -- if (debug_level >= CAMERA_VIDEO) -- motion_log(-1, 0, "%s: to %d", __FUNCTION__, newformat); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: to %d", newformat); -+ - return newformat; - } - -@@ -485,73 +479,75 @@ statict int setup_pixelformat(int bktr) - struct meteor_pixfmt p; - int format=-1; - -- for(i = 0; ; i++){ -+ for (i = 0; ; i++) { - p.index = i; -- if (ioctl(bktr, METEORGSUPPIXFMT, &p ) < 0) { -+ if (ioctl(bktr, METEORGSUPPIXFMT, &p) < 0) { - if (errno == EINVAL) - break; -- motion_log(LOG_ERR, 1, "METEORGSUPPIXFMT getting pixformat %d", i); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORGSUPPIXFMT getting pixformat %d", i); - return -1; - } - - -- // Hack from xawtv 4.x -+ // Hack from xawtv 4.x - -- switch ( p.type ) { -+ switch (p.type) { - case METEOR_PIXTYPE_RGB: -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB"); -- switch(p.masks[0]) { -- case 31744: // 15 bpp -- format = p.swap_bytes ? VIDEO_RGB15_LE : VIDEO_RGB15_BE; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB15"); -- break; -- case 63488: // 16 bpp -- format = p.swap_bytes ? VIDEO_RGB16_LE : VIDEO_RGB16_BE; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB16"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB"); -+ switch (p.masks[0]) { -+ case 31744: // 15 bpp -+ format = p.swap_bytes ? VIDEO_RGB15_LE : VIDEO_RGB15_BE; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB15"); - break; -- case 16711680: // 24/32 bpp -- if (p.Bpp == 3 && p.swap_bytes == 1) { -- format = VIDEO_BGR24; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR24"); -- } else if (p.Bpp == 4 && p.swap_bytes == 1 && p.swap_shorts == 1) { -- format = VIDEO_BGR32; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR32"); -- } else if (p.Bpp == 4 && p.swap_bytes == 0 && p.swap_shorts == 0) { -- format = VIDEO_RGB32; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB32"); -- } -+ case 63488: // 16 bpp -+ format = p.swap_bytes ? VIDEO_RGB16_LE : VIDEO_RGB16_BE; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB16"); - break; -- case METEOR_PIXTYPE_YUV: -- format = VIDEO_YUV422P; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_YUV"); -+ case 16711680: // 24/32 bpp -+ if (p.Bpp == 3 && p.swap_bytes == 1) { -+ format = VIDEO_BGR24; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR24"); -+ } else if (p.Bpp == 4 && p.swap_bytes == 1 && p.swap_shorts == 1) { -+ format = VIDEO_BGR32; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_BGR32"); -+ } else if (p.Bpp == 4 && p.swap_bytes == 0 && p.swap_shorts == 0) { -+ format = VIDEO_RGB32; -+ MOTION_LOG(EMG, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_RGB VIDEO_RGB32"); -+ } -+ } - break; -- case METEOR_PIXTYPE_YUV_12: -- format = VIDEO_YUV422P; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_YUV_12"); -+ case METEOR_PIXTYPE_YUV: -+ format = VIDEO_YUV422P; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_YUV"); - break; -- case METEOR_PIXTYPE_YUV_PACKED: -- format = VIDEO_YUV422P; -- motion_log(-1, 0, "setup_pixelformat METEOR_PIXTYPE_YUV_PACKED"); -+ case METEOR_PIXTYPE_YUV_12: -+ format = VIDEO_YUV422P; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_YUV_12"); -+ break; -+ case METEOR_PIXTYPE_YUV_PACKED: -+ format = VIDEO_YUV422P; -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: setup_pixelformat METEOR_PIXTYPE_YUV_PACKED"); - break; -+ - } - -- if (p.type == METEOR_PIXTYPE_RGB && p.Bpp == 3){ -- // Found a good pixeltype -- set it up -- if (ioctl(bktr, METEORSACTPIXFMT, &i) < 0){ -- motion_log(LOG_WARNING, 1, "METEORSACTPIXFMT etting pixformat METEOR_PIXTYPE_RGB Bpp == 3"); -- // Not immediately fatal -+ if (p.type == METEOR_PIXTYPE_RGB && p.Bpp == 3) { -+ // Found a good pixeltype -- set it up -+ if (ioctl(bktr, METEORSACTPIXFMT, &i) < 0) { -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSACTPIXFMT etting pixformat METEOR_PIXTYPE_RGB Bpp == 3"); -+ // Not immediately fatal - } -- motion_log(LOG_DEBUG, 0, "input format METEOR_PIXTYPE_RGB %i", i); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: input format METEOR_PIXTYPE_RGB %i", i); - format = i; - } - - if (p.type == METEOR_PIXTYPE_YUV_PACKED) { - // Found a good pixeltype -- set it up -- if (ioctl(bktr, METEORSACTPIXFMT, &i ) < 0){ -- motion_log(LOG_WARNING, 1, "METEORSACTPIXFMT setting pixformat METEOR_PIXTYPE_YUV_PACKED"); -+ if (ioctl(bktr, METEORSACTPIXFMT, &i) < 0) { -+ MOTION_LOG(WRN, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORSACTPIXFMT setting pixformat METEOR_PIXTYPE_YUV_PACKED"); - // Not immediately fatal -- } -- motion_log(LOG_DEBUG, 0, "input format METEOR_PIXTYPE_YUV_PACKED %i", i); -+ } -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: input format METEOR_PIXTYPE_YUV_PACKED %i", i); - format = i; - } - -@@ -566,23 +562,23 @@ static void v4l_picture_controls(struct - { - int dev = viddev->fd_bktr; - -- if ((cnt->conf.contrast) && (cnt->conf.contrast != viddev->contrast)) { -+ if ((cnt->conf.contrast) && (cnt->conf.contrast != viddev->contrast)) { - set_contrast(dev, cnt->conf.contrast); -- viddev->contrast = cnt->conf.contrast; -+ viddev->contrast = cnt->conf.contrast; - } - - if ((cnt->conf.hue) && (cnt->conf.hue != viddev->hue)) { - set_hue(dev, cnt->conf.hue); -- viddev->hue = cnt->conf.hue; -+ viddev->hue = cnt->conf.hue; - } - -- if ((cnt->conf.brightness) && -+ if ((cnt->conf.brightness) && - (cnt->conf.brightness != viddev->brightness)) { - set_brightness(dev, cnt->conf.brightness); -- viddev->brightness = cnt->conf.brightness; -+ viddev->brightness = cnt->conf.brightness; - } - -- if ((cnt->conf.saturation) && -+ if ((cnt->conf.saturation) && - (cnt->conf.saturation != viddev->saturation)) { - set_saturation(dev, cnt->conf.saturation); - viddev->saturation = cnt->conf.saturation; -@@ -597,7 +593,7 @@ static void v4l_picture_controls(struct - - setup_pixelformat - - set_geometry - -- - set_brightness -+ - set_brightness - - set_chroma - - set_contrast - - set_channelset -@@ -605,97 +601,97 @@ static void v4l_picture_controls(struct - - set_capture_mode - - */ --static unsigned char *v4l_start(struct video_dev *viddev, int width, int height, -- unsigned short input, unsigned short norm, unsigned long freq) -+static unsigned char *v4l_start(struct video_dev *viddev, int width, int height, -+ unsigned input, unsigned norm, unsigned long freq) - { - int dev_bktr = viddev->fd_bktr; - struct sigaction act, old; - //int dev_tunner = viddev->fd_tuner; -- /* to ensure that all device will be support the capture mode -+ /* to ensure that all device will be support the capture mode - _TODO_ : Autodected the best capture mode . - */ - int dummy = 1; --// int pixelformat = BSD_VIDFMT_I420; -+ // int pixelformat = BSD_VIDFMT_I420; - - void *map; - -- /* if we have choose the tuner is needed to setup the frequency */ -+ /* If we have choose the tuner is needed to setup the frequency. */ - if ((viddev->tuner_device != NULL) && (input == IN_TV)) { - if (!freq) { -- motion_log(LOG_ERR, 0, "%s: Not valid Frequency [%lu] for Source input [%i]", -- __FUNCTION__, freq, input); -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Not valid Frequency [%lu] for " -+ "Source input [%i]", freq, input); - return NULL; - } else if (set_freq(viddev, freq) == -1) { -- motion_log(LOG_ERR, 0, "%s: Frequency [%lu] Source input [%i]", -- __FUNCTION__, freq, input); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Frequency [%lu] Source input [%i]", -+ freq, input); - return NULL; - } - } -- -- /* FIXME if we set as input tuner , we need to set option for tuner not for bktr */ - -+ /* FIXME if we set as input tuner , we need to set option for tuner not for bktr */ - if ((dummy = set_input(viddev, input)) == -1) { -- motion_log(LOG_ERR, 0, "%s: set input [%d]", __FUNCTION__, input); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set input [%d]", input); - return NULL; - } - - viddev->input = dummy; - - if ((dummy = set_input_format(viddev, norm)) == -1) { -- motion_log(LOG_ERR, 0, "%s: set input format [%d]", __FUNCTION__, norm); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set input format [%d]", -+ norm); - return NULL; - } - - viddev->norm = dummy; - - if (set_geometry(viddev, width, height) == -1) { -- motion_log(LOG_ERR, 0, "%s: set geometry [%d]x[%d]", __FUNCTION__, width, height); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: set geometry [%d]x[%d]", -+ width, height); - return NULL; - } --/* -+ -+ /* - if (ioctl(dev_bktr, METEORSACTPIXFMT, &pixelformat) < 0) { -- motion_log(LOG_ERR, 1, "set encoding method BSD_VIDFMT_I420"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: set encoding method BSD_VIDFMT_I420"); - return NULL; - } - -- -- NEEDED !? FIXME -+ NEEDED !? FIXME - - if (setup_pixelformat(viddev) == -1) - return NULL; --*/ -+ */ - - if (freq) { -- if (debug_level >= CAMERA_DEBUG) -- motion_log(-1, 0, "%s: Frequency set (no implemented yet", __FUNCTION__); -+ MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Frequency set (no implemented yet"); - /* - TODO missing implementation - set_channelset(viddev); - set_channel(viddev); -- if (set_freq (viddev, freq) == -1) { -+ if (set_freq (viddev, freq) == -1) - return NULL; -- } - */ -- } -- - -- /* set capture mode and capture buffers */ -- -- /* That is the buffer size for capture images , -- so is dependent of color space of input format / FIXME */ -+ } - -+ /* -+ * Set capture mode and capture buffers -+ * That is the buffer size for capture images , -+ * so is dependent of color space of input format / FIXME -+ */ - viddev->v4l_bufsize = (((width * height * 3 / 2)) * sizeof(unsigned char)); - viddev->v4l_fmt = VIDEO_PALETTE_YUV420P; -- - -- map = mmap((caddr_t)0, viddev->v4l_bufsize, PROT_READ|PROT_WRITE, MAP_SHARED, dev_bktr, (off_t)0); - -- if (map == MAP_FAILED){ -- motion_log(LOG_ERR, 1, "%s: mmap failed", __FUNCTION__); -+ map = mmap((caddr_t)0, viddev->v4l_bufsize, PROT_READ|PROT_WRITE, MAP_SHARED, -+ dev_bktr, (off_t)0); -+ -+ if (map == MAP_FAILED) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: mmap failed"); - return NULL; - } - -- /* FIXME double buffer */ -+ /* FIXME double buffer */ - if (0) { - viddev->v4l_maxbuffer = 2; - viddev->v4l_buffers[0] = map; -@@ -709,55 +705,54 @@ static unsigned char *v4l_start(struct v - viddev->v4l_curbuffer = 0; - - /* Clear the buffer */ -- - if (ioctl(dev_bktr, BT848SCBUF, &dummy) < 0) { -- motion_log(LOG_ERR, 1, "%s: BT848SCBUF", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: BT848SCBUF"); - return NULL; - } - -- /* signal handler to know when data is ready to be read() */ -- -+ /* Signal handler to know when data is ready to be read() */ - memset(&act, 0, sizeof(act)); - sigemptyset(&act.sa_mask); - act.sa_handler = catchsignal; - sigaction(SIGUSR2, &act, &old); -- -+ - dummy = SIGUSR2; - - //viddev->capture_method = METEOR_CAP_CONTINOUS; - //viddev->capture_method = METEOR_CAP_SINGLE; -- -- if ((viddev->capture_method == METEOR_CAP_CONTINOUS) && (ioctl(dev_bktr, METEORSSIGNAL, &dummy) < 0)) { -- motion_log(LOG_ERR, 1, "%s: METEORSSIGNAL", __FUNCTION__); -- motion_log(LOG_INFO, 0 , "%s: METEORSSIGNAL", __FUNCTION__); -+ -+ if ((viddev->capture_method == METEOR_CAP_CONTINOUS) && -+ (ioctl(dev_bktr, METEORSSIGNAL, &dummy) < 0)) { -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORSSIGNAL"); -+ - viddev->capture_method = METEOR_CAP_SINGLE; -+ - if (ioctl(dev_bktr, METEORCAPTUR, &viddev->capture_method) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORCAPTUR using single method " -- "Error capturing", __FUNCTION__); -- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR using single method " -- "Error capturing", __FUNCTION__); -- } -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORCAPTUR using single method " -+ "Error capturing"); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORCAPTUR using single method " -+ "Error capturing"); -+ } - } else { - if (ioctl(dev_bktr, METEORCAPTUR, &viddev->capture_method) < 0) { - viddev->capture_method = METEOR_CAP_SINGLE; -+ - if (ioctl(dev_bktr, METEORCAPTUR, &viddev->capture_method) < 0) { -- motion_log(LOG_ERR, 1, "%s: METEORCAPTUR using single method " -- "Error capturing", __FUNCTION__); -- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR using single method " -- "Error capturing", __FUNCTION__); -- } -- } -- } -- -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: METEORCAPTUR using single method " -+ "Error capturing"); -+ } -+ } -+ } -+ - if (viddev->capture_method == METEOR_CAP_CONTINOUS) -- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR METEOR_CAP_CONTINOUS", __FUNCTION__); -- else -- motion_log(LOG_INFO, 0, "%s: METEORCAPTUR METEOR_CAP_SINGLE", __FUNCTION__); -- -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORCAPTUR METEOR_CAP_CONTINOUS"); -+ else -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: METEORCAPTUR METEOR_CAP_SINGLE"); -+ - // settle , sleep(1) replaced - SLEEP(1, 0); - -- /* FIXME*/ -+ /* FIXME */ - switch (viddev->v4l_fmt) { - case VIDEO_PALETTE_YUV420P: - viddev->v4l_bufsize = (width * height * 3) / 2; -@@ -772,12 +767,16 @@ static unsigned char *v4l_start(struct v - viddev->v4l_bufsize = width * height; - break; - } -- -- motion_log(LOG_INFO, 0, "HUE [%d]", get_hue(dev_bktr, &dummy)); -- motion_log(LOG_INFO, 0, "SATURATION [%d]", get_saturation(dev_bktr, &dummy)); -- motion_log(LOG_INFO, 0, "BRIGHTNESS [%d]", get_brightness(dev_bktr, &dummy)); -- motion_log(LOG_INFO, 0, "CONTRAST [%d]", get_contrast(dev_bktr, &dummy)); -- -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: HUE [%d]", -+ get_hue(dev_bktr, &dummy)); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: SATURATION [%d]", -+ get_saturation(dev_bktr, &dummy)); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: BRIGHTNESS [%d]", -+ get_brightness(dev_bktr, &dummy)); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: CONTRAST [%d]", -+ get_contrast(dev_bktr, &dummy)); -+ - return map; - } - -@@ -805,8 +804,10 @@ static int v4l_next(struct video_dev *vi - - /* ONLY MMAP method is used to Capture */ - -- /* Allocate a new mmap buffer */ -- /* Block signals during IOCTL */ -+ /* -+ * Allocates a new mmap buffer -+ * Block signals during IOCTL -+ */ - sigemptyset (&set); - sigaddset (&set, SIGCHLD); - sigaddset (&set, SIGALRM); -@@ -820,21 +821,21 @@ static int v4l_next(struct video_dev *vi - if (viddev->v4l_curbuffer >= viddev->v4l_maxbuffer) - viddev->v4l_curbuffer = 0; - -- /* capture */ -- -+ /* Capture */ -+ - if (viddev->capture_method == METEOR_CAP_CONTINOUS) { -- if (bktr_frame_waiting) -- bktr_frame_waiting = 0; -- -+ if (bktr_frame_waiting) -+ bktr_frame_waiting = 0; -+ - } else if (ioctl(dev_bktr, METEORCAPTUR, &single) < 0) { -- motion_log(LOG_ERR, 1, "%s: Error capturing using single method", __FUNCTION__); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error capturing using single method"); - sigprocmask(SIG_UNBLOCK, &old, NULL); - return -1; - } - -- /*undo the signal blocking*/ -+ /* Undo the signal blocking */ - pthread_sigmask(SIG_UNBLOCK, &old, NULL); -- -+ - switch (viddev->v4l_fmt) { - case VIDEO_PALETTE_RGB24: - rgb24toyuv420p(map, cap_map, width, height); -@@ -845,33 +846,35 @@ static int v4l_next(struct video_dev *vi - default: - memcpy(map, cap_map, viddev->v4l_bufsize); - } -- -+ - return 0; - } - - --/* set input & freq if needed FIXME not allowed use Tuner yet */ -- --static void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, int height, -- unsigned short input, unsigned short norm, int skip, unsigned long freq) -+/** -+ * v4l_set_input -+ * Sets input & freq if needed FIXME not allowed use Tuner yet. -+ */ -+static void v4l_set_input(struct context *cnt, struct video_dev *viddev, unsigned char *map, int width, -+ int height, unsigned input, unsigned norm, int skip, unsigned long freq) - { -- - if (input != viddev->input || norm != viddev->norm || freq != viddev->freq) { - int dummy; - unsigned long frequnits = freq; - -- -+ - if ((dummy = set_input(viddev, input)) == -1) - return; - - viddev->input = dummy; -- -+ - if ((dummy = set_input_format(viddev, norm)) == -1) - return; -- -+ - viddev->norm = dummy; -- -- if ((viddev->tuner_device != NULL) && (viddev->input == IN_TV) && (frequnits > 0)) { -+ -+ if ((viddev->tuner_device != NULL) && (viddev->input == IN_TV) && -+ (frequnits > 0)) { - if (set_freq(viddev, freq) == -1) - return; - } -@@ -879,16 +882,14 @@ static void v4l_set_input(struct context - // FIXME - /* - if (setup_pixelformat(viddev) == -1) { -- motion_log(LOG_ERR, 1, "ioctl (VIDIOCSFREQ)"); -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSFREQ)"); - return - } -- */ - -- /* - if (set_geometry(viddev, width, height) == -1) - return; -- */ -- -+ */ -+ - v4l_picture_controls(cnt, viddev); - - viddev->freq = freq; -@@ -896,7 +897,6 @@ static void v4l_set_input(struct context - /* skip a few frames if needed */ - for (dummy = 0; dummy < skip; dummy++) - v4l_next(viddev, map, width, height); -- - } else { - /* No round robin - we only adjust picture controls */ - v4l_picture_controls(cnt, viddev); -@@ -911,39 +911,39 @@ static void v4l_set_input(struct context - - vid_init - Initi vid_mutex. - vid_start - Setup Device parameters ( device , channel , freq , contrast , hue , saturation , brightness ) and open it. --vid_next - Capture a frame and set input , contrast , hue , saturation and brightness if necessary. --vid_close - close devices. -+vid_next - Capture a frame and set input , contrast , hue , saturation and brightness if necessary. -+vid_close - close devices. - vid_cleanup - Destroy vid_mutex. - - */ - --/* big lock for vid_start to ensure exclusive access to viddevs while adding -- * devices during initialization of each thread -+/* -+ * Big lock for vid_start to ensure exclusive access to viddevs while adding -+ * devices during initialization of each thread. - */ - static pthread_mutex_t vid_mutex; - -- --/* Here we setup the viddevs structure which is used globally in the vid_* -+/* -+ * Here we setup the viddevs structure which is used globally in the vid_* - * functions. -- */ -+ */ - static struct video_dev *viddevs = NULL; - -- --/* -+/** - * vid_init - * - * Called from motion.c at the very beginning before setting up the threads. -- * Function prepares the vid_mutex -+ * Function prepares the vid_mutex. - */ - void vid_init(void) - { - pthread_mutex_init(&vid_mutex, NULL); - } -- -+ - /** - * vid_cleanup - * -- * vid_cleanup is called from motion.c when Motion is stopped or restarted -+ * vid_cleanup is called from motion.c when Motion is stopped or restarted. - */ - void vid_cleanup(void) - { -@@ -952,13 +952,12 @@ void vid_cleanup(void) - - #endif /*WITHOUT_V4L*/ - -- - /** - * vid_close - * -- * vid_close is called from motion.c when a Motion thread is stopped or restarted -+ * vid_close is called from motion.c when a Motion thread is stopped or restarted. - */ --void vid_close(struct context *cnt) -+void vid_close(struct context *cnt) - { - #ifndef WITHOUT_V4L - struct video_dev *dev = viddevs; -@@ -970,79 +969,86 @@ void vid_close(struct context *cnt) - netcam_cleanup(cnt->netcam, 0); - cnt->netcam = NULL; - return; -- } -+ } - - #ifndef WITHOUT_V4L - - /* Cleanup the v4l part */ - pthread_mutex_lock(&vid_mutex); -+ - while (dev) { - if (dev->fd_bktr == cnt->video_dev) - break; -- prev = dev; -- dev = dev->next; -- } -- pthread_mutex_unlock(&vid_mutex); -- -- /* Set it as closed in thread context */ -- cnt->video_dev = -1; -- -- if (dev == NULL) { -- motion_log(LOG_ERR, 0, "%s: Unable to find video device", __FUNCTION__); -- return; -- } -+ prev = dev; -+ dev = dev->next; -+ } - -- if (--dev->usage_count == 0) { -- motion_log(LOG_INFO, 0, "%s: Closing video device %s", -- __FUNCTION__, dev->video_device); -- -- if (dev->fd_tuner > 0) -- close(dev->fd_tuner); -- -- if (dev->fd_bktr > 0) { -- if (dev->capture_method == METEOR_CAP_CONTINOUS) { -- dev->fd_tuner = METEOR_CAP_STOP_CONT; -- ioctl(dev->fd_bktr, METEORCAPTUR, &dev->fd_tuner); -- } -- close(dev->fd_bktr); -- dev->fd_tuner = -1; -+ pthread_mutex_unlock(&vid_mutex); -+ -+ /* Set it as closed in thread context. */ -+ cnt->video_dev = -1; -+ -+ if (dev == NULL) { -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Unable to find video device"); -+ return; -+ } -+ -+ if (--dev->usage_count == 0) { -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Closing video device %s", -+ dev->video_device); -+ -+ if (dev->fd_tuner > 0) -+ close(dev->fd_tuner); -+ -+ if (dev->fd_bktr > 0) { -+ if (dev->capture_method == METEOR_CAP_CONTINOUS) { -+ dev->fd_tuner = METEOR_CAP_STOP_CONT; -+ ioctl(dev->fd_bktr, METEORCAPTUR, &dev->fd_tuner); - } -+ close(dev->fd_bktr); -+ dev->fd_tuner = -1; -+ } - - -- munmap(viddevs->v4l_buffers[0], viddevs->v4l_bufsize); -- viddevs->v4l_buffers[0] = MAP_FAILED; -+ munmap(viddevs->v4l_buffers[0], viddevs->v4l_bufsize); -+ viddevs->v4l_buffers[0] = MAP_FAILED; - -- dev->fd_bktr = -1; -- pthread_mutex_lock(&vid_mutex); -- -- /* Remove from list */ -- if (prev == NULL) -- viddevs = dev->next; -- else -- prev->next = dev->next; -- -- pthread_mutex_unlock(&vid_mutex); -+ dev->fd_bktr = -1; -+ pthread_mutex_lock(&vid_mutex); - -- pthread_mutexattr_destroy(&dev->attr); -- pthread_mutex_destroy(&dev->mutex); -- free(dev); -- } else { -- motion_log(LOG_INFO, 0, "%s: Still %d users of video device %s, so we don't close it now", -- __FUNCTION__, dev->usage_count, dev->video_device); -- /* There is still at least one thread using this device -- * If we own it, release it -- */ -- if (dev->owner == cnt->threadnr) { -+ /* Remove from list */ -+ if (prev == NULL) -+ viddevs = dev->next; -+ else -+ prev->next = dev->next; -+ -+ pthread_mutex_unlock(&vid_mutex); -+ -+ pthread_mutexattr_destroy(&dev->attr); -+ pthread_mutex_destroy(&dev->mutex); -+ free(dev); -+ } else { -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Still %d users of video device %s, " -+ "so we don't close it now", dev->usage_count, -+ dev->video_device); -+ /* -+ * There is still at least one thread using this device -+ * If we own it, release it. -+ */ -+ if (dev->owner == cnt->threadnr) { - dev->frames = 0; - dev->owner = -1; - pthread_mutex_unlock(&dev->mutex); -- } - } --#endif /* WITHOUT_V4L */ -+ } -+#endif /* !WITHOUT_V4L */ - } - - -- -+/** -+ * vid_start -+ * -+ */ - int vid_start(struct context *cnt) - { - struct config *conf = &cnt->conf; -@@ -1054,36 +1060,39 @@ int vid_start(struct context *cnt) - netcam_cleanup(cnt->netcam, 1); - cnt->netcam = NULL; - } -- } -+ } - #ifdef WITHOUT_V4L -- else -- motion_log(LOG_ERR, 0, "%s: You must setup netcam_url", __FUNCTION__); -+ else -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: You must setup netcam_url"); - #else - else { - struct video_dev *dev; - int fd_tuner = -1; - int width, height, capture_method; -- unsigned short input, norm; -+ unsigned input, norm; - unsigned long frequency; - - -- motion_log(-1, 0, "%s: [%s]", __FUNCTION__, conf->video_device); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: [%s]", -+ conf->video_device); - -- /* We use width and height from conf in this function. They will be assigned -- * to width and height in imgs here, and cap_width and cap_height in -+ /* -+ * We use width and height from conf in this function. They will be assigned -+ * to width and height in imgs here, and cap_width and cap_height in - * rotate_data won't be set until in rotate_init. -- * Motion requires that width and height are multiples of 16 so we check for this -+ * Motion requires that width and height are multiples of 8 so we check for this. - */ -- if (conf->width % 16) { -- motion_log(LOG_ERR, 0, -- "%s: config image width (%d) is not modulo 16", -- __FUNCTION__, conf->width); -+ if (conf->width % 8) { -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, -+ "%s: config image width (%d) is not modulo 8", -+ conf->width); - return -1; - } -- if (conf->height % 16) { -- motion_log(LOG_ERR, 0, -- "%s: config image height (%d) is not modulo 16", -- __FUNCTION__, conf->height); -+ -+ if (conf->height % 8) { -+ MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, -+ "%s: config image height (%d) is not modulo 8", -+ conf->height); - return -1; - } - -@@ -1093,39 +1102,41 @@ int vid_start(struct context *cnt) - norm = conf->norm; - frequency = conf->frequency; - capture_method = METEOR_CAP_CONTINOUS; -- -+ - pthread_mutex_lock(&vid_mutex); - -- /* Transfer width and height from conf to imgs. The imgs values are the ones -+ /* -+ * Transfer width and height from conf to imgs. The imgs values are the ones - * that is used internally in Motion. That way, setting width and height via - * http remote control won't screw things up. - */ - cnt->imgs.width = width; - cnt->imgs.height = height; - -- /* First we walk through the already discovered video devices to see -+ /* -+ * First we walk through the already discovered video devices to see - * if we have already setup the same device before. If this is the case - * the device is a Round Robin device and we set the basic settings -- * and return the file descriptor -+ * and return the file descriptor. - */ - dev = viddevs; -- while (dev) { -+ while (dev) { - if (!strcmp(conf->video_device, dev->video_device)) { - int dummy = METEOR_CAP_STOP_CONT; - dev->usage_count++; - cnt->imgs.type = dev->v4l_fmt; - - if (ioctl(dev->fd_bktr, METEORCAPTUR, &dummy) < 0) { -- motion_log(LOG_ERR, 1, "%s Stopping capture", __FUNCTION__); -- return -1; -- } -- -- motion_log(-1, 0, "%s Reusing [%s] inputs [%d,%d] Change capture method " -- "METEOR_CAP_SINGLE", __FUNCTION__, dev->video_device, -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s Stopping capture"); -+ return -1; -+ } -+ -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s Reusing [%s] inputs [%d,%d] Change " -+ "capture method METEOR_CAP_SINGLE", dev->video_device, - dev->input, conf->input); - - dev->capture_method = METEOR_CAP_SINGLE; -- -+ - switch (cnt->imgs.type) { - case VIDEO_PALETTE_GREY: - cnt->imgs.motionsize = width * height; -@@ -1135,13 +1146,13 @@ int vid_start(struct context *cnt) - case VIDEO_PALETTE_YUV422: - cnt->imgs.type = VIDEO_PALETTE_YUV420P; - case VIDEO_PALETTE_YUV420P: -- motion_log(-1, 0, -- "%s VIDEO_PALETTE_YUV420P setting imgs.size " -- "and imgs.motionsize", __FUNCTION__); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s VIDEO_PALETTE_YUV420P setting" -+ " imgs.size and imgs.motionsize"); - cnt->imgs.motionsize = width * height; - cnt->imgs.size = (width * height * 3) / 2; - break; - } -+ - pthread_mutex_unlock(&vid_mutex); - return dev->fd_bktr; // FIXME return fd_tuner ?! - } -@@ -1154,20 +1165,21 @@ int vid_start(struct context *cnt) - - fd_bktr = open(conf->video_device, O_RDWR); - -- if (fd_bktr < 0) { -- motion_log(LOG_ERR, 1, "%s: open video device %s", __FUNCTION__, conf->video_device); -+ if (fd_bktr < 0) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: open video device %s", -+ conf->video_device); - free(dev); - pthread_mutex_unlock(&vid_mutex); - return -1; - } - - -- /* Only open tuner if conf->tuner_device has set , freq and input is 1 */ -+ /* Only open tuner if conf->tuner_device has set , freq and input is 1. */ - if ((conf->tuner_device != NULL) && (frequency > 0) && (input == IN_TV)) { - fd_tuner = open(conf->tuner_device, O_RDWR); -- if (fd_tuner < 0) { -- motion_log(LOG_ERR, 1, "%s: open tuner device %s", -- __FUNCTION__, conf->tuner_device); -+ if (fd_tuner < 0) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: open tuner device %s", -+ conf->tuner_device); - free(dev); - pthread_mutex_unlock(&vid_mutex); - return -1; -@@ -1188,23 +1200,24 @@ int vid_start(struct context *cnt) - dev->freq = frequency; - dev->owner = -1; - dev->capture_method = capture_method; -- -- /* We set brightness, contrast, saturation and hue = 0 so that they only get -+ -+ /* -+ * We set brightness, contrast, saturation and hue = 0 so that they only get - * set if the config is not zero. - */ -- -+ - dev->brightness = 0; - dev->contrast = 0; - dev->saturation = 0; - dev->hue = 0; - dev->owner = -1; - -- /* default palette */ -+ /* Default palette */ - dev->v4l_fmt = VIDEO_PALETTE_YUV420P; - dev->v4l_curbuffer = 0; - dev->v4l_maxbuffer = 1; - -- if (!v4l_start(dev, width, height, input, norm, frequency)) { -+ if (!v4l_start(dev, width, height, input, norm, frequency)) { - close(dev->fd_bktr); - pthread_mutexattr_destroy(&dev->attr); - pthread_mutex_destroy(&dev->mutex); -@@ -1213,10 +1226,10 @@ int vid_start(struct context *cnt) - pthread_mutex_unlock(&vid_mutex); - return -1; - } -- -+ - cnt->imgs.type = dev->v4l_fmt; -- -- switch (cnt->imgs.type) { -+ -+ switch (cnt->imgs.type) { - case VIDEO_PALETTE_GREY: - cnt->imgs.size = width * height; - cnt->imgs.motionsize = width * height; -@@ -1225,19 +1238,19 @@ int vid_start(struct context *cnt) - case VIDEO_PALETTE_YUV422: - cnt->imgs.type = VIDEO_PALETTE_YUV420P; - case VIDEO_PALETTE_YUV420P: -- motion_log(-1, 0, "%s: VIDEO_PALETTE_YUV420P imgs.type", __FUNCTION__); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: VIDEO_PALETTE_YUV420P imgs.type"); - cnt->imgs.size = (width * height * 3) / 2; - cnt->imgs.motionsize = width * height; -- break; -+ break; - } - - /* Insert into linked list */ - dev->next = viddevs; - viddevs = dev; -- -+ - pthread_mutex_unlock(&vid_mutex); - } --#endif /* WITHOUT_V4L */ -+#endif /* !WITHOUT_V4L */ - - /* FIXME needed tuner device ?! */ - return fd_bktr; -@@ -1272,29 +1285,29 @@ int vid_next(struct context *cnt, unsign - - #ifndef WITHOUT_V4L - -- struct video_dev *dev; -+ struct video_dev *dev; - int width, height; - int dev_bktr = cnt->video_dev; - - /* NOTE: Since this is a capture, we need to use capture dimensions. */ - width = cnt->rotate_data.cap_width; - height = cnt->rotate_data.cap_height; -- -+ - pthread_mutex_lock(&vid_mutex); -- dev = viddevs; -+ dev = viddevs; -+ - while (dev) { - if (dev->fd_bktr == dev_bktr) - break; - dev = dev->next; - } -- -+ - pthread_mutex_unlock(&vid_mutex); - - if (dev == NULL) - return V4L_FATAL_ERROR; -- //return -1; - -- if (dev->owner != cnt->threadnr) { -+ if (dev->owner != cnt->threadnr) { - pthread_mutex_lock(&dev->mutex); - dev->owner = cnt->threadnr; - dev->frames = conf->roundrobin_frames; -@@ -1303,19 +1316,20 @@ int vid_next(struct context *cnt, unsign - - v4l_set_input(cnt, dev, map, width, height, conf->input, conf->norm, - conf->roundrobin_skip, conf->frequency); -- -+ - ret = v4l_next(dev, map, width, height); - -- if (--dev->frames <= 0) { -+ if (--dev->frames <= 0) { - dev->owner = -1; - dev->frames = 0; - pthread_mutex_unlock(&dev->mutex); - } -- -- /* rotate the image as specified */ -- if (cnt->rotate_data.degrees > 0) -+ -+ /* Rotate the image as specified */ -+ if (cnt->rotate_data.degrees > 0) - rotate_map(cnt, map); -- --#endif /*WITHOUT_V4L*/ -+ -+ -+#endif /* !WITHOUT_V4L */ - return ret; - } ---- motion-3.2.12.orig/video_freebsd.h -+++ motion-3.2.12/video_freebsd.h -@@ -1,9 +1,10 @@ --/* video_freebsd.h -+/* -+ * video_freebsd.h - * - * Include file for video_freebsd.c -- * Copyright 2004 by Angel Carpintero (ack@telefonica.net) -- * This software is distributed under the GNU public license version 2 -- * See also the file 'COPYING'. -+ * Copyright 2004 by Angel Carpintero (motiondevelop@gmail.com) -+ * This software is distributed under the GNU public license version 2 -+ * See also the file 'COPYING'. - * - */ - -@@ -24,13 +25,13 @@ - #include - #endif - --#endif -+#endif /* !WITHOUT_V4L */ - - /* bktr (video4linux) stuff FIXME more modes not only these */ - - /* not used yet FIXME ! only needed for tuner use */ - /* --#define TV_INPUT_NTSCM BT848_IFORM_F_NTSCM -+#define TV_INPUT_NTSCM BT848_IFORM_F_NTSCM - #define TV_INPUT_NTSCJ BT848_IFORM_F_NTSCJ - #define TV_INPUT_PALBDGHI BT848_IFORM_F_PALBDGHI - #define TV_INPUT_PALM BT848_IFORM_F_PALM -@@ -40,26 +41,26 @@ - */ - - /* video4linux error codes */ --#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ --#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ -+#define V4L_GENERAL_ERROR 0x01 /* binary 000001 */ -+#define V4L_BTTVLOST_ERROR 0x05 /* binary 000101 */ - #define V4L_FATAL_ERROR -1 - --#define NORM_DEFAULT 0x00800 /* METEOR_FMT_AUTOMODE */ --#define NORM_PAL 0x00200 /* METEOR_FMT_PAL */ --#define NORM_NTSC 0x00100 /* METEOR_FMT_NTSC */ --#define NORM_SECAM 0x00400 /* METEOR_FMT_SECAM */ --#define NORM_PAL_NC 0x00200 /* METEOR_FMT_PAL */ -+#define NORM_DEFAULT 0x00800 // METEOR_FMT_AUTOMODE -+#define NORM_PAL 0x00200 // METEOR_FMT_PAL -+#define NORM_NTSC 0x00100 // METEOR_FMT_NTSC -+#define NORM_SECAM 0x00400 // METEOR_FMT_SECAM -+#define NORM_PAL_NC 0x00200 // METEOR_FMT_PAL /* Greyscale howto ?! FIXME */ - --#define NORM_DEFAULT_NEW BT848_IFORM_F_AUTO --#define NORM_PAL_NEW BT848_IFORM_F_PALBDGHI -+#define NORM_DEFAULT_NEW BT848_IFORM_F_AUTO -+#define NORM_PAL_NEW BT848_IFORM_F_PALBDGHI - #define NORM_NTSC_NEW BT848_IFORM_F_NTSCM --#define NORM_SECAM_NEW BT848_IFORM_F_SECAM --#define NORM_PAL_NC_NEW BT848_IFORM_F_AUTO /* FIXME */ -+#define NORM_SECAM_NEW BT848_IFORM_F_SECAM -+#define NORM_PAL_NC_NEW BT848_IFORM_F_AUTO /* FIXME */ - - #define PAL 0 - #define NTSC 1 - #define SECAM 2 --#define PAL_NC 3 -+#define PAL_NC 3 - - #define PAL_HEIGHT 576 - #define SECAM_HEIGHT 576 -@@ -76,7 +77,7 @@ - #define BSD_VIDFMT_LAST 8 - - --#define IN_DEFAULT 0 -+#define IN_DEFAULT 0 - #define IN_COMPOSITE 0 - #define IN_TV 1 - #define IN_COMPOSITE2 2 -@@ -95,8 +96,8 @@ struct video_dev { - int fd_tuner; - const char *video_device; - const char *tuner_device; -- unsigned short input; -- unsigned short norm; -+ unsigned input; -+ unsigned norm; - int width; - int height; - int contrast; -@@ -111,10 +112,10 @@ struct video_dev { - pthread_mutexattr_t attr; - int owner; - int frames; -- -+ - /* Device type specific stuff: */ --#ifndef WITHOUT_V4L -- int capture_method; -+#ifndef WITHOUT_V4L -+ int capture_method; - int v4l_fmt; - unsigned char *v4l_buffers[2]; - int v4l_curbuffer; ---- /dev/null -+++ motion-3.2.12/vloopback_motion.c -@@ -0,0 +1,256 @@ -+/* -+ * vloopback_motion.c -+ * -+ * Video loopback functions for motion. -+ * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) -+ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) -+ * This software is distributed under the GNU public license version 2 -+ * See also the file 'COPYING'. -+ * -+ */ -+#include "vloopback_motion.h" -+#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) && (!defined(BSD)) -+#include -+#include -+ -+/** -+ * v4l_open_vidpipe -+ * -+ */ -+static int v4l_open_vidpipe(void) -+{ -+ int pipe_fd = -1; -+ char pipepath[255]; -+ char buffer[255]; -+ char *major; -+ char *minor; -+ struct utsname uts; -+ -+ if (uname(&uts) < 0) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to execute uname"); -+ return -1; -+ } -+ -+ major = strtok(uts.release, "."); -+ minor = strtok(NULL, "."); -+ -+ if ((major == NULL) || (minor == NULL) || (strcmp(major, "2"))) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to decipher OS version"); -+ return -1; -+ } -+ -+ if (strcmp(minor, "5") < 0) { -+ FILE *vloopbacks; -+ char *loop; -+ char *input; -+ char *istatus; -+ char *output; -+ char *ostatus; -+ -+ vloopbacks = fopen("/proc/video/vloopback/vloopbacks", "r"); -+ -+ if (!vloopbacks) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed to open " -+ "'/proc/video/vloopback/vloopbacks'"); -+ return -1; -+ } -+ -+ /* Read vloopback version*/ -+ if (!fgets(buffer, sizeof(buffer), vloopbacks)) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to read vloopback version"); -+ myfclose(vloopbacks); -+ return -1; -+ } -+ -+ fprintf(stderr, "\t%s", buffer); -+ -+ /* Read explanation line */ -+ -+ if (!fgets(buffer, sizeof(buffer), vloopbacks)) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to read vloopback" -+ " explanation line"); -+ myfclose(vloopbacks); -+ return -1; -+ } -+ -+ while (fgets(buffer, sizeof(buffer), vloopbacks)) { -+ if (strlen(buffer) > 1) { -+ buffer[strlen(buffer)-1] = 0; -+ loop = strtok(buffer, "\t"); -+ input = strtok(NULL, "\t"); -+ istatus = strtok(NULL, "\t"); -+ output = strtok(NULL, "\t"); -+ ostatus = strtok(NULL, "\t"); -+ -+ if (istatus[0] == '-') { -+ snprintf(pipepath, sizeof(pipepath), "/dev/%s", input); -+ pipe_fd = open(pipepath, O_RDWR); -+ -+ if (pipe_fd >= 0) { -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \tInput: /dev/%s " -+ "\tOutput: /dev/%s", input, output); -+ break; -+ } -+ } -+ } -+ } -+ -+ myfclose(vloopbacks); -+ } else { -+ DIR *dir; -+ struct dirent *dirp; -+ const char prefix[] = "/sys/class/video4linux/"; -+ char *ptr, *io; -+ int fd; -+ int low = 9999; -+ int tfd; -+ int tnum; -+ -+ if ((dir = opendir(prefix)) == NULL) { -+ MOTION_LOG(CRT, TYPE_VIDEO, SHOW_ERRNO, "%s: Failed to open '%s'", -+ prefix); -+ return -1; -+ } -+ -+ while ((dirp = readdir(dir)) != NULL) { -+ if (!strncmp(dirp->d_name, "video", 5)) { -+ strncpy(buffer, prefix, sizeof(buffer)); -+ strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); -+ strncat(buffer, "/name", sizeof(buffer) - strlen(buffer)); -+ -+ if ((fd = open(buffer, O_RDONLY)) >= 0) { -+ if ((read(fd, buffer, sizeof(buffer)-1)) < 0) { -+ close(fd); -+ continue; -+ } -+ -+ ptr = strtok(buffer, " "); -+ -+ if (strcmp(ptr, "Video")) { -+ close(fd); -+ continue; -+ } -+ -+ major = strtok(NULL, " "); -+ minor = strtok(NULL, " "); -+ io = strtok(NULL, " \n"); -+ -+ if (strcmp(major, "loopback") || strcmp(io, "input")) { -+ close(fd); -+ continue; -+ } -+ -+ if ((ptr = strtok(buffer, " ")) == NULL) { -+ close(fd); -+ continue; -+ } -+ -+ tnum = atoi(minor); -+ -+ if (tnum < low) { -+ mystrcpy(buffer, "/dev/"); -+ strncat(buffer, dirp->d_name, sizeof(buffer) - strlen(buffer)); -+ if ((tfd = open(buffer, O_RDWR)) >= 0) { -+ strncpy(pipepath, buffer, sizeof(pipepath)); -+ -+ if (pipe_fd >= 0) -+ close(pipe_fd); -+ -+ pipe_fd = tfd; -+ low = tnum; -+ } -+ } -+ close(fd); -+ } -+ } -+ } -+ -+ closedir(dir); -+ -+ if (pipe_fd >= 0) -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Opened %s as input", -+ pipepath); -+ } -+ -+ return pipe_fd; -+} -+ -+/** -+ * v4l_startpipe -+ * -+ */ -+static int v4l_startpipe(const char *dev_name, int width, int height, int type) -+{ -+ int dev; -+ struct video_picture vid_pic; -+ struct video_window vid_win; -+ -+ if (!strcmp(dev_name, "-")) { -+ dev = v4l_open_vidpipe(); -+ } else { -+ dev = open(dev_name, O_RDWR); -+ MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Opened %s as input", -+ dev_name); -+ } -+ -+ if (dev < 0) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Opening %s as input failed", -+ dev_name); -+ return -1; -+ } -+ -+ if (ioctl(dev, VIDIOCGPICT, &vid_pic) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGPICT)"); -+ return -1; -+ } -+ -+ vid_pic.palette = type; -+ -+ if (ioctl(dev, VIDIOCSPICT, &vid_pic) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSPICT)"); -+ return -1; -+ } -+ -+ if (ioctl(dev, VIDIOCGWIN, &vid_win) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCGWIN)"); -+ return -1; -+ } -+ -+ vid_win.height = height; -+ vid_win.width = width; -+ -+ if (ioctl(dev, VIDIOCSWIN, &vid_win) == -1) { -+ MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: ioctl (VIDIOCSWIN)"); -+ return -1; -+ } -+ -+ return dev; -+} -+ -+/** -+ * v4l_putpipe -+ * -+ */ -+static int v4l_putpipe(int dev, unsigned char *image, int size) -+{ -+ return write(dev, image, size); -+} -+ -+/** -+ * vid_startpipe -+ * -+ */ -+int vid_startpipe(const char *dev_name, int width, int height, int type) -+{ -+ return v4l_startpipe(dev_name, width, height, type); -+} -+ -+/** -+ * vid_putpipe -+ * -+ */ -+int vid_putpipe (int dev, unsigned char *image, int size) -+{ -+ return v4l_putpipe(dev, image, size); -+} -+#endif /* !WITHOUT_V4L && !BSD */ ---- /dev/null -+++ motion-3.2.12/vloopback_motion.h -@@ -0,0 +1,17 @@ -+/* vloopback_motion.h -+ * -+ * Include file for vloopback_motion.c -+ * Copyright 2000 by Jeroen Vreeken (pe1rxq@amsat.org) -+ * Copyright 2008 by Angel Carpintero (motiondevelop@gmail.com) -+ * This software is distributed under the GNU public license version 2 -+ * See also the file 'COPYING'. -+ * -+ */ -+#ifndef _INCLUDE_VLOOPBACK_MOTION_H -+#define _INCLUDE_VLOOPBACK_MOTION_H -+ -+#include "motion.h" -+ -+int vid_startpipe(const char *dev_name, int width, int height, int); -+int vid_putpipe(int dev, unsigned char *image, int); -+#endif ---- motion-3.2.12.orig/webhttpd.c -+++ motion-3.2.12/webhttpd.c -@@ -3,9 +3,9 @@ - * - * HTTP Control interface for motion. - * -- * Specs : http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpAPI -+ * Specs : http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpAPI - * -- * Copyright 2004-2005 by Angel Carpintero (ack@telefonica.net) -+ * Copyright 2004-2005 by Angel Carpintero (motiondevelop@gmail.com) - * This software is distributed under the GNU Public License Version 2 - * See also the file 'COPYING'. - * -@@ -18,25 +18,26 @@ - - pthread_mutex_t httpd_mutex; - --int warningkill; // This is a dummy variable use to kill warnings when not checking sscanf and similar functions -+// This is a dummy variable use to kill warnings when not checking sscanf and similar functions -+int warningkill; - --static const char* ini_template = -+static const char *ini_template = - "Motion "VERSION"\n" - "\n"; - - static const char *set_template = - "\nMotion "VERSION"\n" - "\n"; - --static const char* end_template = -+static const char *end_template = - "\n" - "\n"; - --static const char* ok_response = -+static const char *ok_response = - "HTTP/1.1 200 OK\r\n" - "Server: Motion-httpd/"VERSION"\r\n" - "Connection: close\r\n" -@@ -47,7 +48,7 @@ static const char* ok_response = - "Pragma: no-cache\r\n" - "Content-type: text/html\r\n\r\n"; - --static const char* ok_response_raw = -+static const char *ok_response_raw = - "HTTP/1.1 200 OK\r\n" - "Server: Motion-httpd/"VERSION"\r\n" - "Connection: close\r\n" -@@ -58,8 +59,7 @@ static const char* ok_response_raw = - "Pragma: no-cache\r\n" - "Content-type: text/plain\r\n\r\n"; - -- --static const char* bad_request_response = -+static const char *bad_request_response = - "HTTP/1.0 400 Bad Request\r\n" - "Content-type: text/html\r\n\r\n" - "\n" -@@ -69,12 +69,12 @@ static const char* bad_request_response - "\n" - "\n"; - --static const char* bad_request_response_raw = -+static const char *bad_request_response_raw = - "HTTP/1.0 400 Bad Request\r\n" - "Content-type: text/plain\r\n\r\n" - "Bad Request"; - --static const char* not_found_response_template = -+static const char *not_found_response_template = - "HTTP/1.0 404 Not Found\r\n" - "Content-type: text/html\r\n\r\n" - "\n" -@@ -84,12 +84,12 @@ static const char* not_found_response_te - "\n" - "\n"; - --static const char* not_found_response_template_raw = -+static const char *not_found_response_template_raw = - "HTTP/1.0 404 Not Found\r\n" - "Content-type: text/plain\r\n\r\n" - "Not Found"; - --static const char* not_found_response_valid = -+static const char *not_found_response_valid = - "HTTP/1.0 404 Not Valid\r\n" - "Content-type: text/html\r\n\r\n" - "\n" -@@ -99,12 +99,12 @@ static const char* not_found_response_va - "\n" - "\n"; - --static const char* not_found_response_valid_raw = -+static const char *not_found_response_valid_raw = - "HTTP/1.0 404 Not Valid\r\n" - "Content-type: text/plain\r\n\r\n" - "The requested URL is not valid."; - --static const char* not_valid_syntax = -+static const char *not_valid_syntax = - "HTTP/1.0 404 Not Valid Syntax\r\n" - "Content-type: text/html\r\n\r\n" - "\n" -@@ -113,48 +113,48 @@ static const char* not_valid_syntax = - "\n" - "\n"; - --static const char* not_valid_syntax_raw = -+static const char *not_valid_syntax_raw = - "HTTP/1.0 404 Not Valid Syntax\r\n" - "Content-type: text/plain\r\n\r\n" - "Not Valid Syntax\n"; - --static const char* not_track = -+static const char *not_track = - "HTTP/1.0 200 OK\r\n" - "Content-type: text/html\r\n\r\n" - "\n" - "\n" - "

                                                              Tracking Not Enabled

                                                              \n"; - --static const char* not_track_raw = -+static const char *not_track_raw = - "HTTP/1.0 200 OK\r\n" - "Content-type: text/plain\r\n\r\n" - "Tracking Not Enabled"; - --static const char* track_error = -+static const char *track_error = - "HTTP/1.0 200 OK\r\n" - "Content-type: text/html\r\n\r\n" - "\n" - "\n" - "

                                                              Track Error

                                                              \n"; - --static const char* track_error_raw = -+static const char *track_error_raw = - "HTTP/1.0 200 OK\r\n" - "Content-type: text/plain\r\n\r\n" - "Track Error"; - --static const char* error_value = -+static const char *error_value = - "HTTP/1.0 200 OK\r\n" - "Content-type: text/html\r\n\r\n" - "\n" - "\n" - "

                                                              Value Error

                                                              \n"; - --static const char* error_value_raw = -+static const char *error_value_raw = - "HTTP/1.0 200 OK\r\n" - "Content-type: text/plain\r\n\r\n" - "Value Error"; -- --static const char* not_found_response_valid_command = -+ -+static const char *not_found_response_valid_command = - "HTTP/1.0 404 Not Valid Command\r\n" - "Content-type: text/html\r\n\r\n" - "\n" -@@ -164,12 +164,12 @@ static const char* not_found_response_va - "\n" - "\n"; - --static const char* not_found_response_valid_command_raw = -+static const char *not_found_response_valid_command_raw = - "HTTP/1.0 404 Not Valid Command\r\n" - "Content-type: text/plain\n\n" - "Not Valid Command\n"; - --static const char* bad_method_response_template = -+static const char *bad_method_response_template = - "HTTP/1.0 501 Method Not Implemented\r\n" - "Content-type: text/html\r\n\r\n" - "\n" -@@ -179,7 +179,7 @@ static const char* bad_method_response_t - "\n" - "\n"; - --static const char* bad_method_response_template_raw = -+static const char *bad_method_response_template_raw = - "HTTP/1.0 501 Method Not Implemented\r\n" - "Content-type: text/plain\r\n\r\n" - "Method Not Implemented\n"; -@@ -188,54 +188,134 @@ static const char *request_auth_response - "HTTP/1.0 401 Authorization Required\r\n" - "WWW-Authenticate: Basic realm=\"Motion Security Access\"\r\n"; - --static void send_template_ini_client(int client_socket, const char* template) -+/** -+ * write_nonblock -+ */ -+static ssize_t write_nonblock(int fd, const void *buf, size_t size) -+{ -+ ssize_t nwrite = -1; -+ struct timeval tm; -+ fd_set fds; -+ -+ tm.tv_sec = 1; /* Timeout in seconds */ -+ tm.tv_usec = 0; -+ FD_ZERO(&fds); -+ FD_SET(fd, &fds); -+ -+ if (select(fd + 1, NULL, &fds, NULL, &tm) > 0) { -+ if (FD_ISSET(fd, &fds)) { -+ if ((nwrite = write(fd , buf, size)) < 0) { -+ if (errno != EWOULDBLOCK) -+ return -1; -+ } -+ } -+ } -+ -+ return nwrite; -+} -+ -+/** -+ * read_nonblock -+ */ -+static ssize_t read_nonblock(int fd ,void *buf, ssize_t size) -+{ -+ ssize_t nread = -1; -+ struct timeval tm; -+ fd_set fds; -+ -+ tm.tv_sec = 1; /* Timeout in seconds */ -+ tm.tv_usec = 0; -+ FD_ZERO(&fds); -+ FD_SET(fd, &fds); -+ -+ if (select(fd + 1, &fds, NULL, NULL, &tm) > 0) { -+ if (FD_ISSET(fd, &fds)) { -+ if ((nread = read(fd , buf, size)) < 0) { -+ if (errno != EWOULDBLOCK) -+ return -1; -+ } -+ } -+ } -+ -+ return nread; -+} -+ -+/** -+ * send_template_ini_client -+ */ -+static void send_template_ini_client(int client_socket, const char *template) - { - ssize_t nwrite = 0; -- nwrite = write(client_socket, ok_response, strlen (ok_response)); -- nwrite += write(client_socket, template, strlen(template)); -+ nwrite = write_nonblock(client_socket, ok_response, strlen(ok_response)); -+ nwrite += write_nonblock(client_socket, template, strlen(template)); - if (nwrite != (ssize_t)(strlen(ok_response) + strlen(template))) -- motion_log(LOG_ERR, 1, "httpd send_template_ini_client"); -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: failure write"); - } - -+/** -+ * send_template_ini_client_raw -+ */ - static void send_template_ini_client_raw(int client_socket) - { - ssize_t nwrite = 0; -- nwrite = write(client_socket, ok_response_raw, strlen (ok_response_raw)); -+ nwrite = write_nonblock(client_socket, ok_response_raw, strlen(ok_response_raw)); - if (nwrite != (ssize_t)strlen(ok_response_raw)) -- motion_log(LOG_ERR, 1, "httpd send_template_ini_client_raw"); -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: failure write"); - } - -+/** -+ * send_template -+ */ - static void send_template(int client_socket, char *res) - { - ssize_t nwrite = 0; -- nwrite = write(client_socket, res, strlen(res)); -+ nwrite = write_nonblock(client_socket, res, strlen(res)); - if (nwrite != (ssize_t)strlen(res)) -- motion_log(LOG_ERR, 1, "httpd send_template failure write"); -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: failure write"); - } - -+/** -+ * send_template_raw -+ */ - static void send_template_raw(int client_socket, char *res) - { - ssize_t nwrite = 0; -- nwrite = write(client_socket, res, strlen(res)); -+ nwrite = write_nonblock(client_socket, res, strlen(res)); -+ if (nwrite < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); - } - -+/** -+ * send_template_end_client -+ */ - static void send_template_end_client(int client_socket) - { - ssize_t nwrite = 0; -- nwrite = write(client_socket, end_template, strlen(end_template)); -+ nwrite = write_nonblock(client_socket, end_template, strlen(end_template)); -+ if (nwrite < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); -+ - } - --static void response_client(int client_socket, const char* template, char *back) -+/** -+ * response_client -+ */ -+static void response_client(int client_socket, const char *template, char *back) - { - ssize_t nwrite = 0; -- nwrite = write(client_socket, template, strlen(template)); -+ nwrite = write_nonblock(client_socket, template, strlen(template)); - if (back != NULL) { - send_template(client_socket, back); - send_template_end_client(client_socket); - } --} -+ if (nwrite < 0) -+ MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write_nonblock returned value less than zero."); - -+} - -+/** -+ * replace -+ */ - static char *replace(const char *str, const char *old, const char *new) - { - char *ret, *r; -@@ -248,11 +328,10 @@ static char *replace(const char *str, co - count++; - /* this is undefined if p - str > PTRDIFF_MAX */ - retlen = p - str + strlen(p) + count * (newlen - oldlen); -- } else { -+ } else - retlen = strlen(str); -- } - -- ret = malloc(retlen + 1); -+ ret = mymalloc(retlen + 1); - - for (r = ret, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen) { - /* this is undefined if q - p > PTRDIFF_MAX */ -@@ -265,16 +344,18 @@ static char *replace(const char *str, co - strcpy(r, p); - - return ret; --} -- --/* -- This function decode the values from GET request following the http RFC. --*/ -+} - -+/** -+ * url_decode -+ * This function decode the values from GET request following the http RFC. -+ * -+ * Returns nothing. -+ */ - static void url_decode(char *urlencoded, size_t length) - { -- char *data=urlencoded; -- char *urldecoded=urlencoded; -+ char *data = urlencoded; -+ char *urldecoded = urlencoded; - - while (length > 0) { - if (*data == '%') { -@@ -286,19 +367,23 @@ static void url_decode(char *urlencoded, - length--; - c[1] = *data; - c[2] = 0; -+ - warningkill = sscanf(c, "%x", &i); -- if (i < 128) -+ -+ if (i < 128) { - *urldecoded++ = (char)i; -- else { -+ } else { - *urldecoded++ = '%'; - *urldecoded++ = c[0]; - *urldecoded++ = c[1]; - } -- } else if (*data=='+') { -- *urldecoded++=' '; -+ -+ } else if (*data == '<' || *data == '+' || *data == '>') { -+ *urldecoded++ = ' '; - } else { -- *urldecoded++=*data; -+ *urldecoded++ = *data; - } -+ - data++; - length--; - } -@@ -306,61 +391,62 @@ static void url_decode(char *urlencoded, - } - - --/* -- This function manages/parses the config action for motion ( set , get , write , list ). -- -- return 1 to exit from function. --*/ -- --static unsigned short int config(char *pointer, char *res, unsigned short int length_uri, -- unsigned short int thread, int client_socket, void *userdata) -+/** -+ * config -+ * Manages/parses the config action for motion ( set , get , write , list ). -+ * -+ * Returns 1 to exit from function. -+ */ -+static unsigned int config(char *pointer, char *res, unsigned int length_uri, -+ unsigned int thread, int client_socket, void *userdata) - { -- char question = '\0'; -+ char question='\0'; - char command[256] = {'\0'}; -- unsigned short int i; -+ unsigned int i; - struct context **cnt = userdata; - -- warningkill = sscanf (pointer, "%255[a-z]%c", command , &question); -- if (!strcmp(command,"list")) { -+ warningkill = sscanf(pointer, "%255[a-z]%c", command , &question); -+ if (!strcmp(command, "list")) { - pointer = pointer + 4; - length_uri = length_uri - 4; - if (length_uri == 0) { - const char *value = NULL; - char *retval = NULL; - /*call list*/ -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); -- sprintf(res, "<– back

                                                              \nThread %hu\n
                                                                ", thread, thread); -+ sprintf(res, "<– back

                                                                \nThread %hu\n
                                                                  ", -+ thread, thread); - send_template(client_socket, res); - -- for (i = 0; config_params[i].param_name != NULL; i++) { -+ for (i=0; config_params[i].param_name != NULL; i++) { - -- if ((thread != 0) && (config_params[i].main_thread)) -+ if ((thread != 0) && (config_params[i].main_thread)) - continue; - - value = config_params[i].print(cnt, NULL, i, thread); - - if (value == NULL) { -- retval=NULL; -- -- /* Only get the thread value for main thread */ -+ retval = NULL; -+ -+ /* Only get the thread value for main thread */ - if (thread == 0) - config_params[i].print(cnt, &retval, i, thread); -- -+ - /* thread value*/ -- -+ - if (retval) { -- -+ - if (!strcmp(retval,"")) { - free(retval); -- retval = strdup("No threads"); -+ retval = mystrdup("No threads"); - } else { -- char *temp=retval; -+ char *temp = retval; - size_t retval_miss = 0; - size_t retval_len = strlen(retval); -- unsigned short int ind=0; -- char thread_strings[1024]={'\0'}; -- -+ unsigned int ind = 0; -+ char thread_strings[1024] = {'\0'}; -+ - while (retval_miss != retval_len) { - while (*temp != '\n') { - thread_strings[ind++] = *temp; -@@ -376,16 +462,16 @@ static unsigned short int config(char *p - } - free(retval); - retval = NULL; -- retval = strdup(thread_strings); -+ retval = mystrdup(thread_strings); - } -- -+ - sprintf(res, "
                                                                • %s = %s
                                                                • \n", thread, - config_params[i].param_name, config_params[i].param_name, retval); - free(retval); - } else if (thread != 0) { - /* get the value from main thread for the rest of threads */ - value = config_params[i].print(cnt, NULL, i, 0); -- -+ - sprintf(res, "
                                                                • %s = %s
                                                                • \n", thread, - config_params[i].param_name, config_params[i].param_name, - value ? value : "(not defined)"); -@@ -394,35 +480,35 @@ static unsigned short int config(char *p - config_params[i].param_name, config_params[i].param_name, - "(not defined)"); - } -- -+ - } else { -- sprintf(res, "
                                                                • %s = %s
                                                                • \n",thread, -+ sprintf(res, "
                                                                • %s = %s
                                                                • \n", thread, - config_params[i].param_name, config_params[i].param_name, value); - } - send_template(client_socket, res); - } - -- sprintf(res, "
                                                                <– back",thread); -+ sprintf(res, "
                                                              <– back", thread); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); - for (i=0; config_params[i].param_name != NULL; i++) { -- value=config_params[i].print(cnt, NULL, i, thread); -+ value = config_params[i].print(cnt, NULL, i, thread); - if (value == NULL) -- value=config_params[i].print(cnt, NULL, i, 0); -+ value = config_params[i].print(cnt, NULL, i, 0); - sprintf(res, "%s = %s\n", config_params[i].param_name, value); - send_template_raw(client_socket, res); - } - } - } else { - /*error*/ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"set")) { -+ } else if (!strcmp(command, "set")) { - /* set?param_name=value */ - pointer = pointer + 3; - length_uri = length_uri - 3; -@@ -431,13 +517,13 @@ static unsigned short int config(char *p - length_uri--; - warningkill = sscanf(pointer,"%255[-0-9a-z_]%c", command, &question); - /*check command , question == '=' length_uri too*/ -- if ((question == '=') && (command[0]!='\0')) { -+ if ((question == '=') && (command[0] != '\0')) { - length_uri = length_uri - strlen(command) - 1; - pointer = pointer + strlen(command) + 1; - /* check if command exists and type of command and not end of URI */ -- i = 0; -+ i=0; - while (config_params[i].param_name != NULL) { -- if ((thread != 0) && (config_params[i].main_thread)){ -+ if ((thread != 0) && (config_params[i].main_thread)) { - i++; - continue; - } -@@ -449,24 +535,24 @@ static unsigned short int config(char *p - - if (config_params[i].param_name) { - if (length_uri > 0) { -- char Value[1024]={'\0'}; -+ char Value[1024] = {'\0'}; - warningkill = sscanf(pointer,"%1023s", Value); - length_uri = length_uri - strlen(Value); -- if ((length_uri == 0) && (strlen(Value) > 0) ) { -+ if ((length_uri == 0) && (strlen(Value) > 0)) { - /* FIXME need to assure that is a valid value */ -- url_decode(Value,strlen(Value)); -+ url_decode(Value, strlen(Value)); - conf_cmdparse(cnt + thread, config_params[i].param_name, Value); -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, - "<– back" - "

                                                              \nThread %hu\n" - "
                                                              • %s = %s" - "
                                                              Done", -- thread, thread, thread,config_params[i].param_name, -+ thread, thread, thread, config_params[i].param_name, - config_params[i].param_name, Value); -- -+ - send_template_ini_client(client_socket, ini_template); -- send_template(client_socket,res); -+ send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -@@ -475,50 +561,46 @@ static unsigned short int config(char *p - } - } else { - /*error*/ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - } - } else { - char *type = NULL; -- type = strdup(config_type(&config_params[i])); -+ type = mystrdup(config_type(&config_params[i])); - -- if (!strcmp(type,"string")) { -+ if (!strcmp(type, "string")) { - char *value = NULL; - conf_cmdparse(cnt+thread, config_params[i].param_name, value); - free(type); -- type = strdup("(null)"); -- } else if (!strcmp(type,"int")) { -- free(type); -- type = strdup("0"); -- conf_cmdparse(cnt+thread, config_params[i].param_name, type); -- } else if (!strcmp(type,"short")) { -+ type = mystrdup("(null)"); -+ } else if (!strcmp(type, "int")) { - free(type); -- type = strdup("0"); -+ type = mystrdup("0"); - conf_cmdparse(cnt+thread, config_params[i].param_name, type); -- } else if (!strcmp(type,"bool")) { -+ } else if (!strcmp(type, "bool")) { - free(type); -- type = strdup("off"); -+ type = mystrdup("off"); - conf_cmdparse(cnt+thread, config_params[i].param_name, type); - } else { - free(type); -- type = strdup("unknown"); -+ type = mystrdup("unknown"); - } - -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, - "<– back

                                                              \n" -- "Thread %hu\n
                                                              • %s" -- "= %s

                                                              Done", thread, thread, thread, -+ "Thread %hu\n
                                                              • %s" -+ "= %s

                                                              Done", thread, thread, thread, - config_params[i].param_name, config_params[i].param_name, type); -- -+ - send_template_ini_client(client_socket, ini_template); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -- sprintf(res, "%s = %s\nDone\n", config_params[i].param_name,type); -+ sprintf(res, "%s = %s\nDone\n", config_params[i].param_name, type); - send_template_raw(client_socket, res); - } - free(type); -@@ -526,18 +608,18 @@ static unsigned short int config(char *p - } - } else { - /*error*/ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } else { - /* Show param_name dialogue only for html output */ -- if ((cnt[0]->conf.control_html_output) && (command[0]!='\0') && -- (((length_uri = length_uri - strlen(command)) == 0 )) ) { -- i = 0; -+ if ((cnt[0]->conf.webcontrol_html_output) && (command[0] != '\0') && -+ (((length_uri = length_uri - strlen(command)) == 0))) { -+ i=0; - while (config_params[i].param_name != NULL) { -- if ((thread != 0) && (config_params[i].main_thread)){ -+ if ((thread != 0) && (config_params[i].main_thread)) { - i++; - continue; - } -@@ -548,10 +630,10 @@ static unsigned short int config(char *p - } - /* param_name exists */ - if (config_params[i].param_name) { -- const char *value = NULL; -+ const char *value = NULL; - char *text_help = NULL; - char *sharp = NULL; -- -+ - value = config_params[i].print(cnt, NULL, i, thread); - - sharp = strstr(config_params[i].param_help, "#\n\n#"); -@@ -560,21 +642,21 @@ static unsigned short int config(char *p - sharp++; - - text_help = replace(sharp, "\n#", "
                                                              "); -- -+ - send_template_ini_client(client_socket, ini_template); -- if (!strcmp ("bool",config_type(&config_params[i])) ){ -+ if (!strcmp ("bool", config_type(&config_params[i]))) { - char option[80] = {'\0'}; -- -+ - if ((value == NULL) && (thread != 0)) - value = config_params[i].print(cnt, NULL, i, 0); -- -+ - if (!strcmp ("on", value)) - sprintf(option, "\n" - "\n"); - else - sprintf(option, "\n" - "\n"); -- -+ - sprintf(res, "<– back

                                                              \n" - "Thread %hu\n" - "
                                                              \n" -@@ -585,50 +667,50 @@ static unsigned short int config(char *p - "[help]" - "
                                                              \n
                                                              %s", thread, thread, - config_params[i].param_name, config_params[i].param_name, -- option, FOSWIKI_URL,config_params[i].param_name, text_help); -+ option, TWIKI_URL, config_params[i].param_name, text_help); - } else { -- -- if (value == NULL){ -+ -+ if (value == NULL) { - if (thread != 0) - /* get the value from main thread for the rest of threads */ -- value = config_params[i].print(cnt, NULL, i, 0); -+ value = config_params[i].print(cnt, NULL, i, 0); - if (value == NULL) value = ""; - } - sprintf(res, "<– back

                                                              \n" - "Thread %hu\n
                                                              \n" -- "%s \n" -+ "%s \n" - "\n" - "    " - "[help]" - "
                                                              \n
                                                              %s", thread, thread, - config_params[i].param_name, config_params[i].param_name, -- value, FOSWIKI_URL, config_params[i].param_name, text_help); -+ value, TWIKI_URL, config_params[i].param_name, text_help); - } - - send_template(client_socket, res); - send_template_end_client(client_socket); - free(text_help); - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } - } else if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, set_template); - sprintf(res, "<– back

                                                              \nThread %hu\n" -- "
                                                              \n\n", thread, thread); - - send_template(client_socket, res); -- for (i = 0; config_params[i].param_name != NULL; i++) { -+ for (i=0; config_params[i].param_name != NULL; i++) { - if ((thread != 0) && (config_params[i].main_thread)) - continue; - sprintf(res, "\n", -@@ -650,12 +732,12 @@ static unsigned short int config(char *p - } - } else { - /*error*/ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"get")) { -+ } else if (!strcmp(command, "get")) { - /* get?query=param_name */ - pointer = pointer + 3; - length_uri = length_uri - 3; -@@ -666,18 +748,18 @@ static unsigned short int config(char *p - length_uri--; - warningkill = sscanf(pointer,"%255[-0-9a-z]%c", command, &question); - -- if ((question == '=') && (!strcmp(command,"query")) ) { -+ if ((question == '=') && (!strcmp(command, "query"))) { - pointer = pointer + 6; - length_uri = length_uri - 6; - warningkill = sscanf(pointer, "%255[-0-9a-z_]", command); - /*check if command exist, length_uri too*/ -- length_uri = length_uri-strlen(command); -+ length_uri = length_uri - strlen(command); - - if (length_uri == 0) { - const char *value = NULL; - i = 0; - while (config_params[i].param_name != NULL) { -- if ((thread != 0) && (config_params[i].main_thread)){ -+ if ((thread != 0) && (config_params[i].main_thread)) { - i++; - continue; - } -@@ -686,15 +768,16 @@ static unsigned short int config(char *p - break; - i++; - } -- /* FIXME bool values or commented values maybe that should be -- solved with config_type */ -- -+ /* -+ * FIXME bool values or commented values maybe that should be -+ * solved with config_type -+ */ - if (config_params[i].param_name) { -- const char *type=NULL; -+ const char *type = NULL; - type = config_type(&config_params[i]); -- if (!strcmp(type,"unknown")) { -- /*error doesn't exists this param_name */ -- if (cnt[0]->conf.control_html_output) -+ if (!strcmp(type, "unknown")) { -+ /* error doesn't exists this param_name */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -713,16 +796,15 @@ static unsigned short int config(char *p - text_help = replace(sharp, "\n#", "
                                                              "); - - if (value == NULL) -- value=config_params[i].print(cnt, NULL, i, 0); -- -- if (cnt[0]->conf.control_html_output) { -- send_template_ini_client(client_socket,ini_template); -+ value = config_params[i].print(cnt, NULL, i, 0); -+ if (cnt[0]->conf.webcontrol_html_output) { -+ send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                              \n" - "Thread %hu
                                                              \n
                                                              %s", -- thread, thread, config_params[i].param_name, value, -- FOSWIKI_URL, config_params[i].param_name, text_help); -+ "[help]

                                                            %s", -+ thread, thread, config_params[i].param_name, value, -+ TWIKI_URL, config_params[i].param_name, text_help); - - send_template(client_socket, res); - send_template_end_client(client_socket); -@@ -730,41 +812,39 @@ static unsigned short int config(char *p - free(text_help); - } else { - send_template_ini_client_raw(client_socket); -- sprintf(res, "%s = %s\nDone\n", config_params[i].param_name,value); -+ sprintf(res, "%s = %s\nDone\n", config_params[i].param_name, value); - send_template_raw(client_socket, res); - } - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } - } else if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); -- sprintf(res, "<– back

                                                            \nThread %hu
                                                            \n" -+ sprintf(res, "<– back

                                                            \nThread %hu
                                                            \n" - "\n" - "\n" - "\n" - "\n"); -@@ -776,17 +856,17 @@ static unsigned short int config(char *p - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - } -- } else if (!strcmp(command,"write")) { -+ } else if (!strcmp(command, "write")) { - pointer = pointer + 5; - length_uri = length_uri - 5; - if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Are you sure? Yes\n", thread, thread); -@@ -799,8 +879,8 @@ static unsigned short int config(char *p - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -811,7 +891,7 @@ static unsigned short int config(char *p - length_uri = length_uri - 8; - if (length_uri == 0) { - conf_print(cnt); -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \nThread %hu write done !\n", - thread, thread); -@@ -823,16 +903,16 @@ static unsigned short int config(char *p - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) { - response_client(client_socket, not_found_response_valid_command, NULL); -- } else { -+ } -+ else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -- } - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -842,27 +922,28 @@ static unsigned short int config(char *p - } - - --/* -- This function manages/parses the actions for motion ( makemovie , snapshot , restart , quit ). -- -- return 0 for restart & quit -- return 1 for makemovie & snaphost --*/ -- --static unsigned short int action(char *pointer, char *res, unsigned short int length_uri, -- unsigned short int thread, int client_socket, void *userdata) -+/** -+ * action -+ * manages/parses the actions for motion ( makemovie , snapshot , restart , quit ). -+ * -+ * Returns -+ * 0 for restart & quit -+ * 1 for makemovie & snaphost -+ */ -+static unsigned int action(char *pointer, char *res, unsigned int length_uri, -+ unsigned int thread, int client_socket, void *userdata) - { - /* parse action commands */ - char command[256] = {'\0'}; - struct context **cnt = userdata; -- unsigned short int i = 0; -+ unsigned int i = 0; - -- warningkill = sscanf (pointer, "%255[a-z]" , command); -- if (!strcmp(command,"makemovie")) { -+ warningkill = sscanf(pointer, "%255[a-z]" , command); -+ if (!strcmp(command, "makemovie")) { - pointer = pointer + 9; - length_uri = length_uri - 9; - if (length_uri == 0) { -- /*call makemovie*/ -+ /* call makemovie */ - - if (thread == 0) { - while (cnt[++i]) -@@ -871,7 +952,7 @@ static unsigned short int action(char *p - cnt[thread]->makemovie = 1; - } - -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "makemovie for thread %hu done
                                                            \n", thread, thread); -@@ -883,27 +964,27 @@ static unsigned short int action(char *p - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -- response_client(client_socket,not_found_response_valid_command,NULL); -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) -+ response_client(client_socket, not_found_response_valid_command, NULL); - else -- response_client(client_socket,not_found_response_valid_command_raw,NULL); -+ response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"snapshot")) { -+ } else if (!strcmp(command, "snapshot")) { - pointer = pointer + 8; - length_uri = length_uri - 8; - if (length_uri == 0) { -- /*call snapshot*/ -+ /* call snapshot */ - - if (thread == 0) { - while (cnt[++i]) -- cnt[i]->snapshot=1; -+ cnt[i]->snapshot = 1; - } else { -- cnt[thread]->snapshot=1; -+ cnt[thread]->snapshot = 1; - } - - cnt[thread]->snapshot = 1; -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "snapshot for thread %hu done
                                                            \n", thread, thread); -@@ -915,8 +996,8 @@ static unsigned short int action(char *p - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -925,12 +1006,12 @@ static unsigned short int action(char *p - pointer = pointer + 7; - length_uri = length_uri - 7; - if (length_uri == 0) { -- /*call restart*/ -+ /* call restart */ - - if (thread == 0) { -- motion_log(LOG_DEBUG, 0, "httpd restart"); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd is going to restart"); - kill(getpid(),SIGHUP); -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "restart in progress ... bye
                                                            \nHome"); - send_template(client_socket, res); -@@ -942,13 +1023,14 @@ static unsigned short int action(char *p - } - return 0; // to restart - } else { -- motion_log(LOG_DEBUG, 0, "httpd restart thread %d", thread); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd is going to restart thread %d", -+ thread); - if (cnt[thread]->running) { -- cnt[thread]->makemovie=1; -- cnt[thread]->finish=1; -+ cnt[thread]->makemovie = 1; -+ cnt[thread]->finish = 1; - } -- cnt[thread]->restart=1; -- if (cnt[0]->conf.control_html_output) { -+ cnt[thread]->restart = 1; -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "restart for thread %hu done
                                                            \n", thread, thread); -@@ -961,21 +1043,21 @@ static unsigned short int action(char *p - } - } - } else { -- if (cnt[0]->conf.control_html_output) -- response_client(client_socket,not_found_response_valid_command,NULL); -+ if (cnt[0]->conf.webcontrol_html_output) -+ response_client(client_socket, not_found_response_valid_command, NULL); - else -- response_client(client_socket,not_found_response_valid_command_raw,NULL); -+ response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"quit")) { -+ } else if (!strcmp(command, "quit")) { - pointer = pointer + 4; - length_uri = length_uri - 4; - if (length_uri == 0) { -- /*call quit*/ -+ /* call quit */ - - if (thread == 0) { -- motion_log(LOG_DEBUG, 0, "httpd quit"); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd quits"); - kill(getpid(),SIGQUIT); -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "quit in progress ... bye"); - send_template(client_socket, res); -@@ -986,14 +1068,14 @@ static unsigned short int action(char *p - send_template_raw(client_socket, res); - } - return 0; // to quit -- - } else { -- motion_log(LOG_DEBUG, 0, "httpd quit thread %d", thread); -- cnt[thread]->restart=0; -- cnt[thread]->makemovie=1; -- cnt[thread]->finish=1; -- cnt[thread]->watchdog=WATCHDOG_OFF; -- if (cnt[0]->conf.control_html_output) { -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: httpd quits thread %d", -+ thread); -+ cnt[thread]->restart = 0; -+ cnt[thread]->makemovie = 1; -+ cnt[thread]->finish = 1; -+ cnt[thread]->watchdog = WATCHDOG_OFF; -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "quit for thread %hu done
                                                            \n", thread, thread); -@@ -1006,14 +1088,14 @@ static unsigned short int action(char *p - } - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -1022,42 +1104,44 @@ static unsigned short int action(char *p - return 1; - } - --/* -- This function manages/parses the detection actions for motion ( status , start , pause ). -- -- return 1 to exit from function. --*/ -+/** -+ * detection -+ * manages/parses the detection actions for motion ( status , start , pause ). -+ * -+ * Returns -+ * 1 to exit from function. -+ */ - --static unsigned short int detection(char *pointer, char *res, unsigned short int length_uri, unsigned short int thread, -- int client_socket, void *userdata) -+static unsigned int detection(char *pointer, char *res, unsigned int length_uri, -+ unsigned int thread, int client_socket, void *userdata) - { -- char command[256]={'\0'}; -+ char command[256] = {'\0'}; - struct context **cnt = userdata; -- unsigned short int i = 0; -+ unsigned int i = 0; - -- warningkill = sscanf (pointer, "%255[a-z]" , command); -- if (!strcmp(command,"status")) { -+ warningkill = sscanf(pointer, "%255[a-z]" , command); -+ if (!strcmp(command, "status")) { - pointer = pointer + 6; - length_uri = length_uri - 6; - if (length_uri == 0) { -- /*call status*/ -- -- if (cnt[0]->conf.control_html_output) { -+ /* call status */ -+ -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); -- sprintf(res, "<– back

                                                            Thread %hu" -- " Detection status %s\n", thread, thread, -+ sprintf(res, "<– back

                                                            Thread %hu" -+ " Detection status %s\n", thread, thread, - (!cnt[thread]->running)? "NOT RUNNING": (cnt[thread]->pause)? "PAUSE":"ACTIVE"); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { -- sprintf(res, "Thread %hu Detection status %s\n",thread, -+ sprintf(res, "Thread %hu Detection status %s\n", thread, - (!cnt[thread]->running)? "NOT RUNNING": (cnt[thread]->pause)? "PAUSE":"ACTIVE"); - send_template_ini_client_raw(client_socket); - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -1066,7 +1150,7 @@ static unsigned short int detection(char - pointer = pointer + 5; - length_uri = length_uri - 5; - if (length_uri == 0) { -- /*call start*/ -+ /* call start */ - - if (thread == 0) { - do { -@@ -1076,9 +1160,9 @@ static unsigned short int detection(char - cnt[thread]->pause = 0; - } - -- if (cnt[0]->conf.control_html_output) { -- send_template_ini_client(client_socket,ini_template); -- sprintf(res, "<– back

                                                            \nThread %hu" -+ if (cnt[0]->conf.webcontrol_html_output) { -+ send_template_ini_client(client_socket, ini_template); -+ sprintf(res, "<– back

                                                            \nThread %hu" - " Detection resumed\n", thread, thread); - send_template(client_socket, res); - send_template_end_client(client_socket); -@@ -1088,17 +1172,17 @@ static unsigned short int detection(char - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"pause")){ -+ } else if (!strcmp(command, "pause")) { - pointer = pointer + 5; - length_uri = length_uri - 5; - if (length_uri == 0) { -- /*call pause*/ -+ /* call pause */ - - if (thread == 0) { - do { -@@ -1107,12 +1191,12 @@ static unsigned short int detection(char - } else { - cnt[thread]->pause = 1; - } -- -- if (cnt[0]->conf.control_html_output) { -+ -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); -- sprintf(res, "<– back

                                                            \nThread %hu" -+ sprintf(res, "<– back

                                                            \nThread %hu" - " Detection paused\n", thread, thread); -- send_template(client_socket,res); -+ send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -@@ -1120,62 +1204,62 @@ static unsigned short int detection(char - send_template_raw(client_socket, res); - } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"connection")){ -+ } else if (!strcmp(command, "connection")) { - pointer = pointer + 10; - length_uri = length_uri - 10; -+ - if (length_uri == 0) { -- -- /*call connection*/ -- if (cnt[0]->conf.control_html_output) { -+ /* call connection */ -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n", thread); -- send_template(client_socket,res); -+ send_template(client_socket, res); - if (thread == 0) { -- do { -- sprintf(res, "Thread %hu %s
                                                            \n",i, -- (!cnt[i]->running)? "NOT RUNNING" : -+ do{ -+ sprintf(res, "Thread %hu %s
                                                            \n", i, -+ (!cnt[i]->running)? "NOT RUNNING" : - (cnt[i]->lost_connection)?CONNECTION_KO:CONNECTION_OK); -- send_template(client_socket,res); -+ send_template(client_socket, res); - } while (cnt[++i]); - } else { - sprintf(res, "Thread %hu %s\n", thread, -- (!cnt[thread]->running)? "NOT RUNNING" : -+ (!cnt[thread]->running)? "NOT RUNNING" : - (cnt[thread]->lost_connection)? CONNECTION_KO: CONNECTION_OK); -- send_template(client_socket,res); -- } -+ send_template(client_socket, res); -+ } - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -- if (thread == 0){ -+ if (thread == 0) { - do { - sprintf(res, "Thread %hu %s\n", i, -- (!cnt[i]->running)? "NOT RUNNING" : -+ (!cnt[i]->running)? "NOT RUNNING" : - (cnt[i]->lost_connection)? CONNECTION_KO: CONNECTION_OK); - send_template_raw(client_socket, res); - } while (cnt[++i]); -- } else { -+ } else { - sprintf(res, "Thread %hu %s\n", thread, -- (!cnt[thread]->running)? "NOT RUNNING" : -+ (!cnt[thread]->running)? "NOT RUNNING" : - (cnt[thread]->lost_connection)? CONNECTION_KO: CONNECTION_OK); - send_template_raw(client_socket, res); -- } -- -- } -+ } -+ -+ } - } else { -- /*error*/ -- if (cnt[0]->conf.control_html_output) -+ /* error */ -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -- } -+ } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -1185,25 +1269,29 @@ static unsigned short int detection(char - } - - --/* -- This function manages/parses the track action for motion ( set , pan , tilt , auto ). -- -- return 1 to exit from function. --*/ -- --static unsigned short int track(char *pointer, char *res, unsigned short int length_uri, unsigned short int thread, -- int client_socket, void *userdata) -+/** -+ * track -+ * manages/parses the track action for motion ( set , pan , tilt , auto ). -+ * -+ * Returns -+ * 1 to exit from function. -+ */ -+static unsigned int track(char *pointer, char *res, unsigned int length_uri, -+ unsigned int thread, int client_socket, void *userdata) - { -- char question = '\0'; -+ char question='\0'; - char command[256] = {'\0'}; - struct context **cnt = userdata; - - warningkill = sscanf(pointer, "%255[a-z]%c", command, &question); - if (!strcmp(command, "set")) { -- pointer=pointer+3;length_uri=length_uri-3; -- /* FIXME need to check each value */ -- /* Relative movement set?pan=0&tilt=0 | set?pan=0 | set?tilt=0*/ -- /* Absolute movement set?x=0&y=0 | set?x=0 | set?y=0 */ -+ pointer = pointer+3; -+ length_uri = length_uri-3; -+ /* -+ * FIXME need to check each value -+ * Relative movement set?pan=0&tilt=0 | set?pan=0 | set?tilt=0 -+ * Absolute movement set?x=0&y=0 | set?x=0 | set?y=0 -+ */ - - if ((question == '?') && (length_uri > 2)) { - char panvalue[12] = {'\0'}, tiltvalue[12] = {'\0'}; -@@ -1213,16 +1301,18 @@ static unsigned short int track(char *po - - pointer++; - length_uri--; -- /* set?pan=value&tilt=value */ -- /* set?x=value&y=value */ -- /* pan= or x= | tilt= or y= */ -+ /* -+ * set?pan=value&tilt=value -+ * set?x=value&y=value -+ * pan= or x= | tilt= or y= -+ */ - -- warningkill = sscanf (pointer, "%255[a-z]%c" , command, &question); -+ warningkill = sscanf(pointer, "%255[a-z]%c" , command, &question); - -- if (( question != '=' ) || (command[0] == '\0')) { -+ if ((question != '=') || (command[0] == '\0')) { - /* no valid syntax */ -- motion_log(LOG_WARNING, 0, "httpd debug race 1"); -- if (cnt[0]->conf.control_html_output) -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 1"); -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); -@@ -1238,7 +1328,7 @@ static unsigned short int track(char *po - pointer = pointer + 3; - length_uri = length_uri - 3; - pan = 1; -- if ((warningkill = sscanf(pointer, "%10[-0-9]", panvalue))){ -+ if ((warningkill = sscanf(pointer, "%10[-0-9]", panvalue))) { - pointer = pointer + strlen(panvalue); - length_uri = length_uri - strlen(panvalue); - } -@@ -1247,7 +1337,7 @@ static unsigned short int track(char *po - pointer = pointer + 4; - length_uri = length_uri - 4; - tilt = 1; -- if ((warningkill = sscanf(pointer, "%10[-0-9]", tiltvalue))){ -+ if ((warningkill = sscanf(pointer, "%10[-0-9]", tiltvalue))) { - pointer = pointer + strlen(tiltvalue); - length_uri = length_uri - strlen(tiltvalue); - } -@@ -1256,7 +1346,7 @@ static unsigned short int track(char *po - pointer++; - length_uri--; - X = 1; -- if ((warningkill = sscanf(pointer, "%10[-0-9]", x_value))){ -+ if ((warningkill = sscanf(pointer, "%10[-0-9]", x_value))) { - pointer = pointer + strlen(x_value); - length_uri = length_uri - strlen(x_value); - } -@@ -1265,36 +1355,32 @@ static unsigned short int track(char *po - pointer++; - length_uri--; - Y = 1; -- if ((warningkill = sscanf (pointer, "%10[-0-9]" , y_value))){ -+ if ((warningkill = sscanf(pointer, "%10[-0-9]" , y_value))) { - pointer = pointer + strlen(y_value); - length_uri = length_uri - strlen(y_value); - } - } else { - /* no valid syntax */ -- motion_log(LOG_WARNING, 0, "httpd debug race 2"); -- if (cnt[0]->conf.control_html_output) -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 2"); -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - return 1; - } - -- - /* first value check for error */ - -- - if (!warningkill) { -- motion_log(LOG_WARNING, 0, "httpd debug race 3"); -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 3"); - /* error value */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, error_value, NULL); - else - response_client(client_socket, error_value_raw, NULL); - return 1; - } - -- -- - /* Only one parameter (pan= ,tilt= ,x= ,y= ) */ - if (length_uri == 0) { - if (pan) { -@@ -1311,11 +1397,11 @@ static unsigned short int track(char *po - // Add the number of frame to skip for motion detection - cnt[thread]->moved = track_move(pancnt, pancnt->video_dev, ¢, &pancnt->imgs, 1); - if (cnt[thread]->moved) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            \n" -- "track set relative pan=%s
                                                            \n", -+ "track set relative pan=%s
                                                            \n", - thread, thread, panvalue); - send_template(client_socket, res); - send_template_end_client(client_socket); -@@ -1325,14 +1411,14 @@ static unsigned short int track(char *po - send_template_raw(client_socket, res); - } - } else { -- /*error in track action*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error in track action */ -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                            " - "Thread %hu\n", thread, thread); - response_client(client_socket, track_error, res); -- } -- else -+ } else { - response_client(client_socket, track_error_raw, NULL); -+ } - } - } else if (tilt) { - struct coord cent; -@@ -1346,9 +1432,9 @@ static unsigned short int track(char *po - cent.x = 0; - cent.y = atoi(tiltvalue); - // Add the number of frame to skip for motion detection -- cnt[thread]->moved=track_move(tiltcnt, tiltcnt->video_dev, ¢, &tiltcnt->imgs, 1); -- if (cnt[thread]->moved){ -- if (cnt[0]->conf.control_html_output) { -+ cnt[thread]->moved = track_move(tiltcnt, tiltcnt->video_dev, ¢, &tiltcnt->imgs, 1); -+ if (cnt[thread]->moved) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            \n" -@@ -1358,18 +1444,18 @@ static unsigned short int track(char *po - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -- sprintf(res, "track set relative tilt=%s\nDone\n",tiltvalue); -+ sprintf(res, "track set relative tilt=%s\nDone\n", tiltvalue); - send_template_raw(client_socket, res); - } - } else { -- /*error in track action*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error in track action */ -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                            " - "Thread %hu\n", thread, thread); - response_client(client_socket, track_error, res); -- } -- else -+ } else { - response_client(client_socket, track_error_raw, NULL); -+ } - } - } else if (X) { - /* X */ -@@ -1377,7 +1463,7 @@ static unsigned short int track(char *po - // 1000 is out of range for pwc - cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, atoi(x_value), 1000); - if (cnt[thread]->moved) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            \n" -@@ -1391,14 +1477,14 @@ static unsigned short int track(char *po - send_template_raw(client_socket, res); - } - } else { -- /*error in track action*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error in track action */ -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                            " - "Thread %hu\n", thread, thread); - response_client(client_socket, track_error, res); -- } -- else -+ } else { - response_client(client_socket, track_error_raw, NULL); -+ } - } - - } else { -@@ -1407,7 +1493,7 @@ static unsigned short int track(char *po - // 1000 is out of range for pwc - cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, 1000, atoi(y_value)); - if (cnt[thread]->moved) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            \n" -@@ -1421,105 +1507,108 @@ static unsigned short int track(char *po - send_template_raw(client_socket, res); - } - } else { -- /*error in track action*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error in track action */ -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                            " - "Thread %hu\n", thread, thread); - response_client(client_socket, track_error, res); - } else { - response_client(client_socket, track_error_raw, NULL); -- } -+ } - } - } - return 1; - } - -- - /* Check Second parameter */ - -- warningkill = sscanf (pointer, "%c%255[a-z]" ,&question, command); -- if (( question != '&' ) || (command[0] == '\0') ){ -- motion_log(LOG_WARNING, 0, "httpd debug race 4"); -- if (strstr(pointer,"&")){ -- if (cnt[0]->conf.control_html_output) -+ warningkill = sscanf(pointer, "%c%255[a-z]" , &question, command); -+ if ((question != '&') || (command[0] == '\0')) { -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 4"); -+ if (strstr(pointer, "&")) { -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, error_value, NULL); - else - response_client(client_socket, error_value_raw, NULL); -- } else { /* no valid syntax */ -- if (cnt[0]->conf.control_html_output) -+ -+ /* no valid syntax */ -+ } else { -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); -- } -+ } - return 1; - } - - pointer++; - length_uri--; - -- if (!strcmp(command, "pan")){ -+ if (!strcmp(command, "pan")) { - pointer = pointer + 3; - length_uri = length_uri - 3; -- if (pan || !tilt || X || Y ) { -- motion_log(LOG_WARNING, 0, "httpd debug race 5"); -+ if (pan || !tilt || X || Y) { -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 5"); - /* no valid syntax */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - return 1; - } - pan=2; -- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, panvalue); -- } -- else if (!strcmp(command, "tilt")) { -+ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, panvalue); -+ -+ } else if (!strcmp(command, "tilt")) { - pointer = pointer + 4; - length_uri = length_uri - 4; -- - if (tilt || !pan || X || Y) { - /* no valid syntax */ -- motion_log(LOG_WARNING, 0, "httpd debug race 6"); -- if (cnt[0]->conf.control_html_output) -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 6"); -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - return 1; - } - tilt = 2; -- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, tiltvalue); -+ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, tiltvalue); -+ - } else if (!strcmp(command, "x")) { - pointer++; - length_uri--; - if (X || !Y || pan || tilt) { -- motion_log(LOG_WARNING, 0, "httpd debug race 7"); -- -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 7"); -+ - /* no valid syntax */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - return 1; - } - X = 2; -- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, x_value); -+ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, x_value); -+ - } else if (!strcmp(command, "y")) { - pointer++; - length_uri--; -- if (Y || !X || pan || tilt){ -- motion_log(LOG_WARNING, 0, "httpd debug race 8"); -+ if (Y || !X || pan || tilt) { -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 8"); - /* no valid syntax */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - return 1; - } - Y = 2; -- warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, y_value); -+ warningkill = sscanf(pointer, "%c%10[-0-9]" , &question, y_value); -+ - } else { -- motion_log(LOG_WARNING, 0, "httpd debug race 9"); -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 9"); - /* no valid syntax */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); -@@ -1529,26 +1618,26 @@ static unsigned short int track(char *po - /* Second value check */ - - if ((warningkill < 2) && (question != '=')) { -- motion_log(LOG_WARNING, 0, "httpd debug race 10"); -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 10"); - /* no valid syntax */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_valid_syntax, NULL); - else - response_client(client_socket, not_valid_syntax_raw, NULL); - return 1; -- } else if (( question == '=') && ( warningkill == 1)) { -- motion_log(LOG_WARNING, 0, "httpd debug race 11"); -- if (cnt[0]->conf.control_html_output) -+ } else if ((question == '=') && (warningkill == 1)) { -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 11"); -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, error_value, NULL); - else - response_client(client_socket, error_value_raw, NULL); - return 1; - } -- -- -+ -+ - if (pan == 2) { - pointer = pointer + strlen(panvalue) + 1; -- length_uri = length_uri - strlen(panvalue) - 1; -+ length_uri = length_uri - strlen(panvalue) - 1; - } else if (tilt == 2) { - pointer = pointer + strlen(tiltvalue) + 1; - length_uri = length_uri - strlen(tiltvalue) - 1; -@@ -1558,27 +1647,25 @@ static unsigned short int track(char *po - } else { - pointer = pointer + strlen(y_value) + 1; - length_uri = length_uri - strlen(y_value) - 1; -- } -- -- -+ } -+ - - if (length_uri != 0) { -- motion_log(LOG_WARNING, 0, "httpd debug race 12"); -- if (cnt[0]->conf.control_html_output) -+ MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO, "%s: httpd debug race 12"); -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, error_value, NULL); - else - response_client(client_socket, error_value_raw, NULL); - return 1; - } - -- - /* track set absolute ( x , y )*/ - - if (X && Y) { - setcnt = cnt[thread]; - cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, atoi(x_value), atoi(y_value)); - if (cnt[thread]->moved) { -- if (cnt[0]->conf.control_html_output){ -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            \n" -@@ -1592,14 +1679,14 @@ static unsigned short int track(char *po - send_template_raw(client_socket, res); - } - } else { -- /*error in track action*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error in track action */ -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                            " - "Thread %hu\n", thread, thread); - response_client(client_socket, track_error, res); - } else { - response_client(client_socket, track_error_raw, NULL); -- } -+ } - } - /* track set relative ( pan , tilt )*/ - } else { -@@ -1614,7 +1701,8 @@ static unsigned short int track(char *po - cent.y = 0; - cent.x = atoi(panvalue); - // Add the number of frame to skip for motion detection -- cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ¢, &relativecnt->imgs, 1); -+ cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, -+ ¢, &relativecnt->imgs, 1); - - if (cnt[thread]->moved) { - /* move tilt */ -@@ -1623,11 +1711,11 @@ static unsigned short int track(char *po - cent.height = relativecnt->imgs.height; - cent.x = 0; - cent.y = atoi(tiltvalue); -- SLEEP(1,0); -- cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ¢, &relativecnt->imgs, 1); -- -+ // SLEEP(1,0); -+ cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, -+ ¢, &relativecnt->imgs, 1); - if (cnt[thread]->moved) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            \n" -@@ -1641,28 +1729,30 @@ static unsigned short int track(char *po - send_template_raw(client_socket, res); - } - return 1; -+ - } else { -- /*error in track tilt*/ -- if (cnt[0]->conf.control_html_output) { -+ /* error in track tilt */ -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                            " - "Thread %hu\n", thread, thread); - response_client(client_socket, track_error, res); - } else { - response_client(client_socket, track_error_raw, NULL); -- } -+ } - } - } - -- /*error in track pan*/ -- if (cnt[0]->conf.control_html_output) { -- sprintf(res, "<– back

                                                            Thread %hu\n", -+ /* error in track pan */ -+ if (cnt[0]->conf.webcontrol_html_output) { -+ sprintf(res, "<– back

                                                            Thread %hu\n", - thread, thread); - response_client(client_socket, track_error, res); -- } else -+ } else { - response_client(client_socket, track_error_raw, NULL); -+ } - } - } else if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \nThread %hu
                                                            \n" - "
                                                            \n" -@@ -1684,36 +1774,63 @@ static unsigned short int track(char *po - } - } else { - /* error not valid command */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"status")) { -+ } else if (!strcmp(command, "center")) { - pointer = pointer+6; - length_uri = length_uri-6; - if (length_uri==0) { -- if (cnt[0]->conf.control_html_output) { -+ struct context *setcnt; -+ setcnt = cnt[thread]; -+ // 1000 is out of range for pwc -+ cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, 0, 0); -+ -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \nThread %hu" -- "
                                                            track auto %s", thread, thread, -+ "
                                                            track set center", thread, thread); -+ send_template(client_socket, res); -+ send_template_end_client(client_socket); -+ } else { -+ sprintf(res, "Thread %hu\n track set center\nDone\n", thread); -+ send_template_ini_client_raw(client_socket); -+ send_template_raw(client_socket, res); -+ } -+ } else { -+ /* error not valid command */ -+ if (cnt[0]->conf.webcontrol_html_output) -+ response_client(client_socket, not_found_response_valid_command, NULL); -+ else -+ response_client(client_socket, not_found_response_valid_command_raw, NULL); -+ } -+ } else if (!strcmp(command, "status")) { -+ pointer = pointer+6; -+ length_uri = length_uri-6; -+ if (length_uri==0) { -+ if (cnt[0]->conf.webcontrol_html_output) { -+ send_template_ini_client(client_socket, ini_template); -+ sprintf(res, "<– back

                                                            \nThread %hu" -+ "
                                                            track auto %s", thread, thread, - (cnt[thread]->track.active)? "enabled":"disabled"); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { -- sprintf(res, "Thread %hu\n track auto %s\nDone\n",thread, -+ sprintf(res, "Thread %hu\n track auto %s\nDone\n", thread, - (cnt[thread]->track.active)? "enabled":"disabled"); - send_template_ini_client_raw(client_socket); - send_template_raw(client_socket, res); - } - } else { - /* error not valid command */ -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } else if (!strcmp(command,"auto")) { -+ } else if (!strcmp(command, "auto")) { - pointer = pointer + 4; - length_uri = length_uri - 4; - if ((question == '?') && (length_uri > 0)) { -@@ -1722,27 +1839,27 @@ static unsigned short int track(char *po - length_uri--; - /* value= */ - -- warningkill = sscanf (pointer, "%255[a-z]%c",query,&question); -- if ((question == '=') && (!strcmp(query,"value")) ) { -+ warningkill = sscanf(pointer, "%255[a-z]%c", query, &question); -+ if ((question == '=') && (!strcmp(query, "value"))) { - pointer = pointer + 6; - length_uri = length_uri - 6; -- warningkill = sscanf (pointer, "%255[-0-9a-z]" , command); -- if ((command!=NULL) && (strlen(command) > 0)) { -+ warningkill = sscanf(pointer, "%255[-0-9a-z]" , command); -+ if ((command != NULL) && (strlen(command) > 0)) { - struct context *autocnt; - -- /* auto value=0|1|status*/ -+ /* auto value=0|1|status */ - -- if (!strcmp(command,"status")) { -- if (cnt[0]->conf.control_html_output) { -+ if (!strcmp(command, "status")) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu
                                                            " -- "track auto %s", thread, thread, -+ "track auto %s", thread, thread, - (cnt[thread]->track.active)? "enabled":"disabled"); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { -- sprintf(res, "Thread %hu\n track auto %s\nDone\n", thread, -+ sprintf(res, "Thread %hu\n track auto %s\nDone\n", thread, - (cnt[thread]->track.active)? "enabled":"disabled"); - send_template_ini_client_raw(client_socket); - send_template_raw(client_socket, res); -@@ -1754,65 +1871,64 @@ static unsigned short int track(char *po - if (active > -1 && active < 2) { - autocnt = cnt[thread]; - autocnt->track.active = active; -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            " - "Thread %hu" -- "
                                                            track auto %s
                                                            ", thread, thread, -+ "
                                                            track auto %s
                                                            ", thread, thread, - active ? "enabled":"disabled"); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -- sprintf(res, "track auto %s\nDone\n",active ? "enabled":"disabled"); -+ sprintf(res, "track auto %s\nDone\n", active ? "enabled":"disabled"); - send_template_raw(client_socket, res); - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } -- else if (length_uri == 0) { -+ } else if (length_uri == 0) { - -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \nThread %hu\n" - "\n" -- "
                                                            \n",thread, thread, (cnt[thread]->track.active) ? "selected":"", -- (cnt[thread]->track.active) ? "selected":"" ); -+ "\n", thread, thread, (cnt[thread]->track.active) ? "selected":"", -+ (cnt[thread]->track.active) ? "selected":""); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -- sprintf(res, "auto accepts only 0,1 or status as valid value\n"); -+ sprintf(res, "auto accepts only 0,1 or status as valid value\n"); - send_template_raw(client_socket, res); - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); -@@ -1823,34 +1939,35 @@ static unsigned short int track(char *po - - - --/* -- parses the action requested for motion ( config , action , detection , track ) and call -- to action function if needed. -- -- return 0 on action restart or quit -- return 1 on success --*/ -- --static unsigned short int handle_get(int client_socket, const char* url, void *userdata) -+/** -+ * handle_get -+ * parses the action requested for motion ( config , action , detection , track ) -+ * and call to action function if needed. -+ * -+ * Returns -+ * 0 on action restart or quit -+ * 1 on success -+ */ -+static unsigned int handle_get(int client_socket, const char *url, void *userdata) - { -- struct context **cnt=userdata; -+ struct context **cnt = userdata; - -- if (*url == '/' ) { -- unsigned short int i = 0; -+ if (*url == '/') { -+ int i = 0; - char *res=NULL; -- res = malloc(2048); -+ res = mymalloc(2048); - - /* get the number of threads */ - while (cnt[++i]); - /* ROOT_URI -> GET / */ -- if (! (strcmp (url, "/"))) { -- unsigned short int y; -- if (cnt[0]->conf.control_html_output) { -- send_template_ini_client(client_socket,ini_template); -+ if (!strcmp(url, "/")) { -+ int y; -+ if (cnt[0]->conf.webcontrol_html_output) { -+ send_template_ini_client(client_socket, ini_template); - sprintf(res, "Motion "VERSION" Running [%hu] Threads
                                                            \n" - "All
                                                            \n", i); - send_template(client_socket, res); -- for (y=1; yThread %hu
                                                            \n", y, y); - send_template(client_socket, res); - } -@@ -1859,16 +1976,15 @@ static unsigned short int handle_get(int - send_template_ini_client_raw(client_socket); - sprintf(res, "Motion "VERSION" Running [%hu] Threads\n0\n", i); - send_template_raw(client_socket, res); -- for (y=1; y GET /2 */ - pointer++; - length_uri--; -- warningkill = sscanf (pointer, "%hd%c", &thread, &slash); -+ warningkill = sscanf(pointer, "%d%c", &thread, &slash); - - if ((thread != -1) && (thread < i)) { - /* thread_number found */ -@@ -1885,23 +2001,23 @@ static unsigned short int handle_get(int - length_uri = length_uri - 2; - } else { - pointer++; -- length_uri--; -+ length_uri--; - } -- -+ - if (slash == '/') { /* slash found /2/ */ - pointer++; - length_uri--; -- } -+ } - - if (length_uri != 0) { -- warningkill = sscanf (pointer, "%255[a-z]%c" , command , &slash); -+ warningkill = sscanf(pointer, "%255[a-z]%c" , command , &slash); - - /* config */ -- if (!strcmp(command,"config")) { -+ if (!strcmp(command, "config")) { - pointer = pointer + 6; - length_uri = length_uri - 6; - if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "Thread %hd
                                                            \n" -@@ -1918,24 +2034,23 @@ static unsigned short int handle_get(int - send_template_raw(client_socket, res); - } - } else if ((slash == '/') && (length_uri >= 4)) { -- /*call config() */ -+ /* call config() */ - pointer++; - length_uri--; - config(pointer, res, length_uri, thread, client_socket, cnt); - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } -- /* action */ -- else if (!strcmp(command,"action")) { -+ -+ } else if (!strcmp(command, "action")) { /* action */ - pointer = pointer + 6; - length_uri = length_uri - 6; - /* call action() */ - if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "Thread %hd
                                                            \n" -@@ -1943,7 +2058,7 @@ static unsigned short int handle_get(int - "snapshot
                                                            \n" - "restart
                                                            \n" - "quit
                                                            \n", -- thread,thread,thread,thread,thread,thread); -+ thread, thread, thread, thread, thread, thread); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { -@@ -1952,7 +2067,7 @@ static unsigned short int handle_get(int - send_template_raw(client_socket, res); - } - } else if ((slash == '/') && (length_uri > 4)) { -- unsigned short int ret = 1; -+ unsigned int ret = 1; - pointer++; - length_uri--; - ret = action(pointer, res, length_uri, thread, client_socket, cnt); -@@ -1960,18 +2075,16 @@ static unsigned short int handle_get(int - return ret; - - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command,NULL); - else - response_client(client_socket, not_found_response_valid_command_raw,NULL); - } -- } -- /* detection */ -- else if (!strcmp(command,"detection")) { -+ } else if (!strcmp(command, "detection")) { /* detection */ - pointer = pointer + 9; - length_uri = length_uri - 9; - if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "Thread %hd
                                                            \n" -@@ -1993,34 +2106,33 @@ static unsigned short int handle_get(int - /* call detection() */ - detection(pointer, res, length_uri, thread, client_socket, cnt); - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_valid_command, NULL); - else - response_client(client_socket, not_found_response_valid_command_raw, NULL); - } -- } -- /* track */ -- else if (!strcmp(command,"track")) { -+ } else if (!strcmp(command,"track")) { /* track */ - pointer = pointer + 5; - length_uri = length_uri - 5; - if (length_uri == 0) { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \n" - "Thread %hd
                                                            \n" - "track set pan/tilt
                                                            \n" -+ "track center
                                                            \n" - "track auto
                                                            \n" - "track status
                                                            \n", -- thread, thread, thread, thread, thread); -+ thread, thread, thread, thread, thread, thread); - send_template(client_socket, res); - send_template_end_client(client_socket); - } else { - send_template_ini_client_raw(client_socket); -- sprintf(res, "Thread %hd\nset pan/tilt\nauto\nstatus\n", thread); -+ sprintf(res, "Thread %hd\nset pan/tilt\ncenter\nauto\nstatus\n", thread); - send_template_raw(client_socket, res); - } -- } -- else if ((slash == '/') && (length_uri >= 4)) { -+ -+ } else if ((slash == '/') && (length_uri >= 4)) { - pointer++; - length_uri--; - /* call track() */ -@@ -2028,33 +2140,33 @@ static unsigned short int handle_get(int - track(pointer, res, length_uri, thread, client_socket, cnt); - } else { - /* error track not enable */ -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back\n", thread); -- response_client(client_socket, not_track,res); -+ response_client(client_socket, not_track, res); -+ } else { -+ response_client(client_socket, not_track_raw, NULL); - } -- else -- response_client(client_socket, not_track_raw,NULL); - } - } else { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back\n", thread); - response_client(client_socket, not_found_response_valid_command, res); -- } -- else -+ } else { - response_client(client_socket, not_found_response_valid_command_raw, NULL); -+ } - } - } else { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back\n", thread); - response_client(client_socket, not_found_response_valid_command, res); -- } -- else -+ } else { - response_client(client_socket, not_found_response_valid_command_raw, NULL); -+ } - } - } else { - /* /thread_number/ requested */ -- if (cnt[0]->conf.control_html_output) { -- send_template_ini_client(client_socket,ini_template); -+ if (cnt[0]->conf.webcontrol_html_output) { -+ send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                            \nThread %hd
                                                            \n" - "config
                                                            \n" - "action
                                                            \n" -@@ -2070,7 +2182,7 @@ static unsigned short int handle_get(int - } - } - } else { -- if (cnt[0]->conf.control_html_output) { -+ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back\n"); - response_client(client_socket, not_found_response_valid, res); - } else { -@@ -2080,7 +2192,7 @@ static unsigned short int handle_get(int - } - free(res); - } else { -- if (cnt[0]->conf.control_html_output) -+ if (cnt[0]->conf.webcontrol_html_output) - response_client(client_socket, not_found_response_template,NULL); - else - response_client(client_socket, not_found_response_template_raw,NULL); -@@ -2090,20 +2202,21 @@ static unsigned short int handle_get(int - } - - --/* -- -TODO- -- As usually web clients uses nonblocking connect/read -- read_client should handle nonblocking sockets. -- return 0 to quit or restart -- return 1 on success --*/ -- --static unsigned short int read_client(int client_socket, void *userdata, char *auth) -+/** -+ * read_client -+ * As usually web clients uses nonblocking connect/read -+ * read_client should handle nonblocking sockets. -+ * -+ * Returns -+ * 0 to quit or restart -+ * 1 on success -+ */ -+static unsigned int read_client(int client_socket, void *userdata, char *auth) - { -- unsigned short int alive = 1; -- unsigned short int ret = 1; -+ unsigned int alive = 1; -+ unsigned int ret = 1; - char buffer[1024] = {'\0'}; -- unsigned short int length = 1023; -+ ssize_t length = 1023; - struct context **cnt = userdata; - - /* lock the mutex */ -@@ -2112,10 +2225,10 @@ static unsigned short int read_client(in - while (alive) { - ssize_t nread = 0, readb = -1; - -- nread = read (client_socket, buffer, length); -+ nread = read_nonblock(client_socket, buffer, length); - - if (nread <= 0) { -- motion_log(LOG_ERR, 1, "httpd First read"); -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd First Read Error"); - pthread_mutex_unlock(&httpd_mutex); - return 1; - } else { -@@ -2126,89 +2239,107 @@ static unsigned short int read_client(in - - buffer[nread] = '\0'; - -- warningkill = sscanf (buffer, "%9s %511s %9s", method, url, protocol); -+ warningkill = sscanf(buffer, "%9s %511s %9s", method, url, protocol); -+ -+ if (warningkill != 3) { -+ if (cnt[0]->conf.webcontrol_html_output) -+ warningkill = write_nonblock(client_socket, bad_request_response, -+ sizeof (bad_request_response)); -+ else -+ warningkill = write_nonblock(client_socket, bad_request_response_raw, -+ sizeof (bad_request_response_raw)); -+ pthread_mutex_unlock(&httpd_mutex); -+ return 1; -+ } - -- while ((strstr (buffer, "\r\n\r\n") == NULL) && (readb != 0) && (nread < length)) { -- readb = read (client_socket, buffer+nread, sizeof (buffer) - nread); -+ while ((strstr(buffer, "\r\n\r\n") == NULL) && (readb != 0) && (nread < length)) { -+ readb = read_nonblock(client_socket, buffer+nread, sizeof (buffer) - nread); - - if (readb == -1) { - nread = -1; - break; - } - -- nread +=readb; -- -+ nread += readb; -+ - if (nread > length) { -- motion_log(LOG_ERR, 1, "httpd End buffer reached waiting for buffer ending"); -+ MOTION_LOG(WRN, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd End buffer" -+ " reached waiting for buffer ending"); - break; - } - buffer[nread] = '\0'; - } - -- /* Make sure the last read didn't fail. If it did, there's a -- problem with the connection, so give up. */ -+ /* -+ * Make sure the last read didn't fail. If it did, there's a -+ * problem with the connection, so give up. -+ */ - if (nread == -1) { -- motion_log(LOG_ERR, 1, "httpd READ"); -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd READ give up!"); - pthread_mutex_unlock(&httpd_mutex); - return 1; - } - alive = 0; - - /* Check Protocol */ -- if (strcmp (protocol, "HTTP/1.0") && strcmp (protocol, "HTTP/1.1")) { -+ if (strcmp(protocol, "HTTP/1.0") && strcmp (protocol, "HTTP/1.1")) { - /* We don't understand this protocol. Report a bad response. */ -- if (cnt[0]->conf.control_html_output) -- warningkill = write (client_socket, bad_request_response, sizeof (bad_request_response)); -+ if (cnt[0]->conf.webcontrol_html_output) -+ warningkill = write_nonblock(client_socket, bad_request_response, -+ sizeof (bad_request_response)); - else -- warningkill = write (client_socket, bad_request_response_raw, sizeof (bad_request_response_raw)); -+ warningkill = write_nonblock(client_socket, bad_request_response_raw, -+ sizeof (bad_request_response_raw)); - - pthread_mutex_unlock(&httpd_mutex); - return 1; - } - - if (strcmp (method, "GET")) { -- /* This server only implements the GET method. If client -- uses other method, report the failure. */ -+ /* -+ * This server only implements the GET method. If client -+ * uses other method, report the failure. -+ */ - char response[1024]; -- if (cnt[0]->conf.control_html_output) -- snprintf (response, sizeof (response),bad_method_response_template, method); -+ if (cnt[0]->conf.webcontrol_html_output) -+ snprintf(response, sizeof (response), bad_method_response_template, method); - else -- snprintf (response, sizeof (response),bad_method_response_template_raw, method); -- warningkill = write (client_socket, response, strlen (response)); -+ snprintf(response, sizeof (response), bad_method_response_template_raw, method); -+ warningkill = write_nonblock(client_socket, response, strlen(response)); - pthread_mutex_unlock(&httpd_mutex); - return 1; - } - - if (auth != NULL) { -- if ((authentication = strstr(buffer,"Basic")) ) { -+ if ((authentication = strstr(buffer,"Basic"))) { - char *end_auth = NULL; - authentication = authentication + 6; - -- if ((end_auth = strstr(authentication,"\r\n")) ) { -+ if ((end_auth = strstr(authentication,"\r\n"))) { - authentication[end_auth - authentication] = '\0'; - } else { - char response[1024]; -- snprintf (response, sizeof (response),request_auth_response_template, method); -- warningkill = write (client_socket, response, strlen (response)); -+ snprintf(response, sizeof (response), request_auth_response_template, method); -+ warningkill = write_nonblock(client_socket, response, strlen(response)); - pthread_mutex_unlock(&httpd_mutex); - return 1; - } - - if (strcmp(auth, authentication)) { -- char response[1024]={'\0'}; -+ char response[1024] = {'\0'}; - snprintf(response, sizeof (response), request_auth_response_template, method); -- warningkill = write (client_socket, response, strlen (response)); -+ warningkill = write_nonblock(client_socket, response, strlen(response)); - pthread_mutex_unlock(&httpd_mutex); - return 1; - } else { -- ret = handle_get (client_socket, url, cnt); -+ ret = handle_get(client_socket, url, cnt); - /* A valid auth request. Process it. */ - } - } else { - // Request Authorization -- char response[1024]={'\0'}; -- snprintf (response, sizeof (response),request_auth_response_template, method); -- warningkill = write (client_socket, response, strlen (response)); -+ char response[1024] = {'\0'}; -+ snprintf(response, sizeof (response), request_auth_response_template, method); -+ warningkill = write_nonblock(client_socket, response, strlen(response)); - pthread_mutex_unlock(&httpd_mutex); - return 1; - } -@@ -2224,126 +2355,171 @@ static unsigned short int read_client(in - } - - --/* -- acceptnonblocking -- -- This function waits timeout seconds for listen socket. -- Returns : -- -1 if the timeout expires or on accept error. -- curfd (client socket) on accept success. --*/ -- -+/** -+ * acceptnonblocking -+ * waits timeout seconds for listen socket. -+ * -+ * Returns -+ * -1 if the timeout expires or on accept error. -+ * curfd (client socket) on accept success. -+ */ - static int acceptnonblocking(int serverfd, int timeout) - { - int curfd; -- socklen_t namelen = sizeof(struct sockaddr_in); -- struct sockaddr_in client; -+ struct sockaddr_storage client; -+ socklen_t namelen = sizeof(client); -+ - struct timeval tm; - fd_set fds; - - tm.tv_sec = timeout; /* Timeout in seconds */ - tm.tv_usec = 0; - FD_ZERO(&fds); -- FD_SET(serverfd,&fds); -- -- if (select (serverfd + 1, &fds, NULL, NULL, &tm) > 0) { -- if (FD_ISSET(serverfd, &fds)) { -+ FD_SET(serverfd, &fds); -+ -+ if (select(serverfd + 1, &fds, NULL, NULL, &tm) > 0) { -+ if (FD_ISSET(serverfd, &fds)) { - if ((curfd = accept(serverfd, (struct sockaddr*)&client, &namelen)) > 0) - return curfd; -- } -+ } - } - - return -1; --} -- -+} - --/* -- Main function: Create the listening socket and waits client requests. --*/ - -+/** -+ * httpd_run -+ * Creates the listening socket and waits client requests. -+ */ - void httpd_run(struct context **cnt) - { -- int sd, client_socket_fd, val = 1; -- unsigned short int client_sent_quit_message = 1, closehttpd = 0; -- struct sockaddr_in servAddr; -+ int sd = -1, client_socket_fd, val; -+ unsigned int client_sent_quit_message = 1, closehttpd = 0; -+ struct addrinfo hints, *res = NULL, *ressave = NULL; - struct sigaction act; - char *authentication = NULL; -+ char portnumber[10], hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; - - /* Initialize the mutex */ - pthread_mutex_init(&httpd_mutex, NULL); - -- - /* set signal handlers TO IGNORE */ -- memset(&act,0,sizeof(act)); -+ memset(&act, 0, sizeof(act)); - sigemptyset(&act.sa_mask); - act.sa_handler = SIG_IGN; -- sigaction(SIGPIPE,&act,NULL); -- sigaction(SIGCHLD,&act,NULL); -- -- /* create socket */ -- sd = socket(AF_INET, SOCK_STREAM, 0); -+ sigaction(SIGPIPE, &act, NULL); -+ sigaction(SIGCHLD, &act, NULL); - -- if (sd < 0) { -- motion_log(LOG_ERR, 1, "httpd socket"); -+ memset(&hints, 0, sizeof(struct addrinfo)); -+ /* AI_PASSIVE as we are going to listen */ -+ hints.ai_flags = AI_PASSIVE; -+#if defined(BSD) -+ hints.ai_family = AF_INET; -+#else -+ if (!cnt[0]->conf.ipv6_enabled) -+ hints.ai_family = AF_INET; -+ else -+ hints.ai_family = AF_UNSPEC; -+#endif -+ hints.ai_socktype = SOCK_STREAM; -+ -+ snprintf(portnumber, sizeof(portnumber), "%u", cnt[0]->conf.webcontrol_port); -+ -+ val = getaddrinfo(cnt[0]->conf.webcontrol_localhost ? "localhost" : NULL, portnumber, &hints, &res); -+ -+ /* check != 0 to allow FreeBSD compatibility */ -+ if (val != 0) { -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: getaddrinfo() for httpd socket failed: %s", -+ gai_strerror(val)); -+ if (res) -+ freeaddrinfo(res); - pthread_mutex_destroy(&httpd_mutex); - return; - } - -- /* bind server port */ -- servAddr.sin_family = AF_INET; -- if (cnt[0]->conf.control_localhost) -- servAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); -- else -- servAddr.sin_addr.s_addr = htonl(INADDR_ANY); -- servAddr.sin_port = htons(cnt[0]->conf.control_port); -+ ressave = res; - -- /* Reuse Address */ -- -- setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)) ; -+ while (res) { -+ /* create socket */ -+ sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); -+ -+ getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, -+ sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV); -+ -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd testing : %s addr: %s port: %s", -+ res->ai_family == AF_INET ? "IPV4":"IPV6", hbuf, sbuf); -+ -+ if (sd >= 0) { -+ val = 1; -+ /* Reuse Address */ -+ setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(int)); -+ -+ if (bind(sd, res->ai_addr, res->ai_addrlen) == 0) { -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd Bound : %s addr: %s" -+ " port: %s", res->ai_family == AF_INET ? "IPV4":"IPV6", -+ hbuf, sbuf); -+ break; -+ } -+ -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd failed bind() interface %s" -+ " / port %s, retrying", hbuf, sbuf); -+ close(sd); -+ sd = -1; -+ } -+ MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd socket failed interface %s" -+ " / port %s, retrying", hbuf, sbuf); -+ res = res->ai_next; -+ } - -- if (bind(sd, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) { -- motion_log(LOG_ERR, 1, "httpd bind()"); -- close(sd); -+ freeaddrinfo(ressave); -+ -+ if (sd < 0) { -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd ERROR bind()" -+ " [interface %s port %s]", hbuf, sbuf); - pthread_mutex_destroy(&httpd_mutex); - return; - } - -- if (listen(sd,5) == -1) { -- motion_log(LOG_ERR, 1, "httpd listen()"); -+ if (listen(sd, DEF_MAXWEBQUEUE) == -1) { -+ MOTION_LOG(CRT, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd ERROR listen()" -+ " [interface %s port %s]", hbuf, sbuf); - close(sd); - pthread_mutex_destroy(&httpd_mutex); - return; - } - -- motion_log(LOG_DEBUG, 0, "motion-httpd/"VERSION" running, accepting connections"); -- motion_log(LOG_DEBUG, 0, "motion-httpd: waiting for data on port TCP %d", cnt[0]->conf.control_port); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd/"VERSION" running," -+ " accepting connections"); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd: waiting for data" -+ " on %s port TCP %s", hbuf, sbuf); - -- if (cnt[0]->conf.control_authentication != NULL) { -+ if (cnt[0]->conf.webcontrol_authentication != NULL) { - char *userpass = NULL; -- size_t auth_size = strlen(cnt[0]->conf.control_authentication); -+ size_t auth_size = strlen(cnt[0]->conf.webcontrol_authentication); - - authentication = (char *) mymalloc(BASE64_LENGTH(auth_size) + 1); - userpass = mymalloc(auth_size + 4); - /* base64_encode can read 3 bytes after the end of the string, initialize it */ - memset(userpass, 0, auth_size + 4); -- strcpy(userpass, cnt[0]->conf.control_authentication); -+ strcpy(userpass, cnt[0]->conf.webcontrol_authentication); - base64_encode(userpass, authentication, auth_size); - free(userpass); - } - -- while ((client_sent_quit_message) && (!closehttpd)) { -+ while ((client_sent_quit_message) && (!closehttpd)) { - - client_socket_fd = acceptnonblocking(sd, 1); - - if (client_socket_fd < 0) { -- if ((!cnt[0]) || (cnt[0]->finish)){ -- motion_log(-1, 0, "httpd - Finishing"); -+ if ((!cnt[0]) || (cnt[0]->finish)) { -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd - Finishing"); - closehttpd = 1; - } - } else { - /* Get the Client request */ -- client_sent_quit_message = read_client (client_socket_fd, cnt, authentication); -- motion_log(-1, 0, "httpd - Read from client"); -+ client_sent_quit_message = read_client(client_socket_fd, cnt, authentication); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd - Read from client"); - - /* Close Connection */ - if (client_socket_fd) -@@ -2352,17 +2528,21 @@ void httpd_run(struct context **cnt) - - } - -- if (authentication != NULL) -+ if (authentication != NULL) - free(authentication); - close(sd); -- motion_log(LOG_DEBUG, 0, "httpd Closing"); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd Closing"); - pthread_mutex_destroy(&httpd_mutex); - } - -+/** -+ * motion_web_control -+ * Calls main function httpd_run -+ */ - void *motion_web_control(void *arg) - { -- struct context **cnt=arg; -+ struct context **cnt = arg; - httpd_run(cnt); -- motion_log(LOG_DEBUG, 0, "httpd thread exit"); -+ MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd thread exit"); - pthread_exit(NULL); - } ---- motion-3.2.12.orig/webhttpd.h -+++ motion-3.2.12/webhttpd.h -@@ -1,11 +1,11 @@ - /* - * webhttpd.h - * -- * Include file for webhttpd.c -+ * Include file for webhttpd.c - * -- * Specs : http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpAPI -+ * Specs : http://www.lavrsen.dk/twiki/bin/view/Motion/MotionHttpAPI - * -- * Copyright 2004-2005 by Angel Carpintero (ack@telefonica.net) -+ * Copyright 2004-2005 by Angel Carpintero (motiondevelop@gmail.com) - * This software is distributed under the GNU Public License Version 2 - * See also the file 'COPYING'. - * -@@ -15,9 +15,9 @@ - - #include "motion.h" - --#define FOSWIKI_URL "http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuideAlphabeticalOptionReferenceManual" -+#define TWIKI_URL "http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuideAlphabeticalOptionReferenceManual" - --void * motion_web_control(void *arg); -+void * motion_web_control(void *arg); - void httpd_run(struct context **); - - #endif diff --git a/debian/patches/series b/debian/patches/series deleted file mode 100644 index 88fa82f..0000000 --- a/debian/patches/series +++ /dev/null @@ -1 +0,0 @@ -github-changes diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in deleted file mode 100644 index 62d7790..0000000 --- a/debian/po/POTFILES.in +++ /dev/null @@ -1 +0,0 @@ -[type: gettext/rfc822deb] motion.templates diff --git a/debian/po/cs.po b/debian/po/cs.po deleted file mode 100644 index 988ec24..0000000 --- a/debian/po/cs.po +++ /dev/null @@ -1,55 +0,0 @@ -# -# Translators, if you are not familiar with the PO format, gettext -# documentation is worth reading, especially sections dedicated to -# this format, e.g. by running: -# info -n '(gettext)PO Files' -# info -n '(gettext)Header Entry' -# -# Some information specific to po-debconf are available at -# /usr/share/doc/po-debconf/README-trans -# or http://www.debian.org/intl/l10n/po-debconf/README-trans -# -# Developers do not need to manually edit POT or PO files. -# -msgid "" -msgstr "" -"Project-Id-Version: motion\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2005-05-07 13:05+0200\n" -"Last-Translator: Mireoslav Kure \n" -"Language-Team: Czech \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "UmístÄ›ní konfiguraÄních souborů programu Motion se zmÄ›nilo" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"Výchozí umístÄ›ní konfiguraÄních souborů programu Motion se pÅ™esunulo z /etc/ " -"do /etc/motion/. Pokud již máte motion.conf ze starší instalace v /etc/, " -"mÄ›li byste jej pÅ™esunout do /etc/motion/, by ho mohl nový Motion využívat." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"To stejné platí pro libovolné soubory thread*.conf, které byste v /etc/ " -"nalezli. Po jejich pÅ™esunu do /etc/motion/ nezapomeňte v motion.conf zmÄ›nit " -"cestu k tÄ›mto souborům." diff --git a/debian/po/da.po b/debian/po/da.po deleted file mode 100644 index b00c4d8..0000000 --- a/debian/po/da.po +++ /dev/null @@ -1,61 +0,0 @@ -# translation of templates.po to -# translation of templates.po to -# -# Translators, if you are not familiar with the PO format, gettext -# documentation is worth reading, especially sections dedicated to -# this format, e.g. by running: -# info -n '(gettext)PO Files' -# info -n '(gettext)Header Entry' -# -# Some information specific to po-debconf are available at -# /usr/share/doc/po-debconf/README-trans -# or http://www.debian.org/intl/l10n/po-debconf/README-trans -# -# Developers do not need to manually edit POT or PO files. -# Frederik Dannemare , 2004. -# -msgid "" -msgstr "" -"Project-Id-Version: templates\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2004-06-30 14:05+0200\n" -"Last-Translator: Frederik Dannemare \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: KBabel 1.3.1\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Placering af Motions konfigurationsfiler er ændret" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"Standardplaceringen af Motions konfigurationsfiler er flyttet fra /etc/ til /" -"etc/motion/. Hvis du allerede har en motion.conf i /etc/ fra en tidligere " -"installation af Motion, bør du flytte denne til /etc/motion/, sÃ¥ Motion er i " -"stand til at finde og bruge den." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Det samme gør sig gældende for de thread*.conf-filer, du mÃ¥ske har. Disse " -"bør ligeledes flyttes til /etc/motion/ (i dette tilfælde skal du huske ogsÃ¥ " -"at opdatere stien til thread*.conf-filerne angivet i motion.conf)." diff --git a/debian/po/de.po b/debian/po/de.po deleted file mode 100644 index 312dbbc..0000000 --- a/debian/po/de.po +++ /dev/null @@ -1,58 +0,0 @@ -# translation of de.po to German -# -# Translators, if you are not familiar with the PO format, gettext -# documentation is worth reading, especially sections dedicated to -# this format, e.g. by running: -# info -n '(gettext)PO Files' -# info -n '(gettext)Header Entry' -# Some information specific to po-debconf are available at -# /usr/share/doc/po-debconf/README-trans -# or http://www.debian.org/intl/l10n/po-debconf/README-trans# -# Developers do not need to manually edit POT or PO files. -# Jens Nachtigall , 2004. -# -msgid "" -msgstr "" -"Project-Id-Version: de\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2004-11-26 00:32+0100\n" -"Last-Translator: Jens Nachtigall \n" -"Language-Team: German \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: KBabel 1.9.1\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Der Ort der Motion-Konfigurationsdatei hat sich geändert" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"Der Standard-Ort von Motions Konfigurationsdatei wurde von /etc/ zu /etc/" -"motion/ geändert. Wenn Sie also von einer früheren Motion-Installation " -"bereits eine motion.conf in /etc/ haben, dann sollten Sie diese nach /etc/" -"motion/ verschieben, damit Motion diese Datei auch verwendet." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Das gleiche gilt für jede thread*.conf-Datei, die Sie eventuell haben. Sie " -"sollten diese ebenfalls nach /etc/motion/ verschieben (in diesem Fall denken " -"Sie bitte auch daran, in der motion.conf den Pfad zu den thread*.conf-" -"Dateien anzupassen)." diff --git a/debian/po/es.po b/debian/po/es.po deleted file mode 100644 index f198050..0000000 --- a/debian/po/es.po +++ /dev/null @@ -1,78 +0,0 @@ -# motion po-debconf translation to spanish -# This file is distributed under the same license as the XXXX package. -# -# Changes: -# - Initial translation -# Jose Ignacio Méndez González -# - Revision -# Fernando Cerezal -# Javier Fernández-Sanguino -# -# -# Traductores, si no conoce el formato PO, merece la pena leer la -# documentación de gettext, especialmente las secciones dedicadas a este -# formato, por ejemplo ejecutando: -# info -n '(gettext)PO Files' -# info -n '(gettext)Header Entry' -# -# Equipo de traducción al español, por favor lean antes de traducir -# los siguientes documentos: -# -# - El proyecto de traducción de Debian al español -# http://www.debian.org/intl/spanish/ -# especialmente las notas y normas de traducción en -# http://www.debian.org/intl/spanish/notas -# -# - La guía de traducción de po's de debconf: -# /usr/share/doc/po-debconf/README-trans -# o http://www.debian.org/intl/l10n/po-debconf/README-trans -# -# Si tiene dudas o consultas sobre esta traducción consulte con el último -# traductor (campo Last-Translator) y ponga en copia a la lista de -# traducción de Debian al español () -# -msgid "" -msgstr "" -"Project-Id-Version: motion VERSION\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2006-12-28 11:32+0100\n" -"Last-Translator: Jose Ignacio Méndez González \n" -"Language-Team: Debian Spanish \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Se ha cambiado la situación de los archivos de configuración de Motion" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"La situación por omisión de los archivos de configuración de Motion se ha " -"movido de /etc/ a /etc/motion/. Por tanto, si usted ya tiene un motion.conf " -"en /etc/ de una instalación anterior de Motion, debe mover éste a /etc/" -"motion/ para que se considere cuando se utilice Motion." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Lo mismo sucede para cualquier archivo thread*.conf que tenga. Usted debe " -"mover éstos también a /etc/motion/ (en este caso, recuerde también " -"actualizar la ruta de los archivos thread*.conf dentro del archivo motion." -"conf)." diff --git a/debian/po/fr.po b/debian/po/fr.po deleted file mode 100644 index ca1caed..0000000 --- a/debian/po/fr.po +++ /dev/null @@ -1,56 +0,0 @@ -# -# Translators, if you are not familiar with the PO format, gettext -# documentation is worth reading, especially sections dedicated to -# this format, e.g. by running: -# info -n '(gettext)PO Files' -# info -n '(gettext)Header Entry' -# Some information specific to po-debconf are available at -# /usr/share/doc/po-debconf/README-trans -# or http://www.debian.org/intl/l10n/po-debconf/README-trans# -# Developers do not need to manually edit POT or PO files. -# Olivier Trichet , 2004. -# -msgid "" -msgstr "" -"Project-Id-Version: motion_3.1.14-1\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2004-08-04 16:54+0200\n" -"Last-Translator: Olivier Trichet \n" -"Language-Team: French \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-15\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: KBabel 1.3.1\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Changement de l'emplacement des fichiers de configuration" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"L'emplacement par défaut des fichiers de configuration de Motion n'est plus /" -"etc/ mais /etc/motion. En conséquence, si vous avez déjà un fichier motion." -"conf dans /etc/, d'une installation précédente, vous devriez le déplacer " -"vers /etc/motion/ afin que Motion puisse le prendre en compte." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Il en va de même pour les fichiers thread*.conf que vous pourriez avoir. " -"Vous devriez les déplacer vers /etc/motion/ ; dans ce cas, modifiez le " -"chemin vers ces fichiers thread*.conf dans motion.conf." diff --git a/debian/po/gl.po b/debian/po/gl.po deleted file mode 100644 index 7b8b2e9..0000000 --- a/debian/po/gl.po +++ /dev/null @@ -1,48 +0,0 @@ -# Galician translation of motion's debconf templates -# This file is distributed under the same license as the motion package. -# Jacobo Tarrio , 2008. -# -msgid "" -msgstr "" -"Project-Id-Version: motion\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2008-06-02 18:58+0100\n" -"Last-Translator: Jacobo Tarrio \n" -"Language-Team: Galician \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Cambiou a ubicación dos ficheiros de configuración de Motion" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"A ubicación por defecto dos ficheiros de configuración de Motion trasladouse " -"de /etc/ a /etc/motion/. Así que se xa ten un ficheiro motion.conf en /etc/ " -"dunha instalación anterior de Motion, debería trasladarlo a /etc/motion/ " -"para que tome efecto cando empregue Motion." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"O mesmo serve para os ficheiros thread*.conf que teña. Debería trasladalos " -"tamén a /etc/motion/ (neste caso, lembre actualizar a ruta aos ficheiros " -"thread*.conf en motion.conf)." - diff --git a/debian/po/it.po b/debian/po/it.po deleted file mode 100644 index b9ae9dd..0000000 --- a/debian/po/it.po +++ /dev/null @@ -1,51 +0,0 @@ -# ITALIAN TRANSLATION OF MOTION'S PO-DEBCONF FILE. -# COPYRIGHT (C) 2010 THE MOTION'S COPYRIGHT HOLDER -# This file is distributed under the same license as the motion package. -# Vincenzo Campanella , 2010. -# -msgid "" -msgstr "" -"Project-Id-Version: motion\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2010-03-16 10:07+0100\n" -"Last-Translator: Vincenzo Campanella \n" -"Language-Team: Italian \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "La posizione dei file di configurazione di Motion è stata modificata" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"La posizione predefinita dei file di configurazione di Motion è stata " -"spostata da «/etc/» a «/etc/motion». Pertanto, se si possiede già una " -"configurazione di Motion in «/etc/» da una precedente installazione, la si " -"dovrebbe spostare in «/etc/motion» affinché possa funzionare quando Motion " -"viene utilizzato." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Lo stesso vale per qualsiasi file di configurazione «thread*.conf»: se se ne " -"hanno, li si dovrebbe spostare a loro volta in «/etc/motion/». In tal caso, " -"ricordarsi anche di aggiornare il percorso dei file di configurazione " -"«thread*.conf» all'interno di «motion.conf»." - diff --git a/debian/po/ja.po b/debian/po/ja.po deleted file mode 100644 index fdcc6f3..0000000 --- a/debian/po/ja.po +++ /dev/null @@ -1,47 +0,0 @@ -# Japanese debconf templates translation for motion. -# Copyright (C) 2007 Noritada Kobayashi -# This file is distributed under the same license as the motion package. -# -msgid "" -msgstr "" -"Project-Id-Version: motion (debconf) 3.2.3-2\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2007-03-01 17:18+0900\n" -"Last-Translator: Noritada Kobayashi \n" -"Language-Team: Japanese \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Motion ã®è¨­å®šãƒ•ァイルã®å ´æ‰€ãŒå¤‰ã‚りã¾ã—ãŸ" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"Motion ã®è¨­å®šãƒ•ァイルã®ãƒ‡ãƒ•ォルトã®å ´æ‰€ãŒã€/etc/ ã‹ã‚‰ /etc/motion/ ã«å¤‰æ›´ã•れ" -"ã¾ã—ãŸã€‚ã—ãŸãŒã£ã¦ã€ä»¥å‰ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—㟠Motion ã® motion.conf ㌠/etc/ ã«æ—¢" -"ã«å­˜åœ¨ã—ã¦ã„ã‚‹å ´åˆã¯ã€Motion を使用ã™ã‚‹ã¨ãã«ã„ã¤ã§ã‚‚ãã®ãƒ•ã‚¡ã‚¤ãƒ«ãŒæœ‰åйã«ãªã‚‹" -"よã†ã€ãƒ•ァイルを /etc/motion/ ã«ç§»å‹•ã—ã¦ãã ã•ã„。" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"ã‚らゆる thread*.conf ファイルã«ã¤ã„ã¦ã‚‚åŒã˜ã“ã¨ãŒè¨€ãˆã¾ã™ã€‚ã“れらã®ãƒ•ァイル" -"ã‚’åŒæ§˜ã« /etc/motion/ ã«ç§»å‹•ã—ã¦ãã ã•ã„ (ãã®éš›ã€motion.conf 内㮠thread*." -"conf ファイルã¸ã®ãƒ‘スも忘れãšã«æ›´æ–°ã—ã¦ãã ã•ã„)。" diff --git a/debian/po/nl.po b/debian/po/nl.po deleted file mode 100644 index 2c0f2ae..0000000 --- a/debian/po/nl.po +++ /dev/null @@ -1,49 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -msgid "" -msgstr "" -"Project-Id-Version: motion\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2007-03-07 20:50+0100\n" -"Last-Translator: Bart Cornelis \n" -"Language-Team: debian-l10n-dutch \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Language: Dutch\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "De locatie van Motion's configuratiebestanden is veranderd." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"De standaardlocatie van de configuratiebestanden van Motion is verplaatst " -"van /etc/ naar /etc/motion/. Mocht u al een motion.conf hebben van een " -"eerdere installatie van Motion in /etc/ dient u dit te verplaatsen naar /etc/" -"motion/ opdat dit effect heeft bij gebruik van Motion." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Hetzelfde geldt voor alle 'thread*.conf'-bestanden die u heeft. Ook deze " -"dient u te verplaatsen naar /etc/motion/ (vergeet niet om in dat geval ook " -"het pad naar de 'thread*.conf'-bestanden aan te passen in motion.conf)." diff --git a/debian/po/pt.po b/debian/po/pt.po deleted file mode 100644 index afb3cb1..0000000 --- a/debian/po/pt.po +++ /dev/null @@ -1,48 +0,0 @@ -# Portuguese translation for motion debconf messages. -# Copyright (C) 2007 Pedro Ribeiro -# This file is distributed under the same license as the motion package. -# Pedro Ribeiro , 2007 -# -msgid "" -msgstr "" -"Project-Id-Version: motion 3.2.3-2.1\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2007-05-23 21:38+0100\n" -"Last-Translator: Pedro Ribeiro \n" -"Language-Team: Portuguese \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "A localização dos ficheiros de configuração do Motion mudou" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"A localização padrão para os ficheiros de configuração do Motion mudou de /" -"etc/ para /etc/motion/. Portanto, se tem um ficheiro motion.conf em /etc/ de " -"uma instalação anterior do Motion, deve movê-lo para /etc/motion/ para que " -"seja usado quando executar Motion." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"A mesma situação aplica-se para qualquer ficheros thread*.conf que possa " -"ter. Deve movê-los também para /etc/motion/ (neste caso não se esqueça de " -"alterar o caminho para os ficheiros thread*.conf em motion.conf)." diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po deleted file mode 100644 index 6572227..0000000 --- a/debian/po/pt_BR.po +++ /dev/null @@ -1,48 +0,0 @@ -# motion Brazilian Portuguese translation. -# Copyright (C) 2007 motion's PACKAGE COPYRIGHT HOLDER -# This file is distributed under the same license as the motion package. -# Beraldo Leal , 2007. -# -msgid "" -msgstr "" -"Project-Id-Version: motion 3.2.3-2.1\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2007-10-03 17:32-0300\n" -"Last-Translator: Beraldo Leal \n" -"Language-Team: l10n portuguese \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "O local dos arquivos de configuração do Motion mudou" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"O local padrão dos arquivos de configuração do Motion foi movido de /etc/ " -"para /etc/motion/. Portanto, se você já possui um motion.conf em /etc/ de " -"uma instalação anterior do Motion, você deveria movê-lo para /etc/motion/ " -"para que tenha efeito sempre que o Motion for usado." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"O mesmo deve ser feito para quaisquer arquivos thread*.conf que você tenha. " -"Você também deveria movê-los para /etc/motion/ (neste caso, lembre-se também " -"de atualizar o caminho para os arquivos thread*.conf dentro de motion.conf)." diff --git a/debian/po/ru.po b/debian/po/ru.po deleted file mode 100644 index 1aad71e..0000000 --- a/debian/po/ru.po +++ /dev/null @@ -1,50 +0,0 @@ -# translation of ru.po to Russian -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# -# Yuri Kozlov , 2009. -msgid "" -msgstr "" -"Project-Id-Version: motion 3.2.11-1\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2009-07-17 18:13+0400\n" -"Last-Translator: Yuri Kozlov \n" -"Language-Team: Russian \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: KBabel 1.11.4\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" -"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "ИзменилоÑÑŒ раÑположение файлов наÑтройки Motion" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"Файлы наÑтройки Motion перенеÑены из /etc/ в /etc/motion/. ПоÑтому, еÑли у " -"Ð²Ð°Ñ ÐµÑть файл motion.conf в /etc/ от предыдущей уÑтановки Motion, " -"перемеÑтите его в каталог /etc/motion/ (чтобы Motion Ñнова начал " -"иÑпользовать его)." - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Это каÑаетÑÑ Ð¸ файлов thread*.conf. ПеремеÑтите их в /etc/motion/ (в Ñтом " -"Ñлучае, не забудьте иÑправить путь к файлам thread*.conf в motion.conf)." diff --git a/debian/po/sv.po b/debian/po/sv.po deleted file mode 100644 index d786870..0000000 --- a/debian/po/sv.po +++ /dev/null @@ -1,54 +0,0 @@ -# Translators, if you are not familiar with the PO format, gettext -# documentation is worth reading, especially sections dedicated to -# this format, e.g. by running: -# info -n '(gettext)PO Files' -# info -n '(gettext)Header Entry' -# Some information specific to po-debconf are available at -# /usr/share/doc/po-debconf/README-trans -# or http://www.debian.org/intl/l10n/po-debconf/README-trans -# Developers do not need to manually edit POT or PO files. -# , fuzzy -# -# -msgid "" -msgstr "" -"Project-Id-Version: motion 3.1.19-1\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2005-09-28 17:41-0700\n" -"Last-Translator: Daniel Nylander \n" -"Language-Team: Swedish \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=iso-8859-1\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "Sökvägen till Motion's konfigurationsfiler har ändrats" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" -"Standard sökväg till Motion's konfigurationsfiler har flyttats från /etc/ " -"till /etc/motion/. Om du redan har en motion.conf i /etc/ från en tidigare " -"installation av Motion kan du flytta denna till /etc/motion/" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" -"Samma sak gäller för alla thread*.conf-filer som du har. Du bör flytta dessa " -"till /etc/motion/ (kom i håg att uppdatera sökvägen till thread*.conf-" -"filerna i motion.conf)." diff --git a/debian/po/templates.pot b/debian/po/templates.pot deleted file mode 100644 index eb5fc04..0000000 --- a/debian/po/templates.pot +++ /dev/null @@ -1,42 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "Location of Motion's config files has changed" -msgstr "" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "" - -#. Type: note -#. Description -#: ../motion.templates:1001 -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "" diff --git a/debian/po/vi.po b/debian/po/vi.po deleted file mode 100644 index 14917f8..0000000 --- a/debian/po/vi.po +++ /dev/null @@ -1,42 +0,0 @@ -# Vietnamese translation for Motion. -# Copyright © 2010 Free Software Foundation, Inc. -# Clytie Siddall , 2010. -# -msgid "" -msgstr "" -"Project-Id-Version: motion\n" -"Report-Msgid-Bugs-To: juan@apuntale.com\n" -"POT-Creation-Date: 2007-11-02 20:04-0400\n" -"PO-Revision-Date: 2010-04-01 16:59+1030\n" -"Last-Translator: Clytie Siddall \n" -"Language-Team: Vietnamese \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: LocFactoryEditor 1.8\n" - -#: ../motion.templates:1001 -#. Type: note -#. Description -msgid "Location of Motion's config files has changed" -msgstr "Tập tin cấu hình Motion có vị trí khác" - -#: ../motion.templates:1001 -#. Type: note -#. Description -msgid "" -"The default location of Motion's configuration files has moved from /etc/ " -"to /etc/motion/. So if you already have a motion.conf in /etc/ from a " -"previous installation of Motion, you should move this to /etc/motion/ in " -"order for it to take effect whenever Motion is used." -msgstr "Vị trí mặc định cá»§a các tập tin cấu hình Motion đã di chuyển từ « /etc/ » sang « /etc/motion/ ». Vì thế nếu bạn có má»™t tập tin « motion.conf » trong « /etc/ » từ má»™t bản cài đặt Motion trước thì bạn nên di chuyển nó sang « /etc/motion/ » để có tác động khi chạy Motion." - -#: ../motion.templates:1001 -#. Type: note -#. Description -msgid "" -"The same thing goes for any thread*.conf files you may have. You should move " -"these to /etc/motion/ as well (in this case, also remember to update the " -"path to the thread*.conf files inside motion.conf)." -msgstr "Tương tá»± vá»›i tập tin « thread*.conf » nào — di chuyển tập tin như vậy sang « /etc/motion/ ». Trong trưá»ng hợp này, cÅ©ng cần phải cập nhật đưá»ng dẫn đến các tập tin « thread*.conf » bên trong tập tin « motion.conf »." diff --git a/debian/postrm b/debian/postrm deleted file mode 100644 index fb6a47e..0000000 --- a/debian/postrm +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -set -e - -case "$1" in - - purge) - - rm -rf /etc/motion - userdel motion || true - ;; - - remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - - ;; - - *) - - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - -esac - -#DEBHELPER# - -exit 0 diff --git a/debian/prerm b/debian/prerm deleted file mode 100644 index b668bb2..0000000 --- a/debian/prerm +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -set -e - -case "$1" in - - remove|remove-in-favour|deconfigure|deconfigure-in-favour) - - if [ -x /etc/init.d/motion ]; then - if [ -x /usr/sbin/invoke-rc.d ] ; then - invoke-rc.d motion stop - else - /etc/init.d/motion stop - fi - fi - - ;; - - upgrade|failed-upgrade) - - ;; - - *) - - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - - ;; - -esac - -#DEBHELPER# - -exit 0 diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 56040d8..0000000 --- a/debian/rules +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/make -f -# export DH_VERBOSE=1 - -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) - -CFLAGS = -Wall -g -LDFLAGS = -Wl,--as-needed - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_PROGRAM += -s -endif - -config.status: - dh_testdir - dh_autoreconf - # Add here commands to configure the package. - CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure \ - --prefix=/usr \ - --bindir=\$${prefix}/bin \ - --build=${DEB_BUILD_GNU_TYPE} \ - --host=${DEB_HOST_GNU_TYPE} \ - --datadir=\$${prefix}/share \ - --mandir=\$${datadir}/man \ - --infodir=\$${datadir}/info \ - --sysconfdir=/etc/motion \ - --with-ffmpeg \ - --with-mysql \ - --with-mysql-lib=/usr/lib/$(DEB_HOST_MULTIARCH) \ - --with-pgsql \ - --without-optimizecpu \ - --without-jpeg-mmx - touch configure-stamp - -build: build-arch build-indep -build-arch: build-stamp -build-indep: build-stamp - -build-stamp: config.status - dh_testdir - $(MAKE) - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - -[ ! -f Makefile ] || $(MAKE) distclean - dh_autoreconf_clean - dh_clean - -install: build-stamp - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - # Add here commands to install the package into debian/motion. - $(MAKE) install DESTDIR=$(CURDIR)/debian/motion - # Offer a minimal default config file. - cp thread*.conf debian/motion/etc/motion - cp debian/NEWS debian/motion/usr/share/doc/motion - # Remove unwanted/misplaced files. - rm -rf $(CURDIR)/debian/motion/usr/share/doc/motion* - rm -f $(CURDIR)/debian/motion/etc/motion/motion-dist.conf - # Fix mode Daemon - cat $(CURDIR)/motion-dist.conf | sed 's/^daemon on/daemon off/g' > motion.conf - mv motion.conf $(CURDIR)/debian/motion/etc/motion/motion.conf - # Fix path directory for pictures and films - cat $(CURDIR)/debian/motion/etc/motion/motion.conf | sed 's/target_dir \/usr\/local\/apache2\/htdocs\/cam1/target_dir \/tmp\/motion/g' > motion.conf - mv motion.conf $(CURDIR)/debian/motion/etc/motion/motion.conf - # Fix default format encoding - cat $(CURDIR)/debian/motion/etc/motion/motion.conf | sed 's/^ffmpeg_video_codec mpeg4/ffmpeg_video_codec swf/g' > motion.conf - mv motion.conf $(CURDIR)/debian/motion/etc/motion/motion.conf - # Remove dir/files unnecessary - rm -rf $(CURDIR)/debian/motion/usr/share/motion-3.2.12 - -# Build architecture-independent files here. -binary-indep: build-stamp install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build-stamp install - dh_testdir - dh_testroot - dh_installchangelogs CHANGELOG - dh_installdocs - dh_installinit --init-script=motion \ - --update-rcd-params='start 60 2 3 4 5 . stop 60 0 1 6 .' - dh_installman debian/motion.1 - dh_installdebconf - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build-stamp clean binary-indep binary-arch binary install diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 163aaf8..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/debian/watch b/debian/watch deleted file mode 100644 index 29df717..0000000 --- a/debian/watch +++ /dev/null @@ -1,4 +0,0 @@ -version=3 -http://sf.net/motion/motion-(.*)\.tar\.gz - - From 45a523ca43663bbb298fe3936887100a06139cda Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Thu, 25 Sep 2014 19:09:21 -0700 Subject: [PATCH 047/233] packaging fixes from infinity0 --- FAQ | 4 ++-- Makefile.in | 19 +++++++++++-------- conf.c | 6 +++--- motion-dist.conf.in | 8 ++++---- motion.1 | 30 +++++++++++++++--------------- motion.init-FreeBSD.sh.in | 2 +- motion_guide.html | 16 ++++++++-------- thread1.conf.in | 2 +- thread2.conf.in | 2 +- thread3.conf.in | 2 +- thread4.conf.in | 2 +- 11 files changed, 48 insertions(+), 45 deletions(-) diff --git a/FAQ b/FAQ index f4cc8ff..fb6f705 100644 --- a/FAQ +++ b/FAQ @@ -13,8 +13,8 @@ Q: Were does motion look for the config file? A: First it will look for 'motion.conf' in the current directory, next it will try to find '.motion/motion.conf' in your home directory (pointed to by the HOME environment variable). If these don't exist it will try to open - '/usr/local/etc/motion.conf' if you specified /usr/local as the prefix to - configure (this is the default). + '/usr/local/etc/motion/motion.conf' if you specified /usr/local as the prefix + to configure (this is the default). Q: What codingstyle is used for motion? diff --git a/Makefile.in b/Makefile.in index 546eeb1..46dd0ab 100644 --- a/Makefile.in +++ b/Makefile.in @@ -12,6 +12,7 @@ CC = @CC@ INSTALL = install +INSTALL_DATA = ${INSTALL} -m 644 ################################################################################ # Install locations, controlled by setting configure flags. # @@ -39,8 +40,9 @@ OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $( alg.o event.o picture.o rotate.o webhttpd.o \ stream.o md5.o @FFMPEG_OBJ@ @SDL_OBJ@ @RTPS_OBJ@ SRC = $(OBJ:.o=.c) -DOC = CHANGELOG COPYING CREDITS INSTALL README motion_guide.html -EXAMPLES = *.conf motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh +DOC = CHANGELOG COPYING CREDITS README motion_guide.html +EXAMPLES = *.conf +EXAMPLES_BIN = motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh PROGS = motion DEPEND_FILE = .depend @@ -204,17 +206,18 @@ install: mkdir -p $(DESTDIR)$(sysconfdir) mkdir -p $(DESTDIR)$(docdir) mkdir -p $(DESTDIR)$(examplesdir) - $(INSTALL) motion.1 $(DESTDIR)$(mandir)/man1 - $(INSTALL) $(DOC) $(DESTDIR)$(docdir) - $(INSTALL) $(EXAMPLES) $(DESTDIR)$(examplesdir) - $(INSTALL) motion-dist.conf $(DESTDIR)$(sysconfdir) + $(INSTALL_DATA) motion.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) $(DOC) $(DESTDIR)$(docdir) + $(INSTALL_DATA) $(EXAMPLES) $(DESTDIR)$(examplesdir) + $(INSTALL) $(EXAMPLES_BIN) $(DESTDIR)$(examplesdir) + $(INSTALL_DATA) motion-dist.conf $(DESTDIR)$(sysconfdir)/motion for prog in $(PROGS); \ do \ ($(INSTALL) $$prog $(DESTDIR)$(bindir) ); \ done @echo "--------------------------------------------------------------------------------" @echo "Install complete! The default configuration file, motion-dist.conf, has been" - @echo "installed to $(sysconfdir). You need to rename/copy it to $(sysconfdir)/motion.conf" + @echo "installed to $(sysconfdir)/motion. You need to rename/copy it to motion.conf" @echo "for Motion to find it. More configuration examples as well as init scripts" @echo "can be found in $(examplesdir)." @echo @@ -230,7 +233,7 @@ uninstall remove: pre-build-info ($ rm -f $(bindir)/$$prog ); \ done rm -f $(mandir)/man1/motion.1 - rm -f $(sysconfdir)/motion-dist.conf + rm -f $(sysconfdir)/motion/motion-dist.conf rm -rf $(docdir) rm -rf $(examplesdir) @echo "--------------------------------------------------------------------------------" diff --git a/conf.c b/conf.c index cf905c6..71b3ee0 100644 --- a/conf.c +++ b/conf.c @@ -1800,7 +1800,7 @@ void conf_print(struct context **cnt) fprintf(conffile, "%s\n", val); if (strlen(val) == 0) - fprintf(conffile, "; thread /usr/local/etc/thread1.conf\n"); + fprintf(conffile, "; thread %s/motion/thread1.conf\n", sysconfdir); free(val); } else if (thread == 0) { @@ -1911,7 +1911,7 @@ struct context **conf_load(struct context **cnt) fp = fopen(filename, "r"); if (!fp) { - snprintf(filename, PATH_MAX, "%s/motion.conf", sysconfdir); + snprintf(filename, PATH_MAX, "%s/motion/motion.conf", sysconfdir); fp = fopen(filename, "r"); if (!fp) /* There is no config file.... use defaults. */ @@ -2387,6 +2387,6 @@ static void usage() printf("-h\t\t\tShow this screen.\n"); printf("\n"); printf("Motion is configured using a config file only. If none is supplied,\n"); - printf("it will read motion.conf from current directory, ~/.motion or %s.\n", sysconfdir); + printf("it will read motion.conf from current directory, ~/.motion or %s/motion.\n", sysconfdir); printf("\n"); } diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 5408394..081d6ba 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -729,8 +729,8 @@ quiet on # This motion.conf file AND thread1.conf and thread2.conf. # Only put the options that are unique to each camera in the # thread config files. -; thread /usr/local/etc/thread1.conf -; thread /usr/local/etc/thread2.conf -; thread /usr/local/etc/thread3.conf -; thread /usr/local/etc/thread4.conf +; thread @sysconfdir@/motion/thread1.conf +; thread @sysconfdir@/motion/thread2.conf +; thread @sysconfdir@/motion/thread3.conf +; thread @sysconfdir@/motion/thread4.conf diff --git a/motion.1 b/motion.1 index a023f83..e2b62bc 100644 --- a/motion.1 +++ b/motion.1 @@ -3,7 +3,7 @@ motion \- Detect motion using a video4linux device .SH SYNOPSIS .B motion -[ -hmns ] [ -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 @@ -12,7 +12,7 @@ if needed. Creation of automated snapshots is also possible. .SH OPTIONS .TP .B \-c -Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default. +Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc/motion unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default. .TP .B \-h Show help screen. @@ -36,7 +36,7 @@ Set type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. .TP .B \-l -Full path and filename of log file. ( use -l syslog to log to stderr and syslog ) +Full path and filename of log file. ( use \-l syslog to log to stderr and syslog ) .TP .SH "CONFIG FILE OPTIONS" These are the options that can be used in the config file. @@ -132,7 +132,7 @@ pipe raw video to generally - 'STDIN', allowing to use an external video encoder .br e.g. using memcoder : .br -extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt: threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps +extpipe mencoder \-demuxer rawvideo \-rawvideo w=320:h=240:i420 \-ovc x264 \-x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt: threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me \-vf denoise3d=16:12:48:4,pp=lb \-of avi \-o %f.avi \- \-fps %fps .TP .B ffmpeg_bps integer Values: 0 - 9999999 / Default: 400000 @@ -195,9 +195,9 @@ Values: 0 - 255 / Default: 0 (disabled) The hue level for the video device. .TP .B input integer -Values: -1 - 64, -1 = disabled / Default: -1 (disabled) +Values: \-1 - 64, \-1 = disabled / Default: \-1 (disabled) .br -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. +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 @@ -529,12 +529,12 @@ This option defines the value of the special event conversion specifier %C. You .B text_left string Values: Max 4095 characters / Default: Not defined .br -User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). +User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \\n and conversion specifiers (codes starting by a %). .TP .B text_right string -Values: Max 4095 characters / Default: %Y-%m-%d\n%T +Values: Max 4095 characters / Default: %Y-%m-%d\\n%T .br -User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock +User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \\n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\\n%T = date in ISO format and time in 24 hour clock .TP .B thread string Values: Max 4095 characters / Default: Not defined @@ -695,19 +695,19 @@ A "motion" image/movie shows the pixels that have actually changed during the la A "normal" image is the real image taken by the camera with text overlayed. .TP .B Threads and config files -If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. +If Motion was invoked with command line option \-c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with \-c you can call it anything. .br -If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: +If you do not specify \-c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: .br 1. Current directory from where motion was invoked .br 2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf .br -3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) +3. The directory defined by the \-\-sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) .br -If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. +If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file in the default /usr/local/etc/motion directory. .br -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc/motion directory. .br The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. .br @@ -742,7 +742,7 @@ If you run the webcontrol command http://host:port/0/config/writeyes, motion wil .B Conversion Specifiers for Advanced Filename and Text Features The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, picture_filename, movie_filename, timelapse_filename, on_area_detected, on_camera_lost, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. .br -In text_left and text_right you can additionally use '\n' for new line. +In text_left and text_right you can additionally use '\\n' for new line. .TP .B %a diff --git a/motion.init-FreeBSD.sh.in b/motion.init-FreeBSD.sh.in index a7b6e3d..5e99db4 100644 --- a/motion.init-FreeBSD.sh.in +++ b/motion.init-FreeBSD.sh.in @@ -20,7 +20,7 @@ rcvar=`set_rcvar` command="@BIN_PATH@/${name}" pidfile="/var/run/${name}.pid" -required_files="/usr/local/etc/${name}.conf" +required_files="/usr/local/etc/motion/${name}.conf" load_rc_config $name run_rc_command "$1" diff --git a/motion_guide.html b/motion_guide.html index c23bb02..0260ed3 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -459,13 +459,13 @@

                                                            -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory. Installation directories:     - --prefix=PREFIX install architecture-independent files in PREFIX
                                                            [/usr/local] The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
                                                            If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                            This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                            If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                            Example: --prefix=$HOME + --prefix=PREFIX install architecture-independent files in PREFIX
                                                            [/usr/local] The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc/motion, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
                                                            If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                            This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                            If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                            Example: --prefix=$HOME --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
                                                            [PREFIX] If you set this it only defines an alternative installation directory for the executable binary.
                                                            Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
                                                            Editor recommends leaving this as default (i.e. not setting it). --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control. --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it. --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it. --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it. - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
                                                            Motion searches for the configuration file "motion.conf" in the following order:

                                                              1. Current directory from where motion was invoked
                                                              2. $HOME/.motion
                                                              3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/

                                                            Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again. + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
                                                            Motion searches for the configuration file "motion.conf" in the following order:

                                                              1. Current directory from where motion was invoked
                                                              2. $HOME/.motion
                                                              3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/motion

                                                            Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again. --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it. --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it. --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it. @@ -514,7 +514,7 @@

                                                            Make Install

                                                          • Manual page "motion.1" to /usr/local/man/man1
                                                          • Document files "CHANGELOG, COPYING, CREDITS, INSTALL, and README to /usr/local/share/doc/motion-3.2.X
                                                          • Example configuration files "*.conf" to /usr/local/share/doc/examples/motion-3.2.X -
                                                          • Configuration file "motion-dist.conf" to /usr/local/etc +
                                                          • Configuration file "motion-dist.conf" to /usr/local/etc/motion
                                                          Note that the any existing files are overwritten. The default config file motion-dist.conf is named like this so that you do not get your working motion.conf file overwritten when you upgrade Motion.

                                                          @@ -652,11 +652,11 @@

                                                          The Config Files

                                                          1. Current directory from where motion was invoked
                                                          2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf -
                                                          3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion
                                                            (If this option was not defined the default is /usr/local/etc/) +
                                                          4. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion
                                                            (If this option was not defined the default is /usr/local/etc/motion)
                                                          -If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. +If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file in the default /usr/local/etc/motion directory.

                                                          -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this file gets copied to the /usr/local/etc directory. +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this file gets copied to the /usr/local/etc/motion directory.

                                                          The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion.

                                                          @@ -705,7 +705,7 @@

                                                          Option Description Editors comment -n Run in non-daemon mode. Instead of running Motion in the background Motion runs in the terminal window writing messages when things happen. If you have problems getting Motion to start or work, run Motion in this mode to get more messages that can help you solve the problem. -s Run in setup mode. Also forces non-daemon mode - -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default + -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc/motion unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default -h Show help screen.   -d level Debugging mode This mode is used for developers to enable debug messages. Normal users will not need to use this mode unless a developer request to get additional information in the attempt to resolve a bug. Mainly the netcam code has debugging features. The level defines how much debugging info you get. A high number displays all debugging. -p process_id_file Full path of process ID file Full path and filename of process id file (PID file). This is optional. If none is given as command line option or in motion.conf (process_id_file) Motion will not create a PID file. @@ -3539,4 +3539,4 @@

                                                          video_pipe

                                                          --- KennethLavrsen - 13 Apr 2005 \ No newline at end of file +-- KennethLavrsen - 13 Apr 2005 diff --git a/thread1.conf.in b/thread1.conf.in index f6d5fe8..3d1620e 100644 --- a/thread1.conf.in +++ b/thread1.conf.in @@ -1,4 +1,4 @@ -# /usr/local/etc/thread1.conf +# @sysconfdir@/motion/thread1.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ diff --git a/thread2.conf.in b/thread2.conf.in index d0b8b2a..fade2f9 100644 --- a/thread2.conf.in +++ b/thread2.conf.in @@ -1,4 +1,4 @@ -# /usr/local/etc/thread2.conf +# @sysconfdir@/motion/thread2.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ diff --git a/thread3.conf.in b/thread3.conf.in index 2192805..0910ab6 100644 --- a/thread3.conf.in +++ b/thread3.conf.in @@ -1,4 +1,4 @@ -# /usr/local/etc/thread3.conf +# @sysconfdir@/motion/thread3.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ diff --git a/thread4.conf.in b/thread4.conf.in index 64a6363..9bc4e3d 100644 --- a/thread4.conf.in +++ b/thread4.conf.in @@ -1,4 +1,4 @@ -# /usr/local/etc/thread4.conf +# @sysconfdir@/motion/thread4.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ From 6c5dacbb1d62e9d61d39f10ff1cd3d757e7058df Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 25 Sep 2014 19:11:46 -0700 Subject: [PATCH 048/233] Additional packaging fixes --- Makefile.in | 12 ++++++++++-- motion-dist.conf.in | 10 +++++----- thread1.conf.in | 22 +++++++++++++++------- thread2.conf.in | 19 +++++++++++++------ thread3.conf.in | 23 ++++++++++++++--------- thread4.conf.in | 39 +++++++++++++++++++++------------------ 6 files changed, 78 insertions(+), 47 deletions(-) diff --git a/Makefile.in b/Makefile.in index 46dd0ab..32e81f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -38,7 +38,7 @@ VIDEO_OBJ = @VIDEO@ OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ alg.o event.o picture.o rotate.o webhttpd.o \ - stream.o md5.o @FFMPEG_OBJ@ @SDL_OBJ@ @RTPS_OBJ@ + stream.o md5.o netcam_rtsp.o @FFMPEG_OBJ@ @SDL_OBJ@ SRC = $(OBJ:.o=.c) DOC = CHANGELOG COPYING CREDITS README motion_guide.html EXAMPLES = *.conf @@ -203,7 +203,7 @@ install: @echo "--------------------------------------------------------------------------------" mkdir -p $(DESTDIR)$(bindir) mkdir -p $(DESTDIR)$(mandir)/man1 - mkdir -p $(DESTDIR)$(sysconfdir) + mkdir -p $(DESTDIR)$(sysconfdir)/motion mkdir -p $(DESTDIR)$(docdir) mkdir -p $(DESTDIR)$(examplesdir) $(INSTALL_DATA) motion.1 $(DESTDIR)$(mandir)/man1 @@ -211,6 +211,10 @@ install: $(INSTALL_DATA) $(EXAMPLES) $(DESTDIR)$(examplesdir) $(INSTALL) $(EXAMPLES_BIN) $(DESTDIR)$(examplesdir) $(INSTALL_DATA) motion-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread1.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread2.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread3.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread4.conf $(DESTDIR)$(sysconfdir)/motion for prog in $(PROGS); \ do \ ($(INSTALL) $$prog $(DESTDIR)$(bindir) ); \ @@ -234,6 +238,10 @@ uninstall remove: pre-build-info done rm -f $(mandir)/man1/motion.1 rm -f $(sysconfdir)/motion/motion-dist.conf + rm -f $(sysconfdir)/motion/thread1.conf + rm -f $(sysconfdir)/motion/thread2.conf + rm -f $(sysconfdir)/motion/thread3.conf + rm -f $(sysconfdir)/motion/thread4.conf rm -rf $(docdir) rm -rf $(examplesdir) @echo "--------------------------------------------------------------------------------" diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 081d6ba..1f93f08 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -419,7 +419,7 @@ text_double off # Target base directory for pictures and films # Recommended to use absolute path. (Default: current working directory) -target_dir /tmp/motion +#target_dir /tmp/motion # File path for snapshots (jpeg or ppm) relative to target_dir # Default: %v-%Y%m%d%H%M%S-snapshot @@ -729,8 +729,8 @@ quiet on # This motion.conf file AND thread1.conf and thread2.conf. # Only put the options that are unique to each camera in the # thread config files. -; thread @sysconfdir@/motion/thread1.conf -; thread @sysconfdir@/motion/thread2.conf -; thread @sysconfdir@/motion/thread3.conf -; thread @sysconfdir@/motion/thread4.conf +; thread @prefix@/etc/motion/thread1.conf +; thread @prefix@/etc/motion/thread2.conf +; thread @prefix@/etc/motion/thread3.conf +; thread @prefix@/etc/motion/thread4.conf diff --git a/thread1.conf.in b/thread1.conf.in index 3d1620e..b3d1d57 100644 --- a/thread1.conf.in +++ b/thread1.conf.in @@ -1,8 +1,6 @@ -# @sysconfdir@/motion/thread1.conf +# @prefix@/etc/motion/thread1.conf # -# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ - - +# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ ########################################################### # Capture device options @@ -38,7 +36,16 @@ text_left CAMERA 1 # Target base directory for pictures and films # Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam1 +#target_dir /tmp/motion/cam1 + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename CAM1_%v-%Y%m%d%H%M%S-%q ############################################################ @@ -50,8 +57,9 @@ stream_port 8081 # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) # The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse1.pl +#on_picture_save /usr/local/motion-extras/camparse2.pl # Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) # Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse1.pl +#on_movie_end /usr/local/motion-extras/mpegparse2.pl + diff --git a/thread2.conf.in b/thread2.conf.in index fade2f9..d6d81ff 100644 --- a/thread2.conf.in +++ b/thread2.conf.in @@ -1,9 +1,7 @@ -# @sysconfdir@/motion/thread2.conf +# @prefix@/etc/motion/thread2.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ - - ########################################################### # Capture device options ############################################################ @@ -38,7 +36,16 @@ text_left CAMERA 2 # Target base directory for pictures and films # Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam2 +#target_dir /tmp/motion/cam2 + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename CAM2_%v-%Y%m%d%H%M%S-%q ############################################################ @@ -50,9 +57,9 @@ stream_port 8082 # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) # The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse2.pl +#on_picture_save /usr/local/motion-extras/camparse2.pl # Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) # Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse2.pl +#on_movie_end /usr/local/motion-extras/mpegparse2.pl diff --git a/thread3.conf.in b/thread3.conf.in index 0910ab6..14a2655 100644 --- a/thread3.conf.in +++ b/thread3.conf.in @@ -1,8 +1,6 @@ -# @sysconfdir@/motion/thread3.conf +# @prefix@/etc/motion/thread3.conf # -# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ - - +# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ ########################################################### # Capture device options @@ -38,7 +36,16 @@ text_left CAMERA 3 # Target base directory for pictures and films # Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam3 +#target_dir /tmp/motion/cam3 + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename CAM3_%v-%Y%m%d%H%M%S-%q ############################################################ @@ -50,11 +57,9 @@ stream_port 8083 # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) # The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse3.pl +#on_picture_save /usr/local/motion-extras/camparse2.pl # Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) # Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse3.pl - - +#on_movie_end /usr/local/motion-extras/mpegparse2.pl diff --git a/thread4.conf.in b/thread4.conf.in index 9bc4e3d..b22235e 100644 --- a/thread4.conf.in +++ b/thread4.conf.in @@ -1,31 +1,25 @@ -# @sysconfdir@/motion/thread4.conf +# @prefix@/etc/motion/thread4.conf # -# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ +# This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ ########################################################### # Capture device options ############################################################ -# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined -netcam_url http://192.168.1.6:8093/ +# Videodevice to be used for capturing (default /dev/video0) +# for FreeBSD default is /dev/bktr0 +videodevice /dev/video3 -# The setting for keep-alive of network socket, should improve performance on compatible net cameras. -# off: The historical implementation using HTTP/1.0, closing the socket after each http request. -# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -# on: Use HTTP/1.1 requests that support keep alive as default. -# Default: off -netcam_keepalive force - -# Set less strict jpeg checks for network cameras with a poor/buggy firmware. -# Default: off -netcam_tolerant_check on +# 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 # Text is placed in lower left corner text_left CAMERA 4 + ############################################################ # Target Directories and filenames For Images And Films # For the options snapshot_, picture_, mpeg_ and timelapse_filename @@ -42,7 +36,16 @@ text_left CAMERA 4 # Target base directory for pictures and films # Recommended to use absolute patch. (Default: current working directory) -target_dir /usr/local/apache2/htdocs/cam4 +#target_dir /tmp/motion/cam4 + +# File path for motion triggered images (jpeg or ppm) relative to target_dir +# Default: %v-%Y%m%d%H%M%S-%q +# Default value is equivalent to legacy oldlayout option +# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q +# File extension .jpg or .ppm is automatically added so do not include this +# Set to 'preview' together with best-preview feature enables special naming +# convention for preview shots. See motion guide for details +picture_filename CAM4_%v-%Y%m%d%H%M%S-%q ############################################################ @@ -54,9 +57,9 @@ stream_port 8084 # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) # The filename of the picture is appended as an argument for the command. -on_picture_save /usr/local/motion-extras/camparse4.pl +#on_picture_save /usr/local/motion-extras/camparse2.pl # Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) # Filename of movie is appended as an argument for the command. -on_movie_end /usr/local/motion-extras/mpegparse4.pl +#on_movie_end /usr/local/motion-extras/mpegparse2.pl From c37ac341753453068ed3d943c740d5bdbc5c6699 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 25 Sep 2014 19:16:27 -0700 Subject: [PATCH 049/233] Add support to ffmpeg.c for libav10 --- ffmpeg.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 6127542..b0a6985 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -279,8 +279,11 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) #endif /* Manually override the codec id. */ if (of) +#if (LIBAVFORMAT_VERSION_MAJOR >= 56) + of->video_codec = AV_CODEC_ID_MSMPEG4V2; +#else of->video_codec = CODEC_ID_MSMPEG4V2; - +#endif } else if (strcmp(codec, "swf") == 0) { ext = ".swf"; #ifdef GUESS_NO_DEPRECATED @@ -308,7 +311,11 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) * Requires strict_std_compliance to be <= -2 */ if (of) +#if (LIBAVFORMAT_VERSION_MAJOR >= 56) + of->video_codec = AV_CODEC_ID_FFV1; +#else of->video_codec = CODEC_ID_FFV1; +#endif } else if (strcmp(codec, "mov") == 0) { ext = ".mov"; @@ -402,7 +409,11 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, /* Create a new video stream and initialize the codecs. */ ffmpeg->video_st = NULL; +#if (LIBAVFORMAT_VERSION_MAJOR >= 56) + if (ffmpeg->oc->oformat->video_codec != AV_CODEC_ID_NONE) { +#else if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { +#endif ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); if (!ffmpeg->video_st) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: av_new_stream - could" @@ -424,8 +435,12 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->codec_type = AVMEDIA_TYPE_VIDEO; #else c->codec_type = CODEC_TYPE_VIDEO; -#endif +#endif +#if (LIBAVFORMAT_VERSION_MAJOR >= 56) + is_mpeg1 = c->codec_id == AV_CODEC_ID_MPEG1VIDEO; +#else is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; +#endif if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; From f880807aea4c6a18e9d40a920e53caf1f26f1482 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 25 Sep 2014 19:18:45 -0700 Subject: [PATCH 050/233] Clean up ffmpeg.c and plug memory leak --- ffmpeg.c | 570 ++++++++++++++----------------------------------------- ffmpeg.h | 54 ++---- motion.c | 10 +- 3 files changed, 156 insertions(+), 478 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index b0a6985..8216bf1 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -8,156 +8,54 @@ * The contents of this file has been derived from output_example.c * and apiexample.c from the FFmpeg distribution. * + * This file has been modified so that only major versions greater than + * 53 are supported. */ + #ifdef HAVE_FFMPEG #include "ffmpeg.h" #include "motion.h" -#if LIBAVCODEC_BUILD > 4680 -/* - * FFmpeg after build 4680 doesn't have support for mpeg1 videos with - * non-standard framerates. Previous builds contained a broken hack - * that padded with B frames to obtain the correct framerate. - */ -# define FFMPEG_NO_NONSTD_MPEG1 -#endif /* LIBAVCODEC_BUILD > 4680 */ - -#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR -# if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 -# define GUESS_NO_DEPRECATED -# endif -#endif - -#if LIBAVFORMAT_BUILD >= 4616 -/* - * The API for av_write_frame changed with FFmpeg version 0.4.9pre1. - * It now uses an AVPacket struct instead of direct parameters to the - * function. - */ -# define FFMPEG_AVWRITEFRAME_NEWAPI -#endif /* LIBAVFORMAT_BUILD >= 4616 */ - -#if LIBAVFORMAT_BUILD >= 4629 -/* - * In this build/header version, the codec member of struct AVStream - * was changed to a pointer so changes to AVCodecContext shouldn't - * break binary compatibility with AVStream. - */ -# define AVSTREAM_CODEC_PTR(avs_ptr) (avs_ptr->codec) -#else -# define AVSTREAM_CODEC_PTR(avs_ptr) (&avs_ptr->codec) -#endif /* LIBAVFORMAT_BUILD >= 4629 */ - -// AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) -// (54*2^16 | 6*2^8 | 100) -#if LIBAVFORMAT_BUILD >= 3540580 -#define FF_API_NEW_AVIO -#define URL_RDONLY AVIO_FLAG_READ /**< read-only */ -#define URL_WRONLY AVIO_FLAG_WRITE /**< write-only */ -#define URL_RDWR AVIO_FLAG_READ_WRITE /**< read-write pseudo flag */ -#endif +#define AVSTREAM_CODEC_PTR(avs_ptr) (avs_ptr->codec) -/* - * Name of custom file protocol for appending to existing files instead - * of truncating. - */ -#define APPEND_PROTO "appfile" +/**************************************************************************** + * The section below is the "my" section of functions. + * These are designed to be extremely simple version specific + * variants of the libav functions. + ****************************************************************************/ +#if (LIBAVFORMAT_VERSION_MAJOR >= 55) || ((LIBAVFORMAT_VERSION_MAJOR == 54) && (LIBAVFORMAT_VERSION_MINOR > 6)) -/* Some forward-declarations. */ -int ffmpeg_put_frame(struct ffmpeg *, AVFrame *); -void ffmpeg_cleanups(struct ffmpeg *); -AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, - unsigned char *, unsigned char *); +#define MY_FLAG_READ AVIO_FLAG_READ +#define MY_FLAG_WRITE AVIO_FLAG_WRITE +#define MY_FLAG_READ_WRITE AVIO_FLAG_READ_WRITE -/* This is the trailer used to end mpeg1 videos. */ -static unsigned char mpeg1_trailer[] = {0x00, 0x00, 0x01, 0xb7}; +#else //Older versions +#define MY_FLAG_READ URL_RDONLY +#define MY_FLAG_WRITE URL_WRONLY +#define MY_FLAG_READ_WRITE URL_RDWR -// FFMPEG API changed in 0.8 -#if defined FF_API_NEW_AVIO +#endif +/*********************************************/ +#if (LIBAVFORMAT_VERSION_MAJOR >= 56) -// TODO +#define MY_CODEC_ID_MSMPEG4V2 AV_CODEC_ID_MSMPEG4V2 +#define MY_CODEC_ID_FLV1 AV_CODEC_ID_FLV1 +#define MY_CODEC_ID_FFV1 AV_CODEC_ID_FFV1 +#define MY_CODEC_ID_NONE AV_CODEC_ID_NONE - #else -/** - * file_open_append - * Append version of the file open function used in libavformat when opening - * an ordinary file. The original file open function truncates an existing - * file, but this version appends to it instead. - * - * Returns 0 on success and AVERROR(ENOENT) on error. - * - */ -static int file_open_append(URLContext *h, const char *filename, int flags) -{ - const char *colon; - const char *mode; - FILE *fh; - size_t bufsize = 0; - - /* Skip past the protocol part of filename. */ - colon = strchr(filename, ':'); - - if (colon) - filename = colon + 1; - - - if (flags & URL_RDWR) { - mode = "ab+"; - bufsize = BUFSIZE_1MEG; - } else if (flags & URL_WRONLY) { - mode = "ab"; - bufsize = BUFSIZE_1MEG; - } else { - mode = "rb"; - } +#define MY_CODEC_ID_MSMPEG4V2 CODEC_ID_MSMPEG4V2 +#define MY_CODEC_ID_FLV1 CODEC_ID_FLV1 +#define MY_CODEC_ID_FFV1 CODEC_ID_FFV1 +#define MY_CODEC_ID_NONE CODEC_ID_NONE - fh = myfopen(filename, mode, bufsize); - if (fh == NULL) - return AVERROR(ENOENT); - - h->priv_data = (void *)fh; - return 0; -} - -/* - * URLProtocol entry for the append file protocol, which we use for mpeg1 videos - * in order to get append behavior with url_fopen. - * - * Libavformat uses protocols for achieving flexibility when handling files - * and other resources. A call to url_fopen will eventually be redirected to - * a protocol-specific open function. - * - * The remaining functions (for writing, seeking etc.) are set in ffmpeg_init. - */ -URLProtocol mpeg1_file_protocol = { - .name = APPEND_PROTO, - .url_open = file_open_append -}; - - -#ifdef HAVE_FFMPEG_NEW - -/* file_procotol has been removed from avio.h */ -#ifdef FFMPEG_NEW_INCLUDES -#include -#else -#include "avstring.h" #endif - -#endif // HAVE_FFMPEG_NEW - -#endif // FF_API_NEW_AVIO -/**************************************************************************** - * The section below is the "my" section of functions. - * These are designed to be extremely simple version specific - * variants of the libav functions. - ****************************************************************************/ +/*********************************************/ AVFrame *my_frame_alloc(void){ AVFrame *pic; #if (LIBAVFORMAT_VERSION_MAJOR >= 55) @@ -167,7 +65,7 @@ AVFrame *my_frame_alloc(void){ #endif return pic; } - +/*********************************************/ void my_frame_free(AVFrame *frame){ #if (LIBAVFORMAT_VERSION_MAJOR >= 55) av_frame_free(&frame); @@ -177,27 +75,9 @@ void my_frame_free(AVFrame *frame){ av_freep(&frame); #endif } - /**************************************************************************** **************************************************************************** ****************************************************************************/ - -/** - * mpeg1_write_trailer - * We set AVOutputFormat->write_trailer to this function for mpeg1. That way, - * the mpeg1 video gets a proper trailer when it is closed. - * - * Returns 0 - * - */ -static int mpeg1_write_trailer(AVFormatContext *s) -{ - avio_write(s->pb, mpeg1_trailer, 4); - avio_flush(s->pb); - - return 0; /* success */ -} - /** * ffmpeg_init * Initializes for libavformat. @@ -208,17 +88,12 @@ static int mpeg1_write_trailer(AVFormatContext *s) void ffmpeg_init() { MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d" - " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, + " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD); av_register_all(); - -#if LIBAVCODEC_BUILD > 4680 av_log_set_callback((void *)ffmpeg_avcodec_log); av_log_set_level(AV_LOG_ERROR); -#endif - } - /** * get_oformat * Obtains the output format used for the specified codec. For mpeg4 codecs, @@ -235,104 +110,36 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) /* * Here, we use guess_format to automatically setup the codec information. * If we are using msmpeg4, manually set that codec here. - * We also dynamically add the file extension to the filename here. This was - * done to support both mpeg1 and mpeg4 codecs since they have different extensions. + * We also dynamically add the file extension to the filename here. */ - if ((strcmp(codec, TIMELAPSE_CODEC) == 0) -#ifndef FFMPEG_NO_NONSTD_MPEG1 - || (strcmp(codec, "mpeg1") == 0) -#endif - ) { - ext = ".mpg"; - /* - * We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would - * result in a muxed output file, which isn't appropriate here. - */ -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else - of = av_guess_format("mpeg1video", NULL, NULL); -#endif - /* But we want the trailer to be correctly written. */ - if (of) - of->write_trailer = mpeg1_write_trailer; - -#ifdef FFMPEG_NO_NONSTD_MPEG1 - } else if (strcmp(codec, "mpeg1") == 0) { - MOTION_LOG(WRN, TYPE_ENCODER, NO_ERRNO, "%s: *** mpeg1 support for normal" - " videos has been disabled ***"); - return NULL; -#endif + if (strcmp(codec, TIMELAPSE_CODEC) == 0){ + ext = ".avi"; + of = av_guess_format("avi", NULL, NULL); } else if (strcmp(codec, "mpeg4") == 0) { ext = ".avi"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else of = av_guess_format("avi", NULL, NULL); -#endif } else if (strcmp(codec, "msmpeg4") == 0) { ext = ".avi"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else of = av_guess_format("avi", NULL, NULL); -#endif /* Manually override the codec id. */ - if (of) -#if (LIBAVFORMAT_VERSION_MAJOR >= 56) - of->video_codec = AV_CODEC_ID_MSMPEG4V2; -#else - of->video_codec = CODEC_ID_MSMPEG4V2; -#endif + if (of) of->video_codec = MY_CODEC_ID_MSMPEG4V2; } else if (strcmp(codec, "swf") == 0) { ext = ".swf"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else of = av_guess_format("swf", NULL, NULL); -#endif } else if (strcmp(codec, "flv") == 0) { ext = ".flv"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else of = av_guess_format("flv", NULL, NULL); -#endif - of->video_codec = CODEC_ID_FLV1; + of->video_codec = MY_CODEC_ID_FLV1; } else if (strcmp(codec, "ffv1") == 0) { ext = ".avi"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else of = av_guess_format("avi", NULL, NULL); -#endif - /* - * Use the FFMPEG Lossless Video codec (experimental!). - * Requires strict_std_compliance to be <= -2 - */ - if (of) -#if (LIBAVFORMAT_VERSION_MAJOR >= 56) - of->video_codec = AV_CODEC_ID_FFV1; -#else - of->video_codec = CODEC_ID_FFV1; -#endif - + if (of) of->video_codec = MY_CODEC_ID_FFV1; } else if (strcmp(codec, "mov") == 0) { ext = ".mov"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format("mpeg1video", NULL, NULL); -#else of = av_guess_format("mov", NULL, NULL); -#endif - } - else if (strcmp (codec, "ogg") == 0) - { + } else if (strcmp (codec, "ogg") == 0){ ext = ".ogg"; -#ifdef GUESS_NO_DEPRECATED - of = guess_format ("ogg", NULL, NULL); -#else of = av_guess_format ("ogg", NULL, NULL); -#endif } else { MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg_video_codec option value" " %s is not supported", codec); @@ -350,7 +157,6 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) return of; } - /** * ffmpeg_open * Opens an mpeg file using the new libavformat method. Both mpeg1 @@ -368,7 +174,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, AVCodecContext *c; AVCodec *codec; struct ffmpeg *ffmpeg; - int is_mpeg1; int ret; /* * Allocate space for our ffmpeg structure. This structure contains all the @@ -385,11 +190,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); /* Allocation the output media context. */ -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) ffmpeg->oc = avformat_alloc_context(); -#else - ffmpeg->oc = av_alloc_format_context(); -#endif if (!ffmpeg->oc) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Memory error while allocating" @@ -408,13 +209,23 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(ffmpeg->oc->filename, sizeof(ffmpeg->oc->filename), "%s", filename); /* Create a new video stream and initialize the codecs. */ + + /* + * Now that all the parameters are set, we can open the video + * codec and allocate the necessary encode buffers. + */ + ffmpeg->video_st = NULL; -#if (LIBAVFORMAT_VERSION_MAJOR >= 56) - if (ffmpeg->oc->oformat->video_codec != AV_CODEC_ID_NONE) { -#else - if (ffmpeg->oc->oformat->video_codec != CODEC_ID_NONE) { -#endif - ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, NULL /* Codec */); + if (ffmpeg->oc->oformat->video_codec != MY_CODEC_ID_NONE) { + + codec = avcodec_find_encoder(ffmpeg->oc->oformat->video_codec); + if (!codec) { + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Codec %s not found", ffmpeg_video_codec); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + + ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, codec); if (!ffmpeg->video_st) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: av_new_stream - could" " not alloc stream"); @@ -431,16 +242,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); c->codec_id = ffmpeg->oc->oformat->video_codec; -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) c->codec_type = AVMEDIA_TYPE_VIDEO; -#else - c->codec_type = CODEC_TYPE_VIDEO; -#endif -#if (LIBAVFORMAT_VERSION_MAJOR >= 56) - is_mpeg1 = c->codec_id == AV_CODEC_ID_MPEG1VIDEO; -#else - is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; -#endif if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; @@ -452,26 +254,16 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->bit_rate = bps; c->width = width; c->height = height; -#if LIBAVCODEC_BUILD >= 4754 /* Frame rate = 1/time_base, so we set 1/rate, not rate/1 */ c->time_base.num = 1; c->time_base.den = rate; -#else - c->frame_rate = rate; - c->frame_rate_base = 1; -#endif /* LIBAVCODEC_BUILD >= 4754 */ - MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s FPS %d", - rate); + MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s FPS %d", rate); if (vbr) c->flags |= CODEC_FLAG_QSCALE; - /* - * Set codec specific parameters. - * Set intra frame distance in frames depending on codec. - */ - c->gop_size = is_mpeg1 ? 10 : 12; + c->gop_size = 12; /* Some formats want stream headers to be separate. */ if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || @@ -483,19 +275,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, /* Dump the format settings. This shows how the various streams relate to each other. */ //dump_format(ffmpeg->oc, 0, filename, 1); - /* - * Now that all the parameters are set, we can open the video - * codec and allocate the necessary encode buffers. - */ - codec = avcodec_find_encoder(c->codec_id); - - if (!codec) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Codec %s not found", - ffmpeg_video_codec); - ffmpeg_cleanups(ffmpeg); - return NULL; - } - /* Set the picture format - need in ffmpeg starting round April-May 2005 */ c->pix_fmt = PIX_FMT_YUV420P; @@ -543,7 +322,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, if (ffmpeg->vbr) ffmpeg->picture->quality = ffmpeg->vbr; - /* Set the frame data. */ ffmpeg->picture->data[0] = y; ffmpeg->picture->data[1] = u; @@ -556,21 +334,9 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { char file_proto[256]; - /* - * Use append file protocol for mpeg1, to get the append behavior from - * url_fopen, but no protocol (=> default) for other codecs. - */ - if (is_mpeg1) -#if defined FF_API_NEW_AVIO - snprintf(file_proto, sizeof(file_proto), "%s", filename); -#else - snprintf(file_proto, sizeof(file_proto), APPEND_PROTO ":%s", filename); -#endif - else - snprintf(file_proto, sizeof(file_proto), "%s", filename); - + snprintf(file_proto, sizeof(file_proto), "%s", filename); - if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { + if (avio_open(&ffmpeg->oc->pb, file_proto, MY_FLAG_WRITE) < 0) { /* Path did not exist? */ if (errno == ENOENT) { /* Create path for file (don't use file_proto)... */ @@ -579,7 +345,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, return NULL; } - if (avio_open(&ffmpeg->oc->pb, file_proto, URL_WRONLY) < 0) { + if (avio_open(&ffmpeg->oc->pb, file_proto, MY_FLAG_WRITE) < 0) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: url_fopen -" " error opening file %s", filename); ffmpeg_cleanups(ffmpeg); @@ -606,7 +372,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, avformat_write_header(ffmpeg->oc, NULL); return ffmpeg; } - /** * ffmpeg_cleanups * Clean up ffmpeg struct if something was wrong. @@ -616,32 +381,21 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, */ void ffmpeg_cleanups(struct ffmpeg *ffmpeg) { - unsigned int i; /* Close each codec */ if (ffmpeg->video_st) { pthread_mutex_lock(&global_lock); -#if LIBAVCODEC_BUILD > 4680 if (ffmpeg->video_st->codec->priv_data != NULL) -#endif avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); pthread_mutex_unlock(&global_lock); av_freep(&ffmpeg->picture); free(ffmpeg->video_outbuf); } - /* Free the streams */ - for (i = 0; i < ffmpeg->oc->nb_streams; i++) - av_freep(&ffmpeg->oc->streams[i]); - - /* Free the stream */ - av_free(ffmpeg->oc); -#if LIBAVFORMAT_BUILD >= 4629 - av_free(ffmpeg->c); -#endif + avcodec_close(ffmpeg->c); + avformat_free_context(ffmpeg->oc); free(ffmpeg); } - /** * ffmpeg_close * Closes a video file. @@ -651,7 +405,9 @@ void ffmpeg_cleanups(struct ffmpeg *ffmpeg) */ void ffmpeg_close(struct ffmpeg *ffmpeg) { - unsigned int i; + + /* Write the trailer, if any. */ + av_write_trailer(ffmpeg->oc); /* Close each codec */ if (ffmpeg->video_st) { @@ -662,27 +418,16 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) free(ffmpeg->video_outbuf); } - /* Write the trailer, if any. */ - av_write_trailer(ffmpeg->oc); - - /* Free the streams. */ - for (i = 0; i < ffmpeg->oc->nb_streams; i++) - av_freep(&ffmpeg->oc->streams[i]); - + avcodec_close(ffmpeg->c); if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { /* Close the output file. */ avio_close(ffmpeg->oc->pb); } - - /* Free the stream. */ - av_free(ffmpeg->oc); -#if LIBAVFORMAT_BUILD >= 4629 - av_free(ffmpeg->c); -#endif + avformat_free_context(ffmpeg->oc); free(ffmpeg); -} +} /** * ffmpeg_put_image * Puts the image pointed to by ffmpeg->picture. @@ -732,87 +477,96 @@ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, */ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) { - int out_size, ret; +/** + * Since the logic,return values and conditions changed so + * dramatically between versions, the encoding of the frame + * is 100% blocked based upon Libav/FFMpeg version + */ +#if (LIBAVFORMAT_VERSION_MAJOR >= 55) || ((LIBAVFORMAT_VERSION_MAJOR == 54) && (LIBAVFORMAT_VERSION_MINOR > 6)) + int retcd; + int got_packet_ptr; + AVPacket pkt; + + if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { + av_init_packet(&pkt); /* Init static structure. */ + pkt.stream_index = ffmpeg->video_st->index; + pkt.flags |= AV_PKT_FLAG_KEY; + pkt.data = (uint8_t *)pic; + pkt.size = sizeof(AVPicture); + retcd = av_write_frame(ffmpeg->oc, &pkt); + av_free_packet(&pkt); + } else { + av_init_packet(&pkt); + pkt.data = NULL; + retcd = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), + &pkt, pic, &got_packet_ptr); + if (retcd < 0 ){ + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video"); + //Packet is freed upon failure of encoding + return -1; + } + //No error returned, now check packet encoding status. + if (got_packet_ptr == 0){ + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video"); + av_free_packet(&pkt); + return -1; + } + + pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; + if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) + pkt.flags |= AV_PKT_FLAG_KEY; + + retcd = av_write_frame(ffmpeg->oc, &pkt); + av_free_packet(&pkt); + } + + if (retcd != 0) { + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error while writing video frame"); + ffmpeg_cleanups(ffmpeg); + return -1; + } + + return retcd; -#ifdef FFMPEG_AVWRITEFRAME_NEWAPI +#else // Old versions of Libav/FFmpeg + int retcd; AVPacket pkt; av_init_packet(&pkt); /* Init static structure. */ pkt.stream_index = ffmpeg->video_st->index; -#endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ - if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { - /* Raw video case. The API will change slightly in the near future for that. */ -#ifdef FFMPEG_AVWRITEFRAME_NEWAPI -# if LIBAVCODEC_VERSION_MAJOR < 53 - pkt.flags |= PKT_FLAG_KEY; -# else - pkt.flags |= AV_PKT_FLAG_KEY; -# endif - pkt.data = (uint8_t *)pic; + // Raw video case. pkt.size = sizeof(AVPicture); - ret = av_write_frame(ffmpeg->oc, &pkt); -#else - ret = av_write_frame(ffmpeg->oc, ffmpeg->video_st->index, - (uint8_t *)pic, sizeof(AVPicture)); -#endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ + pkt.data = (uint8_t *)pic; + pkt.flags |= AV_PKT_FLAG_KEY; } else { - /* Encodes the image. */ -#if defined FF_API_NEW_AVIO - - int got_packet_ptr; - pkt.data = ffmpeg->video_outbuf; - pkt.size = ffmpeg->video_outbuf_size; - - out_size = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), - &pkt, pic, &got_packet_ptr); - if (out_size < 0) - // Error encondig - out_size = 0; - else - out_size = pkt.size; -#else - out_size = avcodec_encode_video(AVSTREAM_CODEC_PTR(ffmpeg->video_st), + retcd = avcodec_encode_video(AVSTREAM_CODEC_PTR(ffmpeg->video_st), ffmpeg->video_outbuf, ffmpeg->video_outbuf_size, pic); -#endif - /* If zero size, it means the image was buffered. */ - if (out_size != 0) { - /* - * Writes the compressed frame in the media file. - * XXX: in case of B frames, the pts is not yet valid. - */ -#ifdef FFMPEG_AVWRITEFRAME_NEWAPI - pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; - - if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) -# if LIBAVCODEC_VERSION_MAJOR < 53 - pkt.flags |= PKT_FLAG_KEY; -# else - pkt.flags |= AV_PKT_FLAG_KEY; -# endif - - pkt.data = ffmpeg->video_outbuf; - pkt.size = out_size; - ret = av_write_frame(ffmpeg->oc, &pkt); -#else - ret = av_write_frame(ffmpeg->oc, ffmpeg->video_st->index, - ffmpeg->video_outbuf, out_size); -#endif /* FFMPEG_AVWRITEFRAME_NEWAPI */ - - } else { - ret = 0; + if (retcd <= 0 ){ + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video"); + av_free_packet(&pkt); + return -1; } + pkt.size = retcd; + pkt.data = ffmpeg->video_outbuf; + pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; + if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) + pkt.flags |= AV_PKT_FLAG_KEY; } - if (ret != 0) { - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error while writing" - " video frame"); + retcd = av_write_frame(ffmpeg->oc, &pkt); + av_free_packet(&pkt); + + if (retcd != 0) { + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error while writing video frame"); ffmpeg_cleanups(ffmpeg); return -1; } - return ret; + return retcd; + +#endif } /** @@ -851,48 +605,6 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y, return picture; } - - -/** - * ffmpeg_deinterlace - * Make the image suitable for deinterlacing using ffmpeg, then deinterlace the picture. - * - * Parameters - * img image in YUV420P format - * width image width in pixels - * height image height in pixels - * - * Returns - * Function returns nothing. - * img contains deinterlaced image - */ -void ffmpeg_deinterlace(unsigned char *img, int width, int height) -{ - AVPicture picture; - int width2 = width / 2; - - picture.data[0] = img; - picture.data[1] = img + width * height; - picture.data[2] = picture.data[1] + (width * height) / 4; - picture.linesize[0] = width; - picture.linesize[1] = width2; - picture.linesize[2] = width2; - - /* We assume using 'PIX_FMT_YUV420P' always */ -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) - MOTION_LOG(ALR, TYPE_NETCAM, NO_ERRNO, "%s: Deinterlace depreciated for recent versions of FFMPEG."); -#else - avpicture_deinterlace(&picture, &picture, PIX_FMT_YUV420P, width, height); -#endif - - -#if !defined(__SSE_MATH__) && (defined(__i386__) || defined(__x86_64__)) - __asm__ __volatile__ ( "emms"); -#endif - - return; -} - /** * ffmpeg_avcodec_log * Handle any logging output from the ffmpeg library avcodec. diff --git a/ffmpeg.h b/ffmpeg.h index c64fd9e..b32ebbb 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -2,37 +2,14 @@ #define _INCLUDE_FFMPEG_H_ #ifdef HAVE_FFMPEG -#include -#ifdef FFMPEG_NEW_INCLUDES +#include #include -#else -#include -#endif - -#ifndef AVERROR /* 0.4.8 & 0.4.9-pre1 */ - -#if EINVAL > 0 -#define AVERROR(e) (-(e)) -#define AVUNERROR(e) (-(e)) -#else -/* Some platforms have E* and errno already negated. */ -#define AVERROR(e) (e) -#define AVUNERROR(e) (e) -#endif - -#endif /* AVERROR */ - -#endif /* HAVE_FFMPEG */ - - #include #include -/* - * Define a codec name/identifier for timelapse videos, so that we can - * differentiate between normal mpeg1 videos and timelapse videos. - */ +#endif /* HAVE_FFMPEG */ + #define TIMELAPSE_CODEC "mpeg1_tl" struct ffmpeg { @@ -56,20 +33,14 @@ struct ffmpeg { /* Initialize FFmpeg stuff. Needs to be called before ffmpeg_open. */ void ffmpeg_init(void); -/* - * Open an mpeg file. This is a generic interface for opening either an mpeg1 or - * an mpeg4 video. If non-standard mpeg1 isn't supported (FFmpeg build > 4680), - * calling this function with "mpeg1" as codec results in an error. To create a - * timelapse video, use TIMELAPSE_CODEC as codec name. - */ struct ffmpeg *ffmpeg_open( - char *ffmpeg_video_codec, - char *filename, + char *ffmpeg_video_codec, + char *filename, unsigned char *y, /* YUV420 Y plane */ unsigned char *u, /* YUV420 U plane */ unsigned char *v, /* YUV420 V plane */ int width, - int height, + int height, int rate, /* framerate, fps */ int bps, /* bitrate; bits per second */ int vbr /* variable bitrate */ @@ -80,24 +51,25 @@ int ffmpeg_put_image(struct ffmpeg *); /* Puts the image defined by u, y and v (YUV420 format). */ int ffmpeg_put_other_image( - struct ffmpeg *ffmpeg, - unsigned char *y, - unsigned char *u, + struct ffmpeg *ffmpeg, + unsigned char *y, + unsigned char *u, unsigned char *v ); /* Closes the mpeg file. */ void ffmpeg_close(struct ffmpeg *); -/* Deinterlace the image. */ -void ffmpeg_deinterlace(unsigned char *, int, int); - /* Setup an avcodec log handler. */ void ffmpeg_avcodec_log(void *, int, const char *, va_list); #ifdef HAVE_FFMPEG AVFrame *my_frame_alloc(void); void my_frame_free(AVFrame *frame); +int ffmpeg_put_frame(struct ffmpeg *, AVFrame *); +void ffmpeg_cleanups(struct ffmpeg *); +AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, + unsigned char *, unsigned char *); #endif #endif /* _INCLUDE_FFMPEG_H_ */ diff --git a/motion.c b/motion.c index ceaa44d..d070f9f 100644 --- a/motion.c +++ b/motion.c @@ -1366,19 +1366,13 @@ static void *motion_loop(void *arg) } cnt->missing_frame_counter = 0; -#ifdef HAVE_FFMPEG - /* Deinterlace the image with ffmpeg, before the image is modified. */ - if (cnt->conf.ffmpeg_deinterlace) - ffmpeg_deinterlace(cnt->current_image->image, cnt->imgs.width, cnt->imgs.height); -#endif - - /* + /* * Save the newly captured still virgin image to a buffer * which we will not alter with text and location graphics */ memcpy(cnt->imgs.image_virgin, cnt->current_image->image, cnt->imgs.size); - /* + /* * If the camera is a netcam we let the camera decide the pace. * Otherwise we will keep on adding duplicate frames. * By resetting the timer the framerate becomes maximum the rate From 0961ece7abafc700e75b9efe15d11b7b42e6b447 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 25 Sep 2014 19:21:11 -0700 Subject: [PATCH 051/233] Add copyright file for added features since version 3.2.12 --- copyright | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 copyright diff --git a/copyright b/copyright new file mode 100644 index 0000000..64f3f51 --- /dev/null +++ b/copyright @@ -0,0 +1,47 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: motion +Source: http://motion.sourceforge.net/ +License: GPL-2+ + +Files: * +Copyright: 1999-2014 motion authors; see CREDITS for details +License: GPL-2+ + +Files: md5.* +Copyright: 1991-1992 RSA Data Security, Inc +License: custom-RSA + +Files: netcam_wget.* +Copyright: 1995-2002 Free Software Foundation, Inc. +License: GPL-2+ + +Files: mmx.h +Copyright: 1997-2001 H. Dietz and R. Fisher +License: GPL-2+ + +Files: debian/* +Copyright: 2000-2014 motion Debian packagers; see debian/changelog for details +License: GPL-2+ + +License: GPL-2+ + On Debian systems, the complete text of the GNU General Public + License can be found in the file /usr/share/common-licenses/GPL-2'. + +License: custom-RSA + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + . + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + . + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + . + These notices must be retained in any copies of any part of this + documentation and/or software. From bb8f34abbd9bddf4db86bca8fc8c11351f858018 Mon Sep 17 00:00:00 2001 From: tosiara Date: Thu, 2 Oct 2014 12:52:29 +0300 Subject: [PATCH 052/233] Release 3.4.0 --- CHANGELOG | 2 +- git-commit-version.sh | 4 ++-- version.sh | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5b3d285..6807a05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -SVN trunk Summary of Changes +3.4.0 Summary of Changes Features * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) diff --git a/git-commit-version.sh b/git-commit-version.sh index 2a47df1..1856aef 100755 --- a/git-commit-version.sh +++ b/git-commit-version.sh @@ -1,5 +1,5 @@ #!/bin/sh -SNV_VERSION=`git show -s --format=%H` -echo -n "Git-$SNV_VERSION" +SNV_VERSION=`git show -s --format=%h` +echo -n "3.4.0-Git-$SNV_VERSION" diff --git a/version.sh b/version.sh index 68dc73e..b19e219 100755 --- a/version.sh +++ b/version.sh @@ -3,4 +3,5 @@ SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` test $SNV_VERSION || SNV_VERSION=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` test $SNV_VERSION || SNV_VERSION=UNKNOWN -echo -n "trunkREV$SNV_VERSION" +SNV_VERSION=`git show -s --format=%h` +echo -n "3.4.0-Git-$SNV_VERSION" From 80c2759726fe3a02cdb9f99e1a63d0655e4ed83d Mon Sep 17 00:00:00 2001 From: tosiara Date: Thu, 2 Oct 2014 13:33:08 +0300 Subject: [PATCH 053/233] Added 3.4 to CHANGELOG --- CHANGELOG | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 28dfd80..7199066 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,18 @@ - * +Summary of Changes + + * Revise version.sh to put out the git commit. + * Rollback revision to allow for a formal pull request. + * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 + * Implement requirement of modulo 16 to avoid seg fault when opening stream + * Add debian build files from trusty(14.04) + * Revise default values for motion.conf + * Revise CHANGELOG to conform with debian format * Revised debian packaging files * Implement new sequence for this file (CHANGELOG) newest to oldest. - * - * Features + +3.4.0 Summary of Changes + +Features * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) * IPV6 for http-control and webcam stream not netcam yet http://www.lavrsen.dk/twiki/bin/view/Motion/IPv6 (Jeroen Massar & Angel Carpintero) @@ -84,15 +94,8 @@ * Added tcp/udp transport config option from hyperbolic2346(commit 423ef7bb3) * Revised comments to be in line with application standard. * Restructure rtsp to handle rescaling and non YUV420 format, rotate, MJPEG input format - * Revise version.sh to put out the git commit. - * Rollback revision to allow for a formal pull request. - * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 - * Implement requirement of modulo 16 to avoid seg fault when opening stream - * Add debian build files from trusty(14.04) - * Revise default values for motion.conf - * Revise CHANGELOG to conform with debian format - * Bugfixes +Bugfixes * Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero) * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2009x06x17x090603 @@ -140,7 +143,7 @@ Bugfixes http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x28x054348 -3.2.11.1 Sumary of Changes +3.2.11.1 Summary of Changes Bugfixes * Fix Segfault on reload or quit for vloopback (maybe other v4l1 devices too) (Peter Holik) From 6894861024a1e2d93ee7a23f038029552696d032 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 2 Oct 2014 20:41:31 -0700 Subject: [PATCH 054/233] Add copyright to the 3.4 branch --- copyright | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 copyright diff --git a/copyright b/copyright new file mode 100644 index 0000000..64f3f51 --- /dev/null +++ b/copyright @@ -0,0 +1,47 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: motion +Source: http://motion.sourceforge.net/ +License: GPL-2+ + +Files: * +Copyright: 1999-2014 motion authors; see CREDITS for details +License: GPL-2+ + +Files: md5.* +Copyright: 1991-1992 RSA Data Security, Inc +License: custom-RSA + +Files: netcam_wget.* +Copyright: 1995-2002 Free Software Foundation, Inc. +License: GPL-2+ + +Files: mmx.h +Copyright: 1997-2001 H. Dietz and R. Fisher +License: GPL-2+ + +Files: debian/* +Copyright: 2000-2014 motion Debian packagers; see debian/changelog for details +License: GPL-2+ + +License: GPL-2+ + On Debian systems, the complete text of the GNU General Public + License can be found in the file /usr/share/common-licenses/GPL-2'. + +License: custom-RSA + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + . + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + . + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + . + These notices must be retained in any copies of any part of this + documentation and/or software. From b6f73ffccb845f2ad265710b585577b3973eec29 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sun, 5 Oct 2014 05:31:47 -0700 Subject: [PATCH 055/233] Timelapse fixes and bump version --- configure | 271 ++++++++++--------- event.c | 31 ++- ffmpeg.c | 358 +++++++++++++----------- ffmpeg.h | 8 +- motion-dist.conf.in | 24 +- motion.c | 645 ++++++++++++++++++++++---------------------- version.sh | 2 +- 7 files changed, 708 insertions(+), 631 deletions(-) diff --git a/configure b/configure index d6d7ee5..cba5c78 100755 --- a/configure +++ b/configure @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for motion trunkREVUNKNOWN. +# Generated by GNU Autoconf 2.69 for motion 3.4.0-Git-d35a11e. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -134,6 +132,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -212,21 +236,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -328,6 +356,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -449,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -483,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -504,28 +544,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -557,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='trunkREVUNKNOWN' -PACKAGE_STRING='motion trunkREVUNKNOWN' +PACKAGE_VERSION='3.4.0-Git-d35a11e' +PACKAGE_STRING='motion 3.4.0-Git-d35a11e' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1141,8 +1161,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1228,7 +1246,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 trunkREVUNKNOWN to adapt to many kinds of systems. +\`configure' configures motion 3.4.0-Git-d35a11e to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1289,7 +1307,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion trunkREVUNKNOWN:";; + short | recursive ) echo "Configuration of motion 3.4.0-Git-d35a11e:";; esac cat <<\_ACEOF @@ -1439,10 +1457,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure trunkREVUNKNOWN -generated by GNU Autoconf 2.68 +motion configure 3.4.0-Git-d35a11e +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1715,7 +1733,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1872,7 +1890,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1888,7 +1907,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1914,7 +1934,8 @@ int main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1930,7 +1951,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -1964,7 +1986,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2036,8 +2059,8 @@ 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 trunkREVUNKNOWN, which was -generated by GNU Autoconf 2.68. Invocation command line was +It was created by motion $as_me 3.4.0-Git-d35a11e, which was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2406,7 +2429,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2446,7 +2469,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2499,7 +2522,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2540,7 +2563,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2598,7 +2621,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2642,7 +2665,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3088,8 +3111,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3329,7 +3351,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3395,7 +3417,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3602,8 +3624,8 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -3659,7 +3681,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3699,7 +3721,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3752,7 +3774,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3793,7 +3815,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3851,7 +3873,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3895,7 +3917,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4091,8 +4113,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4284,7 +4305,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4324,7 +4345,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4377,7 +4398,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4418,7 +4439,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -4476,7 +4497,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4520,7 +4541,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4716,8 +4737,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -6432,11 +6452,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -6453,8 +6473,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -6470,10 +6491,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -7196,16 +7217,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -7265,28 +7286,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -7307,8 +7316,8 @@ 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 trunkREVUNKNOWN, which was -generated by GNU Autoconf 2.68. Invocation command line was +This file was extended by motion $as_me 3.4.0-Git-d35a11e, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -7369,11 +7378,11 @@ _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 trunkREVUNKNOWN -configured by $0, generated by GNU Autoconf 2.68, +motion config.status 3.4.0-Git-d35a11e +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -7461,7 +7470,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/event.c b/event.c index f8a7d28..31566ec 100644 --- a/event.c +++ b/event.c @@ -178,8 +178,8 @@ static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, 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, + + // 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); @@ -194,7 +194,7 @@ static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, } 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 */ @@ -585,7 +585,7 @@ static void event_ffmpeg_newfile(struct context *cnt, int type ATTRIBUTE_UNUSED, if ((cnt->ffmpeg_output = ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->newfilename, y, u, v, cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, - cnt->conf.ffmpeg_vbr)) == NULL) { + cnt->conf.ffmpeg_vbr,TIMELAPSE_NONE)) == NULL) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (new) file [%s]", cnt->newfilename); cnt->finish = 1; @@ -613,7 +613,7 @@ static void event_ffmpeg_newfile(struct context *cnt, int type ATTRIBUTE_UNUSED, if ((cnt->ffmpeg_output_debug = ffmpeg_open((char *)cnt->conf.ffmpeg_video_codec, cnt->motionfilename, y, u, v, cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, - cnt->conf.ffmpeg_vbr)) == NULL) { + cnt->conf.ffmpeg_vbr,TIMELAPSE_NONE)) == NULL) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (motion) file [%s]", cnt->motionfilename); cnt->finish = 1; @@ -665,10 +665,23 @@ static void event_ffmpeg_timelapse(struct context *cnt, v = u + (width * height) / 4; } - if ((cnt->ffmpeg_timelapse = - ffmpeg_open((char *)TIMELAPSE_CODEC, cnt->timelapsefilename, y, u, v, - cnt->imgs.width, cnt->imgs.height, 24, cnt->conf.ffmpeg_bps, - cnt->conf.ffmpeg_vbr)) == NULL) { + if (strcmp(cnt->conf.ffmpeg_video_codec,"swf") == 0) { + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using swf codec."); + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be appended to file"); + cnt->ffmpeg_timelapse = + ffmpeg_open("swf",cnt->timelapsefilename, y, u, v + ,cnt->imgs.width, cnt->imgs.height, 24 + ,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_APPEND); + } else { + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using mpeg4 codec."); + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be trigger new files"); + cnt->ffmpeg_timelapse = + ffmpeg_open("mpeg4",cnt->timelapsefilename, y, u, v + ,cnt->imgs.width, cnt->imgs.height, 1 + ,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_NEW); + } + + if (cnt->ffmpeg_timelapse == NULL){ MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating " "(timelapse) file [%s]", cnt->timelapsefilename); cnt->finish = 1; diff --git a/ffmpeg.c b/ffmpeg.c index 8216bf1..a80c137 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -78,6 +78,36 @@ void my_frame_free(AVFrame *frame){ /**************************************************************************** **************************************************************************** ****************************************************************************/ +/** + * timelapse_exists + * Determines whether the timelapse file exists + * + * Returns + * 0: File doesn't exist + * 1: File exists + */ +int timelapse_exists(const char *fname){ + FILE *file; + file = fopen(fname, "r"); + if (file) + { + fclose(file); + return 1; + } + return 0; +} +int timelapse_append(struct ffmpeg *ffmpeg, AVPacket pkt){ + FILE *file; + + file = fopen(ffmpeg->oc->filename, "a"); + if (!file) return -1; + + fwrite(pkt.data,1,pkt.size,file); + + fclose(file); + + return 0; +} /** * ffmpeg_init * Initializes for libavformat. @@ -85,12 +115,12 @@ void my_frame_free(AVFrame *frame){ * Returns * Function returns nothing. */ -void ffmpeg_init() -{ +void ffmpeg_init(){ MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d" " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD); av_register_all(); + avcodec_register_all(); av_log_set_callback((void *)ffmpeg_avcodec_log); av_log_set_level(AV_LOG_ERROR); } @@ -103,8 +133,7 @@ void ffmpeg_init() * Returns * AVOutputFormat pointer or NULL if any error happens. */ -static AVOutputFormat *get_oformat(const char *codec, char *filename) -{ +static AVOutputFormat *get_oformat(const char *codec, char *filename){ const char *ext; AVOutputFormat *of = NULL; /* @@ -112,9 +141,10 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) * If we are using msmpeg4, manually set that codec here. * We also dynamically add the file extension to the filename here. */ - if (strcmp(codec, TIMELAPSE_CODEC) == 0){ - ext = ".avi"; - of = av_guess_format("avi", NULL, NULL); + if (strcmp(codec, "tlapse") == 0) { + ext = ".swf"; + of = av_guess_format("swf", NULL, NULL); + if (of) of->video_codec = AV_CODEC_ID_MPEG2VIDEO; } else if (strcmp(codec, "mpeg4") == 0) { ext = ".avi"; of = av_guess_format("avi", NULL, NULL); @@ -147,8 +177,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) } if (!of) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not guess format for %s", - codec); + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not guess format for %s", codec); return NULL; } @@ -169,22 +198,22 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename) */ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, unsigned char *y, unsigned char *u, unsigned char *v, - int width, int height, int rate, int bps, int vbr) + int width, int height, int rate, int bps, int vbr, int tlapse) { AVCodecContext *c; AVCodec *codec; struct ffmpeg *ffmpeg; int ret; + char errstr[128]; /* * Allocate space for our ffmpeg structure. This structure contains all the * codec and image information we need to generate movies. - * FIXME when motion exits we should close the movie to ensure that - * ffmpeg is freed. */ ffmpeg = mymalloc(sizeof(struct ffmpeg)); memset(ffmpeg, 0, sizeof(struct ffmpeg)); ffmpeg->vbr = vbr; + ffmpeg->tlapse = tlapse; /* Store codec name in ffmpeg->codec, with buffer overflow check. */ snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); @@ -193,14 +222,17 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->oc = avformat_alloc_context(); if (!ffmpeg->oc) { - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Memory error while allocating" - " output media context"); + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not allocate output context"); ffmpeg_cleanups(ffmpeg); return NULL; } /* Setup output format */ - ffmpeg->oc->oformat = get_oformat(ffmpeg_video_codec, filename); + if (ffmpeg->tlapse == TIMELAPSE_APPEND){ + ffmpeg->oc->oformat = get_oformat("tlapse", filename); + } else { + ffmpeg->oc->oformat = get_oformat(ffmpeg_video_codec, filename); + } if (!ffmpeg->oc->oformat) { ffmpeg_cleanups(ffmpeg); return NULL; @@ -208,13 +240,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, snprintf(ffmpeg->oc->filename, sizeof(ffmpeg->oc->filename), "%s", filename); - /* Create a new video stream and initialize the codecs. */ - - /* - * Now that all the parameters are set, we can open the video - * codec and allocate the necessary encode buffers. - */ - ffmpeg->video_st = NULL; if (ffmpeg->oc->oformat->video_codec != MY_CODEC_ID_NONE) { @@ -227,15 +252,13 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->video_st = avformat_new_stream(ffmpeg->oc, codec); if (!ffmpeg->video_st) { - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: av_new_stream - could" - " not alloc stream"); + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Could not alloc stream"); ffmpeg_cleanups(ffmpeg); return NULL; } } else { /* We did not get a proper video codec. */ - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Failed to obtain a proper" - " video codec"); + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not get the codec"); ffmpeg_cleanups(ffmpeg); return NULL; } @@ -243,77 +266,62 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); c->codec_id = ffmpeg->oc->oformat->video_codec; c->codec_type = AVMEDIA_TYPE_VIDEO; - - if (strcmp(ffmpeg_video_codec, "ffv1") == 0) - c->strict_std_compliance = -2; - - /* Uncomment to allow non-standard framerates. */ - //c->strict_std_compliance = -1; - - /* Set default parameters */ - c->bit_rate = bps; - c->width = width; - c->height = height; - /* Frame rate = 1/time_base, so we set 1/rate, not rate/1 */ + c->bit_rate = bps; + c->width = width; + c->height = height; c->time_base.num = 1; c->time_base.den = rate; + c->gop_size = 0; + c->pix_fmt = PIX_FMT_YUV420P; + c->max_b_frames = 0; - MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s FPS %d", rate); - - if (vbr) - c->flags |= CODEC_FLAG_QSCALE; - - c->gop_size = 12; - - /* Some formats want stream headers to be separate. */ + if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; + if (vbr) c->flags |= CODEC_FLAG_QSCALE; if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || !strcmp(ffmpeg->oc->oformat->name, "mov") || !strcmp(ffmpeg->oc->oformat->name, "3gp")) { c->flags |= CODEC_FLAG_GLOBAL_HEADER; } - /* Dump the format settings. This shows how the various streams relate to each other. */ - //dump_format(ffmpeg->oc, 0, filename, 1); - - /* Set the picture format - need in ffmpeg starting round April-May 2005 */ - c->pix_fmt = PIX_FMT_YUV420P; - - /* Get a mutex lock. */ pthread_mutex_lock(&global_lock); - - /* Open the codec */ - ret = avcodec_open2(c, codec, NULL /* options */ ); - + ret = avcodec_open2(c, codec, NULL); + pthread_mutex_unlock(&global_lock); if (ret < 0) { - /* Release the lock. */ + if (codec->supported_framerates) { + const AVRational *fps = codec->supported_framerates; + while (fps->num) { + MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Reported FPS Supported %d/%d", fps->num, fps->den); + fps++; + } + } + int chkrate = 1; + pthread_mutex_lock(&global_lock); + while ((chkrate < 36) && (ret != 0)) { + c->time_base.den = chkrate; + ret = avcodec_open2(c, codec, NULL); + chkrate++; + } pthread_mutex_unlock(&global_lock); - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_open - could not open codec %s", - ffmpeg_video_codec); - ffmpeg_cleanups(ffmpeg); - return NULL; - } + if (ret < 0){ + av_strerror(ret, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not open codec %s",errstr); + ffmpeg_cleanups(ffmpeg); + return NULL; + } - /* Release the lock. */ - pthread_mutex_unlock(&global_lock); + } + MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Selected Output FPS %d", c->time_base.den); ffmpeg->video_outbuf = NULL; - if (!(ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE)) { - /* - * Allocate output buffer - * XXX: API change will be done - * ffmpeg->video_outbuf_size = 200000 - */ ffmpeg->video_outbuf_size = ffmpeg->c->width * 512; ffmpeg->video_outbuf = mymalloc(ffmpeg->video_outbuf_size); } - /* Allocate the encoded raw picture. */ ffmpeg->picture = my_frame_alloc(); if (!ffmpeg->picture) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: avcodec_alloc_frame -" - " could not alloc frame"); + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: could not alloc frame"); ffmpeg_cleanups(ffmpeg); return NULL; } @@ -330,46 +338,43 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, ffmpeg->picture->linesize[1] = ffmpeg->c->width / 2; ffmpeg->picture->linesize[2] = ffmpeg->c->width / 2; - /* Open the output file, if needed. */ - if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { - char file_proto[256]; - - snprintf(file_proto, sizeof(file_proto), "%s", filename); - if (avio_open(&ffmpeg->oc->pb, file_proto, MY_FLAG_WRITE) < 0) { - /* Path did not exist? */ - if (errno == ENOENT) { - /* Create path for file (don't use file_proto)... */ - if (create_path(filename) == -1) { + /* Open the output file, if needed. */ + if ((timelapse_exists(filename) == 0) || (ffmpeg->tlapse != TIMELAPSE_APPEND)) { + if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { + if (avio_open(&ffmpeg->oc->pb, filename, MY_FLAG_WRITE) < 0) { + if (errno == ENOENT) { + if (create_path(filename) == -1) { + ffmpeg_cleanups(ffmpeg); + return NULL; + } + if (avio_open(&ffmpeg->oc->pb, filename, MY_FLAG_WRITE) < 0) { + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: error opening file %s", filename); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + /* Permission denied */ + } else if (errno == EACCES) { + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO,"%s: Permission denied. %s",filename); ffmpeg_cleanups(ffmpeg); return NULL; - } - - if (avio_open(&ffmpeg->oc->pb, file_proto, MY_FLAG_WRITE) < 0) { - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: url_fopen -" - " error opening file %s", filename); + } else { + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error opening file %s", filename); ffmpeg_cleanups(ffmpeg); return NULL; } - /* Permission denied */ - } else if (errno == EACCES) { - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, - "%s: url_fopen - error opening file %s" - " ... check access rights to target directory", - filename); - ffmpeg_cleanups(ffmpeg); - return NULL; - } else { - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error opening file %s", - filename); - ffmpeg_cleanups(ffmpeg); - return NULL; } } + /* Write the stream header, For the TIMELAPSE_APPEND + * we write the data via standard file I/O so we close the + * items here + */ + avformat_write_header(ffmpeg->oc, NULL); + if (ffmpeg->tlapse == TIMELAPSE_APPEND) { + av_write_trailer(ffmpeg->oc); + avio_close(ffmpeg->oc->pb); + } } - - /* Write the stream header, if any. */ - avformat_write_header(ffmpeg->oc, NULL); return ffmpeg; } /** @@ -379,20 +384,16 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, * Returns * Function returns nothing. */ -void ffmpeg_cleanups(struct ffmpeg *ffmpeg) -{ +void ffmpeg_cleanups(struct ffmpeg *ffmpeg){ /* Close each codec */ if (ffmpeg->video_st) { pthread_mutex_lock(&global_lock); - if (ffmpeg->video_st->codec->priv_data != NULL) - avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); + avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); pthread_mutex_unlock(&global_lock); - av_freep(&ffmpeg->picture); - free(ffmpeg->video_outbuf); } - - avcodec_close(ffmpeg->c); + free(ffmpeg->video_outbuf); + av_freep(&ffmpeg->picture); avformat_free_context(ffmpeg->oc); free(ffmpeg); } @@ -403,27 +404,25 @@ void ffmpeg_cleanups(struct ffmpeg *ffmpeg) * Returns * Function returns nothing. */ -void ffmpeg_close(struct ffmpeg *ffmpeg) -{ - - /* Write the trailer, if any. */ - av_write_trailer(ffmpeg->oc); +void ffmpeg_close(struct ffmpeg *ffmpeg){ + if (ffmpeg->tlapse != TIMELAPSE_APPEND) { + av_write_trailer(ffmpeg->oc); + } /* Close each codec */ if (ffmpeg->video_st) { pthread_mutex_lock(&global_lock); avcodec_close(AVSTREAM_CODEC_PTR(ffmpeg->video_st)); pthread_mutex_unlock(&global_lock); - av_freep(&ffmpeg->picture); - free(ffmpeg->video_outbuf); } + av_freep(&ffmpeg->picture); + free(ffmpeg->video_outbuf); - avcodec_close(ffmpeg->c); if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { - /* Close the output file. */ - avio_close(ffmpeg->oc->pb); + if (ffmpeg->tlapse != TIMELAPSE_APPEND) { + avio_close(ffmpeg->oc->pb); + } } - avformat_free_context(ffmpeg->oc); free(ffmpeg); @@ -435,11 +434,33 @@ void ffmpeg_close(struct ffmpeg *ffmpeg) * Returns * value returned by ffmpeg_put_frame call. */ -int ffmpeg_put_image(struct ffmpeg *ffmpeg) -{ - return ffmpeg_put_frame(ffmpeg, ffmpeg->picture); -} +int ffmpeg_put_image(struct ffmpeg *ffmpeg){ + /* A return code of -2 is thrown by the put_frame + * when a image is buffered. For timelapse, we absolutely + * never want a frame buffered so we keep sending back the + * the same pic until it flushes or fails in a different way + */ + int retcd; + int cnt = 0; + + retcd = ffmpeg_put_frame(ffmpeg, ffmpeg->picture); + while ((retcd == -2) && (ffmpeg->tlapse != TIMELAPSE_NONE)) { + retcd = ffmpeg_put_frame(ffmpeg, ffmpeg->picture); + cnt++; + if (cnt > 50){ + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Excessive attempts to clear buffered packet"); + retcd = -1; + } + } + //non timelapse buffered is ok + if (retcd == -2){ + retcd = 0; + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); + } + + return retcd; +} /** * ffmpeg_put_other_image * Puts an arbitrary picture defined by y, u and v. @@ -450,23 +471,39 @@ int ffmpeg_put_image(struct ffmpeg *ffmpeg) * 0 if error allocating picture. */ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, - unsigned char *u, unsigned char *v) -{ + unsigned char *u, unsigned char *v){ AVFrame *picture; - int ret = 0; + int retcd = 0; + int cnt = 0; /* Allocate the encoded raw picture. */ picture = ffmpeg_prepare_frame(ffmpeg, y, u, v); if (picture) { - ret = ffmpeg_put_frame(ffmpeg, picture); - if (!ret) - av_free(picture); + /* A return code of -2 is thrown by the put_frame + * when a image is buffered. For timelapse, we absolutely + * never want a frame buffered so we keep sending back the + * the same pic until it flushes or fails in a different way + */ + retcd = ffmpeg_put_frame(ffmpeg, picture); + while ((retcd == -2) && (ffmpeg->tlapse != TIMELAPSE_NONE)) { + retcd = ffmpeg_put_frame(ffmpeg, picture); + cnt++; + if (cnt > 50){ + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Excessive attempts to clear buffered packet"); + retcd = -1; + } + } + //non timelapse buffered is ok + if (retcd == -2){ + retcd = 0; + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); + } + av_free(picture); } - return ret; + return retcd; } - /** * ffmpeg_put_frame * Encodes and writes a video frame using the av_write_frame API. This is @@ -475,8 +512,7 @@ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, * Returns * Number of bytes written or -1 if any error happens. */ -int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) -{ +int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ /** * Since the logic,return values and conditions changed so * dramatically between versions, the encoding of the frame @@ -486,39 +522,40 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) int retcd; int got_packet_ptr; AVPacket pkt; + char errstr[128]; + av_init_packet(&pkt); /* Init static structure. */ if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { - av_init_packet(&pkt); /* Init static structure. */ - pkt.stream_index = ffmpeg->video_st->index; - pkt.flags |= AV_PKT_FLAG_KEY; - pkt.data = (uint8_t *)pic; - pkt.size = sizeof(AVPicture); - retcd = av_write_frame(ffmpeg->oc, &pkt); - av_free_packet(&pkt); + pkt.stream_index = ffmpeg->video_st->index; + pkt.flags |= AV_PKT_FLAG_KEY; + pkt.data = (uint8_t *)pic; + pkt.size = sizeof(AVPicture); } else { - av_init_packet(&pkt); pkt.data = NULL; + pkt.size = 0; retcd = avcodec_encode_video2(AVSTREAM_CODEC_PTR(ffmpeg->video_st), &pkt, pic, &got_packet_ptr); if (retcd < 0 ){ - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video"); + av_strerror(retcd, errstr, sizeof(errstr)); + MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video:%s",errstr); //Packet is freed upon failure of encoding return -1; } - //No error returned, now check packet encoding status. if (got_packet_ptr == 0){ - MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video"); + //Buffered packet. Throw special return code av_free_packet(&pkt); - return -1; + return -2; } - pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) pkt.flags |= AV_PKT_FLAG_KEY; - + } + if (ffmpeg->tlapse == TIMELAPSE_APPEND) { + retcd = timelapse_append(ffmpeg, pkt); + } else { retcd = av_write_frame(ffmpeg->oc, &pkt); - av_free_packet(&pkt); } + av_free_packet(&pkt); if (retcd != 0) { MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error while writing video frame"); @@ -543,19 +580,28 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic) retcd = avcodec_encode_video(AVSTREAM_CODEC_PTR(ffmpeg->video_st), ffmpeg->video_outbuf, ffmpeg->video_outbuf_size, pic); - if (retcd <= 0 ){ + if (retcd < 0 ){ MOTION_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO, "%s: Error encoding video"); av_free_packet(&pkt); return -1; } + if (retcd == 0 ){ + // No bytes encoded => buffered=>special handling + av_free_packet(&pkt); + return -2; + } + pkt.size = retcd; pkt.data = ffmpeg->video_outbuf; pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) pkt.flags |= AV_PKT_FLAG_KEY; } - - retcd = av_write_frame(ffmpeg->oc, &pkt); + if (ffmpeg->tlapse == TIMELAPSE_APPEND) { + retcd = timelapse_append(ffmpeg, pkt); + } else { + retcd = av_write_frame(ffmpeg->oc, &pkt); + } av_free_packet(&pkt); if (retcd != 0) { diff --git a/ffmpeg.h b/ffmpeg.h index b32ebbb..25dbdaf 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -10,7 +10,9 @@ #endif /* HAVE_FFMPEG */ -#define TIMELAPSE_CODEC "mpeg1_tl" +#define TIMELAPSE_NONE 0 /* No timelapse, regular processing */ +#define TIMELAPSE_APPEND 1 /* Use append version of timelapse */ +#define TIMELAPSE_NEW 2 /* Use create new file version of timelapse */ struct ffmpeg { #ifdef HAVE_FFMPEG @@ -25,6 +27,7 @@ struct ffmpeg { void *udata; /* U & V planes for greyscale images */ int vbr; /* variable bitrate setting */ char codec[20]; /* codec name */ + int tlapse; #else int dummy; #endif @@ -43,7 +46,8 @@ struct ffmpeg *ffmpeg_open( int height, int rate, /* framerate, fps */ int bps, /* bitrate; bits per second */ - int vbr /* variable bitrate */ + int vbr, /* variable bitrate */ + int tlapse ); /* Puts the image pointed to by the picture member of struct ffmpeg. */ diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 1f93f08..21a0570 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -287,7 +287,7 @@ ffmpeg_timelapse_mode daily # Bitrate to be used by the ffmpeg encoder (default: 400000) # This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) -ffmpeg_bps 500000 +ffmpeg_bps 400000 # Enables and defines variable bitrate for the ffmpeg encoder. # ffmpeg_bps is ignored if variable bitrate is enabled. @@ -296,9 +296,14 @@ ffmpeg_bps 500000 ffmpeg_variable_bitrate 0 # Codec to used by ffmpeg for the video compression. -# Timelapse mpegs are always made in mpeg1 format independent from this option. -# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. -# mpeg1 - gives you files with extension .mpg +# Timelapse videos have two options. +# swf - Creates swf file with mpeg-2 encoding. +# If motion is shutdown and restarted, new pics will be appended +# to any previously created file with name indicated for timelapse. +# mpeg4 - Creates avi file with the default encoding. +# If motion is shutdown and restarted, new pics will create a +# new file with the name indicated for timelapse. +# Supported formats are: # mpeg4 or msmpeg4 - gives you files with extension .avi # msmpeg4 is recommended for use with Windows Media Player because # it requires no installation of codec on the Windows client. @@ -441,17 +446,12 @@ picture_filename %v-%Y%m%d%H%M%S-%q # File path for motion triggered ffmpeg films (movies) relative to target_dir # Default: %v-%Y%m%d%H%M%S -# Default value is equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S -# File extension .mpg or .avi is automatically added so do not include this -# This option was previously called ffmpeg_filename +# File extensions(.swf .avi) are automatically added so do not include them movie_filename %v-%Y%m%d%H%M%S # File path for timelapse movies relative to target_dir # Default: %Y%m%d-timelapse -# Default value is near equivalent to legacy oldlayout option -# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse -# File extension .mpg is automatically added so do not include this +# File extensions(.swf .avi) are automatically added so do not include them timelapse_filename %Y%m%d-timelapse ############################################################ @@ -661,7 +661,7 @@ quiet on # %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)); # diff --git a/motion.c b/motion.c index d070f9f..f8f5dc5 100644 --- a/motion.c +++ b/motion.c @@ -9,7 +9,7 @@ #include "ffmpeg.h" #include "motion.h" -#if (defined(BSD) && !defined(PWCBSD)) +#if (defined(BSD) && !defined(PWCBSD)) #include "video_freebsd.h" #else #include "video.h" @@ -61,7 +61,7 @@ volatile int threads_running = 0; /* Set this when we want main to end or restart */ volatile unsigned int finish = 0; -/* Log file used instead of stderr and syslog */ +/* Log file used instead of stderr and syslog */ FILE *ptr_logfile = NULL; /** @@ -78,7 +78,7 @@ unsigned int restart = 0; * * This routine is called from motion_loop to resize the image precapture ringbuffer * NOTE: This function clears all images in the old ring buffer - + * Parameters: * * cnt Pointer to the motion context structure @@ -88,12 +88,12 @@ unsigned int restart = 0; */ static void image_ring_resize(struct context *cnt, int new_size) { - /* + /* * Only resize if : * Not in an event and * decreasing at last position in new buffer - * increasing at last position in old buffer - * e.g. at end of smallest buffer + * increasing at last position in old buffer + * e.g. at end of smallest buffer */ if (cnt->event_nr != cnt->prev_event) { int smallest; @@ -102,7 +102,7 @@ static void image_ring_resize(struct context *cnt, int new_size) smallest = new_size; else /* Increasing */ smallest = cnt->imgs.image_ring_size; - + if (cnt->imgs.image_ring_in == smallest - 1 || smallest == 0) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Resizing pre_capture buffer to %d items", new_size); @@ -111,13 +111,13 @@ static void image_ring_resize(struct context *cnt, int new_size) struct image_data *tmp; tmp = mymalloc(new_size * sizeof(struct image_data)); - /* - * Copy all information from old to new - * Smallest is 0 at initial init + /* + * Copy all information from old to new + * Smallest is 0 at initial init */ - if (smallest > 0) + if (smallest > 0) memcpy(tmp, cnt->imgs.image_ring, sizeof(struct image_data) * smallest); - + /* In the new buffers, allocate image memory */ { @@ -127,7 +127,7 @@ static void image_ring_resize(struct context *cnt, int new_size) memset(tmp[i].image, 0x80, cnt->imgs.size); /* initialize to grey */ } } - + /* Free the old ring */ free(cnt->imgs.image_ring); @@ -153,16 +153,16 @@ static void image_ring_resize(struct context *cnt, int new_size) static void image_ring_destroy(struct context *cnt) { int i; - + /* Exit if don't have any ring */ if (cnt->imgs.image_ring == NULL) return; /* Free all image buffers */ - for (i = 0; i < cnt->imgs.image_ring_size; i++) + for (i = 0; i < cnt->imgs.image_ring_size; i++) free(cnt->imgs.image_ring[i].image); - - + + /* Free the ring */ free(cnt->imgs.image_ring); @@ -195,9 +195,9 @@ static void image_save_as_preview(struct context *cnt, struct image_data *img) /* Copy image */ memcpy(cnt->imgs.preview_image.image, img->image, cnt->imgs.size); - /* + /* * If we set output_all to yes and during the event - * there is no image with motion, diffs is 0, we are not going to save the preview event + * there is no image with motion, diffs is 0, we are not going to save the preview event */ if (cnt->imgs.preview_image.diffs == 0) cnt->imgs.preview_image.diffs = 1; @@ -217,7 +217,7 @@ static void image_save_as_preview(struct context *cnt, struct image_data *img) } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, LOCATE_REDCROSS, LOCATE_NORMAL, cnt->process_thisframe); - } + } } } @@ -297,7 +297,7 @@ static void sig_handler(int signo) switch(signo) { case SIGALRM: - /* + /* * Somebody (maybe we ourself) wants us to make a snapshot * This feature triggers snapshots on ALL threads that have * snapshot_interval different from 0. @@ -305,16 +305,16 @@ static void sig_handler(int signo) if (cnt_list) { i = -1; while (cnt_list[++i]) { - if (cnt_list[i]->conf.snapshot_interval) + if (cnt_list[i]->conf.snapshot_interval) cnt_list[i]->snapshot = 1; - + } } break; case SIGUSR1: - /* + /* * Ouch! We have been hit from the outside! Someone wants us to - * make a movie! + * make a movie! */ if (cnt_list) { i = -1; @@ -324,32 +324,32 @@ static void sig_handler(int signo) break; case SIGHUP: restart = 1; - /* + /* * Fall through, as the value of 'restart' is the only difference * between SIGHUP and the ones below. */ case SIGINT: case SIGQUIT: case SIGTERM: - /* + /* * Somebody wants us to quit! We should better finish the actual - * movie and end up! + * movie and end up! */ if (cnt_list) { i = -1; while (cnt_list[++i]) { cnt_list[i]->makemovie = 1; cnt_list[i]->finish = 1; - /* - * Don't restart thread when it ends, - * all threads restarts if global restart is set + /* + * Don't restart thread when it ends, + * all threads restarts if global restart is set */ cnt_list[i]->restart = 0; } } /* * Set flag we want to quit main check threads loop - * if restart is set (above) we start up again + * if restart is set (above) we start up again */ finish = 1; break; @@ -380,19 +380,19 @@ static void sigchild_handler(int signo ATTRIBUTE_UNUSED) static void motion_remove_pid(void) { if ((cnt_list[0]->daemon) && (cnt_list[0]->conf.pid_file) && (restart == 0)) { - if (!unlink(cnt_list[0]->conf.pid_file)) + if (!unlink(cnt_list[0]->conf.pid_file)) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Removed process id file (pid file)."); - else + else MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error removing pid file"); } - if (ptr_logfile) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Closing logfile (%s).", + if (ptr_logfile) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Closing logfile (%s).", cnt_list[0]->conf.log_file); myfclose(ptr_logfile); set_log_mode(LOGMODE_SYSLOG); ptr_logfile = NULL; - } + } } @@ -424,12 +424,12 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDBOX, LOCATE_BOTH, cnt->process_thisframe); } else if (cnt->locate_motion_style == LOCATE_CROSS) { - alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_CROSS, + alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_CROSS, LOCATE_BOTH, cnt->process_thisframe); } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { - alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDCROSS, + alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDCROSS, LOCATE_BOTH, cnt->process_thisframe); - } + } } /* Calculate how centric motion is if configured preview center*/ @@ -445,7 +445,7 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img if (img->flags & IMAGE_TRIGGER) { /* Take action if this is a new event and we have a trigger image */ if (cnt->event_nr != cnt->prev_event) { - /* + /* * Reset prev_event number to current event and save event time * in both time_t and struct tm format. */ @@ -453,7 +453,7 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img cnt->eventtime = img->timestamp; localtime_r(&cnt->eventtime, cnt->eventtime_tm); - /* + /* * Since this is a new event we create the event_text_string used for * the %C conversion specifier. We may already need it for * on_motion_detected_commend so it must be done now. @@ -464,13 +464,13 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img /* EVENT_FIRSTMOTION triggers on_event_start_command and event_ffmpeg_newfile */ event(cnt, EVENT_FIRSTMOTION, img->image, NULL, NULL, &img->timestamp_tm); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion detected - starting event %d", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion detected - starting event %d", cnt->event_nr); /* always save first motion frame as preview-shot, may be changed to an other one later */ - if (cnt->new_img & (NEWIMG_FIRST | NEWIMG_BEST | NEWIMG_CENTER)) + if (cnt->new_img & (NEWIMG_FIRST | NEWIMG_BEST | NEWIMG_CENTER)) image_save_as_preview(cnt, img); - + } /* EVENT_MOTION triggers event_beep and on_motion_detected_command */ @@ -479,27 +479,27 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img /* Limit framerate */ if (img->shot < conf->frame_limit) { - /* + /* * If config option stream_motion is enabled, send the latest motion detected image * to the stream but only if it is not the first shot within a second. This is to * avoid double frames since we already have sent a frame to the stream. * We also disable this in setup_mode. */ - if (conf->stream_motion && !conf->setup_mode && img->shot != 1) + if (conf->stream_motion && !conf->setup_mode && img->shot != 1) event(cnt, EVENT_STREAM, img->image, NULL, NULL, &img->timestamp_tm); - /* - * Save motion jpeg, if configured - * Output the image_out (motion) picture. + /* + * Save motion jpeg, if configured + * Output the image_out (motion) picture. */ - if (conf->motion_img) + if (conf->motion_img) event(cnt, EVENT_IMAGEM_DETECTED, NULL, NULL, NULL, &img->timestamp_tm); } /* if track enabled and auto track on */ - if (cnt->track.type && cnt->track.active) + if (cnt->track.type && cnt->track.active) cnt->moved = track_move(cnt, dev, location, imgs, 0); - + } /** @@ -516,10 +516,10 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img #define IMAGE_BUFFER_FLUSH ((unsigned int)-1) static void process_image_ring(struct context *cnt, unsigned int max_images) { - /* + /* * We are going to send an event, in the events there is still * some code that use cnt->current_image - * so set it temporary to our image + * so set it temporary to our image */ struct image_data *saved_current_image = cnt->current_image; @@ -548,22 +548,22 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) else t = "Other"; - mystrftime(cnt, tmp, sizeof(tmp), "%H%M%S-%q", + mystrftime(cnt, tmp, sizeof(tmp), "%H%M%S-%q", &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm, NULL, 0); - draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 20, + draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 20, cnt->imgs.width, tmp, cnt->conf.text_double); - draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 30, + draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 30, cnt->imgs.width, t, cnt->conf.text_double); } /* Output the picture to jpegs and ffmpeg */ event(cnt, EVENT_IMAGE_DETECTED, - cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, + cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm); - /* - * Check if we must add any "filler" frames into movie to keep up fps - * Only if we are recording videos ( ffmpeg or extenal pipe ) + /* + * 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) && #ifdef HAVE_FFMPEG @@ -571,19 +571,19 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) #else (cnt->conf.useextpipe && cnt->extpipe)) { #endif - /* + /* * movie_last_shoot is -1 when file is created, - * we don't know how many frames there is in first sec + * we don't know how many frames there is in first sec */ if (cnt->movie_last_shot >= 0) { if (cnt_list[0]->log_level >= DBG) { int frames = cnt->movie_fps - (cnt->movie_last_shot + 1); if (frames > 0) { char tmp[15]; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Added %d fillerframes into movie", + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Added %d fillerframes into movie", frames); sprintf(tmp, "Fillerframes %d", frames); - draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 40, + draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 40, cnt->imgs.width, tmp, cnt->conf.text_double); } } @@ -591,7 +591,7 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) while ((cnt->movie_last_shot + 1) < cnt->movie_fps) { /* Add a filler frame into encoder */ event(cnt, EVENT_FFMPEG_PUT, - cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, + cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, NULL, NULL, &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm); cnt->movie_last_shot++; @@ -603,9 +603,9 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) cnt->movie_last_shot = -1; } - /* + /* * Save last shot added to movie - * only when we not are within first sec + * 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; @@ -678,9 +678,9 @@ static int motion_init(struct context *cnt) cnt->smartmask_speed = 0; - /* + /* * We initialize cnt->event_nr to 1 and cnt->prev_event to 0 (not really needed) so - * that certain code below does not run until motion has been detected the first time + * that certain code below does not run until motion has been detected the first time */ cnt->event_nr = 1; cnt->prev_event = 0; @@ -688,7 +688,7 @@ 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 , motion detection %s", + 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) @@ -697,13 +697,13 @@ static int motion_init(struct context *cnt) /* set the device settings */ cnt->video_dev = vid_start(cnt); - /* + /* * We failed to get an initial image from a camera * So we need to guess height and width based on the config * file options. */ if (cnt->video_dev == -1) { - MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " "Motion continues using width and height from config file(s)"); cnt->imgs.width = cnt->conf.width; cnt->imgs.height = cnt->conf.height; @@ -740,13 +740,13 @@ static int motion_init(struct context *cnt) /* allocate buffer here for preview buffer */ cnt->imgs.preview_image.image = mymalloc(cnt->imgs.size); - /* - * Allocate a buffer for temp. usage in some places - * Only despeckle & bayer2rgb24() for now for now... + /* + * Allocate a buffer for temp. usage in some places + * Only despeckle & bayer2rgb24() for now for now... */ cnt->imgs.common_buffer = mymalloc(3 * cnt->imgs.width * cnt->imgs.height); - /* + /* * Now is a good time to init rotation data. Since vid_start has been * called, we know that we have imgs.width and imgs.height. When capturing * from a V4L device, these are copied from the corresponding conf values @@ -778,7 +778,7 @@ static int motion_init(struct context *cnt) /* create a reference frame */ alg_update_reference_frame(cnt, RESET_REF_FRAME); -#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) +#if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) /* open video loopback devices if enabled */ if (cnt->conf.vidpipe) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for normal pictures"); @@ -787,19 +787,19 @@ static int motion_init(struct context *cnt) cnt->pipe = vid_startpipe(cnt->conf.vidpipe, cnt->imgs.width, cnt->imgs.height, cnt->imgs.type); if (cnt->pipe < 0) { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for normal pictures"); + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for normal pictures"); return -1; } } if (cnt->conf.motionvidpipe) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for motion pictures"); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Opening video loopback device for motion pictures"); /* vid_startpipe should get the output dimensions */ cnt->mpipe = vid_startpipe(cnt->conf.motionvidpipe, cnt->imgs.width, cnt->imgs.height, cnt->imgs.type); if (cnt->mpipe < 0) { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for motion pictures"); + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to open video loopback for motion pictures"); return -1; } } @@ -807,16 +807,16 @@ static int motion_init(struct context *cnt) #if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) if (cnt->conf.database_type) { - MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: Database backend %s", + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: Database backend %s", cnt->conf.database_type); - + #ifdef HAVE_SQLITE3 if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { - MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: DB %s", + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: DB %s", cnt->conf.sqlite3_db); if (sqlite3_open(cnt->conf.sqlite3_db, &cnt->database_sqlite3) != SQLITE_OK) { - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s\n", + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s\n", cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); sqlite3_close(cnt->database_sqlite3); exit(1); @@ -825,7 +825,7 @@ static int motion_init(struct context *cnt) #endif /* HAVE_SQLITE3 */ #ifdef HAVE_MYSQL - if ((!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { + if ((!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { // close database to be sure that we are not leaking mysql_close(cnt->database); @@ -835,7 +835,7 @@ static int motion_init(struct context *cnt) if (!mysql_real_connect(cnt->database, cnt->conf.database_host, cnt->conf.database_user, cnt->conf.database_password, cnt->conf.database_dbname, 0, NULL, 0)) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Cannot connect to MySQL database %s on host %s with user %s", - cnt->conf.database_dbname, cnt->conf.database_host, + cnt->conf.database_dbname, cnt->conf.database_host, cnt->conf.database_user); MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: MySQL error was %s", mysql_error(cnt->database)); return -2; @@ -851,7 +851,7 @@ static int motion_init(struct context *cnt) if ((!strcmp(cnt->conf.database_type, "postgresql")) && (cnt->conf.database_dbname)) { char connstring[255]; - /* + /* * Create the connection string. * Quote the values so we can have null values (blank) */ @@ -872,7 +872,7 @@ static int motion_init(struct context *cnt) } } #endif /* HAVE_PGSQL */ - + /* Set the sql mask file according to the SQL config options*/ @@ -887,7 +887,7 @@ static int motion_init(struct context *cnt) /* Load the mask file if any */ if (cnt->conf.mask_file) { if ((picture = myfopen(cnt->conf.mask_file, "r", 0))) { - /* + /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask * applies to the already rotated image, not the capture image. Thus, use * width and height from imgs. @@ -895,19 +895,19 @@ static int motion_init(struct context *cnt) cnt->imgs.mask = get_pgm(picture, cnt->imgs.width, cnt->imgs.height); myfclose(picture); } else { - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening mask file %s", + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening mask file %s", cnt->conf.mask_file); - /* + /* * Try to write an empty mask file to make it easier - * for the user to edit it + * for the user to edit it */ put_fixed_mask(cnt, cnt->conf.mask_file); } if (!cnt->imgs.mask) { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to read mask image. Mask feature disabled."); + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Failed to read mask image. Mask feature disabled."); } else { - MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Maskfile \"%s\" loaded.", + MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Maskfile \"%s\" loaded.", cnt->conf.mask_file); } } else { @@ -928,13 +928,13 @@ static int motion_init(struct context *cnt) /* Initialize stream server if stream port is specified to not 0 */ if (cnt->conf.stream_port) { if (stream_init(cnt) == -1) { - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem enabling motion-stream server in port %d", + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem enabling motion-stream server in port %d", cnt->conf.stream_port); cnt->finish = 1; - } else { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Started motion-stream server in port %d auth %s", + } else { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Started motion-stream server in port %d auth %s", cnt->conf.stream_port, cnt->conf.stream_auth_method ? "Enabled":"Disabled"); - } + } } /* Prevent first few frames from triggering motion... */ @@ -962,8 +962,13 @@ static void motion_cleanup(struct context *cnt) /* Stop stream */ event(cnt, EVENT_STOP, NULL, NULL, NULL, NULL); +#ifdef HAVE_FFMPEG + event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, NULL); + event(cnt, EVENT_ENDMOTION, NULL, NULL, NULL, NULL); +#endif // HAVE_FFMPEG + if (cnt->video_dev >= 0) { - MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Calling vid_close() from motion_cleanup"); + MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Calling vid_close() from motion_cleanup"); vid_close(cnt); } @@ -1050,8 +1055,8 @@ static void motion_cleanup(struct context *cnt) if (cnt->conf.database_type) { #ifdef HAVE_MYSQL - if ( (!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { - mysql_close(cnt->database); + if ( (!strcmp(cnt->conf.database_type, "mysql")) && (cnt->conf.database_dbname)) { + mysql_close(cnt->database); } #endif /* HAVE_MYSQL */ @@ -1059,9 +1064,9 @@ static void motion_cleanup(struct context *cnt) if ((!strcmp(cnt->conf.database_type, "postgresql")) && (cnt->conf.database_dbname)) { PQfinish(cnt->database_pg); } -#endif /* HAVE_PGSQL */ +#endif /* HAVE_PGSQL */ -#ifdef HAVE_SQLITE3 +#ifdef HAVE_SQLITE3 /* Close the SQLite database */ if (cnt->conf.sqlite3_db) sqlite3_close(cnt->database_sqlite3); @@ -1102,7 +1107,7 @@ static void *motion_loop(void *arg) unsigned int get_image = 1; /* Flag used to signal that we capture new image when we run the loop */ struct image_data *old_image; - /* + /* * Next two variables are used for snapshot and timelapse feature * time_last_frame is set to 1 so that first coming timelapse or second = 0 * is acted upon. @@ -1110,10 +1115,10 @@ static void *motion_loop(void *arg) unsigned long int time_last_frame = 1, time_current_frame; cnt->running = 1; - - if (motion_init(cnt) < 0) + + if (motion_init(cnt) < 0) goto err; - + /* Initialize the double sized characters if needed. */ if (cnt->conf.text_double) @@ -1139,9 +1144,9 @@ static void *motion_loop(void *arg) area_maxx[2] = area_maxx[5] = area_maxx[8] = cnt->imgs.width; area_maxy[6] = area_maxy[7] = area_maxy[8] = cnt->imgs.height; - + /* Work out expected frame rate based on config setting */ - if (cnt->conf.frame_limit < 2) + if (cnt->conf.frame_limit < 2) cnt->conf.frame_limit = 2; required_frame_time = 1000000L / cnt->conf.frame_limit; @@ -1164,8 +1169,8 @@ static void *motion_loop(void *arg) cnt->moved = track_center(cnt, cnt->video_dev, 0, 0, 0); #ifdef __OpenBSD__ - /* - * FIXMARK + /* + * FIXMARK * Fixes zombie issue on OpenBSD 4.6 */ struct sigaction sig_handler_action; @@ -1174,8 +1179,8 @@ static void *motion_loop(void *arg) #endif /* - * MAIN MOTION LOOP BEGINS HERE - * Should go on forever... unless you bought vaporware :) + * MAIN MOTION LOOP BEGINS HERE + * Should go on forever... unless you bought vaporware :) */ while (!cnt->finish || cnt->makemovie) { @@ -1188,9 +1193,9 @@ static void *motion_loop(void *arg) gettimeofday(&tv1, NULL); timenow = tv1.tv_usec + 1000000L * tv1.tv_sec; - /* + /* * Calculate detection rate limit. Above 5fps we limit the detection - * rate to 3fps to reduce load at higher framerates. + * rate to 3fps to reduce load at higher framerates. */ cnt->process_thisframe = 0; rate_limit++; @@ -1199,10 +1204,10 @@ static void *motion_loop(void *arg) cnt->process_thisframe = 1; } - /* + /* * Since we don't have sanity checks done when options are set, * this sanity check must go in the main loop :(, before pre_captures - * are attempted. + * are attempted. */ if (cnt->conf.minimum_motion_frames < 1) cnt->conf.minimum_motion_frames = 1; @@ -1210,26 +1215,26 @@ static void *motion_loop(void *arg) if (cnt->conf.pre_capture < 0) cnt->conf.pre_capture = 0; - /* + /* * Check if our buffer is still the right size * If pre_capture or minimum_motion_frames has been changed * via the http remote control we need to re-size the ring buffer */ frame_buffer_size = cnt->conf.pre_capture + cnt->conf.minimum_motion_frames; - if (cnt->imgs.image_ring_size != frame_buffer_size) + if (cnt->imgs.image_ring_size != frame_buffer_size) image_ring_resize(cnt, frame_buffer_size); - + /* Get time for current frame */ cnt->currenttime = time(NULL); - /* + /* * localtime returns static data and is not threadsafe * so we use localtime_r which is reentrant and threadsafe */ localtime_r(&cnt->currenttime, cnt->currenttime_tm); - /* + /* * If we have started on a new second we reset the shots variable * lastrate is updated to be the number of the last frame. last rate * is used as the ffmpeg framerate when motion is detected. @@ -1238,14 +1243,14 @@ static void *motion_loop(void *arg) cnt->lastrate = cnt->shots + 1; cnt->shots = -1; lastframetime = cnt->currenttime; - + if (cnt->conf.minimum_frame_time) { minimum_frame_time_downcounter--; if (minimum_frame_time_downcounter == 0) get_image = 1; } else { get_image = 1; - } + } } @@ -1307,7 +1312,7 @@ static void *motion_loop(void *arg) cnt->current_image->shot = cnt->shots; /***** MOTION LOOP - RETRY INITIALIZING SECTION *****/ - /* + /* * If a camera is not available we keep on retrying every 10 seconds * until it shows up. */ @@ -1317,7 +1322,7 @@ static void *motion_loop(void *arg) "%s: Retrying until successful connection with camera"); cnt->video_dev = vid_start(cnt); - /* + /* * If the netcam has different dimensions than in the config file * we need to restart Motion to re-allocate all the buffers */ @@ -1329,9 +1334,9 @@ static void *motion_loop(void *arg) "image buffers to new picture dimensions"); cnt->conf.width = cnt->imgs.width; cnt->conf.height = cnt->imgs.height; - /* - * Break out of main loop terminating thread - * watchdog will start us again + /* + * Break out of main loop terminating thread + * watchdog will start us again */ break; } @@ -1340,7 +1345,7 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - IMAGE CAPTURE SECTION *****/ - /* + /* * Fetch next frame from camera * If vid_next returns 0 all is well and we got a new picture * Any non zero value is an error. @@ -1382,31 +1387,31 @@ static void *motion_loop(void *arg) gettimeofday(&tv1, NULL); timenow = tv1.tv_usec + 1000000L * tv1.tv_sec; } - // FATAL ERROR - leave the thread by breaking out of the main loop + // FATAL ERROR - leave the thread by breaking out of the main loop } else if (vid_return_code < 0) { /* Fatal error - Close video device */ - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video device fatal error - Closing video device"); + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video device fatal error - Closing video device"); vid_close(cnt); - /* + /* * Use virgin image, if we are not able to open it again next loop * a gray image with message is applied * flag lost_connection */ memcpy(cnt->current_image->image, cnt->imgs.image_virgin, cnt->imgs.size); cnt->lost_connection = 1; - /* NO FATAL ERROR - - * copy last image or show grey image with message + /* NO FATAL ERROR - + * copy last image or show grey image with message * flag on lost_connection if : - * vid_return_code == NETCAM_RESTART_ERROR + * vid_return_code == NETCAM_RESTART_ERROR * cnt->video_dev < 0 * cnt->missing_frame_counter > (MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) - */ - } else { + */ + } else { - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: vid_return_code %d", + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: vid_return_code %d", vid_return_code); - /* + /* * Netcams that change dimensions while Motion is running will * require that Motion restarts to reinitialize all the many * buffers inside Motion. It will be a mess to try and recover any @@ -1415,24 +1420,24 @@ static void *motion_loop(void *arg) if (vid_return_code == NETCAM_RESTART_ERROR) { MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Restarting Motion thread to reinitialize all " "image buffers"); - /* - * Break out of main loop terminating thread - * watchdog will start us again - * Set lost_connection flag on + /* + * Break out of main loop terminating thread + * watchdog will start us again + * Set lost_connection flag on */ cnt->lost_connection = 1; break; } - /* - * First missed frame - store timestamp + /* + * First missed frame - store timestamp * Don't reset time when thread restarts */ if (cnt->connectionlosttime == 0) cnt->connectionlosttime = cnt->currenttime; - /* + /* * Increase missing_frame_counter * The first MISSING_FRAMES_TIMEOUT seconds we copy previous virgin image * After MISSING_FRAMES_TIMEOUT seconds we put a grey error image in the buffer @@ -1449,7 +1454,7 @@ static void *motion_loop(void *arg) char tmpout[80]; struct tm tmptime; cnt->lost_connection = 1; - + if (cnt->video_dev >= 0) tmpin = "CONNECTION TO CAMERA LOST\\nSINCE %Y-%m-%d %T"; else @@ -1463,17 +1468,17 @@ static void *motion_loop(void *arg) /* Write error message only once */ if (cnt->missing_frame_counter == MISSING_FRAMES_TIMEOUT * cnt->conf.frame_limit) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Video signal lost - Adding grey image"); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Video signal lost - Adding grey image"); // Event for lost video signal can be called from here event(cnt, EVENT_CAMERA_LOST, NULL, NULL, NULL, cnt->currenttime_tm); } - /* - * If we don't get a valid frame for a long time, try to close/reopen device - * Only try this when a device is open + /* + * If we don't get a valid frame for a long time, try to close/reopen device + * Only try this when a device is open */ - if ((cnt->video_dev > 0) && + if ((cnt->video_dev > 0) && (cnt->missing_frame_counter == (MISSING_FRAMES_TIMEOUT * 4) * cnt->conf.frame_limit)) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Video signal still lost - " "Trying to close video device"); @@ -1484,7 +1489,7 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - MOTION DETECTION SECTION *****/ - /* + /* * The actual motion detection takes place in the following * diffs is the number of pixels detected as changed * Make a differences picture in image_out @@ -1496,7 +1501,7 @@ static void *motion_loop(void *arg) */ if (cnt->process_thisframe) { if (cnt->threshold && !cnt->pause) { - /* + /* * If we've already detected motion and we want to see if there's * still motion, don't bother trying the fast one first. IF there's * motion, the alg_diff will trigger alg_diff_standard @@ -1515,7 +1520,7 @@ static void *motion_loop(void *arg) */ if (cnt->conf.lightswitch > 1 && !cnt->lost_connection) { if (alg_lightswitch(cnt, cnt->current_image->diffs)) { - MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Lightswitch detected"); + MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Lightswitch detected"); if (cnt->moved < 5) cnt->moved = 5; @@ -1525,7 +1530,7 @@ static void *motion_loop(void *arg) } } - /* + /* * Switchfilter feature tries to detect a change in the video signal * from one camera to the next. This is normally used in the Round * Robin feature. The algorithm is not very safe. @@ -1535,17 +1540,17 @@ static void *motion_loop(void *arg) * because with Round Robin this is controlled by roundrobin_skip. */ if (cnt->conf.switchfilter && cnt->current_image->diffs > cnt->threshold) { - cnt->current_image->diffs = alg_switchfilter(cnt, cnt->current_image->diffs, + cnt->current_image->diffs = alg_switchfilter(cnt, cnt->current_image->diffs, cnt->current_image->image); - + if (cnt->current_image->diffs <= cnt->threshold) { cnt->current_image->diffs = 0; - + MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: Switchfilter detected"); } } - /* + /* * Despeckle feature * First we run (as given by the despeckle_filter option iterations * of erode and dilate algorithms. @@ -1555,7 +1560,7 @@ static void *motion_loop(void *arg) cnt->current_image->total_labels = 0; cnt->imgs.largest_label = 0; olddiffs = 0; - + if (cnt->conf.despeckle_filter && cnt->current_image->diffs > 0) { olddiffs = cnt->current_image->diffs; cnt->current_image->diffs = alg_despeckle(cnt, olddiffs); @@ -1569,13 +1574,13 @@ static void *motion_loop(void *arg) } /* Manipulate smart_mask sensitivity (only every smartmask_ratio seconds) */ - if ((cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) && + if ((cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) && (!--smartmask_count)) { alg_tune_smartmask(cnt); smartmask_count = smartmask_ratio; } - /* + /* * cnt->moved is set by the tracking code when camera has been asked to move. * When camera is moving we do not want motion to detect motion or we will * get our camera chasing itself like crazy and we will get motion detected @@ -1591,16 +1596,16 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - TUNING SECTION *****/ - /* + /* * If noise tuning was selected, do it now. but only when * no frames have been recorded and only once per second */ if ((cnt->conf.noise_tune && cnt->shots == 0) && (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold))) alg_noise_tune(cnt, cnt->imgs.image_virgin); - - /* + + /* * If we are not noise tuning lets make sure that remote controlled * changes of noise_level are used. */ @@ -1608,7 +1613,7 @@ static void *motion_loop(void *arg) if (!cnt->conf.noise_tune) cnt->noise = cnt->conf.noise; - /* + /* * threshold tuning if enabled * if we are not threshold tuning lets make sure that remote controlled * changes of threshold are used. @@ -1618,20 +1623,20 @@ static void *motion_loop(void *arg) else cnt->threshold = cnt->conf.max_changes; - /* + /* * If motion is detected (cnt->current_image->diffs > cnt->threshold) and before we add text to the pictures * we find the center and size coordinates of the motion to be used for text overlays and later - * for adding the locate rectangle + * for adding the locate rectangle */ if (cnt->current_image->diffs > cnt->threshold) alg_locate_center_size(&cnt->imgs, cnt->imgs.width, cnt->imgs.height, &cnt->current_image->location); - /* - * Update reference frame. - * micro-lighswitch: trying to auto-detect lightswitch events. - * frontdoor illumination. Updates are rate-limited to 3 per second at - * framerates above 5fps to save CPU resources and to keep sensitivity - * at a constant level. + /* + * Update reference frame. + * micro-lighswitch: trying to auto-detect lightswitch events. + * frontdoor illumination. Updates are rate-limited to 3 per second at + * framerates above 5fps to save CPU resources and to keep sensitivity + * at a constant level. */ if ((cnt->current_image->diffs > cnt->threshold) && (cnt->conf.lightswitch == 1) && @@ -1645,7 +1650,7 @@ static void *motion_loop(void *arg) cnt->current_image->diffs = 0; cnt->lightswitch_framecounter = 0; - MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: micro-lightswitch!"); + MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "%s: micro-lightswitch!"); } else { alg_update_reference_frame(cnt, UPDATE_REF_FRAME); } @@ -1657,7 +1662,7 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - TEXT AND GRAPHICS OVERLAY SECTION *****/ - /* + /* * Some overlays on top of the motion image * Note that these now modifies the cnt->imgs.out so this buffer * can no longer be used for motion detection features until next @@ -1665,17 +1670,17 @@ static void *motion_loop(void *arg) */ /* Smartmask overlay */ - if (cnt->smartmask_speed && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || + if (cnt->smartmask_speed && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || cnt->conf.setup_mode)) overlay_smartmask(cnt, cnt->imgs.out); /* Largest labels overlay */ - if (cnt->imgs.largest_label && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || + if (cnt->imgs.largest_label && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || cnt->conf.setup_mode)) overlay_largest_label(cnt, cnt->imgs.out); /* Fixed mask overlay */ - if (cnt->imgs.mask && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || + if (cnt->imgs.mask && (cnt->conf.motion_img || cnt->conf.ffmpeg_output_debug || cnt->conf.setup_mode)) overlay_fixed_mask(cnt, cnt->imgs.out); @@ -1696,17 +1701,17 @@ static void *motion_loop(void *arg) else sprintf(tmp, "-"); - draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10, + draw_text(cnt->current_image->image, cnt->imgs.width - 10, 10, cnt->imgs.width, tmp, cnt->conf.text_double); } - /* + /* * Add changed pixels to motion-images (for stream) in setup_mode - * and always overlay smartmask (not only when motion is detected) + * and always overlay smartmask (not only when motion is detected) */ if (cnt->conf.setup_mode) { char tmp[PATH_MAX]; - sprintf(tmp, "D:%5d L:%3d N:%3d", cnt->current_image->diffs, + sprintf(tmp, "D:%5d L:%3d N:%3d", cnt->current_image->diffs, cnt->current_image->total_labels, cnt->noise); draw_text(cnt->imgs.out, cnt->imgs.width - 10, cnt->imgs.height - 30 * text_size_factor, cnt->imgs.width, tmp, cnt->conf.text_double); @@ -1718,18 +1723,18 @@ static void *motion_loop(void *arg) /* Add text in lower left corner of the pictures */ if (cnt->conf.text_left) { char tmp[PATH_MAX]; - mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left, + mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_left, &cnt->current_image->timestamp_tm, NULL, 0); - draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 * text_size_factor, + draw_text(cnt->current_image->image, 10, cnt->imgs.height - 10 * text_size_factor, cnt->imgs.width, tmp, cnt->conf.text_double); } /* Add text in lower right corner of the pictures */ if (cnt->conf.text_right) { char tmp[PATH_MAX]; - mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right, + mystrftime(cnt, tmp, sizeof(tmp), cnt->conf.text_right, &cnt->current_image->timestamp_tm, NULL, 0); - draw_text(cnt->current_image->image, cnt->imgs.width - 10, + draw_text(cnt->current_image->image, cnt->imgs.width - 10, cnt->imgs.height - 10 * text_size_factor, cnt->imgs.width, tmp, cnt->conf.text_double); } @@ -1741,11 +1746,11 @@ static void *motion_loop(void *arg) /* flag this image, it have motion */ cnt->current_image->flags |= IMAGE_MOTION; cnt->lightswitch_framecounter++; /* micro lightswitch */ - } else { + } else { cnt->lightswitch_framecounter = 0; - } + } - /* + /* * If motion has been detected we take action and start saving * pictures and movies etc by calling motion_detected(). * Is emulate_motion enabled we always call motion_detected() @@ -1762,14 +1767,14 @@ static void *motion_loop(void *arg) #endif /* Setup the postcap counter */ cnt->postcap = cnt->conf.post_capture; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: (Em) Init post capture %d", + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: (Em) Init post capture %d", 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)) { - /* + /* * Did we detect motion (like the cat just walked in :) )? * If so, ensure the motion is sustained if minimum_motion_frames */ @@ -1779,13 +1784,13 @@ static void *motion_loop(void *arg) int pos = cnt->imgs.image_ring_in; for (i = 0; i < cnt->conf.minimum_motion_frames; i++) { - + if (cnt->imgs.image_ring[pos].flags & IMAGE_MOTION) frame_count++; - if (pos == 0) + if (pos == 0) pos = cnt->imgs.image_ring_size-1; - else + else pos--; } @@ -1796,23 +1801,23 @@ static void *motion_loop(void *arg) /* Setup the postcap counter */ cnt->postcap = cnt->conf.post_capture; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Setup post capture %d", + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: Setup post capture %d", cnt->postcap); /* Mark all images in image_ring to be saved */ - for (i = 0; i < cnt->imgs.image_ring_size; i++) + for (i = 0; i < cnt->imgs.image_ring_size; i++) cnt->imgs.image_ring[i].flags |= IMAGE_SAVE; - - } else if ((cnt->postcap) && + + } else if ((cnt->postcap) && #ifdef HAVE_FFMPEG (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { #else - (cnt->conf.useextpipe && cnt->extpipe)) { -#endif + (cnt->conf.useextpipe && cnt->extpipe)) { +#endif /* we have motion in this frame, but not enought frames for trigger. Check postcap */ cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); cnt->postcap--; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", cnt->postcap); } else { cnt->current_image->flags |= IMAGE_PRECAP; @@ -1820,16 +1825,16 @@ static void *motion_loop(void *arg) /* 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) && #ifdef HAVE_FFMPEG (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { #else - (cnt->conf.useextpipe && cnt->extpipe)) { + (cnt->conf.useextpipe && cnt->extpipe)) { #endif /* No motion, doing postcap */ cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); cnt->postcap--; - MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", + MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO, "%s: post capture %d", cnt->postcap); } else { /* Done with postcap, so just have the image in the precap buffer */ @@ -1841,18 +1846,18 @@ static void *motion_loop(void *arg) } /* Update last frame saved time, so we can end event after gap time */ - if (cnt->current_image->flags & IMAGE_SAVE) + if (cnt->current_image->flags & IMAGE_SAVE) cnt->lasttime = cnt->current_image->timestamp; - - /* - * Simple hack to recognize motion in a specific area - * Do we need a new coversion specifier as well?? + + /* + * Simple hack to recognize motion in a specific area + * Do we need a new coversion specifier as well?? */ - if ((cnt->conf.area_detect) && (cnt->event_nr != area_once) && + if ((cnt->conf.area_detect) && (cnt->event_nr != area_once) && (cnt->current_image->flags & IMAGE_TRIGGER)) { j = strlen(cnt->conf.area_detect); - + for (i = 0; i < j; i++) { z = cnt->conf.area_detect[i] - 49; /* 1 becomes 0 */ if ((z >= 0) && (z < 9)) { @@ -1871,8 +1876,8 @@ static void *motion_loop(void *arg) } } } - - /* + + /* * Is the movie too long? Then make movies * First test for max_movie_time */ @@ -1880,11 +1885,11 @@ static void *motion_loop(void *arg) (cnt->currenttime - cnt->eventtime >= cnt->conf.max_movie_time)) cnt->makemovie = 1; - /* + /* * Now test for quiet longer than 'gap' OR make movie as decided in * previous statement. */ - if (((cnt->currenttime - cnt->lasttime >= cnt->conf.event_gap) && cnt->conf.event_gap > 0) || + if (((cnt->currenttime - cnt->lasttime >= cnt->conf.event_gap) && cnt->conf.event_gap > 0) || cnt->makemovie) { if (cnt->event_nr == cnt->prev_event || cnt->makemovie) { @@ -1899,14 +1904,14 @@ static void *motion_loop(void *arg) event(cnt, EVENT_ENDMOTION, NULL, NULL, NULL, cnt->currenttime_tm); - /* + /* * If tracking is enabled we center our camera so it does not * point to a place where it will miss the next action */ if (cnt->track.type) cnt->moved = track_center(cnt, cnt->video_dev, 0, 0, 0); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: End of event %d", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: End of event %d", cnt->event_nr); cnt->makemovie = 0; @@ -1917,7 +1922,7 @@ static void *motion_loop(void *arg) cnt->event_nr++; cnt->lightswitch_framecounter = 0; - /* + /* * And we unset the text_event_string to avoid that buffered * images get a timestamp from previous event. */ @@ -1965,7 +1970,7 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - SNAPSHOT FEATURE SECTION *****/ - /* + /* * Did we get triggered to make a snapshot from control http? Then shoot a snap * If snapshot_interval is not zero and time since epoch MOD snapshot_interval = 0 then snap * We actually allow the time to run over the interval in case we have a delay @@ -1991,7 +1996,7 @@ static void *motion_loop(void *arg) if (cnt->conf.timelapse) { - /* + /* * Check to see if we should start a new timelapse file. We start one when * we are on the first shot, and and the seconds are zero. We must use the seconds * to prevent the timelapse file from getting reset multiple times during the minute. @@ -2011,44 +2016,44 @@ static void *motion_loop(void *arg) /* handle the hourly case */ } else if (strcasecmp(cnt->conf.timelapse_mode, "hourly") == 0) { event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); - - /* If we are weekly-sunday, raise timelapseend event at midnight on sunday */ + + /* If we are weekly-sunday, raise timelapseend event at midnight on sunday */ } else if (strcasecmp(cnt->conf.timelapse_mode, "weekly-sunday") == 0) { - if (cnt->current_image->timestamp_tm.tm_wday == 0 && + if (cnt->current_image->timestamp_tm.tm_wday == 0 && cnt->current_image->timestamp_tm.tm_hour == 0) - event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, + event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); - /* If we are weekly-monday, raise timelapseend event at midnight on monday */ + /* If we are weekly-monday, raise timelapseend event at midnight on monday */ } else if (strcasecmp(cnt->conf.timelapse_mode, "weekly-monday") == 0) { - if (cnt->current_image->timestamp_tm.tm_wday == 1 && + if (cnt->current_image->timestamp_tm.tm_wday == 1 && cnt->current_image->timestamp_tm.tm_hour == 0) - event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, + event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); - /* If we are monthly, raise timelapseend event at midnight on first day of month */ + /* If we are monthly, raise timelapseend event at midnight on first day of month */ } else if (strcasecmp(cnt->conf.timelapse_mode, "monthly") == 0) { - if (cnt->current_image->timestamp_tm.tm_mday == 1 && + if (cnt->current_image->timestamp_tm.tm_mday == 1 && cnt->current_image->timestamp_tm.tm_hour == 0) - event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, + event(cnt, EVENT_TIMELAPSEEND, NULL, NULL, NULL, &cnt->current_image->timestamp_tm); - /* If invalid we report in syslog once and continue in manual mode */ + /* If invalid we report in syslog once and continue in manual mode */ } else { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Invalid timelapse_mode argument '%s'", cnt->conf.timelapse_mode); - MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%:s Defaulting to manual timelapse mode"); + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%:s Defaulting to manual timelapse mode"); conf_cmdparse(&cnt, (char *)"ffmpeg_timelapse_mode",(char *)"manual"); } } - /* + /* * If ffmpeg timelapse is enabled and time since epoch MOD ffmpeg_timelaps = 0 * add a timelapse frame to the timelapse movie. */ - if (cnt->shots == 0 && time_current_frame % cnt->conf.timelapse <= + if (cnt->shots == 0 && time_current_frame % cnt->conf.timelapse <= time_last_frame % cnt->conf.timelapse) - event(cnt, EVENT_TIMELAPSE, cnt->current_image->image, NULL, NULL, + event(cnt, EVENT_TIMELAPSE, cnt->current_image->image, NULL, NULL, &cnt->current_image->timestamp_tm); } else if (cnt->ffmpeg_timelapse) { - /* + /* * If timelapse movie is in progress but conf.timelapse is zero then close timelapse file * This is an important feature that allows manual roll-over of timelapse file using the http * remote control via a cron job. @@ -2063,7 +2068,7 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - VIDEO LOOPBACK SECTION *****/ - /* + /* * Feed last image and motion image to video device pipes and the stream clients * In setup mode we send the special setup mode image to both stream and vloopback pipe * In normal mode we feed the latest image to vloopback device and we send @@ -2081,11 +2086,11 @@ static void *motion_loop(void *arg) event(cnt, EVENT_SDL_PUT, cnt->imgs.out, NULL, NULL, cnt->currenttime_tm); #endif } else { - event(cnt, EVENT_IMAGE, cnt->current_image->image, NULL, + event(cnt, EVENT_IMAGE, cnt->current_image->image, NULL, &cnt->pipe, &cnt->current_image->timestamp_tm); if (!cnt->conf.stream_motion || cnt->shots == 1) - event(cnt, EVENT_STREAM, cnt->current_image->image, NULL, NULL, + event(cnt, EVENT_STREAM, cnt->current_image->image, NULL, NULL, &cnt->current_image->timestamp_tm); #ifdef HAVE_SDL if (cnt_list[0]->conf.sdl_threadnr == cnt->threadnr) @@ -2135,7 +2140,7 @@ static void *motion_loop(void *arg) cnt->conf.smart_mask_speed = 0; /* Has someone changed smart_mask_speed or framerate? */ - if (cnt->conf.smart_mask_speed != cnt->smartmask_speed || + if (cnt->conf.smart_mask_speed != cnt->smartmask_speed || smartmask_lastrate != cnt->lastrate) { if (cnt->conf.smart_mask_speed == 0) { memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); @@ -2144,16 +2149,16 @@ static void *motion_loop(void *arg) smartmask_lastrate = cnt->lastrate; cnt->smartmask_speed = cnt->conf.smart_mask_speed; - /* + /* * Decay delay - based on smart_mask_speed (framerate independent) - * This is always 5*smartmask_speed seconds + * This is always 5*smartmask_speed seconds */ smartmask_ratio = 5 * cnt->lastrate * (11 - cnt->smartmask_speed); } #if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) - /* + /* * Set the sql mask file according to the SQL config options * We update it for every frame in case the config was updated * via remote control. @@ -2170,9 +2175,9 @@ static void *motion_loop(void *arg) /***** MOTION LOOP - FRAMERATE TIMING AND SLEEPING SECTION *****/ - /* + /* * Work out expected frame rate based on config setting which may - * have changed from http-control + * have changed from http-control */ if (cnt->conf.frame_limit) required_frame_time = 1000000L / cnt->conf.frame_limit; @@ -2183,7 +2188,7 @@ static void *motion_loop(void *arg) gettimeofday(&tv2, NULL); elapsedtime = (tv2.tv_usec + 1000000L * tv2.tv_sec) - timenow; - /* + /* * Update history buffer but ignore first pass as timebefore * variable will be inaccurate */ @@ -2221,7 +2226,7 @@ static void *motion_loop(void *arg) } } - /* + /* * END OF MOTION MAIN LOOP * If code continues here it is because the thread is exiting or restarting */ @@ -2265,7 +2270,7 @@ static void *motion_loop(void *arg) static void become_daemon(void) { int i; - FILE *pidf = NULL; + FILE *pidf = NULL; struct sigaction sig_ign_action; /* Setup sig_ign_action */ @@ -2282,8 +2287,8 @@ static void become_daemon(void) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion going to daemon mode"); exit(0); } - - /* + + /* * Create the pid file if defined, if failed exit * If we fail we report it. If we succeed we postpone the log entry till * later when we have closed stdout. Otherwise Motion hangs in the terminal waiting @@ -2291,26 +2296,26 @@ static void become_daemon(void) */ if (cnt_list[0]->conf.pid_file) { pidf = myfopen(cnt_list[0]->conf.pid_file, "w+", 0); - + if (pidf) { (void)fprintf(pidf, "%d\n", getpid()); myfclose(pidf); } else { MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Exit motion, cannot create process" " id file (pid file) %s", cnt_list[0]->conf.pid_file); - if (ptr_logfile) - myfclose(ptr_logfile); - exit(0); + if (ptr_logfile) + myfclose(ptr_logfile); + exit(0); } } - /* + /* * Changing dir to root enables people to unmount a disk - * without having to stop Motion + * without having to stop Motion */ - if (chdir("/")) + if (chdir("/")) MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not change directory"); - + #if (defined(BSD)) setpgrp(0, getpid()); @@ -2318,7 +2323,7 @@ static void become_daemon(void) setpgrp(); #endif /* BSD */ - + if ((i = open("/dev/tty", O_RDWR)) >= 0) { ioctl(i, TIOCNOTTY, NULL); close(i); @@ -2339,12 +2344,12 @@ static void become_daemon(void) dup2(i, STDERR_FILENO); close(i); } - + /* Now it is safe to add the PID creation to the logs */ if (pidf) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Created process id file %s. Process ID is %d", cnt_list[0]->conf.pid_file, getpid()); - + sigaction(SIGTTOU, &sig_ign_action, NULL); sigaction(SIGTTIN, &sig_ign_action, NULL); sigaction(SIGTSTP, &sig_ign_action, NULL); @@ -2365,7 +2370,7 @@ static void become_daemon(void) */ static void cntlist_create(int argc, char *argv[]) { - /* + /* * cnt_list is an array of pointers to the context structures cnt for each thread. * First we reserve room for a pointer to thread 0's context structure * and a NULL pointer which indicates that end of the array of pointers to @@ -2382,7 +2387,7 @@ static void cntlist_create(int argc, char *argv[]) /* cnt_list[1] pointing to zero indicates no more thread context structures - they get added later */ cnt_list[1] = NULL; - /* + /* * Command line arguments are being pointed to from cnt_list[0] and we call conf_load which loads * the config options from motion.conf, thread config files and the command line. */ @@ -2409,9 +2414,9 @@ static void motion_shutdown(void) motion_remove_pid(); - while (cnt_list[++i]) + while (cnt_list[++i]) context_destroy(cnt_list[i]); - + free(cnt_list); cnt_list = NULL; #ifndef WITHOUT_V4L @@ -2439,23 +2444,23 @@ static void motion_startup(int daemonize, int argc, char *argv[]) /* Initialize our global mutex */ pthread_mutex_init(&global_lock, NULL); - /* + /* * Create the list of context structures and load the * configuration. */ cntlist_create(argc, argv); if ((cnt_list[0]->conf.log_level > ALL) || - (cnt_list[0]->conf.log_level == 0)) { + (cnt_list[0]->conf.log_level == 0)) { cnt_list[0]->conf.log_level = LEVEL_DEFAULT; cnt_list[0]->log_level = cnt_list[0]->conf.log_level; - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log level (%s) (%d)", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log level (%s) (%d)", get_log_level_str(cnt_list[0]->log_level), SHOW_LEVEL_VALUE(cnt_list[0]->log_level)); } else { cnt_list[0]->log_level = cnt_list[0]->conf.log_level - 1; // Let's make syslog compatible } - //set_log_level(cnt_list[0]->log_level); + //set_log_level(cnt_list[0]->log_level); #ifdef HAVE_SDL MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion "VERSION" Started with SDL support"); @@ -2469,7 +2474,7 @@ static void motion_startup(int daemonize, int argc, char *argv[]) if (ptr_logfile) { set_log_mode(LOGMODE_SYSLOG); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to file (%s)", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to file (%s)", cnt_list[0]->conf.log_file); set_log_mode(LOGMODE_FILE); } else { @@ -2481,15 +2486,15 @@ static void motion_startup(int daemonize, int argc, char *argv[]) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Logging to syslog"); } - if ((cnt_list[0]->conf.log_type_str == NULL) || + if ((cnt_list[0]->conf.log_type_str == NULL) || !(cnt_list[0]->log_type = get_log_type(cnt_list[0]->conf.log_type_str))) { cnt_list[0]->log_type = TYPE_DEFAULT; cnt_list[0]->conf.log_type_str = mystrcpy(cnt_list[0]->conf.log_type_str, "ALL"); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log type (%s)", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using default log type (%s)", get_log_type_str(cnt_list[0]->log_type)); } - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using log type (%s) log level (%s)", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Using log type (%s) log level (%s)", get_log_type_str(cnt_list[0]->log_type), get_log_level_str(cnt_list[0]->log_level)); set_log_level(cnt_list[0]->log_level); @@ -2498,7 +2503,7 @@ static void motion_startup(int daemonize, int argc, char *argv[]) initialize_chars(); if (daemonize) { - /* + /* * If daemon mode is requested, and we're not going into setup mode, * become daemon. */ @@ -2566,7 +2571,7 @@ static void start_motion_thread(struct context *cnt, pthread_attr_t *thread_attr { int i; - /* + /* * Check the stream port number for conflicts. * First we check for conflict with the control port. * Second we check for that two threads does not use the same port number @@ -2580,7 +2585,7 @@ static void start_motion_thread(struct context *cnt, pthread_attr_t *thread_attr MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Stream port number %d for thread %d conflicts with the control port", cnt->conf.stream_port, cnt->threadnr); - MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Stream feature for thread %d is disabled.", + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Stream feature for thread %d is disabled.", cnt->threadnr); cnt->conf.stream_port = 0; } @@ -2595,14 +2600,14 @@ static void start_motion_thread(struct context *cnt, pthread_attr_t *thread_attr "%s: Stream port number %d for thread %d conflicts with thread %d", cnt->conf.stream_port, cnt->threadnr, cnt_list[i]->threadnr); MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, - "%s: Stream feature for thread %d is disabled.", + "%s: Stream feature for thread %d is disabled.", cnt->threadnr); cnt->conf.stream_port = 0; } } } - /* + /* * Update how many threads we have running. This is done within a * mutex lock to prevent multiple simultaneous updates to * 'threads_running'. @@ -2617,7 +2622,7 @@ static void start_motion_thread(struct context *cnt, pthread_attr_t *thread_attr /* Give the thread WATCHDOG_TMO to start */ cnt->watchdog = WATCHDOG_TMO; - /* + /* * Create the actual thread. Use 'motion_loop' as the thread * function. */ @@ -2643,7 +2648,7 @@ int main (int argc, char **argv) pthread_attr_t thread_attr; pthread_t thread_id; - /* + /* * Setup signals and do some initialization. 1 in the call to * 'motion_startup' means that Motion will become a daemon if so has been * requested, and argc and argc are necessary for reading the command @@ -2656,14 +2661,14 @@ int main (int argc, char **argv) motion_startup(1, argc, argv); #ifdef HAVE_FFMPEG - /* + /* * FFMpeg initialization is only performed if FFMpeg support was found * and not disabled during the configure phase. */ ffmpeg_init(); #endif /* HAVE_FFMPEG */ - /* + /* * In setup mode, Motion is very communicative towards the user, which * allows the user to experiment with the config parameters in order to * optimize motion detection and stuff. @@ -2699,7 +2704,7 @@ int main (int argc, char **argv) MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Motion restarted"); } - /* + /* * Start the motion threads. First 'cnt_list' item is global if 'thread' * option is used, so start at 1 then and 0 otherwise. */ @@ -2711,16 +2716,16 @@ int main (int argc, char **argv) { cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", cnt_list[i]->threadnr, cnt_list[i]->conf_filename); } - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", - cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", + cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? cnt_list[i]->conf.netcam_url : cnt_list[i]->conf.video_device, cnt_list[i]->conf.netcam_url ? -1 : cnt_list[i]->conf.input); - - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Stream port %d", + + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Stream port %d", cnt_list[i]->conf.stream_port); start_motion_thread(cnt_list[i], &thread_attr); @@ -2732,24 +2737,24 @@ int main (int argc, char **argv) cnt_list[cnt_list[1] != NULL ? cnt_list[0]->conf.sdl_threadnr : 0]->conf.height); #endif - /* + /* * Create a thread for the control interface if requested. Create it * detached and with 'motion_web_control' as the thread function. */ if (cnt_list[0]->conf.webcontrol_port) pthread_create(&thread_id, &thread_attr, &motion_web_control, cnt_list); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Waiting for threads to finish, pid: %d", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Waiting for threads to finish, pid: %d", getpid()); - /* + /* * Crude way of waiting for all threads to finish - check the thread * counter (because we cannot do join on the detached threads). */ while (1) { SLEEP(1, 0); - /* + /* * Calculate how many threads runnig or wants to run * if zero and we want to finish, break out */ @@ -2760,24 +2765,24 @@ int main (int argc, char **argv) motion_threads_running++; } - if (((motion_threads_running == 0) && finish) || + if (((motion_threads_running == 0) && finish) || ((motion_threads_running == 0) && (threads_running == 0))) { MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-1 threads_running %d motion_threads_running %d " - ", finish %d", threads_running, motion_threads_running, finish); + ", finish %d", threads_running, motion_threads_running, finish); break; - } + } for (i = (cnt_list[1] != NULL ? 1 : 0); cnt_list[i]; i++) { /* Check if threads wants to be restarted */ if ((!cnt_list[i]->running) && (cnt_list[i]->restart)) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion thread %d restart", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion thread %d restart", cnt_list[i]->threadnr); start_motion_thread(cnt_list[i], &thread_attr); } if (cnt_list[i]->watchdog > WATCHDOG_OFF) { cnt_list[i]->watchdog--; - + if (cnt_list[i]->watchdog == 0) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, trying to do " "a graceful restart", cnt_list[i]->threadnr); @@ -2785,7 +2790,7 @@ int main (int argc, char **argv) } if (cnt_list[i]->watchdog == -60) { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, did NOT restart graceful," + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, did NOT restart graceful," "killing it!", cnt_list[i]->threadnr); pthread_cancel(cnt_list[i]->thread_id); pthread_mutex_lock(&global_lock); @@ -2798,7 +2803,7 @@ int main (int argc, char **argv) } } - MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d", + MOTION_LOG(ALL, TYPE_ALL, NO_ERRNO, "%s: DEBUG-2 threads_running %d motion_threads_running %d finish %d", threads_running, motion_threads_running, finish); } /* Reset end main loop flag */ @@ -2853,9 +2858,9 @@ int main (int argc, char **argv) void * mymalloc(size_t nbytes) { void *dummy = calloc(nbytes, 1); - + if (!dummy) { - MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Could not allocate %llu bytes of memory!", + MOTION_LOG(EMG, TYPE_ALL, SHOW_ERRNO, "%s: Could not allocate %llu bytes of memory!", (unsigned long long)nbytes); motion_remove_pid(); exit(1); @@ -2934,7 +2939,7 @@ int create_path(const char *path) buffer[start-path] = 0x00; if (mkdir(buffer, mode) == -1 && errno != EEXIST) { - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem creating directory %s", + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Problem creating directory %s", buffer); free(buffer); return -1; @@ -2944,7 +2949,7 @@ int create_path(const char *path) if (!start) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: creating directory %s", buffer); - + free(buffer); } @@ -3000,7 +3005,7 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) dummy = fopen(path, mode); } } - + if (dummy) { if (bufsize > 0) { int i = 0; @@ -3023,9 +3028,9 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) buffers[i].fh = dummy; } else { - /* + /* * We are reusing an old buffer, but it is too - * small, realloc it + * small, realloc it */ i = first; buffers[i].fh = dummy; @@ -3035,9 +3040,9 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) } if (buffers[i].buffer == NULL) { - /* + /* * Our allocation failed, so just use the default - * OS buffers + * OS buffers */ buffers[i].fh = NULL; buffers[i].bufsize = 0; @@ -3058,7 +3063,7 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) * first time * 2: could still not open the file after the path was created */ - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening file %s with mode %s", + MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening file %s with mode %s", path, mode); } @@ -3068,16 +3073,16 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) /** * myfclose * - * Motion-specific variant of fclose() + * Motion-specific variant of fclose() * * Returns: fclose() return value - */ + */ int myfclose(FILE* fh) { int i = 0; int rval = fclose(fh); - if (rval != 0) + if (rval != 0) MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error closing file"); for (i = 0; i < MYBUFCOUNT; i++) { @@ -3100,7 +3105,7 @@ int myfclose(FILE* fh) * * Motion-specific variant of strftime(3) that supports additional format * specifiers in the format string. - * + * * Parameters: * * cnt - current thread's context structure @@ -3133,7 +3138,7 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us for (pos_userformat = userformat; *pos_userformat; ++pos_userformat) { if (*pos_userformat == '%') { - /* + /* * Reset 'tempstr' to point to the beginning of 'tempstring', * otherwise we will eat up tempstring if there are many * format specifiers. @@ -3232,7 +3237,7 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us continue; } - /* + /* * If a format specifier was found and used, copy the result from * 'tempstr' to 'format'. */ diff --git a/version.sh b/version.sh index 5963498..3ed1c92 100755 --- a/version.sh +++ b/version.sh @@ -4,5 +4,5 @@ SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' test $SNV_VERSION || SNV_VERSION=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` test $SNV_VERSION || SNV_VERSION=UNKNOWN SNV_VERSION=`git show -s --format=%h` -echo -n "3.2.12-Git-$SNV_VERSION" +echo -n "3.4.0-Git-$SNV_VERSION" From 95c6a9fd29c23cd13e6af4c2359225131b4ae210 Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Fri, 2 May 2014 12:31:36 +0200 Subject: [PATCH 056/233] Bugfix: calculate proper size for memset() The proper idiom is: memset(ptr, val, sizeof(*ptr)); These files were using: memset(ptr, val, sizeof(ptr)); --- alg.c | 4 ++-- motion.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alg.c b/alg.c index 93c260f..343ff47 100644 --- a/alg.c +++ b/alg.c @@ -534,7 +534,7 @@ static int alg_labeling(struct context *cnt) imgs->labels_above = 0; /* Init: 0 means no label set / not checked. */ - memset(labels, 0, width * height * sizeof(labels)); + memset(labels, 0, width * height * sizeof(*labels)); pixelpos = 0; for (iy = 0; iy < height - 1; iy++) { @@ -1363,6 +1363,6 @@ void alg_update_reference_frame(struct context *cnt, int action) /* Copy fresh image */ memcpy(cnt->imgs.ref, cnt->imgs.image_virgin, cnt->imgs.size); /* Reset static objects */ - memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); + memset(cnt->imgs.ref_dyn, 0, cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); } } diff --git a/motion.c b/motion.c index f8f5dc5..002df1e 100644 --- a/motion.c +++ b/motion.c @@ -917,7 +917,7 @@ static int motion_init(struct context *cnt) /* Always initialize smart_mask - someone could turn it on later... */ memset(cnt->imgs.smartmask, 0, cnt->imgs.motionsize); memset(cnt->imgs.smartmask_final, 255, cnt->imgs.motionsize); - memset(cnt->imgs.smartmask_buffer, 0, cnt->imgs.motionsize*sizeof(cnt->imgs.smartmask_buffer)); + memset(cnt->imgs.smartmask_buffer, 0, cnt->imgs.motionsize * sizeof(*cnt->imgs.smartmask_buffer)); /* Set noise level */ cnt->noise = cnt->conf.noise; From d0cc56c733ccfe2b3fe78c5f0f90944103fdc002 Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Fri, 2 May 2014 10:49:50 +0200 Subject: [PATCH 057/233] bugfix: motion.c: calculate proper allocation size The proper idiom for calculating the size for memory allocation is: ptr = malloc(sizeof(*ptr)); The sizeof() dereferences the pointer's type, and allocates enough memory to store an instance of that type. motion.c was using this idiom: ptr = malloc(sizeof(ptr)); This is incorrect, but thankfully fairly harmless in practice since the pointer type is usually quite large. Change this to the proper idiom. --- motion.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/motion.c b/motion.c index 002df1e..d47cdfc 100644 --- a/motion.c +++ b/motion.c @@ -723,13 +723,13 @@ static int motion_init(struct context *cnt) memset(cnt->imgs.out, 0, cnt->imgs.size); /* contains the moving objects of ref. frame */ - cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.ref_dyn)); + cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); cnt->imgs.image_virgin = mymalloc(cnt->imgs.size); cnt->imgs.smartmask = mymalloc(cnt->imgs.motionsize); cnt->imgs.smartmask_final = mymalloc(cnt->imgs.motionsize); - cnt->imgs.smartmask_buffer = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.smartmask_buffer)); - cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(cnt->imgs.labels)); - cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(cnt->imgs.labelsize)); + cnt->imgs.smartmask_buffer = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.smartmask_buffer)); + cnt->imgs.labels = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.labels)); + cnt->imgs.labelsize = mymalloc((cnt->imgs.motionsize/2+1) * sizeof(*cnt->imgs.labelsize)); /* Set output picture type */ if (!strcmp(cnt->conf.picture_type, "ppm")) From 8619b48d3a4ac676283e5dcff481c48be0ab3af7 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Sat, 11 Oct 2014 12:10:54 +0100 Subject: [PATCH 058/233] support -b to force running in background --- conf.c | 6 +++++- motion.1 | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conf.c b/conf.c index cf905c6..25717e4 100644 --- a/conf.c +++ b/conf.c @@ -1561,12 +1561,15 @@ 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:hmns?p:k:l:")) != EOF) + while ((c = getopt(conf->argc, conf->argv, "bc:d:hmns?p:k:l:")) != EOF) switch (c) { case 'c': if (thread == -1) strcpy(cnt->conf_filename, optarg); break; + case 'b': + cnt->daemon = 1; + break; case 'n': cnt->daemon = 0; break; @@ -2376,6 +2379,7 @@ static void usage() printf("\nusage:\tmotion [options]\n"); printf("\n\n"); printf("Possible options:\n\n"); + printf("-b\t\t\tRun in background (daemon) mode.\n"); printf("-n\t\t\tRun in non-daemon mode.\n"); printf("-s\t\t\tRun in setup mode.\n"); printf("-c config\t\tFull path and filename of config file.\n"); diff --git a/motion.1 b/motion.1 index a023f83..9a71ba9 100644 --- a/motion.1 +++ b/motion.1 @@ -3,7 +3,7 @@ motion \- Detect motion using a video4linux device .SH SYNOPSIS .B motion -[ -hmns ] [ -c config file path ] [ -d log level ] [ -k log type ] [ -p process_id_file ] [ -l logfile ] +[ -bhmns ] [ -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 @@ -20,6 +20,9 @@ Show help screen. .B \-m Disable motion detection at startup. .TP +.B \-b +Run in background (daemon) mode. +.TP .B \-n Run in non-daemon mode. .TP From ccdeee0073bd0648946dedbcf81060e275822694 Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Wed, 15 Oct 2014 18:24:48 +0200 Subject: [PATCH 059/233] mymalloc(): don't cast return value; void* is always promoted --- conf.c | 2 +- event.c | 2 +- motion.c | 2 +- netcam.c | 7 +++---- netcam_wget.c | 4 ++-- stream.c | 2 +- webhttpd.c | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/conf.c b/conf.c index 71b3ee0..7b40638 100644 --- a/conf.c +++ b/conf.c @@ -2170,7 +2170,7 @@ char *mystrdup(const char *from) } else { stringlength = strlen(from); stringlength = (stringlength < PATH_MAX ? stringlength : PATH_MAX); - tmp = (char *)mymalloc(stringlength + 1); + tmp = mymalloc(stringlength + 1); strncpy(tmp, from, stringlength); /* diff --git a/event.c b/event.c index 31566ec..ee7f43a 100644 --- a/event.c +++ b/event.c @@ -143,7 +143,7 @@ static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, // Close connection before start a new connection mysql_close(cnt->database); - cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); + cnt->database = mymalloc(sizeof(MYSQL)); mysql_init(cnt->database); if (!mysql_real_connect(cnt->database, cnt->conf.database_host, diff --git a/motion.c b/motion.c index d47cdfc..d3f4ffa 100644 --- a/motion.c +++ b/motion.c @@ -829,7 +829,7 @@ static int motion_init(struct context *cnt) // close database to be sure that we are not leaking mysql_close(cnt->database); - cnt->database = (MYSQL *) mymalloc(sizeof(MYSQL)); + cnt->database = mymalloc(sizeof(MYSQL)); mysql_init(cnt->database); if (!mysql_real_connect(cnt->database, cnt->conf.database_host, cnt->conf.database_user, diff --git a/netcam.c b/netcam.c index 700009f..92a22bb 100644 --- a/netcam.c +++ b/netcam.c @@ -121,7 +121,7 @@ static char *netcam_url_match(regmatch_t m, const char *input) if (m.rm_so != -1) { len = m.rm_eo - m.rm_so; - if ((match = (char *) mymalloc(len + 1)) != NULL) { + if ((match = mymalloc(len + 1)) != NULL) { strncpy(match, input + m.rm_so, len); match[len] = '\0'; } @@ -2128,7 +2128,7 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) int ix; /* First the http context structure. */ - netcam->response = (struct rbuf *) mymalloc(sizeof(struct rbuf)); + netcam->response = mymalloc(sizeof(struct rbuf)); memset(netcam->response, 0, sizeof(struct rbuf)); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam has flags:" @@ -2721,8 +2721,7 @@ int netcam_start(struct context *cnt) * Create a new netcam_context for this camera * and clear all the entries. */ - cnt->netcam = (struct netcam_context *) - mymalloc(sizeof(struct netcam_context)); + cnt->netcam = mymalloc(sizeof(struct netcam_context)); memset(cnt->netcam, 0, sizeof(struct netcam_context)); netcam = cnt->netcam; /* Just for clarity in remaining code. */ netcam->cnt = cnt; /* Fill in the "parent" info. */ diff --git a/netcam_wget.c b/netcam_wget.c index 71daac6..4491760 100644 --- a/netcam_wget.c +++ b/netcam_wget.c @@ -70,7 +70,7 @@ int header_get(netcam_context_ptr netcam, char **hdr, enum header_get_flags flag int i; int bufsize = 80; - *hdr = (char *)mymalloc(bufsize); + *hdr = mymalloc(bufsize); for (i = 0; 1; i++) { int res; @@ -257,7 +257,7 @@ void base64_encode(const char *s, char *store, int length) */ char *strdupdelim(const char *beg, const char *end) { - char *res = (char *)mymalloc(end - beg + 1); + char *res = mymalloc(end - beg + 1); memcpy (res, beg, end - beg); res[end - beg] = '\0'; diff --git a/stream.c b/stream.c index a073617..fbbb9f7 100644 --- a/stream.c +++ b/stream.c @@ -205,7 +205,7 @@ static void* handle_basic_auth(void* param) char *userpass = NULL; size_t auth_size = strlen(p->conf->stream_authentication); - authentication = (char *) mymalloc(BASE64_LENGTH(auth_size) + 1); + authentication = mymalloc(BASE64_LENGTH(auth_size) + 1); userpass = mymalloc(auth_size + 4); /* base64_encode can read 3 bytes after the end of the string, initialize it. */ memset(userpass, 0, auth_size + 4); diff --git a/webhttpd.c b/webhttpd.c index f7449df..614d2a8 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2498,7 +2498,7 @@ void httpd_run(struct context **cnt) char *userpass = NULL; size_t auth_size = strlen(cnt[0]->conf.webcontrol_authentication); - authentication = (char *) mymalloc(BASE64_LENGTH(auth_size) + 1); + authentication = mymalloc(BASE64_LENGTH(auth_size) + 1); userpass = mymalloc(auth_size + 4); /* base64_encode can read 3 bytes after the end of the string, initialize it */ memset(userpass, 0, auth_size + 4); From f7e0830978f6ca073a99d2557000b2adb3f6c33e Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Wed, 15 Oct 2014 18:31:32 +0200 Subject: [PATCH 060/233] mymalloc sets allocated memory to zero; no need for extra memset --- ffmpeg.c | 1 - motion.c | 1 - netcam.c | 6 ------ video_common.c | 1 - video_freebsd.c | 1 - 5 files changed, 10 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index a80c137..753e09b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -210,7 +210,6 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, * codec and image information we need to generate movies. */ ffmpeg = mymalloc(sizeof(struct ffmpeg)); - memset(ffmpeg, 0, sizeof(struct ffmpeg)); ffmpeg->vbr = vbr; ffmpeg->tlapse = tlapse; diff --git a/motion.c b/motion.c index d3f4ffa..2ca0c8d 100644 --- a/motion.c +++ b/motion.c @@ -720,7 +720,6 @@ static int motion_init(struct context *cnt) cnt->imgs.ref = mymalloc(cnt->imgs.size); cnt->imgs.out = mymalloc(cnt->imgs.size); - memset(cnt->imgs.out, 0, cnt->imgs.size); /* contains the moving objects of ref. frame */ cnt->imgs.ref_dyn = mymalloc(cnt->imgs.motionsize * sizeof(*cnt->imgs.ref_dyn)); diff --git a/netcam.c b/netcam.c index 92a22bb..90b747d 100644 --- a/netcam.c +++ b/netcam.c @@ -1850,7 +1850,6 @@ tfile_context *file_new_context(void) if (!ret) return ret; - memset(ret, 0, sizeof(tfile_context)); return ret; } @@ -2129,7 +2128,6 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) /* First the http context structure. */ netcam->response = mymalloc(sizeof(struct rbuf)); - memset(netcam->response, 0, sizeof(struct rbuf)); MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: Netcam has flags:" " HTTP/1.0: %s HTTP/1.1: %s Keep-Alive %s.", @@ -2722,7 +2720,6 @@ int netcam_start(struct context *cnt) * and clear all the entries. */ cnt->netcam = mymalloc(sizeof(struct netcam_context)); - memset(cnt->netcam, 0, sizeof(struct netcam_context)); netcam = cnt->netcam; /* Just for clarity in remaining code. */ netcam->cnt = cnt; /* Fill in the "parent" info. */ @@ -2733,15 +2730,12 @@ int netcam_start(struct context *cnt) /* Our image buffers */ netcam->receiving = mymalloc(sizeof(netcam_buff)); - memset(netcam->receiving, 0, sizeof(netcam_buff)); netcam->receiving->ptr = mymalloc(NETCAM_BUFFSIZE); netcam->jpegbuf = mymalloc(sizeof(netcam_buff)); - memset(netcam->jpegbuf, 0, sizeof(netcam_buff)); netcam->jpegbuf->ptr = mymalloc(NETCAM_BUFFSIZE); netcam->latest = mymalloc(sizeof(netcam_buff)); - memset(netcam->latest, 0, sizeof(netcam_buff)); netcam->latest->ptr = mymalloc(NETCAM_BUFFSIZE); netcam->timeout.tv_sec = READ_TIMEOUT; diff --git a/video_common.c b/video_common.c index 9f8d6a0..5ce2ebc 100644 --- a/video_common.c +++ b/video_common.c @@ -726,7 +726,6 @@ static int vid_v4lx_start(struct context *cnt) conf->video_device, conf->input); dev = mymalloc(sizeof(struct video_dev)); - memset(dev, 0, sizeof(struct video_dev)); dev->video_device = conf->video_device; diff --git a/video_freebsd.c b/video_freebsd.c index ec98a55..66a0165 100644 --- a/video_freebsd.c +++ b/video_freebsd.c @@ -1161,7 +1161,6 @@ int vid_start(struct context *cnt) dev = mymalloc(sizeof(struct video_dev)); - memset(dev, 0, sizeof(struct video_dev)); fd_bktr = open(conf->video_device, O_RDWR); From 8f5bf18c48022941c72cc6551f5a339d06fd5e38 Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Wed, 15 Oct 2014 21:56:08 +0200 Subject: [PATCH 061/233] netcam.c: tfile_context(): simplify function This function always returned `ret`, so might as well take a shortcut and return the pointer directly. --- netcam.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/netcam.c b/netcam.c index 90b747d..1ae90e5 100644 --- a/netcam.c +++ b/netcam.c @@ -1843,14 +1843,8 @@ static int netcam_read_file_jpeg(netcam_context_ptr netcam) tfile_context *file_new_context(void) { - tfile_context *ret; - /* Note that mymalloc will exit on any problem. */ - ret = mymalloc(sizeof(tfile_context)); - if (!ret) - return ret; - - return ret; + return mymalloc(sizeof(tfile_context)); } void file_free_context(tfile_context* ctxt) From a36801e6dd24374958122fc6d1027f1efa7d5dd4 Mon Sep 17 00:00:00 2001 From: Alfred Klomp Date: Wed, 15 Oct 2014 23:46:37 +0200 Subject: [PATCH 062/233] free(): remove unnecessary NULL pointer checks Calling free() on a NULL pointer is a completely harmless. Reduce code complexity by removing the unnecessary checks. --- event.c | 9 ++---- motion.c | 84 +++++++++++++++++---------------------------------- netcam.c | 69 ++++++++++++------------------------------ netcam_ftp.c | 12 ++------ netcam_rtsp.c | 6 ++-- picture.c | 3 +- stream.c | 17 +++-------- video2.c | 9 ++---- webhttpd.c | 3 +- 9 files changed, 67 insertions(+), 145 deletions(-) diff --git a/event.c b/event.c index ee7f43a..59870f6 100644 --- a/event.c +++ b/event.c @@ -745,8 +745,7 @@ static void event_ffmpeg_closefile(struct context *cnt, { if (cnt->ffmpeg_output) { - if (cnt->ffmpeg_output->udata) - free(cnt->ffmpeg_output->udata); + free(cnt->ffmpeg_output->udata); ffmpeg_close(cnt->ffmpeg_output); cnt->ffmpeg_output = NULL; @@ -755,8 +754,7 @@ static void event_ffmpeg_closefile(struct context *cnt, } if (cnt->ffmpeg_output_debug) { - if (cnt->ffmpeg_output_debug->udata) - free(cnt->ffmpeg_output_debug->udata); + free(cnt->ffmpeg_output_debug->udata); ffmpeg_close(cnt->ffmpeg_output_debug); cnt->ffmpeg_output_debug = NULL; @@ -771,8 +769,7 @@ static void event_ffmpeg_timelapseend(struct context *cnt, struct tm *tm ATTRIBUTE_UNUSED) { if (cnt->ffmpeg_timelapse) { - if (cnt->ffmpeg_timelapse->udata) - free(cnt->ffmpeg_timelapse->udata); + free(cnt->ffmpeg_timelapse->udata); ffmpeg_close(cnt->ffmpeg_timelapse); cnt->ffmpeg_timelapse = NULL; diff --git a/motion.c b/motion.c index 2ca0c8d..c265aac 100644 --- a/motion.c +++ b/motion.c @@ -971,60 +971,38 @@ static void motion_cleanup(struct context *cnt) vid_close(cnt); } - if (cnt->imgs.out) { - free(cnt->imgs.out); - cnt->imgs.out = NULL; - } + free(cnt->imgs.out); + cnt->imgs.out = NULL; - if (cnt->imgs.ref) { - free(cnt->imgs.ref); - cnt->imgs.ref = NULL; - } + free(cnt->imgs.ref); + cnt->imgs.ref = NULL; - if (cnt->imgs.ref_dyn) { - free(cnt->imgs.ref_dyn); - cnt->imgs.ref_dyn = NULL; - } + free(cnt->imgs.ref_dyn); + cnt->imgs.ref_dyn = NULL; - if (cnt->imgs.image_virgin) { - free(cnt->imgs.image_virgin); - cnt->imgs.image_virgin = NULL; - } + free(cnt->imgs.image_virgin); + cnt->imgs.image_virgin = NULL; - if (cnt->imgs.labels) { - free(cnt->imgs.labels); - cnt->imgs.labels = NULL; - } + free(cnt->imgs.labels); + cnt->imgs.labels = NULL; - if (cnt->imgs.labelsize) { - free(cnt->imgs.labelsize); - cnt->imgs.labelsize = NULL; - } + free(cnt->imgs.labelsize); + cnt->imgs.labelsize = NULL; - if (cnt->imgs.smartmask) { - free(cnt->imgs.smartmask); - cnt->imgs.smartmask = NULL; - } + free(cnt->imgs.smartmask); + cnt->imgs.smartmask = NULL; - if (cnt->imgs.smartmask_final) { - free(cnt->imgs.smartmask_final); - cnt->imgs.smartmask_final = NULL; - } + free(cnt->imgs.smartmask_final); + cnt->imgs.smartmask_final = NULL; - if (cnt->imgs.smartmask_buffer) { - free(cnt->imgs.smartmask_buffer); - cnt->imgs.smartmask_buffer = NULL; - } + free(cnt->imgs.smartmask_buffer); + cnt->imgs.smartmask_buffer = NULL; - if (cnt->imgs.common_buffer) { - free(cnt->imgs.common_buffer); - cnt->imgs.common_buffer = NULL; - } + free(cnt->imgs.common_buffer); + cnt->imgs.common_buffer = NULL; - if (cnt->imgs.preview_image.image) { - free(cnt->imgs.preview_image.image); - cnt->imgs.preview_image.image = NULL; - } + free(cnt->imgs.preview_image.image); + cnt->imgs.preview_image.image = NULL; image_ring_destroy(cnt); /* Cleanup the precapture ring buffer */ @@ -1041,16 +1019,12 @@ static void motion_cleanup(struct context *cnt) } /* Cleanup the current time structure */ - if (cnt->currenttime_tm) { - free(cnt->currenttime_tm); - cnt->currenttime_tm = NULL; - } + free(cnt->currenttime_tm); + cnt->currenttime_tm = NULL; /* Cleanup the event time structure */ - if (cnt->eventtime_tm) { - free(cnt->eventtime_tm); - cnt->eventtime_tm = NULL; - } + free(cnt->eventtime_tm); + cnt->eventtime_tm = NULL; if (cnt->conf.database_type) { #ifdef HAVE_MYSQL @@ -2230,8 +2204,7 @@ static void *motion_loop(void *arg) * If code continues here it is because the thread is exiting or restarting */ err: - if (rolling_average_data) - free(rolling_average_data); + free(rolling_average_data); cnt->lost_connection = 1; MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread exiting"); @@ -3089,8 +3062,7 @@ int myfclose(FILE* fh) buffers[i].fh = NULL; if ( finish ) { /* Free the buffers */ - if (buffers[i].buffer) - free(buffers[i].buffer); + free(buffers[i].buffer); buffers[i].buffer = NULL; buffers[i].bufsize = 0; } diff --git a/netcam.c b/netcam.c index 1ae90e5..2eda9bc 100644 --- a/netcam.c +++ b/netcam.c @@ -226,25 +226,17 @@ static void netcam_url_parse(struct url_t *parse_url, const char *text_url) */ void netcam_url_free(struct url_t *parse_url) { - if (parse_url->service) { - free(parse_url->service); - parse_url->service = NULL; - } + free(parse_url->service); + parse_url->service = NULL; - if (parse_url->userpass) { - free(parse_url->userpass); - parse_url->userpass = NULL; - } + free(parse_url->userpass); + parse_url->userpass = NULL; - if (parse_url->host) { - free(parse_url->host); - parse_url->host = NULL; - } + free(parse_url->host); + parse_url->host = NULL; - if (parse_url->path) { - free(parse_url->path); - parse_url->path = NULL; - } + free(parse_url->path); + parse_url->path = NULL; } /** @@ -333,8 +325,7 @@ static int netcam_check_keepalive(char *header) return -1; /* We do not detect the second field or other case mixes at present. */ - if (content_type) - free(content_type); + free(content_type); return 1; } @@ -364,8 +355,7 @@ static int netcam_check_close(char *header) if (!strcmp(type, "close")) /* strcmp returns 0 for match. */ ret = 1; - if (type) - free(type); + free(type); return ret; } @@ -409,8 +399,7 @@ static int netcam_check_content_type(char *header) ret = 0; } - if (content_type) - free(content_type); + free(content_type); return ret; } @@ -652,8 +641,7 @@ static int netcam_read_first_header(netcam_context_ptr netcam) if ((boundary = strstr(header, "boundary="))) { /* On error recovery this may already be set. */ - if (netcam->boundary) - free(netcam->boundary); + free(netcam->boundary); netcam->boundary = mystrdup(boundary + 9); /* @@ -1852,9 +1840,7 @@ void file_free_context(tfile_context* ctxt) if (ctxt == NULL) return; - if (ctxt->path != NULL) - free(ctxt->path); - + free(ctxt->path); free(ctxt); } @@ -2561,35 +2547,23 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) pthread_mutex_unlock(&netcam->mutex); /* and cleanup the rest of the netcam_context structure. */ - if (netcam->connect_host != NULL) - free(netcam->connect_host); - - if (netcam->connect_request != NULL) - free(netcam->connect_request); - - - if (netcam->boundary != NULL) - free(netcam->boundary); + free(netcam->connect_host); + free(netcam->connect_request); + free(netcam->boundary); if (netcam->latest != NULL) { - if (netcam->latest->ptr != NULL) - free(netcam->latest->ptr); - + free(netcam->latest->ptr); free(netcam->latest); } if (netcam->receiving != NULL) { - if (netcam->receiving->ptr != NULL) - free(netcam->receiving->ptr); - + free(netcam->receiving->ptr); free(netcam->receiving); } if (netcam->jpegbuf != NULL) { - if (netcam->jpegbuf->ptr != NULL) - free(netcam->jpegbuf->ptr); - + free(netcam->jpegbuf->ptr); free(netcam->jpegbuf); } @@ -2598,10 +2572,7 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) else netcam_disconnect(netcam); - - if (netcam->response != NULL) - free(netcam->response); - + free(netcam->response); if (netcam->caps.streaming == NCS_RTSP) netcam_shutdown_rtsp(netcam); diff --git a/netcam_ftp.c b/netcam_ftp.c index 7a0451f..a6533c1 100644 --- a/netcam_ftp.c +++ b/netcam_ftp.c @@ -57,15 +57,9 @@ void ftp_free_context(ftp_context_pointer ctxt) if (ctxt == NULL) return; - if (ctxt->path != NULL) - free(ctxt->path); - - if (ctxt->user) - free(ctxt->user); - - if (ctxt->passwd) - free(ctxt->passwd); - + free(ctxt->path); + free(ctxt->user); + free(ctxt->passwd); if (ctxt->control_file_desc >= 0) close(ctxt->control_file_desc); diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 1c90a81..3309fbb 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -746,9 +746,9 @@ void netcam_shutdown_rtsp(netcam_context_ptr netcam){ MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO,"%s: netcam shut down"); } - if (netcam->rtsp->path != NULL) free(netcam->rtsp->path); - if (netcam->rtsp->user != NULL) free(netcam->rtsp->user); - if (netcam->rtsp->pass != NULL) free(netcam->rtsp->pass); + free(netcam->rtsp->path); + free(netcam->rtsp->user); + free(netcam->rtsp->pass); free(netcam->rtsp); netcam->rtsp = NULL; diff --git a/picture.c b/picture.c index 9284280..f658534 100644 --- a/picture.c +++ b/picture.c @@ -392,8 +392,7 @@ static void put_jpeg_exif(j_compress_ptr cinfo, /* EXIF data lives in a JPEG APP1 marker */ jpeg_write_marker(cinfo, JPEG_APP0 + 1, marker, marker_len); - if (description) - free(description); + free(description); free(marker); } diff --git a/stream.c b/stream.c index fbbb9f7..782a966 100644 --- a/stream.c +++ b/stream.c @@ -584,11 +584,8 @@ static void* handle_md5_digest(void* param) goto Error; } - if(server_user) - free(server_user); - - if(server_pass) - free(server_pass); + free(server_user); + free(server_pass); /* Lock the mutex */ pthread_mutex_lock(&stream_auth_mutex); @@ -604,11 +601,8 @@ static void* handle_md5_digest(void* param) pthread_exit(NULL); InternalError: - if(server_user) - free(server_user); - - if(server_pass) - free(server_pass); + free(server_user); + free(server_pass); if (write(p->sock, internal_error_template, strlen(internal_error_template)) < 0) MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: write failure 3:handle_md5_digest"); @@ -698,8 +692,7 @@ static void do_client_auth(struct context *cnt, int sc) Error: close(sc); - if(handle_param) - free(handle_param); + free(handle_param); } /** diff --git a/video2.c b/video2.c index 9896edb..2ee14f9 100644 --- a/video2.c +++ b/video2.c @@ -854,8 +854,7 @@ unsigned char *v4l2_start(struct context *cnt, struct video_dev *viddev, int wid return (void *) 1; err: - if (vid_source) - free(vid_source); + free(vid_source); viddev->v4l2_private = NULL; viddev->v4l2 = 0; @@ -1101,10 +1100,8 @@ void v4l2_cleanup(struct video_dev *viddev) vid_source->buffers = NULL; } - if (vid_source->controls) { - free(vid_source->controls); - vid_source->controls = NULL; - } + free(vid_source->controls); + vid_source->controls = NULL; free(vid_source); viddev->v4l2_private = NULL; diff --git a/webhttpd.c b/webhttpd.c index 614d2a8..2b3a133 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2528,8 +2528,7 @@ void httpd_run(struct context **cnt) } - if (authentication != NULL) - free(authentication); + free(authentication); close(sd); MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd Closing"); pthread_mutex_destroy(&httpd_mutex); From f38c5a876f9b79968ba0a90166eae3586ae5c8fc Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 18 Oct 2014 12:40:33 -0700 Subject: [PATCH 063/233] Update CHANGELOG --- CHANGELOG | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7199066..d2718d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,13 @@ Summary of Changes - + * Merge mymalloc, free and casting changes from Alfred Klomp + * Merge bug fix for sizeof from Alfred Klomp + * Rewrote timelapse so that it works + * Merge tosiara changes for version number + * Add copyright file for features added since 3.2.12 + * Cleanup ffmpeg.c and plug memory leak + * Add support for latest version of ffmpeg/libav + * Tidy up packaging changes + * Add packaging fixes (infinity0) * Revise version.sh to put out the git commit. * Rollback revision to allow for a formal pull request. * Reimplement changes not to be included in pull request from tosiara commit 9ebee031 From f3d36d4fce7f3374a1f2f9d5a12c2544e237c675 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 18 Oct 2014 12:47:02 -0700 Subject: [PATCH 064/233] Fix compile without ffmpeg and older versions --- CHANGELOG | 1 + ffmpeg.c | 4 +++- ffmpeg.h | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d2718d9..f615778 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Changes to ffmpeg.h/ffmpeg.c to allow for compiling without ffmpeg/libav or with older versions. * Merge mymalloc, free and casting changes from Alfred Klomp * Merge bug fix for sizeof from Alfred Klomp * Rewrote timelapse so that it works diff --git a/ffmpeg.c b/ffmpeg.c index 753e09b..febe41e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -46,6 +46,7 @@ #define MY_CODEC_ID_FLV1 AV_CODEC_ID_FLV1 #define MY_CODEC_ID_FFV1 AV_CODEC_ID_FFV1 #define MY_CODEC_ID_NONE AV_CODEC_ID_NONE +#define MY_CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO #else @@ -53,6 +54,7 @@ #define MY_CODEC_ID_FLV1 CODEC_ID_FLV1 #define MY_CODEC_ID_FFV1 CODEC_ID_FFV1 #define MY_CODEC_ID_NONE CODEC_ID_NONE +#define MY_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO #endif /*********************************************/ @@ -144,7 +146,7 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename){ if (strcmp(codec, "tlapse") == 0) { ext = ".swf"; of = av_guess_format("swf", NULL, NULL); - if (of) of->video_codec = AV_CODEC_ID_MPEG2VIDEO; + if (of) of->video_codec = MY_CODEC_ID_MPEG2VIDEO; } else if (strcmp(codec, "mpeg4") == 0) { ext = ".avi"; of = av_guess_format("avi", NULL, NULL); diff --git a/ffmpeg.h b/ffmpeg.h index 25dbdaf..46737d4 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -1,12 +1,13 @@ #ifndef _INCLUDE_FFMPEG_H_ #define _INCLUDE_FFMPEG_H_ +#include +#include + #ifdef HAVE_FFMPEG #include #include -#include -#include #endif /* HAVE_FFMPEG */ From 9479d910f2149b5558788bb86f97f26522794212 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 18 Oct 2014 12:53:11 -0700 Subject: [PATCH 065/233] Updated configure script --- configure | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/configure b/configure index cba5c78..dc06adf 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.69 for motion 3.4.0-Git-d35a11e. +# Generated by GNU Autoconf 2.69 for motion 3.4.0-Git-78ba2da. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='3.4.0-Git-d35a11e' -PACKAGE_STRING='motion 3.4.0-Git-d35a11e' +PACKAGE_VERSION='3.4.0-Git-78ba2da' +PACKAGE_STRING='motion 3.4.0-Git-78ba2da' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1246,7 +1246,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 3.4.0-Git-d35a11e to adapt to many kinds of systems. +\`configure' configures motion 3.4.0-Git-78ba2da to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1307,7 +1307,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion 3.4.0-Git-d35a11e:";; + short | recursive ) echo "Configuration of motion 3.4.0-Git-78ba2da:";; esac cat <<\_ACEOF @@ -1457,7 +1457,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure 3.4.0-Git-d35a11e +motion configure 3.4.0-Git-78ba2da generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2059,7 +2059,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 3.4.0-Git-d35a11e, which was +It was created by motion $as_me 3.4.0-Git-78ba2da, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -7316,7 +7316,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 3.4.0-Git-d35a11e, which was +This file was extended by motion $as_me 3.4.0-Git-78ba2da, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7378,7 +7378,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 3.4.0-Git-d35a11e +motion config.status 3.4.0-Git-78ba2da configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" From 8d99f2815af6a8620be72990398c695e0a8eef2c Mon Sep 17 00:00:00 2001 From: tosiara Date: Tue, 14 Oct 2014 10:54:19 +0300 Subject: [PATCH 066/233] Optimization of function mjpegtoyuv420p Patch proposed by Github user aklomp Link: https://github.com/Mr-Dave/motion/issues/49 --- video_common.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/video_common.c b/video_common.c index 5ce2ebc..54569c6 100644 --- a/video_common.c +++ b/video_common.c @@ -387,42 +387,15 @@ void conv_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, */ int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size) { - uint8_t *yuv[3]; - unsigned char *y, *u, *v; - int loop, ret; - - yuv[0] = mymalloc(width * height * sizeof(yuv[0][0])); - yuv[1] = mymalloc(width * height / 4 * sizeof(yuv[1][0])); - yuv[2] = mymalloc(width * height / 4 * sizeof(yuv[2][0])); - - - ret = decode_jpeg_raw(cap_map, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]); + int ret = decode_jpeg_raw(cap_map, size, 0, 420, width, height, + map, + map + (width * height), + map + (width * height) + (width * height) / 4); if (ret == 1) { MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Corrupt image ... continue"); ret = 2; } - - y = map; - u = y + width * height; - v = u + (width * height) / 4; - memset(y, 0, width * height); - memset(u, 0, width * height / 4); - memset(v, 0, width * height / 4); - - for(loop = 0; loop < width * height; loop++) - *map++ = yuv[0][loop]; - - for(loop = 0; loop < width * height / 4; loop++) - *map++ = yuv[1][loop]; - - for(loop = 0; loop < width * height / 4; loop++) - *map++ = yuv[2][loop]; - - free(yuv[0]); - free(yuv[1]); - free(yuv[2]); - return ret; } From bfbfebadccfa68403fe769ffc6555a72f8319f75 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Tue, 21 Oct 2014 19:26:45 -0700 Subject: [PATCH 067/233] Allow netcams with modulo 8 dimensions --- CHANGELOG | 1 + netcam.c | 12 ++++++------ netcam_rtsp.c | 18 +++++++++--------- picture.c | 43 +++++++++++++++++++++++++++++-------------- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f615778..1a3c1ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Revised picture.c to allow for modulo 8 pictures and adjusted netcam modules accordingly as well. * Changes to ffmpeg.h/ffmpeg.c to allow for compiling without ffmpeg/libav or with older versions. * Merge mymalloc, free and casting changes from Alfred Klomp * Merge bug fix for sizeof from Alfred Klomp diff --git a/netcam.c b/netcam.c index 2eda9bc..2dbc587 100644 --- a/netcam.c +++ b/netcam.c @@ -2666,7 +2666,7 @@ int netcam_next(struct context *cnt, unsigned char *image) * * Returns: 0 on success * -1 on any failure - * -3 image dimensions are not modulo 16 + * -3 image dimensions are not modulo 8 */ int netcam_start(struct context *cnt) @@ -2865,17 +2865,17 @@ int netcam_start(struct context *cnt) } /* * Motion currently requires that image height and width is a - * multiple of 16. So we check for this. + * multiple of 8. So we check for this. */ - if (netcam->width % 16) { + if (netcam->width % 8) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" - " is not modulo 16", netcam->width); + " is not modulo 8", netcam->width); return -3; } - if (netcam->height % 16) { + if (netcam->height % 8) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" - " is not modulo 16", netcam->height); + " is not modulo 8", netcam->height); return -3; } diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 3309fbb..45e61b3 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -853,15 +853,15 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ /* * Warn and fix dimensions as needed. */ - if (netcam->cnt->conf.width % 16) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image width (%d) requested is not modulo 16.", netcam->cnt->conf.width); - netcam->cnt->conf.width = netcam->cnt->conf.width - (netcam->cnt->conf.width % 16) + 16; - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting width to next higher multiple of 16 (%d).", netcam->cnt->conf.width); - } - if (netcam->cnt->conf.height % 16) { - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image height (%d) requested is not modulo 16.", netcam->cnt->conf.height); - netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 16) + 16; - MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 16 (%d).", netcam->cnt->conf.height); + if (netcam->cnt->conf.width % 8) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image width (%d) requested is not modulo 8.", netcam->cnt->conf.width); + netcam->cnt->conf.width = netcam->cnt->conf.width - (netcam->cnt->conf.width % 8) + 8; + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting width to next higher multiple of 8 (%d).", netcam->cnt->conf.width); + } + if (netcam->cnt->conf.height % 8) { + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Image height (%d) requested is not modulo 8.", netcam->cnt->conf.height); + netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 8) + 8; + MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 8 (%d).", netcam->cnt->conf.height); } av_register_all(); diff --git a/picture.c b/picture.c index f658534..2e9550f 100644 --- a/picture.c +++ b/picture.c @@ -452,21 +452,30 @@ static int put_jpeg_yuv420p_memory(unsigned char *dest_image, int image_size, jpeg_set_quality(&cinfo, quality, TRUE); cinfo.dct_method = JDCT_FASTEST; - + _jpeg_mem_dest(&cinfo, dest_image, image_size); // Data written to mem + jpeg_start_compress(&cinfo, TRUE); put_jpeg_exif(&cinfo, cnt, tm, box); - + + /* If the image is not a multiple of 16, this overruns the buffers + * we'll just pad those last bytes with zeros + */ for (j = 0; j < height; j += 16) { for (i = 0; i < 16; i++) { - y[i] = input_image + width * (i + j); - - if (i % 2 == 0) { - cb[i / 2] = input_image + width * height + width / 2 * ((i + j) /2); - cr[i / 2] = input_image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); - } + if ((width * (i + j)) < (width * height)) { + y[i] = input_image + width * (i + j); + if (i % 2 == 0) { + cb[i / 2] = input_image + width * height + width / 2 * ((i + j) /2); + cr[i / 2] = input_image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); + } + } else { + y[i] = 0x00; + cb[i] = 0x00; + cr[i] = 0x00; + } } jpeg_write_raw_data(&cinfo, data, 16); } @@ -594,12 +603,18 @@ static void put_jpeg_yuv420p_file(FILE *fp, for (j = 0; j < height; j += 16) { for (i = 0; i < 16; i++) { - y[i] = image + width * (i + j); - if (i % 2 == 0) { - cb[i / 2] = image + width * height + width / 2 * ((i + j) / 2); - cr[i / 2] = image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); - } - } + if ((width * (i + j)) < (width * height)) { + y[i] = image + width * (i + j); + if (i % 2 == 0) { + cb[i / 2] = image + width * height + width / 2 * ((i + j) / 2); + cr[i / 2] = image + width * height + width * height / 4 + width / 2 * ((i + j) / 2); + } + } else { + y[i] = 0x00; + cb[i] = 0x00; + cr[i] = 0x00; + } + } jpeg_write_raw_data(&cinfo, data, 16); } From dcbd514147b4497c51f4abb83af58d8e2b0ce956 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Thu, 23 Oct 2014 12:55:15 +0100 Subject: [PATCH 068/233] forward definition for setup_signals(), needed on OpenBSD --- motion.c | 1 + 1 file changed, 1 insertion(+) diff --git a/motion.c b/motion.c index c265aac..072a835 100644 --- a/motion.c +++ b/motion.c @@ -25,6 +25,7 @@ /* Forward declarations */ static int motion_init(struct context *cnt); static void motion_cleanup(struct context *cnt); +static void setup_signals(struct sigaction *, struct sigaction *); /** From 80633f222bad01ea1584567c15cb82d666b3eff9 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Thu, 23 Oct 2014 12:55:53 +0100 Subject: [PATCH 069/233] include rotate.h (for pthread.h) before netcam_rtsp.h --- netcam_rtsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 3309fbb..93e6a31 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -19,8 +19,8 @@ ***********************************************************/ #include -#include "netcam_rtsp.h" #include "rotate.h" /* already includes motion.h */ +#include "netcam_rtsp.h" #ifdef HAVE_FFMPEG From eef23f02b5ca42b9dcc4ab6dfcaf459d2a58cade Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Thu, 23 Oct 2014 12:56:30 +0100 Subject: [PATCH 070/233] check for V4L2 header in sys/videoio.h as well as linux/videodev.h --- configure.ac | 9 ++++++--- track.c | 2 +- video.h | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index a92e8b8..6730d62 100755 --- a/configure.ac +++ b/configure.ac @@ -915,7 +915,7 @@ fi #Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h) +AC_CHECK_HEADERS(stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h sys/videoio.h) AC_CHECK_FUNCS(get_current_dir_name) @@ -931,8 +931,11 @@ else [SUPPORTED_V4L2=true], [SUPPORTED_V4L2=false], [#include - #include ]) - + #ifdef HAVE_LINUX_VIDEODEV_H + #include + #elif HAVE_SYS_VIDEOIO_H + #include + #endif]) AC_MSG_CHECKING(for V42L support) if test x$SUPPORTED_V4L2 = xtrue; then AC_MSG_RESULT(yes) diff --git a/track.c b/track.c index 0d7e3b3..46e65ff 100644 --- a/track.c +++ b/track.c @@ -9,7 +9,7 @@ #include #include "motion.h" -#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) +#if (defined(HAVE_LINUX_VIDEODEV_H) || defined(HAVE_SYS_VIDEOIO_H)) && (!defined(WITHOUT_V4L)) #include "pwc-ioctl.h" #endif diff --git a/video.h b/video.h index 12f2928..193087b 100644 --- a/video.h +++ b/video.h @@ -14,8 +14,12 @@ #include -#if defined(HAVE_LINUX_VIDEODEV_H) && (!defined(WITHOUT_V4L)) +#if !defined(WITHOUT_V4L) +#if defined(HAVE_LINUX_VIDEODEV_H) #include +#elif defined(HAVE_SYS_VIDEOIO_H) +#include +#endif #include "vloopback_motion.h" #include "pwc-ioctl.h" #endif From 570faea249c0e3885029e003575e70a7c28f573b Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Thu, 23 Oct 2014 12:56:50 +0100 Subject: [PATCH 071/233] ioctl(2) "request" is an unsigned long on OpenBSD --- video2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/video2.c b/video2.c index 2ee14f9..e1a617a 100644 --- a/video2.c +++ b/video2.c @@ -179,7 +179,11 @@ typedef struct { /** * xioctl */ +#ifdef __OpenBSD__ +static int xioctl(int fd, unsigned long request, void *arg) +#else static int xioctl(int fd, int request, void *arg) +#endif { int ret; From ec580999d0bab6f54919ceb3a17b53741a8ab3ed Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Thu, 23 Oct 2014 12:57:12 +0100 Subject: [PATCH 072/233] don't detect any *BSD as FreeBSD --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6730d62..a426ec4 100755 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ if test "${Darwin}" = ""; then AC_MSG_RESULT(no) AC_MSG_CHECKING(for *BSD) - FreeBSD=`uname -a | grep "BSD"` + FreeBSD=`uname -a | grep "FreeBSD"` if test "${FreeBSD}" = ""; then AC_MSG_RESULT(no) VIDEO="video.o video2.o video_common.o" From 43f9e569bbf13887fa2044f7cbf38f608590868b Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Thu, 23 Oct 2014 12:57:30 +0100 Subject: [PATCH 073/233] add comment to config file, need to use input 0 on OpenBSD --- motion-dist.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 21a0570..fd4a969 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -73,6 +73,7 @@ v4l2_palette 17 # 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 +# Set to 0 for uvideo(4) on OpenBSD input -1 # The video norm to use (only for video capture and TV tuner cards) From 120cc4bb6589d3b7044d27587687859c1cad51be Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 23 Oct 2014 20:20:59 -0700 Subject: [PATCH 074/233] Update changelog --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 1a3c1ca..6ce404b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Merge OpenBSD fixes from sthen pull request * Revised picture.c to allow for modulo 8 pictures and adjusted netcam modules accordingly as well. * Changes to ffmpeg.h/ffmpeg.c to allow for compiling without ffmpeg/libav or with older versions. * Merge mymalloc, free and casting changes from Alfred Klomp From fb9befa241763d557f13f6d26b19ce9f927495ff Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 23 Oct 2014 20:23:46 -0700 Subject: [PATCH 075/233] Revise version script --- CHANGELOG | 4 +++- version.sh | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6ce404b..84ba5ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ Summary of Changes + * Revise version number generated by script to indicate Unofficial-Git-'hash' + * Revised Changelog description for version 3.4 * Merge OpenBSD fixes from sthen pull request * Revised picture.c to allow for modulo 8 pictures and adjusted netcam modules accordingly as well. * Changes to ffmpeg.h/ffmpeg.c to allow for compiling without ffmpeg/libav or with older versions. @@ -21,7 +23,7 @@ Summary of Changes * Revised debian packaging files * Implement new sequence for this file (CHANGELOG) newest to oldest. -3.4.0 Summary of Changes +Summary of Changes that were proposed to maintainer for a version 3.4 Features * Insert Blanking frames http://www.lavrsen.dk/twiki/bin/view/Motion/FeatureRequest2007x12x16x132522 (Dag Erlandsson) diff --git a/version.sh b/version.sh index 3ed1c92..8111433 100755 --- a/version.sh +++ b/version.sh @@ -3,6 +3,9 @@ SNV_VERSION=`cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2` test $SNV_VERSION || SNV_VERSION=`cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2` test $SNV_VERSION || SNV_VERSION=UNKNOWN -SNV_VERSION=`git show -s --format=%h` -echo -n "3.4.0-Git-$SNV_VERSION" +GITDIR=".git" +if [ -d "$GITDIR" ]; then + SNV_VERSION=`git show -s --format=%h` +fi +echo -n "Unofficial-Git-$SNV_VERSION" From c943a67b1cafc7537a23e6dd061aa0c4f79d4b21 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 23 Oct 2014 20:24:33 -0700 Subject: [PATCH 076/233] Bump configure script --- configure | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/configure b/configure index dc06adf..568fe70 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.69 for motion 3.4.0-Git-78ba2da. +# Generated by GNU Autoconf 2.69 for motion Unofficial-Git-fb9befa. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='3.4.0-Git-78ba2da' -PACKAGE_STRING='motion 3.4.0-Git-78ba2da' +PACKAGE_VERSION='Unofficial-Git-fb9befa' +PACKAGE_STRING='motion Unofficial-Git-fb9befa' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1246,7 +1246,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 3.4.0-Git-78ba2da to adapt to many kinds of systems. +\`configure' configures motion Unofficial-Git-fb9befa to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1307,7 +1307,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion 3.4.0-Git-78ba2da:";; + short | recursive ) echo "Configuration of motion Unofficial-Git-fb9befa:";; esac cat <<\_ACEOF @@ -1457,7 +1457,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure 3.4.0-Git-78ba2da +motion configure Unofficial-Git-fb9befa generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2059,7 +2059,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 3.4.0-Git-78ba2da, which was +It was created by motion $as_me Unofficial-Git-fb9befa, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4235,7 +4235,7 @@ $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 $as_echo_n "checking for *BSD... " >&6; } - FreeBSD=`uname -a | grep "BSD"` + FreeBSD=`uname -a | grep "FreeBSD"` if test "${FreeBSD}" = ""; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -6120,7 +6120,7 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi -for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h +for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h sys/videoio.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6157,7 +6157,11 @@ $as_echo_n "checking for V42L support... " >&6; } $as_echo "skipping" >&6; } else ac_fn_c_check_type "$LINENO" "struct v4l2_buffer" "ac_cv_type_struct_v4l2_buffer" "#include + #ifdef HAVE_LINUX_VIDEODEV_H #include + #elif HAVE_SYS_VIDEOIO_H + #include + #endif " if test "x$ac_cv_type_struct_v4l2_buffer" = xyes; then : SUPPORTED_V4L2=true @@ -6165,7 +6169,6 @@ else SUPPORTED_V4L2=false fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 $as_echo_n "checking for V42L support... " >&6; } if test x$SUPPORTED_V4L2 = xtrue; then @@ -7316,7 +7319,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 3.4.0-Git-78ba2da, which was +This file was extended by motion $as_me Unofficial-Git-fb9befa, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7378,7 +7381,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 3.4.0-Git-78ba2da +motion config.status Unofficial-Git-fb9befa configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" From 93ca6f8f270d90cd9f72455de174231825fba9dc Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 27 Oct 2014 19:03:02 -0700 Subject: [PATCH 077/233] Lock thread for ffmpeg/libav init --- CHANGELOG | 1 + netcam_rtsp.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 84ba5ec..10d2955 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Lock thread on ffmpeg/libav init and open_codec * Revise version number generated by script to indicate Unofficial-Git-'hash' * Revised Changelog description for version 3.4 * Merge OpenBSD fixes from sthen pull request diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 550948e..0bcaca0 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -197,8 +197,10 @@ static int netcam_open_codec(int *stream_idx, AVFormatContext *fmt_ctx, enum AVM return -1; } - /* Open the codec */ - ret = avcodec_open2(dec_ctx, dec, NULL); + /* Open the codec It is not thread safe so lock it*/ + pthread_mutex_lock(&global_lock); + ret = avcodec_open2(dec_ctx, dec, NULL); + pthread_mutex_unlock(&global_lock); if (ret < 0) { av_strerror(ret, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Failed to open codec!: %s", errstr); @@ -863,11 +865,17 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ netcam->cnt->conf.height = netcam->cnt->conf.height - (netcam->cnt->conf.height % 8) + 8; MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Adjusting height to next higher multiple of 8 (%d).", netcam->cnt->conf.height); } - - av_register_all(); - avformat_network_init(); - avcodec_register_all(); + /* + * Documentation does not indicate thread safety on these + * init functions but we lock them just in case. + */ + pthread_mutex_lock(&global_lock); + av_register_all(); + avformat_network_init(); + avcodec_register_all(); + pthread_mutex_unlock(&global_lock); + /* * The RTSP context should be all ready to attempt a connection with * the server, so we try .... From c3b21b11b6d2242729f46852075ee0989463f519 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 27 Oct 2014 19:03:54 -0700 Subject: [PATCH 078/233] bump configure --- configure | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 568fe70..ca6dd56 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.69 for motion Unofficial-Git-fb9befa. +# Generated by GNU Autoconf 2.69 for motion Unofficial-Git-93ca6f8. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Unofficial-Git-fb9befa' -PACKAGE_STRING='motion Unofficial-Git-fb9befa' +PACKAGE_VERSION='Unofficial-Git-93ca6f8' +PACKAGE_STRING='motion Unofficial-Git-93ca6f8' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1246,7 +1246,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 Unofficial-Git-fb9befa to adapt to many kinds of systems. +\`configure' configures motion Unofficial-Git-93ca6f8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1307,7 +1307,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Unofficial-Git-fb9befa:";; + short | recursive ) echo "Configuration of motion Unofficial-Git-93ca6f8:";; esac cat <<\_ACEOF @@ -1457,7 +1457,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Unofficial-Git-fb9befa +motion configure Unofficial-Git-93ca6f8 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2059,7 +2059,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 Unofficial-Git-fb9befa, which was +It was created by motion $as_me Unofficial-Git-93ca6f8, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -7319,7 +7319,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 Unofficial-Git-fb9befa, which was +This file was extended by motion $as_me Unofficial-Git-93ca6f8, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7381,7 +7381,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 Unofficial-Git-fb9befa +motion config.status Unofficial-Git-93ca6f8 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" From c0757d4fa9046bad40040710adc4765b2903654d Mon Sep 17 00:00:00 2001 From: tosiara Date: Sun, 25 Jan 2015 19:00:09 +0200 Subject: [PATCH 079/233] Fix typo. EMR is not a valid log level. Should be EMG --- conf.c | 4 ++-- motion-dist.conf.in | 2 +- motion.1 | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf.c b/conf.c index abd4538..ecac41b 100644 --- a/conf.c +++ b/conf.c @@ -221,7 +221,7 @@ config_param config_params[] = { }, { "log_level", - "# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC)", + "# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC)", 1, CONF_OFFSET(log_level), copy_int, @@ -2383,7 +2383,7 @@ static void usage() printf("-n\t\t\tRun in non-daemon mode.\n"); 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("-d level\t\tLog level (1-9) (EMG, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). default: 6 / NTC.\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"); diff --git a/motion-dist.conf.in b/motion-dist.conf.in index fd4a969..5f148d3 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -24,7 +24,7 @@ setup_mode off # Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) ;logfile /tmp/motion.log -# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) +# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) log_level 6 # Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) diff --git a/motion.1 b/motion.1 index 161f1b1..6713386 100644 --- a/motion.1 +++ b/motion.1 @@ -30,7 +30,7 @@ Run in non-daemon mode. Run in setup mode. Also forces non-daemon mode .TP .B \-d log level -Set log level [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) +Set log level [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) .TP .B \-k log type Set type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) @@ -230,7 +230,7 @@ Use a file to save logs messages, if not defined stderr and syslog is used. ( if .B log_level integer Values: 1 - 9 / Default: 6 .br -Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC). +Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC). .TP .B log_type discrete strings Values: STR, ENC, NET, DBL, EVT, TRK, VID, ALL / Default: ALL From 5c6f4be9e60a5115989b1cf34e14ea7c826bfa8e Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sun, 25 Jan 2015 17:12:50 -0700 Subject: [PATCH 080/233] Bump Configure --- configure | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/configure b/configure index ca6dd56..56d647e 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.69 for motion Unofficial-Git-93ca6f8. +# Generated by GNU Autoconf 2.69 for motion Unofficial-Git-a5b5f13. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Unofficial-Git-93ca6f8' -PACKAGE_STRING='motion Unofficial-Git-93ca6f8' +PACKAGE_VERSION='Unofficial-Git-a5b5f13' +PACKAGE_STRING='motion Unofficial-Git-a5b5f13' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1246,7 +1246,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 Unofficial-Git-93ca6f8 to adapt to many kinds of systems. +\`configure' configures motion Unofficial-Git-a5b5f13 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1307,7 +1307,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Unofficial-Git-93ca6f8:";; + short | recursive ) echo "Configuration of motion Unofficial-Git-a5b5f13:";; esac cat <<\_ACEOF @@ -1457,7 +1457,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Unofficial-Git-93ca6f8 +motion configure Unofficial-Git-a5b5f13 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2059,7 +2059,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 Unofficial-Git-93ca6f8, which was +It was created by motion $as_me Unofficial-Git-a5b5f13, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -7319,7 +7319,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 Unofficial-Git-93ca6f8, which was +This file was extended by motion $as_me Unofficial-Git-a5b5f13, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7381,7 +7381,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 Unofficial-Git-93ca6f8 +motion config.status Unofficial-Git-a5b5f13 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" From cb6a30088278d85ee4e4cdf34df9c0febc0ccccc Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 4 Feb 2015 12:17:38 +0200 Subject: [PATCH 081/233] Fix for ftp_send_type - was missing type param Author: mterzo https://github.com/mterzo/motion/commit/2dbff19b9dc1a6505e1a279bc210d44259bd789d --- netcam_ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netcam_ftp.c b/netcam_ftp.c index a6533c1..f91d0db 100644 --- a/netcam_ftp.c +++ b/netcam_ftp.c @@ -789,7 +789,7 @@ int ftp_send_type(ftp_context_pointer ctxt, char type) toupper(type); /* Assure transfer will be in "image" mode. */ - snprintf(buf, sizeof(buf), "TYPE I\r\n"); + snprintf(buf, sizeof(buf), "TYPE %c\r\n", utype); len = strlen(buf); res = send(ctxt->control_file_desc, buf, len, 0); From 003a666af20db56ec1dc2483a196beed5171a6da Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Tue, 28 Oct 2014 04:35:09 -0400 Subject: [PATCH 082/233] Moved #define events to an enum and added a to string option --- event.c | 121 ++++++++++++++++++++++++++++++++++++++++++-------------- event.h | 49 ++++++++++++----------- 2 files changed, 118 insertions(+), 52 deletions(-) diff --git a/event.c b/event.c index 59870f6..1647631 100644 --- a/event.c +++ b/event.c @@ -17,6 +17,41 @@ /* Various functions (most doing the actual action) */ +const char *eventList[] = { + "NULL", + "EVENT_FILECREATE", + "EVENT_MOTION", + "EVENT_FIRSTMOTION", + "EVENT_ENDMOTION", + "EVENT_STOP", + "EVENT_TIMELAPSE", + "EVENT_TIMELAPSEEND", + "EVENT_STREAM", + "EVENT_IMAGE_DETECTED", + "EVENT_IMAGEM_DETECTED", + "EVENT_IMAGE_SNAPSHOT", + "EVENT_IMAGE", + "EVENT_IMAGEM", + "EVENT_FILECLOSE", + "EVENT_DEBUG", + "EVENT_CRITICAL", + "EVENT_AREA_DETECTED", + "EVENT_CAMERA_LOST", + "EVENT_FFMPEG_PUT", + "EVENT_SDL_PUT", + "EVENT_LAST" +}; + +/** + * eventToString + * + * returns string label of the event + */ +static const char *eventToString(motion_event e) +{ + return eventList[(int)e]; +} + /** * exec_command * Execute 'command' with 'arg' as its argument. @@ -61,15 +96,16 @@ static void exec_command(struct context *cnt, char *command, char *filename, int */ static void event_newfile(struct context *cnt ATTRIBUTE_UNUSED, - int type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, - char *filename, void *ftype, struct tm *tm ATTRIBUTE_UNUSED) + motion_event type ATTRIBUTE_UNUSED, + unsigned char *dummy ATTRIBUTE_UNUSED, char *filename, void *ftype, + struct tm *tm ATTRIBUTE_UNUSED) { MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: File of type %ld saved to: %s", (unsigned long)ftype, filename); } -static void event_beep(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_beep(struct context *cnt, motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, char *filename ATTRIBUTE_UNUSED, void *ftype ATTRIBUTE_UNUSED, @@ -88,7 +124,8 @@ static void event_beep(struct context *cnt, int type ATTRIBUTE_UNUSED, * to the config parameter. */ static void on_picture_save_command(struct context *cnt, - int type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, + motion_event type ATTRIBUTE_UNUSED, + unsigned char *dummy ATTRIBUTE_UNUSED, char *filename, void *arg, struct tm *tm ATTRIBUTE_UNUSED) { int filetype = (unsigned long)arg; @@ -101,7 +138,8 @@ static void on_picture_save_command(struct context *cnt, } static void on_motion_detected_command(struct context *cnt, - int type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, + motion_event type ATTRIBUTE_UNUSED, + unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -111,7 +149,8 @@ static void on_motion_detected_command(struct context *cnt, #if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) -static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_sqlnewfile(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, char *filename, void *arg, struct tm *tm ATTRIBUTE_UNUSED) { @@ -215,7 +254,8 @@ static void event_sqlnewfile(struct context *cnt, int type ATTRIBUTE_UNUSED, #endif /* defined HAVE_MYSQL || defined HAVE_PGSQL || defined(HAVE_SQLITE3) */ -static void on_area_command(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void on_area_command(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) @@ -224,7 +264,8 @@ static void on_area_command(struct context *cnt, int type ATTRIBUTE_UNUSED, exec_command(cnt, cnt->conf.on_area_detected, NULL, 0); } -static void on_event_start_command(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void on_event_start_command(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) @@ -233,7 +274,8 @@ static void on_event_start_command(struct context *cnt, int type ATTRIBUTE_UNUSE exec_command(cnt, cnt->conf.on_event_start, NULL, 0); } -static void on_event_end_command(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void on_event_end_command(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) @@ -242,7 +284,8 @@ static void on_event_end_command(struct context *cnt, int type ATTRIBUTE_UNUSED, exec_command(cnt, cnt->conf.on_event_end, NULL, 0); } -static void event_stop_stream(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_stop_stream(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) @@ -251,7 +294,8 @@ static void event_stop_stream(struct context *cnt, int type ATTRIBUTE_UNUSED, stream_stop(cnt); } -static void event_stream_put(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_stream_put(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -260,7 +304,8 @@ static void event_stream_put(struct context *cnt, int type ATTRIBUTE_UNUSED, } #ifdef HAVE_SDL -static void event_sdl_put(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_sdl_put(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -270,7 +315,8 @@ static void event_sdl_put(struct context *cnt, int type ATTRIBUTE_UNUSED, #if defined(HAVE_LINUX_VIDEODEV_H) && !defined(WITHOUT_V4L) && !defined(BSD) -static void event_vid_putpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_vid_putpipe(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy ATTRIBUTE_UNUSED, void *devpipe, struct tm *tm ATTRIBUTE_UNUSED) { @@ -289,7 +335,8 @@ const char *imageext(struct context *cnt) return "jpg"; } -static void event_image_detect(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_image_detect(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *newimg, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { @@ -315,7 +362,8 @@ static void event_image_detect(struct context *cnt, int type ATTRIBUTE_UNUSED, } } -static void event_imagem_detect(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_imagem_detect(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *newimg ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { @@ -345,7 +393,8 @@ static void event_imagem_detect(struct context *cnt, int type ATTRIBUTE_UNUSED, } } -static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_image_snapshot(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { @@ -391,7 +440,8 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, cnt->snapshot = 0; } -static void event_camera_lost(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_camera_lost(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm ATTRIBUTE_UNUSED) { @@ -399,7 +449,8 @@ static void event_camera_lost(struct context *cnt, int type ATTRIBUTE_UNUSED, exec_command(cnt, cnt->conf.on_camera_lost, NULL, 0); } -static void on_movie_end_command(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void on_movie_end_command(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, char *filename, void *arg, struct tm *tm ATTRIBUTE_UNUSED) { @@ -409,7 +460,8 @@ static void on_movie_end_command(struct context *cnt, int type ATTRIBUTE_UNUSED, exec_command(cnt, cnt->conf.on_movie_end, filename, filetype); } -static void event_extpipe_end(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_extpipe_end(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -424,7 +476,8 @@ static void event_extpipe_end(struct context *cnt, int type ATTRIBUTE_UNUSED, } } -static void event_create_extpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_create_extpipe(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { @@ -490,7 +543,8 @@ static void event_create_extpipe(struct context *cnt, int type ATTRIBUTE_UNUSED, } } -static void event_extpipe_put(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_extpipe_put(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -511,7 +565,8 @@ static void event_extpipe_put(struct context *cnt, int type ATTRIBUTE_UNUSED, } -static void event_new_video(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_new_video(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *dummy ATTRIBUTE_UNUSED, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -537,7 +592,8 @@ static void grey2yuv420p(unsigned char *u, unsigned char *v, int width, int heig } -static void event_ffmpeg_newfile(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_ffmpeg_newfile(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { @@ -626,7 +682,7 @@ static void event_ffmpeg_newfile(struct context *cnt, int type ATTRIBUTE_UNUSED, } static void event_ffmpeg_timelapse(struct context *cnt, - int type ATTRIBUTE_UNUSED, unsigned char *img, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { @@ -708,7 +764,8 @@ static void event_ffmpeg_timelapse(struct context *cnt, } -static void event_ffmpeg_put(struct context *cnt, int type ATTRIBUTE_UNUSED, +static void event_ffmpeg_put(struct context *cnt, + motion_event type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -739,7 +796,8 @@ static void event_ffmpeg_put(struct context *cnt, int type ATTRIBUTE_UNUSED, } static void event_ffmpeg_closefile(struct context *cnt, - int type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, + motion_event type ATTRIBUTE_UNUSED, + unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -764,7 +822,8 @@ static void event_ffmpeg_closefile(struct context *cnt, } static void event_ffmpeg_timelapseend(struct context *cnt, - int type ATTRIBUTE_UNUSED, unsigned char *dummy1 ATTRIBUTE_UNUSED, + motion_event type ATTRIBUTE_UNUSED, + unsigned char *dummy1 ATTRIBUTE_UNUSED, char *dummy2 ATTRIBUTE_UNUSED, void *dummy3 ATTRIBUTE_UNUSED, struct tm *tm ATTRIBUTE_UNUSED) { @@ -786,7 +845,7 @@ static void event_ffmpeg_timelapseend(struct context *cnt, */ struct event_handlers { - int type; + motion_event type; event_handler handler; }; @@ -931,12 +990,14 @@ struct event_handlers event_handlers[] = { * The split between unsigned images and signed filenames was introduced in 3.2.2 * as a code reading friendly solution to avoid a stream of compiler warnings in gcc 4.0. */ -void event(struct context *cnt, int type, unsigned char *image, char *filename, void *eventdata, struct tm *tm) +void event(struct context *cnt, motion_event type, unsigned char *image, + char *filename, void *eventdata, struct tm *tm) { int i=-1; while (event_handlers[++i].handler) { if (type == event_handlers[i].type) - event_handlers[i].handler(cnt, type, image, filename, eventdata, tm); + event_handlers[i].handler(cnt, type, image, filename, eventdata, + tm); } } diff --git a/event.h b/event.h index d226566..50ee69f 100644 --- a/event.h +++ b/event.h @@ -11,31 +11,36 @@ #ifndef _INCLUDE_EVENT_H_ #define _INCLUDE_EVENT_H_ -#define EVENT_FILECREATE 1 -#define EVENT_MOTION 2 -#define EVENT_FIRSTMOTION 3 -#define EVENT_ENDMOTION 4 -#define EVENT_STOP 5 -#define EVENT_TIMELAPSE 6 -#define EVENT_TIMELAPSEEND 7 -#define EVENT_STREAM 8 -#define EVENT_IMAGE_DETECTED 9 -#define EVENT_IMAGEM_DETECTED 10 -#define EVENT_IMAGE_SNAPSHOT 11 -#define EVENT_IMAGE 12 -#define EVENT_IMAGEM 13 -#define EVENT_FILECLOSE 14 -#define EVENT_DEBUG 15 -#define EVENT_CRITICAL 16 -#define EVENT_AREA_DETECTED 17 -#define EVENT_CAMERA_LOST 18 -#define EVENT_FFMPEG_PUT 19 -#define EVENT_SDL_PUT 20 +typedef enum { + EVENT_FILECREATE = 1, + EVENT_MOTION, + EVENT_FIRSTMOTION, + EVENT_ENDMOTION, + EVENT_STOP, + EVENT_TIMELAPSE, + EVENT_TIMELAPSEEND, + EVENT_STREAM, + EVENT_IMAGE_DETECTED, + EVENT_IMAGEM_DETECTED, + EVENT_IMAGE_SNAPSHOT, + EVENT_IMAGE, + EVENT_IMAGEM, + EVENT_FILECLOSE, + EVENT_DEBUG, + EVENT_CRITICAL, + EVENT_AREA_DETECTED, + EVENT_CAMERA_LOST, + EVENT_FFMPEG_PUT, + EVENT_SDL_PUT, + EVENT_LAST, +} motion_event; -typedef void(* event_handler)(struct context *, int, unsigned char *, char *, void *, struct tm *); +typedef void(* event_handler)(struct context *, motion_event, unsigned char *, + char *, void *, struct tm *); -void event(struct context *, int, unsigned char *, char *, void *, struct tm *); +void event(struct context *, motion_event, unsigned char *, char *, void *, + struct tm *); const char * imageext(struct context *); #endif /* _INCLUDE_EVENT_H_ */ From e81e3e726e3d7a0dee04c91921d56418175b11a5 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 4 Feb 2015 12:24:36 +0200 Subject: [PATCH 083/233] Typo fix, was build break --- netcam_ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netcam_ftp.c b/netcam_ftp.c index f91d0db..3040400 100644 --- a/netcam_ftp.c +++ b/netcam_ftp.c @@ -789,7 +789,7 @@ int ftp_send_type(ftp_context_pointer ctxt, char type) toupper(type); /* Assure transfer will be in "image" mode. */ - snprintf(buf, sizeof(buf), "TYPE %c\r\n", utype); + snprintf(buf, sizeof(buf), "TYPE %c\r\n", type); len = strlen(buf); res = send(ctxt->control_file_desc, buf, len, 0); From e433706bb7366bf038d4372a27b5d1675bbb6a3a Mon Sep 17 00:00:00 2001 From: tosiara Date: Mon, 16 Mar 2015 14:25:55 +0200 Subject: [PATCH 084/233] Typo fix. ERR was mentioned twice, while it should have been INF --- conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf.c b/conf.c index ecac41b..8454ac1 100644 --- a/conf.c +++ b/conf.c @@ -221,7 +221,7 @@ config_param config_params[] = { }, { "log_level", - "# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC)", + "# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC)", 1, CONF_OFFSET(log_level), copy_int, @@ -2383,7 +2383,7 @@ static void usage() printf("-n\t\t\tRun in non-daemon mode.\n"); 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) (EMG, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). default: 6 / NTC.\n"); + printf("-d level\t\tLog level (1-9) (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). default: 6 / NTC.\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"); From d71cebf8e84bd72585ab946a68649e7792bbd0c2 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 20 Mar 2015 00:12:51 -0600 Subject: [PATCH 085/233] Fix FTP option --- CHANGELOG | 1 + motion.c | 4 ++-- netcam.c | 21 +++++++++++++++------ netcam_ftp.c | 2 ++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 10d2955..e1a07ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Fixed the network ftp image option. * Lock thread on ffmpeg/libav init and open_codec * Revise version number generated by script to indicate Unofficial-Git-'hash' * Revised Changelog description for version 3.4 diff --git a/motion.c b/motion.c index 072a835..7f6e6fd 100644 --- a/motion.c +++ b/motion.c @@ -662,7 +662,7 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) * Returns: 0 OK * -1 Fatal error, open loopback error * -2 Fatal error, open SQL database error - * -3 Fatal error, image dimensions are not modulo 16 + * -3 Fatal error, image dimensions are not modulo 8 */ static int motion_init(struct context *cnt) { @@ -713,7 +713,7 @@ static int motion_init(struct context *cnt) cnt->imgs.type = VIDEO_PALETTE_YUV420P; } else if (cnt->video_dev == -2) { MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Could not fetch initial image from camera " - "Motion only supports width and height modulo 16"); + "Motion only supports width and height modulo 8"); return -3; } diff --git a/netcam.c b/netcam.c index 2dbc587..cdf27ee 100644 --- a/netcam.c +++ b/netcam.c @@ -2366,7 +2366,12 @@ static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) * ownership" of the string away from the URL (i.e. it won't be freed * when we cleanup the url structure later). */ - netcam->ftp->path = url->path; + if (strcmp(url->path,"/")){ + netcam->ftp->path = mystrdup(url->path + 1); + } else { + netcam->ftp->path = mystrdup(url->path); + } + url->path = NULL; if (cnt->conf.netcam_userpass != NULL) { @@ -2395,6 +2400,7 @@ static int netcam_setup_ftp(netcam_context_ptr netcam, struct url_t *url) */ if (ftp_connect(netcam) < 0) { ftp_free_context(netcam->ftp); + netcam->ftp = NULL; return -1; } @@ -2567,10 +2573,12 @@ void netcam_cleanup(netcam_context_ptr netcam, int init_retry_flag) free(netcam->jpegbuf); } - if (netcam->ftp != NULL) + if (netcam->ftp != NULL) { ftp_free_context(netcam->ftp); - else + netcam->ftp = NULL; + } else { netcam_disconnect(netcam); + } free(netcam->response); @@ -2841,7 +2849,8 @@ int netcam_start(struct context *cnt) if ((retval = netcam->get_image(netcam)) != 0) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Failed trying to " "read first image - retval:%d", retval); - netcam->rtsp->status = RTSP_NOTCONNECTED; + if (netcam->caps.streaming == NCS_RTSP) + netcam->rtsp->status = RTSP_NOTCONNECTED; return -1; } @@ -2870,13 +2879,13 @@ int netcam_start(struct context *cnt) if (netcam->width % 8) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image width (%d)" " is not modulo 8", netcam->width); - return -3; + return -2; } if (netcam->height % 8) { MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: netcam image height (%d)" " is not modulo 8", netcam->height); - return -3; + return -2; } diff --git a/netcam_ftp.c b/netcam_ftp.c index a6533c1..841c3ad 100644 --- a/netcam_ftp.c +++ b/netcam_ftp.c @@ -251,6 +251,8 @@ static int ftp_get_response(ftp_context_pointer ctxt) ctxt->control_buffer_index = ptr - ctxt->control_buffer; + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Server Response: %s",ctxt->control_buffer); + return (res / 100); } From c5d39b1c03f123513587851342facbbfbf076c10 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 20 Mar 2015 00:14:42 -0600 Subject: [PATCH 086/233] Bump configure --- configure | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 56d647e..b4c4200 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.69 for motion Unofficial-Git-a5b5f13. +# Generated by GNU Autoconf 2.69 for motion Unofficial-Git-d71cebf. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Unofficial-Git-a5b5f13' -PACKAGE_STRING='motion Unofficial-Git-a5b5f13' +PACKAGE_VERSION='Unofficial-Git-d71cebf' +PACKAGE_STRING='motion Unofficial-Git-d71cebf' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1246,7 +1246,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 Unofficial-Git-a5b5f13 to adapt to many kinds of systems. +\`configure' configures motion Unofficial-Git-d71cebf to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1307,7 +1307,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Unofficial-Git-a5b5f13:";; + short | recursive ) echo "Configuration of motion Unofficial-Git-d71cebf:";; esac cat <<\_ACEOF @@ -1457,7 +1457,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Unofficial-Git-a5b5f13 +motion configure Unofficial-Git-d71cebf generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2059,7 +2059,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 Unofficial-Git-a5b5f13, which was +It was created by motion $as_me Unofficial-Git-d71cebf, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -7319,7 +7319,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 Unofficial-Git-a5b5f13, which was +This file was extended by motion $as_me Unofficial-Git-d71cebf, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7381,7 +7381,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 Unofficial-Git-a5b5f13 +motion config.status Unofficial-Git-d71cebf configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" From cc49c75d2274fe271450f2b416ec37b0fdd22070 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Mon, 11 May 2015 16:20:38 -0700 Subject: [PATCH 087/233] Sqlite3 changes - use local sqlite3.c if found. new option to set busy_timeout (wait on locked condition) --- conf.h | 1 + configure.ac | 28 ++++++++++++++++++++-------- motion-dist.conf.in | 4 ++++ motion.c | 7 ++++++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/conf.h b/conf.h index c487b9e..4aaa79b 100644 --- a/conf.h +++ b/conf.h @@ -110,6 +110,7 @@ struct config { const char *database_user; const char *database_password; const char *sqlite3_db; + int sqlite3_busy_timeout; int database_port; char *on_picture_save; char *on_area_detected; diff --git a/configure.ac b/configure.ac index a426ec4..8fbee5f 100755 --- a/configure.ac +++ b/configure.ac @@ -610,15 +610,27 @@ if test "${SQLITE3}" = "no"; then else saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS - - AC_CHECK_LIB(sqlite3, sqlite3_open, - [ - TEMP_LIBS="$TEMP_LIBS -lsqlite3" - SQLITE3_SUPPORT="yes" - AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 support]) - ] + # first we check to see if the sqlite3 amalgamation (sqlite3.c), is in with our source + # this is the prefered way to use sqlite + AC_CHECK_FILE([sqlite3.c], + [ + SQLITE3_SUPPORT="yes" + VIDEO="$VIDEO sqlite3.o" + TEMP_LIBS="$TEMP_LIBS -ldl" + AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 imbedded support]) + ] + , + [ + # if sqlite3.c is not found then we look for the shared library + AC_CHECK_LIB(sqlite3, sqlite3_open, + [ + TEMP_LIBS="$TEMP_LIBS -lsqlite3" + SQLITE3_SUPPORT="yes" + AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 shared library support]) + ] + ) + ] ) - CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS fi diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 5f148d3..33fb1e4 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -703,6 +703,10 @@ quiet on # SQLite3 database (file path) (default: not defined) ; sqlite3_db value +# SQLite3 wait time in milliseconds for locked database to +# be unlocked before returning database locked error (default 0) +; sqlite3_busy_timeout 0 + ############################################################ diff --git a/motion.c b/motion.c index 7f6e6fd..bd3a015 100644 --- a/motion.c +++ b/motion.c @@ -812,7 +812,7 @@ static int motion_init(struct context *cnt) #ifdef HAVE_SQLITE3 if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { - MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: DB %s", + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 Database filename %s", cnt->conf.sqlite3_db); if (sqlite3_open(cnt->conf.sqlite3_db, &cnt->database_sqlite3) != SQLITE_OK) { @@ -821,6 +821,11 @@ static int motion_init(struct context *cnt) sqlite3_close(cnt->database_sqlite3); exit(1); } + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %s msec", + cnt->conf.sqlite3_busy_timeout); + if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.sqlite3_busy_timeout) != SQLITE_OK) + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s : %s\n", + cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); } #endif /* HAVE_SQLITE3 */ From 2f43f947b6a13ca863888caeda2d34684d842f4d Mon Sep 17 00:00:00 2001 From: jdodgen Date: Tue, 12 May 2015 12:24:09 -0700 Subject: [PATCH 088/233] V4L2 missing a #include --- track.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/track.c b/track.c index 46e65ff..cc0a709 100644 --- a/track.c +++ b/track.c @@ -5,7 +5,9 @@ * Copyright 2000, Jeroen Vreeken * This program is published under the GNU Public license */ - +#ifdef MOTION_V4L2 +#include +#endif /* MOTION_V4L2 */ #include #include "motion.h" From ea0d11eb8f4a8e0aaa9fec375c44f54ccd28c828 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Tue, 12 May 2015 15:52:00 -0700 Subject: [PATCH 089/233] lastsnap allow path information when doing a singelton lastsnap picture --- event.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/event.c b/event.c index 59870f6..2800f0e 100644 --- a/event.c +++ b/event.c @@ -350,8 +350,13 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { char fullfilename[PATH_MAX]; - - if (strcmp(cnt->conf.snappath, "lastsnap")) { + int len = strlen(cnt->conf.snappath); + int offset = 0; + if (len >= 9) + { + offset = len - 8; + } + if (strcmp(cnt->conf.snappath+offset, "lastsnap")) { char filename[PATH_MAX]; char filepath[PATH_MAX]; char linkpath[PATH_MAX]; @@ -383,7 +388,11 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, return; } } else { - snprintf(fullfilename, PATH_MAX, "%s/lastsnap.%s", cnt->conf.filepath, imageext(cnt)); + char filename[PATH_MAX]; + char filepath[PATH_MAX]; + mystrftime(cnt, filepath, sizeof(filepath), cnt->conf.snappath, currenttime_tm, NULL, 0); + snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); + snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); remove(fullfilename); put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); } From 5a31c0b44993440ca28c0796ec7cf262b20ecfce Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 15:32:54 -0700 Subject: [PATCH 090/233] moved declarations up --- event.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/event.c b/event.c index 2800f0e..378b496 100644 --- a/event.c +++ b/event.c @@ -351,14 +351,14 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, { char fullfilename[PATH_MAX]; int len = strlen(cnt->conf.snappath); + char filename[PATH_MAX]; + char filepath[PATH_MAX]; int offset = 0; if (len >= 9) { offset = len - 8; } - if (strcmp(cnt->conf.snappath+offset, "lastsnap")) { - char filename[PATH_MAX]; - char filepath[PATH_MAX]; + if (strcmp(cnt->conf.snappath+offset, "lastsnap")) char linkpath[PATH_MAX]; const char *snappath; /* @@ -388,8 +388,6 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, return; } } else { - char filename[PATH_MAX]; - char filepath[PATH_MAX]; mystrftime(cnt, filepath, sizeof(filepath), cnt->conf.snappath, currenttime_tm, NULL, 0); snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); From 06e4f3bc1f2abbbba145493c94565c6e338b8ef5 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 15:39:36 -0700 Subject: [PATCH 091/233] replacing spaces with tabs --- event.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/event.c b/event.c index 378b496..4329094 100644 --- a/event.c +++ b/event.c @@ -350,16 +350,16 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { char fullfilename[PATH_MAX]; - int len = strlen(cnt->conf.snappath); + int len = strlen(cnt->conf.snappath); char filename[PATH_MAX]; char filepath[PATH_MAX]; - int offset = 0; - if (len >= 9) - { + int offset = 0; + if (len >= 9) + { offset = len - 8; } - if (strcmp(cnt->conf.snappath+offset, "lastsnap")) - char linkpath[PATH_MAX]; + if (strcmp(cnt->conf.snappath+offset, "lastsnap")) + char linkpath[PATH_MAX]; const char *snappath; /* * conf.snappath would normally be defined but if someone deleted it by control interface From 0cb7a049e12b6506538d3ecc3252ae78241ce995 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 15:42:28 -0700 Subject: [PATCH 092/233] more spaces to tabs --- event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/event.c b/event.c index 4329094..77fe903 100644 --- a/event.c +++ b/event.c @@ -391,11 +391,11 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, mystrftime(cnt, filepath, sizeof(filepath), cnt->conf.snappath, currenttime_tm, NULL, 0); snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); - remove(fullfilename); - put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); + remove(fullfilename); + put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); } - cnt->snapshot = 0; + cnt->snapshot = 0; } static void event_camera_lost(struct context *cnt, int type ATTRIBUTE_UNUSED, From 899ce50ce92e45d057ffd4f76752f50341df4353 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 15:43:50 -0700 Subject: [PATCH 093/233] whoops did one wrong now tab to space conversion :) --- event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event.c b/event.c index 77fe903..44bf42a 100644 --- a/event.c +++ b/event.c @@ -395,7 +395,7 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); } - cnt->snapshot = 0; + cnt->snapshot = 0; } static void event_camera_lost(struct context *cnt, int type ATTRIBUTE_UNUSED, From cc3cafdce5a9a5f2e991e2d116b87031cdb36fab Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 16:08:29 -0700 Subject: [PATCH 094/233] Another tab to space change --- event.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/event.c b/event.c index 44bf42a..e3ce367 100644 --- a/event.c +++ b/event.c @@ -349,11 +349,11 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { - char fullfilename[PATH_MAX]; - int len = strlen(cnt->conf.snappath); + char fullfilename[PATH_MAX]; char filename[PATH_MAX]; char filepath[PATH_MAX]; int offset = 0; + int len = strlen(cnt->conf.snappath); if (len >= 9) { offset = len - 8; @@ -391,8 +391,8 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, mystrftime(cnt, filepath, sizeof(filepath), cnt->conf.snappath, currenttime_tm, NULL, 0); snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); - remove(fullfilename); - put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); + remove(fullfilename); + put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); } cnt->snapshot = 0; From 2c316263c5c3ee06463bb37b43ae7e306f061fe3 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 16:10:38 -0700 Subject: [PATCH 095/233] found another tab that needed spaces --- event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event.c b/event.c index e3ce367..b83ee75 100644 --- a/event.c +++ b/event.c @@ -349,7 +349,7 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { - char fullfilename[PATH_MAX]; + char fullfilename[PATH_MAX]; char filename[PATH_MAX]; char filepath[PATH_MAX]; int offset = 0; From 4996c3105436e372bcf3347371261c7604972a21 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 16:12:59 -0700 Subject: [PATCH 096/233] still trying to figure out how may spaces it had --- event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event.c b/event.c index b83ee75..e3ce367 100644 --- a/event.c +++ b/event.c @@ -349,7 +349,7 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { - char fullfilename[PATH_MAX]; + char fullfilename[PATH_MAX]; char filename[PATH_MAX]; char filepath[PATH_MAX]; int offset = 0; From 9496889fd1d94628179b2bdb1c3d05b83354ebf8 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 16:18:16 -0700 Subject: [PATCH 097/233] this is a tab in the original spaces to tabs --- event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event.c b/event.c index e3ce367..b83ee75 100644 --- a/event.c +++ b/event.c @@ -349,7 +349,7 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { - char fullfilename[PATH_MAX]; + char fullfilename[PATH_MAX]; char filename[PATH_MAX]; char filepath[PATH_MAX]; int offset = 0; From ba7044e4f04e03188f483fa2c7c4991ad9fc7f2d Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sat, 16 May 2015 16:23:23 -0700 Subject: [PATCH 098/233] Whew found it a trailing tab --- event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event.c b/event.c index b83ee75..74bf8ab 100644 --- a/event.c +++ b/event.c @@ -349,7 +349,7 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { - char fullfilename[PATH_MAX]; + char fullfilename[PATH_MAX]; char filename[PATH_MAX]; char filepath[PATH_MAX]; int offset = 0; From 3e99410c5f8dc25eba1c4ec8fb1bee1a0bff40a7 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Sun, 17 May 2015 09:12:09 -0700 Subject: [PATCH 099/233] Tab to space conversion --- event.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/event.c b/event.c index 74bf8ab..a021e19 100644 --- a/event.c +++ b/event.c @@ -349,17 +349,17 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, unsigned char *img, char *dummy1 ATTRIBUTE_UNUSED, void *dummy2 ATTRIBUTE_UNUSED, struct tm *currenttime_tm) { - char fullfilename[PATH_MAX]; - char filename[PATH_MAX]; - char filepath[PATH_MAX]; - int offset = 0; - int len = strlen(cnt->conf.snappath); - if (len >= 9) - { - offset = len - 8; - } - if (strcmp(cnt->conf.snappath+offset, "lastsnap")) - char linkpath[PATH_MAX]; + char fullfilename[PATH_MAX]; + char filename[PATH_MAX]; + char filepath[PATH_MAX]; + int offset = 0; + int len = strlen(cnt->conf.snappath); + + if (len >= 9) + offset = len - 8; + + if (strcmp(cnt->conf.snappath+offset, "lastsnap")) { + char linkpath[PATH_MAX]; const char *snappath; /* * conf.snappath would normally be defined but if someone deleted it by control interface @@ -388,9 +388,9 @@ static void event_image_snapshot(struct context *cnt, int type ATTRIBUTE_UNUSED, return; } } else { - mystrftime(cnt, filepath, sizeof(filepath), cnt->conf.snappath, currenttime_tm, NULL, 0); - snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); - snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); + mystrftime(cnt, filepath, sizeof(filepath), cnt->conf.snappath, currenttime_tm, NULL, 0); + snprintf(filename, PATH_MAX, "%s.%s", filepath, imageext(cnt)); + snprintf(fullfilename, PATH_MAX, "%s/%s", cnt->conf.filepath, filename); remove(fullfilename); put_picture(cnt, fullfilename, img, FTYPE_IMAGE_SNAPSHOT); } From c045c428ca0f1e5054ad9f320abbd752d3567037 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Mon, 18 May 2015 14:14:36 -0700 Subject: [PATCH 100/233] Remove tabs --- motion.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/motion.c b/motion.c index bd3a015..810e6b4 100644 --- a/motion.c +++ b/motion.c @@ -823,8 +823,8 @@ static int motion_init(struct context *cnt) } MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %s msec", cnt->conf.sqlite3_busy_timeout); - if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.sqlite3_busy_timeout) != SQLITE_OK) - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s : %s\n", + if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.sqlite3_busy_timeout) != SQLITE_OK) + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s : %s\n", cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); } #endif /* HAVE_SQLITE3 */ From 152be1ec47af58ca6f10886449b3c0ad1c54c324 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Tue, 19 May 2015 12:04:55 -0700 Subject: [PATCH 101/233] Seemed to have lost a few of my changes during my breakapart of patches Also some formating (tab to spaces) fixes were done --- conf.c | 46 ++++++++++++++++++++++++++++------------------ motion.c | 6 +++--- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/conf.c b/conf.c index 8454ac1..5692662 100644 --- a/conf.c +++ b/conf.c @@ -132,6 +132,7 @@ struct config conf_template = { database_port: 0, #ifdef HAVE_SQLITE3 sqlite3_db: NULL, + sqlite3_busy_timeout: 0, #endif #endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || define(HAVE_SQLITE3) */ on_picture_save: NULL, @@ -1504,6 +1505,15 @@ config_param config_params[] = { copy_string, print_string }, + { + "sqlite3_busy_timeout", + "# SQLite3 wait for unlock time (default: 0)", + 0, + CONF_OFFSET(sqlite3_busy_timeout), + copy_int, + print_int + }, + #endif /* HAVE_SQLITE3 */ #endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ @@ -1582,26 +1592,26 @@ static void conf_cmdline(struct context *cnt, int thread) cnt->log_level = (unsigned int)atoi(optarg); break; case 'k': - if (thread == -1) { - strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); - cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); + cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; + } + break; case 'p': - if (thread == -1) { - strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); - cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); + cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; + } + break; case 'l': - if (thread == -1) { - strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); - cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); + cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; + } + break; case 'm': cnt->pause = 1; - break; + break; case 'h': case '?': default: @@ -1919,7 +1929,7 @@ struct context **conf_load(struct context **cnt) if (!fp) /* There is no config file.... use defaults. */ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: could not open configfile %s", - filename); + filename); } } @@ -1928,7 +1938,7 @@ struct context **conf_load(struct context **cnt) strncpy(cnt[0]->conf_filename, filename, sizeof(cnt[0]->conf_filename) - 1); cnt[0]->conf_filename[sizeof(cnt[0]->conf_filename) - 1] = '\0'; MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing thread 0 - config file %s", - filename); + filename); cnt = conf_process(cnt, fp); myfclose(fp); } else { diff --git a/motion.c b/motion.c index 810e6b4..efbd11f 100644 --- a/motion.c +++ b/motion.c @@ -821,11 +821,11 @@ static int motion_init(struct context *cnt) sqlite3_close(cnt->database_sqlite3); exit(1); } - MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %s msec", + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %d msec", cnt->conf.sqlite3_busy_timeout); if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.sqlite3_busy_timeout) != SQLITE_OK) - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s : %s\n", - cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s\n", + sqlite3_errmsg(cnt->database_sqlite3)); } #endif /* HAVE_SQLITE3 */ From 2441720023740c3cb334bb3539b6c3f6e51f3344 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 20 May 2015 11:44:10 -0700 Subject: [PATCH 102/233] More sqlite changes, now using threaded serial option if sqlite is configured for threads --- motion.c | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/motion.c b/motion.c index efbd11f..5575bc4 100644 --- a/motion.c +++ b/motion.c @@ -811,12 +811,15 @@ static int motion_init(struct context *cnt) cnt->conf.database_type); #ifdef HAVE_SQLITE3 - if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { + /* if database_sqlite3 is NULL then we are using a non threaded version of + * sqlite3 and will need a seperate connection for each thread */ + if (cnt->database_sqlite3) { + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 using shared handle"); + } else if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 Database filename %s", cnt->conf.sqlite3_db); - if (sqlite3_open(cnt->conf.sqlite3_db, &cnt->database_sqlite3) != SQLITE_OK) { - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s\n", + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s", cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); sqlite3_close(cnt->database_sqlite3); exit(1); @@ -824,7 +827,7 @@ static int motion_init(struct context *cnt) MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %d msec", cnt->conf.sqlite3_busy_timeout); if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.sqlite3_busy_timeout) != SQLITE_OK) - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s\n", + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s", sqlite3_errmsg(cnt->database_sqlite3)); } #endif /* HAVE_SQLITE3 */ @@ -2438,6 +2441,7 @@ static void motion_startup(int daemonize, int argc, char *argv[]) cnt_list[0]->log_level = cnt_list[0]->conf.log_level - 1; // Let's make syslog compatible } + //set_log_level(cnt_list[0]->log_level); #ifdef HAVE_SDL @@ -2645,6 +2649,34 @@ int main (int argc, char **argv) */ ffmpeg_init(); #endif /* HAVE_FFMPEG */ +#ifdef HAVE_SQLITE3 + /* database_sqlite3 == NULL if not changed causes each thread to creat their own + * sqlite3 connection this will only happens when using a non-threaded sqlite version */ + cnt_list[0]->database_sqlite3=NULL; + if ((!strcmp(cnt_list[0]->conf.database_type, "sqlite3")) && cnt_list[0]->conf.sqlite3_db) { + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 Database filename %s", + cnt_list[0]->conf.sqlite3_db); + + int thread_safe = sqlite3_threadsafe(); + if (thread_safe > 0) { + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 is threadsafe"); + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 serialized %s", + (sqlite3_config(SQLITE_CONFIG_SERIALIZED)?"FAILED":"SUCCESS")); + if (sqlite3_open( cnt_list[0]->conf.sqlite3_db, &cnt_list[0]->database_sqlite3) != SQLITE_OK) { + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s", + cnt_list[0]->conf.sqlite3_db, sqlite3_errmsg( cnt_list[0]->database_sqlite3)); + sqlite3_close( cnt_list[0]->database_sqlite3); + exit(1); + } + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %d msec", + cnt_list[0]->conf.sqlite3_busy_timeout); + if (sqlite3_busy_timeout( cnt_list[0]->database_sqlite3, cnt_list[0]->conf.sqlite3_busy_timeout) != SQLITE_OK) + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s", + sqlite3_errmsg( cnt_list[0]->database_sqlite3)); + } + + } +#endif /* HAVE_SQLITE3 */ /* * In setup mode, Motion is very communicative towards the user, which @@ -2705,7 +2737,9 @@ int main (int argc, char **argv) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Stream port %d", cnt_list[i]->conf.stream_port); - + /* this is done to share the seralized handle + * and supress creation of new handles in the threads */ + cnt_list[i]->database_sqlite3=cnt_list[0]->database_sqlite3; start_motion_thread(cnt_list[i], &thread_attr); } From 761b2f2195bdaf17d494a158031679a40bfe62a9 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Thu, 21 May 2015 14:06:48 -0700 Subject: [PATCH 103/233] Fixed problem not finding local sqlite3.h file wne local files are used --- configure.ac | 1351 +++++++++++++++++++++++++------------------------- motion.h | 40 +- 2 files changed, 698 insertions(+), 693 deletions(-) diff --git a/configure.ac b/configure.ac index 8fbee5f..73daccd 100755 --- a/configure.ac +++ b/configure.ac @@ -16,8 +16,8 @@ FreeBSD="" LINUXTHREADS="no" AC_ARG_WITH(linuxthreads, [ --with-linuxthreads Use linuxthreads in BSD instead of native pthreads - ] - , + ] + , LINUXTHREADS="$withval" ) @@ -34,45 +34,45 @@ AC_MSG_CHECKING(for Darwin) Darwin=`uname -a | grep "Darwin"` if test "${Darwin}" = ""; then - AC_MSG_RESULT(no) - AC_MSG_CHECKING(for *BSD) - - FreeBSD=`uname -a | grep "FreeBSD"` - if test "${FreeBSD}" = ""; then - AC_MSG_RESULT(no) - VIDEO="video.o video2.o video_common.o" - else - AC_MSG_RESULT(yes) - if test "${LINUXTHREADS}" = "no"; then - AC_MSG_CHECKING(Linuxthreads) - AC_MSG_RESULT(skipping) - else - THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" - THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" - fi - - if test "${PWCBSD}" != "no"; then - VIDEO="video.o video2.o video_common.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" - else - VIDEO="video_freebsd.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" - fi - - TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" - TEMP_LIBS="-L/usr/local/lib" - AC_MSG_RESULT(Build with PWCBSD support $PWCBSD) - - fi + AC_MSG_RESULT(no) + AC_MSG_CHECKING(for *BSD) + + FreeBSD=`uname -a | grep "FreeBSD"` + if test "${FreeBSD}" = ""; then + AC_MSG_RESULT(no) + VIDEO="video.o video2.o video_common.o" + else + AC_MSG_RESULT(yes) + if test "${LINUXTHREADS}" = "no"; then + AC_MSG_CHECKING(Linuxthreads) + AC_MSG_RESULT(skipping) + else + THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" + THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" + fi + + if test "${PWCBSD}" != "no"; then + VIDEO="video.o video2.o video_common.o" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" + else + VIDEO="video_freebsd.o" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" + fi + + TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" + TEMP_LIBS="-L/usr/local/lib" + AC_MSG_RESULT(Build with PWCBSD support $PWCBSD) + + fi else - TEMP_CFLAGS="${CFLAGS} -I/sw/include" - TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" - TEMP_LIBS="-L/sw/lib" - VIDEO="video_freebsd.o" - FINK_LIB="-L/sw/lib" - Darwin="yes" - V4L="no" - AC_MSG_RESULT($Darwin) + TEMP_CFLAGS="${CFLAGS} -I/sw/include" + TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" + TEMP_LIBS="-L/sw/lib" + VIDEO="video_freebsd.o" + FINK_LIB="-L/sw/lib" + Darwin="yes" + V4L="no" + AC_MSG_RESULT($Darwin) fi @@ -87,14 +87,14 @@ TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then - AC_MSG_CHECKING(bktr headers in /usr/include/dev/bktr) + AC_MSG_CHECKING(bktr headers in /usr/include/dev/bktr) - if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" - fi + if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" + fi # # Check to Exclude BKTR # @@ -107,9 +107,9 @@ AC_ARG_WITH(bktr, BKTR="$withval" ) - if test "${BKTR}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" - fi + if test "${BKTR}" = "no"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + fi else @@ -128,7 +128,7 @@ fi if test "${V4L}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" fi @@ -139,22 +139,22 @@ AC_MSG_CHECKING(for linuxthreads) # # Check for thread header # - if test -f "${THREAD_CHECK}"; then - HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" - THREADS="yes" - else - THREADS="no" - fi + if test -f "${THREAD_CHECK}"; then + HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" + THREADS="yes" + else + THREADS="no" + fi # # Check for thread lib # - if test -f "${THREAD_LIB_CHECK}" ; then - THREADS="yes" - LIB_THREAD="-llthread -llgcc_r" - else - THREADS="no" - fi + if test -f "${THREAD_LIB_CHECK}" ; then + THREADS="yes" + LIB_THREAD="-llthread -llgcc_r" + else + THREADS="no" + fi # Checks for Library linuxthreads for FreeBSD # @@ -164,8 +164,8 @@ AC_MSG_CHECKING(for linuxthreads) # /usr/local/lib/libpthread.so # - if test "${THREADS}" = "yes"; then - TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" + if test "${THREADS}" = "yes"; then + TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" THREAD_CFLAGS="-D_THREAD_SAFE" PTHREAD_SUPPORT="yes" @@ -190,21 +190,21 @@ AC_TRY_LINK([#include ], if test x$PTHREAD_LIB != xyes; then - if test "${FreeBSD}" != ""; then - TEMP_LIBS="$TEMP_LIBS -pthread" - TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" - else - TEMP_LIBS="$TEMP_LIBS -lpthread" - TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" - fi - PTHREAD_SUPPORT="yes" + if test "${FreeBSD}" != ""; then + TEMP_LIBS="$TEMP_LIBS -pthread" + TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" + else + TEMP_LIBS="$TEMP_LIBS -lpthread" + TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" + fi + PTHREAD_SUPPORT="yes" fi - AC_MSG_RESULT($PTHREAD_SUPPORT) + AC_MSG_RESULT($PTHREAD_SUPPORT) else - echo - echo "You do not have threads support" - echo + echo + echo "You do not have threads support" + echo fi @@ -219,33 +219,33 @@ AC_ARG_WITH(sdl, []) AC_MSG_CHECKING(for sdl) if test "x$withval" = "xno"; then - AC_MSG_RESULT(skipped) + AC_MSG_RESULT(skipped) else - if test "${FreeBSD}" != ""; then - CONFIG_SDL='sdl11-config' - else - CONFIG_SDL='sdl-config' - fi - if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then - AC_MSG_RESULT(no) - if test "$withval" = "yes"; then - echo "" - echo "****************************************************" - echo "* sdl-config could not be found. Please install it *" - echo "* and remove the --with-sdl configure argument. *" - echo "* libSDL can be found at http://www.libsdl.org *" - echo "****************************************************" - echo "" - fi - else - AC_MSG_RESULT(yes) - SDL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" - TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" - AC_DEFINE([HAVE_SDL],1,[Define to 1 if you have SDL support]) - SDL_OBJ="sdl.o" - AC_SUBST(SDL_OBJ) - fi + if test "${FreeBSD}" != ""; then + CONFIG_SDL='sdl11-config' + else + CONFIG_SDL='sdl-config' + fi + if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then + AC_MSG_RESULT(no) + if test "$withval" = "yes"; then + echo "" + echo "****************************************************" + echo "* sdl-config could not be found. Please install it *" + echo "* and remove the --with-sdl configure argument. *" + echo "* libSDL can be found at http://www.libsdl.org *" + echo "****************************************************" + echo "" + fi + else + AC_MSG_RESULT(yes) + SDL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" + TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" + AC_DEFINE([HAVE_SDL],1,[Define to 1 if you have SDL support]) + SDL_OBJ="sdl.o" + AC_SUBST(SDL_OBJ) + fi fi # @@ -316,42 +316,42 @@ if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then AC_MSG_CHECKING(for libjpeg-mmx) AC_MSG_RESULT(skipping) elif test "${JPEG_MMX}" = "yes"; then - # AUTODETECT STATIC LIB - AC_MSG_CHECKING(for libjpeg-mmx autodetecting) - - if test -f /usr/lib/libjpeg-mmx.a ; then - AC_MSG_RESULT(found) - JPEG_MMX_OK="found" - JPEG_MMX="/usr/lib" - elif test -f /usr/local/lib/libjpeg-mmx.a ; then - AC_MSG_RESULT(found) - JPEG_MMX_OK="found" - JPEG_MMX="/usr/local/lib" - else - AC_MSG_RESULT(not found) - fi + # AUTODETECT STATIC LIB + AC_MSG_CHECKING(for libjpeg-mmx autodetecting) + + if test -f /usr/lib/libjpeg-mmx.a ; then + AC_MSG_RESULT(found) + JPEG_MMX_OK="found" + JPEG_MMX="/usr/lib" + elif test -f /usr/local/lib/libjpeg-mmx.a ; then + AC_MSG_RESULT(found) + JPEG_MMX_OK="found" + JPEG_MMX="/usr/local/lib" + else + AC_MSG_RESULT(not found) + fi else - AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) - if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then - AC_MSG_RESULT(found) - JPEG_MMX_OK="found" - else - AC_MSG_RESULT(not found) - fi + AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) + if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then + AC_MSG_RESULT(found) + JPEG_MMX_OK="found" + else + AC_MSG_RESULT(not found) + fi fi if test "${JPEG_MMX_OK}" = "found"; then - saved_CFLAGS="$CFLAGS" - saved_LIBS="$LIBS" - CFLAGS="$CFLAGS -I${JPEG_MMX}" - LIBS="$LIBS -L${JPEG_MMX}" - AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress, - [ TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" - TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" - JPEG_SUPPORT="yes"],,) - LIBS="$saved_LIBS" - CFLAGS="$saved_CFLAGS" - JPEG_SUPPORT_MMX="yes" + saved_CFLAGS="$CFLAGS" + saved_LIBS="$LIBS" + CFLAGS="$CFLAGS -I${JPEG_MMX}" + LIBS="$LIBS -L${JPEG_MMX}" + AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress, + [ TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" + TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" + JPEG_SUPPORT="yes"],,) + LIBS="$saved_LIBS" + CFLAGS="$saved_CFLAGS" + JPEG_SUPPORT_MMX="yes" fi # @@ -362,13 +362,13 @@ if test x$JPEG_SUPPORT != xyes ; then LDFLAGS=$TEMP_LDFLAGS AC_CHECK_LIB(jpeg, jpeg_set_defaults, [ - TEMP_LIBS="$TEMP_LIBS -ljpeg" - JPEG_SUPPORT="yes" - ], [ - echo - echo "You do not have libjpeg installed" - echo - ] + TEMP_LIBS="$TEMP_LIBS -ljpeg" + JPEG_SUPPORT="yes" + ], [ + echo + echo "You do not have libjpeg installed" + echo + ] ) fi @@ -414,78 +414,78 @@ FFMPEG_EXTRALIBS="$withval" # --without-ffmpeg or with-ffmpeg=no # if test "${FFMPEG_DIR}" = "no"; then - AC_MSG_CHECKING(for ffmpeg) - AC_MSG_RESULT(skipping) + AC_MSG_CHECKING(for ffmpeg) + AC_MSG_RESULT(skipping) # # with-ffmpeg=

                                                          or nothing # else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB - AC_MSG_CHECKING(for ffmpeg autodetecting libraries) - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib64) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib" - FFMPEG_DIR="/usr" - elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/local/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" + # AUTODETECT STATIC/SHARED LIB + AC_MSG_CHECKING(for ffmpeg autodetecting libraries) + + if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib64) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib64" + FFMPEG_DIR="/usr" + elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib" + FFMPEG_DIR="/usr" + elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then + AC_MSG_RESULT(found in /usr/local/lib) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/local/lib" + FFMPEG_DIR="/usr/local" elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then AC_MSG_RESULT(found in /usr/lib/x86_64-linux-gnu) FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" FFMPEG_DIR="/usr" - elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then + elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/i386-linux-gnu" FFMPEG_DIR="/usr" - else - AC_MSG_RESULT(not found) - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi + else + AC_MSG_RESULT(not found) + echo "" + echo "**********************************************" + echo "* libavcodec.a or libavcodec.so or *" + echo "* libavformat.a or libavformat.so not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi else - AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_OK="found" - FFMPEG_LIB="${FFMPEG_DIR}/lib" - elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_LIB="${FFMPEG_DIR}" - FFMPEG_OK="found" - else - AC_MSG_RESULT(not found) - if test "${FFMPEG_OK}" != "found"; then - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - fi + AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) + if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then + AC_MSG_RESULT(found) + FFMPEG_OK="found" + FFMPEG_LIB="${FFMPEG_DIR}/lib" + elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then + AC_MSG_RESULT(found) + FFMPEG_LIB="${FFMPEG_DIR}" + FFMPEG_OK="found" + else + AC_MSG_RESULT(not found) + if test "${FFMPEG_OK}" != "found"; then + echo "" + echo "**********************************************" + echo "* libavcodec.a or libavcodec.so or *" + echo "* libavformat.a or libavformat.so not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi + fi fi @@ -613,23 +613,24 @@ else # first we check to see if the sqlite3 amalgamation (sqlite3.c), is in with our source # this is the prefered way to use sqlite AC_CHECK_FILE([sqlite3.c], - [ - SQLITE3_SUPPORT="yes" - VIDEO="$VIDEO sqlite3.o" - TEMP_LIBS="$TEMP_LIBS -ldl" - AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 imbedded support]) - ] - , - [ - # if sqlite3.c is not found then we look for the shared library - AC_CHECK_LIB(sqlite3, sqlite3_open, - [ - TEMP_LIBS="$TEMP_LIBS -lsqlite3" - SQLITE3_SUPPORT="yes" - AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 shared library support]) - ] - ) - ] + [ + SQLITE3_SUPPORT="yes" + VIDEO="$VIDEO sqlite3.o" + TEMP_LIBS="$TEMP_LIBS -ldl" + AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3]) + AC_DEFINE([HAVE_SQLITE3_EMBEDDED],1,[Define to 1 if you have SQLITE3 embedded support]) + ] + , + [ + # if sqlite3.c is not found then we look for the shared library + AC_CHECK_LIB(sqlite3, sqlite3_open, + [ + TEMP_LIBS="$TEMP_LIBS -lsqlite3" + SQLITE3_SUPPORT="yes" + AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 shared library support]) + ] + ) + ] ) CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS @@ -677,110 +678,110 @@ MYSQL_HEADERS="$withval" if test "${MYSQL}" = "no"; then - AC_MSG_RESULT(skipped) + AC_MSG_RESULT(skipped) else - AC_MSG_RESULT(testing) - # ******* Search mysql headers ******* - - if test "${MYSQL_HEADERS}" = "yes"; then - AC_MSG_CHECKING(autodect mysql headers) - # Autodetect - for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do - # check for plain setups - if test -f $w/mysql.h; then - MYSQL_INCDIR=$w - break - fi - # check for "/usr/include/" type setups - if test -f $w/mysql/mysql.h; then - MYSQL_INCDIR=$w/mysql - break - fi - # check for "/usr//include" type setups - if test -f $w/mysql/include/mysql.h; then - MYSQL_INCDIR=$w/mysql/include - break - fi - done - elif test "${MYSQL_HEADERS}" = "no"; then - AC_MSG_CHECKING(for mysql headers) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) - # Manual detection for - if test -f $MYSQL_HEADERS/mysql.h; then - MYSQL_INCDIR=$MYSQL_HEADERS - fi - fi - - if test -z "$MYSQL_INCDIR" ; then - MYSQL_HEADERS="no" - AC_MSG_RESULT(not found) - echo "Invalid MySQL directory - unable to find mysql.h." - else - AC_MSG_RESULT($MYSQL_INCDIR yes) - MYSQL_HEADERS="yes" - fi - - - if test "${MYSQL_HEADERS}" = "yes"; then - - # ******* Search mysql libs ********* - if test "${MYSQL_LIBS}" = "yes"; then - AC_MSG_CHECKING(autodect mysql libs) - # Autodetect - for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do - # check for plain setups - if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then - MYSQL_LIBDIR=$w - break - fi - # check for "/usr/lib/" type setups - if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then - MYSQL_LIBDIR=$w/mysql - break - fi - # check for "/usr//lib" type setups - if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then - MYSQL_LIBDIR=$w/mysql/lib - break - fi - done - elif test "${MYSQL_LIBS}" = "no"; then - AC_MSG_CHECKING(for mysql libs) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) - # Manual detection for - if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then - MYSQL_LIBDIR=$MYSQL_LIBS - fi - fi - - - if test -z "$MYSQL_LIBDIR" ; then - AC_MSG_RESULT(not found) - echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." - else - AC_MSG_RESULT($MYSQL_LIBDIR) - #LDFLAGS="-L$MYSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$MYSQL_INCDIR" - LIBS="-L$MYSQL_LIBDIR" - AC_CHECK_LIB(mysqlclient,mysql_init,[ - TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" - TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" - MYSQL_SUPPORT="yes" - AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) - ], - AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - # end mysql-include , mysql-libs - fi + AC_MSG_RESULT(testing) + # ******* Search mysql headers ******* + + if test "${MYSQL_HEADERS}" = "yes"; then + AC_MSG_CHECKING(autodect mysql headers) + # Autodetect + for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do + # check for plain setups + if test -f $w/mysql.h; then + MYSQL_INCDIR=$w + break + fi + # check for "/usr/include/" type setups + if test -f $w/mysql/mysql.h; then + MYSQL_INCDIR=$w/mysql + break + fi + # check for "/usr//include" type setups + if test -f $w/mysql/include/mysql.h; then + MYSQL_INCDIR=$w/mysql/include + break + fi + done + elif test "${MYSQL_HEADERS}" = "no"; then + AC_MSG_CHECKING(for mysql headers) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) + # Manual detection for + if test -f $MYSQL_HEADERS/mysql.h; then + MYSQL_INCDIR=$MYSQL_HEADERS + fi + fi + + if test -z "$MYSQL_INCDIR" ; then + MYSQL_HEADERS="no" + AC_MSG_RESULT(not found) + echo "Invalid MySQL directory - unable to find mysql.h." + else + AC_MSG_RESULT($MYSQL_INCDIR yes) + MYSQL_HEADERS="yes" + fi + + + if test "${MYSQL_HEADERS}" = "yes"; then + + # ******* Search mysql libs ********* + if test "${MYSQL_LIBS}" = "yes"; then + AC_MSG_CHECKING(autodect mysql libs) + # Autodetect + for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do + # check for plain setups + if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then + MYSQL_LIBDIR=$w + break + fi + # check for "/usr/lib/" type setups + if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then + MYSQL_LIBDIR=$w/mysql + break + fi + # check for "/usr//lib" type setups + if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then + MYSQL_LIBDIR=$w/mysql/lib + break + fi + done + elif test "${MYSQL_LIBS}" = "no"; then + AC_MSG_CHECKING(for mysql libs) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) + # Manual detection for + if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then + MYSQL_LIBDIR=$MYSQL_LIBS + fi + fi + + + if test -z "$MYSQL_LIBDIR" ; then + AC_MSG_RESULT(not found) + echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." + else + AC_MSG_RESULT($MYSQL_LIBDIR) + #LDFLAGS="-L$MYSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$MYSQL_INCDIR" + LIBS="-L$MYSQL_LIBDIR" + AC_CHECK_LIB(mysqlclient,mysql_init,[ + TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" + TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" + MYSQL_SUPPORT="yes" + AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) + ], + AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + # end mysql-include , mysql-libs + fi # end Mysql detection fi @@ -826,100 +827,100 @@ PGSQL_HEADERS="$withval" AC_MSG_CHECKING(for PostgreSQL) if test "${PGSQL}" = "no"; then - AC_MSG_RESULT(skipped) + AC_MSG_RESULT(skipped) else - AC_MSG_RESULT(testing) - - # ******* Search pgsql headers ******* - if test "${PGSQL_HEADERS}" = "yes"; then - - AC_MSG_CHECKING(autodect pgsql headers) - # Autodetect - for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do - PGSQL_INC_CHK(/include) - el[]PGSQL_INC_CHK(/include/pgsql) - el[]PGSQL_INC_CHK(/include/postgresql) - fi - done - - elif test "${PGSQL_HEADERS}" = "no"; then - AC_MSG_CHECKING(for pgsql headers) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) - # Manual detection for - if test -f $PGSQL_HEADERS/libpq-fe.h; then - PGSQL_INCDIR=$PGSQL_HEADERS - fi - fi - - if test -z "$PGSQL_INCDIR" ; then - PGSQL_HEADERS="no" - AC_MSG_RESULT(not found) - echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." - else - AC_MSG_RESULT(yes [$PGSQL_INCDIR]) - PGSQL_HEADERS="yes" - fi - - - if test "${PGSQL_HEADERS}" = "yes"; then - - # ******* Search pgsql libs ********* - if test "${PGSQL_LIBS}" = "yes"; then - AC_MSG_CHECKING(autodect pgsql libs) - # Autodetect - PGSQL_INCLUDE="-I$PGSQL_INCDIR" - PGSQL_LIBDIR=$PGSQL_DIR/lib - - if test -f /usr/lib64/libpq.so ; then - PGSQL_LIBDIR=/usr/lib64 - elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql - elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql - elif test -f $PGSQL_DIR/lib/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib - else - PGSQL_LIBDIR="" - fi - - AC_MSG_RESULT($PGSQL_LIBDIR) - - elif test "${PGSQL_LIBS}" = "no"; then - AC_MSG_CHECKING(for pgsql libs) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) - # Manual detection for - if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then - PGSQL_LIBDIR=$PGSQL_LIBS - fi - fi - - - if test -z "$PGSQL_LIBDIR" ; then - AC_MSG_RESULT(not found) - echo "Invalid PostgreSQL directory [$PGSQL_LIBDIR] - unable to find libpq.a or libpq.so." - else - #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$PGSQL_INCDIR" - LIBS="-L$PGSQL_LIBDIR" - AC_CHECK_LIB(pq, PQconnectStart, [ - PGSQL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" - TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" - AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) - ], - AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) - LDFLAGS="" - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - fi # end pgsql-include , pgsql-libs + AC_MSG_RESULT(testing) + + # ******* Search pgsql headers ******* + if test "${PGSQL_HEADERS}" = "yes"; then + + AC_MSG_CHECKING(autodect pgsql headers) + # Autodetect + for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do + PGSQL_INC_CHK(/include) + el[]PGSQL_INC_CHK(/include/pgsql) + el[]PGSQL_INC_CHK(/include/postgresql) + fi + done + + elif test "${PGSQL_HEADERS}" = "no"; then + AC_MSG_CHECKING(for pgsql headers) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) + # Manual detection for + if test -f $PGSQL_HEADERS/libpq-fe.h; then + PGSQL_INCDIR=$PGSQL_HEADERS + fi + fi + + if test -z "$PGSQL_INCDIR" ; then + PGSQL_HEADERS="no" + AC_MSG_RESULT(not found) + echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." + else + AC_MSG_RESULT(yes [$PGSQL_INCDIR]) + PGSQL_HEADERS="yes" + fi + + + if test "${PGSQL_HEADERS}" = "yes"; then + + # ******* Search pgsql libs ********* + if test "${PGSQL_LIBS}" = "yes"; then + AC_MSG_CHECKING(autodect pgsql libs) + # Autodetect + PGSQL_INCLUDE="-I$PGSQL_INCDIR" + PGSQL_LIBDIR=$PGSQL_DIR/lib + + if test -f /usr/lib64/libpq.so ; then + PGSQL_LIBDIR=/usr/lib64 + elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql + elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql + elif test -f $PGSQL_DIR/lib/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib + else + PGSQL_LIBDIR="" + fi + + AC_MSG_RESULT($PGSQL_LIBDIR) + + elif test "${PGSQL_LIBS}" = "no"; then + AC_MSG_CHECKING(for pgsql libs) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) + # Manual detection for + if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then + PGSQL_LIBDIR=$PGSQL_LIBS + fi + fi + + + if test -z "$PGSQL_LIBDIR" ; then + AC_MSG_RESULT(not found) + echo "Invalid PostgreSQL directory [$PGSQL_LIBDIR] - unable to find libpq.a or libpq.so." + else + #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$PGSQL_INCDIR" + LIBS="-L$PGSQL_LIBDIR" + AC_CHECK_LIB(pq, PQconnectStart, [ + PGSQL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" + TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" + AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) + ], + AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) + LDFLAGS="" + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + fi # end pgsql-include , pgsql-libs # end PostgreSQL detection fi @@ -936,38 +937,38 @@ SUPPORTED_V4L2=false SUPPORTED_V4L2_old=false if test "${V4L}" = "no"; then - AC_MSG_CHECKING(for V42L support) - AC_MSG_RESULT(skipping) + AC_MSG_CHECKING(for V42L support) + AC_MSG_RESULT(skipping) else - AC_CHECK_TYPE([struct v4l2_buffer], - [SUPPORTED_V4L2=true], - [SUPPORTED_V4L2=false], - [#include - #ifdef HAVE_LINUX_VIDEODEV_H - #include - #elif HAVE_SYS_VIDEOIO_H - #include - #endif]) - AC_MSG_CHECKING(for V42L support) - if test x$SUPPORTED_V4L2 = xtrue; then - AC_MSG_RESULT(yes) - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" - else - AC_MSG_RESULT(no) - fi - - # linux/videodev.h doesn't include videodev2.h - if test x$SUPPORTED_V4L2 = xfalse; then - AC_MSG_CHECKING(for V42L *old* support) - AC_MSG_RESULT(testing) - AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) - fi - - - if test x$SUPPORTED_V4L2_old = xtrue; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" - SUPPORTED_V4L2=true - fi + AC_CHECK_TYPE([struct v4l2_buffer], + [SUPPORTED_V4L2=true], + [SUPPORTED_V4L2=false], + [#include + #ifdef HAVE_LINUX_VIDEODEV_H + #include + #elif HAVE_SYS_VIDEOIO_H + #include + #endif]) + AC_MSG_CHECKING(for V42L support) + if test x$SUPPORTED_V4L2 = xtrue; then + AC_MSG_RESULT(yes) + TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" + else + AC_MSG_RESULT(no) + fi + + # linux/videodev.h doesn't include videodev2.h + if test x$SUPPORTED_V4L2 = xfalse; then + AC_MSG_CHECKING(for V42L *old* support) + AC_MSG_RESULT(testing) + AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) + fi + + + if test x$SUPPORTED_V4L2_old = xtrue; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" + SUPPORTED_V4L2=true + fi fi @@ -981,15 +982,15 @@ AC_CHECK_SIZEOF(int *) AC_CHECK_SIZEOF(void *) if test "$ac_cv_sizeof_short" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" else - if test "$ac_cv_sizeof_int" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" - else - if test "$ac_cv_sizeof_long_int" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" - fi - fi + if test "$ac_cv_sizeof_int" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" + else + if test "$ac_cv_sizeof_long_int" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" + fi + fi fi @@ -999,7 +1000,7 @@ AC_ARG_WITH(optimizecpu, [ --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. - ], + ], OPTIMIZECPU="$withval" ) @@ -1016,7 +1017,7 @@ DEVELOPER_FLAGS="$withval" AC_C_CONST if test "${FreeBSD}" != ""; then - OPTIMIZECPU="" + OPTIMIZECPU="" fi if test "${OPTIMIZECPU}" = "yes"; then @@ -1025,193 +1026,193 @@ if test "${OPTIMIZECPU}" = "yes"; then CPU_NAME="unknown" CPU_TYPE="unknown" if test -e "/proc/cpuinfo" ; then - intel[[30]]="-march=i386" - intel[[32]]="-march=i386" - intel[[34]]="-march=i386" - intel[[40]]="-march=i486" - intel[[41]]="-march=i486" - intel[[42]]="-march=i486" - intel[[43]]="-march=i486" - intel[[44]]="-march=i486" - intel[[45]]="-march=i486" - intel[[47]]="-march=i486" - intel[[48]]="-march=i486" - intel[[51]]="-march=pentium" - intel[[52]]="-march=pentium" - intel[[54]]="-march=pentium-mmx" - intel[[56]]="-march=pentium-mmx" - intel[[61]]="-march=pentiumpro" - intel[[63]]="-march=pentium2" - intel[[65]]="-march=pentium2" - intel[[66]]="-march=pentium2" - intel[[67]]="-march=pentium3" - intel[[68]]="-march=pentium3" - intel[[610]]="-march=pentium3" - intel[[611]]="-march=pentium3" - intel[[150]]="-march=pentium4" - intel[[151]]="-march=pentium4" - intel[[152]]="-march=pentium4" - intel[[154]]="-march=pentium4" - intel[[614]]="-march=prescott" - intel[[628]]="-march=core2" - amd[[50]]="-march=i586" - amd[[51]]="-march=i586" - amd[[52]]="-march=i586" - amd[[53]]="-march=i586" - amd[[56]]="-march=k6" - amd[[57]]="-march=k6" - amd[[58]]="-march=k6-2" - amd[[510]]="-march=k6-2" - amd[[59]]="-march=k6-3" - amd[[513]]="-march=k6-3" - amd[[61]]="-march=athlon" - amd[[62]]="-march=athlon" - amd[[63]]="-march=athlon" - amd[[64]]="-march=athlon" - amd[[66]]="-march=athlon" - amd[[67]]="-march=athlon" - amd[[68]]="-march=athlon" - amd[[610]]="-march=athlon" - amd[[158]]="-march=athlon-xp" - amd[[154]]="-march=k8" - amd[[155]]="-march=athlon64" - amd[[1543]]="-march=athlon64" - amd[[1544]]="-march=athlon64" - amd[[1565]]="-march=opteron" - amd[[1572]]="-march=k8" - via[[67]]="-march=c3" - via[[68]]="-march=c3" - via[[69]]="-march=i686" - via[[610]]="-march=i686" - - CPU_TYPE="known" - CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` - CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` - CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` - CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` - CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` - CPU_FAMILY=${CPU_FAMILY#*: } - CPU_MODEL=${CPU_MODEL#*: } - CPU_NAME=${CPU_NAME#*: } - CPU_FLAGS=${CPU_FLAGS#*: } - CPU_VENDOR=${CPU_VENDOR#*: } - if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then - CPU_OPTIONS=${intel[[$CPU_FAMILY$CPU_MODEL]]} - fi - if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then - CPU_OPTIONS=${amd[[$CPU_FAMILY$CPU_MODEL]]} - fi - if test "x${CPU_VENDOR}" = "xCentaurHauls"; then - CPU_OPTIONS=${via[[$CPU_FAMILY$CPU_MODEL]]} - fi - if test "x${CPU_OPTIONS}" = "x" ; then - CPU_TYPE="unknown" - fi - CPU_EXT="" - for i in $CPU_FLAGS ; do - case $i in - fpu) - CPU_FPU="-mfpmath=387" - ;; - mmx) - CPU_EXT="$CPU_EXT -mmmx" - ;; - sse) - CPU_FPU="-mfpmath=sse -msse" - ;; - sse2) - CPU_FPU="-mfpmath=sse -msse2" - ;; - sse3) - CPU_FPU="-msse3" - ;; - ssse3) - CPU_FPU="-mfpmath=sse -msse2 -mssse3" - ;; - 3dnow) - CPU_EXT="$CPU_EXT -m3dnow" - ;; - esac - done - CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" + intel[[30]]="-march=i386" + intel[[32]]="-march=i386" + intel[[34]]="-march=i386" + intel[[40]]="-march=i486" + intel[[41]]="-march=i486" + intel[[42]]="-march=i486" + intel[[43]]="-march=i486" + intel[[44]]="-march=i486" + intel[[45]]="-march=i486" + intel[[47]]="-march=i486" + intel[[48]]="-march=i486" + intel[[51]]="-march=pentium" + intel[[52]]="-march=pentium" + intel[[54]]="-march=pentium-mmx" + intel[[56]]="-march=pentium-mmx" + intel[[61]]="-march=pentiumpro" + intel[[63]]="-march=pentium2" + intel[[65]]="-march=pentium2" + intel[[66]]="-march=pentium2" + intel[[67]]="-march=pentium3" + intel[[68]]="-march=pentium3" + intel[[610]]="-march=pentium3" + intel[[611]]="-march=pentium3" + intel[[150]]="-march=pentium4" + intel[[151]]="-march=pentium4" + intel[[152]]="-march=pentium4" + intel[[154]]="-march=pentium4" + intel[[614]]="-march=prescott" + intel[[628]]="-march=core2" + amd[[50]]="-march=i586" + amd[[51]]="-march=i586" + amd[[52]]="-march=i586" + amd[[53]]="-march=i586" + amd[[56]]="-march=k6" + amd[[57]]="-march=k6" + amd[[58]]="-march=k6-2" + amd[[510]]="-march=k6-2" + amd[[59]]="-march=k6-3" + amd[[513]]="-march=k6-3" + amd[[61]]="-march=athlon" + amd[[62]]="-march=athlon" + amd[[63]]="-march=athlon" + amd[[64]]="-march=athlon" + amd[[66]]="-march=athlon" + amd[[67]]="-march=athlon" + amd[[68]]="-march=athlon" + amd[[610]]="-march=athlon" + amd[[158]]="-march=athlon-xp" + amd[[154]]="-march=k8" + amd[[155]]="-march=athlon64" + amd[[1543]]="-march=athlon64" + amd[[1544]]="-march=athlon64" + amd[[1565]]="-march=opteron" + amd[[1572]]="-march=k8" + via[[67]]="-march=c3" + via[[68]]="-march=c3" + via[[69]]="-march=i686" + via[[610]]="-march=i686" + + CPU_TYPE="known" + CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` + CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` + CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` + CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` + CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` + CPU_FAMILY=${CPU_FAMILY#*: } + CPU_MODEL=${CPU_MODEL#*: } + CPU_NAME=${CPU_NAME#*: } + CPU_FLAGS=${CPU_FLAGS#*: } + CPU_VENDOR=${CPU_VENDOR#*: } + if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then + CPU_OPTIONS=${intel[[$CPU_FAMILY$CPU_MODEL]]} + fi + if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then + CPU_OPTIONS=${amd[[$CPU_FAMILY$CPU_MODEL]]} + fi + if test "x${CPU_VENDOR}" = "xCentaurHauls"; then + CPU_OPTIONS=${via[[$CPU_FAMILY$CPU_MODEL]]} + fi + if test "x${CPU_OPTIONS}" = "x" ; then + CPU_TYPE="unknown" + fi + CPU_EXT="" + for i in $CPU_FLAGS ; do + case $i in + fpu) + CPU_FPU="-mfpmath=387" + ;; + mmx) + CPU_EXT="$CPU_EXT -mmmx" + ;; + sse) + CPU_FPU="-mfpmath=sse -msse" + ;; + sse2) + CPU_FPU="-mfpmath=sse -msse2" + ;; + sse3) + CPU_FPU="-msse3" + ;; + ssse3) + CPU_FPU="-mfpmath=sse -msse2 -mssse3" + ;; + 3dnow) + CPU_EXT="$CPU_EXT -m3dnow" + ;; + esac + done + CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" fi if test "x${CPU_TYPE}" = "xunknown"; then - CPU_TYPE=`( uname -p ) 2>&1` - case $CPU_TYPE in - i386) - CPU_OPTIONS="-march=i386" - ;; - i486) - CPU_OPTIONS="-march=i486" - ;; - Pentium2) - CPU_OPTIONS="-march=pentium2" - ;; - Pentiumpro) - CPU_OPTIONS="-march=pentiumpro" - ;; - Pentium*) - CPU_OPTIONS="-march=pentium" - ;; - k6) - CPU_OPTIONS="-march=k6" - ;; - k6-2) - CPU_OPTIONS="-march=k6-2" - ;; - k6-3) - CPU_OPTIONS="-march=k6-3" - ;; - "VIA C3 Ezra") - CPU_OPTIONS="-march=c3" - CPU_TYPE="known" + CPU_TYPE=`( uname -p ) 2>&1` + case $CPU_TYPE in + i386) + CPU_OPTIONS="-march=i386" + ;; + i486) + CPU_OPTIONS="-march=i486" + ;; + Pentium2) + CPU_OPTIONS="-march=pentium2" + ;; + Pentiumpro) + CPU_OPTIONS="-march=pentiumpro" + ;; + Pentium*) + CPU_OPTIONS="-march=pentium" + ;; + k6) + CPU_OPTIONS="-march=k6" + ;; + k6-2) + CPU_OPTIONS="-march=k6-2" + ;; + k6-3) + CPU_OPTIONS="-march=k6-3" + ;; + "VIA C3 Ezra") + CPU_OPTIONS="-march=c3" + CPU_TYPE="known" ;; - *) - CPU_OPTIONS="" - CPU_TYPE="unknown" - ;; - esac - if test "x${CPU_TYPE}" = "xunknown"; then - CPU_TYPE=`( uname -m ) 2>&1` - case $CPU_TYPE in - i386) - CPU_OPTIONS="-march=i386" - ;; - i486) - CPU_OPTIONS="-march=i486" - ;; - i586) - CPU_OPTIONS="-march=i586" - ;; - i686) - CPU_OPTIONS="-march=i686" - ;; - Pentium2) - CPU_OPTIONS="-march=pentium2" - ;; - Pentiumpro) - CPU_OPTIONS="-march=pentiumpro" - ;; - k6) - CPU_OPTIONS="-march=k6" - ;; - k6-2) - CPU_OPTIONS="-march=k6-2" - ;; - k6-3) - CPU_OPTIONS="-march=k6-3" - ;; - *) - CPU_OPTIONS="-march=native -mtune=native" - ;; - esac - fi + *) + CPU_OPTIONS="" + CPU_TYPE="unknown" + ;; + esac + if test "x${CPU_TYPE}" = "xunknown"; then + CPU_TYPE=`( uname -m ) 2>&1` + case $CPU_TYPE in + i386) + CPU_OPTIONS="-march=i386" + ;; + i486) + CPU_OPTIONS="-march=i486" + ;; + i586) + CPU_OPTIONS="-march=i586" + ;; + i686) + CPU_OPTIONS="-march=i686" + ;; + Pentium2) + CPU_OPTIONS="-march=pentium2" + ;; + Pentiumpro) + CPU_OPTIONS="-march=pentiumpro" + ;; + k6) + CPU_OPTIONS="-march=k6" + ;; + k6-2) + CPU_OPTIONS="-march=k6-2" + ;; + k6-3) + CPU_OPTIONS="-march=k6-3" + ;; + *) + CPU_OPTIONS="-march=native -mtune=native" + ;; + esac + fi fi echo "Detected CPU: $CPU_NAME" # Now we check if the compiler supports the detected cpu COMPILER=$CC for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do - test "$I" && break + test "$I" && break done TMPC="$I/cpu_test-$RANDOM-$$.c" TMPO="$I/cpu_test-$RANDOM-$$.o" @@ -1225,35 +1226,35 @@ rm -f $TMPC if test "x${TMP}" = "x1" ; then - CPU_OPTIONS="" - echo "No CPU optimizations will be added" + CPU_OPTIONS="" + echo "No CPU optimizations will be added" else - echo "CPU optimization: $CPU_OPTIONS" + echo "CPU optimization: $CPU_OPTIONS" fi else - CPU_OPTIONS="" + CPU_OPTIONS="" fi AC_MSG_CHECKING(for bswap instruction) AC_LINK_IFELSE([ - AC_LANG_PROGRAM([ ], - [unsigned int __x=0; - register unsigned int __v; - __asm("bswap %0" : "=r" (__v) : "0" (__x));]) - ], - [ - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_RESULT(no) - ]) + AC_LANG_PROGRAM([ ], + [unsigned int __x=0; + register unsigned int __v; + __asm("bswap %0" : "=r" (__v) : "0" (__x));]) + ], + [ + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + ]) if test "${DEVELOPER_FLAGS}" = "yes"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" + TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" fi CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" @@ -1266,18 +1267,18 @@ LDFLAGS="${TEMP_LDFLAGS}" # Add the right exec path for rc scripts # if test $prefix = "NONE";then - BIN_PATH="$ac_default_prefix" - if test $exec_prefix = "NONE"; then - BIN_PATH="$BIN_PATH/bin" - else - BIN_PATH="$BIN_PATH/$bindir" - fi + BIN_PATH="$ac_default_prefix" + if test $exec_prefix = "NONE"; then + BIN_PATH="$BIN_PATH/bin" + else + BIN_PATH="$BIN_PATH/$bindir" + fi else - if test $exec_prefix = "NONE";then - BIN_PATH="$prefix/bin" - else - BIN_PATH="$prefix/$bindir" - fi + if test $exec_prefix = "NONE";then + BIN_PATH="$prefix/bin" + else + BIN_PATH="$prefix/$bindir" + fi fi @@ -1337,36 +1338,36 @@ else fi if test "${FreeBSD}" != ""; then - if test "${BKTR}" = "yes"; then + if test "${BKTR}" = "yes"; then echo "BKTR included: Yes" - else + else echo "BKTR included: No" - fi + fi - if test "${PWCBSD}" = "yes"; then + if test "${PWCBSD}" = "yes"; then echo "PWCBSD include: Yes" - else + else echo "PWCBSD include: No" - fi + fi else - if test "${V4L}" = "yes"; then + if test "${V4L}" = "yes"; then echo "V4L support: Yes" - else + else echo "V4L support: No" - fi + fi - if test x$SUPPORTED_V4L2 = xtrue; then + if test x$SUPPORTED_V4L2 = xtrue; then echo "V4L2 support: Yes" - else + else echo "V4L2 support: No" - fi + fi fi if test "${SDL_SUPPORT}" = "yes"; then - echo "SDL support: Yes" + echo "SDL support: Yes" else - echo "SDL support: No" + echo "SDL support: No" fi if test "${FFMPEG_OK}" = "found"; then diff --git a/motion.h b/motion.h index c08d84f..6ae06ab 100644 --- a/motion.h +++ b/motion.h @@ -22,8 +22,12 @@ #endif #ifdef HAVE_SQLITE3 +#ifdef HAVE_SQLITE3_EMBEDDED +#include sqlite3.h +#else #include #endif +#endif #ifdef HAVE_PGSQL #include @@ -89,7 +93,7 @@ #endif -/* +/* * The macro below defines a version of sleep using nanosleep * If a signal such as SIG_CHLD interrupts the sleep we just continue sleeping */ @@ -98,7 +102,7 @@ tv.tv_sec = (seconds); \ tv.tv_nsec = (nanoseconds); \ while (nanosleep(&tv, &tv) == -1); \ - } + } #define CLEAR(x) memset(&(x), 0, sizeof(x)) @@ -215,7 +219,7 @@ struct images; #include "track.h" #include "netcam.h" -/* +/* * Structure to hold images information * The idea is that this should have all information about a picture e.g. diffs, timestamp etc. * The exception is the label information, it uses a lot of memory @@ -238,9 +242,9 @@ struct image_data { struct tm timestamp_tm; int shot; /* Sub second timestamp count */ - /* - * Movement center to img center distance - * Note: Dist is calculated distX*distX + distY*distY + /* + * Movement center to img center distance + * Note: Dist is calculated distX*distX + distY*distY */ unsigned long cent_dist; @@ -251,24 +255,24 @@ struct image_data { int total_labels; }; -/* +/* * DIFFERENCES BETWEEN imgs.width, conf.width AND rotate_data.cap_width * (and the corresponding height values, of course) * =========================================================================== * Location Purpose - * + * * conf The values in conf reflect width and height set in the - * configuration file. These can be set via http remote control, + * configuration file. These can be set via http remote control, * but they are not used internally by Motion, so it won't break * anything. These values are transferred to imgs in vid_start. * * imgs The values in imgs are the actual output dimensions. Normally * the output dimensions are the same as the capture dimensions, - * but for 90 or 270 degrees rotation, they are not. E.g., if + * but for 90 or 270 degrees rotation, they are not. E.g., if * you capture at 320x240, and rotate 90 degrees, the output * dimensions are 240x320. - * These values are set from the conf values in vid_start, or - * from the first JPEG image in netcam_start. For 90 or 270 + * These values are set from the conf values in vid_start, or + * from the first JPEG image in netcam_start. For 90 or 270 * degrees rotation, they are swapped in rotate_init. * * rotate_data The values in rotate_data are named cap_width and cap_height, @@ -302,7 +306,7 @@ struct images { int width; int height; int type; - int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ + int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ int size; int motionsize; int labelgroup_max; @@ -315,7 +319,7 @@ struct images { struct rotdata { /* Temporary buffer for 90 and 270 degrees rotation. */ unsigned char *temp_buf; - /* + /* * Degrees to rotate; copied from conf.rotate_deg. This is the value * that is actually used. The value of conf.rotate_deg cannot be used * because it can be changed by motion-control, and changing rotation @@ -323,8 +327,8 @@ struct rotdata { */ int degrees; /* - * Capture width and height - different from output width and height if - * rotating 90 or 270 degrees. + * Capture width and height - different from output width and height if + * rotating 90 or 270 degrees. */ int cap_width; int cap_height; @@ -396,7 +400,7 @@ struct context { unsigned int moved; unsigned int pause; int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ - unsigned int lost_connection; + unsigned int lost_connection; #if (defined(BSD)) int tuner_dev; @@ -407,7 +411,7 @@ struct context { struct stream stream; int stream_count; - + #if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) int sql_mask; #endif From 848eff33dfdb934fd521a4f4b3f2d04d14315112 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Thu, 21 May 2015 14:37:59 -0700 Subject: [PATCH 104/233] Fixed quites in include --- motion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion.h b/motion.h index 6ae06ab..e7c2f47 100644 --- a/motion.h +++ b/motion.h @@ -23,7 +23,7 @@ #ifdef HAVE_SQLITE3 #ifdef HAVE_SQLITE3_EMBEDDED -#include sqlite3.h +#include "sqlite3.h" #else #include #endif From ad3344edadbe2181dabf092c6f75706633025518 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 09:02:42 -0700 Subject: [PATCH 105/233] reverting tab to spaces changes --- conf.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/conf.c b/conf.c index 5692662..6c6b8de 100644 --- a/conf.c +++ b/conf.c @@ -1592,26 +1592,26 @@ static void conf_cmdline(struct context *cnt, int thread) cnt->log_level = (unsigned int)atoi(optarg); break; case 'k': - if (thread == -1) { - strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); - cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); + cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; + } + break; case 'p': - if (thread == -1) { - strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); - cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); + cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; + } + break; case 'l': - if (thread == -1) { - strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); - cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); + cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; + } + break; case 'm': cnt->pause = 1; - break; + break; case 'h': case '?': default: @@ -1938,7 +1938,7 @@ struct context **conf_load(struct context **cnt) strncpy(cnt[0]->conf_filename, filename, sizeof(cnt[0]->conf_filename) - 1); cnt[0]->conf_filename[sizeof(cnt[0]->conf_filename) - 1] = '\0'; MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing thread 0 - config file %s", - filename); + filename); cnt = conf_process(cnt, fp); myfclose(fp); } else { From 6177885e135ac67c285eaf183f0fd254cd17ee2c Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 09:14:36 -0700 Subject: [PATCH 106/233] another tab reversion --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 6c6b8de..9db4ee6 100644 --- a/conf.c +++ b/conf.c @@ -1929,7 +1929,7 @@ struct context **conf_load(struct context **cnt) if (!fp) /* There is no config file.... use defaults. */ MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: could not open configfile %s", - filename); + filename); } } From 7273caec6dd31cd7999d646ff205b1d5542e1fca Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 09:34:46 -0700 Subject: [PATCH 107/233] reverting motion.h tab to spaces fix --- motion.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/motion.h b/motion.h index e7c2f47..2d42b0e 100644 --- a/motion.h +++ b/motion.h @@ -93,7 +93,7 @@ #endif -/* +/* * The macro below defines a version of sleep using nanosleep * If a signal such as SIG_CHLD interrupts the sleep we just continue sleeping */ @@ -102,7 +102,7 @@ tv.tv_sec = (seconds); \ tv.tv_nsec = (nanoseconds); \ while (nanosleep(&tv, &tv) == -1); \ - } + } #define CLEAR(x) memset(&(x), 0, sizeof(x)) @@ -219,7 +219,7 @@ struct images; #include "track.h" #include "netcam.h" -/* +/* * Structure to hold images information * The idea is that this should have all information about a picture e.g. diffs, timestamp etc. * The exception is the label information, it uses a lot of memory @@ -242,9 +242,9 @@ struct image_data { struct tm timestamp_tm; int shot; /* Sub second timestamp count */ - /* - * Movement center to img center distance - * Note: Dist is calculated distX*distX + distY*distY + /* + * Movement center to img center distance + * Note: Dist is calculated distX*distX + distY*distY */ unsigned long cent_dist; @@ -255,24 +255,24 @@ struct image_data { int total_labels; }; -/* +/* * DIFFERENCES BETWEEN imgs.width, conf.width AND rotate_data.cap_width * (and the corresponding height values, of course) * =========================================================================== * Location Purpose - * + * * conf The values in conf reflect width and height set in the - * configuration file. These can be set via http remote control, + * configuration file. These can be set via http remote control, * but they are not used internally by Motion, so it won't break * anything. These values are transferred to imgs in vid_start. * * imgs The values in imgs are the actual output dimensions. Normally * the output dimensions are the same as the capture dimensions, - * but for 90 or 270 degrees rotation, they are not. E.g., if + * but for 90 or 270 degrees rotation, they are not. E.g., if * you capture at 320x240, and rotate 90 degrees, the output * dimensions are 240x320. - * These values are set from the conf values in vid_start, or - * from the first JPEG image in netcam_start. For 90 or 270 + * These values are set from the conf values in vid_start, or + * from the first JPEG image in netcam_start. For 90 or 270 * degrees rotation, they are swapped in rotate_init. * * rotate_data The values in rotate_data are named cap_width and cap_height, @@ -306,7 +306,7 @@ struct images { int width; int height; int type; - int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ + int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ int size; int motionsize; int labelgroup_max; @@ -319,7 +319,7 @@ struct images { struct rotdata { /* Temporary buffer for 90 and 270 degrees rotation. */ unsigned char *temp_buf; - /* + /* * Degrees to rotate; copied from conf.rotate_deg. This is the value * that is actually used. The value of conf.rotate_deg cannot be used * because it can be changed by motion-control, and changing rotation @@ -327,8 +327,8 @@ struct rotdata { */ int degrees; /* - * Capture width and height - different from output width and height if - * rotating 90 or 270 degrees. + * Capture width and height - different from output width and height if + * rotating 90 or 270 degrees. */ int cap_width; int cap_height; @@ -400,7 +400,7 @@ struct context { unsigned int moved; unsigned int pause; int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */ - unsigned int lost_connection; + unsigned int lost_connection; #if (defined(BSD)) int tuner_dev; @@ -411,7 +411,7 @@ struct context { struct stream stream; int stream_count; - + #if defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) int sql_mask; #endif From 2ab6ef6e81bef23cf0856ceacf24609f7d1ec2fd Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 09:51:35 -0700 Subject: [PATCH 108/233] reverting tab to space --- motion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion.h b/motion.h index 2d42b0e..88e5839 100644 --- a/motion.h +++ b/motion.h @@ -306,7 +306,7 @@ struct images { int width; int height; int type; - int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ + int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ int size; int motionsize; int labelgroup_max; From ef60ae4a1195def7028f5f86fa7bbc3c39053244 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 09:54:09 -0700 Subject: [PATCH 109/233] reverting tab to space --- motion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion.h b/motion.h index 88e5839..07db87b 100644 --- a/motion.h +++ b/motion.h @@ -306,7 +306,7 @@ struct images { int width; int height; int type; - int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ + int picture_type; /* Output picture type IMAGE_JPEG, IMAGE_PPM */ int size; int motionsize; int labelgroup_max; From 310cac7c68778d6efd8b37865a2883275f4680a5 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 14:36:58 -0700 Subject: [PATCH 110/233] Reverting tab to spaces fix --- configure.ac | 1318 +++++++++++++++++++++++++------------------------- 1 file changed, 660 insertions(+), 658 deletions(-) diff --git a/configure.ac b/configure.ac index 73daccd..5eb7ddc 100755 --- a/configure.ac +++ b/configure.ac @@ -16,8 +16,8 @@ FreeBSD="" LINUXTHREADS="no" AC_ARG_WITH(linuxthreads, [ --with-linuxthreads Use linuxthreads in BSD instead of native pthreads - ] - , + ] + , LINUXTHREADS="$withval" ) @@ -34,45 +34,45 @@ AC_MSG_CHECKING(for Darwin) Darwin=`uname -a | grep "Darwin"` if test "${Darwin}" = ""; then - AC_MSG_RESULT(no) - AC_MSG_CHECKING(for *BSD) - - FreeBSD=`uname -a | grep "FreeBSD"` - if test "${FreeBSD}" = ""; then - AC_MSG_RESULT(no) - VIDEO="video.o video2.o video_common.o" - else - AC_MSG_RESULT(yes) - if test "${LINUXTHREADS}" = "no"; then - AC_MSG_CHECKING(Linuxthreads) - AC_MSG_RESULT(skipping) - else - THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" - THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" - fi - - if test "${PWCBSD}" != "no"; then - VIDEO="video.o video2.o video_common.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" - else - VIDEO="video_freebsd.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" - fi - - TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" - TEMP_LIBS="-L/usr/local/lib" - AC_MSG_RESULT(Build with PWCBSD support $PWCBSD) - - fi + AC_MSG_RESULT(no) + AC_MSG_CHECKING(for *BSD) + + FreeBSD=`uname -a | grep "FreeBSD"` + if test "${FreeBSD}" = ""; then + AC_MSG_RESULT(no) + VIDEO="video.o video2.o video_common.o" + else + AC_MSG_RESULT(yes) + if test "${LINUXTHREADS}" = "no"; then + AC_MSG_CHECKING(Linuxthreads) + AC_MSG_RESULT(skipping) + else + THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" + THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" + fi + + if test "${PWCBSD}" != "no"; then + VIDEO="video.o video2.o video_common.o" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" + else + VIDEO="video_freebsd.o" + TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" + fi + + TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" + TEMP_LIBS="-L/usr/local/lib" + AC_MSG_RESULT(Build with PWCBSD support $PWCBSD) + + fi else - TEMP_CFLAGS="${CFLAGS} -I/sw/include" - TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" - TEMP_LIBS="-L/sw/lib" - VIDEO="video_freebsd.o" - FINK_LIB="-L/sw/lib" - Darwin="yes" - V4L="no" - AC_MSG_RESULT($Darwin) + TEMP_CFLAGS="${CFLAGS} -I/sw/include" + TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" + TEMP_LIBS="-L/sw/lib" + VIDEO="video_freebsd.o" + FINK_LIB="-L/sw/lib" + Darwin="yes" + V4L="no" + AC_MSG_RESULT($Darwin) fi @@ -87,14 +87,14 @@ TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then - AC_MSG_CHECKING(bktr headers in /usr/include/dev/bktr) + AC_MSG_CHECKING(bktr headers in /usr/include/dev/bktr) - if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" - fi + if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" + fi # # Check to Exclude BKTR # @@ -107,9 +107,9 @@ AC_ARG_WITH(bktr, BKTR="$withval" ) - if test "${BKTR}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" - fi + if test "${BKTR}" = "no"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + fi else @@ -128,7 +128,7 @@ fi if test "${V4L}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" + TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" fi @@ -139,22 +139,22 @@ AC_MSG_CHECKING(for linuxthreads) # # Check for thread header # - if test -f "${THREAD_CHECK}"; then - HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" - THREADS="yes" - else - THREADS="no" - fi + if test -f "${THREAD_CHECK}"; then + HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" + THREADS="yes" + else + THREADS="no" + fi # # Check for thread lib # - if test -f "${THREAD_LIB_CHECK}" ; then - THREADS="yes" - LIB_THREAD="-llthread -llgcc_r" - else - THREADS="no" - fi + if test -f "${THREAD_LIB_CHECK}" ; then + THREADS="yes" + LIB_THREAD="-llthread -llgcc_r" + else + THREADS="no" + fi # Checks for Library linuxthreads for FreeBSD # @@ -164,8 +164,8 @@ AC_MSG_CHECKING(for linuxthreads) # /usr/local/lib/libpthread.so # - if test "${THREADS}" = "yes"; then - TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" + if test "${THREADS}" = "yes"; then + TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" THREAD_CFLAGS="-D_THREAD_SAFE" PTHREAD_SUPPORT="yes" @@ -190,21 +190,21 @@ AC_TRY_LINK([#include ], if test x$PTHREAD_LIB != xyes; then - if test "${FreeBSD}" != ""; then - TEMP_LIBS="$TEMP_LIBS -pthread" - TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" - else - TEMP_LIBS="$TEMP_LIBS -lpthread" - TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" - fi - PTHREAD_SUPPORT="yes" + if test "${FreeBSD}" != ""; then + TEMP_LIBS="$TEMP_LIBS -pthread" + TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" + else + TEMP_LIBS="$TEMP_LIBS -lpthread" + TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" + fi + PTHREAD_SUPPORT="yes" fi - AC_MSG_RESULT($PTHREAD_SUPPORT) + AC_MSG_RESULT($PTHREAD_SUPPORT) else - echo - echo "You do not have threads support" - echo + echo + echo "You do not have threads support" + echo fi @@ -219,33 +219,33 @@ AC_ARG_WITH(sdl, []) AC_MSG_CHECKING(for sdl) if test "x$withval" = "xno"; then - AC_MSG_RESULT(skipped) + AC_MSG_RESULT(skipped) else - if test "${FreeBSD}" != ""; then - CONFIG_SDL='sdl11-config' - else - CONFIG_SDL='sdl-config' - fi - if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then - AC_MSG_RESULT(no) - if test "$withval" = "yes"; then - echo "" - echo "****************************************************" - echo "* sdl-config could not be found. Please install it *" - echo "* and remove the --with-sdl configure argument. *" - echo "* libSDL can be found at http://www.libsdl.org *" - echo "****************************************************" - echo "" - fi - else - AC_MSG_RESULT(yes) - SDL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" - TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" - AC_DEFINE([HAVE_SDL],1,[Define to 1 if you have SDL support]) - SDL_OBJ="sdl.o" - AC_SUBST(SDL_OBJ) - fi + if test "${FreeBSD}" != ""; then + CONFIG_SDL='sdl11-config' + else + CONFIG_SDL='sdl-config' + fi + if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then + AC_MSG_RESULT(no) + if test "$withval" = "yes"; then + echo "" + echo "****************************************************" + echo "* sdl-config could not be found. Please install it *" + echo "* and remove the --with-sdl configure argument. *" + echo "* libSDL can be found at http://www.libsdl.org *" + echo "****************************************************" + echo "" + fi + else + AC_MSG_RESULT(yes) + SDL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" + TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" + AC_DEFINE([HAVE_SDL],1,[Define to 1 if you have SDL support]) + SDL_OBJ="sdl.o" + AC_SUBST(SDL_OBJ) + fi fi # @@ -316,42 +316,42 @@ if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then AC_MSG_CHECKING(for libjpeg-mmx) AC_MSG_RESULT(skipping) elif test "${JPEG_MMX}" = "yes"; then - # AUTODETECT STATIC LIB - AC_MSG_CHECKING(for libjpeg-mmx autodetecting) - - if test -f /usr/lib/libjpeg-mmx.a ; then - AC_MSG_RESULT(found) - JPEG_MMX_OK="found" - JPEG_MMX="/usr/lib" - elif test -f /usr/local/lib/libjpeg-mmx.a ; then - AC_MSG_RESULT(found) - JPEG_MMX_OK="found" - JPEG_MMX="/usr/local/lib" - else - AC_MSG_RESULT(not found) - fi + # AUTODETECT STATIC LIB + AC_MSG_CHECKING(for libjpeg-mmx autodetecting) + + if test -f /usr/lib/libjpeg-mmx.a ; then + AC_MSG_RESULT(found) + JPEG_MMX_OK="found" + JPEG_MMX="/usr/lib" + elif test -f /usr/local/lib/libjpeg-mmx.a ; then + AC_MSG_RESULT(found) + JPEG_MMX_OK="found" + JPEG_MMX="/usr/local/lib" + else + AC_MSG_RESULT(not found) + fi else - AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) - if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then - AC_MSG_RESULT(found) - JPEG_MMX_OK="found" - else - AC_MSG_RESULT(not found) - fi + AC_MSG_CHECKING(for libjpeg-mmx in -> [${JPEG_MMX}] <-) + if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then + AC_MSG_RESULT(found) + JPEG_MMX_OK="found" + else + AC_MSG_RESULT(not found) + fi fi if test "${JPEG_MMX_OK}" = "found"; then - saved_CFLAGS="$CFLAGS" - saved_LIBS="$LIBS" - CFLAGS="$CFLAGS -I${JPEG_MMX}" - LIBS="$LIBS -L${JPEG_MMX}" - AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress, - [ TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" - TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" - JPEG_SUPPORT="yes"],,) - LIBS="$saved_LIBS" - CFLAGS="$saved_CFLAGS" - JPEG_SUPPORT_MMX="yes" + saved_CFLAGS="$CFLAGS" + saved_LIBS="$LIBS" + CFLAGS="$CFLAGS -I${JPEG_MMX}" + LIBS="$LIBS -L${JPEG_MMX}" + AC_CHECK_LIB(jpeg-mmx, jpeg_start_compress, + [ TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" + TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" + JPEG_SUPPORT="yes"],,) + LIBS="$saved_LIBS" + CFLAGS="$saved_CFLAGS" + JPEG_SUPPORT_MMX="yes" fi # @@ -362,13 +362,13 @@ if test x$JPEG_SUPPORT != xyes ; then LDFLAGS=$TEMP_LDFLAGS AC_CHECK_LIB(jpeg, jpeg_set_defaults, [ - TEMP_LIBS="$TEMP_LIBS -ljpeg" - JPEG_SUPPORT="yes" - ], [ - echo - echo "You do not have libjpeg installed" - echo - ] + TEMP_LIBS="$TEMP_LIBS -ljpeg" + JPEG_SUPPORT="yes" + ], [ + echo + echo "You do not have libjpeg installed" + echo + ] ) fi @@ -414,78 +414,78 @@ FFMPEG_EXTRALIBS="$withval" # --without-ffmpeg or with-ffmpeg=no # if test "${FFMPEG_DIR}" = "no"; then - AC_MSG_CHECKING(for ffmpeg) - AC_MSG_RESULT(skipping) + AC_MSG_CHECKING(for ffmpeg) + AC_MSG_RESULT(skipping) # # with-ffmpeg= or nothing # else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB - AC_MSG_CHECKING(for ffmpeg autodetecting libraries) - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib64) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib" - FFMPEG_DIR="/usr" - elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/local/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" + # AUTODETECT STATIC/SHARED LIB + AC_MSG_CHECKING(for ffmpeg autodetecting libraries) + + if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib64) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib64" + FFMPEG_DIR="/usr" + elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then + AC_MSG_RESULT(found in /usr/lib) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/lib" + FFMPEG_DIR="/usr" + elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then + AC_MSG_RESULT(found in /usr/local/lib) + FFMPEG_OK="found" + FFMPEG_LIB="/usr/local/lib" + FFMPEG_DIR="/usr/local" elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then AC_MSG_RESULT(found in /usr/lib/x86_64-linux-gnu) FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" FFMPEG_DIR="/usr" - elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then + elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) FFMPEG_OK="found" FFMPEG_LIB="/usr/lib/i386-linux-gnu" FFMPEG_DIR="/usr" - else - AC_MSG_RESULT(not found) - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi + else + AC_MSG_RESULT(not found) + echo "" + echo "**********************************************" + echo "* libavcodec.a or libavcodec.so or *" + echo "* libavformat.a or libavformat.so not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi else - AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_OK="found" - FFMPEG_LIB="${FFMPEG_DIR}/lib" - elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_LIB="${FFMPEG_DIR}" - FFMPEG_OK="found" - else - AC_MSG_RESULT(not found) - if test "${FFMPEG_OK}" != "found"; then - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - fi + AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) + if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then + AC_MSG_RESULT(found) + FFMPEG_OK="found" + FFMPEG_LIB="${FFMPEG_DIR}/lib" + elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then + AC_MSG_RESULT(found) + FFMPEG_LIB="${FFMPEG_DIR}" + FFMPEG_OK="found" + else + AC_MSG_RESULT(not found) + if test "${FFMPEG_OK}" != "found"; then + echo "" + echo "**********************************************" + echo "* libavcodec.a or libavcodec.so or *" + echo "* libavformat.a or libavformat.so not found: *" + echo "* ALL FFMPEG FEATURES DISABLED *" + echo "* *" + echo "* Please read the Motion Guide for help: *" + echo "* http://motion.sourceforge.net *" + echo "**********************************************" + echo "" + fi + fi fi @@ -610,6 +610,7 @@ if test "${SQLITE3}" = "no"; then else saved_CFLAGS=$CFLAGS saved_LIBS=$LIBS + # first we check to see if the sqlite3 amalgamation (sqlite3.c), is in with our source # this is the prefered way to use sqlite AC_CHECK_FILE([sqlite3.c], @@ -632,6 +633,7 @@ else ) ] ) + CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS fi @@ -678,110 +680,110 @@ MYSQL_HEADERS="$withval" if test "${MYSQL}" = "no"; then - AC_MSG_RESULT(skipped) + AC_MSG_RESULT(skipped) else - AC_MSG_RESULT(testing) - # ******* Search mysql headers ******* - - if test "${MYSQL_HEADERS}" = "yes"; then - AC_MSG_CHECKING(autodect mysql headers) - # Autodetect - for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do - # check for plain setups - if test -f $w/mysql.h; then - MYSQL_INCDIR=$w - break - fi - # check for "/usr/include/" type setups - if test -f $w/mysql/mysql.h; then - MYSQL_INCDIR=$w/mysql - break - fi - # check for "/usr//include" type setups - if test -f $w/mysql/include/mysql.h; then - MYSQL_INCDIR=$w/mysql/include - break - fi - done - elif test "${MYSQL_HEADERS}" = "no"; then - AC_MSG_CHECKING(for mysql headers) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) - # Manual detection for - if test -f $MYSQL_HEADERS/mysql.h; then - MYSQL_INCDIR=$MYSQL_HEADERS - fi - fi - - if test -z "$MYSQL_INCDIR" ; then - MYSQL_HEADERS="no" - AC_MSG_RESULT(not found) - echo "Invalid MySQL directory - unable to find mysql.h." - else - AC_MSG_RESULT($MYSQL_INCDIR yes) - MYSQL_HEADERS="yes" - fi - - - if test "${MYSQL_HEADERS}" = "yes"; then - - # ******* Search mysql libs ********* - if test "${MYSQL_LIBS}" = "yes"; then - AC_MSG_CHECKING(autodect mysql libs) - # Autodetect - for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do - # check for plain setups - if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then - MYSQL_LIBDIR=$w - break - fi - # check for "/usr/lib/" type setups - if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then - MYSQL_LIBDIR=$w/mysql - break - fi - # check for "/usr//lib" type setups - if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then - MYSQL_LIBDIR=$w/mysql/lib - break - fi - done - elif test "${MYSQL_LIBS}" = "no"; then - AC_MSG_CHECKING(for mysql libs) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) - # Manual detection for - if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then - MYSQL_LIBDIR=$MYSQL_LIBS - fi - fi - - - if test -z "$MYSQL_LIBDIR" ; then - AC_MSG_RESULT(not found) - echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." - else - AC_MSG_RESULT($MYSQL_LIBDIR) - #LDFLAGS="-L$MYSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$MYSQL_INCDIR" - LIBS="-L$MYSQL_LIBDIR" - AC_CHECK_LIB(mysqlclient,mysql_init,[ - TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" - TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" - MYSQL_SUPPORT="yes" - AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) - ], - AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - # end mysql-include , mysql-libs - fi + AC_MSG_RESULT(testing) + # ******* Search mysql headers ******* + + if test "${MYSQL_HEADERS}" = "yes"; then + AC_MSG_CHECKING(autodect mysql headers) + # Autodetect + for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do + # check for plain setups + if test -f $w/mysql.h; then + MYSQL_INCDIR=$w + break + fi + # check for "/usr/include/" type setups + if test -f $w/mysql/mysql.h; then + MYSQL_INCDIR=$w/mysql + break + fi + # check for "/usr//include" type setups + if test -f $w/mysql/include/mysql.h; then + MYSQL_INCDIR=$w/mysql/include + break + fi + done + elif test "${MYSQL_HEADERS}" = "no"; then + AC_MSG_CHECKING(for mysql headers) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS) + # Manual detection for + if test -f $MYSQL_HEADERS/mysql.h; then + MYSQL_INCDIR=$MYSQL_HEADERS + fi + fi + + if test -z "$MYSQL_INCDIR" ; then + MYSQL_HEADERS="no" + AC_MSG_RESULT(not found) + echo "Invalid MySQL directory - unable to find mysql.h." + else + AC_MSG_RESULT($MYSQL_INCDIR yes) + MYSQL_HEADERS="yes" + fi + + + if test "${MYSQL_HEADERS}" = "yes"; then + + # ******* Search mysql libs ********* + if test "${MYSQL_LIBS}" = "yes"; then + AC_MSG_CHECKING(autodect mysql libs) + # Autodetect + for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do + # check for plain setups + if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then + MYSQL_LIBDIR=$w + break + fi + # check for "/usr/lib/" type setups + if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then + MYSQL_LIBDIR=$w/mysql + break + fi + # check for "/usr//lib" type setups + if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then + MYSQL_LIBDIR=$w/mysql/lib + break + fi + done + elif test "${MYSQL_LIBS}" = "no"; then + AC_MSG_CHECKING(for mysql libs) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS) + # Manual detection for + if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then + MYSQL_LIBDIR=$MYSQL_LIBS + fi + fi + + + if test -z "$MYSQL_LIBDIR" ; then + AC_MSG_RESULT(not found) + echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." + else + AC_MSG_RESULT($MYSQL_LIBDIR) + #LDFLAGS="-L$MYSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$MYSQL_INCDIR" + LIBS="-L$MYSQL_LIBDIR" + AC_CHECK_LIB(mysqlclient,mysql_init,[ + TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" + TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" + MYSQL_SUPPORT="yes" + AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MySQL support]) + ], + AC_MSG_ERROR(MySQL support can't build without MySQL libraries)) + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + # end mysql-include , mysql-libs + fi # end Mysql detection fi @@ -827,100 +829,100 @@ PGSQL_HEADERS="$withval" AC_MSG_CHECKING(for PostgreSQL) if test "${PGSQL}" = "no"; then - AC_MSG_RESULT(skipped) + AC_MSG_RESULT(skipped) else - AC_MSG_RESULT(testing) - - # ******* Search pgsql headers ******* - if test "${PGSQL_HEADERS}" = "yes"; then - - AC_MSG_CHECKING(autodect pgsql headers) - # Autodetect - for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do - PGSQL_INC_CHK(/include) - el[]PGSQL_INC_CHK(/include/pgsql) - el[]PGSQL_INC_CHK(/include/postgresql) - fi - done - - elif test "${PGSQL_HEADERS}" = "no"; then - AC_MSG_CHECKING(for pgsql headers) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) - # Manual detection for - if test -f $PGSQL_HEADERS/libpq-fe.h; then - PGSQL_INCDIR=$PGSQL_HEADERS - fi - fi - - if test -z "$PGSQL_INCDIR" ; then - PGSQL_HEADERS="no" - AC_MSG_RESULT(not found) - echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." - else - AC_MSG_RESULT(yes [$PGSQL_INCDIR]) - PGSQL_HEADERS="yes" - fi - - - if test "${PGSQL_HEADERS}" = "yes"; then - - # ******* Search pgsql libs ********* - if test "${PGSQL_LIBS}" = "yes"; then - AC_MSG_CHECKING(autodect pgsql libs) - # Autodetect - PGSQL_INCLUDE="-I$PGSQL_INCDIR" - PGSQL_LIBDIR=$PGSQL_DIR/lib - - if test -f /usr/lib64/libpq.so ; then - PGSQL_LIBDIR=/usr/lib64 - elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql - elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql - elif test -f $PGSQL_DIR/lib/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib - else - PGSQL_LIBDIR="" - fi - - AC_MSG_RESULT($PGSQL_LIBDIR) - - elif test "${PGSQL_LIBS}" = "no"; then - AC_MSG_CHECKING(for pgsql libs) - AC_MSG_RESULT(skipped) - else - AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) - # Manual detection for - if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then - PGSQL_LIBDIR=$PGSQL_LIBS - fi - fi - - - if test -z "$PGSQL_LIBDIR" ; then - AC_MSG_RESULT(not found) - echo "Invalid PostgreSQL directory [$PGSQL_LIBDIR] - unable to find libpq.a or libpq.so." - else - #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$PGSQL_INCDIR" - LIBS="-L$PGSQL_LIBDIR" - AC_CHECK_LIB(pq, PQconnectStart, [ - PGSQL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" - TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" - AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) - ], - AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) - LDFLAGS="" - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - fi # end pgsql-include , pgsql-libs + AC_MSG_RESULT(testing) + + # ******* Search pgsql headers ******* + if test "${PGSQL_HEADERS}" = "yes"; then + + AC_MSG_CHECKING(autodect pgsql headers) + # Autodetect + for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do + PGSQL_INC_CHK(/include) + el[]PGSQL_INC_CHK(/include/pgsql) + el[]PGSQL_INC_CHK(/include/postgresql) + fi + done + + elif test "${PGSQL_HEADERS}" = "no"; then + AC_MSG_CHECKING(for pgsql headers) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS) + # Manual detection for + if test -f $PGSQL_HEADERS/libpq-fe.h; then + PGSQL_INCDIR=$PGSQL_HEADERS + fi + fi + + if test -z "$PGSQL_INCDIR" ; then + PGSQL_HEADERS="no" + AC_MSG_RESULT(not found) + echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." + else + AC_MSG_RESULT(yes [$PGSQL_INCDIR]) + PGSQL_HEADERS="yes" + fi + + + if test "${PGSQL_HEADERS}" = "yes"; then + + # ******* Search pgsql libs ********* + if test "${PGSQL_LIBS}" = "yes"; then + AC_MSG_CHECKING(autodect pgsql libs) + # Autodetect + PGSQL_INCLUDE="-I$PGSQL_INCDIR" + PGSQL_LIBDIR=$PGSQL_DIR/lib + + if test -f /usr/lib64/libpq.so ; then + PGSQL_LIBDIR=/usr/lib64 + elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql + elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql + elif test -f $PGSQL_DIR/lib/libpq.so ; then + PGSQL_LIBDIR=$PGSQL_DIR/lib + else + PGSQL_LIBDIR="" + fi + + AC_MSG_RESULT($PGSQL_LIBDIR) + + elif test "${PGSQL_LIBS}" = "no"; then + AC_MSG_CHECKING(for pgsql libs) + AC_MSG_RESULT(skipped) + else + AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS) + # Manual detection for + if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then + PGSQL_LIBDIR=$PGSQL_LIBS + fi + fi + + + if test -z "$PGSQL_LIBDIR" ; then + AC_MSG_RESULT(not found) + echo "Invalid PostgreSQL directory [$PGSQL_LIBDIR] - unable to find libpq.a or libpq.so." + else + #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" + saved_CFLAGS=$CFLAGS + saved_LIBS=$LIBS + CFLAGS="-I$PGSQL_INCDIR" + LIBS="-L$PGSQL_LIBDIR" + AC_CHECK_LIB(pq, PQconnectStart, [ + PGSQL_SUPPORT="yes" + TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" + TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" + AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PostgreSQL support]) + ], + AC_MSG_ERROR(PostgreSQL support can't build without PostgreSQL libraries)) + LDFLAGS="" + CFLAGS=$saved_CFLAGS + LIBS=$saved_LIBS + fi + + fi # end pgsql-include , pgsql-libs # end PostgreSQL detection fi @@ -937,38 +939,38 @@ SUPPORTED_V4L2=false SUPPORTED_V4L2_old=false if test "${V4L}" = "no"; then - AC_MSG_CHECKING(for V42L support) - AC_MSG_RESULT(skipping) + AC_MSG_CHECKING(for V42L support) + AC_MSG_RESULT(skipping) else - AC_CHECK_TYPE([struct v4l2_buffer], - [SUPPORTED_V4L2=true], - [SUPPORTED_V4L2=false], - [#include - #ifdef HAVE_LINUX_VIDEODEV_H - #include - #elif HAVE_SYS_VIDEOIO_H - #include - #endif]) - AC_MSG_CHECKING(for V42L support) - if test x$SUPPORTED_V4L2 = xtrue; then - AC_MSG_RESULT(yes) - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" - else - AC_MSG_RESULT(no) - fi - - # linux/videodev.h doesn't include videodev2.h - if test x$SUPPORTED_V4L2 = xfalse; then - AC_MSG_CHECKING(for V42L *old* support) - AC_MSG_RESULT(testing) - AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) - fi - - - if test x$SUPPORTED_V4L2_old = xtrue; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" - SUPPORTED_V4L2=true - fi + AC_CHECK_TYPE([struct v4l2_buffer], + [SUPPORTED_V4L2=true], + [SUPPORTED_V4L2=false], + [#include + #ifdef HAVE_LINUX_VIDEODEV_H + #include + #elif HAVE_SYS_VIDEOIO_H + #include + #endif]) + AC_MSG_CHECKING(for V42L support) + if test x$SUPPORTED_V4L2 = xtrue; then + AC_MSG_RESULT(yes) + TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" + else + AC_MSG_RESULT(no) + fi + + # linux/videodev.h doesn't include videodev2.h + if test x$SUPPORTED_V4L2 = xfalse; then + AC_MSG_CHECKING(for V42L *old* support) + AC_MSG_RESULT(testing) + AC_CHECK_HEADERS(linux/videodev2.h,[SUPPORTED_V4L2_old=true],[], [#include ]) + fi + + + if test x$SUPPORTED_V4L2_old = xtrue; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" + SUPPORTED_V4L2=true + fi fi @@ -982,15 +984,15 @@ AC_CHECK_SIZEOF(int *) AC_CHECK_SIZEOF(void *) if test "$ac_cv_sizeof_short" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" else - if test "$ac_cv_sizeof_int" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" - else - if test "$ac_cv_sizeof_long_int" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" - fi - fi + if test "$ac_cv_sizeof_int" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" + else + if test "$ac_cv_sizeof_long_int" = "4"; then + TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" + fi + fi fi @@ -1000,7 +1002,7 @@ AC_ARG_WITH(optimizecpu, [ --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. - ], + ], OPTIMIZECPU="$withval" ) @@ -1017,7 +1019,7 @@ DEVELOPER_FLAGS="$withval" AC_C_CONST if test "${FreeBSD}" != ""; then - OPTIMIZECPU="" + OPTIMIZECPU="" fi if test "${OPTIMIZECPU}" = "yes"; then @@ -1026,193 +1028,193 @@ if test "${OPTIMIZECPU}" = "yes"; then CPU_NAME="unknown" CPU_TYPE="unknown" if test -e "/proc/cpuinfo" ; then - intel[[30]]="-march=i386" - intel[[32]]="-march=i386" - intel[[34]]="-march=i386" - intel[[40]]="-march=i486" - intel[[41]]="-march=i486" - intel[[42]]="-march=i486" - intel[[43]]="-march=i486" - intel[[44]]="-march=i486" - intel[[45]]="-march=i486" - intel[[47]]="-march=i486" - intel[[48]]="-march=i486" - intel[[51]]="-march=pentium" - intel[[52]]="-march=pentium" - intel[[54]]="-march=pentium-mmx" - intel[[56]]="-march=pentium-mmx" - intel[[61]]="-march=pentiumpro" - intel[[63]]="-march=pentium2" - intel[[65]]="-march=pentium2" - intel[[66]]="-march=pentium2" - intel[[67]]="-march=pentium3" - intel[[68]]="-march=pentium3" - intel[[610]]="-march=pentium3" - intel[[611]]="-march=pentium3" - intel[[150]]="-march=pentium4" - intel[[151]]="-march=pentium4" - intel[[152]]="-march=pentium4" - intel[[154]]="-march=pentium4" - intel[[614]]="-march=prescott" - intel[[628]]="-march=core2" - amd[[50]]="-march=i586" - amd[[51]]="-march=i586" - amd[[52]]="-march=i586" - amd[[53]]="-march=i586" - amd[[56]]="-march=k6" - amd[[57]]="-march=k6" - amd[[58]]="-march=k6-2" - amd[[510]]="-march=k6-2" - amd[[59]]="-march=k6-3" - amd[[513]]="-march=k6-3" - amd[[61]]="-march=athlon" - amd[[62]]="-march=athlon" - amd[[63]]="-march=athlon" - amd[[64]]="-march=athlon" - amd[[66]]="-march=athlon" - amd[[67]]="-march=athlon" - amd[[68]]="-march=athlon" - amd[[610]]="-march=athlon" - amd[[158]]="-march=athlon-xp" - amd[[154]]="-march=k8" - amd[[155]]="-march=athlon64" - amd[[1543]]="-march=athlon64" - amd[[1544]]="-march=athlon64" - amd[[1565]]="-march=opteron" - amd[[1572]]="-march=k8" - via[[67]]="-march=c3" - via[[68]]="-march=c3" - via[[69]]="-march=i686" - via[[610]]="-march=i686" - - CPU_TYPE="known" - CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` - CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` - CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` - CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` - CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` - CPU_FAMILY=${CPU_FAMILY#*: } - CPU_MODEL=${CPU_MODEL#*: } - CPU_NAME=${CPU_NAME#*: } - CPU_FLAGS=${CPU_FLAGS#*: } - CPU_VENDOR=${CPU_VENDOR#*: } - if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then - CPU_OPTIONS=${intel[[$CPU_FAMILY$CPU_MODEL]]} - fi - if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then - CPU_OPTIONS=${amd[[$CPU_FAMILY$CPU_MODEL]]} - fi - if test "x${CPU_VENDOR}" = "xCentaurHauls"; then - CPU_OPTIONS=${via[[$CPU_FAMILY$CPU_MODEL]]} - fi - if test "x${CPU_OPTIONS}" = "x" ; then - CPU_TYPE="unknown" - fi - CPU_EXT="" - for i in $CPU_FLAGS ; do - case $i in - fpu) - CPU_FPU="-mfpmath=387" - ;; - mmx) - CPU_EXT="$CPU_EXT -mmmx" - ;; - sse) - CPU_FPU="-mfpmath=sse -msse" - ;; - sse2) - CPU_FPU="-mfpmath=sse -msse2" - ;; - sse3) - CPU_FPU="-msse3" - ;; - ssse3) - CPU_FPU="-mfpmath=sse -msse2 -mssse3" - ;; - 3dnow) - CPU_EXT="$CPU_EXT -m3dnow" - ;; - esac - done - CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" + intel[[30]]="-march=i386" + intel[[32]]="-march=i386" + intel[[34]]="-march=i386" + intel[[40]]="-march=i486" + intel[[41]]="-march=i486" + intel[[42]]="-march=i486" + intel[[43]]="-march=i486" + intel[[44]]="-march=i486" + intel[[45]]="-march=i486" + intel[[47]]="-march=i486" + intel[[48]]="-march=i486" + intel[[51]]="-march=pentium" + intel[[52]]="-march=pentium" + intel[[54]]="-march=pentium-mmx" + intel[[56]]="-march=pentium-mmx" + intel[[61]]="-march=pentiumpro" + intel[[63]]="-march=pentium2" + intel[[65]]="-march=pentium2" + intel[[66]]="-march=pentium2" + intel[[67]]="-march=pentium3" + intel[[68]]="-march=pentium3" + intel[[610]]="-march=pentium3" + intel[[611]]="-march=pentium3" + intel[[150]]="-march=pentium4" + intel[[151]]="-march=pentium4" + intel[[152]]="-march=pentium4" + intel[[154]]="-march=pentium4" + intel[[614]]="-march=prescott" + intel[[628]]="-march=core2" + amd[[50]]="-march=i586" + amd[[51]]="-march=i586" + amd[[52]]="-march=i586" + amd[[53]]="-march=i586" + amd[[56]]="-march=k6" + amd[[57]]="-march=k6" + amd[[58]]="-march=k6-2" + amd[[510]]="-march=k6-2" + amd[[59]]="-march=k6-3" + amd[[513]]="-march=k6-3" + amd[[61]]="-march=athlon" + amd[[62]]="-march=athlon" + amd[[63]]="-march=athlon" + amd[[64]]="-march=athlon" + amd[[66]]="-march=athlon" + amd[[67]]="-march=athlon" + amd[[68]]="-march=athlon" + amd[[610]]="-march=athlon" + amd[[158]]="-march=athlon-xp" + amd[[154]]="-march=k8" + amd[[155]]="-march=athlon64" + amd[[1543]]="-march=athlon64" + amd[[1544]]="-march=athlon64" + amd[[1565]]="-march=opteron" + amd[[1572]]="-march=k8" + via[[67]]="-march=c3" + via[[68]]="-march=c3" + via[[69]]="-march=i686" + via[[610]]="-march=i686" + + CPU_TYPE="known" + CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` + CPU_MODEL=`cat /proc/cpuinfo | grep model[[^\ ]] | head -n1` + CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` + CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` + CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` + CPU_FAMILY=${CPU_FAMILY#*: } + CPU_MODEL=${CPU_MODEL#*: } + CPU_NAME=${CPU_NAME#*: } + CPU_FLAGS=${CPU_FLAGS#*: } + CPU_VENDOR=${CPU_VENDOR#*: } + if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then + CPU_OPTIONS=${intel[[$CPU_FAMILY$CPU_MODEL]]} + fi + if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then + CPU_OPTIONS=${amd[[$CPU_FAMILY$CPU_MODEL]]} + fi + if test "x${CPU_VENDOR}" = "xCentaurHauls"; then + CPU_OPTIONS=${via[[$CPU_FAMILY$CPU_MODEL]]} + fi + if test "x${CPU_OPTIONS}" = "x" ; then + CPU_TYPE="unknown" + fi + CPU_EXT="" + for i in $CPU_FLAGS ; do + case $i in + fpu) + CPU_FPU="-mfpmath=387" + ;; + mmx) + CPU_EXT="$CPU_EXT -mmmx" + ;; + sse) + CPU_FPU="-mfpmath=sse -msse" + ;; + sse2) + CPU_FPU="-mfpmath=sse -msse2" + ;; + sse3) + CPU_FPU="-msse3" + ;; + ssse3) + CPU_FPU="-mfpmath=sse -msse2 -mssse3" + ;; + 3dnow) + CPU_EXT="$CPU_EXT -m3dnow" + ;; + esac + done + CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" fi if test "x${CPU_TYPE}" = "xunknown"; then - CPU_TYPE=`( uname -p ) 2>&1` - case $CPU_TYPE in - i386) - CPU_OPTIONS="-march=i386" - ;; - i486) - CPU_OPTIONS="-march=i486" - ;; - Pentium2) - CPU_OPTIONS="-march=pentium2" - ;; - Pentiumpro) - CPU_OPTIONS="-march=pentiumpro" - ;; - Pentium*) - CPU_OPTIONS="-march=pentium" - ;; - k6) - CPU_OPTIONS="-march=k6" - ;; - k6-2) - CPU_OPTIONS="-march=k6-2" - ;; - k6-3) - CPU_OPTIONS="-march=k6-3" - ;; - "VIA C3 Ezra") - CPU_OPTIONS="-march=c3" - CPU_TYPE="known" + CPU_TYPE=`( uname -p ) 2>&1` + case $CPU_TYPE in + i386) + CPU_OPTIONS="-march=i386" + ;; + i486) + CPU_OPTIONS="-march=i486" + ;; + Pentium2) + CPU_OPTIONS="-march=pentium2" + ;; + Pentiumpro) + CPU_OPTIONS="-march=pentiumpro" + ;; + Pentium*) + CPU_OPTIONS="-march=pentium" + ;; + k6) + CPU_OPTIONS="-march=k6" + ;; + k6-2) + CPU_OPTIONS="-march=k6-2" + ;; + k6-3) + CPU_OPTIONS="-march=k6-3" + ;; + "VIA C3 Ezra") + CPU_OPTIONS="-march=c3" + CPU_TYPE="known" ;; - *) - CPU_OPTIONS="" - CPU_TYPE="unknown" - ;; - esac - if test "x${CPU_TYPE}" = "xunknown"; then - CPU_TYPE=`( uname -m ) 2>&1` - case $CPU_TYPE in - i386) - CPU_OPTIONS="-march=i386" - ;; - i486) - CPU_OPTIONS="-march=i486" - ;; - i586) - CPU_OPTIONS="-march=i586" - ;; - i686) - CPU_OPTIONS="-march=i686" - ;; - Pentium2) - CPU_OPTIONS="-march=pentium2" - ;; - Pentiumpro) - CPU_OPTIONS="-march=pentiumpro" - ;; - k6) - CPU_OPTIONS="-march=k6" - ;; - k6-2) - CPU_OPTIONS="-march=k6-2" - ;; - k6-3) - CPU_OPTIONS="-march=k6-3" - ;; - *) - CPU_OPTIONS="-march=native -mtune=native" - ;; - esac - fi + *) + CPU_OPTIONS="" + CPU_TYPE="unknown" + ;; + esac + if test "x${CPU_TYPE}" = "xunknown"; then + CPU_TYPE=`( uname -m ) 2>&1` + case $CPU_TYPE in + i386) + CPU_OPTIONS="-march=i386" + ;; + i486) + CPU_OPTIONS="-march=i486" + ;; + i586) + CPU_OPTIONS="-march=i586" + ;; + i686) + CPU_OPTIONS="-march=i686" + ;; + Pentium2) + CPU_OPTIONS="-march=pentium2" + ;; + Pentiumpro) + CPU_OPTIONS="-march=pentiumpro" + ;; + k6) + CPU_OPTIONS="-march=k6" + ;; + k6-2) + CPU_OPTIONS="-march=k6-2" + ;; + k6-3) + CPU_OPTIONS="-march=k6-3" + ;; + *) + CPU_OPTIONS="-march=native -mtune=native" + ;; + esac + fi fi echo "Detected CPU: $CPU_NAME" # Now we check if the compiler supports the detected cpu COMPILER=$CC for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do - test "$I" && break + test "$I" && break done TMPC="$I/cpu_test-$RANDOM-$$.c" TMPO="$I/cpu_test-$RANDOM-$$.o" @@ -1226,35 +1228,35 @@ rm -f $TMPC if test "x${TMP}" = "x1" ; then - CPU_OPTIONS="" - echo "No CPU optimizations will be added" + CPU_OPTIONS="" + echo "No CPU optimizations will be added" else - echo "CPU optimization: $CPU_OPTIONS" + echo "CPU optimization: $CPU_OPTIONS" fi else - CPU_OPTIONS="" + CPU_OPTIONS="" fi AC_MSG_CHECKING(for bswap instruction) AC_LINK_IFELSE([ - AC_LANG_PROGRAM([ ], - [unsigned int __x=0; - register unsigned int __v; - __asm("bswap %0" : "=r" (__v) : "0" (__x));]) - ], - [ - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_RESULT(no) - ]) + AC_LANG_PROGRAM([ ], + [unsigned int __x=0; + register unsigned int __v; + __asm("bswap %0" : "=r" (__v) : "0" (__x));]) + ], + [ + TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + ]) if test "${DEVELOPER_FLAGS}" = "yes"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" + TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" fi CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" @@ -1267,18 +1269,18 @@ LDFLAGS="${TEMP_LDFLAGS}" # Add the right exec path for rc scripts # if test $prefix = "NONE";then - BIN_PATH="$ac_default_prefix" - if test $exec_prefix = "NONE"; then - BIN_PATH="$BIN_PATH/bin" - else - BIN_PATH="$BIN_PATH/$bindir" - fi + BIN_PATH="$ac_default_prefix" + if test $exec_prefix = "NONE"; then + BIN_PATH="$BIN_PATH/bin" + else + BIN_PATH="$BIN_PATH/$bindir" + fi else - if test $exec_prefix = "NONE";then - BIN_PATH="$prefix/bin" - else - BIN_PATH="$prefix/$bindir" - fi + if test $exec_prefix = "NONE";then + BIN_PATH="$prefix/bin" + else + BIN_PATH="$prefix/$bindir" + fi fi @@ -1338,36 +1340,36 @@ else fi if test "${FreeBSD}" != ""; then - if test "${BKTR}" = "yes"; then + if test "${BKTR}" = "yes"; then echo "BKTR included: Yes" - else + else echo "BKTR included: No" - fi + fi - if test "${PWCBSD}" = "yes"; then + if test "${PWCBSD}" = "yes"; then echo "PWCBSD include: Yes" - else + else echo "PWCBSD include: No" - fi + fi else - if test "${V4L}" = "yes"; then + if test "${V4L}" = "yes"; then echo "V4L support: Yes" - else + else echo "V4L support: No" - fi + fi - if test x$SUPPORTED_V4L2 = xtrue; then + if test x$SUPPORTED_V4L2 = xtrue; then echo "V4L2 support: Yes" - else + else echo "V4L2 support: No" - fi + fi fi if test "${SDL_SUPPORT}" = "yes"; then - echo "SDL support: Yes" + echo "SDL support: Yes" else - echo "SDL support: No" + echo "SDL support: No" fi if test "${FFMPEG_OK}" = "found"; then From 72aef1fb65c8fe4cd1b040333e6ebb026a469aca Mon Sep 17 00:00:00 2001 From: jdodgen Date: Wed, 10 Jun 2015 14:50:38 -0700 Subject: [PATCH 111/233] Added ifdef around shared sqlite handle assignment --- motion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/motion.c b/motion.c index 5575bc4..a3fc70b 100644 --- a/motion.c +++ b/motion.c @@ -2737,9 +2737,11 @@ int main (int argc, char **argv) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Stream port %d", cnt_list[i]->conf.stream_port); +#ifdef HAVE_SQLITE /* this is done to share the seralized handle - * and supress creation of new handles in the threads */ + * and supress creation of new handles in the threads */ cnt_list[i]->database_sqlite3=cnt_list[0]->database_sqlite3; +#endif start_motion_thread(cnt_list[i], &thread_attr); } From 5eb3da40500c7bdb695913ee4f106049272043e5 Mon Sep 17 00:00:00 2001 From: jdodgen Date: Fri, 21 Aug 2015 09:25:51 -0700 Subject: [PATCH 112/233] Fixed mull pointer causing segfault --- motion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion.c b/motion.c index a3fc70b..07780a6 100644 --- a/motion.c +++ b/motion.c @@ -2653,7 +2653,7 @@ int main (int argc, char **argv) /* database_sqlite3 == NULL if not changed causes each thread to creat their own * sqlite3 connection this will only happens when using a non-threaded sqlite version */ cnt_list[0]->database_sqlite3=NULL; - if ((!strcmp(cnt_list[0]->conf.database_type, "sqlite3")) && cnt_list[0]->conf.sqlite3_db) { + if (cnt_list[0]->conf.database_type && ((!strcmp(cnt_list[0]->conf.database_type, "sqlite3")) && cnt_list[0]->conf.sqlite3_db)) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 Database filename %s", cnt_list[0]->conf.sqlite3_db); From cf88e025ab2dc2db139f3276f5c2fb2a0620b54f Mon Sep 17 00:00:00 2001 From: David Fries Date: Sat, 3 Nov 2012 15:49:25 -0500 Subject: [PATCH 113/233] typo fix, unused variable cleanup, etc motion.c bad spelling, to "an image" webhttpd.c consolidate the timeout to the top of the file as I needed to change it for testing --- jpegutils.c | 2 +- motion.c | 4 ++-- webhttpd.c | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jpegutils.c b/jpegutils.c index 8998034..7447c9d 100644 --- a/jpegutils.c +++ b/jpegutils.c @@ -818,7 +818,7 @@ int decode_jpeg_gray_raw(unsigned char *jpeg_data, int len, guarantee_huff_tables(&dinfo); jpeg_start_decompress (&dinfo); - vsf[0]= 1; vsf[1] = 1; vsf[2] = 1; + vsf[0] = 1; vsf[1] = 1; vsf[2] = 1; /* Height match image height or be exact twice the image height. */ diff --git a/motion.c b/motion.c index 072a835..9b88b43 100644 --- a/motion.c +++ b/motion.c @@ -174,7 +174,7 @@ static void image_ring_destroy(struct context *cnt) /** * image_save_as_preview * - * This routine is called when we detect motion and want to save a image in the preview buffer + * This routine is called when we detect motion and want to save an image in the preview buffer * * Parameters: * @@ -2728,7 +2728,7 @@ int main (int argc, char **argv) SLEEP(1, 0); /* - * Calculate how many threads runnig or wants to run + * Calculate how many threads are running or wants to run * if zero and we want to finish, break out */ int motion_threads_running = 0; diff --git a/webhttpd.c b/webhttpd.c index 2b3a133..d228e12 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -16,6 +16,9 @@ #include #include +/* Timeout in seconds, used for read and write */ +const int NONBLOCK_TIMEOUT = 1; + pthread_mutex_t httpd_mutex; // This is a dummy variable use to kill warnings when not checking sscanf and similar functions @@ -197,7 +200,7 @@ static ssize_t write_nonblock(int fd, const void *buf, size_t size) struct timeval tm; fd_set fds; - tm.tv_sec = 1; /* Timeout in seconds */ + tm.tv_sec = NONBLOCK_TIMEOUT; tm.tv_usec = 0; FD_ZERO(&fds); FD_SET(fd, &fds); @@ -223,7 +226,7 @@ static ssize_t read_nonblock(int fd ,void *buf, ssize_t size) struct timeval tm; fd_set fds; - tm.tv_sec = 1; /* Timeout in seconds */ + tm.tv_sec = NONBLOCK_TIMEOUT; /* Timeout in seconds */ tm.tv_usec = 0; FD_ZERO(&fds); FD_SET(fd, &fds); @@ -2509,7 +2512,7 @@ void httpd_run(struct context **cnt) while ((client_sent_quit_message) && (!closehttpd)) { - client_socket_fd = acceptnonblocking(sd, 1); + client_socket_fd = acceptnonblocking(sd, NONBLOCK_TIMEOUT); if (client_socket_fd < 0) { if ((!cnt[0]) || (cnt[0]->finish)) { From 23d6354d53708cb9ecdde54a80c1bfbd715f539e Mon Sep 17 00:00:00 2001 From: David Fries Date: Sun, 23 Aug 2015 06:53:47 -0500 Subject: [PATCH 114/233] ftp_send_type send type like the function comment says The function comment says it will send 'I' or 'A', but it was only sending 'I', even though the function did everything, but put it in the snprintf (which could be skipped for a fixed string). --- netcam_ftp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/netcam_ftp.c b/netcam_ftp.c index a6533c1..401ccfa 100644 --- a/netcam_ftp.c +++ b/netcam_ftp.c @@ -784,12 +784,11 @@ int ftp_get_socket(ftp_context_pointer ctxt) */ int ftp_send_type(ftp_context_pointer ctxt, char type) { - char buf[100]; + char buf[100], utype; int len, res; - toupper(type); - /* Assure transfer will be in "image" mode. */ - snprintf(buf, sizeof(buf), "TYPE I\r\n"); + utype = toupper(type); + snprintf(buf, sizeof(buf), "TYPE %c\r\n", utype); len = strlen(buf); res = send(ctxt->control_file_desc, buf, len, 0); From 0629d9db616552b97e349402ef4ba504b9eef1be Mon Sep 17 00:00:00 2001 From: David Fries Date: Thu, 8 Nov 2012 22:26:17 -0600 Subject: [PATCH 115/233] set motion capture thread running in the main thread I identified this while debugging, the thread was created, but hadn't yet set its state to running before the main thread checked the running variable and started another thread for the same device. That resulted in a crash. Set running in the main thread, to avoid this race condition. --- motion.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/motion.c b/motion.c index 9b88b43..f655c72 100644 --- a/motion.c +++ b/motion.c @@ -1088,8 +1088,6 @@ static void *motion_loop(void *arg) */ unsigned long int time_last_frame = 1, time_current_frame; - cnt->running = 1; - if (motion_init(cnt) < 0) goto err; @@ -2595,11 +2593,22 @@ static void start_motion_thread(struct context *cnt, pthread_attr_t *thread_attr /* Give the thread WATCHDOG_TMO to start */ cnt->watchdog = WATCHDOG_TMO; + /* Flag it as running outside of the thread, otherwise if the main loop + * checked if it is was running before the thread set it to 1, it would + * start another thread for this device. */ + cnt->running = 1; + /* * Create the actual thread. Use 'motion_loop' as the thread * function. */ - pthread_create(&cnt->thread_id, thread_attr, &motion_loop, cnt); + if (pthread_create(&cnt->thread_id, thread_attr, &motion_loop, cnt)) { + /* thread create failed, undo running state */ + cnt->running = 0; + pthread_mutex_lock(&global_lock); + threads_running--; + pthread_mutex_unlock(&global_lock); + } } /** From bab15abfee844dd6eec33cb56eaa749fca06cd07 Mon Sep 17 00:00:00 2001 From: David Fries Date: Thu, 8 Nov 2012 23:14:29 -0600 Subject: [PATCH 116/233] count webcontrol as a thread to avoid a crash On a SIGHUP restart the main thread waits to restart until all worker threads are finished executing, except webcontrol wasn't included. If it was still running (such as reading a web request), it would have a dangling context pointer after cnt_list was freed leading to a crash. This counts that thread in the running threads, as a termination webcontrol_finish variable to terminate it indepdent of the device thread, and creates a webcontrol_running to identify when it is running. --- CHANGELOG | 1 + CREDITS | 3 +++ motion.c | 23 ++++++++++++++++++++--- motion.h | 3 +++ webhttpd.c | 13 ++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 10d2955..3cd8860 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -143,6 +143,7 @@ Bugfixes * Fixed leak in vloopback. * Fixed a build of motion for some kernel version with not good videodev.h * Netcam Modulo 8 + * Fix webhttpd race condition crash with SIGHUP, add it to running thread counter (David Fries) 3.2.12 Summary of Changes diff --git a/CREDITS b/CREDITS index 89390a7..d21549b 100644 --- a/CREDITS +++ b/CREDITS @@ -473,6 +473,9 @@ Mark Feenstra Miguel Freitas * Came up with the round robing idea. +David Fries + * Fix webhttpd race condition crash with SIGHUP, add it to running thread counter + Aaron Gage * Pointed me to the vid_mmap/int problem when calling SYNC in video.c diff --git a/motion.c b/motion.c index f655c72..099e0dd 100644 --- a/motion.c +++ b/motion.c @@ -341,6 +341,7 @@ static void sig_handler(int signo) while (cnt_list[++i]) { cnt_list[i]->makemovie = 1; cnt_list[i]->finish = 1; + cnt_list[i]->webcontrol_finish = 1; /* * Don't restart thread when it ends, * all threads restarts if global restart is set @@ -2723,8 +2724,21 @@ int main (int argc, char **argv) * Create a thread for the control interface if requested. Create it * detached and with 'motion_web_control' as the thread function. */ - if (cnt_list[0]->conf.webcontrol_port) - pthread_create(&thread_id, &thread_attr, &motion_web_control, cnt_list); + if (cnt_list[0]->conf.webcontrol_port) { + pthread_mutex_lock(&global_lock); + threads_running++; + /* set outside the loop to avoid thread set vs main thread check */ + cnt_list[0]->webcontrol_running = 1; + pthread_mutex_unlock(&global_lock); + if (pthread_create(&thread_id, &thread_attr, &motion_web_control, + cnt_list)) { + /* thread create failed, undo running state */ + pthread_mutex_lock(&global_lock); + threads_running--; + cnt_list[0]->webcontrol_running = 0; + pthread_mutex_unlock(&global_lock); + } + } MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Waiting for threads to finish, pid: %d", getpid()); @@ -2746,6 +2760,9 @@ int main (int argc, char **argv) if (cnt_list[i]->running || cnt_list[i]->restart) motion_threads_running++; } + if (cnt_list[0]->conf.webcontrol_port && + cnt_list[0]->webcontrol_running) + motion_threads_running++; if (((motion_threads_running == 0) && finish) || ((motion_threads_running == 0) && (threads_running == 0))) { @@ -2805,7 +2822,7 @@ int main (int argc, char **argv) // Be sure that http control exits fine - cnt_list[0]->finish = 1; + cnt_list[0]->webcontrol_finish = 1; SLEEP(1, 0); MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Motion terminating"); diff --git a/motion.h b/motion.h index c08d84f..567feac 100644 --- a/motion.h +++ b/motion.h @@ -370,6 +370,9 @@ struct context { volatile unsigned int restart; /* Restart the thread when it ends */ /* Is the motion thread running */ volatile unsigned int running; + /* Is the web control thread running */ + volatile unsigned int webcontrol_running; + volatile unsigned int webcontrol_finish; /* End the thread */ volatile int watchdog; pthread_t thread_id; diff --git a/webhttpd.c b/webhttpd.c index d228e12..3693ae8 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2515,7 +2515,7 @@ void httpd_run(struct context **cnt) client_socket_fd = acceptnonblocking(sd, NONBLOCK_TIMEOUT); if (client_socket_fd < 0) { - if ((!cnt[0]) || (cnt[0]->finish)) { + if ((!cnt[0]) || (cnt[0]->webcontrol_finish)) { MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd - Finishing"); closehttpd = 1; } @@ -2545,6 +2545,17 @@ void *motion_web_control(void *arg) { struct context **cnt = arg; httpd_run(cnt); + + /* + * Update how many threads we have running. This is done within a + * mutex lock to prevent multiple simultaneous updates to + * 'threads_running'. + */ + pthread_mutex_lock(&global_lock); + threads_running--; + cnt[0]->webcontrol_running = 0; + pthread_mutex_unlock(&global_lock); + MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO, "%s: motion-httpd thread exit"); pthread_exit(NULL); } From bbd2f3f81393e5f8530c6b1e7c0302bfd3516d7b Mon Sep 17 00:00:00 2001 From: David Fries Date: Thu, 14 Aug 2014 20:43:19 -0500 Subject: [PATCH 117/233] redo watchdog termination logic, wait for the thread to cleanup I apparently have some marginal USB hardware and motion has been crashing every couple of days in the memcpy at the end of alg.c as both cnt->imgs.ref and cnt->imgs.image_virgin were NULL pointers. This was just after the main thread watchdog timer called pthread_cancel on that thread. The problem is pthread_cancel can't possibly kill a thread running on another CPU atomically, although in this case it's a single core processor and I think pthread_cancel was releasing it from the ioctl and it would then run to completition. This modifies the code to not cleanup that content's resources until that thread is no longer running. If it runs to completition a normal restart will happen, if it doesn't the main thread will check once a second until it no longer is running, cleanup and restart, but it can't cleanup with that thread running. --- motion.c | 47 +++++++++++++++++++++++++++++++---------------- motion.h | 1 + 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/motion.c b/motion.c index 099e0dd..a99e131 100644 --- a/motion.c +++ b/motion.c @@ -2780,24 +2780,39 @@ int main (int argc, char **argv) } if (cnt_list[i]->watchdog > WATCHDOG_OFF) { - cnt_list[i]->watchdog--; + if (cnt_list[i]->watchdog == WATCHDOG_KILL) { + /* if 0 then it finally did clean up (and will restart without any further action here) + * kill(, 0) == ESRCH means the thread is no longer running + * if it is no longer running with running set, then cleanup here so it can restart + */ + if(cnt_list[i]->running && pthread_kill(cnt_list[i]->thread_id, 0) == ESRCH) { + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: cleaning Thread %d", cnt_list[i]->threadnr); + pthread_mutex_lock(&global_lock); + threads_running--; + pthread_mutex_unlock(&global_lock); + motion_cleanup(cnt_list[i]); + cnt_list[i]->running = 0; + cnt_list[i]->finish = 0; + } + } else { + cnt_list[i]->watchdog--; - if (cnt_list[i]->watchdog == 0) { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, trying to do " - "a graceful restart", cnt_list[i]->threadnr); - cnt_list[i]->finish = 1; - } - if (cnt_list[i]->watchdog == -60) { - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, did NOT restart graceful," - "killing it!", cnt_list[i]->threadnr); - pthread_cancel(cnt_list[i]->thread_id); - pthread_mutex_lock(&global_lock); - threads_running--; - pthread_mutex_unlock(&global_lock); - motion_cleanup(cnt_list[i]); - cnt_list[i]->running = 0; - cnt_list[i]->finish = 0; + if (cnt_list[i]->watchdog == 0) { + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, trying to do " + "a graceful restart", cnt_list[i]->threadnr); + cnt_list[i]->finish = 1; + } + + if (cnt_list[i]->watchdog == WATCHDOG_KILL) { + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: Thread %d - Watchdog timeout, did NOT restart graceful," + "killing it!", cnt_list[i]->threadnr); + /* The problem is pthead_cancel might just wake up the thread so it runs to completition + * or it might not. In either case don't rip the carpet out under it by + * doing motion_cleanup until it no longer is running. + */ + pthread_cancel(cnt_list[i]->thread_id); + } } } } diff --git a/motion.h b/motion.h index 567feac..65d2698 100644 --- a/motion.h +++ b/motion.h @@ -149,6 +149,7 @@ */ #define WATCHDOG_TMO 30 /* 30 sec max motion_loop interval */ +#define WATCHDOG_KILL -60 /* -60 sec grace period before calling thread cancel */ #define WATCHDOG_OFF -127 /* Turn off watchdog, used when we wants to quit a thread */ #define CONNECTION_KO "Lost connection" From ea7e94863a12f4820a4d409109c9ed9b1e37cbfe Mon Sep 17 00:00:00 2001 From: David Fries Date: Sat, 16 Aug 2014 00:27:28 -0500 Subject: [PATCH 118/233] get the thread out of the xioctl loop As long as errno is EINTR (and that must be the case when the USB device is still there, but the transfers are failing), the thread keeps looping running the ioctl when it isn't going to succeed, so give it access to the finish variable to only loop if the thread isn't supposed to be going away, and then keep sendig SIGVTALRM to break out of the ioctl when the thread is supposed to be exiting. With this fix the webcam was no longer crashing, which let the webcam without a problem continue to stream. --- motion.c | 10 ++++++++++ video2.c | 58 +++++++++++++++++++++++++++++--------------------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/motion.c b/motion.c index a99e131..e21f8bf 100644 --- a/motion.c +++ b/motion.c @@ -357,6 +357,9 @@ static void sig_handler(int signo) break; case SIGSEGV: exit(0); + case SIGVTALRM: + printf("SIGVTALRM went off\n"); + break; } } @@ -2525,6 +2528,10 @@ static void setup_signals(struct sigaction *sig_handler_action, struct sigaction sigaction(SIGQUIT, sig_handler_action, NULL); sigaction(SIGTERM, sig_handler_action, NULL); sigaction(SIGUSR1, sig_handler_action, NULL); + + /* use SIGVTALRM as a way to break out of the ioctl, don't restart */ + sig_handler_action->sa_flags = 0; + sigaction(SIGVTALRM, sig_handler_action, NULL); } /** @@ -2793,6 +2800,9 @@ int main (int argc, char **argv) motion_cleanup(cnt_list[i]); cnt_list[i]->running = 0; cnt_list[i]->finish = 0; + } else { + /* keep sending signals so it doesn't get stuck in a blocking call */ + pthread_kill(cnt_list[i]->thread_id, SIGVTALRM); } } else { cnt_list[i]->watchdog--; diff --git a/video2.c b/video2.c index e1a617a..714fcc8 100644 --- a/video2.c +++ b/video2.c @@ -173,6 +173,7 @@ typedef struct { u32 ctrl_flags; struct v4l2_queryctrl *controls; + volatile unsigned int *finish; /* End the thread */ } src_v4l2_t; @@ -180,16 +181,16 @@ typedef struct { * xioctl */ #ifdef __OpenBSD__ -static int xioctl(int fd, unsigned long request, void *arg) +static int xioctl(src_v4l2_t *vid_source, unsigned long request, void *arg) #else -static int xioctl(int fd, int request, void *arg) +static int xioctl(src_v4l2_t *vid_source, int request, void *arg) #endif { int ret; do - ret = ioctl(fd, request, arg); - while (-1 == ret && EINTR == errno); + ret = ioctl(vid_source->fd, request, arg); + while (-1 == ret && EINTR == errno && !vid_source->finish); return ret; } @@ -199,7 +200,7 @@ static int xioctl(int fd, int request, void *arg) */ static int v4l2_get_capability(src_v4l2_t * vid_source) { - if (xioctl(vid_source->fd, VIDIOC_QUERYCAP, &vid_source->cap) < 0) { + if (xioctl(vid_source, VIDIOC_QUERYCAP, &vid_source->cap) < 0) { MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: Not a V4L2 device?"); return -1; } @@ -262,7 +263,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, input.index = IN_TV; else input.index = in; - if (xioctl(vid_source->fd, VIDIOC_ENUMINPUT, &input) == -1) { + if (xioctl(vid_source, VIDIOC_ENUMINPUT, &input) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Unable to query input %d." " VIDIOC_ENUMINPUT, if you use a WEBCAM change input value in conf by -1", input.index); @@ -278,7 +279,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, if (input.type & V4L2_INPUT_TYPE_CAMERA) MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - CAMERA"); - if (xioctl(vid_source->fd, VIDIOC_S_INPUT, &input.index) == -1) { + if (xioctl(vid_source, VIDIOC_S_INPUT, &input.index) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error selecting input %d" " VIDIOC_S_INPUT", input.index); return -1; @@ -290,7 +291,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, * Set video standard usually webcams doesn't support the ioctl or * return V4L2_STD_UNKNOWN */ - if (xioctl(vid_source->fd, VIDIOC_G_STD, &std_id) == -1) { + if (xioctl(vid_source, VIDIOC_G_STD, &std_id) == -1) { MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: Device doesn't support VIDIOC_G_STD"); norm = std_id = 0; // V4L2_STD_UNKNOWN = 0 } @@ -299,7 +300,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, memset(&standard, 0, sizeof(standard)); standard.index = 0; - while (xioctl(vid_source->fd, VIDIOC_ENUMSTD, &standard) == 0) { + while (xioctl(vid_source, VIDIOC_ENUMSTD, &standard) == 0) { if (standard.id & std_id) MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: - video standard %s", standard.name); @@ -318,7 +319,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, std_id = V4L2_STD_PAL; } - if (xioctl(vid_source->fd, VIDIOC_S_STD, &std_id) == -1) + if (xioctl(vid_source, VIDIOC_S_STD, &std_id) == -1) MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error selecting standard" " method %d VIDIOC_S_STD", (int)std_id); @@ -338,7 +339,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, memset(&tuner, 0, sizeof(struct v4l2_tuner)); tuner.index = input.tuner; - if (xioctl(vid_source->fd, VIDIOC_G_TUNER, &tuner) == -1) { + if (xioctl(vid_source, VIDIOC_G_TUNER, &tuner) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: tuner %d VIDIOC_G_TUNER", tuner.index); return 0; @@ -353,7 +354,7 @@ static int v4l2_select_input(struct config *conf, struct video_dev *viddev, freq.type = V4L2_TUNER_ANALOG_TV; freq.frequency = (freq_ / 1000) * 16; - if (xioctl(vid_source->fd, VIDIOC_S_FREQUENCY, &freq) == -1) { + if (xioctl(vid_source, VIDIOC_S_FREQUENCY, &freq) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: freq %ul VIDIOC_S_FREQUENCY", freq.frequency); return 0; @@ -405,7 +406,7 @@ static int v4l2_do_set_pix_format(u32 pixformat, src_v4l2_t * vid_source, vid_source->dst_fmt.fmt.pix.pixelformat = pixformat; vid_source->dst_fmt.fmt.pix.field = V4L2_FIELD_ANY; - if (xioctl(vid_source->fd, VIDIOC_TRY_FMT, &vid_source->dst_fmt) != -1 && + if (xioctl(vid_source, VIDIOC_TRY_FMT, &vid_source->dst_fmt) != -1 && vid_source->dst_fmt.fmt.pix.pixelformat == pixformat) { MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Testing palette %c%c%c%c (%dx%d)", pixformat >> 0, pixformat >> 8, @@ -423,7 +424,7 @@ static int v4l2_do_set_pix_format(u32 pixformat, src_v4l2_t * vid_source, *height = vid_source->dst_fmt.fmt.pix.height; } - if (xioctl(vid_source->fd, VIDIOC_S_FMT, &vid_source->dst_fmt) == -1) { + if (xioctl(vid_source, VIDIOC_S_FMT, &vid_source->dst_fmt) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error setting pixel " "format.\nVIDIOC_S_FMT: "); return -1; @@ -502,7 +503,7 @@ static int v4l2_set_pix_format(struct context *cnt, src_v4l2_t * vid_source, MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: Supported palettes:"); - while (xioctl(vid_source->fd, VIDIOC_ENUM_FMT, &fmtd) != -1) { + while (xioctl(vid_source, VIDIOC_ENUM_FMT, &fmtd) != -1) { int i; @@ -556,7 +557,7 @@ static void v4l2_set_fps(src_v4l2_t * vid_source) { setfpvid_source->parm.capture.timeperframe.numerator = 1; setfpvid_source->parm.capture.timeperframe.denominator = vid_source->fps; - if (xioctl(vid_source->fd, VIDIOC_S_PARM, setfps) == -1) + if (xioctl(vid_source, VIDIOC_S_PARM, setfps) == -1) MOTION_LOG(ERR, 1, "%s: v4l2_set_fps VIDIOC_S_PARM"); @@ -581,7 +582,7 @@ static int v4l2_set_mmap(src_v4l2_t * vid_source) vid_source->req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vid_source->req.memory = V4L2_MEMORY_MMAP; - if (xioctl(vid_source->fd, VIDIOC_REQBUFS, &vid_source->req) == -1) { + if (xioctl(vid_source, VIDIOC_REQBUFS, &vid_source->req) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error requesting buffers" " %d for memory map. VIDIOC_REQBUFS", vid_source->req.count); @@ -613,7 +614,7 @@ static int v4l2_set_mmap(src_v4l2_t * vid_source) buf.memory = V4L2_MEMORY_MMAP; buf.index = buffer_index; - if (xioctl(vid_source->fd, VIDIOC_QUERYBUF, &buf) == -1) { + if (xioctl(vid_source, VIDIOC_QUERYBUF, &buf) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error querying buffer" " %i\nVIDIOC_QUERYBUF: ", buffer_index); free(vid_source->buffers); @@ -642,7 +643,7 @@ static int v4l2_set_mmap(src_v4l2_t * vid_source) vid_source->buf.memory = V4L2_MEMORY_MMAP; vid_source->buf.index = buffer_index; - if (xioctl(vid_source->fd, VIDIOC_QBUF, &vid_source->buf) == -1) { + if (xioctl(vid_source, VIDIOC_QBUF, &vid_source->buf) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_QBUF"); return -1; } @@ -650,7 +651,7 @@ static int v4l2_set_mmap(src_v4l2_t * vid_source) type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (xioctl(vid_source->fd, VIDIOC_STREAMON, &type) == -1) { + if (xioctl(vid_source, VIDIOC_STREAMON, &type) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: Error starting stream." " VIDIOC_STREAMON"); return -1; @@ -671,7 +672,7 @@ static int v4l2_scan_controls(src_v4l2_t * vid_source) for (i = 0, count = 0; queried_ctrls[i]; i++) { queryctrl.id = queried_ctrls[i]; - if (xioctl(vid_source->fd, VIDIOC_QUERYCTRL, &queryctrl)) + if (xioctl(vid_source, VIDIOC_QUERYCTRL, &queryctrl)) continue; count++; @@ -692,7 +693,7 @@ static int v4l2_scan_controls(src_v4l2_t * vid_source) struct v4l2_control control; queryctrl.id = queried_ctrls[i]; - if (xioctl(vid_source->fd, VIDIOC_QUERYCTRL, &queryctrl)) + if (xioctl(vid_source, VIDIOC_QUERYCTRL, &queryctrl)) continue; memcpy(ctrl, &queryctrl, sizeof(struct v4l2_queryctrl)); @@ -704,7 +705,7 @@ static int v4l2_scan_controls(src_v4l2_t * vid_source) memset(&control, 0, sizeof (control)); control.id = queried_ctrls[i]; - xioctl(vid_source->fd, VIDIOC_G_CTRL, &control); + xioctl(vid_source, VIDIOC_G_CTRL, &control); MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s: \t\"%s\", default %d, current %d", ctrl->name, ctrl->default_value, control.value); @@ -740,12 +741,12 @@ static int v4l2_set_control(src_v4l2_t * vid_source, u32 cid, int value) case V4L2_CTRL_TYPE_INTEGER: value = control.value = (value * (ctrl->maximum - ctrl->minimum) / 256) + ctrl->minimum; - ret = xioctl(vid_source->fd, VIDIOC_S_CTRL, &control); + ret = xioctl(vid_source, VIDIOC_S_CTRL, &control); break; case V4L2_CTRL_TYPE_BOOLEAN: value = control.value = value ? 1 : 0; - ret = xioctl(vid_source->fd, VIDIOC_S_CTRL, &control); + ret = xioctl(vid_source, VIDIOC_S_CTRL, &control); break; default: @@ -822,6 +823,7 @@ unsigned char *v4l2_start(struct context *cnt, struct video_dev *viddev, int wid vid_source->fd = viddev->fd; vid_source->fps = cnt->conf.frame_limit; vid_source->pframe = -1; + vid_source->finish = &cnt->finish; struct config *conf = &cnt->conf; if (v4l2_get_capability(vid_source)) @@ -965,7 +967,7 @@ int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, vid_source->pframe); if (vid_source->pframe >= 0) { - if (xioctl(vid_source->fd, VIDIOC_QBUF, &vid_source->buf) == -1) { + if (xioctl(vid_source, VIDIOC_QBUF, &vid_source->buf) == -1) { MOTION_LOG(ERR, TYPE_VIDEO, SHOW_ERRNO, "%s: VIDIOC_QBUF"); pthread_sigmask(SIG_UNBLOCK, &old, NULL); return -1; @@ -977,7 +979,7 @@ int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, vid_source->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vid_source->buf.memory = V4L2_MEMORY_MMAP; - if (xioctl(vid_source->fd, VIDIOC_DQBUF, &vid_source->buf) == -1) { + if (xioctl(vid_source, VIDIOC_DQBUF, &vid_source->buf) == -1) { int ret; /* * Some drivers return EIO when there is no signal, @@ -1082,7 +1084,7 @@ void v4l2_close(struct video_dev *viddev) enum v4l2_buf_type type; type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - xioctl(vid_source->fd, VIDIOC_STREAMOFF, &type); + xioctl(vid_source, VIDIOC_STREAMOFF, &type); close(vid_source->fd); vid_source->fd = -1; } From 37360d858d629d0de398930639cbdd8a089bfafa Mon Sep 17 00:00:00 2001 From: David Fries Date: Sat, 23 Aug 2014 14:04:22 -0500 Subject: [PATCH 119/233] fix dangling pointer cnt->current_image after resize cnt->current_image because a dangling pointer after image_ring_resize because it is pointing to cnt->imgs.image_ring which is reallocated in that routine. motion_loop will then store cnt->current_image in old_image which it can then read from. Reallocations are rare, once in init to size 1, then once to the final size. I apparently have a bad USB link and I was seeing a crash pointing to bad data, after that camera started, then had an error and crashed in process_image_ring(cnt, IMAGE_BUFFER_FLUSH); it hadn't yet resized to the normal ring buffer size. That got me trying valgrind with a ring buffer size limit of 1 which found this bug. --- motion.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/motion.c b/motion.c index e21f8bf..852c5a9 100644 --- a/motion.c +++ b/motion.c @@ -134,6 +134,7 @@ static void image_ring_resize(struct context *cnt, int new_size) /* Point to the new ring */ cnt->imgs.image_ring = tmp; + cnt->current_image = NULL; cnt->imgs.image_ring_size = new_size; } @@ -168,6 +169,7 @@ static void image_ring_destroy(struct context *cnt) free(cnt->imgs.image_ring); cnt->imgs.image_ring = NULL; + cnt->current_image = NULL; cnt->imgs.image_ring_size = 0; } From 740f3cc73f919d3228dfbaf526084ec95f8a370f Mon Sep 17 00:00:00 2001 From: David Fries Date: Mon, 28 Jul 2014 23:27:53 -0500 Subject: [PATCH 120/233] alg_labeling give diffs feedback even when not over the threshold This is especially useful when picking a threshold to see how close to the threshold it was. --- alg.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/alg.c b/alg.c index 343ff47..226ebd7 100644 --- a/alg.c +++ b/alg.c @@ -526,6 +526,8 @@ static int alg_labeling(struct context *cnt) int height = imgs->height; int labelsize = 0; int current_label = 2; + /* Keep track of the area just under the threshold. */ + int max_under = 0; cnt->current_image->total_labels = 0; imgs->labelsize_max = 0; @@ -561,7 +563,8 @@ static int alg_labeling(struct context *cnt) labelsize = iflood(ix, iy, width, height, out, labels, current_label + 32768, current_label); imgs->labelgroup_max += labelsize; imgs->labels_above++; - } + } else if(max_under < labelsize) + max_under = labelsize; if (imgs->labelsize_max < labelsize) { imgs->labelsize_max = labelsize; @@ -579,8 +582,11 @@ static int alg_labeling(struct context *cnt) "Largest Label: %i", imgs->largest_label, imgs->labelsize_max, cnt->current_image->total_labels); - /* Return group of significant labels. */ - return imgs->labelgroup_max; + /* Return group of significant labels or if that's none, the next largest + * group (which is under the threshold, but especially for setup gives an + * idea how close it was). + */ + return imgs->labelgroup_max ? imgs->labelgroup_max : max_under; } /** From a3104af8d0deef28c7a97f152ddfb62b8256e9a1 Mon Sep 17 00:00:00 2001 From: David Fries Date: Thu, 8 Nov 2012 23:59:32 -0600 Subject: [PATCH 121/233] accept a width specifier to mystrftime Allow the user to specify field widths to keep the strings from jumping around as the width changes. This makes the values easier to read. --- CHANGELOG | 1 + CREDITS | 1 + motion.c | 46 +++++++++++++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3cd8860..a898754 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -85,6 +85,7 @@ Features * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) + * Allow text format specifiers to take a width like printf would. (David Fries) * Resolve additional compiler warnings in ffmpeg (Mr-Dave) * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) diff --git a/CREDITS b/CREDITS index d21549b..a656adb 100644 --- a/CREDITS +++ b/CREDITS @@ -475,6 +475,7 @@ Miguel Freitas David Fries * Fix webhttpd race condition crash with SIGHUP, add it to running thread counter + * Allow text format specifiers to take a width like printf would. Aaron Gage * Pointed me to the vid_mmap/int problem when calling SYNC in diff --git a/motion.c b/motion.c index 852c5a9..bc66e4f 100644 --- a/motion.c +++ b/motion.c @@ -3151,6 +3151,7 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us char tempstring[PATH_MAX] = ""; char *format, *tempstr; const char *pos_userformat; + int width; format = formatstring; @@ -3170,6 +3171,12 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us */ tempstr = tempstring; tempstr[0] = '\0'; + width = 0; + while ('0' <= pos_userformat[1] && pos_userformat[1] <= '9') { + width *= 10; + width += pos_userformat[1] - '0'; + ++pos_userformat; + } switch (*++pos_userformat) { case '\0': // end of string @@ -3177,81 +3184,86 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us break; case 'v': // event - sprintf(tempstr, "%02d", cnt->event_nr); + sprintf(tempstr, "%0*d", width ? width : 2, cnt->event_nr); break; case 'q': // shots - sprintf(tempstr, "%02d", cnt->current_image->shot); + sprintf(tempstr, "%0*d", width ? width : 2, + cnt->current_image->shot); break; case 'D': // diffs - sprintf(tempstr, "%d", cnt->current_image->diffs); + sprintf(tempstr, "%*d", width, cnt->current_image->diffs); break; case 'N': // noise - sprintf(tempstr, "%d", cnt->noise); + sprintf(tempstr, "%*d", width, cnt->noise); break; case 'i': // motion width - sprintf(tempstr, "%d", cnt->current_image->location.width); + sprintf(tempstr, "%*d", width, + cnt->current_image->location.width); break; case 'J': // motion height - sprintf(tempstr, "%d", cnt->current_image->location.height); + sprintf(tempstr, "%*d", width, + cnt->current_image->location.height); break; case 'K': // motion center x - sprintf(tempstr, "%d", cnt->current_image->location.x); + sprintf(tempstr, "%*d", width, cnt->current_image->location.x); break; case 'L': // motion center y - sprintf(tempstr, "%d", cnt->current_image->location.y); + sprintf(tempstr, "%*d", width, cnt->current_image->location.y); break; case 'o': // threshold - sprintf(tempstr, "%d", cnt->threshold); + sprintf(tempstr, "%*d", width, cnt->threshold); break; case 'Q': // number of labels - sprintf(tempstr, "%d", cnt->current_image->total_labels); + sprintf(tempstr, "%*d", width, + cnt->current_image->total_labels); break; case 't': // thread number - sprintf(tempstr, "%d",(int)(unsigned long) + sprintf(tempstr, "%*d", width, (int)(unsigned long) pthread_getspecific(tls_key_threadnr)); break; case 'C': // text_event if (cnt->text_event_string && cnt->text_event_string[0]) - snprintf(tempstr, PATH_MAX, "%s", cnt->text_event_string); + snprintf(tempstr, PATH_MAX, "%*s", width, + cnt->text_event_string); else ++pos_userformat; break; case 'w': // picture width - sprintf(tempstr, "%d", cnt->imgs.width); + sprintf(tempstr, "%*d", width, cnt->imgs.width); break; case 'h': // picture height - sprintf(tempstr, "%d", cnt->imgs.height); + sprintf(tempstr, "%*d", width, cnt->imgs.height); break; case 'f': // filename -- or %fps if ((*(pos_userformat+1) == 'p') && (*(pos_userformat+2) == 's')) { - sprintf(tempstr, "%d", cnt->movie_fps); + sprintf(tempstr, "%*d", width, cnt->movie_fps); pos_userformat += 2; break; } if (filename) - snprintf(tempstr, PATH_MAX, "%s", filename); + snprintf(tempstr, PATH_MAX, "%*s", width, filename); else ++pos_userformat; break; case 'n': // sqltype if (sqltype) - sprintf(tempstr, "%d", sqltype); + sprintf(tempstr, "%*d", width, sqltype); else ++pos_userformat; break; From 63e585dc7699247bab857b7d9d0761fbdf73e0c5 Mon Sep 17 00:00:00 2001 From: David Fries Date: Fri, 9 Nov 2012 23:54:12 -0600 Subject: [PATCH 122/233] add power_line_frequency configuration item The USB webcam I have defaults to the wrong setting causing visible flickering degrading the image quality. This allows setting the value to any of the currently available options or -1 to by default not modify the value. --- CHANGELOG | 2 ++ CREDITS | 1 + conf.c | 17 +++++++++++++++++ conf.h | 1 + video.h | 1 + video2.c | 19 +++++++++++++++++++ video_common.c | 2 ++ 7 files changed, 43 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a898754..2f8a77f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -86,6 +86,8 @@ Features * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) * Allow text format specifiers to take a width like printf would. (David Fries) + * Allow text format specifiers to take a width like printf would. (David Fries) + * Add power_line_frequency configuration item to improve image quality. (David Fries) * Resolve additional compiler warnings in ffmpeg (Mr-Dave) * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) diff --git a/CREDITS b/CREDITS index a656adb..02434b1 100644 --- a/CREDITS +++ b/CREDITS @@ -476,6 +476,7 @@ Miguel Freitas David Fries * Fix webhttpd race condition crash with SIGHUP, add it to running thread counter * Allow text format specifiers to take a width like printf would. + * Add power_line_frequency configuration item to improve image quality. Aaron Gage * Pointed me to the vid_mmap/int problem when calling SYNC in diff --git a/conf.c b/conf.c index ecac41b..c335bb2 100644 --- a/conf.c +++ b/conf.c @@ -71,6 +71,7 @@ struct config conf_template = { contrast: 0, saturation: 0, hue: 0, + power_line_frequency: -1, roundrobin_frames: 1, roundrobin_skip: 1, pre_capture: 0, @@ -470,6 +471,22 @@ config_param config_params[] = { print_int }, { + "power_line_frequency", + "# Set the power line frequency to help cancel flicker by compensating\n" + "# for light intensity ripple. (default: -1).\n" + "# This can help reduce power line light flicker.\n" + "# Valuse :\n" + "# do not modify the device setting : -1\n" + "# V4L2_CID_POWER_LINE_FREQUENCY_DISABLED : 0\n" + "# V4L2_CID_POWER_LINE_FREQUENCY_50HZ : 1\n" + "# V4L2_CID_POWER_LINE_FREQUENCY_60HZ : 2\n" + "# V4L2_CID_POWER_LINE_FREQUENCY_AUTO : 3", + 0, + CONF_OFFSET(power_line_frequency), + copy_int, + print_int + }, + { "roundrobin_frames", "\n############################################################\n" "# Round Robin (multiple inputs on same video device name)\n" diff --git a/conf.h b/conf.h index c487b9e..5046267 100644 --- a/conf.h +++ b/conf.h @@ -53,6 +53,7 @@ struct config { int contrast; int saturation; int hue; + int power_line_frequency; int roundrobin_frames; int roundrobin_skip; int pre_capture; diff --git a/video.h b/video.h index 193087b..1ac4553 100644 --- a/video.h +++ b/video.h @@ -65,6 +65,7 @@ struct video_dev { int contrast; int saturation; int hue; + int power_line_frequency; unsigned long freq; int tuner_number; int fps; diff --git a/video2.c b/video2.c index 714fcc8..bca7535 100644 --- a/video2.c +++ b/video2.c @@ -144,6 +144,10 @@ static const u32 queried_ctrls[] = { V4L2_CID_CONTRAST, V4L2_CID_SATURATION, V4L2_CID_HUE, +/* first added in Linux kernel v2.6.26 */ +#ifdef V4L2_CID_POWER_LINE_FREQUENCY + V4L2_CID_POWER_LINE_FREQUENCY, +#endif V4L2_CID_RED_BALANCE, V4L2_CID_BLUE_BALANCE, @@ -749,6 +753,13 @@ static int v4l2_set_control(src_v4l2_t * vid_source, u32 cid, int value) ret = xioctl(vid_source, VIDIOC_S_CTRL, &control); break; + case V4L2_CTRL_TYPE_MENU: + /* set as is, no adjustments */ + control.value = value; + ret = xioctl(vid_source, VIDIOC_S_CTRL, &control); + break; + + default: MOTION_LOG(WRN, TYPE_VIDEO, NO_ERRNO, "%s: control type not supported yet"); return -1; @@ -789,6 +800,14 @@ static void v4l2_picture_controls(struct context *cnt, struct video_dev *viddev) v4l2_set_control(vid_source, V4L2_CID_HUE, viddev->hue); } +#ifdef V4L2_CID_POWER_LINE_FREQUENCY + /* -1 is don't modify as 0 is an option to disable the power line filter */ + if (cnt->conf.power_line_frequency != -1 && cnt->conf.power_line_frequency != viddev->power_line_frequency) { + viddev->power_line_frequency = cnt->conf.power_line_frequency; + v4l2_set_control(vid_source, V4L2_CID_POWER_LINE_FREQUENCY, viddev->power_line_frequency); + } +#endif + if (cnt->conf.autobright) { if (vid_do_autobright(cnt, viddev)) { if (v4l2_set_control(vid_source, V4L2_CID_BRIGHTNESS, viddev->brightness)) diff --git a/video_common.c b/video_common.c index 54569c6..cabc5aa 100644 --- a/video_common.c +++ b/video_common.c @@ -732,6 +732,8 @@ static int vid_v4lx_start(struct context *cnt) dev->contrast = 0; dev->saturation = 0; dev->hue = 0; + /* -1 is don't modify, (0 is a valid value) */ + dev->power_line_frequency = -1; dev->owner = -1; dev->v4l_fmt = VIDEO_PALETTE_YUV420P; dev->fps = 0; From 12433edb3f24456961e8188cafa89856e039d854 Mon Sep 17 00:00:00 2001 From: David Fries Date: Sat, 5 Jan 2013 16:42:13 -0600 Subject: [PATCH 123/233] add ffmpeg_duplicate_frames option This lets the user decide which video problems they would rather see. In my case a Raspberry Pi 2 with a 640x480 webcam sometimes can keep up with 10fps so I don't want to set the framerate any lower, but then sometimes it can't and with duplicate frames it looks like the video output freezes every second. --- conf.c | 9 +++++++++ conf.h | 1 + motion.c | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index c335bb2..e2f1275 100644 --- a/conf.c +++ b/conf.c @@ -678,6 +678,15 @@ config_param config_params[] = { print_string }, { + "ffmpeg_duplicate_frames", + "# True to duplicate frames to achieve \"framerate\" fps, but enough\n" + "duplicated frames and the video appears to freeze once a second.", + 0, + CONF_OFFSET(ffmpeg_duplicate_frames), + copy_bool, + print_bool + }, + { "output_debug_pictures", "# Output pictures with only the pixels moving object (ghost images) (default: off)", 0, diff --git a/conf.h b/conf.h index 5046267..a6ad5c5 100644 --- a/conf.h +++ b/conf.h @@ -30,6 +30,7 @@ struct config { int max_changes; int threshold_tune; const char *output_pictures; + int ffmpeg_duplicate_frames; int motion_img; int emulate_motion; int event_gap; diff --git a/motion.c b/motion.c index bc66e4f..b3cdc77 100644 --- a/motion.c +++ b/motion.c @@ -571,8 +571,13 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) /* * Check if we must add any "filler" frames into movie to keep up fps * Only if we are recording videos ( ffmpeg or extenal pipe ) + * While the overall elapsed time might be correct, if there are + * many duplicated frames, say 10 fps, 5 duplicated, the video will + * look like it is frozen every second for half a second. */ - if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot == 0) && + if (!cnt->conf.ffmpeg_duplicate_frames) { + /* don't duplicate frames */ + } else if ((cnt->imgs.image_ring[cnt->imgs.image_ring_out].shot == 0) && #ifdef HAVE_FFMPEG (cnt->ffmpeg_output || (cnt->conf.useextpipe && cnt->extpipe))) { #else From 4750579af2bd95411053a1d9d431f3f1669ec802 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Wed, 26 Aug 2015 19:09:12 -0600 Subject: [PATCH 124/233] ffmpeg.c fix GOP size --- CHANGELOG | 5 ++++- ffmpeg.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e1a07ee..f3eb2dd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ -Summary of Changes +Summary of Changes + * Fix the GOP size for the created videos + * Fix netcam ftp functionality + * Fix Typo on the log level * Fixed the network ftp image option. * Lock thread on ffmpeg/libav init and open_codec * Revise version number generated by script to indicate Unofficial-Git-'hash' diff --git a/ffmpeg.c b/ffmpeg.c index febe41e..2c2505c 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -272,7 +272,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->height = height; c->time_base.num = 1; c->time_base.den = rate; - c->gop_size = 0; + c->gop_size = 12; c->pix_fmt = PIX_FMT_YUV420P; c->max_b_frames = 0; From e991c53bd63163e2a8475cef35aabe737f0f7c44 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Wed, 26 Aug 2015 21:13:15 -0600 Subject: [PATCH 125/233] Revision for clean build --- event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/event.c b/event.c index 1647631..0f77028 100644 --- a/event.c +++ b/event.c @@ -47,10 +47,13 @@ const char *eventList[] = { * * returns string label of the event */ + /** + * Future use debug / notification function static const char *eventToString(motion_event e) { return eventList[(int)e]; } +*/ /** * exec_command From f9a5d1cc5c65dad0673838f560905fe06bccc6f0 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Wed, 26 Aug 2015 21:18:49 -0600 Subject: [PATCH 126/233] Add the new options to motion-dist.conf --- CHANGELOG | 9 +++++---- motion-dist.conf.in | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5f54a2c..7184bf6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,9 @@ Summary of Changes + * Add new config options to the motion-dist.conf + * Allow text format specifiers to take a width like printf would. (David Fries) + * Allow text format specifiers to take a width like printf would. (David Fries) + * Add power_line_frequency configuration item to improve image quality. (David Fries) + * Fix webhttpd race condition crash with SIGHUP, add it to running thread counter (David Fries) * Fix the GOP size for the created videos * Fix netcam ftp functionality * Fix Typo on the log level @@ -89,9 +94,6 @@ Features * Bug fix as part of warnings in webhttpd.c fixed(Mr-Dave) * Removed compiler warning regarding ffmpeg being newer than 0.4 version(Mr-Dave) * New configure script and identification of ffmpeg version and additional libs. (Mr-Dave) - * Allow text format specifiers to take a width like printf would. (David Fries) - * Allow text format specifiers to take a width like printf would. (David Fries) - * Add power_line_frequency configuration item to improve image quality. (David Fries) * Resolve additional compiler warnings in ffmpeg (Mr-Dave) * Revised INSTALL with samples(Mr-Dave) * Revisions for RTSP and code standard.(Mr-Dave) @@ -150,7 +152,6 @@ Bugfixes * Fixed leak in vloopback. * Fixed a build of motion for some kernel version with not good videodev.h * Netcam Modulo 8 - * Fix webhttpd race condition crash with SIGHUP, add it to running thread counter (David Fries) 3.2.12 Summary of Changes diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 5f148d3..b83af87 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -83,6 +83,15 @@ norm 0 # The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) frequency 0 +# Override the power line frequency for the webcam. (normally not necessary) +# Values: +# -1 : Do not modify device setting +# 0 : Power line frequency Disabled +# 1 : 50hz +# 2 : 60hz +# 3 : Auto +power_line_frequency -1 + # Rotate image this number of degrees. The rotation affects all saved images as # well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. rotate 0 @@ -320,6 +329,11 @@ ffmpeg_video_codec mpeg4 # (default: off) ffmpeg_deinterlace off +# When creating videos, should frames be duplicated in order +# to keep up with the requested frames per second +# (default: true) +ffmpeg_duplicate_frames true + ############################################################ # SDL Window ############################################################ From c7fced79833bd7e3ffde119e3be9e6ee308f902c Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Wed, 26 Aug 2015 22:30:25 -0600 Subject: [PATCH 127/233] Revise install instructions --- .gitignore | 1 + INSTALL | 105 +- configure | 8199 ---------------------------------------------------- 3 files changed, 52 insertions(+), 8253 deletions(-) delete mode 100755 configure diff --git a/.gitignore b/.gitignore index b730f6e..6e536cb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ motion config.h config.status Makefile +configure motion-dist.conf motion.init-Debian motion.init-Fedora diff --git a/INSTALL b/INSTALL index 8773bff..3f79cae 100644 --- a/INSTALL +++ b/INSTALL @@ -1,61 +1,58 @@ -NOTE: Versions come, versions go, packages change, etc. These instructions are intended as a starting point - and may need modification by the time you read this. - -********************************** -*** DEBIAN BASED SYSTEMS *** - -Required Packages: - sudo apt-get install autoconf automake build-essential libtool libjpeg8-dev libzip-dev - -Obtain source code (via git) - sudo apt-get install git - cd ~ - git clone {https://github.com/your favorite fork} - -To rebuild the motion configure file use - autoreconf - -Optional: With FFMPEG support: - Build FFMPEG via their instructions - Configure with manually built ffmpeg which currently installs to ~/bin and ~/ffmpeg_build - Basic - ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include - - With extra libraries for ffmpeg IMPORTANT NOTE: Your libraries will vary depending upon your build of FFMPEG - ./configure --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " - - With extra libraries for ffmpeg and install to ~/motion_build - ./configure --prefix=$HOME/motion_build --with-ffmpeg=$HOME/ffmpeg_build --with-ffmpeg-headers=$HOME/ffmpeg_build/include --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " - -With LIBAV APT versions of libraries - sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libav-tools libswscale-dev - -Without any LIBAV/FFMPEG support or the installed version of libavcodec/libavformat +The following is a brief overview of the building and installing instructions. + +The building instructions vary based upon the base system and the desired options. +For most installs, it will be desired to include either ffmpeg or libav and these will +have associated dependencies which dictate the configuration options. + +Build Packages(apt): + autoconf + automake + libtool + libjpeg8-dev + build-essential + libzip-dev + +Build Packages(zypper) + autoconf + automake + libtool + libjpeg8-devel + -t pattern devel_basis + -t pattern devel_C_C++ + +The option to include FFMPEG or Libav functionality in motion is a choice of one OR the other not both. +The packages and library names change frequently and vary across base operating systems. If ffmpeg or +libav are built and installed from source the custom motion configuration options will usually be needed. + +FFMPEG Packages + ffmpeg + libavformat-dev + libavcodec-dev + libavutil-dev + libswscale-dev + +Libav Packages + libavformat-dev + libavcodec-dev + libavutil-dev + libav-tools + libswscale-dev + +Once required packages are installed, execute: + autoreconf -f ./configure - -Sample PI configuration with LIBAV - ./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf --with-ffmpeg-headers=/usr/include - - -Once configured type: make make install -***************************** -*** OpenSUSE SYSTEM *** +Sample custom configuration options: + --prefix : Specify the install location for the motion package + --with-ffmpeg : Specify the location in which ffmpeg/libav is installed. + --with-ffmpeg-headers : Specify the location for the ffmpeg/libav headers + --with-ffmpeg-libs : Specify the additional libraries for ffmpeg/libav -sudo zypper install autoconf automake libtool git -sudo zypper install --type pattern devel_basis -sudo zypper install libjpeg8-devel -sudo zypper install -t pattern devel_C_C++ +Sample additional libs that MAY be needed for ffmpeg/libav + -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm + -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc + -lvorbis -ltheoraenc -ltheoradec -Optional: FFmpeg files -sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials -sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia -sudo zypper install libffmpeg-devel - -./configure - make - make install -************************* diff --git a/configure b/configure deleted file mode 100755 index b4c4200..0000000 --- a/configure +++ /dev/null @@ -1,8199 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for motion Unofficial-Git-d71cebf. -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='motion' -PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Unofficial-Git-d71cebf' -PACKAGE_STRING='motion Unofficial-Git-d71cebf' -PACKAGE_BUGREPORT='' -PACKAGE_URL='' - -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_unique_file="motion.c" -ac_subst_vars='LTLIBOBJS -LIBOBJS -BIN_PATH -RTPS_OBJ -FFMPEG_OBJ -SDL_OBJ -VIDEO -EGREP -GREP -CPP -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -with_linuxthreads -with_pwcbsd -with_bktr -with_v4l -with_sdl -with_jpeg_turbo -with_jpeg_mmx -with_ffmpeg -with_ffmpeg_headers -with_ffmpeg_libs -with_sqlite3 -with_mysql -with_mysql_lib -with_mysql_include -with_pgsql -with_pgsql_lib -with_pgsql_include -with_optimizecpu -with_developer_flags -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -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 Unofficial-Git-d71cebf to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/motion] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of motion Unofficial-Git-d71cebf:";; - esac - cat <<\_ACEOF - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-linuxthreads Use linuxthreads in BSD instead of native pthreads - - - --with-pwcbsd Use pwcbsd based webcams ( only BSD ) - - - --without-bktr Exclude to use bktr subsystem , that usually useful - for devices as network cameras ( ONLY used in *BSD). - - - --without-v4l Exclude using v4l (video4linux) subsystem. - Makes Motion so it only supports network cameras. - - --without-sdl Compile without sdl support to get stream in SDL window. - - --with-jpeg-turbo=DIR Specify the prefix for the install path for - jpeg-turbo for optimized jpeg handling (optional). - - --with-jpeg-mmx=DIR Specify the prefix for the install path for - jpeg-mmx for optimized jpeg handling (optional). - If this is not specified motion will try to find - the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. - - --with-ffmpeg=DIR Specify the prefix for the install path for - libavcodec/libavformat (part of ffmpeg) be able to - encode mpeg movies realtime. - If this is not specified motion will try to find - the libraries in /usr and /usr/local. - - --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. - - --with-ffmpeg-libs=libs Specify the extra libs for ffmpeg - - --without-sqlite3 Disable sqlite3 support in motion. - - --without-mysql Disable mysql support in motion. - - --with-mysql-lib=DIR Normally, configure will scan all possible default - installation paths for mysql libs. When it fails, use - this command to tell configure where mysql libs - installation root directory is. - - --with-mysql-include=DIR Normally, configure will scan all possible default - installation paths for mysql include. When it fails, use - this command to tell configure where mysql include - installation root directory is. - - --without-pgsql Disable PostgreSQL support in motion. - - --with-pgsql-lib=DIR Normally, configure will scan all possible default - installation paths for pgsql libs. When it fails, use - this command to tell configure where pgsql libs - installation root directory is. - - --with-pgsql-include=DIR Normally, configure will scan all possible default - installation paths for pgsql include. When it fails, use - this command to tell configure where pgsql include - installation root directory is. - - --without-optimizecpu Exclude autodetecting platform and cpu type. - This will disable the compilation of gcc - optimizing code by platform and cpu. - - --with-developer-flags Causes practically all of the possible gcc - warning flags to be set. This may produce - a large amount of warnings. - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to the package provider. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -motion configure Unofficial-Git-d71cebf -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_func - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_type - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 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 Unofficial-Git-d71cebf, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = xyes; then : - MINIX=yes -else - MINIX= -fi - - - if test "$MINIX" = yes; then - -$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h - - -$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h - - -$as_echo "#define _MINIX 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 -$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if ${ac_cv_safe_to_define___extensions__+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_safe_to_define___extensions__=yes -else - ac_cv_safe_to_define___extensions__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 -$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } - test $ac_cv_safe_to_define___extensions__ = yes && - $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h - - $as_echo "#define _ALL_SOURCE 1" >>confdefs.h - - $as_echo "#define _GNU_SOURCE 1" >>confdefs.h - - $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h - - $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h - - - - -ac_config_headers="$ac_config_headers config.h" - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -THREAD_CFLAGS="" -THREAD_CHECK="/usr/include/pthread.h" - -Darwin="" -FreeBSD="" - -LINUXTHREADS="no" - -# Check whether --with-linuxthreads was given. -if test "${with_linuxthreads+set}" = set; then : - withval=$with_linuxthreads; LINUXTHREADS="$withval" - -fi - - -PWCBSD="no" - -# Check whether --with-pwcbsd was given. -if test "${with_pwcbsd+set}" = set; then : - withval=$with_pwcbsd; PWCBSD="$withval" - -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Darwin" >&5 -$as_echo_n "checking for Darwin... " >&6; } -Darwin=`uname -a | grep "Darwin"` - -if test "${Darwin}" = ""; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for *BSD" >&5 -$as_echo_n "checking for *BSD... " >&6; } - - FreeBSD=`uname -a | grep "FreeBSD"` - if test "${FreeBSD}" = ""; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - VIDEO="video.o video2.o video_common.o" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - if test "${LINUXTHREADS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linuxthreads" >&5 -$as_echo_n "checking Linuxthreads... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } - else - THREAD_CHECK="/usr/local/include/pthread/linuxthreads/pthread.h" - THREAD_LIB_CHECK="/usr/local/lib/liblthread.so" - fi - - if test "${PWCBSD}" != "no"; then - VIDEO="video.o video2.o video_common.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include -DPWCBSD" - else - VIDEO="video_freebsd.o" - TEMP_CFLAGS="${CFLAGS} -I/usr/local/include" - fi - - TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib" - TEMP_LIBS="-L/usr/local/lib" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: Build with PWCBSD support $PWCBSD" >&5 -$as_echo "Build with PWCBSD support $PWCBSD" >&6; } - - fi -else - TEMP_CFLAGS="${CFLAGS} -I/sw/include" - TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib" - TEMP_LIBS="-L/sw/lib" - VIDEO="video_freebsd.o" - FINK_LIB="-L/sw/lib" - Darwin="yes" - V4L="no" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Darwin" >&5 -$as_echo "$Darwin" >&6; } -fi - - - - -# Checks for programs. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -TEMP_LIBS="-lm ${TEMP_LIBS}" -TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}" -TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}" - -if test "${FreeBSD}" != "" && test "${PWCBSD}" = "no"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking bktr headers in /usr/include/dev/bktr" >&5 -$as_echo_n "checking bktr headers in /usr/include/dev/bktr... " >&6; } - - if test -f /usr/include/dev/bktr/ioctl_meteor.h && test -f /usr/include/dev/bktr/ioctl_bt848.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - TEMP_CFLAGS="${TEMP_CFLAGS} -DOLD_BKTR" - fi -# -# Check to Exclude BKTR -# -BKTR="yes" - -# Check whether --with-bktr was given. -if test "${with_bktr+set}" = set; then : - withval=$with_bktr; BKTR="$withval" - -fi - - - if test "${BKTR}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" - fi - -else - -# -# Check to Exclude V4L -# -V4L="yes" - -# Check whether --with-v4l was given. -if test "${with_v4l+set}" = set; then : - withval=$with_v4l; V4L="$withval" - -fi - - -fi - - -if test "${V4L}" = "no"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DWITHOUT_V4L" -fi - - -if test "${FreeBSD}" != "" && test "${LINUXTHREADS}" != "no" ; then - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linuxthreads" >&5 -$as_echo_n "checking for linuxthreads... " >&6; } - -# -# Check for thread header -# - if test -f "${THREAD_CHECK}"; then - HEADERS_THREAD_CFLAGS="-I/usr/local/include/pthread/linuxthreads" - THREADS="yes" - else - THREADS="no" - fi - -# -# Check for thread lib -# - if test -f "${THREAD_LIB_CHECK}" ; then - THREADS="yes" - LIB_THREAD="-llthread -llgcc_r" - else - THREADS="no" - fi - -# Checks for Library linuxthreads for FreeBSD -# -# linuxthreads on freeBSD, ports collection -# /usr/local/include/pthreads/linuxthreads/pthread.h -# #include -# /usr/local/lib/libpthread.so -# - - if test "${THREADS}" = "yes"; then - TEMP_CFLAGS="${HEADERS_THREAD_CFLAGS} $TEMP_CFLAGS -DWITH_LINUXTREADS" - TEMP_LIBS="$TEMP_LIBS ${LIB_THREAD}" - THREAD_CFLAGS="-D_THREAD_SAFE" - PTHREAD_SUPPORT="yes" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 -$as_echo "$THREADS" >&6; } - else - PTHREAD_SUPPORT="no" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADS" >&5 -$as_echo "$THREADS" >&6; } - echo - echo "You do not have linuxthread installed" - echo - fi - -elif test -f "${THREAD_CHECK}"; then - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking threads" >&5 -$as_echo_n "checking threads... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - PTHREAD_LIB=yes -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - -if test x$PTHREAD_LIB != xyes; then - - if test "${FreeBSD}" != ""; then - TEMP_LIBS="$TEMP_LIBS -pthread" - TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT -D_THREAD_SAFE" - else - TEMP_LIBS="$TEMP_LIBS -lpthread" - TEMP_CFLAGS="${TEMP_CFLAGS} -D_REENTRANT" - fi - PTHREAD_SUPPORT="yes" -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_SUPPORT" >&5 -$as_echo "$PTHREAD_SUPPORT" >&6; } - -else - echo - echo "You do not have threads support" - echo -fi - - -# -# Check for sdl library -# -SDL_SUPPORT="no" - -# Check whether --with-sdl was given. -if test "${with_sdl+set}" = set; then : - withval=$with_sdl; -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdl" >&5 -$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; } -else - if test "${FreeBSD}" != ""; then - CONFIG_SDL='sdl11-config' - else - CONFIG_SDL='sdl-config' - fi - if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - if test "$withval" = "yes"; then - echo "" - echo "****************************************************" - echo "* sdl-config could not be found. Please install it *" - echo "* and remove the --with-sdl configure argument. *" - echo "* libSDL can be found at http://www.libsdl.org *" - echo "****************************************************" - echo "" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SDL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" - TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" - -$as_echo "#define HAVE_SDL 1" >>confdefs.h - - SDL_OBJ="sdl.o" - - fi -fi - -# -# Check for the libjpeg-turbo library -# -JPEG_TURBO="no" -JPEG_TURBO_OK="not_found" - - -# Check whether --with-jpeg-turbo was given. -if test "${with_jpeg_turbo+set}" = set; then : - withval=$with_jpeg_turbo; JPEG_TURBO="$withval" - -fi - - -if test "${JPEG_TURBO}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo" >&5 -$as_echo_n "checking for libjpeg-turbo... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-turbo in -> ${JPEG_TURBO} <-" >&5 -$as_echo_n "checking for libjpeg-turbo in -> ${JPEG_TURBO} <-... " >&6; } - if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - JPEG_TURBO_OK="found" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - fi -fi - - -if test "${JPEG_TURBO_OK}" = "found"; then - saved_CFLAGS="$CFLAGS" - saved_LIBS="$LIBS" - saved_LDFLAGS="$LDFLAGS" - LDFLAGS="-L${JPEG_TURBO}/lib" - CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" - LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 -$as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_jpeg_start_compress+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ljpeg $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char jpeg_start_compress (); -int -main () -{ -return jpeg_start_compress (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_jpeg_jpeg_start_compress=yes -else - ac_cv_lib_jpeg_jpeg_start_compress=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 -$as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } -if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = xyes; then : - TEMP_LIBS="$LIBS" - TEMP_CFLAGS="${CFLAGS}" - TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" - JPEG_SUPPORT="yes" -fi - - LIBS="$saved_LIBS" - CFLAGS="$saved_CFLAGS" - LDFLAGS="$saved_LDFLAGS" - JPEG_SUPPORT_TURBO="yes" -fi - - -# -# Check for the special mmx accelerated jpeg library -# -JPEG_MMX="no" -JPEG_MMX_OK="not_found" - -# Check whether --with-jpeg-mmx was given. -if test "${with_jpeg_mmx+set}" = set; then : - withval=$with_jpeg_mmx; JPEG_MMX="$withval" - -fi - - -# -# --without-jpeg-mmx or with-jpeg-mmx=no -# - -if test "${JPEG_MMX}" = "no" || test x$JPEG_SUPPORT != xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx" >&5 -$as_echo_n "checking for libjpeg-mmx... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } -elif test "${JPEG_MMX}" = "yes"; then - # AUTODETECT STATIC LIB - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx autodetecting" >&5 -$as_echo_n "checking for libjpeg-mmx autodetecting... " >&6; } - - if test -f /usr/lib/libjpeg-mmx.a ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - JPEG_MMX_OK="found" - JPEG_MMX="/usr/lib" - elif test -f /usr/local/lib/libjpeg-mmx.a ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - JPEG_MMX_OK="found" - JPEG_MMX="/usr/local/lib" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg-mmx in -> ${JPEG_MMX} <-" >&5 -$as_echo_n "checking for libjpeg-mmx in -> ${JPEG_MMX} <-... " >&6; } - if test -f ${JPEG_MMX}/libjpeg-mmx.a ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - JPEG_MMX_OK="found" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - fi -fi - -if test "${JPEG_MMX_OK}" = "found"; then - saved_CFLAGS="$CFLAGS" - saved_LIBS="$LIBS" - CFLAGS="$CFLAGS -I${JPEG_MMX}" - LIBS="$LIBS -L${JPEG_MMX}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg-mmx" >&5 -$as_echo_n "checking for jpeg_start_compress in -ljpeg-mmx... " >&6; } -if ${ac_cv_lib_jpeg_mmx_jpeg_start_compress+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ljpeg-mmx $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char jpeg_start_compress (); -int -main () -{ -return jpeg_start_compress (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_jpeg_mmx_jpeg_start_compress=yes -else - ac_cv_lib_jpeg_mmx_jpeg_start_compress=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&5 -$as_echo "$ac_cv_lib_jpeg_mmx_jpeg_start_compress" >&6; } -if test "x$ac_cv_lib_jpeg_mmx_jpeg_start_compress" = xyes; then : - TEMP_LIBS="$TEMP_LIBS -ljpeg-mmx" - TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_MMX}" - JPEG_SUPPORT="yes" -fi - - LIBS="$saved_LIBS" - CFLAGS="$saved_CFLAGS" - JPEG_SUPPORT_MMX="yes" -fi - -# -# Look for _a_ jpeg lib that will work. -# -if test x$JPEG_SUPPORT != xyes ; then - # Checks for libraries - LDFLAGS=$TEMP_LDFLAGS - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_set_defaults in -ljpeg" >&5 -$as_echo_n "checking for jpeg_set_defaults in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_jpeg_set_defaults+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ljpeg $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char jpeg_set_defaults (); -int -main () -{ -return jpeg_set_defaults (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_jpeg_jpeg_set_defaults=yes -else - ac_cv_lib_jpeg_jpeg_set_defaults=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_set_defaults" >&5 -$as_echo "$ac_cv_lib_jpeg_jpeg_set_defaults" >&6; } -if test "x$ac_cv_lib_jpeg_jpeg_set_defaults" = xyes; then : - - TEMP_LIBS="$TEMP_LIBS -ljpeg" - JPEG_SUPPORT="yes" - -else - - echo - echo "You do not have libjpeg installed" - echo - - -fi - -fi - - -# -# Check for libavcodec and libavformat from ffmpeg -# - -FFMPEG_DIR="yes" -FFMPEG_OK="no_found" -FFMPEG_OBJ="" - -# Check whether --with-ffmpeg was given. -if test "${with_ffmpeg+set}" = set; then : - withval=$with_ffmpeg; FFMPEG_DIR="$withval" - -fi - - -# -# ffmpeg headers custom location -# -FFMPEG_HEADERS_DIR="yes" - -# Check whether --with-ffmpeg_headers was given. -if test "${with_ffmpeg_headers+set}" = set; then : - withval=$with_ffmpeg_headers; FFMPEG_HEADERS_DIR="$withval" - -fi - - -# -# ffmpeg custom extra libraries -# -FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " - -# Check whether --with-ffmpeg-libs was given. -if test "${with_ffmpeg_libs+set}" = set; then : - withval=$with_ffmpeg_libs; FFMPEG_EXTRALIBS="$withval" - -fi - - -# -# --without-ffmpeg or with-ffmpeg=no -# -if test "${FFMPEG_DIR}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg" >&5 -$as_echo_n "checking for ffmpeg... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } -# -# with-ffmpeg= or nothing -# -else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting libraries" >&5 -$as_echo_n "checking for ffmpeg autodetecting libraries... " >&6; } - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib64" >&5 -$as_echo "found in /usr/lib64" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib" >&5 -$as_echo "found in /usr/lib" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib" - FFMPEG_DIR="/usr" - elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/local/lib" >&5 -$as_echo "found in /usr/local/lib" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" - elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/x86_64-linux-gnu" >&5 -$as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 -$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/i386-linux-gnu" - FFMPEG_DIR="/usr" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-" >&5 -$as_echo_n "checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-... " >&6; } - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="${FFMPEG_DIR}/lib" - elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - FFMPEG_LIB="${FFMPEG_DIR}" - FFMPEG_OK="found" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - if test "${FFMPEG_OK}" != "found"; then - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - fi -fi - - -# -# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found -# - -AVFORMAT_DIR="" - -if test "${FFMPEG_OK}" = "found"; then - if test "${FFMPEG_HEADERS_DIR}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 -$as_echo_n "checking for ffmpeg headers in ${FFMPEG_DIR}... " >&6; } - AVFORMAT_DIR="${FFMPEG_DIR}" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}" >&5 -$as_echo_n "checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}... " >&6; } - FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}" - fi - - if test -f ${FFMPEG_DIR}/include/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" - AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" - elif test -f ${FFMPEG_DIR}/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" - elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/libavformat/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I{FFMPEG_DIR}/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - FFMPEG_OK="no_found" - AVFORMAT_DIR="avformat.h" - echo "**********************************************" - echo "* avformat.h not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - -# -# If ffmpeg libs and headers have been found -# - - if test "${FFMPEG_OK}" = "found"; then - TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" - TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" - - FFMPEG_OBJ="ffmpeg.o" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 -$as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - - CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - - #include <${AVFORMAT_DIR}> - URLProtocol test_file_protocol; - int main(void){ - test_file_protocol.url_read = file_protocol.url_read; - return 0; - } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi -fi -fi - -# Revised RTSP module so that it can be included -# whether or not FFMPEG is found. - - RTPS_OBJ="netcam_rtsp.o" - - -# -# Check SQLITE3 -# - -SQLITE3_SUPPORT="no" - -# Check whether --with-sqlite3 was given. -if test "${with_sqlite3+set}" = set; then : - withval=$with_sqlite3; SQLITE3="$withval" - # if not given argument, assume standard - -fi - - -if test "${SQLITE3}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3" >&5 -$as_echo_n "checking for sqlite3... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } -else - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5 -$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; } -if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsqlite3 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sqlite3_open (); -int -main () -{ -return sqlite3_open (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_sqlite3_sqlite3_open=yes -else - ac_cv_lib_sqlite3_sqlite3_open=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5 -$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; } -if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then : - - TEMP_LIBS="$TEMP_LIBS -lsqlite3" - SQLITE3_SUPPORT="yes" - -$as_echo "#define HAVE_SQLITE3 1" >>confdefs.h - - - -fi - - - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS -fi - - -# -# Check Mysql -# - -MYSQL="yes" -MYSQL_SUPPORT="no" -MYSQL_HEADERS="yes" -MYSQL_LIBS="yes" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql support" >&5 -$as_echo_n "checking for mysql support... " >&6; } - - -# Check whether --with-mysql was given. -if test "${with_mysql+set}" = set; then : - withval=$with_mysql; MYSQL="$withval" -# if not given argument, assume standard - -fi - - - -# Check whether --with-mysql-lib was given. -if test "${with_mysql_lib+set}" = set; then : - withval=$with_mysql_lib; MYSQL_LIBS="$withval" -# if not given argument, assume standard - -fi - - - - -# Check whether --with-mysql-include was given. -if test "${with_mysql_include+set}" = set; then : - withval=$with_mysql_include; MYSQL_HEADERS="$withval" -# if not given argument, assume standard - -fi - - - -if test "${MYSQL}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: testing" >&5 -$as_echo "testing" >&6; } - # ******* Search mysql headers ******* - - if test "${MYSQL_HEADERS}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql headers" >&5 -$as_echo_n "checking autodect mysql headers... " >&6; } - # Autodetect - for w in /usr/include /usr/local/include /usr/mysql /usr/local/mysql /usr/local/mysql/include /opt /opt/mysql; do - # check for plain setups - if test -f $w/mysql.h; then - MYSQL_INCDIR=$w - break - fi - # check for "/usr/include/" type setups - if test -f $w/mysql/mysql.h; then - MYSQL_INCDIR=$w/mysql - break - fi - # check for "/usr//include" type setups - if test -f $w/mysql/include/mysql.h; then - MYSQL_INCDIR=$w/mysql/include - break - fi - done - elif test "${MYSQL_HEADERS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers" >&5 -$as_echo_n "checking for mysql headers... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql headers in $MYSQL_HEADERS" >&5 -$as_echo_n "checking for mysql headers in $MYSQL_HEADERS... " >&6; } - # Manual detection for - if test -f $MYSQL_HEADERS/mysql.h; then - MYSQL_INCDIR=$MYSQL_HEADERS - fi - fi - - if test -z "$MYSQL_INCDIR" ; then - MYSQL_HEADERS="no" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "Invalid MySQL directory - unable to find mysql.h." - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_INCDIR yes" >&5 -$as_echo "$MYSQL_INCDIR yes" >&6; } - MYSQL_HEADERS="yes" - fi - - - if test "${MYSQL_HEADERS}" = "yes"; then - - # ******* Search mysql libs ********* - if test "${MYSQL_LIBS}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect mysql libs" >&5 -$as_echo_n "checking autodect mysql libs... " >&6; } - # Autodetect - for w in /usr/lib64 /usr/lib /usr/local/lib /usr/mysql /usr/local/mysql /usr/local/mysql/lib /opt /opt/mysql /usr/lib/x86_64-linux-gnu; do - # check for plain setups - if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then - MYSQL_LIBDIR=$w - break - fi - # check for "/usr/lib/" type setups - if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then - MYSQL_LIBDIR=$w/mysql - break - fi - # check for "/usr//lib" type setups - if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then - MYSQL_LIBDIR=$w/mysql/lib - break - fi - done - elif test "${MYSQL_LIBS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs" >&5 -$as_echo_n "checking for mysql libs... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql libs in $MYSQL_LIBS" >&5 -$as_echo_n "checking for mysql libs in $MYSQL_LIBS... " >&6; } - # Manual detection for - if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then - MYSQL_LIBDIR=$MYSQL_LIBS - fi - fi - - - if test -z "$MYSQL_LIBDIR" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "Invalid MySQL directory - unable to find libmysqlclient.a or libmysqlclient.so." - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MYSQL_LIBDIR" >&5 -$as_echo "$MYSQL_LIBDIR" >&6; } - #LDFLAGS="-L$MYSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$MYSQL_INCDIR" - LIBS="-L$MYSQL_LIBDIR" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 -$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } -if ${ac_cv_lib_mysqlclient_mysql_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lmysqlclient $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char mysql_init (); -int -main () -{ -return mysql_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_mysqlclient_mysql_init=yes -else - ac_cv_lib_mysqlclient_mysql_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 -$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } -if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then : - - TEMP_LIBS="$TEMP_LIBS -L$MYSQL_LIBDIR -lmysqlclient -lz" - TEMP_CFLAGS="$TEMP_CFLAGS -I$MYSQL_INCDIR" - MYSQL_SUPPORT="yes" - -$as_echo "#define HAVE_MYSQL 1" >>confdefs.h - - -else - as_fn_error $? "MySQL support can't build without MySQL libraries" "$LINENO" 5 -fi - - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - # end mysql-include , mysql-libs - fi - -# end Mysql detection -fi - - -# -# Check PostgreSQL -# -PGSQL="yes" -PGSQL_SUPPORT="no" -PGSQL_HEADERS="yes" -PGSQL_LIBS="yes" - - - - -# Check whether --with-pgsql was given. -if test "${with_pgsql+set}" = set; then : - withval=$with_pgsql; PGSQL="$withval" -# if not given argument, assume standard - -fi - - - -# Check whether --with-pgsql-lib was given. -if test "${with_pgsql_lib+set}" = set; then : - withval=$with_pgsql_lib; PGSQL_LIBS="$withval" -# if not given argument, assume standard - -fi - - - -# Check whether --with-pgsql-include was given. -if test "${with_pgsql_include+set}" = set; then : - withval=$with_pgsql_include; PGSQL_HEADERS="$withval" -# if not given argument, assume standard - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PostgreSQL" >&5 -$as_echo_n "checking for PostgreSQL... " >&6; } - -if test "${PGSQL}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: testing" >&5 -$as_echo "testing" >&6; } - - # ******* Search pgsql headers ******* - if test "${PGSQL_HEADERS}" = "yes"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql headers" >&5 -$as_echo_n "checking autodect pgsql headers... " >&6; } - # Autodetect - for i in /usr /usr/local /usr/local/pgsql $PHP_PGSQL; do - if test -r $i/include/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i/include - elif test -r $i/include/pgsql/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i/include/pgsql - elif test -r $i/include/postgresql/libpq-fe.h; then PGSQL_DIR=$i; PGSQL_INCDIR=$i/include/postgresql - fi - done - - elif test "${PGSQL_HEADERS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers" >&5 -$as_echo_n "checking for pgsql headers... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql headers in $PGSQL_HEADERS" >&5 -$as_echo_n "checking for pgsql headers in $PGSQL_HEADERS... " >&6; } - # Manual detection for - if test -f $PGSQL_HEADERS/libpq-fe.h; then - PGSQL_INCDIR=$PGSQL_HEADERS - fi - fi - - if test -z "$PGSQL_INCDIR" ; then - PGSQL_HEADERS="no" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "Invalid PostgreSQL directory - unable to find libpq-fe.h." - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes $PGSQL_INCDIR" >&5 -$as_echo "yes $PGSQL_INCDIR" >&6; } - PGSQL_HEADERS="yes" - fi - - - if test "${PGSQL_HEADERS}" = "yes"; then - - # ******* Search pgsql libs ********* - if test "${PGSQL_LIBS}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking autodect pgsql libs" >&5 -$as_echo_n "checking autodect pgsql libs... " >&6; } - # Autodetect - PGSQL_INCLUDE="-I$PGSQL_INCDIR" - PGSQL_LIBDIR=$PGSQL_DIR/lib - - if test -f /usr/lib64/libpq.so ; then - PGSQL_LIBDIR=/usr/lib64 - elif test -f $PGSQL_DIR/lib/pgsql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql - elif test -f $PGSQL_DIR/lib/postgresql/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib/postgresql - elif test -f $PGSQL_DIR/lib/libpq.so ; then - PGSQL_LIBDIR=$PGSQL_DIR/lib - else - PGSQL_LIBDIR="" - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PGSQL_LIBDIR" >&5 -$as_echo "$PGSQL_LIBDIR" >&6; } - - elif test "${PGSQL_LIBS}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs" >&5 -$as_echo_n "checking for pgsql libs... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5 -$as_echo "skipped" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pgsql libs in $PGSQL_LIBS" >&5 -$as_echo_n "checking for pgsql libs in $PGSQL_LIBS... " >&6; } - # Manual detection for - if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then - PGSQL_LIBDIR=$PGSQL_LIBS - fi - fi - - - if test -z "$PGSQL_LIBDIR" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "Invalid PostgreSQL directory $PGSQL_LIBDIR - unable to find libpq.a or libpq.so." - else - #LDFLAGS="$TEMP_LDFLAGS -L$PGSQL_LIBDIR" - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - CFLAGS="-I$PGSQL_INCDIR" - LIBS="-L$PGSQL_LIBDIR" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectStart in -lpq" >&5 -$as_echo_n "checking for PQconnectStart in -lpq... " >&6; } -if ${ac_cv_lib_pq_PQconnectStart+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpq $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char PQconnectStart (); -int -main () -{ -return PQconnectStart (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_pq_PQconnectStart=yes -else - ac_cv_lib_pq_PQconnectStart=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectStart" >&5 -$as_echo "$ac_cv_lib_pq_PQconnectStart" >&6; } -if test "x$ac_cv_lib_pq_PQconnectStart" = xyes; then : - - PGSQL_SUPPORT="yes" - TEMP_LIBS="$TEMP_LIBS -L$PGSQL_LIBDIR -lpq" - TEMP_CFLAGS="$TEMP_CFLAGS -I$PGSQL_INCDIR" - -$as_echo "#define HAVE_PGSQL 1" >>confdefs.h - - -else - as_fn_error $? "PostgreSQL support can't build without PostgreSQL libraries" "$LINENO" 5 -fi - - LDFLAGS="" - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi - - fi # end pgsql-include , pgsql-libs - -# end PostgreSQL detection -fi - - -#Checks for header files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -for ac_header in stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h linux/videodev.h linux/videodev2.h sys/param.h sys/types.h sys/videoio.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_func in get_current_dir_name -do : - ac_fn_c_check_func "$LINENO" "get_current_dir_name" "ac_cv_func_get_current_dir_name" -if test "x$ac_cv_func_get_current_dir_name" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GET_CURRENT_DIR_NAME 1 -_ACEOF - -fi -done - - -# Check if v4l2 is available -SUPPORTED_V4L2=false -SUPPORTED_V4L2_old=false - -if test "${V4L}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 -$as_echo_n "checking for V42L support... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } -else - ac_fn_c_check_type "$LINENO" "struct v4l2_buffer" "ac_cv_type_struct_v4l2_buffer" "#include - #ifdef HAVE_LINUX_VIDEODEV_H - #include - #elif HAVE_SYS_VIDEOIO_H - #include - #endif -" -if test "x$ac_cv_type_struct_v4l2_buffer" = xyes; then : - SUPPORTED_V4L2=true -else - SUPPORTED_V4L2=false -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L support" >&5 -$as_echo_n "checking for V42L support... " >&6; } - if test x$SUPPORTED_V4L2 = xtrue; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - - # linux/videodev.h doesn't include videodev2.h - if test x$SUPPORTED_V4L2 = xfalse; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for V42L *old* support" >&5 -$as_echo_n "checking for V42L *old* support... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: testing" >&5 -$as_echo "testing" >&6; } - for ac_header in linux/videodev2.h -do : - ac_fn_c_check_header_compile "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "#include -" -if test "x$ac_cv_header_linux_videodev2_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_VIDEODEV2_H 1 -_ACEOF - SUPPORTED_V4L2_old=true -fi - -done - - fi - - - if test x$SUPPORTED_V4L2_old = xtrue; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DMOTION_V4L2 -DMOTION_V4L2_OLD" - SUPPORTED_V4L2=true - fi - -fi - - -# Check sizes of integer types -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 -$as_echo_n "checking size of short... " >&6; } -if ${ac_cv_sizeof_short+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_short" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (short) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_short=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 -$as_echo "$ac_cv_sizeof_short" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SHORT $ac_cv_sizeof_short -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 -$as_echo_n "checking size of int... " >&6; } -if ${ac_cv_sizeof_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (int) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_int=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 -$as_echo "$ac_cv_sizeof_int" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT $ac_cv_sizeof_int -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5 -$as_echo_n "checking size of long int... " >&6; } -if ${ac_cv_sizeof_long_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long int) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_int=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_int" >&5 -$as_echo "$ac_cv_sizeof_long_int" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_INT $ac_cv_sizeof_long_int -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 -$as_echo_n "checking size of long long... " >&6; } -if ${ac_cv_sizeof_long_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 -$as_echo "$ac_cv_sizeof_long_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 -$as_echo_n "checking size of int *... " >&6; } -if ${ac_cv_sizeof_int_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_int_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (int *) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_int_p=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int_p" >&5 -$as_echo "$ac_cv_sizeof_int_p" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT_P $ac_cv_sizeof_int_p -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 -$as_echo_n "checking size of void *... " >&6; } -if ${ac_cv_sizeof_void_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_void_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (void *) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_void_p=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 -$as_echo "$ac_cv_sizeof_void_p" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_VOID_P $ac_cv_sizeof_void_p -_ACEOF - - - -if test "$ac_cv_sizeof_short" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"short\"" -else - if test "$ac_cv_sizeof_int" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"int\"" - else - if test "$ac_cv_sizeof_long_int" = "4"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -DTYPE_32BIT=\"long int\"" - fi - fi -fi - - -OPTIMIZECPU="yes" - - -# Check whether --with-optimizecpu was given. -if test "${with_optimizecpu+set}" = set; then : - withval=$with_optimizecpu; OPTIMIZECPU="$withval" - -fi - - -DEVELOPER_FLAGS="no" - - -# Check whether --with-developer-flags was given. -if test "${with_developer_flags+set}" = set; then : - withval=$with_developer_flags; DEVELOPER_FLAGS="$withval" - -fi - - -# Checks for typedefs, structures, and compiler characteristics. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if ${ac_cv_c_const+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - -#ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ - typedef int charset[2]; - const charset cs = { 0, 0 }; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this sort of thing. */ - char tx; - char *t = &tx; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - - -if test "${FreeBSD}" != ""; then - OPTIMIZECPU="" -fi - -if test "${OPTIMIZECPU}" = "yes"; then - -# Try to autodetect cpu type -CPU_NAME="unknown" -CPU_TYPE="unknown" -if test -e "/proc/cpuinfo" ; then - intel[30]="-march=i386" - intel[32]="-march=i386" - intel[34]="-march=i386" - intel[40]="-march=i486" - intel[41]="-march=i486" - intel[42]="-march=i486" - intel[43]="-march=i486" - intel[44]="-march=i486" - intel[45]="-march=i486" - intel[47]="-march=i486" - intel[48]="-march=i486" - intel[51]="-march=pentium" - intel[52]="-march=pentium" - intel[54]="-march=pentium-mmx" - intel[56]="-march=pentium-mmx" - intel[61]="-march=pentiumpro" - intel[63]="-march=pentium2" - intel[65]="-march=pentium2" - intel[66]="-march=pentium2" - intel[67]="-march=pentium3" - intel[68]="-march=pentium3" - intel[610]="-march=pentium3" - intel[611]="-march=pentium3" - intel[150]="-march=pentium4" - intel[151]="-march=pentium4" - intel[152]="-march=pentium4" - intel[154]="-march=pentium4" - intel[614]="-march=prescott" - intel[628]="-march=core2" - amd[50]="-march=i586" - amd[51]="-march=i586" - amd[52]="-march=i586" - amd[53]="-march=i586" - amd[56]="-march=k6" - amd[57]="-march=k6" - amd[58]="-march=k6-2" - amd[510]="-march=k6-2" - amd[59]="-march=k6-3" - amd[513]="-march=k6-3" - amd[61]="-march=athlon" - amd[62]="-march=athlon" - amd[63]="-march=athlon" - amd[64]="-march=athlon" - amd[66]="-march=athlon" - amd[67]="-march=athlon" - amd[68]="-march=athlon" - amd[610]="-march=athlon" - amd[158]="-march=athlon-xp" - amd[154]="-march=k8" - amd[155]="-march=athlon64" - amd[1543]="-march=athlon64" - amd[1544]="-march=athlon64" - amd[1565]="-march=opteron" - amd[1572]="-march=k8" - via[67]="-march=c3" - via[68]="-march=c3" - via[69]="-march=i686" - via[610]="-march=i686" - - CPU_TYPE="known" - CPU_FAMILY=`cat /proc/cpuinfo | grep "cpu family" | head -n1` - CPU_MODEL=`cat /proc/cpuinfo | grep model[^\ ] | head -n1` - CPU_NAME=`cat /proc/cpuinfo | grep "model name" | head -n1` - CPU_FLAGS=`cat /proc/cpuinfo | grep "flags" | head -n1` - CPU_VENDOR=`cat /proc/cpuinfo | grep "vendor_id" | head -n1` - CPU_FAMILY=${CPU_FAMILY#*: } - CPU_MODEL=${CPU_MODEL#*: } - CPU_NAME=${CPU_NAME#*: } - CPU_FLAGS=${CPU_FLAGS#*: } - CPU_VENDOR=${CPU_VENDOR#*: } - if test "x${CPU_VENDOR}" = "xGenuineIntel" ; then - CPU_OPTIONS=${intel[$CPU_FAMILY$CPU_MODEL]} - fi - if test "x${CPU_VENDOR}" = "xAuthenticAMD" ; then - CPU_OPTIONS=${amd[$CPU_FAMILY$CPU_MODEL]} - fi - if test "x${CPU_VENDOR}" = "xCentaurHauls"; then - CPU_OPTIONS=${via[$CPU_FAMILY$CPU_MODEL]} - fi - if test "x${CPU_OPTIONS}" = "x" ; then - CPU_TYPE="unknown" - fi - CPU_EXT="" - for i in $CPU_FLAGS ; do - case $i in - fpu) - CPU_FPU="-mfpmath=387" - ;; - mmx) - CPU_EXT="$CPU_EXT -mmmx" - ;; - sse) - CPU_FPU="-mfpmath=sse -msse" - ;; - sse2) - CPU_FPU="-mfpmath=sse -msse2" - ;; - sse3) - CPU_FPU="-msse3" - ;; - ssse3) - CPU_FPU="-mfpmath=sse -msse2 -mssse3" - ;; - 3dnow) - CPU_EXT="$CPU_EXT -m3dnow" - ;; - esac - done - CPU_OPTIONS="$CPU_OPTIONS $CPU_FPU $CPU_EXT" -fi -if test "x${CPU_TYPE}" = "xunknown"; then - CPU_TYPE=`( uname -p ) 2>&1` - case $CPU_TYPE in - i386) - CPU_OPTIONS="-march=i386" - ;; - i486) - CPU_OPTIONS="-march=i486" - ;; - Pentium2) - CPU_OPTIONS="-march=pentium2" - ;; - Pentiumpro) - CPU_OPTIONS="-march=pentiumpro" - ;; - Pentium*) - CPU_OPTIONS="-march=pentium" - ;; - k6) - CPU_OPTIONS="-march=k6" - ;; - k6-2) - CPU_OPTIONS="-march=k6-2" - ;; - k6-3) - CPU_OPTIONS="-march=k6-3" - ;; - "VIA C3 Ezra") - CPU_OPTIONS="-march=c3" - CPU_TYPE="known" - ;; - *) - CPU_OPTIONS="" - CPU_TYPE="unknown" - ;; - esac - if test "x${CPU_TYPE}" = "xunknown"; then - CPU_TYPE=`( uname -m ) 2>&1` - case $CPU_TYPE in - i386) - CPU_OPTIONS="-march=i386" - ;; - i486) - CPU_OPTIONS="-march=i486" - ;; - i586) - CPU_OPTIONS="-march=i586" - ;; - i686) - CPU_OPTIONS="-march=i686" - ;; - Pentium2) - CPU_OPTIONS="-march=pentium2" - ;; - Pentiumpro) - CPU_OPTIONS="-march=pentiumpro" - ;; - k6) - CPU_OPTIONS="-march=k6" - ;; - k6-2) - CPU_OPTIONS="-march=k6-2" - ;; - k6-3) - CPU_OPTIONS="-march=k6-3" - ;; - *) - CPU_OPTIONS="-march=native -mtune=native" - ;; - esac - fi -fi -echo "Detected CPU: $CPU_NAME" -# Now we check if the compiler supports the detected cpu -COMPILER=$CC -for I in "$TMPDIR" "$TEMPDIR" "/tmp" ; do - test "$I" && break -done -TMPC="$I/cpu_test-$RANDOM-$$.c" -TMPO="$I/cpu_test-$RANDOM-$$.o" -cat > $TMPC << EOF -int main(void) { return 0; } -EOF -( $COMPILER $CPU_OPTIONS -o $TMPO $TMPC ) 2>&1 -TMP="$?" -rm -f $TMPO -rm -f $TMPC - - -if test "x${TMP}" = "x1" ; then - CPU_OPTIONS="" - echo "No CPU optimizations will be added" -else - echo "CPU optimization: $CPU_OPTIONS" -fi - -else - CPU_OPTIONS="" -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bswap instruction" >&5 -$as_echo_n "checking for bswap instruction... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -int -main () -{ -unsigned int __x=0; - register unsigned int __v; - __asm("bswap %0" : "=r" (__v) : "0" (__x)); - ; - return 0; -} - -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_BSWAP" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - -if test "${DEVELOPER_FLAGS}" = "yes"; then - TEMP_CFLAGS="${TEMP_CFLAGS} -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3" -fi - -CFLAGS="${TEMP_CFLAGS} $UNAME_DEFS $CPU_OPTIONS" - -LIBS="${TEMP_LIBS}" -LDFLAGS="${TEMP_LDFLAGS}" - - -# -# Add the right exec path for rc scripts -# -if test $prefix = "NONE";then - BIN_PATH="$ac_default_prefix" - if test $exec_prefix = "NONE"; then - BIN_PATH="$BIN_PATH/bin" - else - BIN_PATH="$BIN_PATH/$bindir" - fi -else - if test $exec_prefix = "NONE";then - BIN_PATH="$prefix/bin" - else - BIN_PATH="$prefix/$bindir" - fi -fi - - - - -ac_config_files="$ac_config_files thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian motion.init-Fedora motion.spec Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# 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 Unofficial-Git-d71cebf, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Report bugs to the package provider." - -_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 Unofficial-Git-d71cebf -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "thread1.conf") CONFIG_FILES="$CONFIG_FILES thread1.conf" ;; - "thread2.conf") CONFIG_FILES="$CONFIG_FILES thread2.conf" ;; - "thread3.conf") CONFIG_FILES="$CONFIG_FILES thread3.conf" ;; - "thread4.conf") CONFIG_FILES="$CONFIG_FILES thread4.conf" ;; - "motion-dist.conf") CONFIG_FILES="$CONFIG_FILES motion-dist.conf" ;; - "motion.init-FreeBSD.sh") CONFIG_FILES="$CONFIG_FILES motion.init-FreeBSD.sh" ;; - "motion.init-Debian") CONFIG_FILES="$CONFIG_FILES motion.init-Debian" ;; - "motion.init-Fedora") CONFIG_FILES="$CONFIG_FILES motion.init-Fedora" ;; - "motion.spec") CONFIG_FILES="$CONFIG_FILES motion.spec" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; - - - esac - -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - - -echo "" -echo " **************************" -echo " Configure status " -echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}" -echo " **************************" -echo - - -if test "${Darwin}" != ""; then - echo "OS : Darwin" -elif test "${FreeBSD}" != ""; then - echo "OS : *BSD" -else - echo "OS : Linux" -fi - -if test "${PTHREAD_SUPPORT}" = "yes"; then - echo "pthread support: Yes" -else - echo "pthread support: No" - echo "**********************************************" - echo "** Fatal Error YOU MUST HAVE pthread Support *" - echo "**********************************************" -fi - - -if test "${JPEG_SUPPORT_TURBO}" = "yes"; then - echo "jpeg turbo support: Yes" -elif test "${JPEG_SUPPORT_MMX}" = "yes"; then - echo "jpeg-mmx support: Yes" -elif test "${JPEG_SUPPORT}" = "yes"; then - echo "jpeg support: Yes" -else - echo "jpeg support: No" - echo "**********************************************" - echo "** Fatal Error YOU MUST HAVE jpeg Support ***" - echo "**********************************************" -fi - -if test "${FreeBSD}" != ""; then - if test "${BKTR}" = "yes"; then - echo "BKTR included: Yes" - else - echo "BKTR included: No" - fi - - if test "${PWCBSD}" = "yes"; then - echo "PWCBSD include: Yes" - else - echo "PWCBSD include: No" - fi - -else - if test "${V4L}" = "yes"; then - echo "V4L support: Yes" - else - echo "V4L support: No" - fi - - if test x$SUPPORTED_V4L2 = xtrue; then - echo "V4L2 support: Yes" - else - echo "V4L2 support: No" - fi -fi - -if test "${SDL_SUPPORT}" = "yes"; then - echo "SDL support: Yes" -else - echo "SDL support: No" -fi - -if test "${FFMPEG_OK}" = "found"; then - echo "FFmpeg support: Yes" -else - echo "FFmpeg support: No" -fi - -if test "${SQLITE3_SUPPORT}" = "yes"; then - echo "SQLite3 support: Yes" -else - echo "SQLite3 support: No" -fi - -if test "${MYSQL_SUPPORT}" = "yes"; then - echo "MYSQL support: Yes" -else - echo "MYSQL support: No" -fi - -if test "${PGSQL_SUPPORT}" = "yes"; then - echo "PostgreSQL support: Yes" -else - echo "PostgreSQL support: No" -fi -echo -echo "CFLAGS: $CFLAGS" -echo "LIBS: $LIBS" -echo "LDFLAGS: $LDFLAGS" -echo -echo "Install prefix: $prefix" -echo From ab7d7e717bf0e0fb513a09a0ae7f4f0ae45d8e73 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 28 Aug 2015 18:09:10 -0600 Subject: [PATCH 128/233] Add revisions to CHANGELOG --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7184bf6..f7fe79f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ Summary of Changes + * Fix missing header for some builds(Jim Dodgen) + * Sqlite3 revisions (Jim Dodgen) * Add new config options to the motion-dist.conf * Allow text format specifiers to take a width like printf would. (David Fries) * Allow text format specifiers to take a width like printf would. (David Fries) From 124e8e302a394002399185a4768e463cac4d3c75 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sun, 30 Aug 2015 23:37:48 -0600 Subject: [PATCH 129/233] Logitech MJPEG patch --- CHANGELOG | 1 + jpegutils.c | 30 +++++++++++++++++++++++------- video2.c | 1 + video_common.c | 28 +++++++++++++++++++++++++++- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f7fe79f..8276b0a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Handle MJPEG streams from some Logitech webcams which send AVI1 instead of JFIF. * Fix missing header for some builds(Jim Dodgen) * Sqlite3 revisions (Jim Dodgen) * Add new config options to the motion-dist.conf diff --git a/jpegutils.c b/jpegutils.c index 7447c9d..15d762d 100644 --- a/jpegutils.c +++ b/jpegutils.c @@ -265,6 +265,7 @@ struct my_error_mgr { static void my_error_exit(j_common_ptr cinfo) { + char buffer[JMSG_LENGTH_MAX]; /* cinfo->err really points to a my_error_mgr struct, so coerce pointer. */ struct my_error_mgr *myerr = (struct my_error_mgr *) cinfo->err; @@ -272,7 +273,9 @@ static void my_error_exit(j_common_ptr cinfo) * Always display the message. * We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); + (*cinfo->err->format_message) (cinfo, buffer); + + MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: %s", buffer); /* Return control to the setjmp point. */ longjmp (myerr->setjmp_buffer, 1); @@ -280,14 +283,18 @@ static void my_error_exit(j_common_ptr cinfo) static void my_emit_message(j_common_ptr cinfo, int msg_level) { + char buffer[JMSG_LENGTH_MAX]; /* cinfo->err really points to a my_error_mgr struct, so coerce pointer. */ struct my_error_mgr *myerr = (struct my_error_mgr *) cinfo->err; if (msg_level < 0) - myerr->warning_seen = 1; + myerr->warning_seen++ ; - /* Call original emit_message() */ - (myerr->original_emit_message)(cinfo, msg_level); + //msg_level = 3 are the RST markers of the JPG which are not of much interest + if (msg_level < 3) { + (*cinfo->err->format_message) (cinfo, buffer); + MOTION_LOG(DBG, TYPE_VIDEO, NO_ERRNO, "%s: msg_level: %d, %s", msg_level, buffer); + } } #define MAX_LUMA_WIDTH 4096 @@ -746,10 +753,19 @@ int decode_jpeg_raw (unsigned char *jpeg_data, int len, jpeg_destroy_decompress (&dinfo); - if (jerr.warning_seen) + /** + * The 10% was determined by trial. Perhaps a better + * threshold for discarding an image would be a function + * of the threshold for the trigger of motion. + */ + if (dinfo.output_height == 0){ return 1; - else - return 0; + } else { + if ( (jerr.warning_seen / dinfo.output_height) > 0.10) + return 1; + else + return 0; + } ERR_EXIT: jpeg_destroy_decompress (&dinfo); diff --git a/video2.c b/video2.c index bca7535..798f8f8 100644 --- a/video2.c +++ b/video2.c @@ -997,6 +997,7 @@ int v4l2_next(struct context *cnt, struct video_dev *viddev, unsigned char *map, vid_source->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vid_source->buf.memory = V4L2_MEMORY_MMAP; + vid_source->buf.bytesused = 0; if (xioctl(vid_source, VIDIOC_DQBUF, &vid_source->buf) == -1) { int ret; diff --git a/video_common.c b/video_common.c index cabc5aa..6575147 100644 --- a/video_common.c +++ b/video_common.c @@ -387,11 +387,37 @@ void conv_rgb24toyuv420p(unsigned char *map, unsigned char *cap_map, int width, */ int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size) { - int ret = decode_jpeg_raw(cap_map, size, 0, 420, width, height, + unsigned char *ptr_buffer; + size_t soi_pos = 0; + int ret = 0; + + ptr_buffer = memmem(cap_map, size, "\xff\xd8", 2); + if (ptr_buffer != NULL) { + /** + Some cameras are sending multiple SOIs in the buffer. + Move the pointer to the last SOI in the buffer and proceed. + */ + while (ptr_buffer != NULL && ((size - soi_pos - 1) > 2) ){ + soi_pos = ptr_buffer - cap_map; + ptr_buffer = memmem(cap_map + soi_pos + 1, size - soi_pos - 1, "\xff\xd8", 2); + } + + if (soi_pos != 0){ + MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: SOI position adjusted by %d bytes.", soi_pos); + } + + memmove(cap_map, cap_map + soi_pos, size - soi_pos); + size -= soi_pos; + ret = decode_jpeg_raw(cap_map, size, 0, 420, width, height, map, map + (width * height), map + (width * height) + (width * height) / 4); + } else { + //Buffer does not have a SOI + ret = 1; + } + if (ret == 1) { MOTION_LOG(CRT, TYPE_VIDEO, NO_ERRNO, "%s: Corrupt image ... continue"); ret = 2; From cc8e4513116ea3c3094443abf0b41c2828ba43a5 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 31 Aug 2015 20:53:05 -0600 Subject: [PATCH 130/233] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 8276b0a..919aac0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Updated handling of lastsnap to permit subdirectory specification. * Handle MJPEG streams from some Logitech webcams which send AVI1 instead of JFIF. * Fix missing header for some builds(Jim Dodgen) * Sqlite3 revisions (Jim Dodgen) From ccfc14296e1b80a7d60440f303f6f40474d30cab Mon Sep 17 00:00:00 2001 From: hackeron Date: Fri, 22 Feb 2013 22:25:08 +0000 Subject: [PATCH 131/233] Update netcam.c --- netcam.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netcam.c b/netcam.c index cdf27ee..77cce1a 100644 --- a/netcam.c +++ b/netcam.c @@ -1305,6 +1305,11 @@ static int netcam_read_html_jpeg(netcam_context_ptr netcam) MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: gettimeofday"); netcam->receiving->image_time = curtime; + + /* Fix starting of JPEG if needed , some cameras introduce thrash before + * SOI 0xFFD8 Start Of Image + */ + netcam_fix_jpeg_header(netcam); /* * Calculate our "running average" time for this netcam's From e7f4b968925d2a02f4735429c62254d90d1ebee8 Mon Sep 17 00:00:00 2001 From: hackeron Date: Fri, 22 Feb 2013 22:25:53 +0000 Subject: [PATCH 132/233] Update netcam.h --- netcam.h | 1 + 1 file changed, 1 insertion(+) diff --git a/netcam.h b/netcam.h index 3612f1a..22dc042 100644 --- a/netcam.h +++ b/netcam.h @@ -296,6 +296,7 @@ typedef struct { */ /* Within netcam_jpeg.c */ int netcam_proc_jpeg (struct netcam_context *, unsigned char *); +void netcam_fix_jpeg_header(struct netcam_context *); void netcam_get_dimensions (struct netcam_context *); /* Within netcam.c */ int netcam_start (struct context *); From 6861a82840ddf7b869ae94648982a58fb82290e1 Mon Sep 17 00:00:00 2001 From: hackeron Date: Fri, 22 Feb 2013 22:27:32 +0000 Subject: [PATCH 133/233] Handle junk data at beginning of JPEG images --- netcam_jpeg.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/netcam_jpeg.c b/netcam_jpeg.c index 20fbda2..f5c0614 100644 --- a/netcam_jpeg.c +++ b/netcam_jpeg.c @@ -484,6 +484,42 @@ int netcam_proc_jpeg(netcam_context_ptr netcam, unsigned char *image) return retval; } +/** + * netcam_fix_jpeg_header + * + * Routine to decode an image received from a netcam into a YUV420P buffer + * suitable for processing by motion. + * + * Parameters: + * netcam pointer to the netcam_context structure + * + * Returns: Nothing + * + */ +void netcam_fix_jpeg_header(netcam_context_ptr netcam) +{ + char *ptr_buffer; + + ptr_buffer = memmem(netcam->receiving->ptr, netcam->receiving->used, "\xff\xd8", 2); + + if (ptr_buffer != NULL) { + size_t soi_position = 0; + + soi_position = ptr_buffer - netcam->receiving->ptr; + + if (soi_position > 0) { + memmove(netcam->receiving->ptr, netcam->receiving->ptr + soi_position, + netcam->receiving->used - soi_position); + netcam->receiving->used -= soi_position; + } + + // if (debug_level > CAMERA_INFO) + // motion_log(LOG_INFO, 0, "%s: SOI found , position %d", + // __FUNCTION__, soi_position); + } +} + + /** * netcam_get_dimensions * From a7ec135777c1cd30150e6eae4952576efacf6729 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Thu, 3 Sep 2015 20:33:15 -0600 Subject: [PATCH 134/233] Changelog for hackeron fix for SOI on Netcams --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 919aac0..c58d7b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Remove extra bytes before SOI marker on netcam images. * Updated handling of lastsnap to permit subdirectory specification. * Handle MJPEG streams from some Logitech webcams which send AVI1 instead of JFIF. * Fix missing header for some builds(Jim Dodgen) From cc19f88f7fe8761a5866a24fc93d2fd9c5bea748 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 4 Sep 2015 11:22:52 -0600 Subject: [PATCH 135/233] Updated gitignore --- .gitignore | 1 + config.h.in | 144 ---------------------------------------------------- 2 files changed, 1 insertion(+), 144 deletions(-) delete mode 100644 config.h.in diff --git a/.gitignore b/.gitignore index 6e536cb..f99fee3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ motion config.h config.status +config.h.in Makefile configure motion-dist.conf diff --git a/config.h.in b/config.h.in deleted file mode 100644 index ac42b9c..0000000 --- a/config.h.in +++ /dev/null @@ -1,144 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `get_current_dir_name' function. */ -#undef HAVE_GET_CURRENT_DIR_NAME - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LINUX_VIDEODEV2_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LINUX_VIDEODEV_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have MySQL support */ -#undef HAVE_MYSQL - -/* Define to 1 if you have PostgreSQL support */ -#undef HAVE_PGSQL - -/* Define to 1 if you have SDL support */ -#undef HAVE_SDL - -/* Define to 1 if you have the header file. */ -#undef HAVE_SIGNAL_H - -/* Define to 1 if you have SQLITE3 support */ -#undef HAVE_SQLITE3 - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* The size of `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of `int *', as computed by sizeof. */ -#undef SIZEOF_INT_P - -/* The size of `long int', as computed by sizeof. */ -#undef SIZEOF_LONG_INT - -/* The size of `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - -/* The size of `short', as computed by sizeof. */ -#undef SIZEOF_SHORT - -/* The size of `void *', as computed by sizeof. */ -#undef SIZEOF_VOID_P - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Define to 1 if on MINIX. */ -#undef _MINIX - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const From a02eb478609e5ed133554646ec093bcde3f95254 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 4 Sep 2015 12:16:15 -0600 Subject: [PATCH 136/233] Add additional container options --- CHANGELOG | 4 +++- ffmpeg.c | 30 +++++++++++++++++++++++------- motion-dist.conf.in | 2 ++ netcam_rtsp.c | 1 - 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c58d7b4..3d35572 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ -Summary of Changes +Summary of Changes + * Remove avformat_network_init call. Call was not needed and was leaking memory + * Add extra container options for ffmpeg videos * Remove extra bytes before SOI marker on netcam images. * Updated handling of lastsnap to permit subdirectory specification. * Handle MJPEG streams from some Logitech webcams which send AVI1 instead of JFIF. diff --git a/ffmpeg.c b/ffmpeg.c index 2c2505c..0ba3a51 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -47,6 +47,7 @@ #define MY_CODEC_ID_FFV1 AV_CODEC_ID_FFV1 #define MY_CODEC_ID_NONE AV_CODEC_ID_NONE #define MY_CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO +#define MY_CODEC_ID_H264 AV_CODEC_ID_H264 #else @@ -55,7 +56,7 @@ #define MY_CODEC_ID_FFV1 CODEC_ID_FFV1 #define MY_CODEC_ID_NONE CODEC_ID_NONE #define MY_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO - +#define MY_CODEC_ID_H264 CODEC_ID_H264 #endif /*********************************************/ AVFrame *my_frame_alloc(void){ @@ -72,8 +73,6 @@ void my_frame_free(AVFrame *frame){ #if (LIBAVFORMAT_VERSION_MAJOR >= 55) av_frame_free(&frame); #else - //avcodec_free_frame(&frame); - //av_frame_free(&netcam->rtsp->frame); av_freep(&frame); #endif } @@ -172,6 +171,14 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename){ } else if (strcmp (codec, "ogg") == 0){ ext = ".ogg"; of = av_guess_format ("ogg", NULL, NULL); + } else if (strcmp (codec, "mp4") == 0){ + ext = ".mp4"; + of = av_guess_format ("mp4", NULL, NULL); + of->video_codec = MY_CODEC_ID_H264; + } else if (strcmp (codec, "mkv") == 0){ + ext = ".mkv"; + of = av_guess_format ("matroska", NULL, NULL); + of->video_codec = MY_CODEC_ID_H264; } else { MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg_video_codec option value" " %s is not supported", codec); @@ -207,6 +214,8 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, struct ffmpeg *ffmpeg; int ret; char errstr[128]; + AVDictionary *opts = 0; + /* * Allocate space for our ffmpeg structure. This structure contains all the * codec and image information we need to generate movies. @@ -275,6 +284,11 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->gop_size = 12; c->pix_fmt = PIX_FMT_YUV420P; c->max_b_frames = 0; + if (c->codec_id == AV_CODEC_ID_H264){ + av_dict_set(&opts, "preset", "ultrafast", 0); + av_dict_set(&opts, "crf", "18", 0); + av_dict_set(&opts, "tune", "zerolatency", 0); + } if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; if (vbr) c->flags |= CODEC_FLAG_QSCALE; @@ -285,7 +299,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, } pthread_mutex_lock(&global_lock); - ret = avcodec_open2(c, codec, NULL); + ret = avcodec_open2(c, codec, &opts); pthread_mutex_unlock(&global_lock); if (ret < 0) { if (codec->supported_framerates) { @@ -299,18 +313,20 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, pthread_mutex_lock(&global_lock); while ((chkrate < 36) && (ret != 0)) { c->time_base.den = chkrate; - ret = avcodec_open2(c, codec, NULL); + ret = avcodec_open2(c, codec, &opts); chkrate++; } pthread_mutex_unlock(&global_lock); if (ret < 0){ av_strerror(ret, errstr, sizeof(errstr)); MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Could not open codec %s",errstr); + av_dict_free(&opts); ffmpeg_cleanups(ffmpeg); return NULL; } } + av_dict_free(&opts); MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Selected Output FPS %d", c->time_base.den); ffmpeg->video_outbuf = NULL; @@ -457,7 +473,7 @@ int ffmpeg_put_image(struct ffmpeg *ffmpeg){ //non timelapse buffered is ok if (retcd == -2){ retcd = 0; - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); + MOTION_LOG(DBG, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); } return retcd; @@ -498,7 +514,7 @@ int ffmpeg_put_other_image(struct ffmpeg *ffmpeg, unsigned char *y, //non timelapse buffered is ok if (retcd == -2){ retcd = 0; - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); + MOTION_LOG(DBG, TYPE_ENCODER, NO_ERRNO, "%s: Buffered packet"); } av_free(picture); } diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 99c5832..7992aad 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -322,6 +322,8 @@ ffmpeg_variable_bitrate 0 # ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) # mov - QuickTime ( testing ) # ogg - Ogg/Theora ( testing ) +# mp4 - MPEG-4 Part 14 H264 encoding +# mkv - Matroska H264 encoding ffmpeg_video_codec mpeg4 # Use ffmpeg to deinterlace video. Necessary if you use an analog camera diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 0bcaca0..4430030 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -872,7 +872,6 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){ */ pthread_mutex_lock(&global_lock); av_register_all(); - avformat_network_init(); avcodec_register_all(); pthread_mutex_unlock(&global_lock); From d09bdd19e0f086e712dc47b72cfdafb33e02ec59 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Thu, 30 Jul 2015 13:13:37 +0200 Subject: [PATCH 137/233] To include a linux-specific header like linux/types.h, one should test for the presence of linux rather than the absence of BSD. --- pwc-ioctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwc-ioctl.h b/pwc-ioctl.h index 48a3861..e7f5480 100644 --- a/pwc-ioctl.h +++ b/pwc-ioctl.h @@ -52,7 +52,7 @@ ... the function */ -#if (!defined(BSD)) +#if defined(__linux__) #include #include @@ -309,7 +309,7 @@ struct pwc_table_init_buffer { * use interface offer by v4l2. */ -#if (defined(MOTION_V4L2)) && (!defined(BSD)) +#if (defined(MOTION_V4L2)) && defined(__linux__) #define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0) #define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1) From 5ad825efef2952500977762610753cfaec86e498 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Thu, 30 Jul 2015 13:14:24 +0200 Subject: [PATCH 138/233] Fix build for Debian GNU/kFreeBSD which defines __FreeBSD_kernel__ but not BSD --- conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.h b/conf.h index a9589c2..cc372c8 100644 --- a/conf.h +++ b/conf.h @@ -86,7 +86,7 @@ struct config { int tuner_number; int timelapse; const char *timelapse_mode; -#if (defined(BSD)) +#if (defined(BSD) || defined(__FreeBSD_kernel__)) const char *tuner_device; #endif const char *video_device; From 6a1b25876350ae1330b1aba7dcb5b5f638c157b1 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 4 Sep 2015 13:03:25 -0600 Subject: [PATCH 139/233] Remove depreciated deinterlace option --- CHANGELOG | 1 + conf.c | 22 +++++++--------------- conf.h | 1 - motion-dist.conf.in | 5 ----- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3d35572..cdd1b25 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Remove depreciated deinterlace option * Remove avformat_network_init call. Call was not needed and was leaking memory * Add extra container options for ffmpeg videos * Remove extra bytes before SOI marker on netcam images. diff --git a/conf.c b/conf.c index 9b0019c..36c66f5 100644 --- a/conf.c +++ b/conf.c @@ -679,15 +679,6 @@ config_param config_params[] = { print_string }, { - "ffmpeg_duplicate_frames", - "# True to duplicate frames to achieve \"framerate\" fps, but enough\n" - "duplicated frames and the video appears to freeze once a second.", - 0, - CONF_OFFSET(ffmpeg_duplicate_frames), - copy_bool, - print_bool - }, - { "output_debug_pictures", "# Output pictures with only the pixels moving object (ghost images) (default: off)", 0, @@ -787,19 +778,20 @@ config_param config_params[] = { "# flv - gives you a flash video with extension .flv\n" "# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )\n" "# mov - QuickTime ( testing )\n" - "# ogg - Ogg/Theora ( testing )", + "# ogg - Ogg/Theora ( testing )\n" + "# mp4 - MPEG-4 Part 14 H264 encoding\n" + "# mkv - Matroska H264 encoding", 0, CONF_OFFSET(ffmpeg_video_codec), copy_string, print_string }, { - "ffmpeg_deinterlace", - "# Use ffmpeg to deinterlace video. Necessary if you use an analog camera\n" - "# and see horizontal combing on moving objects in video or pictures.\n" - "# (default: off)", + "ffmpeg_duplicate_frames", + "# True to duplicate frames to achieve \"framerate\" fps, but enough\n" + "duplicated frames and the video appears to freeze once a second.", 0, - CONF_OFFSET(ffmpeg_deinterlace), + CONF_OFFSET(ffmpeg_duplicate_frames), copy_bool, print_bool }, diff --git a/conf.h b/conf.h index cc372c8..d1e88ca 100644 --- a/conf.h +++ b/conf.h @@ -64,7 +64,6 @@ struct config { int ffmpeg_output_debug; int ffmpeg_bps; int ffmpeg_vbr; - int ffmpeg_deinterlace; const char *ffmpeg_video_codec; #ifdef HAVE_SDL int sdl_threadnr; diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 7992aad..06865da 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -326,11 +326,6 @@ ffmpeg_variable_bitrate 0 # mkv - Matroska H264 encoding ffmpeg_video_codec mpeg4 -# Use ffmpeg to deinterlace video. Necessary if you use an analog camera -# and see horizontal combing on moving objects in video or pictures. -# (default: off) -ffmpeg_deinterlace off - # When creating videos, should frames be duplicated in order # to keep up with the requested frames per second # (default: true) From 90a97c05eb716ffb642c8235517ed51072760bec Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 4 Sep 2015 16:49:38 -0600 Subject: [PATCH 140/233] Ffmpeg container fixes --- CHANGELOG | 1 + ffmpeg.c | 13 ++++++++++--- ffmpeg.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cdd1b25..61720ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Additional container fixes * Remove depreciated deinterlace option * Remove avformat_network_init call. Call was not needed and was leaking memory * Add extra container options for ffmpeg videos diff --git a/ffmpeg.c b/ffmpeg.c index 0ba3a51..93b68a4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -284,12 +284,12 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->gop_size = 12; c->pix_fmt = PIX_FMT_YUV420P; c->max_b_frames = 0; - if (c->codec_id == AV_CODEC_ID_H264){ + + if (c->codec_id == MY_CODEC_ID_H264){ av_dict_set(&opts, "preset", "ultrafast", 0); av_dict_set(&opts, "crf", "18", 0); av_dict_set(&opts, "tune", "zerolatency", 0); } - if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; if (vbr) c->flags |= CODEC_FLAG_QSCALE; if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || @@ -563,7 +563,14 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ av_free_packet(&pkt); return -2; } - pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts = av_rescale_q(pkt.pts, + ffmpeg->video_st->codec->time_base, + ffmpeg->video_st->time_base); + if (pkt.dts != AV_NOPTS_VALUE) + pkt.dts = av_rescale_q(pkt.dts, + ffmpeg->video_st->codec->time_base, + ffmpeg->video_st->time_base); if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) pkt.flags |= AV_PKT_FLAG_KEY; } diff --git a/ffmpeg.h b/ffmpeg.h index 46737d4..71928e3 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -8,6 +8,7 @@ #include #include +#include #endif /* HAVE_FFMPEG */ From cb7dcc3018c0d6d998aaae81141e19c9021d7541 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Fri, 4 Sep 2015 20:39:09 -0600 Subject: [PATCH 141/233] Add preview to webcontrol --- CHANGELOG | 1 + conf.c | 20 +++++++++++++++++++- conf.h | 2 ++ motion-dist.conf.in | 7 +++++++ webhttpd.c | 45 +++++++++++++++++++++++++++++++++++---------- 5 files changed, 64 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 61720ab..b316557 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Add preview to webcontrol page * Additional container fixes * Remove depreciated deinterlace option * Remove avformat_network_init call. Call was not needed and was leaking memory diff --git a/conf.c b/conf.c index 36c66f5..77be20e 100644 --- a/conf.c +++ b/conf.c @@ -96,6 +96,8 @@ struct config conf_template = { stream_limit: 0, stream_auth_method: 0, stream_authentication: NULL, + stream_preview_scale: 25, + stream_preview_newline: 0, webcontrol_port: 0, webcontrol_localhost: 1, webcontrol_html_output: 1, @@ -898,7 +900,7 @@ config_param config_params[] = { copy_string, print_string }, - { + { "text_changes", "# Draw the number of changed pixed on the images (default: off)\n" "# Will normally be set to off except when you setup and adjust the motion settings\n" @@ -1102,6 +1104,22 @@ config_param config_params[] = { print_string }, { + "stream_preview_scale", + "# Percentage to scale the preview stream image (default: 25)\n", + 0, + CONF_OFFSET(stream_preview_scale), + copy_int, + print_int + }, + { + "stream_preview_newline", + "# Have stream preview image start on a new line (default: no)\n", + 0, + CONF_OFFSET(stream_preview_newline), + copy_bool, + print_bool + }, + { "webcontrol_port", "\n############################################################\n" "# HTTP Based Control\n" diff --git a/conf.h b/conf.h index d1e88ca..c4c8723 100644 --- a/conf.h +++ b/conf.h @@ -77,6 +77,8 @@ struct config { int stream_limit; int stream_auth_method; const char *stream_authentication; + int stream_preview_scale; + int stream_preview_newline; int webcontrol_port; int webcontrol_localhost; int webcontrol_html_output; diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 06865da..f7cbe88 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -507,6 +507,13 @@ stream_auth_method 0 # Default: not defined (Disabled) ; stream_authentication username:password +# Percentage to scale the stream image for preview +# Default: 25 +; stream_preview_scale 25 + +# Have stream preview image start on a new line +# Default: no +; stream_preview_newline no ############################################################ # HTTP Based Control diff --git a/webhttpd.c b/webhttpd.c index 3693ae8..e2047ae 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -1965,25 +1965,50 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat /* ROOT_URI -> GET / */ if (!strcmp(url, "/")) { int y; + int counter; + + //Send the webcontrol section if applicable if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "Motion "VERSION" Running [%hu] Threads
                                                          \n" - "All
                                                          \n", i); + "All\n", i); send_template(client_socket, res); + + counter = 0; for (y = 1; y < i; y++) { - sprintf(res, "Thread %hu
                                                          \n", y, y); + counter++; + if (counter == 6){ + sprintf(res, "
                                                          "); + send_template(client_socket, res); + counter = 0; + } + sprintf(res, "Thread %hu\n", y, y); send_template(client_socket, res); } - send_template_end_client(client_socket); + sprintf(res, "
                                                          "); + send_template(client_socket, res); } else { - send_template_ini_client_raw(client_socket); - sprintf(res, "Motion "VERSION" Running [%hu] Threads\n0\n", i); - send_template_raw(client_socket, res); - for (y = 1; y < i; y++) { - sprintf(res, "%hu\n", y); - send_template_raw(client_socket, res); + send_template_ini_client(client_socket, ini_template); + sprintf(res, "Motion "VERSION" Running [%hu] Threads
                                                          \n", i); + send_template(client_socket, res); + } + //Send the preview section + for (y = 0; y < i; y++) { + if (cnt[y]->conf.stream_port) { + if (cnt[y]->conf.stream_preview_newline) { + sprintf(res, "
                                                          "); + send_template(client_socket, res); + } + sprintf(res, " " + "" + ,cnt[y]->conf.stream_port + ,cnt[y]->conf.stream_port + ,cnt[y]->conf.stream_preview_scale); + send_template(client_socket, res); } } + send_template_end_client(client_socket); + } else { char command[256] = {'\0'}; char slash; @@ -2231,7 +2256,7 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) nread = read_nonblock(client_socket, buffer, length); if (nread <= 0) { - MOTION_LOG(ERR, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd First Read Error"); + MOTION_LOG(DBG, TYPE_STREAM, SHOW_ERRNO, "%s: motion-httpd First Read Error"); pthread_mutex_unlock(&httpd_mutex); return 1; } else { From 0f45a713a77f97a7cb52a2cc913363914cb3ce8b Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 5 Sep 2015 10:09:55 -0600 Subject: [PATCH 142/233] Remote preview fixes --- CHANGELOG | 8 ++++---- webhttpd.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b316557..b2065f7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ Summary of Changes - * Add preview to webcontrol page - * Additional container fixes + * Add preview to webcontrol page(closes 172526) + * Additional container fixes(closes requests/bugs 201900,110304,001656,050731) * Remove depreciated deinterlace option * Remove avformat_network_init call. Call was not needed and was leaking memory * Add extra container options for ffmpeg videos @@ -22,11 +22,11 @@ Summary of Changes * Revise version number generated by script to indicate Unofficial-Git-'hash' * Revised Changelog description for version 3.4 * Merge OpenBSD fixes from sthen pull request - * Revised picture.c to allow for modulo 8 pictures and adjusted netcam modules accordingly as well. + * Revised picture.c to allow for modulo 8 pictures and adjusted netcam modules accordingly as well.(closes 135313) * Changes to ffmpeg.h/ffmpeg.c to allow for compiling without ffmpeg/libav or with older versions. * Merge mymalloc, free and casting changes from Alfred Klomp * Merge bug fix for sizeof from Alfred Klomp - * Rewrote timelapse so that it works + * Rewrote timelapse so that it works(closes 180501) * Merge tosiara changes for version number * Add copyright file for features added since 3.2.12 * Cleanup ffmpeg.c and plug memory leak diff --git a/webhttpd.c b/webhttpd.c index e2047ae..302e1d4 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -1966,6 +1966,7 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat if (!strcmp(url, "/")) { int y; int counter; + char hostname[1024]; //Send the webcontrol section if applicable if (cnt[0]->conf.webcontrol_html_output) { @@ -1993,16 +1994,19 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat send_template(client_socket, res); } //Send the preview section + hostname[1023] = '\0'; + gethostname(hostname, 1023); + for (y = 0; y < i; y++) { if (cnt[y]->conf.stream_port) { if (cnt[y]->conf.stream_preview_newline) { sprintf(res, "
                                                          "); send_template(client_socket, res); } - sprintf(res, " " - "" - ,cnt[y]->conf.stream_port - ,cnt[y]->conf.stream_port + sprintf(res, " " + "" + ,hostname,cnt[y]->conf.stream_port + ,hostname,cnt[y]->conf.stream_port ,cnt[y]->conf.stream_preview_scale); send_template(client_socket, res); } From 33b7d4f0453e69fb62ac19791fb937c0ca47a1e6 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 5 Sep 2015 13:08:41 -0600 Subject: [PATCH 143/233] Clean tabs for issue 071831 patch --- CHANGELOG | 1 + conf.c | 30 +++++++++++++++--------------- logger.c | 4 ++-- webhttpd.c | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b2065f7..ec92d46 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Tab/Space cleanup and validation security issue addressed. (closes 071831) * Add preview to webcontrol page(closes 172526) * Additional container fixes(closes requests/bugs 201900,110304,001656,050731) * Remove depreciated deinterlace option diff --git a/conf.c b/conf.c index 77be20e..9b157fa 100644 --- a/conf.c +++ b/conf.c @@ -1628,23 +1628,23 @@ static void conf_cmdline(struct context *cnt, int thread) cnt->log_level = (unsigned int)atoi(optarg); break; case 'k': - if (thread == -1) { - strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); - cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->log_type_str, optarg, sizeof(cnt->log_type_str) - 1); + cnt->log_type_str[sizeof(cnt->log_type_str) - 1] = '\0'; + } + break; case 'p': - if (thread == -1) { - strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); - cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->pid_file, optarg, sizeof(cnt->pid_file) - 1); + cnt->pid_file[sizeof(cnt->pid_file) - 1] = '\0'; + } + break; case 'l': - if (thread == -1) { - strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); - cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; - } - break; + if (thread == -1) { + strncpy(cnt->log_file, optarg, sizeof(cnt->log_file) - 1); + cnt->log_file[sizeof(cnt->log_file) - 1] = '\0'; + } + break; case 'm': cnt->pause = 1; break; diff --git a/logger.c b/logger.c index aa47753..2ecf143 100644 --- a/logger.c +++ b/logger.c @@ -220,8 +220,8 @@ void motion_log(int level, unsigned int type, int errno_flag, const char *fmt, . // just knock off 10 characters if we're that close... if (buf_len + 10 > 1024) { - buf[1024 - 10] = '\0'; - buf_len = 1024 - 10; + buf[1024 - 10] = '\0'; + buf_len = 1024 - 10; } strncat(buf, ": ", 1024 - buf_len); diff --git a/webhttpd.c b/webhttpd.c index 302e1d4..f7b791a 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -381,8 +381,8 @@ static void url_decode(char *urlencoded, size_t length) *urldecoded++ = c[1]; } - } else if (*data == '<' || *data == '+' || *data == '>') { - *urldecoded++ = ' '; + } else if (*data == '<' || *data == '+' || *data == '>') { + *urldecoded++ = ' '; } else { *urldecoded++ = *data; } From 320732d97bb4ebfe44ff8a4fff8b73e244629c4e Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 5 Sep 2015 23:34:50 -0600 Subject: [PATCH 144/233] Update manual --- CHANGELOG | 1 + motion.1 | 2945 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 2042 insertions(+), 904 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ec92d46..a4d6a44 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Revise manual to have current options. * Tab/Space cleanup and validation security issue addressed. (closes 071831) * Add preview to webcontrol page(closes 172526) * Additional container fixes(closes requests/bugs 201900,110304,001656,050731) diff --git a/motion.1 b/motion.1 index 6713386..1fb9587 100644 --- a/motion.1 +++ b/motion.1 @@ -1,904 +1,2041 @@ -.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 -[ \-bhmns ] [ \-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 -and motion pictures will be taken. Motion can also take actions to notify you -if needed. Creation of automated snapshots is also possible. -.SH OPTIONS -.TP -.B \-c -Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc/motion unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default. -.TP -.B \-h -Show help screen. -.TP -.B \-m -Disable motion detection at startup. -.TP -.B \-b -Run in background (daemon) mode. -.TP -.B \-n -Run in non-daemon mode. -.TP -.B \-s -Run in setup mode. Also forces non-daemon mode -.TP -.B \-d log level -Set log level [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) -.TP -.B \-k log type -Set type of log (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) -.TP -.B \-p -Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. -.TP -.B \-l -Full path and filename of log file. ( use \-l syslog to log to stderr and syslog ) -.TP -.SH "CONFIG FILE OPTIONS" -These are the options that can be used in the config file. -.I They are overridden by the commandline! -All number values are integer numbers (no decimals allowed). -Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). -.TP -.B area_detect integer -Values: 0 - 999999999 / Default: Not defined -.br -Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 -.br -A script (on_area_detected) is started immediately when motion is 4 5 6 -.br -detected in one of the given areas, but only once during an event. 7 8 9 -.br -One or more areas can be specified with this option. Take care: This option does NOT restrict detection to these areas! (Default: not defined) -.TP -.B auto_brightness boolean -Values: on, off / Default: off -.br -Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness -.TP -.B brightness integer -Values: 0 - 255 / Default: 0 (disabled) -.br -The brightness level for the video device. -.TP -.B contrast boolean -Values: 0 - 255 / Default: 0 (disabled) -.br -The contrast level for the video device. -.TP -.B daemon boolean -Values: on, off / Default: off -.br -Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. -.TP -.B database_dbname string -Values: Max 4095 characters / Default: Not defined -.br -Name of the database. -.TP -.B database_host string -Values: Max 4095 characters / Default: localhost -.br -IP address or domain name for the database server. Use "localhost" if motion and database runs on the same server. -.TP -.B database_password string -Values: Max 4095 characters / Default: Not defined -.br -The database password. -.TP -.B database_port integer -Values: 0 - 65535 / Default: Not defined -.br -The database server port number. -.TP -.B database_type discrete strings -Values: mysql, postgresql / Default: Not defined -.br -The database type ( mysql , postgresql ). -.TP -.B database_user string -Values: Max 4095 characters / Default: Not defined -.br -The database user name. -.TP -.B despeckle_filter string -Values: EedDl / Default: Not defined -.br -Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. -.TP -.B emulate_motion boolean -Values: on, off / Default: off -.br -Picture are saved continuously as if motion was detected all the time. -.TP -.B event_gap integer -Values: 0 - 2147483647 / Default: 60 -.br -Event Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. -.TP -.B exif_text string -Values: Max 4095 characters / Default: Not defined -.br -Text to include in a JPEG EXIF comment , may be any text, including conversion specifiers. The EXIF timestamp is included independent of this text. -.TP -.B extpipe string -Values: Max 4095 characters / Default: Not defined -.br -pipe raw video to generally - 'STDIN', allowing to use an external video encoder. -.br -e.g. using memcoder : -.br -extpipe mencoder \-demuxer rawvideo \-rawvideo w=320:h=240:i420 \-ovc x264 \-x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt: threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me \-vf denoise3d=16:12:48:4,pp=lb \-of avi \-o %f.avi \- \-fps %fps -.TP -.B ffmpeg_bps integer -Values: 0 - 9999999 / Default: 400000 -.br -Bitrate of movies produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. -.TP -.B ffmpeg_output_debug_movies boolean -Values: on, off / Default: off -.br -Use ffmpeg libraries to encode motion type movies where you only see the pixels that changes. -.TP -.B ffmpeg_output_movies boolean -Values: on, off / Default: off -.br -Use ffmpeg libraries to encode movies in realtime. -.TP -.B ffmpeg_deinterlace boolean -Values: on, off / Default: off -.br -Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. -.TP -.B ffmpeg_timelapse integer -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. -.TP -.B ffmpeg_timelapse_mode discrete strings -Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual / Default: daily -.br -The file rollover mode of the timelapse video. -.TP -.B ffmpeg_variable_bitrate integer -Values: 0, 2 - 31 / Default: 0 (disabled) -.br -Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. -.TP -.B ffmpeg_video_codec discrete strings -Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf , flv , ffv1, mov, ogg / Default: mpeg4 -.br -Codec to be used by ffmpeg for the video compression. Timelapse movies are always made in mpeg1 format independent from this option. -.TP -.B framerate integer -Values: 2 - 100 / Default: 100 (no limit) -.br -Maximum number of frames to be captured from the camera per second. -.TP -.B frequency integer -Values: 0 - 999999 / Default: 0 (Not set) -.br -The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) -.TP -.B height integer -Values: Device Dependent / Default: 288 -.br -The height of each frame in pixels. -.TP -.B hue integer -Values: 0 - 255 / Default: 0 (disabled) -.br -The hue level for the video device. -.TP -.B input integer -Values: \-1 - 64, \-1 = disabled / Default: \-1 (disabled) -.br -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 -.br -Enable or disable IPV6 for http control and stream. -.TP -.B lightswitch integer -Values: 0 - 100 / Default: 0 (disabled) -.br -Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. -.TP -.B locate_motion discrete strings -Values: on, off, redbox, center, redcross, preview / Default: off -.br -Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved movie. -.TP -.B logfile string -Values: Max 4095 characters / Default: Not defined -.br -Use a file to save logs messages, if not defined stderr and syslog is used. -.TP -.B logfile string -Values: Max 4095 characters / Default: Not defined -.br -Use a file to save logs messages, if not defined stderr and syslog is used. ( if syslog is set then will log to stderr and syslog ) -.TP -.B log_level integer -Values: 1 - 9 / Default: 6 -.br -Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, ERR, DBG, ALL). (default: 6 / NTC). -.TP -.B log_type discrete strings -Values: STR, ENC, NET, DBL, EVT, TRK, VID, ALL / Default: ALL -.br -Filter to log messages by type (STR, ENC, NET, DBL, EVT, TRK, VID, ALL). -.TP -.B mask_file string -Values: Max 4095 characters / Default: Not defined -.br -PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. -.TP -.B max_movie_time integer -Values: 0 (infinite) - 2147483647 / Default: 3600 -.br -The maximum length of a movie in seconds. Set this to zero for unlimited length. -.TP -.B minimum_frame_time integer -Values: 0 - 2147483647 / Default: 0 -.br -Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. -.TP -.B minimum_motion_frames integer -Values: 1 - 1000s / Default: 1 -.br -Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. -.TP -.B motion_video_pipe string -Values: Max 4095 characters / Default: Not defined -.br -The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set -.TP -.B movie_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S -.br -File path for motion triggered ffmpeg movies relative to target_dir. This was previously called ffmpeg_filename. -.TP -.B netcam_tolerant_check boolean -Values: on, off / Default: off -.br -Set less strict jpeg checks for network cameras with a poor/buggy firmware. -.TP -.B netcam_keepalive discrete string -Values: off , force, on / Default: off -.br -The setting for keep-alive of network socket, should improve performance on compatible net cameras. -.TP -.B netcam_proxy string -Values: Max 4095 characters / Default: Not defined -.br -URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber -.TP -.B netcam_url string -Values: Max 4095 characters / Default: Not defined -.br -Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. -.br -http:// ftp:// mjpg:// or file:/// ( mjpg:// is for network cameras with codec mjpeg ). -.TP -.B netcam_userpass string -Values: Max 4095 characters / Default: Not defined -.br -For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. -.TP -.B noise_level integer -Values: 1 - 255 / Default: 32 -.br -The noise level is used as a threshold for distinguishing between noise and motion. -.TP -.B noise_tune boolean -Values: on, off / Default: on -.br -Activates the automatic tuning of noise level. -.TP -.B norm integer -Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) / Default: 0 (PAL) -.br -Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) -.TP -.B on_area_detected string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when motion in a predefined area is detected, check option area_detect. -.TP -.B on_camera_lost -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B on_event_end string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option event_gap. You can use Conversion Specifiers and spaces as part of the command. -.TP -.B on_event_start string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by event_gap. You can use ConversionSpecifiers and spaces as part of the command. -.TP -.B on_motion_detected string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. -.TP -.B on_movie_end string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B on_movie_start string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when a movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B on_picture_save string -Values: Max 4095 characters / Default: Not defined -.br -Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -.TP -.B output_debug_pictures boolean -Values: on, off / Default: off -.br -Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. -.TP -.B output_pictures discrete strings -Values: on, off, first, best, center / Default: on -.br -Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. -.TP -.B picture_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-%q -.br -File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved movie file. -.TP -.B picture_type discrete strings -Values: jpeg , ppm / Default: jpeg -.br -Type of images motion will trigger when motion is detected. -.TP -.B post_capture integer -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Specifies the number of frames to be captured after motion has been detected. -.TP -.B pre_capture integer -Values: 0 - 100s / Default: 0 (disabled) -.br -Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth movies. To smooth movies use larger values of post_capture instead. -.TP -.B process_id_file string -Values: Max 4095 characters / Default: Not defined -.br -File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid -.TP -.B quality integer -Values: 1 - 100 / Default: 75 -.br -The quality for the jpeg images in percent. -.TP -.B quiet boolean -Values: on, off / Default: off -.br -Be quiet, don't output beeps when detecting motion. -.TP -.B rotate discrete strings -Values: 0, 90, 180, 270 / Default: 0 (not rotated) -.br -Rotate image the given number of degrees. The rotation affects all saved images as well as movies. -.TP -.B roundrobin_frames integer -Values: 1 - 2147483647 / Default: 1 -.br -Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. -.TP -.B roundrobin_skip integer -Values: 1 - 2147483647 / Default: 1 -.br -Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). -.TP -.B saturation integer -Values: 0 - 255 / Default: 0 (disabled) -.br -The colour saturation level for the video device. -.TP -.B sdl_threadnr -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Number of motion thread to show in SDL Window (default: 0 = disabled) -.TP -.B setup_mode boolean -Values: on, off / Default: off -.br -Run Motion in setup mode. -.TP -.B smart_mask_speed integer -Values: 0 - 10 / Default: 0 (disabled) -.br -Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. -.TP -.B snapshot_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d%H%M%S-snapshot -.br -File path for snapshots (jpeg or ppm) relative to target_dir. -.TP -.B snapshot_interval integer -Values: 0 - 2147483647 / Default: 0 (disabled) -.br -Make automated snapshots every 'snapshot_interval' seconds. -.TP -.B sql_log_picture boolean -Values: on, off / Default: on -.br -Log to the database when creating motion triggered image file. -.TP -.B sql_log_movie boolean -Values: on, off / Default: off -.br -Log to the database when creating motion triggered movie file. -.TP -.B sql_log_snapshot boolean -Values: on, off / Default: on -.br -Log to the database when creating a snapshot image file. -.TP -.B sql_log_timelapse boolean -Values: on, off / Default: off -.br -Log to the database when creating timelapse movie file -.TP -.B sql_query string -Values: Max 4095 characters / Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -.br -SQL query string that is sent to the database. The values for each field are given by using convertion specifiers -.TP -.B stream_auth_method integer -Values: 0 = disabled , 1 = Basic authentication ,2 = MD5 digest (the safer authentication). / Default: 0 (disabled) -.br -Set the authentication method for stream. -.TP -.B stream_authentication string -Values: username:password / Default: not defined (disabled) -.br -Authentication for the stream. -.TP -.B stream_limit integer -Values: 0 - 2147483647 / Default: 0 (unlimited) -.br -Limit the number of frames to number frames. After 'stream_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. -.TP -.B stream_localhost boolean -Values: on, off / Default: on -.br -Limits the access to the stream to the localhost. -.TP -.B stream_maxrate integer -Values: 1 - 100 / Default: 1 -.br -Limit the framerate of the stream in frames per second. Default is 1. Set the value to 100 for practically unlimited. -.TP -.B stream_motion boolean -Values: on, off / Default: off -.br -If set to 'on' Motion sends slows down the stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by stream_maxrate. When 'off' the stream always runs as defined by stream_maxrate. -.TP -.B stream_port integer -Values: 0 - 65535 / Default: 0 (disabled) -.br -TCP port on which motion will listen for incoming connects with its stream server. -.TP -.B stream_quality integer -Values: 1 - 100 / Default: 50 -.br -Quality setting in percent for the mjpeg picture frames transferred over the stream connection. Keep it low to restrict needed bandwidth. -.TP -.B switchfilter boolean -Values: on, off / Default: off -.br -Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. -.TP -.B target_dir string -Values: Max 4095 characters / Default: Not defined = current working directory -.br -Target directory for picture and movie files. -.TP -.B text_changes boolean -Values: on, off / Default: off -.br -Turns the text showing changed pixels on/off. -.TP -.B text_double boolean -Values: on, off / Default: off -.br -Draw characters at twice normal size on images. -.TP -.B text_event string -Values: Max 4095 characters / Default: %Y%m%d%H%M%S -.br -This option defines the value of the special event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. -.TP -.B text_left string -Values: Max 4095 characters / Default: Not defined -.br -User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \\n and conversion specifiers (codes starting by a %). -.TP -.B text_right string -Values: Max 4095 characters / Default: %Y-%m-%d\\n%T -.br -User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \\n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\\n%T = date in ISO format and time in 24 hour clock -.TP -.B thread string -Values: Max 4095 characters / Default: Not defined -.br -Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file. -.TP -.B threshold integer -Values: 1 - 2147483647 / Default: 1500 -.br -Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. -.TP -.B threshold_tune boolean -Values: on, off / Default: off -.br -Activates the automatic tuning of threshold level. -.TP -.B timelapse_filename string -Values: Max 4095 characters / Default: %v-%Y%m%d-timelapse -.br -File path for timelapse movies relative to target_dir (ffmpeg only). -.TP -.B track_auto boolean -Values: on, off / Default: off -.br -Enable auto tracking -.TP -.B track_iomojo_id integer -Values: 0 - 65535 / Default: 0 -.br -Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. -.TP -.B track_maxx integer -Values: 0 - 65535 / Default: 0 -.br -The maximum position for servo x. -.TP -.B track_maxy integer -Values: 0 - 65535 / Default: 0 -.br -The maximum position for servo y. -.TP -.B track_motorx integer -Values: 0 - 65535 / Default: 0 -.br -The motor number that is used for controlling the x-axis. -.TP -.B track_motory integer -Values: 0 - 65535 / Default: 0 -.br -The motor number that is used for controlling the y-axis. -.TP -.B track_move_wait integer -Values: 0 - 65535 / Default: 10 -.br -Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. -.TP -.B track_port string -Values: Max 4095 characters / Default: Not defined -.br -This is the device name of the serial port to which the stepper motor interface is connected. -.TP -.B track_speed integer -Values: 0 - 255 / Default: 255 -.br -Speed to set the motor to. -.TP -.B track_step_angle_x integer -Values: 0-90 / Default: 10 -.br -Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. -.TP -.B track_step_angle_y integer -Values: 0-40 / Default: 10 -.br -Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. -.TP -.B track_stepsize integer -Values: 0 - 255 / Default: 40 -.br -Number of steps to make. -.TP -.B track_type discrete strings -Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) / Default: 0 (None) -.br -Type of tracker. -.TP -.B tunerdevice string -Values: Max 4095 characters / Default: /dev/tuner0 -.br -The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. -.TP -.B use_extpipe boolean -Values: on, off / Default: off -.br -Enables extpipe to use an external video encoder feeding with YUV420 using a pipe . -.TP -.B v4l2_palette discrete strings -Values: 0 - 8 / Default: 8 -.br -Allow to choose preferable palette to be use by motion to capture from those supported by your videodevice. -.TP -.B video_pipe string -Values: Max 4095 characters / Default: Not defined -.br -The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. -.TP -.B videodevice string -Values: Max 4095 characters / Default: /dev/video0 (FreeBSD: /dev/bktr0) -.br -The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. -.TP -.B webcontrol_authentication string -Values: Max 4096 characters / Default: Not defined -.br -To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username: password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. -.TP -.B webcontrol_html_output boolean -Values: on, off / Default: on -.br -Enable HTML in the answer sent back to a browser connecting to the webcontrol_port. This option must be placed in motion.conf and not in a thread config file. -.TP -.B webcontrol_localhost boolean -Values: on, off / Default: on -.br -Limits the webcontrol to the localhost. This option must be placed in motion.conf and not in a thread config file. -.TP -.B webcontrol_port integer -Values: 0 - 65535 / Default: 0 (disabled) -.br -Sets the port number for the http (html using browser) based remote webcontrol. This option must be placed in motion.conf and not in a thread config file. - -.TP -.B width integer -Values: Device Dependent / Default: 352 -.br -The width in pixels of each frame. Valid range is camera dependent. - -.SH SIGNALS -Motion responds to the following signals: -.TP -.B SIGHUP -The config file will be reread. -.TP -.B SIGTERM -If needed motion will create a movie file of the last event and exit -.TP -.B SIGUSR1 -Motion will create a movie file of the current event. -.SH NOTES -.TP -.B Snapshot -A snapshot is a picture taken at regular intervals independently of any movement in the picture. -.TP -.B Motion image -A "motion" image/movie shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. -.TP -.B Normal image -A "normal" image is the real image taken by the camera with text overlayed. -.TP -.B Threads and config files -If Motion was invoked with command line option \-c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with \-c you can call it anything. -.br -If you do not specify \-c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: -.br -1. Current directory from where motion was invoked -.br -2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf -.br -3. The directory defined by the \-\-sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) -.br -If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file in the default /usr/local/etc/motion directory. -.br -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc/motion directory. -.br -The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. -.br -If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. -.br -So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. -.br -An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). -.br -An option that is unique to a camera must be defined in each thread file. -.br -The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. -.br -Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. -.br -Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins. -.br -1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. -.br -2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. -.br -3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. -.br -4. Motion reads the command line option again overruling any previously defined options. -.br -So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. -.br -If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. -.br -If you run the webcontrol command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. -.TP -.B Conversion Specifiers for Advanced Filename and Text Features -The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, picture_filename, movie_filename, timelapse_filename, on_area_detected, on_camera_lost, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. -.br -In text_left and text_right you can additionally use '\\n' for new line. - -.TP -.B %a -The abbreviated weekday name according to the current locale. -.TP -.B %A -The full weekday name according to the current locale. -.TP -.B %b -The abbreviated month name according to the current locale. -.TP -.B %B -The full month name according to the current locale. -.TP -.B %c -The preferred date and time representation for the current locale. -.TP -.B %C -Text defined by the text_event feature -.TP -.B %d -The day of the month as a decimal number (range 01 to 31). -.TP -.B %D -Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. -.TP -.B %E -Modifier: use alternative format, see below. -.TP -.B %f -File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. -.TP -.B %F -Equivalent to %Y-%m-%d (the ISO 8601 date format). -.TP -.B %H -The hour as a decimal number using a 24-hour clock (range 00 to 23). -.TP -.B %i -Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate_motion is on). -.TP -.B %I -The hour as a decimal number using a 12-hour clock (range 01 to 12). -.TP -.B %j -The day of the year as a decimal number (range 001 to 366). -.TP -.B %J -Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate_motion is on). -.TP -.B %k -The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) -.TP -.B %K -X coordinate in pixels of the center point of motion. Origin is upper left corner. -.TP -.B %l -The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) -.TP -.B %L -Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). -.TP -.B %m -The month as a decimal number (range 01 to 12). -.TP -.B %M -The minute as a decimal number (range 00 to 59). -.TP -.B %n -Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. -.TP -.B %N -Noise level. -.TP -.B %o -Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. -.TP -.B %p -Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. -.TP -.B %P -Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. -.TP -.B %q -Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for movies. -.TP -.B %Q -Number of detected labels found by the despeckle feature -.TP -.B %r -The time in a.m. or p.m. notation. -.TP -.B %R -The time in 24-hour notation (%H:%M). -.TP -.B %s -The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. -.TP -.B %S -The second as a decimal number (range 00 to 61). -.TP -.B %t -Thread number (camera number) -.TP -.B %T -The time in 24-hour notation (%H:%M:%S). -.TP -.B %u -The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. -.TP -.B %U -The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. -.TP -.B %v -Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. -.TP -.B %V -The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. -.TP -.B %w -The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. -.TP -.B %W -The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. -.TP -.B %x -The preferred date representation for the current locale without the time. -.TP -.B %X -The preferred time representation for the current locale without the date. -.TP -.B %y -The year as a decimal number without a century (range 00 to 99). -.TP -.B %Y -The year as a decimal number including the century. -.TP -.B %z -The time-zone as hour offset from GMT. -.TP -.B %Z -The time zone or name or abbreviation. - -.TP -.B More information -Motion homepage: http://motion.sourceforge.net/ - -Motion Guide (user and installation guide): -.br -http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide -.br -http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice -.SH AUTHORS -Jeroen Vreeken (pe1rxq@amsat.org), -Folkert van Heusden, -Kenneth Lavrsen (kenneth@lavrsen.dk) +.TH MOTION 1 2007-11-06 "Motion" "Motion Options and Config Files" +.SH NAME +motion \- Detct motion using a video4linux device or network camera +.SH SYNOPSIS +.B motion [ -hbnsm ] [ -c config file path ] [ -d level ] [ -k level ] [ -p process_id_file ][ -l log_file ] +.SH DESCRIPTION +.I Motion +uses a video4linux device or network camera to detect motion. If motion is detected both normal +and motion pictures can be taken. Motion can also take actions to notify you +if needed. Creation of automated snapshots is also possible. +.SH OPTIONS +.TP +.B \-c +Full path and filename of config file. +For example: \fI /home/kurt/motion.conf \fR +The default is \fI /usr/local/etc/motion\fR unless specified differently when building Motion. +Many RPMs and Debian packages will use \fI/etc\fR or \fI/etc/motion\fR as the default. +.TP +.B \-h +Show help screen. +.TP +.B \-b +Run in daemon mode. +.TP +.B \-n +Run in non-daemon mode. +.TP +.B \-s +Run in setup mode. Also forces non-daemon mode +.TP +.B \-d +Run with message log level 1-9. +.TP +.B \-k +Run with message log type 1-9 +.TP +.B \-l +Full path and file name for the log file +.TP +.B \-p +Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. +.TP +.B \-m +Start in pause mode +.TP +.SH "CONFIG FILE OPTIONS" +These are the options that can be used in the config file. +.I They are overridden by the commandline! +All number values are integer numbers (no decimals allowed). +Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). + +.TP +.B daemon +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +When specified as ON, Motion goes into daemon (background process) mode and releases the terminal. +.RE +.RE + +.TP +.B process_id_file +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +File to store the process ID, also called pid file. +.RE +.RE + +.TP +.B setup_mode +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Start in Setup-Mode, daemon disabled. +.RE +.RE + +.TP +.B logfile +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +File to save logs messages, if not defined stderr and syslog is used. +.RE +.RE + +.TP +.B log_level +.RS +.nf +Values: 1 to 9 (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL) +Default: 6 / NTC +Description: +.fi +.RS +Specify the level of verbosity in the messages sent to the log. +.RE +.RE + +.TP +.B log_type +.RS +.nf +Values: COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL +Default: ALL +Description: +.fi +.RS +Filter to log messages by type +.RE +.RE + +.TP +.B videodevice +.RS +.nf +Values: User specified string +Default: /dev/video0 +Description: +.fi +.RS +String to specify the videodevice to be used for capturing. +For Linux, the format is usually /dev/videoX where X varies depending upon the video devices connnected to the computer. +For FreeBSD the default device would be /dev/bktr0. +.RE +.RE + +.TP +.B v4l2_palette +.RS +.nf +Values: 0 to 17 +.RS +V4L2_PIX_FMT_SN9C10X : 0 'S910' +V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' +V4L2_PIX_FMT_SBGGR8 : 2 'BA81' +V4L2_PIX_FMT_SPCA561 : 3 'S561' +V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' +V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' +V4L2_PIX_FMT_PAC207 : 6 'P207' +V4L2_PIX_FMT_PJPG : 7 'PJPG' +V4L2_PIX_FMT_MJPEG : 8 'MJPEG' +V4L2_PIX_FMT_JPEG : 9 'JPEG' +V4L2_PIX_FMT_RGB24 : 10 'RGB3' +V4L2_PIX_FMT_SPCA501 : 11 'S501' +V4L2_PIX_FMT_SPCA505 : 12 'S505' +V4L2_PIX_FMT_SPCA508 : 13 'S508' +V4L2_PIX_FMT_UYVY : 14 'UYVY' +V4L2_PIX_FMT_YUYV : 15 'YUYV' +V4L2_PIX_FMT_YUV422P : 16 '422P' +V4L2_PIX_FMT_YUV420 : 17 'YU12' +.RE +Default: 17 +Description: +.fi +.RS +The v4l2_palette option allows users to choose the prefered palette to be use by motion to capture from the video device. +If the prefered palette is not available from the video device, Motion will attempt to use palettes that are supported. +.RE +.RE + +.TP +.B tunerdevice +.RS +.nf +Values: User Specified String +Default: /dev/tuner0 +Description: +.fi +.RS +Tuner device to be used for capturing images. +This is ONLY used for FreeBSD. +.RE +.RE + +.TP +.B input +.RS +.nf +Values: +.RS +-1 : USB Cameras +0 : video/TV cards or uvideo(4) on OpenBSD +1 : video/TV cards +.RE +Default: -1 +Description: +.fi +.RS +The video input to be used. +.RE +.RE + +.TP +.B norm +.RS +.nf +Values: +.RS +0 (PAL) +1 (NTSC) +2 (SECAM) +3 (PAL NC no colour) +.RE +Default: 0 (PAL) +Description: +.fi +.RS +The video norm to use when capturing from TV tuner cards +.RE +.RE + +.TP +.B frequency +.RS +.nf +Values: Dependent upon video device +Default: 0 +Description: +.fi +.RS +The frequency to set the tuner in kHz when using a TV tuner card. +.RE +.RE + +.TP +.B power_line_frequency +.RS +.nf +Values: +.RS +-1 : Do not modify device setting +0 : Power line frequency Disabled +1 : 50hz +2 : 60hz +3 : Auto +.RE +Default: -1 +Description: +.fi +.RS +Override the power line frequency for the video device. +.RE +.RE + +.TP +.B rotate +.RS +.nf +Values: 0, 90, 180, 270 +Default: 0 +Description: +.fi +.RS +Rotate image this number of degrees. +The rotation affects all saved images as well as movies. +.RE +.RE + +.TP +.B width +.RS +.nf +Values: Dependent upon video device +Default: 352 +Description: +.fi +.RS +Image width in pixels for the video device. +.RE +.RE + +.TP +.B height +.RS +.nf +Values: Dependent upon video device +Default: off +Description: +.fi +.RS +Image height in pixels for the video device +.RE +.RE + +.TP +.B framerate +.RS +.nf +Values: 2 - 100 +Default: 100 +Description: +.fi +.RS +The maximum number of frames to capture in 1 second. +The default of 100 will normally be limited by the capabilities of the video device. +Typical video devices have a maximum rate of 30. +.RE +.RE + +.TP +.B minimum_frame_time +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +The minimum time in seconds between capturing picture frames from the camera. +The default of 0 disables this option and relies upon the capture rate of the camera. +This option is used when you want to capture images at a rate lower than 2 per second. +.RE +.RE + +.TP +.B netcam_url +.RS +.nf +Values: User specified string +Default: None +Description: +.fi +.RS +Full connection URL string to use to connect to a network camera. +The URL must provide a stream of images instead of only a static image. +The following prefixes are recognized + +.RS +http:// +ftp:// +mjpg:// +rtsp:// +mjpeg:// +file:// +.RE + +The connection string is camera specific. +It is usually the same as what other video playing applications would use to connect to the camera stream. +Motion currently only supports basic authentication for the cameras. +Digest is not currently supported. +Basic authentication can be specified in the URL or via the netcam_userpass option. +.RE +.RE + +.TP +.B netcam_userpass +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +The user id and password required to access the network camera string. +only basic authentication is supported at this time. +Format is in user:password format when both a user name and password is required. +.RE +.RE + +.TP +.B netcam_keepalive +.RS +.nf +Values: +.RS +.fi +off: The historical implementation using HTTP/1.0, closing the socket after each http request. +.nf + +.fi +force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +.nf + +.fi +on: Use HTTP/1.1 requests that support keep alive as default. +.nf +.RE +Default: off +Description: +.fi +.RS +This setting is to keep-alive (open) the network socket between requests. +When used, this option should improve performance on compatible net cameras. +This option is not applicable for the rtsp:// and mjpeg:// formats. +.RE +.RE + +.TP +.B netcam_proxy +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +If required, the URL to use for a netcam proxy server. +For example, "http://myproxy". +If a port number other than 80 is needed, append to the specification. +For examplet, "http://myproxy:1234". +.RE +.RE + +.TP +.B netcam_tolerant_check +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use a less strict jpeg validation for network cameras. +This can assist with cameras that have poor or buggy firmware. +.RE +.RE + +.TP +.B rtsp_uses_tcp +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +When using a RTSP connection for a network camera, use a TCP transport instead of UDP. +The UDP transport frequently results in "smeared" corrupt images. +.RE +.RE + +.TP +.B auto_brightness +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +The auto_brightness feature uses the brightness option as its target value. +If brightness is zero auto_brightness will adjust to average brightness value 128. +only recommended for cameras without auto brightness. +.RE +.RE + +.TP +.B brightness +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The initial brightness of a video device. +If auto_brightness is enabled, this value defines the average brightness level which Motion will try and adjust to. +.RE +.RE + +.TP +.B contrast +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The contrast value to set for the video device. +.RE +.RE + +.TP +.B saturation +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The saturation value to set for the video device. +.RE +.RE + +.TP +.B hue +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The hue value to set for the video device. +.RE +.RE + +.TP +.B roundrobin_frames +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +Number of frames to capture in each roundrobin step +.RE +.RE + +.TP +.B roundrobin_skip +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +Number of frames to skip before each roundrobin step +.RE +.RE + +.TP +.B switchfilter +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Filter out noise generated by roundrobin +.RE +.RE + +.TP +.B threshold +.RS +.nf +Values: 1 to unlimited +Default: 1500 +Description: +.fi +.RS +Threshold for number of changed pixels in an image that triggers motion detection +.RE +.RE + +.TP +.B threshold_tune +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Automatically tune the threshold down if possible. +.RE +.RE + +.TP +.B noise_level +.RS +.nf +Values: 1 to unlimited +Default: 32 +Description: +.fi +.RS +Noise threshold for the motion detection. +.RE +.RE + +.TP +.B noise_tune +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Automatically tune the noise threshold +.RE +.RE + +.TP +.B despeckle_filter +.RS +.nf +Values: +.RS +e/E : erode +d/D : dilate +l : label +.RE +Default: EedDl +Description: +.fi +.RS +Despeckle motion image using (e)rode or (d)ilate or (l)abel. +The recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. +(l)abeling must only be used once and the 'l' must be the last letter. +Comment out to disable +.RE +.RE + +.TP +.B area_detect +.RS +.nf +Values: 1 to 9 +Default: Not Defined +Description: +.fi +.RS +When motion is detected in the predefined areas indicated below, +trigger the script indicated by the on_area_detected. +The trigger is only activated once during an event. +one or more areas can be specified with this option. +Note that this option is only used to trigger the indicated script. +It does not limit all motion detection events to only the area indicated. +.RS +Image Areas +123 +456 +789 +.RE +.RE +.RE + +.TP +.B mask_file +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +When particular area should be ignored for motion, it can be accomplished using a PGM mask file. +The PGM mask file is a specially constructed mask file that allows the user to indicate the areas +for which motion should be monitored. +This option specifies the full path and name for the mask file. +.RE +.RE + +.TP +.B smart_mask_speed +.RS +.nf +Values: 0 to 10 +Default: 0 (off) +Description: +.fi +.RS +Speed of mask changes when creating a dynamic mask file. +.RE +.RE + +.TP +.B lightswitch +.RS +.nf +Values: 0 to 100 +Default: 0 +Description: +.fi +.RS +Ignore sudden massive light intensity changes. +Value is a percentage of the picture area that changed intensity. +.RE +.RE + +.TP +.B minimum_motion_frames +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +The minimum number of picture frames in a row that must contain motion before a event is triggered. +The default of 1 means that all motion is detected. +The recommended range is 1 to 5. +.RE +.RE + +.TP +.B pre_capture +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +The number of pre-captured (buffered) pictures from before motion was detected that will be output upon motion detection. +The recommended range is 0 to 5. +It is not recommended to use large values since it will cause Motion to skip frames. +To smooth movies use larger values of post_capture instead. +.RE +.RE + +.TP +.B post_capture +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Number of frames to capture after motion is no longer detected. +.RE +.RE + +.TP +.B event_gap +.RS +.nf +Values: -1 to unlimited +Default: 60 +Description: +.fi +.RS +The number of seconds of no motion that triggers the end of an event. +An event is defined as a series of motion images taken within a short timeframe. +The recommended value is 60 seconds. The value -1 is allowed and disables +events causing all Motion to be written to one single movie file and no pre_capture. +If set to 0, motion is running in gapless mode. +Movies don't have gaps anymore. +An event ends right after no more motion is detected and post_capture is over. +.RE +.RE + +.TP +.B max_movie_time +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Maximum length in seconds of a movie. +When value is exceeded a new movie file is created. +The value of 0 means that there is no limit. +.RE +.RE + +.TP +.B emulate_motion +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Always save images even if there was no motion. +.RE +.RE + +.TP +.B output_pictures +.RS +.nf +Values: on, off, first, best, center +Default: on +Description: +.fi +.RS +Output pictures when motion is detected. +When set to 'first', only the first picture of an event is saved. +Picture with most motion of an event is saved when set to 'best'. +Picture with motion nearest center of picture is saved when set to 'center'. +Can be used as preview shot for the corresponding movie. +.RE +.RE + +.TP +.B output_debug_pictures +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Output pictures with only the pixels moving object (ghost images) +.RE +.RE + +.TP +.B quality +.RS +.nf +Values: 1 to 100 +Default: 75 +Description: +.fi +.RS +The quality (in percent) to be used by the jpeg compression +.RE +.RE + +.TP +.B picture_type +.RS +.nf +Values: jpeg/ppm +Default: jpeg +Description: +.fi +.RS +The file type of output images +.RE +.RE + +.TP +.B ffmpeg_output_movies +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use ffmpeg to encode movies of the motion. +.RE +.RE + +.TP +.B ffmpeg_output_debug_movies +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use ffmpeg to encode movies with only the pixels moving object (ghost images) +.RE +.RE + +.TP +.B ffmpeg_timelapse +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Number of seconds between frame captures for a timelapse movie. +Specify 0 to disable the timelapse. +.RE +.RE + +.TP +.B ffmpeg_timelapse_mode +.RS +.nf +Values: +.RS +hourly +.br +daily +.br +weekly-sunday +.br +weekly-monday +.br +monthly +.br +manual +.RE +Default: daily +Description: +.fi +.RS +File rollover mode for the timelapse video. +.RE +.RE + +.TP +.B ffmpeg_bps +.RS +.nf +Values: 0 to unlimited +Default: 400000 +Description: +.fi +.RS +Bitrate to be used by the ffmpeg encoder. +This option is ignored if ffmpeg_variable_bitrate is not 0. +.RE +.RE + +.TP +.B ffmpeg_variable_bitrate +.RS +.nf +Values: 0, 2 to 31 +Default: 0 +Description: +.fi +.RS +Enable and define the variable bitrate for the ffmpeg encoder. +ffmpeg_bps is ignored if variable bitrate is enabled. +When specified as 0, use the fixed bitrate defined by ffmpeg_bps. +When defined as 2 - 31 vary the quality of the movie. +A value of 2 is best quality versus a value of 31 is worst quality. +.RE +.RE + +.TP +.B ffmpeg_video_codec +.RS +.nf +Values: +.RS +Timelapse videos: +.RS +swf - Creates swf file with mpeg-2 encoding. +mpeg4 - Creates avi file with the default encoding. +.RE +Motion videos: +.RS +mpeg4 - Creates .avi file +msmpeg4 - Creates .avi file +swf - Flash film with extension .swf +flv - Flash video with extension .flv +ffv1 - FF video codec 1 for Lossless Encoding +mov - QuickTime +ogg - Ogg/Theora +mp4 - MPEG-4 Part 14 H264 encoding +mkv - Matroska H264 encoding +.RE +.RE +Default: mpeg4 +Description: +.fi +.RS +The container and codec to use when creating videos. +When creating timelapse videos, there are only two options and the processing varies due to container/codec limitations. +For swf timelapse videos, if motion is shutdown and restarted, new pics will be appended +to any previously created file with name indicated for timelapse. +For mpeg4 timelapse videos, if motion is shutdown and restarted, new pics will create a +new file with the name indicated for timelapse. +For regular motion videos, the container/codec must be available in the ffmpeg installed on the computer. +.RE +.RE + +.TP +.B ffmpeg_duplicate_frames +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +When creating videos, should frames be duplicated in order to keep up with the requested frames per second +.RE +.RE + +.TP +.B sdl_threadnr +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Number of motion thread to show in SDL Window +.RE +.RE + +.TP +.B use_extpipe +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use the external pipe in order to encode videos. +This is a replacement option for the FFMPEG builtin encoder for ffmpeg_output_movies only. +The options movie_filename and timelapse_filename are also used from the ffmpeg feature +.RE +.RE + +.TP +.B extpipe +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +Command line string to receive and process a pipe of images to encode. +Generally, use '-' for STDIN +.RE +.RE + +.TP +.B snapshot_interval +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +When specified as 0, the snapshot feature is disabled. +When a value is specified, the value indicates the number of seconds between snapshots. +.RE +.RE + +.TP +.B locate_motion_mode +.RS +.nf +Values: on/off/preview +Default: off +Description: +.fi +.RS +When specified as 'on', locate and draw a box around the moving object. +When set 'preview', only draw a box in preview_shot pictures. +.RE +.RE + +.TP +.B locate_motion_style +.RS +.nf +Values: +.RS +.fi +box : Draw traditional box around the part of the image generating the motion +.nf + +.fi +redbox : Draw a red box around the part of the image generating the motion +.nf + +.fi +cross : Draw a cross on the part of the image generating the motion +.nf + +.fi +redcross : Draw a red cross on the part of the image generating the motion +.nf +.RE +Default: box +Description: +.fi +.RS +When locate_motion_mode is enable, this option specifies how the motion will be indicated on the image. +.RE +.RE + +.TP +.B text_right +.RS +.nf +Values: User specified string +Default: %Y-%m-%d\n%T-%q +Description: +.fi +.RS +Text to place in lower right corner of image. Format specifiers follow C function strftime(3) +.RE +.RE + +.TP +.B text_left +.RS +.nf +Values: User specified string +Default: CAMERA %t +Description: +.fi +.RS +Text to place in lower left corner of image. Format specifiers follow C function strftime(3) +.RE +.RE + +.TP +.B text_changes +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +When specified, draw the number of changed pixed on the images. +This option will normally be set to off except when you setup and adjust the motion settings. +The text is placed in upper right corner of the image. +.RE +.RE + +.TP +.B text_event +.RS +.nf +Values: User specified string +Default: %Y%m%d%H%M%S +Description: +.fi +.RS +Define the value of the special event conversion specifier %C. +The user can use any conversion specifier in this option except %C. +Date and time values are from the timestamp of the first image in the current event. +The %C can be used filenames and text_left/right for creating +a unique identifier for each event. +.RE +.RE + +.TP +.B text_double +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Draw characters at twice normal size on images. +.RE +.RE + +.TP +.B exif_text +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +Text to include in a JPEG EXIF comment +.RE +.RE + +.TP +.B target_dir +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +Target base directory for pictures and films. +It is recommended to use an absolute path. +If this option is not defined, the current working directory is used. +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B snapshot_filename +.RS +.nf +Values: User specified string +Default: %v-%Y%m%d%H%M%S-snapshot +Description: +.fi +.RS +The file path for snapshots relative to target_dir. +The file extension .jpg or .ppm is automatically added so do not include this. +A symbolic link called lastsnap.jpg created in the target_dir will always +point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B picture_filename +.RS +.nf +Values: User specified string +Default: %v-%Y%m%d%H%M%S-%q +Description: +.fi +.RS +The file path for motion triggered images (jpeg or ppm) relative to target_dir. +The file extension of .jpg or .ppm is automatically added so do not include this. +Set to 'preview' together with best-preview feature enables special naming +convention for preview shots. +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B movie_filename +.RS +.nf +Values: User specified string +Default: %v-%Y%m%d%H%M%S +Description: +.fi +.RS +File path for motion triggered ffmpeg films (movies) relative to target_dir. +The extensions(.swf, .avi, etc) are automatically added so do not include them +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B timelapse_filename +.RS +.nf +Values: User specified string +Default: %Y%m%d-timelapse +Description: +.fi +.RS +File path for timelapse movies relative to target_dir. +The file extensions(.swf .avi) are automatically added so do not include them +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B ipv6_enabled +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Enable or disable IPV6 for http control and stream +.RE +.RE + +.TP +.B stream_port +.RS +.nf +Values: 0 to port number limit +Default: 0 +Description: +.fi +.RS +This option is the port number that the mini-http server listens on for streams of the pictures. +.RE +.RE + +.TP +.B stream_quality +.RS +.nf +Values: 1 to 100 +Default: 50 +Description: +.fi +.RS +The quality in percent for the jpg images streamed. +.RE +.RE + +.TP +.B stream_motion +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Output frames at 1 fps when no motion is detected and increase to the rate given by stream_maxrate when motion is detected +.RE +.RE + +.TP +.B stream_maxrate +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +Maximum frame rate to send to stream +.RE +.RE + +.TP +.B stream_localhost +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Restrict stream connections to localhost only +.RE +.RE + +.TP +.B stream_limit +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Limits the number of images per connection. +The default value of 0 means unlimited. +The number can be defined by multiplying actual stream rate by the desired number of seconds. +The actual stream rate is the smallest of the framerate and stream_maxrate. +.RE +.RE + +.TP +.B stream_auth_method +.RS +.nf +Values: +.RS +0 = disabled +1 = Basic authentication +2 = MD5 digest (the safer authentication) +.RE +Default: 0 +Description: +.fi +.RS +The authentication method to use for viewing the stream. +.RE +.RE + +.TP +.B stream_authentication +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +The username and password to use for authentication of the stream. +The format is Username:Password +.RE +.RE + +.TP +.B stream_preview_scale +.RS +.nf +Values: 1 to 100 +Default: 25 +Description: +.fi +.RS +This defines what percentage the stream image should be scaled to for the preview page +.RE +.RE + +.TP +.B stream_preview_newline +.RS +.nf +Values: yes/no +Default: no +Description: +.fi +.RS +When the image is put on the preview page, should the image start on a new line. +This option allows the user to specify whether the preview images should be side by side +or stacked on the page. +.RE +.RE + +.TP +.B webcontrol_port +.RS +.nf +Values: 0 to maximum port number +Default: 0 +Description: +.fi +.RS +Port number for the web control / preview page. +.RE +.RE + +.TP +.B webcontrol_localhost +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Restrict control connections to localhost only +.RE +.RE + +.TP +.B webcontrol_html_output +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Specified whether the web control/preview page should be raw or html format. Preview page is always html. +.RE +.RE + +.TP +.B webcontrol_authentication +.RS +.nf +Values: +.RS +0 = disabled +1 = Basic authentication +2 = MD5 digest (the safer authentication) +.RE +Default: 0 +Description: +.fi +.RS +The authentication method to use for viewing the web control. +.RE +.RE + +.TP +.B track_type +.RS +.nf +Values: +.RS +0 = none +1 = stepper +2 = iomojo +3 = pwc +4 = generic +5 = uvcvideo +6 = servo +.RE +Default: 0 +Description: +.fi +.RS +This option specifies the type of tracker. +The generic type enables the definition of motion center and motion size to +be used with the conversion specifiers for options like on_motion_detected +.RE +.RE + +.TP +.B track_auto +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Enables/disables the automatic tracking. +.RE +.RE + +.TP +.B track_port +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +The serial port of the motor. For example /dev/ttyS0 +.RE +.RE + +.TP +.B Tracking options +.RS +.nf +track_motorx, track_motorx_reverse, track_motory, track_motory_reverse +track_maxx, track_minx, track_maxy, track_miny, track_homex, track_homey +track_iomojo_id, track_step_angle_x, track_step_angle_y, track_move_wait +track_speed, track_stepsize + +.fi +.RE +.RS +.nf +Values: device dependent +Default: 0 +Description: +.fi +.RS +These options specify the parameters for cameras with tracking capabilities. +.RE +.RE + +.TP +.B quiet +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Do not sound beeps when detecting motion +.RE +.RE + +.TP +.B Script Options +.RS +.nf +on_event_start, on_event_end, on_picture_save +on_motion_detected, on_area_detected, on_movie_start +on_movie_end, on_camera_lost + +.fi +.RE +.RS +.nf +Values: User defined string +Default: Not defined +Description: +.fi +.RS +Specify the full path and file name for the script to execute when the indicated event occurs. +When a file name is required for the script, append a %f to the script string. +.RE +.RE + +.TP +.B sql_log_picture +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Log to the database when creating motion triggered picture file +.RE +.RE + +.TP +.B sql_log_snapshot +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Log to the database when creating a snapshot image file +.RE +.RE + +.TP +.B sql_log_movie +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Log to the database when creating motion triggered movie file +.RE +.RE + +.TP +.B sql_log_timelapse +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Log to the database when creating timelapse movies file +.RE +.RE + +.TP +.B sql_query +.RS +.nf +Values: User defined string +Default: Not defined +Description: +.fi +.RS +SQL statement to execute when a event occurs. +Use same conversion specifiers as for text features +Additional special conversion specifiers are +.RS +%n = the number representing the file_type +%f = filename with full path +.RE +Sample table set up (not sql_query): +.RS +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)); +.RE +.RS +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); +.RE +Sample sql_query +.RS +insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') +.RE +.RE +.RE + +.TP +.B database_type +.RS +.nf +Values: mysql, postgresql, sqlite3 +Default: Not defined +Description: +.fi +.RS +The type of database being used. +.RE +.RE + +.TP +.B database_dbname +.RS +.nf +Values: User defined string +Default: Not defined +Description: +.fi +.RS +The name of the database being used (dbname) +.RE +.RE + +.TP +.B database_host +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The name of the host on which the database is running. +.RE +.RE + +.TP +.B database_user +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The username to access the database +.RE +.RE + +.TP +.B database_password +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The database password for the user to access the database. +.RE +.RE + +.TP +.B database_port +.RS +.nf +Values: 0 to maximum port number +Default: Not defined +Description: +.fi +.RS +The port to use in order to access the database. +Default ports: mysql 3306 , postgresql 5432 +.RE +.RE + +.TP +.B sqlite3_db +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The full path to the sqlite3 database. +.RE +.RE + +.TP +.B sqlite3_busy_timeout +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +SQLite3 wait time in milliseconds for locked database to be unlocked before returning database locked error +.RE +.RE + +.TP +.B video_pipe +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +Output images to a video4linux loopback device. The value '-' means next available +.RE +.RE + +.TP +.B motion_video_pipe +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +Output motion images to a video4linux loopback device. The value '-' means next available +.RE +.RE + +.TP +.B thread +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +This option specifies the full path and file name to individual thread files. +This option can be listed multiple times. +Each thread file should contain the options that are unique to that camera/video device. +Common options are obtained from the motion.conf file and values are overwritten from each +thread file. While the motion.conf includes four sample thread options, the actual +limit of threads is only dependent upon the machine capabilities. +Remember: If you have more than one camera you must have one +thread file for each camera. For example, 2 cameras would require 3 files: +The motion.conf file AND thread1.conf and thread2.conf. +only put the options that are unique to each camera in the +thread config files. +.RE +.RE + + + + + + +.SH SIGNALS +Motion responds to the following signals: +.TP +.B SIGHUP +The config file will be reread. +.TP +.B SIGTERM +If needed motion will create an mpeg file of the last event and exit +.TP +.B SIGUSR1 +Motion will create an mpeg file of the current event. +.SH NOTES +.TP +.B Snapshot +A snapshot is a picture taken at regular intervals independently of any movement in the picture. +.TP +.B Motion image +A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. +.TP +.B Normal image +A "normal" image is the real image taken by the camera with text overlayed. +.TP +.B Threads and config files +If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. +.br +If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: +.br +1. Current directory from where motion was invoked +.br +2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf +.br +3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) +.br +If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. +.br +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. +.br +The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. +.br +If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. +.br +So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. +.br +An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). +.br +An option that is unique to a camera must be defined in each thread file. +.br +The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. +.br +Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. +.br +Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins. +.br +1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. +.br +2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. +.br +3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. +.br +4. Motion reads the command line option again overruling any previously defined options. +.br +So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. +.br +If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. +.br +If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. +.TP +.B Conversion Specifiers for Advanced Filename and Text Features +The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. +.br +In text_left and text_right you can additionally use '\n' for new line. + +.TP +.B %a +The abbreviated weekday name according to the current locale. +.TP +.B %A +The full weekday name according to the current locale. +.TP +.B %b +The abbreviated month name according to the current locale. +.TP +.B %B +The full month name according to the current locale. +.TP +.B %c +The preferred date and time representation for the current locale. +.TP +.B %C +Text defined by the text_event feature +.TP +.B %d +The day of the month as a decimal number (range 01 to 31). +.TP +.B %D +Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. +.TP +.B %E +Modifier: use alternative format, see below. +.TP +.B %f +File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. +.TP +.B %F +Equivalent to %Y-%m-%d (the ISO 8601 date format). +.TP +.B %H +The hour as a decimal number using a 24-hour clock (range 00 to 23). +.TP +.B %i +Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). +.TP +.B %I +The hour as a decimal number using a 12-hour clock (range 01 to 12). +.TP +.B %j +The day of the year as a decimal number (range 001 to 366). +.TP +.B %J +Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). +.TP +.B %k +The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) +.TP +.B %K +X coordinate in pixels of the center point of motion. Origin is upper left corner. +.TP +.B %l +The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) +.TP +.B %L +Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). +.TP +.B %m +The month as a decimal number (range 01 to 12). +.TP +.B %M +The minute as a decimal number (range 00 to 59). +.TP +.B %n +Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. +.TP +.B %N +Noise level. +.TP +.B %o +Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. +.TP +.B %p +Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. +.TP +.B %P +Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. +.TP +.B %q +Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. +.TP +.B %Q +Number of detected labels found by the despeckle feature +.TP +.B %r +The time in a.m. or p.m. notation. +.TP +.B %R +The time in 24-hour notation (%H:%M). +.TP +.B %s +The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. +.TP +.B %S +The second as a decimal number (range 00 to 61). +.TP +.B %t +Thread number (camera number) +.TP +.B %T +The time in 24-hour notation (%H:%M:%S). +.TP +.B %u +The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. +.TP +.B %U +The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. +.TP +.B %v +Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. +.TP +.B %V +The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. +.TP +.B %w +The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. +.TP +.B %W +The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. +.TP +.B %x +The preferred date representation for the current locale without the time. +.TP +.B %X +The preferred time representation for the current locale without the date. +.TP +.B %y +The year as a decimal number without a century (range 00 to 99). +.TP +.B %Y +The year as a decimal number including the century. +.TP +.B %z +The time-zone as hour offset from GMT. +.TP +.B %Z +The time zone or name or abbreviation. + +.TP +.B More information +Motion homepage: http://www.lavrsen.dk/foswiki/bin/view/Motion/ + +Motion Guide (user and installation guide): +.br http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide +.br http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice +.SH AUTHORS +Jeroen Vreeken (pe1rxq@amsat.org), +Folkert van Heusden, +Kenneth Lavrsen (kenneth@lavrsen.dk), +Juan Angulo Moreno , +and many others \ No newline at end of file From 383321daa11cff0fde1f00436948c280b56d7205 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Tue, 8 Sep 2015 21:26:08 -0600 Subject: [PATCH 145/233] Fix send raw error introduced with Chrome preview fix --- webhttpd.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/webhttpd.c b/webhttpd.c index f7b791a..ca80f05 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -1988,31 +1988,35 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat } sprintf(res, "
                                                          "); send_template(client_socket, res); - } else { - send_template_ini_client(client_socket, ini_template); - sprintf(res, "Motion "VERSION" Running [%hu] Threads
                                                          \n", i); - send_template(client_socket, res); - } - //Send the preview section - hostname[1023] = '\0'; - gethostname(hostname, 1023); - for (y = 0; y < i; y++) { - if (cnt[y]->conf.stream_port) { - if (cnt[y]->conf.stream_preview_newline) { - sprintf(res, "
                                                          "); + //Send the preview section + hostname[1023] = '\0'; + gethostname(hostname, 1023); + + for (y = 0; y < i; y++) { + if (cnt[y]->conf.stream_port) { + if (cnt[y]->conf.stream_preview_newline) { + sprintf(res, "
                                                          "); + send_template(client_socket, res); + } + sprintf(res, " " + "" + ,hostname,cnt[y]->conf.stream_port + ,hostname,cnt[y]->conf.stream_port + ,cnt[y]->conf.stream_preview_scale); send_template(client_socket, res); - } - sprintf(res, " " - "" - ,hostname,cnt[y]->conf.stream_port - ,hostname,cnt[y]->conf.stream_port - ,cnt[y]->conf.stream_preview_scale); - send_template(client_socket, res); + } + } + send_template_end_client(client_socket); + } else { + send_template_ini_client_raw(client_socket); + sprintf(res, "Motion "VERSION" Running [%hu] Threads\n0\n", i); + send_template_raw(client_socket, res); + for (y = 1; y < i; y++) { + sprintf(res, "%hu\n", y); + send_template_raw(client_socket, res); } } - send_template_end_client(client_socket); - } else { char command[256] = {'\0'}; char slash; From 2aed0a44ae8e6cb14dfc1945c16c85eb67f0fdf8 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 12 Sep 2015 19:13:27 -0600 Subject: [PATCH 146/233] Revised motion guide --- CHANGELOG | 1 + motion_guide.html | 7612 +++++++++++++++++++++++++-------------------- 2 files changed, 4195 insertions(+), 3418 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a4d6a44..0a99226 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Draft revised motion_guide.html with new options. * Revise manual to have current options. * Tab/Space cleanup and validation security issue addressed. (closes 071831) * Add preview to webcontrol page(closes 172526) diff --git a/motion_guide.html b/motion_guide.html index 0260ed3..7bc95a4 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -1,1974 +1,2357 @@ -

                                                          Motion Guide - One Large Document.

                                                          +

                                                          Motion Guide

                                                          +

                                                          This version of the Guide is made for inclusion in the Motion download package for off line reading. -

                                                          -If you read this document from the distribution package of Motion or from some not up to date mirror you should know that the URL for the always up to date version is http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide. If you are already on the new TWiki based Motion site clicking the link just mentioned will lead you to the index page for the Motion Guide documents. -


                                                          -This topic consists of the following subtopics: -MotionOverview, KnownProblems, InstallOverview, PrepareInstall, ConfigureScript, MakeInstall, UpgradingFromOlderVersion, RunningMotionConfigFiles, CommandLineOptions, ConfigFileOptions, SignalsKill, ErrorLogging, CaptureDeviceOptions, MotionDetectionSettings, ImageFileOutput, TuningMotion, MpegFilmsFFmpeg, SnapshotsWebCam, TextFeatures, AdvancedFilenames, ConversionSpecifiers, WebcamServer, RemoteControlHttp, ExternalCommands, TrackingControl, UsingDatabases, LoopbackDevice. -
                                                          -

                                                          -

                                                          -
                                                          -

                                                          -

                                                          Motion Guide - Installation

                                                          -

                                                          -

                                                          Motion Overview

                                                          -

                                                          -

                                                          What is Motion?

                                                          +

                                                          +

                                                          + + + + + +

                                                          Overview

                                                          +
                                                            +

                                                            +

                                                            What is Motion?

                                                            +

                                                            Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. Or in other words, it can detect motion. -

                                                            -The program is written in C and is made for the Linux operating system. -

                                                            -Motion is a command line based tool. It has absolutely no graphical user interface. Everything is setup either via the command line or via a set of configuration files (simple ASCII files that can be edited by any ASCII editor). -

                                                            +

                                                            +The program is written in C and was made for the Linux operating system. Recent revisions have also made it available for BSD. +

                                                            +Motion is a command line based tool with only limited support for configuration via a http interface. +The many configuration options are set via the command line or configuration files. + +

                                                            The output from motion can be: -

                                                              -
                                                            • jpg files -
                                                            • ppm format files -
                                                            • mpeg video sequences -
                                                            -

                                                            -

                                                            How do I get Motion and what does it cost?

                                                            -Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project. -

                                                            -

                                                            Maintenance and Support

                                                            -Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day. -

                                                            -To get motion direct your browser to the Motion Homepage. -

                                                            -On the Download Files page you will find a links to the latest stable version both as sources and binaries for some of the most popular Linux distributions. You will also find links to development versions. Snapshot releases are special test releases that are normally very stable. Every day a Motion Daily Source Snap is created from the Motion Subversion -

                                                            -Motion was originally written by Jeroen Vreeken who still actively participates in the development of Motion and later Folkert van Heusden continued as a lead programmer with Kenneth Lavrsen responsible for Motion Guide, website and releases on Sourceforge. -

                                                            -From version 3.1.12 Motion is now project managed entirely by Kenneth Lavrsen, and the project now shift towards being developed by many contributers. -

                                                            -For support we encourage you to join the mailing list instead of writing to Jeroen, Folkert or Kenneth directly. We are all very active on the mailing list and by using the mailing list much more users will have benefit of the answers. Newbies and stupid questions are welcome on the list. Contributions in the form of patches are also very welcome on the mailing list. -

                                                            -

                                                            Which version to download and use?

                                                            -Versions 3.2.X are the current version. There is at the moment no development branch. The versions 3.1.X ended at 3.1.20 and there will be no more 3.1.X releases. If you use use a version older than 3.2.X you are encouraged to update. -

                                                            -Since 3.1.13 quite many options have been renamed to make setting up Motion easier. From 3.1.17-18 some unfinished features have been removed. The Berkeley mpeg feature is now removed because the ffmpeg feature is now mature and much better working. At version 3.1.18 a new network camera feature was introduced replacing the old cURL based netcam code and introducing support of mjpeg streaming cameras. However this new code was quite difficult to get stable. During the development of 3.2.2 the network camera code was totally rewritten again learning from our experience and now finally it seems to be stable. -

                                                            -Since 3.2.3 Debian users can find binary packages on the Motion Sourceforge file download page. You can find Debian versions of Motion in different Debian repositories but they are all out of date and hardly ever get updated. -

                                                            -

                                                            What features does Motion have?

                                                            -See more description at the Motion Homepage.
                                                              -
                                                            • Taking snapshots of movement -
                                                            • Watch multiple video devices at the same time -
                                                            • Watch multiple inputs on one capture card at the same time -
                                                            • Live streaming webcam (using multipart/x-mixed-replace) -
                                                            • Real time creation of mpeg movies using libraries from ffmpeg -
                                                            • Take automated snapshots on regular intervals -
                                                            • Take automated snapshots at irregular intervals using cron -
                                                            • Executing external program when detecting movement -
                                                            • Execute external program at the beginning of an event of several motion detections. -
                                                            • Execute external program at the end of an event of several motion detections. -
                                                            • Execute external program when a picture is saved. -
                                                            • Execute external program when a movie mpeg is created (opened) -
                                                            • Execite external program when a movie mpeg ends (closed) -
                                                            • Motion tracking -
                                                            • Feed events to an MySQL or PostgreSQL database. -
                                                            • Feed video back to a video4linux loopback for real time viewing -
                                                            • Web interface using Motion Related Projects such as motion.cgi, Kenneths Webcam Package, Kevins Webpage, X-Motion and many more. -
                                                            • User configurable and user defined on screen display. -
                                                            • Control via simple web interface. -
                                                            • Automatic noise and threshold control -
                                                            • Ability to control the pan/tilt of a Logitech Sphere (or Orbit) camera -
                                                            • Highly configurable display of text on images. -
                                                            • High configurable definition of path and file names of the stored images and films. -
                                                            -

                                                            -You can find more information and links at the Motion Homepage. -

                                                            -

                                                            FreeBSD

                                                            -

                                                            -Motion is originally developed for Linux and it is still mainly developed and supported for this platform. From version 3.1.15 an experimental port has been made by Angel Carpintero. Not all features of Motion are supported at this time and it still needs a lot of test time on different hardware. Angel is very interested in feedback. Join the Motion Mailing List and give your feedback there. Patches for bugfixes and for enabling the missing features are very welcome. The rest of this guide is still mainly targeted for Linux users. Follow this topic to Install FreeBSD. -

                                                            -

                                                            MacOSX

                                                            -

                                                            -From Motion version 3.2.4 it is now also possible to build and install Motion under MacOSX. Feature set it the same as for FreeBSD. See the MacOSX topic for specific help how to install Motion and its dependencies on MacOSX. Again this port has been contributed by Angel Carpintero. -

                                                            -

                                                            Documentation

                                                            +

                                                            +
                                                              +
                                                            • jpg files
                                                            • +
                                                            • ppm format files
                                                            • +
                                                            • movie video sequences
                                                            • +
                                                            +

                                                            +

                                                            How do I get Motion and what does it cost?

                                                            +

                                                            +Motion is an open source type of project. It does not cost anything. Motion is published +under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project. +

                                                            +

                                                            Maintenance and Support

                                                            +

                                                            +Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day. +

                                                            +To get motion direct your browser to the Motion Homepage. +

                                                            +On the Download Files page you will find +links to the latest stable version both as sources and binaries for some of the most popular Linux distributions. +You will also find links to development versions. Snapshot releases are special test releases that are normally +stable. Every day a Motion Daily Source Snap is created from the Motion Subversion +

                                                            +Motion was originally written by Jeroen Vreeken and later Folkert van Heusden continued as a +lead programmer with Kenneth Lavrsen responsible for Motion Guide, website and releases on Sourceforge. +

                                                            +From version 3.1.12 Motion is now project managed entirely by Kenneth Lavrsen, and the project now shift +towards being developed by many contributers. +

                                                            +For support we encourage you to join the mailing list instead of writing to Jeroen, Folkert or Kenneth directly. +Newbies and stupid questions are welcome on the list. Contributions in the form of patches are also very welcome +on the mailing list. +

                                                            +

                                                            Which version to download and use?

                                                            +

                                                            +Versions 3.2.12 is the current official version released in June 2010. The trunk of the SVN represents the official +development branch of Motion. Additional independent development forks exist on Github that contain additional bug +fixes, enhanced features and updated +documentation. This guide is based upon the features and options included in the Mr-Dave Github repository as of +September 2015. +Note that the majority of the new options and changed names represent differences between the official 3.2.12 version +and the SVN trunk rather than differences between the trunk and the Mr-Dave repository. Users are encouraged to evaluate +the pros and cons for themselves of using any particular source. +

                                                            +Since 3.2.12 many options have been renamed in the development branches to make setting up Motion easier. +

                                                            +Motion is included in Debian and Ubuntu while RPM users can find the binary package for 3.2.12 on the Motion Sourceforge file download page. +

                                                            +

                                                            What features does Motion have?

                                                            +

                                                            +See more description at the Motion Homepage. +
                                                              +
                                                            • Taking snapshots of movement
                                                            • +
                                                            • Watch multiple video devices at the same time
                                                            • +
                                                            • Watch multiple inputs on one capture card at the same time
                                                            • +
                                                            • Live streaming webcam
                                                            • +
                                                            • Real time creation of movies using libraries from ffmpeg
                                                            • +
                                                            • Take automated snapshots on regular intervals
                                                            • +
                                                            • Take automated snapshots at irregular intervals using cron
                                                            • +
                                                            • Executing external program when a particular event occurs
                                                            • +
                                                            • Motion tracking
                                                            • +
                                                            • Feed events to an MySQL, PostgreSQL or SQLite3 database.
                                                            • +
                                                            • Feed video back to a video4linux loopback for real time viewing
                                                            • +
                                                            • Control via simple web interface.
                                                            • +
                                                            • Automatic noise and threshold control
                                                            • +
                                                            • Ability to control the pan/tilt of a tracking camera.
                                                            • +
                                                            • Highly configurable display of text on images.
                                                            • +
                                                            • Highly configurable definition of path and file names of the stored images and movies.
                                                            • +
                                                            +

                                                            +

                                                            FreeBSD

                                                            +

                                                            +Motion is originally developed for Linux and it is still mainly developed and supported for this platform. Thanks to contributions of Angel Carpintero, Motion now builds on BSD platforms. These platforms however have had only limited testing. +

                                                            +

                                                            MacOSX

                                                            +

                                                            +Starting with Motion version 3.2.4, it is now possible to build Motion under MacOSX thanks to Angel Carpintero. The features included are similar to BSD platforms and have had limited testing. +

                                                            +

                                                            Documentation

                                                            +

                                                            You have the following sources of information: -

                                                            -

                                                            -

                                                            Supported Hardware

                                                            -Input devices: Here we are thinking about the cameras. -

                                                            +

                                                            +
                                                              +
                                                            • This Motion Guide
                                                            • +
                                                            • The Frequently Asked Questions
                                                            • +
                                                            • The author of the program has written a description of the technology behind motion.
                                                            • +
                                                            • The man page. After installation simply type 'man motion' into a terminal screen.
                                                            • +
                                                            • The default motion.conf file (motion-dist.conf) that comes with the package.
                                                            • +
                                                            +

                                                            +

                                                            Supported Hardware

                                                            +

                                                            Motion supports video input from two kinds of sources. -

                                                            -Standard video4linux devices (e.g. /dev/video0). Motion has no drivers for cameras. Installing the camera itself is outside the scope of this document. But here are some nice links.

                                                            -Network cameras (which are actually cameras with a built in web server that can be connected directory to your network). -

                                                            -

                                                            -

                                                            Known Problems

                                                            -See also the Frequently Asked Questions and Bug Reports for known open bugs. -

                                                            -Kernel 2.6 and pwc. Note that for kernel 2.6 there is a new release of the Philips WebCam (pwc) drivers 10.0.X. It is recommended to install this. At the time of this being written the 2.6.12+ kernels have a version of pwc built-in but it is a cripled version which can only support very small picture size. You can however download the latest source code of the pwc driver (at this time 10.0.11) and build it without having to rebuild your kernel. But you will need to have either the kernel sources or a special kernel-header package installed to compile it. See Installation of PWC page which is also hosted in this wiki. -

                                                            +

                                                            +Standard video4linux devices (e.g. /dev/video0) and network cameras. Motion has no drivers for cameras. +Installing or configuring the camera itself is outside the scope of this document. Generally, if the device works with +other common video player software, it will work with Motion (and vice versa). As a result, it is +often convenient to first get the device working with other software and then use those connection options with Motion. +

                                                            +

                                                            +
                                                          + +

                                                          Known Problems

                                                          +
                                                            + +

                                                            +See also the Frequently Asked Questions and Bug Reports for known open bugs. +

                                                            +Kernel 2.6 and pwc. Note that for kernel 2.6 there is a new release of the Philips WebCam (pwc) drivers 10.0.X. It is recommended to install this. At the time of this being written the 2.6.12+ kernels have a version of pwc built-in but it is a crippled version which can only support very small picture size. You can however download the latest source code of the pwc driver (at this time 10.0.11) and build it without having to rebuild your kernel. But you will need to have either the kernel sources or a special kernel-header package installed to compile it. See Installation of PWC page which is also hosted in this wiki. +

                                                            If you use use a Logitech Quickcam Orbit or Sphere using the driver pwc/pwcx and kernel 2.6.X you should replace the file in the Motion sources called pwc-ioctl.h with the one that comes with the your pwc version. Motion is shipped with 3 versions of pwc-ioctl.h-VERSION. Rename the one that fits your major pwc version number best to pwc-ioctl.h (after renaming the current to something else). There has been some small adjustments in the API that requires that you have the right header file. -

                                                            -Camera picture dimensions must be multiple of 16 -Dimentions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. But if you intend to monitor a network camera which is saving jpeg images you may have to pay attention to the dimensions of the picture. -

                                                            -ffmpeg_filename has changed name to movie_filename -The 3.2.5 release contains a motion_guide and man page in which it was forgotten to change ffmpeg_filename to movie_filename. Please note that the option that defines the filenames for mpeg movies is now called movie_filename. This change is made because we may soon implement alternatives to ffmpeg and then ffmpeg_filename will be a bad name. This is fixed in release 3.2.5.1. -

                                                            -error: `time_current_frame' undeclared (first use in this function) -A bug in 3.2.5 and 3.2.5.1 where a bugfix related to snapshot feature has created a new bug when you compile Motion without ffmpeg libs installed. This is fixed in 3.2.6. -

                                                            -

                                                            -

                                                            How do I install Motion?

                                                            -Motion is mainly distributed as source files that you must compile yourself. There is also an RPM made on Fedora Core 3. And Debian packages are available for selected versions. -

                                                            -The short overview of the steps to install Motion from sources.

                                                              -
                                                            • Preparation: Motion uses a number of shared libraries that must be installed on your computer before you can build Motion. The needed shared libraries depends on the features you wish to use. Features network camera, ffmpeg, MySQL and PostgreSQL needs specific shared libraries installed. See preparation section for more information. -
                                                            -

                                                              -
                                                            • Download the motion source files (distributed as tar'ed and compressed files). Place the file in a place of your own choice. -
                                                            -

                                                              -
                                                            • Untar and uncompress the file to the place you want the program installed. Editor recommends placing the motion source file directory in /usr/local. If you do not have write access to the /usr/local directory (you are under the mercy of an ignorant system administrator with a severe case of paranoia) - you can install the program in a directory in your home directory. You will then need to read the next section about how to configure before you compile the program. Below is shown the exact commands using version 3.2.X installed in /usr/local as an example (replace /path/to with the actual placement of the tar.gz file). -
                                                            -
                                                              -
                                                              -cd /usr/local
                                                              -tar -xvzf /path/to/motion-3.2.X.tar.gz
                                                              -
                                                              -
                                                              -
                                                            • You will now have created a directory called motion-3.2.X. You can rename it to motion (mv motion-3.1.X motion). I recommend creating a symbolic link to the current version. This way you can more easily experiment with different version simply by changing the link. -
                                                            -
                                                              -
                                                              -ln -s motion-3.2.X motion
                                                              -
                                                              -
                                                              -
                                                            • Now change to the new directory -
                                                            -
                                                              -
                                                              -cd motion
                                                              -
                                                              -
                                                              -
                                                            • Run configure. You can start with the defaults. If you need to modify the installation parameters you can read the next section. -
                                                            -
                                                              -
                                                              -./configure
                                                              -
                                                              -
                                                              -
                                                            • Build the code -
                                                            -
                                                              -
                                                              -make
                                                              -
                                                              -
                                                              -
                                                            • Install the code, manual page, etc -
                                                            -
                                                              -
                                                              -make install
                                                              -
                                                              -
                                                              -
                                                            • In /etc/motion/etc you will find a file called motion-dist.conf. If it is the first time you install Motion - rename this file to motion.conf and edit as a minimum the settings: videodevice, input, norm, frequency, width, height and target_dir. That should get you going. -
                                                            -

                                                              -
                                                            • Run the program. To enable more features you must modify the config file. -
                                                            -
                                                              -
                                                              -motion
                                                              -
                                                              -
                                                            -

                                                            -

                                                            -

                                                            Preparation For Install

                                                            -

                                                            -Note: If you're using SuSE 9.2, you might want to ADDITIONALLY have a look at Compiling on SuSE 9.2. As mentioned on that page as well, you will still need to read the instructions here as well. -

                                                            -Before you start you may need to install a number of shared libraries that Motion uses. If they are missing the feature will simply normally not be included. Most of these libraries can be found on the CDs of your distribution. A few will have to be downloaded from the Internet. Note that when you install software using pre-compiled binaries (Redhat type RPMs, Debian debs etc) you normally only get what is needed to run the programs themselves. In order to compile other programs from source that uses these pre-compiled libraries you also need to installed the development packages. These are normally called the same name as the package suffixed by -devel or -dev. These development packages contains the header files (xxx.h) that Motion needs to build with the shared libraries. If you build a library from sources you already have these header files. It is recommended to simply install the pre-compiled binary packages and their development brothers. -

                                                            -This is a list of shared libraries used by Motion and the RPM packages that provides them. -

                                                            -Motion will always need these libraries to be built and work - - - - -
                                                            Library RPM Packages Debian Packages
                                                            libm, libresolv, libdl, libpthread, libc, ld-linux, libcrypt, and libnsl glibc and glibc-devel libc6 , libc6-dev ,libglib1.2
                                                            libjpeg libjpeg and libjpeg-devel libjpeg62 and libjpeg62-dev ( optional libjpeg-mmx-dev )
                                                            libz zlib and zlib-devel zlib1g and zlib1g-dev
                                                            -

                                                            -For generating mpeg films with ffmpeg you need this library:
                                                            -(See also the section Generating MPEG films with ffmpeg for how to install ffmpeg and libavformat/libavcodec)
                                                            -Motion must be installed with revision 0.4.8 or 0.4.9pre1 of ffmpeg. Motion will also work with later CVS snapshots of ffmpeg but the API of the ffmpeg libraries changes all the time and without warning. If you have problems compiling Motion or with running an RPM of Motion you may try with an older CVS snapshot of ffmpeg. The Motion developers will like to know when ffmpeg changes and breaks Motion so we can fix it. Please file a bug report then with the exact date of the ffmpeg CVS version you have trouble with. -

                                                            - - -
                                                            Library RPM Packages Debian Packages
                                                            libavcodec, libavformat ffmpeg and ffmpeg-devel or install from source libavcodec-dev libavcodec0d libavformat-dev libavformat0d (*)
                                                            -

                                                            -Debian has not provided deb packages for ffmpeg due patent issues. However this is about to change so checkout for availability of newer versions of debian ffmpeg debs. You can build yourself from source or from Christian Marillat website or apt repository. -

                                                            -deb http://www.debian-multimedia.org stable main # ( etch )
                                                            -deb http://www.debian-multimedia.org testing main # ( lenny )
                                                            -deb http://www.debian-multimedia.org unstable main # ( sid )
                                                            +

                                                            +

                                                            -
                                                            -Add the suitable line to your /etc/apt/sources.list and run this: -
                                                            -apt-get update ; apt-get -y install libavcodec-dev libavcodec0d libavformat-dev libavformat0d
                                                            -
                                                            -

                                                            -For logging in MySQL you need this library: - - -
                                                            Library RPM Packages Debian Packages
                                                            libmysqlclient mysql and mysql-devel libmysqlclient15-off and libmysqlclient15-dev
                                                            -

                                                            -For logging in PostgreSQL you need this library: - - -
                                                            Library RPM Packages Debian Packages
                                                            libpq postgresql-libs and postgresql-devel libpq-dev and libpq4
                                                            -

                                                            -

                                                            -

                                                            Configure Script

                                                            -Configure is script that you run to setup the build environment for the C-compiler. It generates the "Makefile" which the program "make" uses to compile and install the software. -

                                                            -To run configure your current directory must be the motion directory. You type -

                                                            +

                                                          +

                                                          Installation on Ubuntu and Debian

                                                          +
                                                            + +

                                                            +Motion is part of the Ubuntu and Debian repositories. +

                                                            +Open up a terminal window and type: +

                                                            +sudo apt-get install motion +

                                                            +Before we start configuring Motion, we need to copy the config file to our Home folder so that the master copy won't be affected. Open a terminal and copy the configuration file to your Home folder with following commands: +

                                                            +mkdir .motion +

                                                            +(Note: This will create a hidden folder .motion in your Home directory.) +

                                                            +sudo cp /etc/motion/motion.conf ~/.motion/motion.conf +

                                                            +(Note: This command will copy the original motion configuration file to its location.) +

                                                            +Now can open the configuration file for editing: +

                                                            +sudo nano ~/.motion/motion.conf +

                                                            +After you you have made all the appropriate adjustments to the configuration file, close it. +Then start motion in the terminal simply by typing: +

                                                            +motion +

                                                            +

                                                            +
                                                          + +

                                                          How to build Motion from source code

                                                          +
                                                            + +

                                                            +While Motion is included in the apt packages for Ubuntu and Debian, it can also be built from the source code. +Source code is located in multiple locations depending upon the needs of the user +
                                                              +
                                                            • SourceForge (official release)
                                                            • +
                                                            • SVN(official release and maintainer development trunk)
                                                            • +
                                                            • Github(Latest fixes, enhancements and documents from community)
                                                            • +
                                                            + +

                                                            +

                                                            +
                                                              + +

                                                              +

                                                              +In order to build Motion from source, many shared libraries must be installed. +The particular libraries needed will vary depending upon the features desired. +

                                                              +Note that when you install software using pre-compiled binaries (Redhat type RPMs, Debian debs etc) +you normally only get what is needed to run the programs themselves. In order to compile other programs +from source that uses these pre-compiled libraries you also need to installed the development packages. +These are normally called the same name as the package suffixed by -devel or -dev. These development +packages contains the header files (xxx.h) that Motion needs to build with the shared libraries. If +you build a library from sources you already have these header files. It is recommended to simply +install the pre-compiled binary packages and their development brothers. +

                                                              +Open a terminal and run the following commands to install the packages. +

                                                              +Ubuntu / Debian Packages +
                                                                +
                                                              • Required
                                                              • +
                                                                  +

                                                                  + sudo apt-get install autoconf automake build-essential libtool libzip-dev libjpeg62 libjpeg62-dev +

                                                                  +
                                                                +

                                                                +
                                                              • Optional Packages
                                                              • +
                                                                  +
                                                                • FFMpeg Functionality(Required for creating movies, using network cameras, etc. SEE NOTE BELOW!)
                                                                • +
                                                                    +

                                                                    + sudo apt-get install libav-tools libavformat-dev libavcodec-dev libavutil-dev libswscale-dev +

                                                                    + OR (DO NOT RUN BOTH OF THESE COMMANDS!) +

                                                                    + sudo apt-get install ffmpeg libavformat-ffmpeg-dev libavcodec-ffmpeg-dev libavutil-ffmpeg-dev libswscale-ffmpeg-dev +

                                                                    +
                                                                  +
                                                                • MySQL database functionality
                                                                • +
                                                                    +

                                                                    + sudo apt-get install mysql-server libmysqlclient-dev +

                                                                    +
                                                                  +
                                                                • PostgreSQL database functionality
                                                                • +
                                                                    +

                                                                    + sudo apt-get install postgresql libpq-dev +

                                                                    +
                                                                  +
                                                                • SQLite3 database functionality
                                                                • +
                                                                    +

                                                                    + sudo apt-get install sqlite3 +

                                                                    +
                                                                  +
                                                                • JPEG Turbo
                                                                • +
                                                                    +

                                                                    + sudo apt-get install libjpeg-turbo8 libjpeg-turbo8-dev +

                                                                    +
                                                                  +
                                                                • SDL
                                                                • +
                                                                    +

                                                                    + sudo apt-get install libsdl1.2-dev +

                                                                    +
                                                                  + +
                                                                + Important ffmpeg/libav note: Only ONE of the set of packages indicated above are needed by Motion. The set of + packages and whether they are Libav or ffmpeg is a user selection and possibly dependent upon which is + available in the Ubuntu/Debian repositories. The source code with the latest fixes will work with either Libav or + ffmpeg. Older source code may compile better using one or the other. It is important to note that many repositories + do NOT include both Libav and ffmpeg. They will only have one or the other. +
                                                              +

                                                              +

                                                              +openSUSE Packages +
                                                                +
                                                              • Required
                                                              • +
                                                                  +

                                                                  + sudo zypper install autoconf automake libtool +

                                                                  + sudo zypper install --type pattern devel_basis +

                                                                  + sudo zypper install libjpeg8-devel +

                                                                  + sudo zypper install -t pattern devel_C_C++ +

                                                                  +
                                                                +

                                                                +
                                                              • Optional Packages
                                                              • +
                                                                  +
                                                                • FFMpeg Functionality(Required for creating movies, using network cameras, etc. SEE NOTE BELOW!)
                                                                • +
                                                                    +

                                                                    + sudo zypper ar -f -n packman-essentials http://packman.inode.at/suse/openSUSE_13.1/Essentials/ packman-essentials +

                                                                    + sudo zypper ar -f -n packman-multimedia http://packman.inode.at/suse/openSUSE_13.1/Multimedia/ packman-multimedia +

                                                                    + sudo zypper install libffmpeg-devel +

                                                                    +
                                                                  +
                                                                • MySQL database functionality
                                                                • +
                                                                    +

                                                                    + Not known by author +

                                                                    +
                                                                  +
                                                                • PostgreSQL database functionality
                                                                • +
                                                                    +

                                                                    + Not known by author +

                                                                    +
                                                                  +
                                                                • SQLite3 database functionality
                                                                • +
                                                                    +

                                                                    + Not known by author +

                                                                    +
                                                                  +
                                                                + Important ffmpeg note: The ffmpeg libraries indicated above are provided by a external repository. This may + change in the future. Validate that the repository is still valid when doing the install on openSUSE systems. +
                                                              +

                                                              +

                                                              +
                                                            +

                                                            Configure Script

                                                            +
                                                              +Motion uses a set tools called the "autotools" in order to generate the required scripts in order to +compile and install Motion. The next step after gathering all of the required and desired libraries is to +have the autotools create a configure script. To do this open a terminal and change to the directory with +the source code and type +

                                                              +autoreconf +

                                                              +If the 'configure' file exists and contains a valid script, the tool will return immediately since no additional work +needs to be completed. If the script needs updating, then it will take a moment to return. Once it has been executed, +a file called 'configure' will exist in the directory. Note that if the command is run as +

                                                              +autoreconf -f +

                                                              +The -f parameter instructs it to force a new configure file to be created. This can be preferable in certain +situations so that the configure script gets updated with the correct version number. +Once the 'configure' file is created, we can execute it. What the script does is interrogate the system and look +for all the needed items in order to compile Motion. In this process it looks to determine which optional components +have been installed on the system and if found sets flags to indicate for them to be included. If a particular library +is required by Motion and is not found, the configure script will issue an error. The error means that the library was +not found because it was either not installed or that it was installed into a location that the script could not find. +With the Motion configure script, once it has ended it also lists out all of the optional components that were located. +Note that if you KNOW that a particular component is installed yet the configure script reports it as not installed, then +it may be necessary to use one or more of the configure options described below to tell the script where to find +the particular component. (This happens frequently with the Libav/ffmpeg libraries since the install location has changed +numerous times). + +

                                                              +To run the configure your current directory must be the motion directory. You type +

                                                              ./configure -

                                                              -You can add the parameter ./configure --help to get help on the different switches. -

                                                              -This is walk through of the options. -

                                                              - - -

                                                              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

                                                              +You can add the parameter ./configure --help to get help on the different switches. + +The following table lists the current configure options. +

                                                              + + +
                                                              Option Description
                                                              Defaults for the options
                                                              are specified in brackets [ ]
                                                              Editors comment
                                                              -h, --help display this help and exit  
                                                              --help=short display options specific to this package This command shows the options special to motion. Recommended
                                                              --help=recursive display the short help of all the included packages  
                                                              -V, --version display version information and exit Gives no useful information
                                                              -q, --quiet, --silent do not print `checking...' messages Not very useful. Output to screen is only a few lines anyway.
                                                              --cache-file=FILE cache test results in FILE. [disabled] No function
                                                              -C, --config-cach alias for `--cache-file=config.cache' No function
                                                              -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk
                                                              --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory.
                                                              Installation directories:    
                                                              --prefix=PREFIX install architecture-independent files in PREFIX
                                                              [/usr/local]
                                                              The default /usr/local means that the executable binary "motion" is installed in /usr/local/bin, the manual page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version, configuration file in /usr/local/etc/motion, and some examples config files in /usr/local/examples/motion-versionEditor recommends keeping this default setting.
                                                              If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                              This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                              If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                              Example: --prefix=$HOME
                                                              --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
                                                              [PREFIX]
                                                              If you set this it only defines an alternative installation directory for the executable binary.
                                                              Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
                                                              Editor recommends leaving this as default (i.e. not setting it).
                                                              --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control.
                                                              --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it.
                                                              --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it.
                                                              --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it.
                                                              --sysconfdir=DIR read-only single-machine data [PREFIX/etc] This is where motion both installs the default configuration file and also where it later searches for it.
                                                              Motion searches for the configuration file "motion.conf" in the following order:

                                                                1. Current directory from where motion was invoked
                                                                2. $HOME/.motion
                                                                3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/motion

                                                              Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again.
                                                              --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it.
                                                              --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it.
                                                              --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it.
                                                              --includedir=DIR C header files [PREFIX/include] Not used by motion. Ignore it.
                                                              --oldincludedir=DIR C header files for non-gcc [/usr/include] Not used by motion. Ignore it.
                                                              --infodir=DIR info documentation [PREFIX/info] Not used by motion. Ignore it.
                                                              --mandir=DIR man documentation [PREFIX/man] Editor recommends the default.
                                                              Optional Packages:    
                                                              --with-ffmpeg=DIR Specify the path for the directory prefix in which the library and headers are installed.
                                                              If not specified configure will search in /usr/ and /usr/local/
                                                              DIR is the directory PREFIX in which the ffmpeg shared libraries and their headers are installed.
                                                              If you install ffmpeg from sources and use the default directories or if ffmpeg is installed as a binary package (RPM or deb) you do not need to specify the directory prefix. Configure will find the libraries automatically. If you installed ffmpeg from sources and specified a different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR).
                                                              For more information on FFmpeg see the FFmpeg project home page.
                                                              FFmpeg is a package that enables streamed video mpeg signal from your web camera to a browser.
                                                              Editor recommends installing ffmpeg from source and in the directory /usr/local/ffmpeg and build ffmpeg with ./configure --enable-shared.
                                                              This places libraries in /usr/local/lib and headers in /usr/local/include.
                                                              --without-ffmpeg Do not compile with ffmpeg Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg.
                                                              --with-mysql-lib=DIR Lib directory of MySQL Normally, configure will scan all possible default installation paths for MySQL libs. When its fail, use this command to tell configure where MySQL libs installation root directory is.
                                                              --with-mysql-include=DIR Include directory with headers for MySQL Normally, configure will scan all possible default installation paths for MySQL include. When its fail, use this command to tell configure where MySQL include installation directory is. This is the directory with the MySQL header files.
                                                              --without-mysql Do not compile with MySQL support Use this if you do not want to include MySQL support in the package.
                                                              This can also be useful if you get compilation errors related to MySQL and you actually do not need the feature anyway.
                                                              --with-pgsql=DIR Include PostgreSQL support. DIR is the PostgreSQL base install directory, defaults to /usr/local/pgsql.
                                                              Set DIR to "shared" to build as a dynamic library, or "shared,DIR" to build as a dynamic library and still specify DIR.
                                                              Default is that make searches in the normal installation directories of most distributions.
                                                              See section later about PostgreSQL about potential problem during compilation. There is an easy workaround for it.
                                                              --without-pgsql Do not compile with PostgreSQL support Use this if you do not want to include PostgreSQL support in the package.
                                                              This can also be useful if you get compilation errors related to PostgreSQL and you actually do not need the feature anyway.
                                                              --without-v4l Exclude using v4l (video4linux) subsystem. Makes Motion so it only supports network cameras. Can be used if you do not need V4L support and maybe lack some of the libraries for it.
                                                              --with-linuxthreads Use linuxthreads in BSD instead of native phtreads Only relevant for BSD. In Linux we always use this per default.
                                                              --without-bktr Exclude to use bktr subsystem , that usually useful for devices as network cameras ONLY used in *BSD
                                                              --with-jpeg-mmx=DIR Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling (optional). If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. Considered experimental
                                                              --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. Use this if the optimization causes problems. Typically if you build on some non X386 compatible CPU.
                                                              Developers options    
                                                              --with-developer-flags Add additional warning flags for the compiler. This option is for developers only. It produces a flood of warnings that helps the developer to write more robust code. These warnings are normally harmless but can sometimes be a latent defect.
                                                              For more information about these flags, see CompileWithDeveloperFlags
                                                              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                                                              Options Description
                                                              Defaults for the options are specified in brackets [ ]
                                                              Editors comment
                                                              -h, --help display this help and exit
                                                              --help=short display options specific to this package This command shows the options special to motion. Recommended
                                                              --help=recursive display the short help of all the included packages
                                                              -V, --version display version information and exit Provides the version number of the source code and autotools
                                                              -q, --quiet, --silent do not print `checking...' messages Illustrates only the results of the script.
                                                              --cache-file=FILE cache test results in FILE. [disabled] No function
                                                              -C, --config-cach alias for `--cache-file=config.cache' No function
                                                              -n, --no-create do not create output files Used for testing if other switches produce error - without writing anything to the disk
                                                              --srcdir=DIR find the sources in DIR. [configure dir or `..'] DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory.
                                                              Installation directories:    
                                                              --prefix=PREFIX install architecture-independent files in PREFIX
                                                              [/usr/local]
                                                              The default /usr/local means that

                                                              The executable binary "motion" is installed in /usr/local/bin
                                                              The manual page in /usr/local/man/man1
                                                              The document files in /usr/local/docs/motion-version
                                                              The configuration file in /usr/local/etc
                                                              The example config files in /usr/local/examples/motion-version

                                                              The editor recommends keeping this default setting.
                                                              If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                              This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                              If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                              Example: --prefix=$HOME
                                                              --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
                                                              [PREFIX]
                                                              If you set this it only defines an alternative installation directory for the executable binary.
                                                              Note: The executable binary will be placed in a directory "bin" below the directory specified by this option
                                                              Editor recommends leaving this as default (i.e. not setting it).
                                                              --bindir=DIR user executables [EPREFIX/bin] With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control.
                                                              --sbindir=DIR System admin executables [EPREFIX/sbin] Not used by motion. Ignore it.
                                                              --libexecdir=DIR program executables [EPREFIX/libexec] Not used by motion. Ignore it.
                                                              --datadir=DIR read-only architecture-independent data [PREFIX/share] Not used by motion. Ignore it.
                                                              --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + This is where motion both installs the default configuration file and also where it later searches for it.
                                                              + Motion searches for the configuration file "motion.conf" in the following order: +
                                                              +

                                                                1. Current directory from where motion was invoked +
                                                                2. $HOME/.motion +
                                                                3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/
                                                                +

                                                              Editor recommends leaving this at default. Be careful if you run "make install" again. + This will overwrite the motion-dist.conf file that you may have edited. +
                                                              --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] Not used by motion. Ignore it.
                                                              --localstatedir=DIR modifiable single-machine data [PREFIX/var] Not used by motion. Ignore it.
                                                              --libdir=DIR object code libraries [EPREFIX/lib] Not used by motion. Ignore it.
                                                              --includedir=DIR C header files [PREFIX/include] Not used by motion. Ignore it.
                                                              --oldincludedir=DIR C header files for non-gcc [/usr/include] Not used by motion. Ignore it.
                                                              --infodir=DIR info documentation [PREFIX/info] Not used by motion. Ignore it.
                                                              --mandir=DIR man documentation [PREFIX/man] Editor recommends the default.
                                                              Optional Packages:    
                                                              --with-linuxthreads Use linuxthreads in BSD instead of native phtreads Only relevant for BSD. In Linux we always use this per default.
                                                              --with-pwcbsd Use pwcbsd based webcams ( only BSD ) This option allow to build motion to support V4L/V4L2 in BSD.
                                                              --without-bktr Exclude to use bktr subsystem , that usually useful for devices as network cameras ONLY used in *BSD
                                                              --without-v4l Exclude using v4l (video4linux) subsystem. Makes Motion so it only supports network cameras. Can be used if you do not need support and maybe lack some of the libraries for it.
                                                              --with-jpeg-mmx=DIR Specify the prefix for the install path for jpeg-mmx for optimized jpeg handling (optional). If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. Considered experimental
                                                              --with-ffmpeg=DIR Specify the path for the directory prefix in which the library and headers are installed .
                                                              If not specified configure will search in /usr/ and /usr/local/
                                                              DIR is the directory PREFIX in which the ffmpeg shared libraries + and their headers are installed.
                                                              If you install ffmpeg from sources and use the default directories or + if ffmpeg is installed as a binary package (RPM or deb) you may not need to specify the directory prefix. + Configure should find the libraries automatically. If you installed ffmpeg from sources and specified a + different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR). + For more information on FFmpeg see the documentation for the FFmpeg project.
                                                              --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. DIR is the directory PREFIX in which the ffmpeg headers are installed.
                                                              If you install ffmpeg from sources and use the default directories or + if ffmpeg is installed as a binary package (RPM or deb) you may not need to specify the directory prefix. + Configure should find the libraries automatically. If you installed ffmpeg from sources and specified a + different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR). + For more information on FFmpeg see the documentation for the FFmpeg project.
                                                              --with-ffmpeg-libs=libs Specify the extra libs ffmpeg. libs is a list of libraries associated with ffmpeg necessary for linking.
                                                              --without-ffmpeg Do not compile with ffmpeg Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg.
                                                              --with-mysql-lib=DIR Lib directory of MySQL Normally, configure will scan all possible default installation paths for MySQL libs. When its fail, use this command to tell configure where MySQL libs installation root directory is.
                                                              --with-mysql-include=DIR Include directory with headers for MySQL Normally, configure will scan all possible default installation paths for MySQL include. When its fail, use this command to tell configure where MySQL include installation directory is. This is the directory with the MySQL header files.
                                                              --without-mysql Do not compile with MySQL support Use this if you do not want to include MySQL support in the package.
                                                              This can also be useful if you get compilation errors related to MySQL and you actually do not need the feature anyway.
                                                              --with-pgsql-lib=DIR Normally, configure will scan all possible default installation paths for pgsql libs. When it fails, use
                                                              this command to tell configure where pgsql libs installation root directory is.
                                                               
                                                              --with-pgsql-include=DIR Normally, configure will scan all possible default installation paths for pgsql include. When it fails, use this command to tell configure where pgsql include installation root directory is.  
                                                              --without-pgsql Do not compile with PostgreSQL support Use this if you do not want to include PostgreSQL support in the package.
                                                              This can also be useful if you get compilation errors related to PostgreSQL and you actually do not need the feature anyway.
                                                              --without-sqlite3 Disable sqlite3 support in motion. Use this if you do not want to include SQLite3 support in the package.
                                                              This can also be useful if you get compilation errors related to SQLite4 and you actually do not need the feature anyway.
                                                              --without-optimizecpu Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu. Use this if the optimization causes problems. Typically if you build on some non X386 compatible CPU.
                                                              --without-sdl Compile without sdl support.  
                                                              --with-jpeg-turbo=DIR Specify the prefix for the install path for jpeg-turbo for optimized jpeg handling (optional).  
                                                              --with-developer-flags Add additional warning flags for the compiler. This option is for developers only. It produces a flood of warnings that helps the developer to write more robust code. These warnings are normally harmless but can sometimes be a latent defect.
                                                              - -
                                                              -
                                                              -

                                                              -

                                                              Make

                                                              -When you run make, all the C-source files are automatically compiled and linked. Just look out for error messages. -

                                                              -Make uses a file called "Makefile" which is generated by the "configure" script you just ran. If you have special needs you can manually edit this file. Next time you run configure a new Makefile will be generated and your changes are lost. -

                                                              -ALERT! Attention! -

                                                              -If you have run make before, you should run a make clean before running make again. This cleans out all the object files that were generated the previous time you ran make. If you do not run make clean first before you rebuild Motion you may not get the additional feature included. For example: If you built Motion without ffmpeg support and then add it later - and rebuild Motion without running make clean first - the ffmpeg feature does not get compiled into the Motion binary. -

                                                              -First time you build motion run ./configure, make, make install. If you need to build it again (to run with different configure options) run ./configure, make clean, make, make install. -

                                                              -

                                                              Make Install

                                                              -make install simply copies all the nice files that were generated during the compilation/linking that make did. -

                                                              -Makes the directories (if they do not already exist)(path shown are the defaults): /usr/local/bin, usr/local/man/man1, /usr/local/etc, /usr/local/share/doc/motion-3.2.X, and /usr/local/share/doc/examples/motion-3.2.X. -

                                                              -Copies the following files from the base motion directory (assuming the default PREFIX /usr/local was used when running configure - otherwise adjust to the actuals you chose)

                                                                -
                                                              • Executable binary "motion" to /usr/local/bin -
                                                              • Manual page "motion.1" to /usr/local/man/man1 -
                                                              • Document files "CHANGELOG, COPYING, CREDITS, INSTALL, and README to /usr/local/share/doc/motion-3.2.X -
                                                              • Example configuration files "*.conf" to /usr/local/share/doc/examples/motion-3.2.X -
                                                              • Configuration file "motion-dist.conf" to /usr/local/etc/motion -
                                                              -Note that the any existing files are overwritten. The default config file motion-dist.conf is named like this so that you do not get your working motion.conf file overwritten when you upgrade Motion. -

                                                              -

                                                              Un-install

                                                              +

                                                              +

                                                              +
                                                            +

                                                            Make

                                                            +
                                                              + +Once the configure script finishes successfully, a 'makefile' is created. The makefile builds the Motion program +and links in all of the required libraries. To run the makefile, type +

                                                              +make +

                                                              +The makefile will go through each of the files and compile it. Depending upon the source code obtained, there may be many +warnings or possibly none. +

                                                              +If the notifications indicate many many undefined references, then it is most likely that +an additional library needs to be added in via the configure switches. Many of these additional libraries are related +to the version of ffmpeg and how it was built or installed. The following is a sample of the configuration +line that needs to be run to add references to the ffmpeg libraries. Note that it is unlikely that ALL of these +libraries would be needed and this sample is only intended to provide some guidance. As indicated, the libraries are +associated with ffmpeg and how that component was created. +

                                                              + +./configure --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " + +

                                                              + +

                                                              +Once the makefile has completed correctly, it will report 'build complete'. +

                                                              +ALERT! +

                                                              +If you have run make before, you should run a make clean before +running make again. This cleans out all the object files that were +generated the previous time you ran make. If you do not run make clean first +before you rebuild Motion you may not get the additional feature included. +For example: If you built Motion without ffmpeg support and then add it later and rebuild Motion +without running make clean first the ffmpeg feature does not get compiled into the Motion binary. +

                                                              +First time you build motion run ./configure, make, make install. +If you need to build it again (to run with different configure options) run ./configure, +make clean, make, make install. +

                                                              +

                                                              Make Install

                                                              +make install copies and installs all the files that were generated during the compilation/linking +that make did. +

                                                              +Creates the directories (if they do not already exist)(path shown are the defaults): +
                                                                +
                                                              • /usr/local/bin
                                                              • +
                                                              • usr/local/man/man1
                                                              • +
                                                              • /usr/local/etc
                                                              • +
                                                              • /usr/local/share/doc/motion-version
                                                              • +
                                                              • /usr/local/share/doc/examples/motion-version
                                                              • +
                                                              +

                                                              + +Copies the following files from the base motion directory +(assuming the default PREFIX /usr/local was used when running configure. Otherwise adjust to the actuals you chose) +
                                                                +
                                                              • Executable binary "motion" to /usr/local/bin
                                                              • +
                                                              • Manual page "motion.1" to /usr/local/man/man1
                                                              • +
                                                              • Document files "CHANGELOG, COPYING, CREDITS, INSTALL, and README to /usr/local/share/doc/motion-version
                                                              • +
                                                              • Example configuration files "*.conf" to /usr/local/share/doc/examples/motion-version
                                                              • +
                                                              • Configuration file "motion-dist.conf" to /usr/local/etc
                                                              • +
                                                              + +Note that the any existing files are overwritten. The default config file motion-dist.conf is named like +this so that you do not get your working motion.conf file overwritten when you upgrade Motion. + +

                                                              +

                                                              Un-install

                                                              From the motion base installation directory you simply run make uninstall -

                                                              +

                                                              And delete the base installation directory in /usr/local and any link pointing to it. If you have forgotten where you installed it or someone else did it for you, simply search for the files and directories starting with motion. If the filenames and the directories match the names described in the "Make Install" section of this document, you can safely delete them. -

                                                              -

                                                              Additional Make Options

                                                              +

                                                              +

                                                              Additional Make Options

                                                              The make command can be run with several options. make, make install and make uninstall has already been described above. -

                                                              -
                                                              make clean
                                                              deletes all the binary files (object files) and the motion binary generated by make. It also deletes temporary files and any jpg files that motion has saved in the motion source directory. It is very important to always run make clean before you run make if you change the configuration (like adding features such as ffmpeg) and rebuild motion. -
                                                              -

                                                              -
                                                              make distclean
                                                              deletes the files: config.status, config.log, config.cache, Makefile, and motion.spec. -
                                                              -

                                                              -
                                                              make updateguide
                                                              fetches a fresh new copy of this guide and place it in your motion source directory. Note that the pictures are not downloaded. -
                                                              -

                                                              -
                                                              make dist
                                                              performs make clean, make distclean and make updateguide in one single operation. -
                                                              -

                                                              -

                                                              -

                                                              Upgrading From Older Version

                                                              -If you are upgrading from motion 3.0.X or from an older version of 3.1.X you should note that many options have been removed from version 3.1.13 and forward and many new have arrived. You still have most of the old features. The options have been changed for two reasons. New more flexible features and to simplify getting started with Motion. With 3.2.1 the changes are significant. -You should also note these major differences.
                                                                -
                                                              • The use of thread files has completely changed. Read the section "The Config Files" carefully. -
                                                              • The mask file format has changed. Read the section about "Mask File" -
                                                              • Pre_capture feature introduced in 3.1.12 -
                                                              • Advanced filename feature enables very flexible filename definitions (3.1.13) -
                                                              • onffmpegclose options enables running external scripts when mpeg file is closed (3.1.13) -
                                                              • despeckle feature improves motion detection and noise immunity (3.1.13) -
                                                              • Minimum_motion_frames feature prevents short noise events from being saved (3.1.14) -
                                                              • If you use the database features you need to note that from version 3.1.15 and forward the fields have been redefined. Removed are second, minute, hour, day, month and year. Instead these six have been replaced by a real timestamp field called time_stamp. The relatively new field 'type' has been renamed to 'file_type' to avoid reserved SQL words. A new field 'text_left' has been added which stores the text given by the config option text_left. And last a field called 'camera' has been added which stores the thread number. -
                                                              • From 3.1.15 the ffmpeg feature now also supports mpeg4 and msmpeg4. The build process of Motion now use ffmpeg libraries as shared libraries. The --with-libavcodec has been replaced by a --with-ffmpeg which only needed to specify if you are installing ffmpeg from sources in a non-standard location. If you have installed ffmpeg from sources already you will need to rebuild by running (from within the ffmpeg source file root) ./configure --enable-shared followed by make and make install. If you had installed ffmpeg from a binary RPM or deb you probably don't have to do anything. -
                                                              • Rotate feature was introduced in 3.1.15 -
                                                              • Berkeley mpeg feature has been removed in 3.1.18 (use ffmpeg - it is much better) -
                                                              • Incomplete prediction feature was removed in 3.1.18. (lack of interest in finishing it) -
                                                              • Smart Mask feature introduced in 3.1.18 -
                                                              • output_normal can now also have the value "first" which means only save first jpg from each event (3.1.18) -
                                                              • ffmpeg-0.4.9 is now supported. Motion detection mpegs can no longer be saved as mpeg1 (ffmpeg does not support non-standard framerates in 0.4.9) (3.1.18) -
                                                              • Motion now supports most (not all) mjpeg streaming cameras (3.1.18). -
                                                              • output_normal can now have values "first" or "best". It is used when you need to present a link to an mpeg movie shown as a single jpeg image. "First" saves the first picture frame in the new event. "Best" saves the picture frame with most motion content (most changed pixels) when the event is over. "on" still saves all motion detection picture frames plus pre and post captured images. With "best" you can set jpeg_filename = "preview" and it gets the same filename as the mpeg file but with extension .jpg. Option "locate" can also take the value "preview" which makes it only draw a rectangel on the jpeg but not on the mpeg movie. (3.2.1) -
                                                              • The xmlrpc remote control interface is replaced by a much nicer http remote control interface. (3.2.1) -
                                                              • All the options that calls external programs have been made much more generic. New onxxxx options have been added. Execute, sms and mail have been replaced by the generic on_event_start. (3.2.1) -
                                                              • New setup mode makes setting all the detection options much easier. -
                                                              • netcam now also supports proxies (3.2.2) and ftp (3.2.4) -
                                                              • text on the pictures can be set to double size (3.2.2) -
                                                              • Tracking with Logitech Sphere/Orbit improved (3.2.4) -
                                                              • SQL database feature is now fully configurable so you can control which fields you have in the database. -
                                                              • Many new conversion specifiers have been added which can be used both in filenames, commands, text, and SQL database features (3.2.2-3.2.4) -
                                                              • Stepper motor tracking feature extended to also include a Y axis (3.2.5) -
                                                              • ffmpeg_filename has been renamed to movie_filename to prepare for alternative implementation to mpeg files made with ffmpeg (3.2.5) -
                                                              • New feature: ffmpeg_deinterlace which can de-interlace using the ffmpeg libs (3.2.5) -
                                                              • New feature: minimum_frame_time which enables Motion to run at frame rates below 2. minimum_gap feature was removed since this was useless and the new minimum_frame_time feature replaces it with much better function. (3.2.7) -
                                                              • New feature: process_id_file which writes a PID file when started and removes it when stopped (3.2.7) -
                                                              • V4L2 support with many new supported palettes : V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_UYVY (3.2.8) -
                                                              • ffmpeg_video_codec allow swf (3.2.8) -
                                                              • V4L2 fix support for : V4L2_PIX_FMT_MJPEG (3.2.9) -
                                                              • ffmpeg_video_codec allow flv and ffv1(3.2.9) -
                                                              -

                                                              -

                                                              -The table below shows the new options in the left column, and obsolete options in the right column. If the there are options on both sides in a row it means that the options in the left column replaced the options in the right column. -

                                                              - -

                                                              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                              New Options Obsolete Options
                                                              text_left (3.1.13)
                                                              text_right (3.1.13)
                                                              text_changes (3.1.13)
                                                              drawtext_user (3.1.13)
                                                              drawtext_shots (3.1.13)
                                                              drawtext_changes (3.1.13)
                                                              jpeg_filename (3.1.13)
                                                              ffmpeg_filename (3.1.13)
                                                              snapshot_filename (3.1.13)
                                                              timelapse_filename (3.1.13)
                                                              predict_filename (3.1.13)
                                                              (predict_filename removed in 3.1.18)
                                                              oldlayout (3.1.13)
                                                              snapshots_overwrite (3.1.13)
                                                              snapshot_interval (3.1.13) snapshots (3.1.13)
                                                                realmotion (3.1.13)
                                                              despeckle (3.1.13)  
                                                              pre_capture (3.1.12)  
                                                              ffmpeg_timelapse (v. 3.1.14) ffmpeg_timelaps (renamed v 3.1.14)
                                                              ffmpeg_timelapse_mode (3.1.14)  
                                                              sql_log_image (3.1.14)
                                                              sql_log_snapshot (3.1.14)
                                                              sql_log_mpeg (3.1.14)
                                                              sql_log_timelapse (3.1.14)
                                                              sql_log_prediction (3.1.14)
                                                               
                                                              minimum_motion_frames (3.1.14)  
                                                              rotate (3.1.15)  
                                                              ffmpeg_variable_bitrate (3.1.15)
                                                              ffmpeg_video_codec (3.1.15)
                                                               
                                                                berkeley_single_directory (3.1.18)
                                                              mpeg_encode (3.1.18)
                                                              mpeg_encode_bin (3.1.18)
                                                              adjust_rate off (3.1.18)
                                                              jpg_cleanup (3.1.18)
                                                                predict_filename (3.1.18)
                                                              predict_enable (3.1.18)
                                                              predict_threshold (3.1.18)
                                                              predict_description (3.1.18)
                                                              sql_log_prediction (3.1.18)
                                                              brightness (3.1.18)
                                                              contrast (3.1.18)
                                                              saturation (3.1.18)
                                                              hue (3.1.18)
                                                               
                                                              smart_mask_speed (3.1.18)  
                                                              output_normal
                                                              valid values are now "on", "off", "first" (3.1.18) and "best" (3.2.1)
                                                               
                                                              setup_mode (3.2.1) always_changes (3.2.1)
                                                              locate
                                                              valid values are now "on", "off", "preview" (3.2.1)
                                                               
                                                              jpeg_filename
                                                              Besides normal path names the value "preview" has speciel meaning together with output_normal = "best" (3.2.1)
                                                               
                                                              control_html_output (3.2.1)  
                                                              on_event_start (3.2.1)
                                                              execute (3.2.1)
                                                              sms (3.2.1)
                                                              mail (3.2.1)
                                                              on_event_end (3.2.1)
                                                               
                                                              on_motion_detected (3.2.1)
                                                               
                                                              on_picture_save (3.2.1)
                                                              onsave (3.2.1)
                                                              on_movie_start (3.2.1)
                                                              on_movie_end (3.2.1)
                                                              onmpeg (3.2.1)
                                                              onffmpegclose (introduced 3.1.13)(renamed to on_movie_end 3.2.1)
                                                              netcam_proxy (3.2.2)  
                                                              text_double (3.2.2)  
                                                              webcam_motion
                                                              Feature has been heavily improved so it is actually usefull now (3.2.2).
                                                               
                                                              netcam_url
                                                              Now also supports fetching single frame jpeg pictures via ftp using ftp:// syntax (3.2.4)
                                                               
                                                              track_step_angle_x (3.2.4)
                                                              track_step_angle_y (3.2.4)
                                                              Add better configuration of auto tracking with a Logitech Sphere/Orbit camera.
                                                               
                                                              track_move_wait (3.2.4)
                                                              track_auto (3.2.4)
                                                              Adds better configuration of auto tracking feature
                                                               
                                                              sql_query (3.2.4)
                                                              Adds full flexibility of defining fields when using the SQL database features.
                                                               
                                                              track_maxy (3.2.5)
                                                              track_motory (3.2.5)
                                                               
                                                              movie_filename (3.2.5) ffmpeg_filename (3.2.5)
                                                              ffmpeg_deinterlace (3.2.5)  
                                                              minimum_frame_time (3.2.7) minimum_gap (3.2.7)
                                                              process_id_file (3.2.7)  
                                                              ffmpeg_video_codec allow swf (3.2.8)  
                                                              ffmpeg_video_codec allow flv and ffv1 (3.2.9)  
                                                                night_compensate (3.2.10)
                                                              low_cpu (3.2.10)
                                                              - -
                                                              -
                                                              -

                                                              -

                                                              Running Motion

                                                              -

                                                              -

                                                              Important Definitions

                                                              -Motion is invoked from the command line. It has no GUI. Everything is controlled from config files. From version 3.2 the command line is only used to define location of config file and a few special runtime modes (setup and non-daemon). -

                                                              -A few important definitions.

                                                                -
                                                              • A snapshot is a picture taken at regular intervals independently of any movement in the picture. -
                                                              • A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. -
                                                              • A "normal" image is the real image taken by the camera with text overlayed. -
                                                              -

                                                              - -

                                                              The Config Files

                                                              -

                                                              +

                                                              +
                                                              +
                                                              make clean
                                                              +
                                                              deletes all the binary files (object files) and the motion binary generated by make. It also deletes temporary files and any jpg files that motion has saved in the motion source directory. It is very important to always run make clean before you run make if you change the configuration (like adding features such as ffmpeg) and rebuild motion.
                                                              +
                                                              +

                                                              +
                                                              +
                                                              make distclean
                                                              +
                                                              deletes the files: config.status, config.log, config.cache, Makefile, and motion.spec.
                                                              +
                                                              +

                                                              +
                                                              +
                                                              make updateguide
                                                              +
                                                              fetches the copy of this guide from the web page and puts it in your motion source directory. Note that the pictures are not downloaded.
                                                              +
                                                              +

                                                              +
                                                              +
                                                              make dist
                                                              +
                                                              performs make clean, make distclean and make updateguide in one single operation.
                                                              +
                                                              + +

                                                              +

                                                              + +
                                                            +

                                                            Upgrading From Older Version

                                                            +
                                                              + If you are upgrading from an older version of Motion you should note that many many options have been rename, added or removed. + The author recommends that you start by copying the configuration files from the older version to a safe location for reference only. + Then start with a clean copy of the new motion-dist.conf installed and make changes to it. +

                                                              +

                                                              +
                                                            +

                                                            Running Motion

                                                            +
                                                              + +

                                                              +

                                                              +
                                                            + +
                                                          + +

                                                          Important Definitions

                                                          +
                                                            + +

                                                            +Motion is invoked from the command line. It has no GUI. Everything is controlled from config files. +From version 3.2 the command line is only used to define location of config file and a few special +options. +

                                                            +A few important definitions. +
                                                              +
                                                            • A snapshot is a picture taken at regular intervals independently of any movement in the picture.
                                                            • +
                                                            • A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in red.
                                                            • +
                                                            • A "normal" image is the real image taken by the camera with text overlayed.
                                                            • +
                                                            + +

                                                            +

                                                            +
                                                          + +

                                                          The Configuration Files

                                                          +
                                                            + +

                                                            If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. -

                                                            +

                                                            If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: -

                                                              -
                                                            1. Current directory from where motion was invoked -
                                                            2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf -
                                                            3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion
                                                              (If this option was not defined the default is /usr/local/etc/motion) -
                                                            -If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file in the default /usr/local/etc/motion directory. -

                                                            -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this file gets copied to the /usr/local/etc/motion directory. -

                                                            +

                                                            +
                                                              +
                                                            1. Current directory from where motion was invoked
                                                            2. +
                                                            3. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf
                                                            4. +
                                                            5. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion
                                                              (If this option was not defined the default is /usr/local/etc/motion)
                                                            6. +
                                                            + +If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file +in the default /usr/local/etc/motion directory. +

                                                            +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this +file gets copied to the /usr/local/etc/motion directory. +

                                                            The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. -

                                                            -If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. -

                                                            +

                                                            +If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra thread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. +

                                                            So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. -

                                                            +

                                                            An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). -

                                                            +

                                                            An option that is unique to a camera must be defined in each thread file. -

                                                            +

                                                            It is often seen that people copy the entire motion.conf into the thread config files and change a few options. This works but it not recommended because it is more difficult to maintain and overview. Keep all the common options in motion.conf and the few unique only in the thread config files -

                                                            +

                                                            The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. -

                                                            +

                                                            Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. -

                                                            -Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins.

                                                              -
                                                            1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. -
                                                            2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. -
                                                            3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. -
                                                            4. Motion reads the command line option again overruling any previously defined options. -
                                                            +

                                                            +To make it clear, the thread files format and syntax is the same as motion.conf. An example of what you might want in a thread file as follows: assume you have two cameras, attached to one system. Create files thread0.conf and thread1.conf. At the end of motion.conf, uncomment out the lines that refer to them. The full contents of the thread files can be as simple as +

                                                            + +

                                                            +thread0.conf:

                                                            videodevice /dev/video0

                                                            stream_port 8081 +

                                                            +

                                                            +

                                                            +thread1.conf:

                                                            videodevice /dev/video1

                                                            stream_port 8082 +

                                                            +

                                                            +

                                                            +Motion reads its configuration parameters in the following sequence. If the same +parameter exists more than one place the last one read wins + + +
                                                              +
                                                            1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line.
                                                            2. +
                                                            3. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read.
                                                            4. +
                                                            5. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file.
                                                            6. +
                                                            7. Motion reads the command line option again overruling any previously defined options.
                                                            8. +
                                                            So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. -

                                                            -Nearly all config options can be unique for a specific camera and placed in a thread config file. There are a few options that must be in motion.conf and cannot be in a thread config file: control_authentication, control_html_output, control_localhost, control_port, daemon, and thread. -

                                                            -If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. -

                                                            +

                                                            +Nearly all config options can be unique for a specific camera and placed in a thread config file. +There are a few options that must be in motion.conf and cannot be in a thread config +file: stream_auth_method, webcontrol_* , daemon, and thread. +

                                                            +If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. +

                                                            If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. -

                                                            -

                                                            -

                                                            Command Line Options

                                                            -

                                                            -ALERT! In Motion 3.2.1 and forward most command line options have been removed and replaced them by an option to specify location to motion.conf and a few options related to setting up motion. There are now only few command line options left and they are basically all new. -

                                                            + +

                                                            +

                                                            +
                                                          + +

                                                          Command Line Options

                                                          +
                                                            + +

                                                            SYNOPSIS
                                                            -motion [ -hns ] [ -c config file path]
                                                            +motion [ -hbnsm ] [ -c config file path ] [ -d level ] [ -k level ] [ -p process_id_file ] [ -l log_file ]
                                                             
                                                            -

                                                            - -

                                                            - - - - - - - - - +

                                                            +
                                                              +
                                                            • -c : Full path and filename of config file.
                                                            • +
                                                            • -h : Show help screen
                                                            • +
                                                            • -b : Run in daemon mode
                                                            • +
                                                            • -n : Run in non-daemon mode
                                                            • +
                                                            • -s : Run in setup mode. Also forces non-daemon mode.
                                                            • +
                                                            • -d : Run with message log level 1 - 9
                                                            • +
                                                            • -k : Run with message log type 1 - 9
                                                            • +
                                                            • -l : Full path and file name for log file
                                                            • +
                                                            • -p : Full path and file name for the process id file
                                                            • +
                                                            • -m : Start in pause mode
                                                            • +
                                                            +

                                                            +

                                                            + + +

                                                            Signals (sent with e.g. kill command)

                                                            +
                                                              +

                                                              +A signal can be sent from the command line by typing e.g. kill -s SIGHUP pid, where the last parameter is the process ID which you get by typing ps -ef ¦ grep motion. The PID is the first on the list which is the parent process for the threads. +Motion responds to the following signals: +

                                                              +
                                                            Option Description Editors comment
                                                            -n Run in non-daemon mode. Instead of running Motion in the background Motion runs in the terminal window writing messages when things happen. If you have problems getting Motion to start or work, run Motion in this mode to get more messages that can help you solve the problem.
                                                            -s Run in setup mode. Also forces non-daemon mode
                                                            -c config file path Full path and filename of config file. E.g. /home/kurt/motion.conf. Default is /usr/local/etc/motion unless specified differently when building Motion. Many RPMs and debian packages will most likely use /etc or /etc/motion as default
                                                            -h Show help screen.  
                                                            -d level Debugging mode This mode is used for developers to enable debug messages. Normal users will not need to use this mode unless a developer request to get additional information in the attempt to resolve a bug. Mainly the netcam code has debugging features. The level defines how much debugging info you get. A high number displays all debugging.
                                                            -p process_id_file Full path of process ID file Full path and filename of process id file (PID file). This is optional. If none is given as command line option or in motion.conf (process_id_file) Motion will not create a PID file.
                                                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                                                            Signal Description Editors comment
                                                            SIGHUP The config file will be reread. This is a very useful signal when you experiment with settings in the config file.
                                                            SIGTERM If needed motion will create an movie file of the last event and exit  
                                                            SIGUSR1 Motion will create an movie file of the current event.  
                                                            - -
                                                            -
                                                            -

                                                            -

                                                            -

                                                            Config File Options

                                                            + +

                                                            +

                                                            +
                                                          + +

                                                          Error Logging

                                                          +
                                                            + +

                                                            +Motion reports errors to the console when it runs in non-daemon mode. And it outputs +even more information when run in setup mode. +

                                                            +Error logging has been implemented so that errors during daemon (background) mode are logged in the syslog or to the user +specified log file. +

                                                            +The log is in most Linux systems the file /var/log/messages (e.g. RedHat/Fedora) +or /var/log/syslog and /var/log/user.log (e.g. Debian). +

                                                            +

                                                            +
                                                          + +

                                                          Basic Setup

                                                          +
                                                            +

                                                            + +Before you can start using Motion you need to know some basics about your camera. +Either you have a camera connected directly to your computer. In this case it is a video4linux type of camera. +Or you connect to a network camera using a normal web URL. +

                                                            +For video4linux devices, the camera must be installed per the requirements of the camera. It is +out of the scope of this document to tell you how to do this and it depends on which type of camera. Once +the camera is installed it will have the device name(s) of /dev/video0, /dev/video1, /dev/video2... +

                                                            +FreeBSD has a different naming of devices. When you build Motion for FreeBSD the default device name is /dev/bktr0. +Under FreeBSD a TV card has a special device for controlling the tuner (e.g. /dev/tuner0). The option tunerdevice +is only valid when Motion is built and running under FreeBSD. For Linux do not include this option in the config +file (remove or comment out). +

                                                            +USB cameras take a lot of bandwidth. A USB camera connected to a USB 2 port or hub consumes virtually +all the bandwidth that the port can handle. Even with a small framesize and low framerate you should not expect to have +more than one camera per USB controller. If you need more than 1 USB camera it is possible to add extra USB PCI cards +to your computer. It is also possible that your computer has more than one controller for different USB slots. For +example, if the computer has six USB ports, the three on the left may be on controller A versus the three on the right +may be on controller B. In this situation, connecting two cameras to ports only on the left would not work due to +excessive bandwidth. However connecting one camera to port on the right and the other to the port on the left +may work since they are on different controllers. + +Motion permits the use of video cards that have discreet input channels. Since USB cameras do not have input channels, +the option input must be set to the value -1 for USB cameras. +

                                                            + +Network cameras are set up via the netcam_url parameter. The latest versions of Motion support +rtsp format which many cameras now stream. The URL connection string to enter is specific to the camera and is +usually provided by the manufacturer. The connection string is the same as what would be used by other +video playing software such as VLC. If the camera does not stream via RTSP and instead uses a MJPEG, then Motion +can also view that format. See the option netcam_url for additional options. + +

                                                            +Composite video cards are normally made with a chip called BT878 (older cards have a BT848). They +all use the Linux driver called 'bttv'. +

                                                            +There are cards with more then one video input but still only one BT878 chip. They have a video multiplexer which +input is selected with the config option input. Input channel numbers start at 0 +(which is why the value -1 and not 0 disables input selection). There are video capture cards available +with 4 or 8 inputs but only one chip. They present themselves as one single video device and +you select input using the 'input' option. If you define e.g. 4 thread config files with the +same videodevice name but different input numbers Motion automatically +goes into round robin mode. +

                                                            +Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. +Others have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. +For video capture cards input 1 is normally the composite video input. +

                                                            +Some capture cards are specially made for surveillance with for example 4 inputs. +Others have a TV tuner, a composite input (phono socket) and perhaps also a S-VHS input. +For all these cards the inputs are numbered. The numbering varies from card to card so the easiest +is to experiment for 5 minutes with a program that can show the videostream. +Use a program such as Camstream, xawtv or VLC to experiment with the values. +

                                                            +If you use the TV tuner input you also need to set the frequency of the TV channel using the +option frequency. Otherwise set frequency to 0. +

                                                            +Finally you need to set the TV norm. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default is 0 (PAL). +If your camera is a PAL black and white you may get a better result with norm=3 (PAL no colour). +

                                                            +

                                                            +
                                                          + +

                                                          Configuration Options

                                                          +
                                                            + + +

                                                            These are the options that can be used in the config file. -

                                                            +

                                                            All number values are integer numbers (no decimals allowed). Boolean options can be on or off. -

                                                            -Some configuration options are only used if Motion is built on a system that has the matching software libraries installed (MySQL, PostgreSQL and FFMPEG). -

                                                            -MySQL

                                                              -
                                                            • mysql_db, mysql_host, mysql_user, mysql_password -
                                                            -

                                                            -PostgreSQL

                                                              -
                                                            • pgsql_db, pgsql_host, pgsql_user, pgsql_password, pgsql_port -
                                                            -

                                                            -FFMPEG (libavcodec)

                                                              -
                                                            • ffmpeg_cap_new, ffmpeg_cap_motion, ffmpeg_filename, ffmpeg_timelapse, ffmpeg_timelapse_mode, ffmpeg_bps, ffmpeg_variable_bitrate, ffmpeg_video_codec -
                                                            -

                                                            -

                                                            Options in Alphabetical Order.

                                                            -

                                                            -The table below lists all the Motion options in alphabetical order. Click on the option name to see a longer description of each. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

                                                            +Some configuration options are only used if Motion is built on a system that has the matching software libraries installed (MySQL, PostgreSQL, SQLite, FFMPEG, etc). +

                                                            +

                                                            + +System Processing +
                                                              + +
                                                            Option Range/Values
                                                            Default
                                                            Description
                                                            auto_brightness Values: on, off
                                                            Default: off
                                                            Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness
                                                            brightness Values: 0 - 255
                                                            Default: 0 (disabled)
                                                            The brightness level for the video device.
                                                            contrast Values: 0 - 255
                                                            Default: 0 (disabled)
                                                            The contrast level for the video device.
                                                            control_authentication Values: Max 4096 characters
                                                            Default: Not defined
                                                            To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file.
                                                            control_html_output Values: on, off
                                                            Default: on
                                                            Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file.
                                                            control_localhost Values: on, off
                                                            Default: on
                                                            Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file.
                                                            control_port Values: 0 - 65535
                                                            Default: 0 (disabled)
                                                            Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file.
                                                            daemon Values: on, off
                                                            Default: off
                                                            Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file.
                                                            despeckle Values: EedDl
                                                            Default: Not defined
                                                            Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling.
                                                            ffmpeg_bps Values: 0 - 9999999
                                                            Default: 400000
                                                            Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed.
                                                            ffmpeg_cap_motion Values: on, off
                                                            Default: off
                                                            Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes.
                                                            ffmpeg_cap_new Values: on, off
                                                            Default: off
                                                            Use ffmpeg libraries to encode mpeg movies in realtime.
                                                            ffmpeg_deinterlace Values: on, off
                                                            Default: off
                                                            Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures.
                                                            ffmpeg_filename (now called movie_filename) Values: Max 4095 characters
                                                            Default: %v-%Y%m%d%H%M%S
                                                            File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution.
                                                            ffmpeg_timelapse Values: 0 - 2147483647
                                                            Default: 0 (disabled)
                                                            Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.
                                                            ffmpeg_timelapse_mode Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual
                                                            Default: daily
                                                            The file rollover mode of the timelapse video.
                                                            ffmpeg_variable_bitrate Values: 0, 2 - 31
                                                            Default: 0 (disabled)
                                                            Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst.
                                                            ffmpeg_video_codec Values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1
                                                            Default: mpeg4
                                                            Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option.
                                                            framerate Values: 2 - 100
                                                            Default: 100 (no limit)
                                                            Maximum number of frames to be captured from the camera per second.
                                                            frequency Values: 0 - 999999
                                                            Default: 0 (Not set)
                                                            The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it)
                                                            gap Values: 0 - 2147483647
                                                            Default: 60
                                                            Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe.
                                                            height Values: Device Dependent
                                                            Default: 288
                                                            The height of each frame in pixels.
                                                            hue Values: 0 - 255
                                                            Default: 0 (disabled)
                                                            The hue level for the video device.
                                                            input Values: 0 - 7, 8 = disabled
                                                            Default: 8 (disabled)
                                                            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.
                                                            jpeg_filename Values: Max 4095 characters
                                                            Default: %v-%Y%m%d%H%M%S-%q
                                                            File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file.
                                                            lightswitch Values: 0 - 100
                                                            Default: 0 (disabled)
                                                            Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity.
                                                            locate Values: on, off, preview
                                                            Default: off
                                                            Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie.
                                                            low_cpu Values: 0 - 100
                                                            Default: 0 (disabled)
                                                            When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled.
                                                            mask_file Values: Max 4095 characters
                                                            Default: Not defined
                                                            PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format.
                                                            max_mpeg_time Values: 0 (infinite) - 2147483647
                                                            Default: 3600
                                                            The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length.
                                                            minimum_frame_time Values: 0 - 2147483647
                                                            Default: 0
                                                            Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate.
                                                            minimum_gap Values: 0 - 2147483647
                                                            Default: 0 (no minimum)
                                                            The minimum time between two shots in seconds.
                                                            minimum_motion_frames Values: 1 - 1000s
                                                            Default: 1
                                                            Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5.
                                                            motion_video_pipe Values: Max 4095 characters
                                                            Default: Not defined
                                                            The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set
                                                            movie_filename Values: Max 4095 characters
                                                            Default: %v-%Y%m%d%H%M%S
                                                            File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename.
                                                            mysql_db Values: Max 4095 characters
                                                            Default: Not defined
                                                            Name of the MySQL database.
                                                            mysql_host Values: Max 4095 characters
                                                            Default: localhost
                                                            IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server.
                                                            mysql_password Values: Max 4095 characters
                                                            Default: Not defined
                                                            The MySQL password.
                                                            mysql_user Values: Max 4095 characters
                                                            Default: Not defined
                                                            The MySQL user name.
                                                            netcam_proxy Values: Max 4095 characters
                                                            Default: Not defined
                                                            URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber
                                                            netcam_url Values: Max 4095 characters
                                                            Default: Not defined
                                                            Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera.
                                                            netcam_userpass Values: Max 4095 characters
                                                            Default: Not defined
                                                            For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication.
                                                            night_compensate Values: on, off
                                                            Default: off
                                                            When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise.
                                                            noise_level Values: 1 - 255
                                                            Default: 32
                                                            The noise level is used as a threshold for distinguishing between noise and motion.
                                                            noise_tune Values: on, off
                                                            Default: on
                                                            Activates the automatic tuning of noise level.
                                                            norm Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour)
                                                            Default: 0 (PAL)
                                                            Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
                                                            on_event_end Values: Max 4095 characters
                                                            Default: Not defined
                                                            Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command.
                                                            on_event_start Values: Max 4095 characters
                                                            Default: Not defined
                                                            Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command.
                                                            on_motion_detected Values: Max 4095 characters
                                                            Default: Not defined
                                                            Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command.
                                                            on_movie_end Values: Max 4095 characters
                                                            Default: Not defined
                                                            Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
                                                            on_movie_start Values: Max 4095 characters
                                                            Default: Not defined
                                                            Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
                                                            on_picture_save Values: Max 4095 characters
                                                            Default: Not defined
                                                            Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command.
                                                            output_all Values: on, off
                                                            Default: off
                                                            Picture are saved continuously as if motion was detected all the time.
                                                            output_motion Values: on, off
                                                            Default: off
                                                            Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red.
                                                            output_normal Values: on, off, first, best
                                                            Default: on
                                                            Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored.
                                                            pgsql_db Values: Max 4095 characters
                                                            Default: Not defined
                                                            Name of the PostgreSQL database.
                                                            pgsql_host Values: Max 4095 characters
                                                            Default: localhost
                                                            IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server.
                                                            pgsql_password Values: Max 4095 characters
                                                            Default: Not defined
                                                            The PostgreSQL password.
                                                            pgsql_port Values: 0 - 65535
                                                            Default: 5432
                                                            The PostgreSQL server port number.
                                                            pgsql_user Values: Max 4095 characters
                                                            Default: Not defined
                                                            The PostgreSQL user name.
                                                            post_capture Values: 0 - 2147483647
                                                            Default: 0 (disabled)
                                                            Specifies the number of frames to be captured after motion has been detected.
                                                            ppm Values: on, off
                                                            Default: off
                                                            Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg.
                                                            pre_capture Values: 0 - 100s
                                                            Default: 0 (disabled)
                                                            Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.
                                                            process_id_file Values: Max 4095 characters
                                                            Default: Not defined
                                                            File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid
                                                            quality Values: 1 - 100
                                                            Default: 75
                                                            The quality for the jpeg images in percent.
                                                            quiet Values: on, off
                                                            Default: off
                                                            Be quiet, don't output beeps when detecting motion.
                                                            rotate Values: 0, 90, 180, 270
                                                            Default: 0 (not rotated)
                                                            Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies.
                                                            roundrobin_frames Values: 1 - 2147483647
                                                            Default: 1
                                                            Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible.
                                                            roundrobin_skip Values: 1 - 2147483647
                                                            Default: 1
                                                            Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe).
                                                            saturation Values: 0 - 255
                                                            Default: 0 (disabled)
                                                            The colour saturation level for the video device.
                                                            setup_mode Values: on, off
                                                            Default: off
                                                            Run Motion in setup mode.
                                                            smart_mask_speed Values: 0 - 10
                                                            Default: 0 (disabled)
                                                            Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast.
                                                            snapshot_filename Values: Max 4095 characters
                                                            Default: %v-%Y%m%d%H%M%S-snapshot
                                                            File path for snapshots (jpeg or ppm) relative to target_dir.
                                                            snapshot_interval Values: 0 - 2147483647
                                                            Default: 0 (disabled)
                                                            Make automated snapshots every 'snapshot_interval' seconds.
                                                            sql_log_image Values: on, off
                                                            Default: on
                                                            Log to the database when creating motion triggered image file.
                                                            sql_log_mpeg Values: on, off
                                                            Default: off
                                                            Log to the database when creating motion triggered mpeg file.
                                                            sql_log_snapshot Values: on, off
                                                            Default: on
                                                            Log to the database when creating a snapshot image file.
                                                            sql_log_timelapse Values: on, off
                                                            Default: off
                                                            Log to the database when creating timelapse mpeg file
                                                            sql_query Values: Max 4095 characters
                                                            Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
                                                            SQL query string that is sent to the database. The values for each field are given by using convertion specifiers
                                                            switchfilter Values: on, off
                                                            Default: off
                                                            Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection.
                                                            target_dir Values: Max 4095 characters
                                                            Default: Not defined = current working directory
                                                            Target directory for picture and movie files.
                                                            text_changes Values: on, off
                                                            Default: off
                                                            Turns the text showing changed pixels on/off.
                                                            text_double Values: on, off
                                                            Default: off
                                                            Draw characters at twice normal size on images.
                                                            text_event Values: Max 4095 characters
                                                            Default: %Y%m%d%H%M%S
                                                            This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event.
                                                            text_left Values: Max 4095 characters
                                                            Default: Not defined
                                                            User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers (codes starting by a %).
                                                            text_right Values: Max 4095 characters
                                                            Default: %Y-%m-%d\n%T
                                                            User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
                                                            thread Values: Max 4095 characters
                                                            Default: Not defined
                                                            Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file.
                                                            threshold Values: 1 - 2147483647
                                                            Default: 1500
                                                            Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling.
                                                            threshold_tune Values: on, off
                                                            Default: off
                                                            Activates the automatic tuning of threshold level.
                                                            timelapse_filename Values: Max 4095 characters
                                                            Default: %v-%Y%m%d-timelapse
                                                            File path for timelapse mpegs relative to target_dir (ffmpeg only).
                                                            track_auto Values: on, off
                                                            Default: off
                                                            Enable auto tracking
                                                            track_iomojo_id Values: 0 - 2147483647
                                                            Default: 0
                                                            Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller.
                                                            track_maxx Values: 0 - 2147483647
                                                            Default: 0
                                                            The maximum position for servo x.
                                                            track_maxy Values: 0 - 2147483647
                                                            Default: 0
                                                            The maximum position for servo y.
                                                            track_motorx Values: -1 - 2147483647
                                                            Default: -1
                                                            The motor number that is used for controlling the x-axis.
                                                            track_motory Values: -1 - 2147483647
                                                            Default: -1
                                                            The motor number that is used for controlling the y-axis.
                                                            track_move_wait Values: 0 - 2147483647
                                                            Default: 10
                                                            Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames.
                                                            track_port Values: Max 4095 characters
                                                            Default: Not defined
                                                            This is the device name of the serial port to which the stepper motor interface is connected.
                                                            track_speed Values: 0 - 255
                                                            Default: 255
                                                            Speed to set the motor to.
                                                            track_step_angle_x Values: 0-90
                                                            Default: 10
                                                            Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras.
                                                            track_step_angle_y Values: 0-40
                                                            Default: 10
                                                            Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras.
                                                            track_stepsize Values: 0 - 255
                                                            Default: 40
                                                            Number of steps to make.
                                                            track_type Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo)
                                                            Default: 0 (None)
                                                            Type of tracker.
                                                            tunerdevice Values: Max 4095 characters
                                                            Default: /dev/tuner0
                                                            The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD.
                                                            video_pipe Values: Max 4095 characters
                                                            Default: Not defined
                                                            The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe.
                                                            videodevice Values: Max 4095 characters
                                                            Default: /dev/video0 (FreeBSD: /dev/bktr0)
                                                            The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0.
                                                            webcam_limit Values: 0 - 2147483647
                                                            Default: 0 (unlimited)
                                                            Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited.
                                                            webcam_localhost Values: on, off
                                                            Default: on
                                                            Limits the access to the webcam to the localhost.
                                                            webcam_maxrate Values: 1 - 100
                                                            Default: 1
                                                            Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited.
                                                            webcam_motion Values: on, off
                                                            Default: off
                                                            If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate.
                                                            webcam_port Values: 0 - 65535
                                                            Default: 0 (disabled)
                                                            TCP port on which motion will listen for incoming connects with its webcam server.
                                                            webcam_quality Values: 1 - 100
                                                            Default: 50
                                                            Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth.
                                                            width Values: Device Dependent
                                                            Default: 352
                                                            The width in pixels of each frame. Valid range is camera dependent.
                                                            + + + + + + + + + + + + + + + + + + + +
                                                            daemon process_id_file setup_mode logfile
                                                            log_level log_type sdl_threadnr thread
                                                            -

                                                            -

                                                            -

                                                            Signals (sent with e.g. kill command)

                                                            -A signal can be sent from the command line by typing e.g. kill -s SIGHUP pid, where the last parameter is the process ID which you get by typing ps -ef ¦ grep motion. The PID is the first on the list which is the parent process for the threads. -Motion responds to the following signals: -

                                                            - - - - + +

                                                            +

                                                            +

                                                            + + +Video4Linux Devices +
                                                              + +
                                                            Signal Description Editors comment
                                                            SIGHUP The config file will be reread. This is a very useful signal when you experiment with settings in the config file.
                                                            SIGTERM If needed motion will create an mpeg file of the last event and exit  
                                                            SIGUSR1 Motion will create an mpeg file of the current event.  
                                                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                                                            videodevice v4l2_palette tunerdevice input
                                                            norm #frequency power_line_frequency auto_brightness
                                                            brightness contrast saturation hue
                                                            roundrobin_frames roundrobin_skip switchfilter
                                                            +

                                                            +

                                                            +

                                                            +
                                                          + +Network Cameras + + +Image_Processing + + +Motion Detection + + +Script Execution +
                                                            + + + + + + + + + + + + + + + + + + + + + +
                                                            on_event_start on_event_end on_picture_save on_motion_detected
                                                            on_area_detected on_movie_start on_movie_end on_camera_lost
                                                            -

                                                            -

                                                            -

                                                            Error Logging

                                                            -Motion reports errors to the console when it runs in non-daemon mode. And it outputs even more information when run in setup mode. -

                                                            -Error logging has been implemented so that errors during daemon (background) mode are logged in the syslog. -

                                                            -The syslog is in most Linux systems the file /var/log/messages (e.g. RedHat/Fedora) or /var/log/syslog and /var/log/user.log (e.g. Debian). -

                                                            -

                                                            -

                                                            Motion Guide - Basic Features

                                                            -

                                                            -

                                                            Capture Device Options - The Basic Setup

                                                            -Before you can start using motion you need to know some basics about your camera. -Either you have a camera connected directly to your computer. In this case it is a video4linux type of camera. Or you connect to a network camera using a normal web URL. -

                                                            -

                                                            video4linux (V4L) devices

                                                            -You need to install your camera with the right driver. It is out of scope of this document to tell you how to do this and it depends on which type of camera. -

                                                            -Once installed the camera(s) will have the device names /dev/video0, /dev/video1, /dev/video2... -

                                                            -FreeBSD has a different naming of devices. When you build Motion for FreeBSD the default device name is /dev/bktr0. Under FreeBSD a TV card has a special device for controlling the tuner (e.g. /dev/tuner0). The option tunerdevice is only valid when Motion is built and running under FreeBSD. For Linux do not include this option in the config file (remove or comment out). -

                                                            -USB cameras take a lot of bandwidth. A USB camera connected to a USB 1.1 port or hub consumes all the bandwidth. Even with a small framesize and low framerate you should not expect to have more than one camera per USB 1.1 controller. If you need more than 1 USB camera add extra USB PCI cards to your computer. There exists cards that have 4 inputs each with their own controller and with full bandwidth. Many 4-input cards only have 1 controller. USB cameras do not have the feature of selecting input channels. To disable the input selection the option input must be set to the value 8 for USB cameras. -

                                                            -Composite video cards are normally made with a chip called BT878 (older cards have a BT848). They all use the Linux driver called 'bttv'. -

                                                            -There are cards with more then one video input but still only one BT878 chip. They have a video multiplexer which input is selected with the config option input. Input channel numbers start at 0 (which is why the value 8 and not 0 disables input selection). There are video capture cards available with 4 or 8 inputs but only one chip. They present themselves as one single video device and you select input using the 'input' option. If you define e.g. 4 thread config files with the same videodevice name but different input numbers Motion automatically goes into round robin mode. See the round robin section for more information. Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. For video capture cards input 1 is normally the composite video input. -

                                                            -Some capture cards are specially made for surveillance with for example 4 inputs. Others have a TV tuner, a composite input (phono socket) and perhaps also a S-VHS input. For all these cards the inputs are numbered. The numbering varies from card to card so the easiest is to experiment for 5 minutes with a program that can show the videostream. Use a program such as Camstream or xawtv to experiment with the values. -

                                                            -If you use the TV tuner input you also need to set the frequency of the TV channel using the option frequency. Otherwise set 'frequency' to 0. -

                                                            -Finally you need to set the TV norm. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default is 0 (PAL). If your camera is a PAL black and white you may get a better result with norm=3 (PAL no colour). -

                                                            -If the netcam_url option is defined all the video4linux options are ignored so make sure the netcam_url option is commented out if you do not need it. -

                                                            -These are the parameters used for video4linux devices -

                                                            -

                                                            + +

                                                            +

                                                            +

                                                            +
                                                          + +Output - General + + +Output - Picture + + +Output - Movie + + +Output - Pipe + + +Stream and Webcontrol + + +Database + + +Tracking + + +Conversion Specifiers +
                                                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                                                            %Y year %m month %d date
                                                            %H hour %M minute %S second
                                                            %T HH:MM:SS %v event %q frame number
                                                            %t thread (camera) number %D changed pixels %N noise level
                                                            %i width of motion area, %J height of motion area, %J height of motion area,
                                                            %K X coordinates of motion center %L Y coordinates of motion center %C value defined by text_event
                                                            %f filename with full path %n number indicating filetype
                                                            +

                                                            +The use of quotation marks around string is permitted. The conversion specifiers used have +the same options as for the C function strftime (3) plus the few that are unique to Motion. +

                                                            +

                                                            +
                                                          + + +

                                                          System Processing

                                                          +
                                                            + +

                                                            +

                                                            daemon

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            +When Motion is started, immediately go to daemon mode and release the terminal. +

                                                            + +

                                                            process_id_file

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values:
                                                            • +
                                                            • Default: Not Defined
                                                            • +
                                                            +

                                                            +Specify the full path and file name in order to store the pid for processing. +

                                                            + +

                                                            setup_mode

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            +When this option is turned on, Motion starts in setup mode so that the +parameters can be set more easily. In setup mode two things happen: +With 'motion -s' Motion runs in console mode instead of daemon. It outputs a lot of +useful information for each frame from the camera. Each message is prefixed by [number] +where number is the camera number (thread number). +When you look at the webcam stream you see a black image with numbers. +What you see is the number of changed pixels, number of labeled areas and noise setting. +When something moves you see the pixels detected as Motion in black and white. The largest +labeled area (assuming despeckle is enabled and with the 'l' at the end) is blue. It is +only the blue areas which is counted as Motion. If smartmask is enabled you see this as red areas. + +Here is a suggestion how to initially setup Motion. +

                                                            +
                                                              +
                                                            • Disable despeckle (comment it out in motion.conf).
                                                            • +
                                                            • Disable smartmask
                                                            • +
                                                            • Enable both http control and webcam by setting port numbers. Example 8080 for control and 8081 for webcam.
                                                            • +
                                                            • Start Motion in setup mode
                                                            • +
                                                            • View the webcam stream. Either with Iceweasel or with Firefox by entering in the address of + http://localhost:8080/ +
                                                            • +
                                                            • Open a new tab and connect to the http interface. + http://localhost:8080/ . + You can now control and change almost anything while Motion is running. To disable a feature enter a space.
                                                            • +
                                                            • Start by experimenting with noise level. Do this both during daylight and during darkness. + You will be surprised to see how much noise a camera makes during night. Try using the automatic + noise feature. It should work for most.
                                                            • +
                                                            • Now try the despeckle feature. Enable it using the recommended default EedDl. If this is not enough experiment. + Remember that the l must be the last letter.
                                                            • +
                                                            • Set the threshold to what you want to trigger Motion.
                                                            • +
                                                            +In normal mode you can use the same setting with two browser tabs and experiment with +settings of the camera if needed. +From the web interface you can ask Motion to write all your changes back to the config files +(motion.conf and thread config files). +

                                                            + +

                                                            logfile

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: Not Defined
                                                            • +
                                                            +

                                                            +Use this option to specify the full path and filename to use +for logging of the messages generated from Motion. If this option +is not defined, the stderr and syslog is used. Note that Motion +can generate a LOT of messages and as a result, this option should +be considered if the log_level is at any of the higher levels. + +

                                                            + +

                                                            log_level

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 1 - 9
                                                            • +
                                                            • Default: 6
                                                            • +
                                                            +

                                                            +This option specifies the level of verbosity of the messages sent from Motion. +At a level of 8(DBG), there are a LOT of messages. At a level of 1(EMR) virtually no +messages will be output. +

                                                            +The various levels are [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). +

                                                            +

                                                            + +

                                                            log_type

                                                            +

                                                            +
                                                              +
                                                            • Type: Discreet Strings
                                                            • +
                                                            • Range / Valid values: See Below
                                                            • +
                                                            • Default: ALL
                                                            • +
                                                            +

                                                            +The different components of Motion use different log types. This option allows the +user to only show the messages from particular components. The choices for this option +are: COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL + +

                                                            + +

                                                            thread

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: Not Defined
                                                            • +
                                                            +

                                                            +The full path and file name for the thread file. +Motion allows for this line to be listed in the motion.conf file multiple +times. These specifications should be the LAST lines in the +motion.conf file. +See the Configuration Files section within +this guide for a completed discussion of what to put into the +thread0.conf, thread1.conf, threadX.conf files that would be specified +in this option. +

                                                            + +

                                                            sdl_threadnr

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default:
                                                            • +
                                                            +

                                                            +The SDL option is optional and unusual. When SDL is included in the +building of Motion, there is the ability for Motion to create a SDL preview +window for the user. The author believes this option to be more of a proof +of concept on how to create a SDL window and show the image. (This same functionality +can be achieved via the stream options) To activate the SDL window, include SDL support in +the building of the Motion application. Start Motion and note the +thread number indicated. Once that is noted, specify that thread number (or 1 more than that number) +for this option. When Motion is started again, it will then create a SDL window to preview +the image. To close the window, press X. Author is not aware of any method to restart the +SDL window after it has been closed. + +

                                                            +

                                                            +
                                                          + +

                                                          Video4Linux Device

                                                          +
                                                            +

                                                            +

                                                            videodevice

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: /dev/video0 (FreeBSD: /dev/bktr0)
                                                            • +
                                                            +

                                                            +The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. +See the Basic Setup +section of this guide for a additional discussion of this option. +

                                                            +This is the video4linux device name. Ignore this for net cameras. +

                                                            + +

                                                            v4l2_palette

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default:
                                                            • +
                                                            +

                                                            +The v4l2_palette allows the user to choose preferable palette to be use by Motion. Note that this +is only the preferred option. If the video device does not support the requested format, Motion will +loop through the available palettes to try to find one that is supported by both Motion and the device. +Motion will report the supported palettes of the device when Motion starts when the log_level +is specified as NTC or higher. The default of 17 is highly preferred since this the native +format that Motion uses internally. +
                                                              +
                                                            • V4L2_PIX_FMT_SN9C10X : 0 'S910'
                                                            • +
                                                            • V4L2_PIX_FMT_SBGGR16 : 1 'BYR2'
                                                            • +
                                                            • V4L2_PIX_FMT_SBGGR8 : 2 'BA81'
                                                            • +
                                                            • V4L2_PIX_FMT_SPCA561 : 3 'S561'
                                                            • +
                                                            • V4L2_PIX_FMT_SGBRG8 : 4 'GBRG'
                                                            • +
                                                            • V4L2_PIX_FMT_SGRBG8 : 5 'GRBG'
                                                            • +
                                                            • V4L2_PIX_FMT_PAC207 : 6 'P207'
                                                            • +
                                                            • V4L2_PIX_FMT_PJPG : 7 'PJPG'
                                                            • +
                                                            • V4L2_PIX_FMT_MJPEG : 8 'MJPEG'
                                                            • +
                                                            • V4L2_PIX_FMT_JPEG : 9 'JPEG'
                                                            • +
                                                            • V4L2_PIX_FMT_RGB24 : 10 'RGB3'
                                                            • +
                                                            • V4L2_PIX_FMT_SPCA501 : 11 'S501'
                                                            • +
                                                            • V4L2_PIX_FMT_SPCA505 : 12 'S505'
                                                            • +
                                                            • V4L2_PIX_FMT_SPCA508 : 13 'S508'
                                                            • +
                                                            • V4L2_PIX_FMT_UYVY : 14 'UYVY'
                                                            • +
                                                            • V4L2_PIX_FMT_YUYV : 15 'YUYV'
                                                            • +
                                                            • V4L2_PIX_FMT_YUV422P : 16 '422P'
                                                            • +
                                                            • V4L2_PIX_FMT_YUV420 : 17 'YU12'
                                                            • + +
                                                            + +

                                                            + +

                                                            tunerdevice

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: /dev/tuner0
                                                            • +
                                                            +

                                                            +The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled +for FreeBSD. Make sure to remove or comment out this option when running Motion under Linux. +See the Basic Setup section of this guide for a additional discussion of this option. +

                                                            + +

                                                            input

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: -1, 0 - 7
                                                            • +
                                                            • Default: 1 (Disabled) /li> +
                                                            +

                                                            +Input channel to use expressed as an integer number starting from 0. +This option should normally be set to 1 for video/TV cards, and -1 for USB cameras. +This parameter is used only with video capture cards that has more than one input. +However if you set the input number to e.g. 1 for a USB camera Motion writes an error message +back. If you set it to -1 it does not give you any warning. +If you have a video capture card you can define the channel to tune to using this option. +If you are using a USB device, network camera or a capture card without tuner you should +set the value to the default -1. +Many TV tuner cards have the input channels: TV Tuner = 0, +Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, +composite video = 2, S-VHS = 3. It is recommended to set the parameter to -1 for USB cameras as +your first try. For video capture cards input 1 is normally the composite video input. +

                                                            + +

                                                            norm

                                                            +

                                                            +
                                                              +
                                                            • Type: Discrete Strings
                                                            • +
                                                            • Range / Valid values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour)
                                                            • +
                                                            • Default: 0 (PAL)
                                                            • +
                                                            +

                                                            +Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) +This value is only used for capture cards using the BTTV driver. +

                                                            + +

                                                            frequency

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 0 - 999999
                                                            • +
                                                            • Default: 0 (Not set)
                                                            • +
                                                            +

                                                            +The frequency to set the tuner to (kHz) per the tuner specifications. The default is 0 meaning +not set. This option is only relevant if you have a TV tuner card where you can select the tuner frequency. +Your tuner card must support this feature. +

                                                            + +

                                                            power_line_frequency

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: -1 to 3
                                                            • +
                                                            • Default: -1
                                                            • +
                                                            +

                                                            +This option allows the user to specify the power line frequency that is applicable to the user. This option +can help stabilize the images of some webcams that are sensitive to this frequency. This is not normally necessary. +
                                                              +
                                                            • -1 : Do not modify device setting
                                                            • +
                                                            • 0 : Power line frequency Disabled
                                                            • +
                                                            • 1 : 50hz
                                                            • +
                                                            • 2 : 60hz
                                                            • +
                                                            • 3 : Auto
                                                            • +
                                                            + +

                                                            +

                                                            auto_brightness

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness -

                                                            -Motion will try to adjust the brightness of the video device if the images captured are too dark or too light. This option will be most useful for video devices like web cams, which sometimes don't have such an option in hardware. -

                                                            -The auto_brightness feature will adjust the brightness of the device up or down until the value defined by the option brightness is reached (1 = dark, 255 = bright). If brightness is zero auto_brightness will try to adjust to the average brightness level 128. -

                                                            -You need to know if the camera supports auto brightness. Most cameras have auto everything. If your video device already does this for you this option might cause oscillations. If you do not know assume that it has and do not use the Motion auto brightness feature. At least not to start with. -

                                                            -

                                                            -

                                                            brightness

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 255 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -The brightness level for the video device. -

                                                            -Value 0 means that Motion does not set the brightness value but leaves it unchanged. -

                                                            -If this setting is used in conjunction with the auto_brightness feature then this setting is the average brightness level in the range 1 (dark) to 255 (bright) that the auto_brightness feature will try to achieve by adjusting the device brightness up and down. -

                                                            -

                                                            -

                                                            contrast

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: 0 - 255 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -The contrast level for the video device. -

                                                            -Disabled (Value 0) means that Motion does not set the contrast value. -

                                                            -

                                                            -

                                                            framerate

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 2 - 100 -
                                                            • Default: 100 (no limit) -
                                                            • Option Topic -
                                                            -

                                                            -Maximum number of frames to be captured from the camera per second. -

                                                            -The faster you fetch pictures from the camera the more CPU load you get and the more pictures get included when Motion is detected. -

                                                            -Motion will stop storing pictures if the framerate is set to less than 2. -

                                                            -Set this parameter to the maximum number of images per second that you want to store either as images or as mpeg films. -

                                                            -To set intervals longer than one second use the 'minimum_gap' option instead. -

                                                            -

                                                            -

                                                            frequency

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: 0 - 999999 -
                                                            • Default: 0 (Not set) -
                                                            • Option Topic -
                                                            -

                                                            -The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) -

                                                            -This option is only relevant if you have a TV tuner card where you can select the tuner frequency. Your tuner card must support this feature. -

                                                            -

                                                            -

                                                            height

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: Device Dependent -
                                                            • Default: 288 -
                                                            • Option Topic -
                                                            -

                                                            -The height of each frame in pixels. -

                                                            -The height of the image in pixels. Motion does not scale so should be set to the actual size of the v4l device. In case of a net camera motion sets the height to the height of the first image read. -

                                                            -Motion actually set the size of the image coming from the video4linux device. -

                                                            -Your camera or capture/TV card will not support any picture size. You must know which frame size (width and height) the camera supports. If you do not know start with width 320 and height 240 which most cameras and capture cards supports. -

                                                            -For some device drivers like pwc (driver for Philips USB cameras) setting the size to a non-standard value makes the driver create an image of the nearest smaller size and create a gray band around the image to fit the size given by motion. Note that it is the driver and not motion that generates the gray band. Motion will try to detect motion in the entire image including the gray band. -

                                                            -Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. -

                                                            -

                                                            +Motion will try to adjust the brightness of the video device if the images captured are too dark or too light. +This option will be most useful for video devices which sometimes don't have such an option in +hardware. The auto_brightness feature will adjust the brightness of the device up or down until the value defined +by the option brightness is reached (1 = dark, 255 = bright). If brightness is zero auto_brightness will try to +adjust to the average brightness level 128. You need to know if the camera supports auto brightness. Most cameras +have auto everything. If your video device already does this for you this option might cause oscillations. If you +do not know assume that it has and do not use the Motion auto brightness feature. At least not to start with. +

                                                            + +

                                                            brightness

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 0 - 255
                                                            • +
                                                            • Default: 0 (disabled)
                                                            • +
                                                            +

                                                            +The brightness level for the video device. Value 0 means that Motion does not set the brightness value but +leaves it unchanged. If this setting is used in conjunction with the auto_brightness feature then this setting +is the average brightness level in the range 1 (dark) to 255 (bright) that the auto_brightness feature will try +to achieve by adjusting the device brightness up and down. +

                                                            + +

                                                            contrast

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 0 - 255
                                                            • +
                                                            • Default: 0 (disabled)
                                                            • +
                                                            +

                                                            +The contrast level for the video device. Disabled (Value 0) means that Motion does not set the contrast value. +

                                                            + +

                                                            saturation

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 0 - 255
                                                            • +
                                                            • Default: 0 (disabled)
                                                            • +
                                                            +

                                                            +The color saturation level for the video device. +

                                                            +

                                                            hue

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 255 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 0 - 255
                                                            • +
                                                            • Default: 0 (disabled)
                                                            • +
                                                            +

                                                            The hue level for the video device. -

                                                            -Normally only relevant for NTSC cameras. -

                                                            -

                                                            -

                                                            input

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 7, 8 = disabled -
                                                            • Default: 8 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -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. -

                                                            -This parameter is really used only with video capture cards that has more than one input. -

                                                            -However if you set the input number to e.g. 1 for a USB camera (ov511 or pwc driver) motion writes an error message back. If you set it to 8 it does not give you any warning. -

                                                            -If you have a video capture card you can define the channel to tune to using this option. If you are using a USB device, network camera or a capture card without tuner you should set the value to the default 8. -

                                                            -Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. It is recommended to set the parameter to 8 for USB cameras as your first try. For video capture cards input 1 is normally the composite video input. -

                                                            -

                                                            -

                                                            minimum_frame_time

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 -
                                                            • Option Topic -
                                                            -

                                                            -Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. -

                                                            -This option is used when you want to capture images at a rate lower than 2 per second. -

                                                            -When this is enabled the framerate option is used only to set the pace the Motion service the webcam port etc. Running Motion at framerate 2 is normally fine. -

                                                            -ALERT! This feature is introduced in Motion 3.2.7 -

                                                            - -

                                                            -

                                                            -

                                                            norm

                                                            -

                                                              -
                                                            • Type: Discrete Strings -
                                                            • Range / Valid values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) -
                                                            • Default: 0 (PAL) -
                                                            • Option Topic -
                                                            -

                                                            -Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) -

                                                            -This value is only used for capture cards using the BTTV driver. -

                                                            -

                                                            +

                                                            + + +

                                                            roundrobin_frames

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 1 - 2147483647
                                                            • +
                                                            • Default: 1
                                                            • +
                                                            +

                                                            +Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) +is possible. The Round Robin feature is automatically activated where multiple threads are sharing the same video +device. Each thread can then set different input channels or frequencies to change camera. If multiple threads use +the same video device, they each can capture roundrobin_frames number of frames before having to share the device +with the other threads. +

                                                            +The RoundRobin feature is automatically activated where multiple threads are sharing the same +video device (for example /dev/video0). Each thread can then set different input channels +to change camera with the input option or by tuning the tuner with the +frequency option. +Round Robin is not relevant for Network cameras or standard USB web cameras. +The Round Robin feature is used with video capture cards which have multiple inputs per video chip. +Note that round robin is not the ideal way to run multiple cameras. When the capture card changes +input it takes a little while before the decoder chip has syncronized to the new camera. You can +improve this if you have expensive cameras with a syncronize input. Only one camera can be decoded +at a time so if you have 4 cameras connected 3 of the camera threads will need to wait for their +turn. The fact that cameras have to take turns and the fact that you have to skip a few frames after +each turn dramatically lowers the possible framerate. You can get a high framerate by viewing each +camera for a long time. But then you may miss the action on one of the inactive cameras. If you can +afford it avoid Round Robin and buy the more expensive type of capture cards that has one decoder chip +per input. If you only need 2 or 3 cameras you can also simply put 2 or 3 cheap TV cards in the computer. +Linux has no problem working with multiple TV cards. (or better yet, it multiple cheap network cameras) +If multiple threads use the same video device, they each can capture roundrobin_frames number of frames +before having to share the device with the other threads. +When another thread wants to watch another input or frequency or size the first +roundrobin_skip number of frames are skipped to allow the device to settle. +The last option switch_filter is supposed to prevent the change of camera from being detected +as Motion. Its function is not perfect and sometimes prevents detection of real motion. You should start +with having the option disabled and then try with the option enabled to see if you can skip less frames +without loosing the detection of the type of motion you normally want to detect. + + +

                                                            + +

                                                            roundrobin_skip

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 1 - 2147483647
                                                            • +
                                                            • Default: 1
                                                            • +
                                                            +

                                                            +Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). +The Round Robin feature is automatically activated where multiple threads are sharing the same video device. +Each thread can then set different input channels or frequencies to change camera. +When another thread wants to watch another input or frequency or size the first roundrobin_ +skip number of frames are skipped to allow the device to settle. +

                                                            + +

                                                            switchfilter

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            +Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this +you can even set roundrobin_skip to 1 without generating much false detection. +This is a round robin related feature used when you have a capture card with multiple inputs (controlled by the +'input' option) on the same videodevice. +

                                                            +

                                                            +
                                                          + +

                                                          Network Cameras

                                                          +
                                                            +

                                                            +Motion can connect to a network camera through a normal TCP socket. All you need to give it is the URL. +The URL given must return either one single jpeg picture or an mjpeg stream. For the time being Motion +cannot connect to a video stream such a mpeg, mpeg4, divx. The URL must return one single jpeg image, a mjpeg stream +a rtsp stream, file or ftp. When getting a still image, make sure to validate that the camera is serving up +a actual raw JPG file and not a HTML page with an embedded JPG which is the current +standard. +When the netcam_url is defined the video4linux options above are ignored. +If the connection to a network camera is lost, Motion will reuse the last good image for +approx 30 seconds. After 30 seconds the image is replaced by a grey image with a text +telling that the signal is lost and when the connection was lost. +This text and its date format is not configurable. + + +

                                                            netcam_url

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: Not defined
                                                            • +
                                                            +

                                                            +URL to use if you are using a network camera, size will be autodetected +Available prefixes to the URL: +
                                                              +
                                                            • http://
                                                            • +
                                                            • ftp://
                                                            • +
                                                            • mjpg://
                                                            • +
                                                            • rtsp://
                                                            • +
                                                            • mjpeg://
                                                            • +
                                                            • file:///
                                                            • +
                                                            + +The prefixes of mjpg and mjpeg are not actual protocols and allow the user to specify +different formats and methods to access the network stream. They are internally translated +into http. For options such as rtsp, it is recommended that the connection string be +validated with other applications such as ffplay or VLC. + +

                                                            +When the netcam_url is defined the video4linux options are ignored. +

                                                            + +

                                                            netcam_userpass

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: Not defined
                                                            • +
                                                            +

                                                            +The Username and password for the network camera. For http protocols, this +option is for HTTP 1.1 Basic authentication. The string is specified as username:password. +Do not specify this option for no authentication. To use no authentication simply +remove this option. Note that only basic authentication is +supported for connection to netwwork cameras. Digest authentication is not currently available + +

                                                            + +

                                                            netcam_keepalive

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default:
                                                            • +
                                                            +

                                                            +The setting for keep-alive of network socket, should improve performance on compatible net cameras. +
                                                              +
                                                            • off: The historical implementation using HTTP/1.0, closing the socket after each http request.
                                                            • +
                                                            • force: Use HTTP/1.0 requests with keep alive header to reuse the same connection.
                                                            • +
                                                            • on: Use HTTP/1.1 requests that support keep alive as default.
                                                            • +
                                                            + +

                                                            + +

                                                            netcam_proxy

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: Not defined
                                                            • +
                                                            +

                                                            +URL to use for a netcam proxy server, if required. The syntax is +http://myproxy:portnumber +Use this if you need to connect to a network camera through a proxy server. +Example of syntax: "http://myproxy.mydomain.com:1024 +If the proxy port number is 80 you can ommit the port number. Then the syntax is use "http://myproxy.mydomain.com" . +Leave this option undefined if you do not use a proxy server. +

                                                            + +

                                                            netcam_tolerant_check

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default:
                                                            • +
                                                            +

                                                            +Use less strict jpeg checks for network cameras +

                                                            + +

                                                            rtsp_uses_tcp

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: on off
                                                            • +
                                                            • Default: on
                                                            • +
                                                            +

                                                            +This option specifies the transport method for rtsp cameras. The TCP transport is highly preferred because +without this option the rtsp images are frequently corrupted and result in many false positive values and +images that appear to be smeared. Off indicates that UDP will be used. +

                                                            +

                                                            +
                                                          + +

                                                          Image Processing

                                                          +
                                                            +

                                                            rotate

                                                            -

                                                              -
                                                            • Type: Discrete Strings -
                                                            • Range / Valid values: 0, 90, 180, 270 -
                                                            • Default: 0 (not rotated) -
                                                            • Option Topic -
                                                            -

                                                            -Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. -

                                                            -The rotation feature is used when the camera is hanging upside down (180 degrees) or if you choose a picture format in portrait instead of the normal landscape (90 or 270 degrees). -

                                                            -Note that the CPU load increases when using this feature with a value other than 0. Also note that Motion automatically swaps width and height if you rotate 90 or 270 degrees, so you don't have to touch these options. -

                                                            -

                                                            -

                                                            saturation

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 255 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -The colour saturation level for the video device. -

                                                            -

                                                            -

                                                            tunerdevice

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: /dev/tuner0 -
                                                            • Option Topic -
                                                            -

                                                            -The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. -

                                                            -Make sure to remove or comment out this option when running Motion under Linux. -

                                                            -

                                                            -

                                                            videodevice

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: /dev/video0 (FreeBSD: /dev/bktr0) -
                                                            • Option Topic -
                                                            -

                                                            -The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. -

                                                            -This is the video4linux device name. Ignore this for net cameras. -

                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: Discrete Strings
                                                            • +
                                                            • Range / Valid values: 0, 90, 180, 270
                                                            • +
                                                            • Default: 0 (not rotated)
                                                            • +
                                                            +

                                                            +Rotate image the given number of degrees. The rotation affects all saved images as well as movies. +The rotation feature is used when the camera is hanging upside down (180 degrees) or if you choose a picture +format in portrait instead of the normal landscape (90 or 270 degrees). +Note that the CPU load increases when using this feature with a value other than 0. Also note that +Motion automatically swaps width and height if you rotate 90 or 270 degrees, so you don't have to touch these options. +

                                                            +

                                                            width

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: Device Dependent -
                                                            • Default: 352 -
                                                            • Option Topic -
                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: Device Dependent
                                                            • +
                                                            • Default: 352
                                                            • +
                                                            +

                                                            The width in pixels of each frame. Valid range is camera dependent. -

                                                            Motion does not scale so should be set to the actual size of the v4l device. -

                                                            -In case of a net camera motion sets the height to the height of the first image read. -

                                                            +In case of a net camera motion sets the height to the height of the first image read +except for rtsp streams which does rescale the network camera image to the +requested dimensions. Note that this rescaling comes at a very high CPU cost so it +is recommended that the network camera send the image in the same dimensions as included +in the configuration file. Motion actually set the size of the image coming from the video4linux device. -

                                                            -Your camera or capture/TV card will not support any picture size. You must know which frame size (width and height) the camera supports. If you do not know start with width 320 and height 240 which most cameras and capture cards supports. -

                                                            -For some device drivers like pwc (driver for Philips USB cameras) setting the size to a non-standard value makes the driver create an image of the nearest smaller size and create a gray band around the image to fit the size given by motion. Note that it is the driver and not motion that generates the gray band. Motion will try to detect motion in the entire image including the gray band. -

                                                            -Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. -

                                                            -

                                                            -

                                                            Network Cameras

                                                            -Motion can connect to a network camera through a normal TCP socket. All you need to give it is the URL. The URL given must return either one single jpeg picture or an mjpeg stream. For the time being Motion cannot connect to a video stream such a mpeg, mpeg4, divx. The URL must return one single jpeg image or an mjpeg stream! You can connect through a proxy server. -

                                                            -Also watch out that you do not use a URL that create an HTML page with an embedded jpg. What must be returned is the jpg picture itself or the raw mjpeg stream. -

                                                            -When the netcam_url is defined all the video4linux options above are ignored!! -

                                                            -If the connection to a network camera is lost - Motion will reuse the last good image for approx 30 seconds. AFter 30 seconds the image is replaced by a grey image with a text telling that the signal is lost and when the connection was lost. This text and its date format is not configurable and there are no plans to make it configurable in order to keep the number config options under control. -

                                                            -Note that Motion requires that dimensions of camera image must have both height and width that are a multiple of 16. Thís is normally not a problem. All standard sizes like 640, 480, 352, 320, 288, 240, ...etc are multiples of 16. But if you intend to monitor a network camera which is saving jpeg images you may have to pay attention to the dimensions of the picture. -

                                                            -The network camera feature has been completely re-written in Motion 3.2.2. We believe the netcam feature is much more stable now that it was in previous versions. Motion tries to reconnect to the camera if the connection is lost. There is no official standard for mjpeg and we know that there are probably still some cameras that are not yet supported. If you run into a problem please file a Bug Report with as much information about the format as possible. A binary raw dump of the first 2-3 frames with headers and boundary strings is very useful. You can see how to make it on the special topic NetcamMjpegStreamDumps. When you have the file you can upload it to the same topic. -

                                                            -

                                                            -

                                                            netcam_proxy

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: Not defined -
                                                            • Option Topic -
                                                            -

                                                            -URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber -

                                                            -Use this if you need to connect to a network camera through a proxy server. -

                                                            -Example of syntax: "http://myproxy.mydomain.com:1024 -

                                                            -If the proxy port number is 80 you can ommit the port number. Then the syntax is use "http://myproxy.mydomain.com" . -

                                                            -Leave this option undefined if you do not use a proxy server. -

                                                            -

                                                            -

                                                            netcam_url

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: Not defined -
                                                            • Option Topic -
                                                            -

                                                            -Specify an url to a downloadable jpeg file or raw mjpeg stream to use as input device. Such as an AXIS 2100 network camera. -

                                                            -Example of URL: http://www.gate.com/pe1rxq/jeroen.jpg. -

                                                            -Motion can connect to a network camera through a normal TCP socket. All you need to give it is the URL. The URL given must return either one single jpeg picture or an mjpeg stream. For the time being Motion cannot connect to a video stream such a mpeg, mpeg4, divx. The URL must return one single jpeg image or an mjpeg stream! -

                                                            -Also watch out that you do not use a URL that create an HTML page with an embedded jpg. What must be returned is the jpg picture itself or the raw mjpeg stream. -

                                                            -When the netcam_url is defined all the video4linux options are ignored!! -

                                                            -Motion can also fetch jpeg pictures via ftp. You then use the ftp:// syntax instead. -

                                                            -

                                                            -

                                                            netcam_userpass

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: Not defined -
                                                            • Option Topic -
                                                            -

                                                            -For network cameras protected by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. -

                                                            -To use no authentication simply remove this option from the config file comment it out with "#" or ";" in front. -

                                                            -

                                                            -

                                                            - -

                                                            Round Robin feature

                                                            -This feature is automatically activated where multiple threads are sharing the same video device (for example /dev/video0). Each thread can then set different input channels to change camera with the input option or by tuning the tuner with frequency option. -

                                                            -ALERT! Round Robin is not relevant for Network cameras or standard USB web cameras. The Round Robin feature is used with video capture cards which have multiple inputs per video chip. -

                                                            -ALERT! Note that round robin is not the ideal way to run multiple cameras. When the capture card changes input it takes a little while before the decoder chip has syncronized to the new camera. You can improve this if you have expensive cameras with a syncronize input. Only one camera can be decoded at a time so if you have 4 cameras connected 3 of the camera threads will need to wait for their turn. The fact that cameras have to take turns and the fact that you have to skip a few frames after each turn dramatically lowers the possible framerate. You can get a high framerate by viewing each camera for a long time. But then you may miss the action on one of the inactive cameras. If you can affort it avoid Round Robin and buy the more expensive type of capture cards that has one decoder chip per input. If you only need 2 or 3 cameras you can also simply put 2 or 3 cheap TV cards in the computer. Linux has no problem working with multiple TV cards. -

                                                              -
                                                            • If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. -
                                                            • When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. -
                                                            • The last option switch_filter is supposed to prevent the change of camera from being detected as Motion. Its function is not perfect and sometimes prevents detection of real motion. You should start with having the option disabled and then try with the option enabled to see if you can skip less frames without loosing the detection of the type of motion you normally want to detect. -
                                                            -

                                                            -These are the special Round Robin options -

                                                            -

                                                            -

                                                            roundrobin_frames

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 1 - 2147483647 -
                                                            • Default: 1 -
                                                            • Option Topic -
                                                            -

                                                            -Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. -

                                                            -The Round Robin feature is automatically activated where multiple threads are sharing the same video device. Each thread can then set different input channels or frequencies to change camera. -

                                                            -If multiple threads use the same video device, they each can capture roundrobin_frames number of frames before having to share the device with the other threads. -

                                                            -

                                                            -

                                                            roundrobin_skip

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 1 - 2147483647 -
                                                            • Default: 1 -
                                                            • Option Topic -
                                                            -

                                                            -Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). -

                                                            -The Round Robin feature is automatically activated where multiple threads are sharing the same video device. Each thread can then set different input channels or frequencies to change camera. -

                                                            -When another thread wants to watch another input or frequency or size the first roundrobin_skip number of frames are skipped to allow the device to settle. -

                                                            -

                                                            -

                                                            switchfilter

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. -

                                                            -This is a round robin related feature used when you have a capture card with multiple inputs (controlled by the 'input' option) on the same videodevice. -

                                                            -ALERT! This feature was seriously broken until Motion 3.2.4 -

                                                            -

                                                            -

                                                            Motion Detection Settings

                                                            -These are the options that controls the detection of motion. Further details follows after. -

                                                            -

                                                            +Your camera or capture/TV card will not support any picture size. You must know +which frame size (width and height) the camera supports. If you do not know start with +width 320 and height 240 which most cameras and capture cards supports. +For some device drivers like pwc (driver for Philips USB cameras) setting the +size to a non-standard value makes the driver create an image of the nearest +smaller size and create a gray band around the image to fit the size given by +motion. Note that it is the driver and not motion that generates the gray band. +Motion will try to detect motion in the entire image including the gray band. +Older versions of Motion required that dimensions of image must have both height and width that are a multiple of 16. +The latest versions have eliminated this requirement. +

                                                            + +

                                                            height

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: Device Dependent
                                                            • +
                                                            • Default: 288
                                                            • +
                                                            +

                                                            +The height of the image in pixels. Motion does not scale so should be set to the actual size of the device. +In case of a net camera motion sets the height to the height of the first image read +except for rtsp streams which does rescale the network camera image to the +requested dimensions. Note that this rescaling comes at a very high CPU cost so it +is recommended that the network camera send the image in the same dimensions as included +in the configuration file. +Motion actually set the size of the image coming from the device. +Your camera or capture/TV card will not support any picture size. You must know which frame size +(width and height) the camera supports. If you do not know start with width 320 and height 240 which +most cameras and capture cards supports. +For some device drivers like pwc (driver for Philips USB cameras) setting the size to a non-standard value +makes the driver create an image of the nearest smaller size and create a gray band around the image to fit +the size given by motion. Note that it is the driver and not motion that generates the gray band. Motion will +try to detect motion in the entire image including the gray band. +Older versions of Motion required that dimensions of image must have both height and width that are a multiple of 16. +The latest versions have eliminated this requirement. +

                                                            + +

                                                            framerate

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 2 - 100
                                                            • +
                                                            • Default: 100 (no limit)
                                                            • +
                                                            +

                                                            +Maximum number of frames to be captured from the camera per second. +The faster you fetch pictures from the camera the more CPU load you +get and the more pictures get included when Motion is detected. +Motion will stop storing pictures if the framerate is set to less than 2. +Set this parameter to the maximum number of images per second that you want +to store either as images or as movies. +To set intervals longer than one second use the 'minimum_gap' option instead. +

                                                            + +

                                                            minimum_frame_time

                                                            +

                                                            +
                                                              +
                                                            • Type: Integer
                                                            • +
                                                            • Range / Valid values: 0 - 2147483647
                                                            • +
                                                            • Default: 0
                                                            • +
                                                            +

                                                            +Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture +rate is given by the camera framerate. +This option is used when you want to capture images at a rate lower than 2 per second. +When this is enabled the framerate option is used only to set the pace the Motion service the +webcam port etc. + +

                                                            +

                                                            despeckle

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: EedDl -
                                                            • Default: Not defined -
                                                            • Option Topic -
                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: EedDl
                                                            • +
                                                            • Default: Not defined
                                                            • +
                                                            +

                                                            Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. -

                                                            -A way of tuning (by removing or enhancing) noise in the motion image. Options for the despeckle feature are any of 'e', 'E', 'd' or 'D'. This can be combined by a trailing 'l' (letter l) which enables the labeling feature. Default: Not Defined (Don't despeckle and label). -

                                                            -Wind blowing grass and trees around or poor light conditions can cause a lot of dots (or noise) to appear in the motion image (See the section on Tuning Motion). This feature removes (or enhances!) this noise and so improves the reliability of motion. -

                                                            -The 'e' option removes diamonds, 'E' removes squares and alternating eE will remove circles. Each e/E you add will shrink the noise by a pixel all the way around. So 'despeckle Ee' will remove circles of radius 2. However, this will also shrink the detection by 2 and will affect the threshold. So to remove noise and then restore the detected motion to its original size try 'despeckle EedD'. -

                                                            -After the despeckle feature is done you can let the labeling feature search for areas of connected pixels and "label" each area. The program will now trigger motion based on the number of changed pixels in the largest area. In other words, the largest labeled area has to be above the threshold to trigger a motion detected. -

                                                            -The value EedDl is a good starting point. The possible combinations are endless and it requires many experiments to find the best combination. Just remember that the labeling feature only works as intended if it runs after the despeckle feature. Ie. the letter 'l' must be the last letter and only one 'l'. -

                                                            -If you have very few problems with false detections leave this option either blank or at EedD which will remove most of the single pixel noise. -A very detailed technical explanation of the despeckle part can be found at the webpage of the author of this feature Ian McConnell's Webcam: Motion Web Page -

                                                            -

                                                            -

                                                            gap

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 60 -
                                                            • Option Topic -
                                                            -

                                                            -Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. -

                                                            -Recommended value is 60 seconds (Default). The value 0 is allowed (but not recommended) and disables events causing all Motion to be written to one single mpeg file and no pre_capture. You can force an event to end and a new to begin using the http control 'http://host:port/thread_number/action/makemovie'. Disabling events has bad side effects on noise_tune and smartmask. Both features can only work properly outside an event. When gap is set to 0, both features don't work properly anymore. -

                                                            -An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. This option defines how long a pause between detected motions that is needed to be defined as a new event. -

                                                            -The gap timer starts after the last motion is detected and post_capture images have been saved and appended to open movie mpeg files. -

                                                            -Any motion detected before the gap timer times out resets the gap timer so it starts counting over again. -

                                                            -Detailed Description -

                                                            -The option 'gap' is important. It defines how long a period of no motion detected it takes before we say an event is over. An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. Motion detected includes post_captured frames set by the 'post_capture' option. The 'gap' option defines how long a pause between detected motions that is needed to be defined as a new event. A good starting value is 60 seconds. -

                                                            -The way 'gap' works in more technical terms is:

                                                              -
                                                            • Gap is a timer that timeout 'gap' seconds after the last video frame with motion is detected. -
                                                            • If 'post_capture' is activated then the gap timer starts counting after the last image of the post_capture buffer has been saved. -
                                                            • The gap timer is reset and starts all over each time new motion is detected, so you will not miss any action by having a short 'gap' value. It will just create more events (e.g. more mpegs files) -
                                                            -

                                                            -The gap value impacts many functions in Motion.

                                                              -
                                                            • When the gap timer runs out the event number is increased by one next time motion is detected. When you use the %v conversion specifier in filenames or text features this means that the number in filename or text increased by one. -
                                                            • The pre_capture feature only works at the beginning of an event. So if you have a very large 'gap' value pre_capture is not working very often. -
                                                            • When you make mpegs using the ffmpeg features a new mpeg file is started at the beginning of an event when the first motion is detected. When 'gap' seconds has passed without motion (and post_captured frames saved) the mpeg files is completed and closed. -
                                                            • Do not use large gap values to generate one large mpeg4 file. If Motion stops working this mpeg4 file never gets properly completed and closed and you will not be able to view it. -
                                                            • Some of the tracking features sets the camera back to the center position when an event is over. -
                                                            -

                                                            -Note that 'gap' and 'minimum_gap' have nothing to do with each other. -

                                                            -

                                                            -

                                                            lightswitch

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 100 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. -

                                                            -Experiment to see what works best for your application. -

                                                            -Note: From version 3.1.17 (snap release 2 and on) this option has changed from a boolean (on or off) to a number in percent between 0 and 100. Zero means the option is disabled. -

                                                            -The value defines the picture areas in percent that will trigger the lightswitch condition. When lightswitch is detected motion detection is disabled for 5 picture frames. This is to avoid false detection when light conditions change and when a camera changes sensitivity at low light. -

                                                            -

                                                            -

                                                            low_cpu

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 100 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. -

                                                            -This is smart for running a server that also does other tasks such as running Apache, MySQL etc. Motion grabs this lower number of frames per second until it detects motion. Then it speeds up to normal speed and take pictures as set by the option "framerate". -

                                                            -

                                                            -

                                                            mask_file

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: Not defined -
                                                            • Option Topic -
                                                            -

                                                            -PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. -

                                                            -Full path of the PGM (portable gray map) mask file (binary format). -

                                                            -If you have one or more areas of the camera image in which you do NOT want motion detected (e.g. a tree that moves in the wind or a corner of the picture where you can see cars/pedestrians passing by) you need a mask file. This file is a picture that you create in your favorite photo editing program. The areas that you want detected must be white. The error that you want ignored must be black. The pgm image must be the same size (number of pixels high and wide) as the pictures that are taken by the camera (video4linux device). -

                                                            -You can adjust sensitivity by using gray tones. -

                                                            -If you do not have a mask file disable this option by not having it in the config file or comment it out ("#"or ";" as first character in line). -If you are using the rotate option, note that the mask is applied after the rotation. -

                                                            -Detailed Description -

                                                            -The mask file must be a pgm format image file (portable gray map). Note that you must choose the BINARY format. -

                                                            -The feature is simple. Create an image of exact the same size as the ones you get from your video device (camera). Make a purely white picture and paint the areas that you want to mask out black. You can also make gray areas where you want to lower the sensitivity to motion. Normally you will stick to pure black and white. -

                                                            -One easy method for generating the mask file is as follows. -

                                                            -You can just take a motion captured picture, edit it with black and white for the mask and save it as a pgm file. -If you cannot save in this format save as a grayscale jpg and then you can convert it to pgm format with -

                                                            -djpeg -grayscale -pnm [inputfile] > mask.pgm -

                                                            -(assuming you have djpeg installed - part of the jpeg lib package). -

                                                            -Note that the mask file option masks off the detection of motion. The entire picture is still shown on the picture. This means that you cannot use the feature to mask off an area that you do not want people to see. -

                                                            -Below are an example of a webcam picture and a mask file to prevent the detection cars in the street. -

                                                            -Normal picture. Notice the street is visible through the hedge. -

                                                            -normal.jpg -

                                                            -Mask file (converted to png format so it can be shown by your web browser) -

                                                            - -
                                                            mask1.png
                                                            -

                                                            -

                                                            -

                                                            max_mpeg_time

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 (infinite) - 2147483647 -
                                                            • Default: 3600 -
                                                            • Option Topic -
                                                            -

                                                            -The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. -

                                                            -

                                                            -

                                                            - -

                                                            -

                                                            -

                                                            minimum_gap

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 (no minimum) -
                                                            • Option Topic -
                                                            -

                                                            -The minimum time between two shots in seconds. -

                                                            -This is the minimum gap between the storing pictures while detecting motion. -

                                                            -The value zero means that pictures can be stored almost at the framerate of the camera. Normally you will set this to 0 -

                                                            -This option has nothing to do with the 'gap' option. -

                                                            -ALERT! From motion 3.2.7 this feature has been removed because it was in practical a useless feature. It prevented saving more than one picture per minimum_gap seconds but the capturing and motion detect was still run at full framerate loading the CPU heavily. From 3.2.7 a new feature called minimum_frame_time has been introduced which lower the capture rate. So it gives the same effect as minimum_gap did but additionally lower the CPU load significantly. -

                                                            -

                                                            -

                                                            minimum_motion_frames

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: 1 - 1000s -
                                                            • Default: 1 -
                                                            • Option Topic -
                                                            -

                                                            -Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, but it is recommended to keep it within 1-5. -

                                                            -Note that the picture frames are buffered by Motion and once motion is detected also the first frames containing motion are saved so you will not miss anything. -

                                                            -The feature is used when you get many false detections when the camera changes light sensitivity or light changes. -

                                                            -Experiment for best setting. Even though Motion accepts large values you should set this to a relatively low number (below 10). For each step larger than 1 Motion reserves space in RAM for the picture frame buffer. If you have a large value Motion will miss many frames from the camera while it is processing the all the pictures in the buffer. -

                                                            -

                                                            -

                                                            night_compensate

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. -

                                                            -It has normally been the advice not to use this with 'noise_tune' turned on. However the latest experience is that with the new improved noise_tune algorithm it actually works fine in combination with 'night_compensate'. -

                                                            -

                                                            -

                                                            noise_level

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 1 - 255 -
                                                            • Default: 32 -
                                                            • Option Topic -
                                                            -

                                                            -The noise level is used as a threshold for distinguishing between noise and motion. -

                                                            -This is different from the threshold parameter. This is changes at pixel level. The purpose is to eliminate the changes generated by electric noise in the camera. Especially in complete darkness you can see the noise as small grey dots that come randomly in the picture. This noise can create false motion detection. What this parameter means is that the intensity of a pixel must change more than +/- the noise threshold parameter to be counted. -

                                                            -

                                                            -

                                                            noise_tune

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: on -
                                                            • Option Topic -
                                                            -

                                                            -Activates the automatic tuning of noise level. -

                                                            -This feature makes Motion continuously adjust the noise threshold for distinguishing between noise and motion. The 'noise_level' setting is ignored when activating this feature. This is a new feature and new algorithm. It may give different results depending on camera and light conditions. Report your experience with it on the Motion mailing list. If it does not work well, deactivate the 'noise_tune' option and use the manual setting of 'noise_level' instead. -

                                                            -

                                                            -

                                                            output_all

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Picture are saved continuously as if motion was detected all the time. -

                                                            -This feature is not meant to be the normal mode of operation. Especially not if you have the output_normal or output_motion features enabled since it will keep on saving pictures on the disk and you will soon run out of disk space. So be careful with this command. -

                                                            -If your frame rate is 10 pictures per second motion will save 10 new picture pr second until the disk is full. -

                                                            -It does all the normal actions that are done when motion is detected. It saves pictures on the harddisk, execute external scripts, etc as fast as the frame rate of the camera. So it is probably a good idea to run with a low framerate when using this feature and to not use activate all the features that saves files on the disk. -

                                                            -The idea of this feature is that you can turn the feature on and off for a short period of time to test or to generate continuous mpeg films when needed. -

                                                            -

                                                            -

                                                            post_capture

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Specifies the number of frames to be captured after motion has been detected. -

                                                            -The purpose of this is mainly to create smooth video clips each time motion is detected. Use it to you personal taste (and disk space).. -

                                                            -This option is the preferred way to create continuous movies. Post_capture does not consume extra RAM and it does not create pauses in the movie even with large values. -

                                                            -If you only store mpegs movies and do not have output_normal on, then the recommended post_capture value is what is equivalent to 1-5 seconds of movie. -

                                                            -

                                                            -

                                                            pre_capture

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 100s -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. -

                                                            -Motion buffers the number of picture frames defined by 'pre_capture'. When motion is detected the pictures in the buffer are included in the video clip generated by ffmpeg. The effect is that it seems the program knew in advance that the event was going to take place and started the recording before it actually happened. This is a nice feature that give more complete video clips of an event. -

                                                            -If pre_capture is set to 0 the feature is disabled. Keep this value below 5. -

                                                            -The recommended value would be approx 0.5 second of video so the value should be defined so it fits the framerate and the desired pre-capture time. E.g. 0.5 second at 20 frames pr second would mean a value of 5. You should never use a value larger than 10. -

                                                            -You can in theory have up to 100s of pre-captured frames but naturally this makes motion leave a larger footprint in the memory of the computer. More important Motion is processing all the buffered images including saving jpegs, encoding mpegs, writing to databases and executing external programs after the first image is detected as Motion. -

                                                            -Motion will not grab another image until this is done. This means that even moderate values for pre_capture combined with high framerates will mean that you will miss quite many frames of Motion. It is therefore recommended to use relative small values for pre_capture. Depending on your chosen framerate and depending on the features enabled values from 1-5 are sensible. -

                                                            -If you wish to create smooth mpegs during events using large pre_capture values will do the opposite! It will create a long pause where a lot of action is missed. -

                                                            -To get a smooth mpeg use a large value for post_capture which does not cost any performance hit or RAM space. -

                                                            -

                                                            -

                                                            smart_mask_speed

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 10 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. -

                                                            -Smartmask is a dynamic, self-learning mask. Smartmask will disable sensitivity in areas with frequent motion (like trees in the wind). Sensitivity is turned on again after some time of no more motion in this area. The built mask is a bit larger at the borders than the actual motion was. This way smartmask works more reliable when sudden moves occur under windy conditions. -

                                                            -smart_mask_speed - tunes the slugginess of the mask. It accepts values from 0 (turned off) to 10 (fast). Fast means here that the mask is built quick, but it is also not staying very long with no more motion. Slow means that it takes a while until the mask is built but it also stays longer. A good start value for smart_mask_speed is 5. This setting is independent from the framerate. The attack and decay time is constant over all available framerates. -

                                                            -When smartmask is enabled and motion is also configured to either write motion-images or motion-mpegs, the current smartmask is copied as an overlay into the black/white motion-pictures/mpegs in red colour. Same thing happens to the webcam stream when Motion runs in setup_mode. That way you can easily adjust smart_mask_speed. -

                                                            -Detailed Description -

                                                            -The mask_file option provides a static mask to turn off sensitivity in certain areas. This is very usefull to mask a street with cars passing by all day long etc... -

                                                            -But imagine a scenario with large bushes and big trees where all the leaves are moving in the wind also triggering motion from time to time even with despeckle turned on. Of course you can also define a static mask here, but what if the bushes are growing during spring and summer? Well, you have to adapt the mask from time to time. What if the camera position moves slightly? What if someone grows new plants in your garden? You always have to setup a new static mask. -

                                                            -The answer to this problem is the smart mask feature introduced in Motion 3.1.18. A dynamic, self-learing mask. -

                                                            -Smart mask will disable sensitivity in areas with frequent motion (like trees in the wind). Sensitivity is turned on again after some time of no more motion in this area. The built mask is a bit larger at the borders than the actual motion. This way smartmask works more reliably when sudden moves occur under windy conditions. -

                                                            -

                                                            -

                                                            threshold

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 1 - 2147483647 -
                                                            • Default: 1500 -
                                                            • Option Topic -
                                                            -

                                                            -Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. -

                                                            -The 'threshold' option is the most important detection setting. When motion runs it compares the current image frame with the previous and counts the number of changed pixels after having processed the image with noise filtering, masking, despeckle and labeling. If more pixels than defined by 'threshold' have changed we assume that we have detected motion. Set the threshold as low as possible so that you get the motion you want detected but large enough so that you do not get detections from noise and plants moving. Note that the larger your frames are, the more pixels you have. So for large picture frame sizes you need a higher threshold. -

                                                            -Use the -s (setup mode) command line option and/or the text_changes config file option to experiment to find the right threshold value. If you do not get small movements detected (see the mouse on the kitchen floor) lower the value. If motion detects too many birds or moving trees, increase the number. Practical values would be from a few hundred to 2000 indoors and 1000-10000 outdoors. -

                                                            -

                                                            -

                                                            threshold_tune

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Activates the automatic tuning of threshold level. -

                                                            -This feature makes Motion continuously adjust the threshold for declaring motion. -

                                                            -The threshold setting is ignored when activating this feature. It may give different results depending on your camera, light conditions, indoor/outdoor, the motion to be detected etc. If it does not work well, deactivate the 'threshold_tune' option and use the manual setting of threshold instead. -

                                                            -

                                                            -

                                                            Image File Output

                                                            -The following options controls how Motion generates images when detection motion. -

                                                            -

                                                            -

                                                            output_motion

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. -

                                                            -Motion images shows the motion content of the pictures. This is good for tuning and testing but probably not very interesting for the general public. -

                                                            -Default is not to store motion images. Motion pictures are stored the same place and with the same filename as normal motion triggered pictures except they have an "m" appended at the end of the filename before the .jpg or .ppm. E.g. the name can be 01-20020424232936-00m.jpg. -

                                                            -

                                                            -

                                                            output_normal

                                                            -

                                                              -
                                                            • Type: Discrete Strings -
                                                            • Range / Valid values: on, off, first, best -
                                                            • Default: on -
                                                            • Option Topic -
                                                            -

                                                            -Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image like defined by output_motion. Default is that normal images are stored. -

                                                            -If you set the value to 'first' Motion saves only the first motion detected picture per event. -

                                                            -If you set it to "best" Motion saves the picture with most changed pixels during the event. This is useful if you store mpegs on a webserver and want to present a jpeg to show the content of the mpeg on a webpage. "best" requires a little more CPU power and resources compared to "first". -

                                                            -Set to 'off' to don't write pictures ( jpeg or ppm ). -

                                                            -

                                                            -

                                                            ppm

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. -

                                                            -The recommendation is to always use jpg except if you have a specific need to store high quality pictures without any quality loss. For web cameras you should always choose jpg. Note that the built in webcam server requires that this parameter is set to off. -

                                                            -

                                                            -

                                                            quality

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 1 - 100 -
                                                            • Default: 75 -
                                                            • Option Topic -
                                                            -

                                                            -The quality for the jpeg images in percent. -

                                                            -100 means hardly compressed. A small number means a much smaller file size but also a less nice quality image to look at. 50 is a good compromise for most. -

                                                            -

                                                            -

                                                            Tuning Motion

                                                            -

                                                            -Motion 3.2 introduces a new feature Setup Mode. This is a great new feature with really make tuning all the settings of Motion much more easy and transparent. In setup mode two things happen: -

                                                              -
                                                            1. With 'motion -s' Motion runs in console mode instead of daemon. It outputs a lot of useful information for each frame from the camera. Each message is prefixed by [number] where number is the camera number (thread number). -
                                                            2. When you look at the mjpeg webcam stream you see a black image with numbers. What you see is the number of changed pixels, number of labeled areas and noise setting. When something moves you see the pixels detected as Motion in black and white. The largest labelled area (assuming despeckle is enabled and with the 'l' at the end) is blue. It is only the blue areas which is counted as Motion. If smartmask is enabled you see this as red areas. -
                                                            -

                                                            -Here is a suggestion how to initially setup Motion. -

                                                              -
                                                            • Disable despeckle (comment it out in motion.conf). -
                                                            • Disable smartmask -
                                                            • Enable both http control and webcam by setting port numbers. Example 8080 for control and 8081 for webcam. -
                                                            • Start Motion in setup mode -
                                                            • View the webcam stream. Either with Cambozola or with Firefox. http://localhost:8081/ Firefox often needs to reload the page before it works. Bug in Firefox. Internet Explorer cannot show the stream unless you make a webpage on your Apache with Cambozola applet. -
                                                            • Open new browser window and connect to the http interface. http://localhost:8080/ . You can now control and change almost anything while Motion is running. You cannot resize the image. That was too hard to code. To disable a feature enter a space. -
                                                            • Start by experimenting with noise level. Do this both during daylight and during darkness. You will be surprised to see how much noise a camera makes during night. Try using the automatic noise feature. It should work for most. -
                                                            • Now try the despeckle feature. Enable it using the recommended default EedDl. If this is not enough experiment. Remember that the l must be the last letter. It is fun to play with. -
                                                            • Set the threshold to what you want to trigger Motion. -
                                                            -

                                                            -In normal mode you can use the same setting with two browser windows and experiment with settings of the camera if needed. -

                                                            -From the web interface you can ask Motion to write all your changes back to the config files (motion.conf and thread config files). It will even tidy them up for you so they look nice. -

                                                            -There are two sets of options to adjust.

                                                            -

                                                            -


                                                            -

                                                            -Normal picture frame -

                                                            -outputnormal1.jpg -

                                                            -


                                                            -Motion type picture frame with despeckle. Note that the largest area is blue and only this is counted as Motion. -

                                                            -The Motion image shows how Motion maintains a "reference frame" which is not just the last picture frame but a matematical calculation of the past images. This enlarges real Motion and ensures that it is not easy to sneak in slowly. -

                                                            -outputmotion1.jpg -


                                                            -

                                                            -

                                                            -

                                                            Generating MPEG films with ffmpeg

                                                            -The ffmpeg option can generate mpeg films very fast and "on the fly". This means that the mpeg film is growing each time motion is detected. -

                                                            -Some people on the Motion mailing list have had trouble building the ffmpeg package because they did not have the NASM assembler package installed. So pay attention to this if you run into problems. -

                                                            -ffmpeg exists as binary packages for most distributions including RPMs and debian packages. -

                                                            -Ffmpeg is an interesting project. The releases have not been very consistent over time. The official releases are out of date now. So we are forced to take our chance and checkout a version from their CVS server and hope that we are lucky in getting a version that works. See ffmpeg project page. We encourage the maintaners of such an important project to introduce better release schedules in the near future for the benefit of opensource software. -

                                                            -In order to help people finding a version of ffmpeg that works we have started testing the Motion package with a selection of binaries and a CVS snapshot. The CVS source snapshot of ffmpeg which is certified with Motion is available on the Related projects file area on the Motion Sourceforge project -

                                                            -Motion works with the following versions of ffmpeg:

                                                              -
                                                            • ffmpeg-0.4.8. With this release Motion supports mpeg1, mpeg4 and msmpeg4. Lately newer distributions have problems building this 2003 release of ffmpeg so many of you no longer have this option. -
                                                            • ffmpeg-0.4.9pre1. Is supported starting from Motion version 3.1.18. With this release Motion supports mpeg4 and msmpeg4 but not mpeg1. The reason is that the ffmpeg team has decided no longer to support non-standard framerates in their mpeg1 encoder library. Also ffmpeg-0.4.9pre1 gives people problems on newer distributions. -
                                                            • ffmpeg from CVS. This may work. We cannot continuously monitor and try every time a new source file is checked into ffmpeg. You will have to try. -
                                                            • ffmpeg RPMs. Currently each Motion release is tested with the current Livna ffmpeg rpm package for Fedora. See the Download Files page for direct links to the version which has been certified with the latest Motion release. -
                                                            • ffmpeg debian binaries. Latest versions from the debian repository for Debian Sarge works fine with Motion. -
                                                            • Certified ffmpeg CVS snapshot for latest Motion release is available from the Motion Sourceforge Related Projects file area -
                                                            -

                                                            -The timelapse feature always runs mpeg1 with both ffmpeg 0.4.8 and 0.4.9 and newer. Motion simply creates the timelapse film with a standard mpeg1 framerate. Note : maximum size for timelapse files is 2GB. -

                                                            -In principle Motion can be made to support many other formats. It requires additional coding in Motion. You are welcome to submit patches. All ffmpeg related code is in the source file ffmpeg.c. It is not trivial to do because the ffmpeg libraries not documented at all. All you have is a couple of code examples. -

                                                            -To build ffpmeg from source follow these steps: -

                                                            -Download the ffmpeg and untar it to /usr/local/ffmpeg. Then it should be a simple matter of entering the ffmpeg directory and run the commands -

                                                            -

                                                            -cd /usr/local/ffmpeg
                                                            -./configure --enable-shared
                                                            -make
                                                            -make install
                                                            -
                                                            -

                                                            -This creates the libavcodec.so and libavformat.so libraries under /usr/local/lib and header files under /usr/local/include/ffmpeg. -

                                                            -You probably need to do one more step. -

                                                            -Make sure you have 'root' privileges for the next steps. -

                                                            -Open the file /etc/ld.so.conf in your favorite text editor. -

                                                            -Add this line of text if it is not already there - otherwise go to the next step (ldconfig). -

                                                            -/usr/local/lib -Run the command ldconfig. -

                                                            -Motion should now be able to find the shared libraries for ffmpeg (libavcodec.so and libavformat.so) in /usr/local/lib. -

                                                            -You can also find a pre-compiled binary package (e.g. rpm or deb) and install this. Normally an rpm will place the libavcodec.so under /usr/lib. -There are various RPMs available from different repositories. Some need additional RPMs that are actually not needed by Motion but need to be installed to satisfy dependencies. The editor has tried different RPMs of ffmpeg-0.4.8 and they all seem to work. -

                                                            -Motion then need to be built by running ./configure, make and make install. -(Note that with earlier versions of motion you had to specify the location of libavcodec. Now configure searches for the shared library in /usr/lib and /usr/local/lib by default.) -

                                                            -Note that if you install ffmpeg from source and already have ffmpeg installed from an RPM, the Motion configure may very well find the binary library from the rpm instead of the sources. Make sure to uninstall any old ffmpeg RPMs before you install ffmpeg from sources. -

                                                            -These are the config file options related to ffmpeg. -

                                                            -

                                                            -

                                                            ffmpeg_bps

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 9999999 -
                                                            • Default: 400000 -
                                                            • Option Topic -
                                                            -

                                                            -Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. -

                                                            -To use this feature you need to install the FFmpeg Streaming Multimedia System. -

                                                            -Experiment to get the desired quality. The better quality the bigger files. This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled). -

                                                            -

                                                            -

                                                            ffmpeg_cap_motion

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. -

                                                            -Works like ffmpeg_cap_new but outputs motion pixel type pictures instead. -

                                                            -This feature generates the special motion type movie where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. The filename given is the same as the normal mpegs except they have an 'm' appended after the filename before the .mpg. E.g. 20040424181525m.mpg -

                                                            -To use this feature you need to install the FFmpeg Streaming Multimedia System -

                                                            -

                                                            -

                                                            ffmpeg_cap_new

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Use ffmpeg libraries to encode mpeg movies in realtime. -

                                                            -Generates a new film at the beginning of each new event and appends to the film for each motion detected within the same event. The current event ends when the time defined by the 'gap' option has passed with no motion detected. At the next detection of motion a new mpeg film is started. -

                                                            -To use this feature you need to install the FFmpeg Streaming Multimedia System -

                                                            -Must not be included in config file without having ffmpeg installed. -

                                                            -

                                                            -

                                                            ffmpeg_deinterlace

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. -

                                                            -To use this feature you need to install the FFmpeg Streaming Multimedia System -

                                                            -Must not be included in config file without having ffmpeg installed. -

                                                            -

                                                            - -

                                                            -

                                                            -

                                                            ffmpeg_timelapse

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. -

                                                            -This feature uses ffmpegs libavcodec to encode a timelaps movie saving a picture frame at the interval in seconds set by this parameter. Setting this option to 0 disables it. -

                                                            -The feature gives your viewer the chance to watch the day pass by. It makes a nice effect to film flowers etc closeup during the day. Options like frame_rate, snapshot, gap etc have no impact on the ffmpeg timelapse function. -

                                                            -Note that the timelapse format is always mpeg1 independent of ffmpeg_video_codec. This is because mpeg1 allows the timelapse to stop and the file to be reopened and more film appended. -

                                                            -To use this feature you need to install the FFmpeg Streaming Multimedia System. -

                                                            -(renamed from ffmpeg_timelaps to ffmpeg_timelapse in 3.1.14) -

                                                            -

                                                            -

                                                            ffmpeg_timelapse_mode

                                                            -

                                                              -
                                                            • Type: Discrete Strings -
                                                            • Range / Valid values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual -
                                                            • Default: daily -
                                                            • Option Topic -
                                                            -

                                                            -The file rollover mode of the timelapse video. -

                                                            -Note that it is important that you use the conversion specifiers in ffmpeg_filename that ensure that the new timelapse file indeed is a new file. If the filename does not change Motion will simply append the timelapse pictures to the existing file. -

                                                            -The value 'Manual' means that Motion does not automatically rollover to a new filename. You can do it manually using the http control interface by setting the option 'ffmpeg_timelapse' to 0 and then back to your chosen value. Value 'hourly' rolls over on the full hour. Value 'daily' which is the default rolls over at midnight. There are two weekly options because depending on where you come from a week may either start on Sunday or Monday. And 'monthly' naturally rolls over on the 1st of the month. -

                                                            -

                                                            -

                                                            ffmpeg_variable_bitrate

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0, 2 - 31 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. -

                                                            -Experiment for the value that gives you the desired compromise between size and quality. -

                                                            -

                                                            -

                                                            ffmpeg_video_codec

                                                            -

                                                              -
                                                            • Type: Discrete Strings -
                                                            • Range / Valid values: mpeg1 (ffmpeg-0.4.8 only), mpeg4, msmpeg4, swf, flv, ffv1 -
                                                            • Default: mpeg4 -
                                                            • Option Topic -
                                                            -

                                                            -Codec to be used by ffmpeg for the video compression. Timelapse mpegs are always made in mpeg1 format independent from this option. -

                                                            -mpeg1 gives you files with extension .mpg. It is only supported by the old ffmpeg version 0.4.8. The ffmpeg team decided no longer to support non-standard framerates for mpeg1 from ffmpeg version 0.4.9pre1. -

                                                            -mpeg4 or msmpeg4 give you files with extension .avi -

                                                            -msmpeg4 is recommended for use with Windows Media Player because it requires with no installation of codec on the Windows client. -

                                                            -swf gives you a flash film with extension .swf -

                                                            -flv gives you a flash video with extension .flv -

                                                            -ffv1 , FF video codec 1 for Lossless Encoding ( experimental ) -

                                                            -This option does not affect the timelapse feature. Timelapse is always recorded in mpeg1 format because we need to be able to append to an existing file. mpeg4 does not easily allow this. -

                                                            -

                                                            -


                                                            -

                                                            -See also the section Advanced Filenames where the two additional options ffmpeg_filename and timelapse_filename are defined. -

                                                            -If you want to use this feature you can read about the FFmpeg Streaming Multimedia System -

                                                            -

                                                            -

                                                            Snapshots - The Traditional Periodic Web Camera

                                                            -Motion can also act like a traditional web camera. -

                                                            -

                                                            -

                                                            snapshot_interval

                                                            -

                                                              -
                                                            • Type: Integer -
                                                            • Range / Valid values: 0 - 2147483647 -
                                                            • Default: 0 (disabled) -
                                                            • Option Topic -
                                                            -

                                                            -Make automated snapshots every 'snapshot_interval' seconds. -

                                                            -The snapshots are stored in the target directory + the directory/filename specified by the snapshot_filename option. -

                                                            -This is the traditional web camera feature where a picture is taken at a regular interval independently of motion in the picture. -

                                                            -

                                                            -See the also snapshot_filename option in the section Advanced Filenames. -

                                                            -

                                                            -

                                                            Text Features

                                                            -Text features are highly flexible. You can taylor the text displayed on the images and films to your taste and you can add your own user defined text. -

                                                            +A way of tuning (by removing or enhancing) noise in the motion image. Options for the despeckle feature are +any of 'e', 'E', 'd' or 'D'. This can be combined by a trailing 'l' (letter l) which enables the labeling +feature. Default: Not Defined (Don't despeckle and label). +Wind blowing grass and trees around or poor light conditions can cause a lot of dots (or noise) to appear in the +motion image (See the section on Tuning Motion). This feature removes (or enhances!) this noise and so improves +the reliability of motion. +The 'e' option removes diamonds, 'E' removes squares and alternating eE will remove circles. Each e/E you add will +shrink the noise by a pixel all the way around. So 'despeckle Ee' will remove circles of radius 2. However, this +will also shrink the detection by 2 and will affect the threshold. So to remove noise and then restore the detected +motion to its original size try 'despeckle EedD'. +After the despeckle feature is done you can let the labeling feature search for areas of connected pixels and "label" +each area. The program will now trigger motion based on the number of changed pixels in the largest area. In other words, +the largest labeled area has to be above the threshold to trigger a motion detected. +The value EedDl is a good starting point. The possible combinations are endless and it requires many experiments to +find the best combination. Just remember that the labeling feature only works as intended if it runs after the +despeckle feature. Ie. the letter 'l' must be the last letter and only one 'l'. +If you have very few problems with false detections leave this option either blank or at EedD which will remove +most of the single pixel noise. +A very detailed technical explanation of the despeckle part can be found at the webpage of the author of this +feature Ian McConnell's Webcam: Motion +Web Page + +

                                                            + +

                                                            locate_motion_mode

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off, preview
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            +Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a +saved preview jpeg image and not on the saved movie. +

                                                            + +

                                                            locate_motion_style

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: box, redbox, cross, redcross
                                                            • +
                                                            • Default:
                                                            • +
                                                            +

                                                            + Set the look and style of the locate box if enabled. +

                                                            + + +

                                                            text_left

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default:
                                                            • +
                                                            +User defined text overlayed on each in the lower left corner. +Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers +

                                                            +If the option is not defined no text is displayed at this position. +

                                                            +You can use Conversion Specifiers to define this field and also include +a new line specifier as \n and spaces if this option is enclosed in quotes. +

                                                            +

                                                            +By combining spaces and new lines '\n' you can place +your text anywhere on the picture. When setting the text using http remote control the text +must be URL encoded. The browser does this for you. If you need +to set it with a command line tool, use a browser first and let it make the encoded URL for you. Then +you can copy paste it to your script file or cron line or whatever you want to use. +

                                                            +This is how the overlayed text is located. +

                                                            + + + + +
                                                            + + + + + + + + + +
                                                            +

                                                              





                                                             

                                                            +
                                                            +

                                                             CHANGES





                                                             

                                                            +
                                                            +



                                                            TEXT_LEFT

                                                            +
                                                            +

                                                            TEXT_RIGHT
                                                            YYYY-MM-DD
                                                            HH:MM:SS 

                                                            +
                                                            +
                                                            +

                                                            +

                                                            + +

                                                            text_right

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: %Y-%m-%d\n%T
                                                            • +
                                                            +

                                                            +User defined text overlayed on each in the lower right corner. +Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers +

                                                            +If the option is not defined no text is displayed at this position. +

                                                            +You can use Conversion Specifiers to define this field and also include +a new line specifier as \n and spaces if this option is enclosed in quotes. +

                                                            +

                                                            +By combining spaces and new lines '\n' you can place +your text anywhere on the picture. When setting the text using http remote control the text +must be URL encoded. The browser does this for you. If you need +to set it with a command line tool, use a browser first and let it make the encoded URL for you. Then +you can copy paste it to your script file or cron line or whatever you want to use. +

                                                            +A major difference from text_left is that if this option is undefined the +default is %Y-%m-%d\n%T which displays the date in ISO format YYYY-MM-DD and below the +time in 24 hour clock HH:MM:SS. +

                                                            This is how the overlayed text is located. -

                                                            +

                                                            - - - - +
                                                            @@ -1993,1449 +2376,1051 @@

                                                            locate

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off, preview -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            -Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. -

                                                            -The value 'preview' only works when 'output_normal' is set to either 'first' or 'best'. -

                                                            -

                                                            +

                                                            +

                                                            +

                                                            text_changes

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            • Option Topic -
                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            Turns the text showing changed pixels on/off. -

                                                            -By setting this option to 'on' the number of pixels that changed compared to the reference frame is displayed in the upper right corner of the pictures. This is good for calibration and test. Maybe not so interesting for a greater public. Set it to your personal taste. -

                                                            -

                                                            +By setting this option to 'on' the number of pixels that changed compared to the +reference frame is displayed in the upper right corner of the pictures. This is good for calibration and testing. +This is how the overlayed text is located. +

                                                            + + + + +
                                                            + + + + + + + + + +
                                                            +

                                                              





                                                             

                                                            +
                                                            +

                                                             CHANGES





                                                             

                                                            +
                                                            +



                                                            TEXT_LEFT

                                                            +
                                                            +

                                                            TEXT_RIGHT
                                                            YYYY-MM-DD
                                                            HH:MM:SS 

                                                            +
                                                            +
                                                            +

                                                            + +

                                                            text_event

                                                            +

                                                            +
                                                              +
                                                            • Type: String
                                                            • +
                                                            • Range / Valid values: Max 4095 characters
                                                            • +
                                                            • Default: Default: %Y%m%d%H%M%S
                                                            • +
                                                            +

                                                            +This option is special in that it defines the conversion specifier %C which can be used both for text +display and for filenames. This option defines the value of the special event conversion specifier %C. +You can use any conversion specifier in this option except %C. Date and time values are from the timestamp +of the first image in the current event. The idea is that %C can be used filenames and text_left/right for +creating a unique identifier for each event. Option text_event defines the value %C which then can be used in +filenames and text_right/text_left. The text_event/%C uses the time stamp for the first image detected in a new +event. %C is an empty string when no event is in progress (gap period expired). Pre_captured and +minimum_motion_frames images are time stamped before the event happens so %C in text_left/right does not +have any effect on those images. + +You can use Conversion Specifiers to define this field (except for +this option itself) + +

                                                            +

                                                            text_double

                                                            -

                                                              -
                                                            • Type: Boolean -
                                                            • Range / Valid values: on, off -
                                                            • Default: off -
                                                            -

                                                            +

                                                            +
                                                              +
                                                            • Type: Boolean
                                                            • +
                                                            • Range / Valid values: on, off
                                                            • +
                                                            • Default: off
                                                            • +
                                                            +

                                                            Draw characters at twice normal size on images. -

                                                            -This option makes the text defined by text_left, text_right and text_changes twice the normal size. This may be useful when using large picture formats such as 640 x 480. -

                                                            - -

                                                            -

                                                            -

                                                            text_event

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: %Y%m%d%H%M%S -
                                                            • Option Topic -
                                                            -

                                                            -This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. -

                                                            -The idea is that %C can be used filenames and text_left/right for creating a unique identifier for each event. -

                                                            -Option text_event defines the value %C which then can be used in filenames and text_right/text_left. The text_event/%C uses the time stamp for the first image detected in a new event. %C is an empty string when no event is in progress (gap period expired). Pre_captured and minimum_motion_frames images are time stamped before the event happens so %C in text_left/right does not have any effect on those images. -

                                                            -

                                                            -

                                                            text_left

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: Not defined -
                                                            • Option Topic -
                                                            -

                                                            -User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > \ , . : - + _ \n and conversion specifiers (codes starting by a %). -

                                                            -text_left is displayed in the lower left corner of the pictures. If the option is not defined no text is displayed at this position. -

                                                            -You can place the text in quotation marks to allow leading spaces. With a combination is spaces and newlines you can position the text anywhere on the picture. -

                                                            -Detailed Description -

                                                            -A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                              -
                                                            • %Y = year -
                                                            • %m = month as two digits -
                                                            • %d = date -
                                                            • %H = hour -
                                                            • %M = minute -
                                                            • %S = second -
                                                            • %T = HH:MM:SS -
                                                            -

                                                            -These are unique to motion

                                                              -
                                                            • %v = event -
                                                            • %q = frame number -
                                                            • %t = thread (camera) number -
                                                            • %D = changed pixels -
                                                            • %N = noise level -
                                                            • %i = width of motion area -
                                                            • %J = height of motion area -
                                                            • %K = X coordinate of motion center -
                                                            • %L = Y coordinate of motion center -
                                                            • %C = value defined by text_event -
                                                            -

                                                            -With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. -

                                                            -For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. -

                                                            -

                                                            -

                                                            text_right

                                                            -

                                                              -
                                                            • Type: String -
                                                            • Range / Valid values: Max 4095 characters -
                                                            • Default: %Y-%m-%d\n%T -
                                                            • Option Topic -
                                                            -

                                                            -User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock -

                                                            -text_right is displayed in the lower right corner of the pictures. If the option is not defined no text is displayed at this position. -

                                                            -You can place the text in quotation marks to allow leading spaces. With a combination is spaces and newlines you can position the text anywhere on the picture. -

                                                            -A major difference from text_left is that if this option is undefined the default is %Y-%m-%d\n%T which displays the date in ISO format YYYY-MM-DD and below the time in 24 hour clock HH:MM:SS. -

                                                            +This option makes the text defined by text_left, text_right and text_changes twice the normal size. +This may be useful when using large picture formats such as 1280 x 720. +

                                                            +

                                                            + + +

                                                            Motion Detection

                                                            +
                                                              +

                                                              +

                                                              emulate_motion

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: on off
                                                              • +
                                                              • Default: off
                                                              • +
                                                              +

                                                              +Always save images even if there was no motion +

                                                              + +

                                                              threshold

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 1 - 2147483647
                                                              • +
                                                              • Default: 1500
                                                              • +
                                                              +

                                                              +Threshold for declaring motion. The threshold is the number of changed + pixels counted after noise filtering, masking, despeckle, and labelling. + The 'threshold' option is the most important detection setting. When motion runs it compares + the current image frame with the previous and counts the number of changed pixels after having + processed the image with noise filtering, masking, despeckle and labeling. If more pixels than defined + by 'threshold' have changed we assume that we have detected motion. Set the threshold as low as possible + so that you get the motion you want detected but large enough so that you do not get detections from noise + and plants moving. Note that the larger your frames are, the more pixels you have. So for large picture frame + sizes you need a higher threshold. + Use the -s (setup mode) command line option and/or the text_changes config file option to experiment to find + the right threshold value. If you do not get small movements detected (see the mouse on the kitchen floor) lower + the value. If motion detects too many birds or moving trees, increase the number. (Unless of course + you are one of the many many users who use Motion to bird watch!) + Practical values would be from a few hundred to thousands. +

                                                              + +

                                                              threshold_tune

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: on, off
                                                              • +
                                                              • Default: off
                                                              • +
                                                              +

                                                              +Activate the automatic tuning of threshold level. +This feature makes Motion continuously adjust the threshold for declaring motion. +The threshold setting is ignored when activating this feature. It may give different results depending +on your camera, light conditions, indoor/outdoor, the motion to be detected etc. If it does not work well, +deactivate the 'threshold_tune' option and use the manual setting of threshold instead. + +

                                                              + +

                                                              noise_level

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 1 - 255
                                                              • +
                                                              • Default: 32
                                                              • +
                                                              +

                                                              +The noise level is used as a threshold for distinguishing between noise and motion. +This is different from the threshold parameter. This is changes at pixel level. The purpose is to +eliminate the changes generated by electric noise in the camera. Especially in complete darkness +you can see the noise as small grey dots that come randomly in the picture. This noise can create +false motion detection. What this parameter means is that the intensity of a pixel must change more +than +/- the noise threshold parameter to be counted. +

                                                              + +

                                                              noise_tune

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: on, off
                                                              • +
                                                              • Default: on
                                                              • +
                                                              +

                                                              +Activates the automatic tuning of noise level. +This feature makes Motion continuously adjust the noise +threshold for distinguishing between noise and motion. +The 'noise_level' setting is ignored when activating this feature. +It may give different results depending on camera and light conditions. +

                                                              + +

                                                              area_detect

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +Detect motion in predefined areas (1 - 9) and when Motion is detected in the area, execute the script. All of +motion detection still continue. This option is only to execute the on_area_detect script. +

                                                              +Areas are numbered like +
                                                                +
                                                              • 1 2 3
                                                              • +
                                                              • 4 5 6
                                                              • +
                                                              • 7 8 9
                                                              • + +
                                                              + +

                                                              + +

                                                              mask_file

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined
                                                              • +
                                                              +

                                                              +The full path and filename for the masking pgm file. +This picture MUST have the same width and height as the frames being +captured and be in binary format. +If you have one or more areas of the camera image in which you do NOT want motion detected (e.g. a tree that +moves in the wind or a corner of the picture where you can see cars/pedestrians passing by) you need a mask file. +This file is a picture that you create in your favorite photo editing program. The areas that you want detected must +be white. The error that you want ignored must be black. The pgm image must be the same size (number of pixels high +and wide) as the pictures that are taken by the camera. +You can adjust sensitivity by using gray tones. +If you do not have a mask file disable this option by not having it in the config file or comment +it out. +If you are using the rotate option, note that the mask is applied after the rotation. Detailed Description -

                                                              -A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                                -
                                                              • %Y = year -
                                                              • %m = month as two digits -
                                                              • %d = date -
                                                              • %H = hour -
                                                              • %M = minute -
                                                              • %S = second -
                                                              • %T = HH:MM:SS -
                                                              -

                                                              -These are unique to motion

                                                                -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i = width of motion area -
                                                              • %J = height of motion area -
                                                              • %K = X coordinate of motion center -
                                                              • %L = Y coordinate of motion center -
                                                              • %C = value defined by text_event -
                                                              -

                                                              -With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. -

                                                              -For a full list of conversion specifiers see the section Conversion Specifiers for Advanced Filename and Text Feature. -

                                                              -

                                                              -

                                                              Advanced Filenames

                                                              -Motion has a very advanced and flexible automated filenaming feature. -

                                                              -By using conversion specifiers (codes that consist of a '%' followed by a letter) you can build up the filenames including sub directories for pictures and movies using any combination of letters, numbers and conversion specifiers which are codes that represents time, date, event number and frame numbers. -

                                                              -The option target_dir is the target directory for all snapshots, motion images and normal images. The default is the current working directory (current working directory of the terminal from which motion was started). You will normally always want to specify this parameter. -

                                                              -Note that the options snapshot_filename, jpeg_filename, ffmpeg_filename, and timelapse_filename all allow specifying directories by using '/' in the filename. These will all be relative to target_dir. This means in principle that you can specify target_dir as '/' and be 100% flexible. It also means that Motion can write files all over your harddisk if you make a mistake. It is recommended to specify the target_dir as deep or detailed as possible for this reason. And note that targer_dir does not allow conversion specifiers. -

                                                              -The conversion specifier %C which is defined by the option text_event is interesting in connection with filenames because it can be used to create files and directories for each event in a very flexible way. -

                                                              -The convertion specifier %t (thread/camera number) is also very useful. Here is an example of filename definitions in motion.conf: -

                                                              -

                                                              -target_dir /usr/local/webcam
                                                              -snapshot_filename cam%t/%v-%Y%m%d%H%M%S-snapshot
                                                              -jpeg_filename cam%t/%v-%Y%m%d%H%M%S-%q
                                                              -ffmpeg_filename cam%t/%v-%Y%m%d%H%M%S
                                                              -timelapse_filename cam%t/%Y%m%d%H-timelapse
                                                              -
                                                              -

                                                              -The smart thing is that this defines the filename of all your camera threads in motion.conf so you do not need to specify target dir and filenames in the thread config files. In the above example an mpegfile for camera thread 3 will be saved as a filename similar to /usr/local/webcam/cam3/28-20051128130840.avi -

                                                              -NOTE: Unless you use the minimum_gap option to limit the number of shots to less then one per second - you must use the frame modifier %q as part of the jpeg_filename. Otherwise the pictures saved within the same second will overwrite each other. The %q in jpeg_filename ensures that each jpeg (or ppm) picture saved gets a unique filename. -

                                                              -ALERT! Security Warning! Note that the flexibility of this feature also means you have to pay attention to the following.

                                                                -
                                                              • Anyone with access to the remote control port (http) can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. -
                                                              • Anyone with local access to the computer and edit rights to the motion.conf file can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Make sure the motion.conf file is maximum readonly to anyone else but the user running Motion. -
                                                              • It is a good idea to run Motion as a harmless user. Not as root. -
                                                              -

                                                              -These are the advanced filename options in motion.conf -

                                                              -

                                                              -

                                                              ffmpeg_filename (now called movie_filename)

                                                              -

                                                              -ALERT! This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: %v-%Y%m%d%H%M%S -
                                                              • Option Topic -
                                                              -

                                                              -File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. -

                                                              -Default value is equivalent to legacy 'oldlayout' option -For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H%M%S -

                                                              -File extension .mpg or .avi is automatically added so do not include this. -

                                                              -This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                                -
                                                              • %Y = year -
                                                              • %m = month as two digits -
                                                              • %d = date -
                                                              • %H = hour -
                                                              • %M = minute -
                                                              • %S = second -
                                                              • %T = HH:MM:SS -
                                                              -

                                                              -These are unique to motion

                                                                -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i = width of motion area -
                                                              • %J = height of motion area -
                                                              • %K = X coordinate of motion center -
                                                              • %L = Y coordinate of motion center -
                                                              • %C = value defined by text_event -
                                                              -

                                                              -If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and %Y/%m/%d/%H%M%S for 'oldlayout off'. -

                                                              -

                                                              -

                                                              jpeg_filename

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: %v-%Y%m%d%H%M%S-%q -
                                                              • Option Topic -
                                                              -

                                                              -File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. -

                                                              -Default value is equivalent to legacy 'oldlayout' option. For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H/%M/%S-%q -

                                                              -This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                                -
                                                              • %Y = year -
                                                              • %m = month as two digits -
                                                              • %d = date -
                                                              • %H = hour -
                                                              • %M = minute -
                                                              • %S = second -
                                                              • %T = HH:MM:SS -
                                                              -

                                                              -These are unique to motion

                                                                -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i = width of motion area -
                                                              • %J = height of motion area -
                                                              • %K = X coordinate of motion center -
                                                              • %L = Y coordinate of motion center -
                                                              • %C = value defined by text_event -
                                                              -

                                                              -If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S-%q for 'oldlayout on' and %Y/%m/%d/%H/%M/%S-%q for 'oldlayout off'. -

                                                              -The value 'preview' only works when 'output_normal' is set to 'best'. It makes Motion name the best preview jpeg file (image with most changed pixels during the event) with the same body name as the mpeg movie created during the same event. The purpose is to create a good single image that represents the saved mpeg moview so you can decide if you want to see it and spend time downloading it from a web page. -

                                                              -

                                                              -

                                                              movie_filename

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: %v-%Y%m%d%H%M%S -
                                                              • Option Topic -
                                                              -

                                                              -File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. -

                                                              -ALERT! This option was renamed from ffmpeg_filename to movie_filename in Motion 3.2.5. -

                                                              -Default value is equivalent to legacy 'oldlayout' option -For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H%M%S -

                                                              -File extension .mpg or .avi is automatically added so do not include this. -

                                                              -This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                                -
                                                              • %Y = year -
                                                              • %m = month as two digits -
                                                              • %d = date -
                                                              • %H = hour -
                                                              • %M = minute -
                                                              • %S = second -
                                                              • %T = HH:MM:SS -
                                                              -

                                                              -These are unique to motion

                                                                -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i = width of motion area -
                                                              • %J = height of motion area -
                                                              • %K = X coordinate of motion center -
                                                              • %L = Y coordinate of motion center -
                                                              • %C = value defined by text_event -
                                                              -

                                                              -If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and %Y/%m/%d/%H%M%S for 'oldlayout off'. -

                                                              -

                                                              -

                                                              snapshot_filename

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: %v-%Y%m%d%H%M%S-snapshot -
                                                              • Option Topic -
                                                              -

                                                              -File path for snapshots (jpeg or ppm) relative to target_dir. -

                                                              -Default value is equivalent to legacy 'oldlayout' option. For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d/%H/%M/%S-snapshot -

                                                              -File extension .jpg or .ppm is automatically added so do not include this -A symbolic link called lastsnap.jpg (or lastsnap.ppm) created in the target_dir will always point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -

                                                              -This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                                -
                                                              • %Y = year -
                                                              • %m = month as two digits -
                                                              • %d = date -
                                                              • %H = hour -
                                                              • %M = minute -
                                                              • %S = second -
                                                              • %T = HH:MM:SS -
                                                              -

                                                              -These are unique to motion

                                                                -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i = width of motion area -
                                                              • %J = height of motion area -
                                                              • %K = X coordinate of motion center -
                                                              • %L = Y coordinate of motion center -
                                                              • %C = value defined by text_event -
                                                              -

                                                              -If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d%H%M%S-snapshot for 'oldlayout on' and %Y/%m/%d/%H/%M/%S-snapshot for 'oldlayout off'. -

                                                              -For the equivalent of the now obsolete option 'snap_overwrite' use the value 'lastsnap'. -

                                                              -

                                                              -

                                                              target_dir

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined = current working directory -
                                                              • Option Topic -
                                                              -

                                                              -Target directory for picture and movie files. -

                                                              -This is the target directory for all snapshots, images files and movie files. The default is the current working directory (current working directory of the terminal from which motion was started). You will normally always want to specify this parameter as an absolute path. -

                                                              -Note that the options snapshot_filename, jpeg_filename, ffmpeg_filename, and timelapse_filename all allows specifying directories. These will all be relative to 'target_dir'. This means in principle that you can specify target_dir as '/' and be 100% flexible. It also means that Motion can write files all over your harddisk if you make a mistake. It is recommended to specify the target_dir as deep or detailed as possible for this reason. -

                                                              -

                                                              -

                                                              timelapse_filename

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: %v-%Y%m%d-timelapse -
                                                              • Option Topic -
                                                              -

                                                              -File path for timelapse mpegs relative to target_dir (ffmpeg only). -

                                                              -Default value is equivalent to legacy 'oldlayout' option. -

                                                              -For Motion 3.0 compatible mode (directories based on date and time) choose: %Y/%m/%d-timelapse -

                                                              -File extension .mpg is automatically added so do not include this. -

                                                              -This option uses conversion specifiers which are codes that start by % and then a letter. The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are:

                                                                -
                                                              • %Y = year -
                                                              • %m = month as two digits -
                                                              • %d = date -
                                                              • %H = hour -
                                                              • %M = minute -
                                                              • %S = second -
                                                              • %T = HH:MM:SS -
                                                              -

                                                              -These are unique to motion

                                                                -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i = width of motion area -
                                                              • %J = height of motion area -
                                                              • %K = X coordinate of motion center -
                                                              • %L = Y coordinate of motion center -
                                                              • %C = value defined by text_event -
                                                              -

                                                              -If you are happy with the directory structures the way they were in earlier versions of motion use %v-%Y%m%d-timelapse for 'oldlayout on' and %Y/%m/%d-timelapse for 'oldlayout off'. -

                                                              -

                                                              -

                                                              Conversion Specifiers for Advanced Filename and Text Features

                                                              -The table below shows all the supported Conversion Specifiers you can use in the options text_event, text_left, text_right, sql_query, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. -

                                                              -In text_left and text_right you can additionally use '\n' for new line. -

                                                              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                              Conversion Specifier Description
                                                              %a The abbreviated weekday name according to the current locale.
                                                              %A The full weekday name according to the current locale.
                                                              %b The abbreviated month name according to the current locale.
                                                              %B The full month name according to the current locale.
                                                              %c The preferred date and time representation for the current locale.
                                                              %C Text defined by the text_event feature
                                                              %d The day of the month as a decimal number (range 01 to 31).
                                                              %D Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area.
                                                              %E Modifier: use alternative format, see below.
                                                              %f File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                              %F Equivalent to %Y-%m-%d (the ISO 8601 date format).
                                                              %H The hour as a decimal number using a 24-hour clock (range 00 to 23).
                                                              %i Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                              %I The hour as a decimal number using a 12-hour clock (range 01 to 12).
                                                              %j The day of the year as a decimal number (range 001 to 366).
                                                              %J Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on).
                                                              %k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.)
                                                              %K X coordinate in pixels of the center point of motion. Origin is upper left corner.
                                                              %l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.)
                                                              %L Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon).
                                                              %m The month as a decimal number (range 01 to 12).
                                                              %M The minute as a decimal number (range 00 to 59).
                                                              %n Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features.
                                                              %N Noise level.
                                                              %o Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold.
                                                              %p Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'.
                                                              %P Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
                                                              %q Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs.
                                                              %Q Number of detected labels found by the despeckle feature
                                                              %r The time in a.m. or p.m. notation.
                                                              %R The time in 24-hour notation (%H:%M).
                                                              %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
                                                              %S The second as a decimal number (range 00 to 61).
                                                              %t Thread number (camera number)
                                                              %T The time in 24-hour notation (%H:%M:%S).
                                                              %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
                                                              %U The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
                                                              %v Event number. An event is a series of motion detections happening with less than 'gap' seconds between them.
                                                              %V The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W.
                                                              %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
                                                              %W The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
                                                              %x The preferred date representation for the current locale without the time.
                                                              %X The preferred time representation for the current locale without the date.
                                                              %y The year as a decimal number without a century (range 00 to 99).
                                                              %Y The year as a decimal number including the century.
                                                              %z The time-zone as hour offset from GMT.
                                                              %Z The time zone or name or abbreviation.
                                                              -

                                                              -

                                                              -

                                                              Webcam Server

                                                              -Motion has simple webcam server built in. The video stream is in mjpeg format. -

                                                              -Each thread can have its own webcam server. If you enable the webcam server (option webcam_port to a number different from 0) and you have more than one camera, you must make sure to include webcam_port in each thread config file and set webcam_port to different and unique port numbers or zero (disable). Otherwise each webcam server will use the setting from the motion.conf file and try to bind to the same port. If the webcam_port numbers are not different from each other Motion will disable the webcam feature. -

                                                              -Note: The webcam server feature requires that the option ppm is set to off. (I.e. saved images are jpeg images). -

                                                              -The webcam_maxrate and webcam_quality options are important to limit the load on your server and link. Don't set them too high unless you only use it on the localhost or on an internal LAN. The option webcam_quality is equivalent to the quality level for jpeg pictures. -

                                                              -The webcam_limit option prevents people from loading your Network connection by streaming for hours and hours. The options defines the number of picture frames sent as mjpeg Motion will allow without re-connecting (e.g. clicking refresh in the browser). -

                                                              -The option webcam_localhost is a security feature. When enabled you can only access the webserver on the same machine as Motion is running on. If you want to present a live webcam on your web site this feature must be disabled. -

                                                              -The webserver generates a stream in "multipart jpeg" format (mjpeg). You cannot watch the stream with most browsers. Only certain versions of Netscape works. Mozilla and Firefox brosers can view the mjpeg stream but you often have to refresh the page once to get the streaming going. Internet Explorer cannot show the mjpeg stream. For public viewing this is not very useful. There exists a java applet called Cambozola which enabled any Java capable browser to show the stream. To enable the feature to a broad audience you should use this applet or similar. -

                                                              -To use the webcam feature with Cambozola is actually very simple. -

                                                              -1. Create a html page in which you will want the streamed picture. -

                                                              -2. In the html page include this code -

                                                              -

                                                              -<applet code=com.charliemouse.cambozola.Viewer
                                                              -    archive=cambozola.jar width="320" height="240" style="border-width:1; border-color:gray; border-style:solid;">
                                                              -    <param name=url value="http://www.myurl.com:8081">
                                                              -</applet>
                                                              -
                                                              -

                                                              -Where the width and height is the image size of the video stream. -

                                                              -Replace www.myurl.com:8081 by the real url and port number of your choice. -

                                                              -3. In the same directory you place the cambozola.jar file. No need to build the java applet from source. Simply use the applet in the package. -

                                                              -4. Enable the feature in motion.conf. -

                                                              -You can also view the live webcam stream using MPlayer like this: -

                                                              -

                                                              mplayer -demuxer lavf http://www.myurl.com:8081/stream.mjpg
                                                              -

                                                              -Note that the stream.mjpg part is important, without it you will get a LAVF_check: no clue about this gibberish! error from libavformat. -

                                                              -These are the special webcam parameters. -

                                                              -

                                                              -

                                                              webcam_limit

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 2147483647 -
                                                              • Default: 0 (unlimited) -
                                                              • Option Topic -
                                                              -

                                                              -Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. -

                                                              -Number can be defined by multiplying actual webcam rate by desired number of seconds. Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate. -

                                                              -

                                                              -

                                                              webcam_localhost

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: on -
                                                              • Option Topic -
                                                              -

                                                              -Limits the access to the webcam to the localhost. -

                                                              -By setting this to on, the webcam can only be accessed on the same machine on which Motion is running. -

                                                              -

                                                              -

                                                              webcam_maxrate

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 1 - 100 -
                                                              • Default: 1 -
                                                              • Option Topic -
                                                              -

                                                              -Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. -

                                                              -Don't set 'webcam_maxrate' too high unless you only use it on the localhost or on an internal LAN. -

                                                              -

                                                              -

                                                              webcam_motion

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: off -
                                                              • Option Topic -
                                                              -

                                                              -If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. -

                                                              -Use this option to save bandwidth when there is not anything important to see from the camera anyway. -

                                                              -Note that this feature was greatly improved from Motion version 3.2.2. Before 3.2.2 the option stopped the webcam stream except when Motion was detected. This made the feature not very useful because it made it difficult to connect to the webcam stream and most mjpeg viewers would timeout and give an error message. From 3.2.2 the feature has been greatly improved and actually quite recommendable. -

                                                              -

                                                              -

                                                              -

                                                              webcam_port

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 65535 -
                                                              • Default: 0 (disabled) -
                                                              • Option Topic -
                                                              -

                                                              -TCP port on which motion will listen for incoming connects with its webcam server. -

                                                              -Note that each camera thread must have its own unique port number and it must also be different from the control_port number. -

                                                              -A good value to select is 8081 for camera 1, 8082 for camera 2, 8083 for camera 3 etc etc. -

                                                              -

                                                              -

                                                              webcam_quality

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 1 - 100 -
                                                              • Default: 50 -
                                                              • Option Topic -
                                                              -

                                                              -Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. -

                                                              -The mjpeg stream consists of a header followed by jpeg frames separated by content-length and boundary string. The quality level defines the size of the individual jpeg pictures in the mjpeg stream. If you set it too high you need quite a high bandwidth to view the stream. -

                                                              -

                                                              Remote Control with http

                                                              -

                                                              -Motion can be remote controlled via a simple http interface. http is the language a normal web browser talks when it requests a web page. The web server answers back with some simple http headers followed by a webpage coded in HTML. -

                                                              -Most Motion config options can be changed while Motion is running except options related to the size of the captured images and mask files which are loaded only when Motion starts. So only your fantasy sets the limit to what you can change combining cron and the remote control interface for Motion. -

                                                              -So the most obvious tool to use to remote control Motion is any web browser. All commands are sent using the http GET method which simply means that the information is sent via the URL and maybe a query string. You can use any browser (Firefox, Mozilla, Internet Explorer, Konquerer, Opera etc). You can also use the text based browser lynx to control Motion from a console. It navigates fine through the very simple and minimalistic http control interface of Motion. -

                                                              -The details about how to control Motion via the URL is described in detail in the Motion http API topic. -

                                                              -But it is probably simpler to connect to the control port with a browser, navigate to the function you want, and copy the URL from the browser URL entry line. If your control_port is 8080 and you browse from the same machine on which Motion runs simply look up http://localhost:8080/ and navigate around. Connecting from a remote machine is done by using a domain name (example http://mydomain.com:8080/) or the IP address of the machine (example http://192.168.1.4:8080/). The option control_localhost must be off to allow connection from a remote machine. -

                                                              -If you want to use a script or cron to automatically change Motion settings while Motion runs you use a program that can fetch a webpage. We simply just throw away the html page that Motion returns. Programs commonly available on Linux machines are wget and lwp-request. Here is an example of how to start and stop motion detection via cron. These two lines are added to /etc/crontab. -

                                                              -

                                                              -0 9 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/start > /dev/null
                                                              -0 18 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/pause > /dev/null
                                                              -
                                                              -

                                                              -If you want to use the http remote control from your own software (for example your own PHP front end) you can set the new motion.conf option html_output off. Then Motion answers back with very basic text only and no html around it. A bit like the xmlrpc interface did. -

                                                              -To remote control Motion from a web pages you can for example use PHP. In PHP it takes this simple code line to send a remote commend to Motion. Here we pause motion detection for camera 2 -

                                                              -readfile('http://localhost:8080/2/detection/pause'); -

                                                              -What happened to XMLRPC? -

                                                              -XMLRPC is replaced by a simpler http remote control interface. It is still being worked on but it is absolutely useable now and much nicer to work with than xmlrpc. Another advantage is that you do not need to install xmlrpc libraries. It is all written in standard C. -

                                                              -ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.

                                                                -
                                                              • Anyone with access to the remote control port (http) can alter the values of any options and save files anywhere on your server with the same privileges as the user running Motion. They can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. -
                                                              • If you limit control port to localhost you still need to take care of any user logging into the server with any kind of terminal session. -
                                                              • It is a good idea to run Motion as a harmless user. Not as root!! -
                                                              -

                                                              -These are the config file options that control Motion. -

                                                              -These must be placed in motion.conf and not in a thread config file. -

                                                              -

                                                              -

                                                              control_authentication

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4096 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. -

                                                              -By setting this to on, the control using http (browser) can only be accessed using login and password ( following the Basic Authentication defined in HTTP RFC). -

                                                              -

                                                              -

                                                              - -

                                                              -

                                                              -

                                                              control_html_output

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: on -
                                                              • Option Topic -
                                                              -

                                                              -Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. -

                                                              -The recommended value for most is "on" which means that you can navigate and control Motion with a normal browser. By setting this option to "off" the replies are in plain text which may be easier to parse for 3rd party programs that control Motion. -

                                                              -

                                                              -

                                                              control_localhost

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: on -
                                                              • Option Topic -
                                                              -

                                                              -Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. -

                                                              -By setting this to on, the control using http (browser) can only be accessed on the same machine on which Motion is running. -

                                                              -

                                                              -

                                                              control_port

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 65535 -
                                                              • Default: 0 (disabled) -
                                                              • Option Topic -
                                                              -

                                                              -Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. -

                                                              -This sets the TCP/IP port number to be used for control of motion using http (browser). Port numbers below 1024 normally requires that you have root privileges. Port 8080 is a fine choice of port to use for the purpose. -

                                                              -

                                                              -

                                                              --- KennethLavrsen - 12 Apr 2005 -

                                                              -

                                                              -

                                                              External Commands

                                                              -Motion can execute external commands based on the motion detection and related events. They are all described in this section. The option quiet is also included in this section. -

                                                              -A redesign of the external commands was due. They were not very easy to understand, not all were flexible enough and some were missing. So a new external command feature set was made for 3.2.1 and on. -

                                                              -This is how the new script commands look like: -

                                                              - - - - - - - +

                                                              +The mask file must be a pgm format image file (portable gray map). Note that you must choose the BINARY format. +

                                                              +To use this feature create an image of exact the same size as the ones you get from your camera. +Then make it purely white for the areas you want detected and +black for the areas you want ignored. You can also make gray areas where +you want to lower the sensitivity to motion. Normally you will stick to pure black and white. +

                                                              +One method for generating the mask file is as follows. +

                                                              +Take a motion captured picture, edit it with black and white for the mask and export it as a pgm file. +with a program such as gimp. + +If you cannot save in this format save as a grayscale jpg and then you can convert it to pgm format with +

                                                              +djpeg -grayscale -pnm [inputfile] > mask.pgm + +

                                                              +(assuming you have djpeg installed - part of the jpeg lib package). +

                                                              +Note that the mask file option masks off the detection of motion. The entire picture is still shown on the picture. +This means that you cannot use the feature to mask off an area that you do not want people to see. +

                                                              +Below are an example of a webcam picture and a mask file to prevent the detection cars in the street. +

                                                              +Normal picture. Notice the street is visible through the hedge. +

                                                              +normal.jpg +

                                                              +Mask file (converted to png format so it can be shown by your web browser) +

                                                              +
                                                              Function Old Option New Option Argument Appended
                                                              Start of event (first motion) execute on_event_start None
                                                              End of event (no motion for gap seconds) New! on_event_end None
                                                              Picture saved (jpg or ppm) onsave on_picture_save Filename of picture
                                                              Movie starts (mpeg file opened) onmpeg on_movie_start Filename of movie
                                                              Movie ends (mpeg file closed) onffmpegclose on_movie_end Filename of movie
                                                              Motion detected (each single frame with Motion detected) New! on_motion_detected None
                                                              + + +
                                                              + mask1.png +
                                                              -

                                                              -Mail and sms has been removed because they were not configurable. If you want to send event-based mails or sms, just use one of those commands above and send the mail from that script. See What happened to mail and sms? -

                                                              -

                                                              -ALERT! Security Warning! Note that this feature also means you have to pay attention to the following.

                                                                -
                                                              • Anyone with access to the remote control port (http) can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside. -
                                                              • If you limit control port to localhost you still need to take care of any user logging into the server with any kind of GUI or terminal session. All it takes is a browser or single command line execution to change settings in Motion. -
                                                              • It is a good idea to run Motion as a harmless user. Not as root!! -
                                                              -

                                                              -These are the options -

                                                              -

                                                              -

                                                              on_event_end

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. -

                                                              -Full path name of the program/script. -

                                                              -This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. -

                                                              -The command is run when an event is over. I.e. the number of seconds defined by the time 'gap' has passed since the last detection of motion and motion closes the mpeg file. -

                                                              -

                                                              +

                                                              + + +

                                                              + +

                                                              smart_mask_speed

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 10
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +Speed for the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. +Smartmask is a dynamic, self-learning mask. Smartmask will disable sensitivity +in areas with frequent motion (like trees in the wind). Sensitivity is turned +on again after some time of no more motion in this area. The built mask is a bit +larger at the borders than the actual motion was. This way smartmask works more +reliable when sudden moves occur under windy conditions. +

                                                              +Fast means here that the mask is built quick, but it is also not staying very long with no more motion. +Slow means that it takes a while until the mask is built but it also stays longer. A good start value +for smart_mask_speed is 5. This setting is independent from the framerate. The attack and decay time +is constant over all available framerates. +When smartmask is enabled and motion is also configured to either write motion-images or motion-mpegs, +the current smartmask is copied as an overlay into the black/white motion-pictures/mpegs in red colour. +Same thing happens to the webcam stream when Motion runs in setup_mode. That way you can +easily adjust smart_mask_speed. +

                                                              +The mask_file option provides a static mask to turn off sensitivity in certain areas. +This is very useful to mask a street with cars passing by all day long etc... +

                                                              +But imagine a scenario with large bushes and big trees where all the leaves are moving +in the wind also triggering motion from time to time even with despeckle turned on. Of +course you can also define a static mask here, but what if the bushes are growing during +spring and summer? Well, you have to adapt the mask from time to time. What if the camera +position moves slightly? What if someone grows new plants in your garden? You always have to setup a new static mask. +

                                                              +The answer to this problem is the smart mask feature A dynamic, self-learing mask. +

                                                              +Smart mask will disable sensitivity in areas with frequent motion (like trees in the wind). +Sensitivity is turned on again after some time of no more motion in this area. The built mask +is a bit larger at the borders than the actual motion. This way smartmask works more reliably +when sudden moves occur under windy conditions. + +

                                                              + +

                                                              lightswitch

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 100
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. +The value defines the picture areas in percent that will trigger the lightswitch condition. When lightswitch is +detected motion detection is disabled for 5 picture frames. This is to avoid false detection when light conditions +change and when a camera changes sensitivity at low light. +

                                                              + +

                                                              minimum_motion_frames

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 1 - 1000s
                                                              • +
                                                              • Default: 1
                                                              • +
                                                              +

                                                              +Picture frames must contain motion at least the specified number of frames in a row before they are +detected as true motion. At the default of 1, all motion is detected. Valid range is 1 to thousands, +but it is recommended to keep it within 1-5. +Note that the picture frames are buffered by Motion and once motion is detected also the first frames +containing motion are saved so you will not miss anything. +The feature is used when you get many false detections when the camera changes light sensitivity or light changes. +Even though Motion accepts large values you should set this to a relatively low number +(below 10). For each step larger than 1 Motion reserves space in RAM for the picture frame buffer. If you have a +large value Motion will miss many frames from the camera while it is processing the all the pictures in the buffer. + +

                                                              + +

                                                              event_gap

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 2147483647
                                                              • +
                                                              • Default: 60
                                                              • +
                                                              +

                                                              +The seconds of no motion detection that triggers the end of an event. +An event is defined as a series of motion images taken within a short timeframe. +The value -1 is allowed and disables + events causing all Motion to be written to one single movie file and no pre_capture. + If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An + event ends right after no more motion is detected and post_capture is over. + +Disabling events has bad side effects on +noise_tune and smartmask. Both features can only work properly outside an event. +When event_gap is set to -1, both features don't work properly anymore. +An event is defined as a series of motion images taken within a short timeframe. +E.g. a person walking through the room is an event that may have caused 10 single +jpg images to be stored. This option defines how long a pause between detected motions +that is needed to be defined as a new event. +The timer starts after the last motion is detected and post_capture images +have been saved and appended to open movie files. +Any motion detected before the gap timer times out resets the gap timer so it starts counting over again. +The option 'event_gap' is important. It defines how long a period of no motion detected it takes before we say an event is over. An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. Motion detected includes post_captured frames set by the 'post_capture' option. The 'gap' option defines how long a pause between detected motions that is needed to be defined as a new event. A good starting value is 60 seconds. +The way 'gap' works in more technical terms is: +
                                                                +
                                                              • A timer that timeouts 'event_gap' seconds after the last video frame with motion is detected.
                                                              • +
                                                              • If 'post_capture' is activated then the gap timer starts counting after the last image of the post_capture buffer has been saved.
                                                              • +
                                                              • The gap timer is reset and starts all over each time new motion is detected, so you will not miss any action by having a short 'gap' value. It will just create more events (e.g. more mpegs files)
                                                              • +
                                                              +The gap value impacts many functions in Motion. +
                                                                +
                                                              • When the timer runs out the event number is increased by one next time motion is detected. + When you use the %v conversion specifier in filenames or text features this means that the + number in filename or text increased by one.
                                                              • +
                                                              • The pre_capture feature only works at the beginning of an event. So if you have a very large 'event_gap' + value pre_capture is not working very often.
                                                              • +
                                                              • When you make movies using the ffmpeg features a new movie file is started at the beginning of an event + when the first motion is detected. When 'event_gap' seconds has passed without motion (and post_captured frames + saved) the movie files are completed and closed.
                                                              • +
                                                              • Do not use large event_gap values to generate one large movie file. + If Motion stops working this movie file never gets properly completed and closed + you will not be able to view it.
                                                              • +
                                                              • Some of the tracking features sets the camera back to the center position when an event is over.
                                                              • +
                                                              + +Note that 'event_gap' and 'minimum_gap' have nothing to do with each other. +

                                                              +

                                                              +
                                                            + +

                                                            Script Execution

                                                            +
                                                              +

                                                              +Motion can execute external commands based on the motion detection and related events. +They are described in the sections below. +

                                                              +Security Warning! +

                                                              +These features mean you have to pay attention to the following. +
                                                                +
                                                              • Anyone with access to the remote control port (http) can execute any command on your computer with +the same privileges as the user running Motion. +Anyone can access your control port if you have not either limited access to localhost or +limited access using firewalls in the server. +You should always have a router between a machine running Motion with remote control +enabled and the Internet and make sure the Motion control port is not accessible from the outside. +
                                                              • +
                                                              • If you limit control port to localhost you still need to take care of any user logging into the server +with any kind of GUI or terminal session. All it takes is a browser or single command line execution to +change settings in Motion. +
                                                              • +
                                                              • It is a good idea to run Motion as a harmless user. Not as root!!
                                                              • +
                                                              +

                                                              + +

                                                              +

                                                              +

                                                              on_event_start

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. -

                                                              -Full path name of the program/script. -

                                                              -This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. -

                                                              -The command is run when an event starts. I.e. the first motion is detected since the last event. -

                                                              -This option replaces the former options 'mail', 'sms' and 'execute'. -

                                                              -

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Default: Not defined
                                                              • +
                                                              +

                                                              +The full path and file name of the program/script to be executed at the start of an event. +An event starts at first motion detected after a +period of no motion defined by gap. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +

                                                              + +

                                                              on_event_end

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined
                                                              • +
                                                              +

                                                              +The full path and file name of the program/script to be executed when a event ends. +An event ends after the event_gap has expired. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +

                                                              + +

                                                              on_picture_save

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined
                                                              • +
                                                              +

                                                              +The full path and file name of the program/script to be executed when a picture is saved. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +Use %f for passing filename (with full path) to the command. +

                                                              +

                                                              +

                                                              on_motion_detected

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. -

                                                              -Do not write "none" if you do not want to execute commands. Simply do not include the option in the file or comment it out by placing a "#" or ";" as the first character on the line before the execute command. -

                                                              -

                                                              -

                                                              on_movie_end

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -

                                                              -Full path name of the program/script. -

                                                              -This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. -

                                                              -The command is run when an event is over. I.e. the number of seconds defined by the time 'gap' has passed since the last detection of motion and motion closes the mpeg file. -

                                                              -This option was previously called onffmpegclose. -

                                                              -Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. -

                                                              -Most common conversion specifiers -

                                                                -
                                                              • %Y = year, %m = month, %d = date -
                                                              • %H = hour, %M = minute, %S = second -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i and %J = width and height of motion area -
                                                              • %K and %L = X and Y coordinates of motion center -
                                                              • %C = value defined by text_event -
                                                              • %f = filename with full path -
                                                              • %n = number indicating filetype -
                                                              -

                                                              -

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined
                                                              • +
                                                              +

                                                              +The full path and file name of the program/script to be executed when motion is detected. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +

                                                              + +

                                                              on_area_detected

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +The full path and file name of the program/script to be executed when motion is +detected in the predefined area indicated in the area_detect option. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +

                                                              +

                                                              on_movie_start

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -

                                                              -Full path name of the program/script. -

                                                              -This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. When you use ffmpeg the film is generated on the fly and on_movie_start then runs when the new mpeg file is created. Often you will want to use the on_movie_end option which runs when the mpeg file is closed and the event is over. -

                                                              -This option was previously called onmpeg. -

                                                              -Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. -

                                                              -Most common conversion specifiers -

                                                                -
                                                              • %Y = year, %m = month, %d = date -
                                                              • %H = hour, %M = minute, %S = second -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i and %J = width and height of motion area -
                                                              • %K and %L = X and Y coordinates of motion center -
                                                              • %C = value defined by text_event -
                                                              • %f = filename with full path -
                                                              • %n = number indicating filetype -
                                                              -

                                                              -

                                                              -

                                                              on_picture_save

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. -

                                                              -Full path name of the program/script. -

                                                              -This can be any type of program or script. Remember to set the execution bit in the file access control list (chmod) and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/usr/bin/perl) as the first line of the script. -

                                                              -Note that from Motion 3.2.4 the path name of the picture file is no longer appended to the command. Instead you can use the conversion specifier %f to insert the picture filename (full path) anywhere in the command. -

                                                              -Most common conversion specifiers -

                                                                -
                                                              • %Y = year, %m = month, %d = date -
                                                              • %H = hour, %M = minute, %S = second -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i and %J = width and height of motion area -
                                                              • %K and %L = X and Y coordinates of motion center -
                                                              • %C = value defined by text_event -
                                                              • %f = filename with full path -
                                                              • %n = number indicating filetype -
                                                              -

                                                              -

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined
                                                              • +
                                                              +

                                                              +The full path and file name of the program/script to be executed when a +new movie is being created. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +Use %f for passing filename (with full path) to the command. +

                                                              +

                                                              + +

                                                              on_movie_end

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined
                                                              • +
                                                              +

                                                              +

                                                              +The full path and file name of the program/script to be executed after a new +movie was created. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +Use %f for passing filename (with full path) to the command. +

                                                              +

                                                              + +

                                                              on_camera_lost

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +The full path and file name of the command to be executed when a camera can't be opened or if it is lost +Note that there are situations when motion doesn't detect a lost camera. It is +dependent upon the camera and driver and it is advised that this option be tested +for each configuration. It has also been observed that there are also +situations in which the disconnection of the camera even hangs the PC in which +case this script will not be executed. +

                                                              +You can use Conversion Specifiers +and spaces as part of the command. This can be any type of program or script. +Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash +also remember the shebang line (e.g. #!/user/bin/perl) as the first line of the script. +

                                                              +

                                                              + +
                                                            + +

                                                            Output - General Options

                                                            +
                                                              + +

                                                              quiet

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: off -
                                                              • Option Topic -
                                                              -

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: on, off
                                                              • +
                                                              • Default: off
                                                              • +
                                                              +

                                                              Be quiet, don't output beeps when detecting motion. -

                                                              Only works in non-daemon mode. -

                                                              -

                                                              -

                                                              - -

                                                              What happened to mail and sms?

                                                              -The 6 new on_xxxxx options replace the former execute, mail and sms options. -

                                                              -They are quite generic and flexible. These small bash scripts gives to the same functionality as mail and sms BUT you have all the flexibility you want to extend the messages, change the 'from' email address etc. -

                                                              -

                                                              Sending email at start of event

                                                              -Script written by JoergWeber -
                                                              -#!/bin/sh
                                                              -
                                                              -# Motion sample script to send an e-mail at start of an event.
                                                              -# Replaces the former 'mail' option.
                                                              -# Just define this script as 'on_event_start'-script in motion.conf like that:
                                                              -# on_event_start send_mail "%Y-%m-%d %T"
                                                              -
                                                              -#change to suit your needs:
                                                              -#location of 'mail' binary
                                                              -MAIL="/usr/bin/mail"
                                                              -#Destination e-mail address
                                                              -TO="root@localhost"
                                                              -#Subject of the e-mail
                                                              -SUBJECT="Motion detected"
                                                              -
                                                              -#Don't change anything below this line
                                                              -echo -e "This is an automated message generated by motion.\n\nMotion detected: $1\n\n" | $MAIL -s "$SUBJECT" $TO
                                                              -
                                                              -

                                                              -

                                                              Sending SMS at start of event

                                                              -Script written by JoergWeber -

                                                              -If you uncomment the line #/usr/local/bin/send_mail $1 you can combine both sending email and sms. -

                                                              -#!/bin/sh
                                                              +

                                                              +

                                                              + +

                                                              pre_capture

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 100s
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +Specifies the number of pre-captured (buffered) pictures from before motion +was detected that will be output at motion detection. +The recommended range is 0 to 5. It is not recommended to use large values. +Large values will cause Motion to skip video frames and cause unsmooth movies. +To smooth movies use larger values of post_capture instead. +

                                                              +Motion buffers the number of picture frames defined by 'pre_capture'. When motion is detected the pictures in the +buffer are included in the movie. The effect is that it seems the program knew in advance +that the event was going to take place and started the recording before it actually happened. +This is a nice feature that give more complete video clips of an event. +

                                                              +If pre_capture is set to 0 the feature is disabled. The recommended value would be approx 0.5 second of +video so the value should be defined so it fits the framerate and the desired pre-capture time. +You can in theory have up to 100s of pre-captured frames but naturally this makes motion leave a larger footprint in +the memory of the computer. +

                                                              +More important Motion is processing all the buffered images including saving jpegs, +encoding the movie, writing to databases and executing external programs after the first image is detected as Motion. +

                                                              +Motion will not grab another image until this is done. This means that even moderate values for pre_capture combined +with high framerates will mean that you will probably miss many frames of Motion. +

                                                              +It is therefore recommended to use relatively small values for pre_capture. +Depending on your chosen framerate and depending on the features enabled values from 1-5 are sensible. +

                                                              +If you wish to create a smooth movie during events using large pre_capture values will do the opposite! It will create +a long pause where a lot of action is missed. +

                                                              +To get a smooth movie use a large value for post_capture which does not cost any performance hit or RAM +space. +

                                                              +

                                                              + +

                                                              post_capture

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 2147483647
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +Specifies the number of frames to be captured after motion has been detected. +The purpose of this is mainly to create smooth video clips each time motion is detected. Use it to you personal +taste (and disk space).. +This option is the preferred way to create continuous movies. Post_capture does not consume extra RAM and it +does not create pauses in the movie even with large values. +If you only store movies and do not have output_normal on, then the recommended post_capture value is what is +equivalent to 1-5 seconds of movie. +

                                                              +

                                                              + +

                                                              target_dir

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: Not defined = current working directory
                                                              • +
                                                              +

                                                              +The full path for the target directory for picture and movie files to be saved. +The default is the current working directory. This is the target directory for all snapshots, +images files and movie files. +You will normally always want to specify this parameter as an absolute path. +

                                                              +Note that the file name options are all saved relative to this target_dir +This means in principle that you can specify target_dir as '/' and be 100% flexible. But this is +NOT recommended. It is recommended that this directory be specified as deep as possible. +

                                                              +

                                                              + +
                                                            + +

                                                            Output - Picture Options

                                                            +
                                                              + +

                                                              +Motion can output different types of pictures. The normal picture is indicated below. +

                                                              +outputnormal1.jpg +

                                                              +The motion type picture or also referred to as a debug picture is shown +below. Note that the largest area is blue and only this is counted as Motion. +

                                                              +The Motion image shows how Motion maintains a "reference frame" which is not just the last picture frame +but a mathematical calculation of the past images. This enlarges real Motion and ensures that it is not easy to +sneak in slowly. +

                                                              +outputmotion1.jpg +

                                                              +

                                                              + + +

                                                              output_pictures

                                                              +

                                                              +
                                                                +
                                                              • Type: Discrete Strings
                                                              • +
                                                              • Range / Valid values: on, off, first, best
                                                              • +
                                                              • Default: on
                                                              • +
                                                              +

                                                              +This option controls the output of the normal image. +

                                                              +'on' is the usual selection. +

                                                              +If you set the value to 'first' Motion saves only the first motion detected picture per event. +If you set it to "best" Motion saves the picture with most changed pixels during the event. +This may be useful if you store movies on a server and want to present a jpeg to show the content of the movie +on a webpage. +

                                                              +"best" requires a little more CPU power and resources compared to "first". +

                                                              +'off' to don't write pictures +

                                                              +

                                                              + +

                                                              output_debug_pictures

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: on, off
                                                              • +
                                                              • Default: off
                                                              • +
                                                              +

                                                              +Output pictures with only the moving object. +This feature generates the special motion type movies where you only see the pixels that +changes as a graytone image. If labelling is enabled you see the largest area in blue. +

                                                              +If a Smartmask is specified, it is shown in red. +

                                                              +Motion images shows the motion content of the pictures. +This is good for tuning and testing but probably not very interesting for the general public. +

                                                              +Default is not to store these motion images. +Motion pictures are stored the same place and with the same filename as normal motion +triggered pictures except they have an "m" appended at the end of the filename before +the .jpg or .ppm. E.g. the name can be 01-20020424232936-00m.jpg. +

                                                              +

                                                              + +

                                                              quality

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 1 - 100
                                                              • +
                                                              • Default: 75
                                                              • +
                                                              +

                                                              +The quality for the jpeg images in percent. +100 means hardly compressed. A small number means a much smaller file size but also a less nice +quality image to look at. +

                                                              +

                                                              + +

                                                              picture_type

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +This option specifies the type of picture file to output. The recommendation is to always use jpg except +if you have a specific need to store high quality pictures without any quality loss. +

                                                              +

                                                              + +

                                                              snapshot_interval

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 2147483647
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +This parameter specifies the number of seconds between each snapshot +

                                                              +

                                                              + +

                                                              snapshot_filename

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: %v-%Y%m%d%H%M%S-snapshot
                                                              • +
                                                              +

                                                              +This option indicates the file name and optionally the path for the snapshots (jpeg or ppm) relative to target_dir. +

                                                              +The file extension .jpg or .ppm is automatically added. +

                                                              +A symbolic link called lastsnap.jpg (or lastsnap.ppm) is created in the target_dir and will always +point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +

                                                              +You can use Conversion Specifiers in this option. +

                                                              +

                                                              + +

                                                              picture_filename

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: %v-%Y%m%d%H%M%S-%q
                                                              • +
                                                              +

                                                              +This option indicates the file name and optionally the path for the pictures (jpeg or ppm) relative to target_dir. +

                                                              +The file extension .jpg or .ppm is automatically added. +

                                                              +You can use Conversion Specifiers in this option. +

                                                              +

                                                              + +

                                                              exif_text

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +Use this option to specify the text to include in a JPEG EXIF comment +The EXIF timestamp is included independent of this text. +

                                                              +You can use Conversion Specifiers in this option. +

                                                              +

                                                              +
                                                            + +

                                                            Output - Movie Options

                                                            +
                                                              +

                                                              +

                                                              max_movie_time

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 (infinite) - 2147483647
                                                              • +
                                                              • Default: 3600
                                                              • +
                                                              +

                                                              +The maximum length of a movie in seconds. Set this to zero for unlimited length. +

                                                              +

                                                              + +

                                                              ffmpeg_output_movies

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: on, off
                                                              • +
                                                              • Default: off
                                                              • +
                                                              +

                                                              +Use ffmpeg libraries to encode movies of the motion. This option +generates a new movie at the beginning of each new event and appends to the +movie for each motion detected within the same event. +The current event ends when the time defined by the 'event_gap' option has passed with no motion detected. +At the next detection of motion a new movie is started. +

                                                              +To use this feature you need to install ffmpeg or Libav. +

                                                              +

                                                              + +

                                                              ffmpeg_output_debug_movies

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: on, off
                                                              • +
                                                              • Default: off
                                                              • +
                                                              +

                                                              +Use ffmpeg libraries to encode motion type movies where you only see the pixels that changes. +Works like ffmpeg_output_movies but outputs motion pixel type pictures instead. +This feature generates the special motion type movie where you only see the pixels +that changes as a graytone image. If labeling is enabled you see the largest area in blue. +Smartmask is shown in red. The filename given is the same as the normal movies except they +have an 'm' appended after the filename. +

                                                              +

                                                              -# Motion sample script to send an sms at start of an event. -# Replaces the former 'sms' option. -# Just define this script as 'on_event_start'-script in motion.conf like that: -# on_event_start send_sms "%Y-%m-%d %T" -# -# If you want to send an e-mail message here as well, just uncomment the last -# line of this script. +

                                                              ffmpeg_timelapse

                                                              +

                                                              +
                                                                +
                                                              • Type: Boolean
                                                              • +
                                                              • Range / Valid values: 0 - 2147483647
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. +

                                                              +

                                                              -#change to suit your needs: -#location of 'sms-client' binary -SMS_CLIENT="/usr/bin/sms_client" -#Destination sms number -TO="12345" +

                                                              ffmpeg_timelapse_mode

                                                              +

                                                              +
                                                                +
                                                              • Type: Discrete Strings
                                                              • +
                                                              • Range / Valid values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual
                                                              • +
                                                              • Default: daily
                                                              • +
                                                              +

                                                              +The file rollover mode of the timelapse video. +Note that it is important that you use the conversion specifiers in ffmpeg_filename that ensure that +the new timelapse file indeed is a new file. If the filename does not change Motion will simply append +the timelapse pictures to the existing file. +The value 'Manual' means that Motion does not automatically rollover to a new filename. You can do it +manually using the http control interface by setting the option 'ffmpeg_timelapse' to 0 and then back +to your chosen value. Value 'hourly' rolls over on the full hour. Value 'daily' which is the default +rolls over at midnight. There are two weekly options because depending on where you come from a week +may either start on Sunday or Monday. And 'monthly' naturally rolls over on the 1st of the month. +

                                                              +

                                                              -#Don't change anything below this line -$SMS_CLIENT $TO "Motion detected $1" +

                                                              ffmpeg_bps

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0 - 9999999
                                                              • +
                                                              • Default: 400000
                                                              • +
                                                              +

                                                              +Bitrate of movies produced by ffmpeg. Bitrate is bits per second. +Higher value mans better quality and larger files if the camera is on a fixed bitrate setting. +Experiment to get the desired quality. The better quality the bigger files. +This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled). +

                                                              +

                                                              -#/usr/local/bin/send_mail $1 +

                                                              ffmpeg_variable_bitrate

                                                              +

                                                              +
                                                                +
                                                              • Type: Integer
                                                              • +
                                                              • Range / Valid values: 0, 2 - 31
                                                              • +
                                                              • Default: 0 (disabled)
                                                              • +
                                                              +

                                                              +Enables and defines variable bitrate for the ffmpeg encoder. +The option of ffmpeg_bps is ignored if variable bitrate is enabled. +A value of 0 disables this option while values 2 - 31 are applicable when a +variable bit rate is desired. The value of 2 means best quality and 31 is worst. +

                                                              +Experiment for the value that gives you the desired compromise between size and quality. +

                                                              +

                                                              - -

                                                              -

                                                              -

                                                              Motion Guide - Special Features

                                                              -

                                                              -

                                                              Tracking Control

                                                              -This is still at the experimental stage. Read more about it motion tracking page. -

                                                              -

                                                              Tracking Feature with Logitech Quickcam Sphere/Orbit

                                                              -Motion supports controlling the pan and tilt feature of a Logitech Quickcam Sphere/Orbit. -

                                                              -Motion can move the camera to a fixed position given in degrees pan (left-right) and tilt (down-up). Movement can be set with absolute coordinates or relative to current position. There is also an auto tracking feature for the Logitech Quickcam Sphere/Orbit but it is not very mature. It is fun to play with but not very useful yet. See this topic of how KennethLavrsen controls his Sphere: LogitechSphereControl. -

                                                              -For a detailed description of http remote control see the section Remote Control with http. -

                                                              -List of tracking options -

                                                              -

                                                              track_auto

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: off -
                                                              • Option Topic -
                                                              -

                                                              -Enable auto tracking -

                                                              -Requires a tracking camera type supported by Motion. -

                                                              -

                                                              -

                                                              track_iomojo_id

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 2147483647 -
                                                              • Default: 0 -
                                                              • Option Topic -
                                                              -

                                                              -Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. -

                                                              -Only used for iomojo camera. -

                                                              -

                                                              -

                                                              track_maxx

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 2147483647 -
                                                              • Default: 0 -
                                                              • Option Topic -
                                                              -

                                                              -The maximum position for servo x. -

                                                              -Only used for stepper motor tracking. -

                                                              -

                                                              -

                                                              track_maxy

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 2147483647 -
                                                              • Default: 0 -
                                                              • Option Topic -
                                                              -

                                                              -The maximum position for servo y. -

                                                              -Only used for stepper motor tracking. -

                                                              - -

                                                              -

                                                              -

                                                              track_motorx

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: -1 - 2147483647 -
                                                              • Default: -1 -
                                                              • Option Topic -
                                                              -

                                                              -The motor number that is used for controlling the x-axis. -

                                                              -Only used for stepper motor tracking. -

                                                              -

                                                              -

                                                              track_motory

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: -1 - 2147483647 -
                                                              • Default: -1 -
                                                              • Option Topic -
                                                              -

                                                              -The motor number that is used for controlling the y-axis. -

                                                              -Only used for stepper motor tracking. -

                                                              - -

                                                              -

                                                              -

                                                              track_move_wait

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 2147483647 -
                                                              • Default: 10 -
                                                              • Option Topic -
                                                              -

                                                              -Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. -

                                                              -The actual delay is depending on the chosen framerate. If you want the camera to move maximum once every 2 seconds and the framerate is 10 then you need to set the track_move_wait value to 2 * 10 = 20. -

                                                              -

                                                              -

                                                              track_port

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -This is the device name of the serial port to which the stepper motor interface is connected. -

                                                              -Only used for stepper motor tracking. -

                                                              -

                                                              -

                                                              track_speed

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 255 -
                                                              • Default: 255 -
                                                              • Option Topic -
                                                              -

                                                              -Speed to set the motor to. -

                                                              -Only used for stepper motor tracking. -

                                                              -

                                                              -

                                                              track_step_angle_x

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0-90 -
                                                              • Default: 10 -
                                                              • Option Topic -
                                                              -

                                                              -Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. -

                                                              -Requires a tracking camera type pwc. -

                                                              -

                                                              -

                                                              track_step_angle_y

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0-40 -
                                                              • Default: 10 -
                                                              • Option Topic -
                                                              -

                                                              -Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. -

                                                              -Requires a tracking camera type pwc. -

                                                              - -

                                                              -

                                                              -

                                                              track_stepsize

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 255 -
                                                              • Default: 40 -
                                                              • Option Topic -
                                                              -

                                                              -Number of steps to make. -

                                                              -Only used for stepper motor tracking. -

                                                              -

                                                              -

                                                              track_type

                                                              -

                                                                -
                                                              • Type: Discrete Strings -
                                                              • Range / Valid values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) -
                                                              • Default: 0 (None) -
                                                              • Option Topic -
                                                              -

                                                              -Type of tracker. -

                                                              -Motion has special tracking options which use either a serial stepper motor controller, an iomojo smile cam or a Philips WebCam driver compatible pan/tilt camera such as the Logitech Quickcam Sphere or Orbit. -

                                                              -To disable tracking, set this to 0 and the other track options are ignored. -

                                                              -Value 1 is for the special Motion Tracking project using a stepper motor and a home made controller. -

                                                              -Value 2 is for the iomojo smilecam -

                                                              -Value 3 is for pwc type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit which is driven by the pwc (Philips WebCam) driver. To use this camera your version of pwc must be at least 8.12. -

                                                              -Value 4 is the generic track type. Currently it has no other function than enabling some of the internal Motion features related to tracking. Eventually more functionality will be implemented for this type. -

                                                              -Value 5 is for uvcvideo type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit MP (new Model) which is driven by the uvcvideo driver. This option was added in Motion 3.2.8. -

                                                              -

                                                              -

                                                              Using Databases

                                                              -Motion can be compiled with both MySQL and PostgreSQL database support. When enabled Motion adds a record to a table in the database as specified by the sql_query. The query contains the fields that are used and the value are given by using conversion specifiers for dynamic data like filename, time, number of detected pixels etc. Motion does not place any binary images in the database and it cannot remove old records. -

                                                              -Motion only adds records to the database when files are created. The database contains records of saved files which means to get a record in the database the feature that enables for example motion detection, timelapse, snapshots etc must be enabled. The sql_log options defines which types of files are logged in the database. -

                                                              -The following sql_log options are common to both MySQL and PostgreSQL. -

                                                              -

                                                              -

                                                              sql_log_image

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: on -
                                                              • Option Topic -
                                                              -

                                                              -Log to the database when creating motion triggered image file. -

                                                              -Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                              -

                                                              -

                                                              sql_log_mpeg

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: off -
                                                              • Option Topic -
                                                              -

                                                              -Log to the database when creating motion triggered mpeg file. -

                                                              -Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                              -

                                                              -

                                                              sql_log_snapshot

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: on -
                                                              • Option Topic -
                                                              -

                                                              -Log to the database when creating a snapshot image file. -

                                                              -Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                              -

                                                              -

                                                              sql_log_timelapse

                                                              -

                                                                -
                                                              • Type: Boolean -
                                                              • Range / Valid values: on, off -
                                                              • Default: off -
                                                              • Option Topic -
                                                              -

                                                              -Log to the database when creating timelapse mpeg file -

                                                              -Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. -

                                                              -

                                                              -

                                                              sql_query

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -
                                                              • Option Topic -
                                                              -

                                                              -SQL query string that is sent to the database. The values for each field are given by using convertion specifiers -

                                                              -Most common conversion specifiers -

                                                                -
                                                              • %Y = year, %m = month, %d = date -
                                                              • %H = hour, %M = minute, %S = second -
                                                              • %v = event -
                                                              • %q = frame number -
                                                              • %t = thread (camera) number -
                                                              • %D = changed pixels -
                                                              • %N = noise level -
                                                              • %i and %J = width and height of motion area -
                                                              • %K and %L = X and Y coordinates of motion center -
                                                              • %C = value defined by text_event -
                                                              • %f = filename with full path -
                                                              • %n = number indicating filetype -
                                                              -

                                                              -

                                                              -See the "MySQL" section for detailed information about the database itself. -

                                                              -

                                                              MySQL

                                                              -You can use the MySQL database to register each file that is stored by motion. -

                                                              -You need to generate a new database with a name of your own choice. You must enter this name in the config file (mysql_db option). The default value for the option sql_query requires that you create a new database in MySQL with a new table called "security" with the following fields: -

                                                              -insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -

                                                                -
                                                              • camera (int) - camera (thread) number -
                                                              • filename (char60) - filename (full path) -
                                                              • frame (int) - the number of the picture frame -
                                                              • file_type (int) - file type as a number - see table below. -
                                                              • time_stamp (timestamp) - timestamp for the picture in native database format -
                                                              • text_event (timestamp) - The text from the text_event option which by default is compatible with timestamps in SQL. -
                                                              -

                                                              -Note from version 3.2.4 the introduction of sql_query completely redefines the way you setup the SQL feature. It is now 100% flexible and can easily be made compatible with your existing Motion database from earlier versions of Motion. -

                                                              -These are the file type descriptions and the file type numbers stored in the database. -

                                                              - - - - - - -
                                                              Normal image 1
                                                              Snapshot image 2
                                                              Motion image (showing only pixels defined as motion) 4
                                                              Normal mpeg image 8
                                                              Motion mpeg (showing only pixels defined as motion) 16
                                                              Timelapse mpeg 32
                                                              -

                                                              -You can create the table using the following SQL statement. -

                                                              -CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), text_event timestamp(14)); -

                                                              -If you choose to use text_event for a non-timestamp value you can instead define something like. -

                                                              -CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), text_event char(40)); -

                                                              -

                                                              -Remember to update grant table to give access to the mysql username you choose for motion. -

                                                              -It would be too much to go into detail about how to setup and use MySQL. After all this is a guide about Motion. However here are some hints and links. -

                                                              -Setting Up a MySQL Based Website - A beginners guide from Linux Planet. -

                                                              -Webmonkey PHP/!MySQL tutorial - Entertaining and easy to read. -

                                                              -The phpMyAdmin homepage. The best and simplest tool to use MySQL (editors opinion). Requires Apache/PHP. -

                                                              -The options for MySQL -

                                                              -

                                                              -

                                                              mysql_db

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Name of the MySQL database. -

                                                              -MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. -

                                                              -If you compiled motion with MySQL support you will need to set the mysql options if you want motion to log events to the database. -

                                                              -

                                                              -

                                                              mysql_host

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: localhost -
                                                              • Option Topic -
                                                              -

                                                              -IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. -

                                                              -MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. -

                                                              -

                                                              -

                                                              mysql_password

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -The MySQL password. -

                                                              -MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. -

                                                              -

                                                              -

                                                              mysql_user

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -The MySQL user name. -

                                                              -MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. -

                                                              -

                                                              -

                                                              -

                                                              PostgreSQL

                                                              -Same/similar as for MySQL above. -

                                                              -The options for PostgreSQL -

                                                              -

                                                              -

                                                              pgsql_db

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -Name of the PostgreSQL database. -

                                                              -PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -If you compiled motion with PostgreSQL support you will need to set all the pgsql_ options if you want motion to log events to the database. -

                                                              -

                                                              -

                                                              pgsql_host

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: localhost -
                                                              • Option Topic -
                                                              -

                                                              -IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. -

                                                              -PostgreSQL CONFIG FILE OPTION. Motion must be built with pgsql_db libraries to use this feature. -

                                                              -

                                                              -

                                                              pgsql_password

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -The PostgreSQL password. -

                                                              -PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -

                                                              -

                                                              pgsql_port

                                                              -

                                                                -
                                                              • Type: Integer -
                                                              • Range / Valid values: 0 - 65535 -
                                                              • Default: 5432 -
                                                              • Option Topic -
                                                              -

                                                              -The PostgreSQL server port number. -

                                                              -PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -

                                                              -

                                                              pgsql_user

                                                              -

                                                                -
                                                              • Type: String -
                                                              • Range / Valid values: Max 4095 characters -
                                                              • Default: Not defined -
                                                              • Option Topic -
                                                              -

                                                              -The PostgreSQL user name. -

                                                              -PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. -

                                                              -

                                                              -

                                                              Video4Linux Loopback Device

                                                              -You can use this driver for looking at motion in realtime. The video4linux driver is written by the same author that first created Motion. You can find the source and a brief description at the video4linux loopback device web page. -

                                                              -The video4linux device is a Kernel module which installs itself as a video pipe. It has an input and an output. The module simply takes anything that comes on its input and send it out at the output. The purpose of this is to create a standard video4linux type video device that other programs can then use. You may now ask: "What do I need that for?". -

                                                              -Only one program can access a video device at a time. When motion is using a camera - no other program can access the same camera. But motion is made to be able to feed a video signal to the video loopback device. This way an additional program such as Camstream, Xawtv, a video stream server etc can watch the signal from a camera that motion uses already. What you see is not the live camera stream but the exact same picture that motion uses for detecting motion and the same pictures that are saved/streamed. You can also choose to see the "motion" type images where you see the pixels that are changing - live. Originally the video4linux pipe was used as an interface between Motion and a Webcam server. Since version 2.9 Motion has had its own webserver so this usage is no longer very relevant. -

                                                              -When you install the video loopback device it will create an input - for example /dev/video5 and an output - for example /dev/video6. You can then tell motion to "pipe" the video signal to the /dev/video5 and look at the pictures live using e.g. Camstream on /dev/video6. Camstream is "fooled" to think it is looking at a real camera. -

                                                              +

                                                              ffmpeg_video_codec

                                                              +

                                                              +
                                                                +
                                                              • Type: Discrete Strings
                                                              • +
                                                              • Range / Valid values: mpeg1, mpeg4, msmpeg4, swf, flv, ffv1
                                                              • +
                                                              • Default: mpeg4
                                                              • +
                                                              +

                                                              +Codec to be used by ffmpeg for the video compression. +

                                                              +Timelapse videos have two options. +
                                                                +
                                                              • swf - Creates swf file with mpeg-2 encoding. If motion is shutdown and restarted, new pics will be appended + to any previously created file with name indicated for timelapse.
                                                              • +
                                                              • mpeg4 - Creates avi file with the default encoding. If motion is shutdown and restarted, new pics will +create a new file with the name indicated for timelapse.
                                                              • +
                                                              +

                                                              +Movie files have the following options +
                                                                +
                                                              • mpeg4 or msmpeg4 - gives you files with extension .avi
                                                              • +
                                                              • swf - gives you a flash film with extension .swf
                                                              • +
                                                              • flv - gives you a flash video with extension .flv
                                                              • +
                                                              • ffv1 - FF video codec 1 for Lossless Encoding
                                                              • +
                                                              • mov - QuickTime
                                                              • +
                                                              • ogg - Ogg/Theora
                                                              • +
                                                              • mp4 - MPEG-4 Part 14 H264 encoding
                                                              • +
                                                              • mkv - Matroska H264 encoding
                                                              • +
                                                              + +

                                                              +

                                                              + +

                                                              ffmpeg_duplicate_frames

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +If the CPU can not keep up with the requested frame rate for the movies, should frames be +duplicated in order to keep up or should it be skipped. +

                                                              +

                                                              + +

                                                              movie_filename

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: %v-%Y%m%d%H%M%S
                                                              • +
                                                              +

                                                              +File path for motion triggered movies relative to target_dir. Note that the file +extension is automatically added to the name based upon the codec selected. +

                                                              +You can use Conversion Specifiers in this option. +

                                                              +

                                                              + + +

                                                              timelapse_filename

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default: %v-%Y%m%d-timelapse
                                                              • +
                                                              +

                                                              +File path for the timelapse movies relative to target_dir. Note that the file +extension is automatically added to the name based upon the codec selected. +

                                                              +You can use Conversion Specifiers in this option. +

                                                              +

                                                              +
                                                            + +

                                                            Output - Pipe Options

                                                            +
                                                              + +

                                                              +The video4linux driver is written by the same author that first created Motion. You can +find the source and a brief description at the +video4linux loopback device web page. +

                                                              +The video4linux device is a Kernel module which installs itself as a video pipe. +It has an input and an output. The module simply takes anything that comes on its input +and send it out at the output. The purpose of this is to create a standard video4linux type video +device that other programs can then use. You may now ask: "What do I need that for?". +

                                                              +Only one program can access a video device at a time. When motion is using a camera - +no other program can access the same camera. But motion is made to be able to feed a video signal +to the video loopback device. This way an additional program can watch the signal from a camera that +motion uses already. What you see is not the live camera stream but the exact same picture that motion +uses for detecting motion and the same pictures that are saved/streamed. You can also choose to +see the "motion" type images where you see the pixels that are changing - live. +

                                                              +When you install the video loopback device it will create an input - +for example /dev/video5 and an output - for example /dev/video6. You can then tell motion to "pipe" +the video signal to the /dev/video5 and look at the pictures live using e.g. Camstream on /dev/video6. +Camstream is "fooled" to think it is looking at a real camera. +

                                                              Installing -

                                                              +

                                                              Installing the video loopback device is not difficult. At least not when you have this document available. -

                                                              -First you must prepare your system for more video devices. You will need two extra devices for each video pipe that you want. -

                                                              -For example if you have 4 cameras they will probably run at /dev/video0, /dev/video1, /dev/video2, and /dev/video3. So you will need additional 8 video devices. This is easy to do. -

                                                              +

                                                              +First you must prepare your system for more video devices. You will need two extra devices for each video +pipe that you want. +

                                                              +For example if you have 4 cameras they will probably run at +/dev/video0, /dev/video1, /dev/video2, and /dev/video3. So you will need additional 8 video devices. +This is easy to do. +

                                                               mknod /dev/video4 c 81 4
                                                               mknod /dev/video5 c 81 5
                                                              @@ -3446,97 +3431,888 @@ 

                                                              video4linux loopback device . Place the file in a place of your own choice. -

                                                              +

                                                              +Download the latest +video4linux loopback device . +Place the file in a place of your own choice. +

                                                              Untar and uncompress the file to the place you want the program installed. Editor recommends /usr/local/vloopback. -

                                                              +

                                                              cd /usr/local -

                                                              +

                                                              tar -xvzf /path/to/vloopback-1.1-rc1.tar.gz -

                                                              -You now have a directory called vloopback-1.1-rc1. You can rename it to vloopback (mv vloopback-1.1-rc1 vloopback). I recommend creating a symbolic link to the current version. This way you can more easily experiment with different versions simply by changing the link. -

                                                              +

                                                              +You now have a directory called vloopback-1.1-rc1. You can rename it to vloopback (mv vloopback-1.1-rc1 vloopback). +I recommend creating a symbolic link to the current version. This way you can more easily experiment with different +versions simply by changing the link. +

                                                              ln -s vloopback-1.1-rc1 vloopback -

                                                              +

                                                              Now change to the new directory -

                                                              +

                                                              cd vloopback -

                                                              +

                                                              Build the code -

                                                              +

                                                              make -

                                                              -There is a good chance that the make will not work and give you a long list of errors. To run make the following must be available on you machine.

                                                                +

                                                                +There is a good chance that the make will not work and give you a long list of errors. +To run make the following must be available on you machine.
                                                                • The kernel source files must be installed. -
                                                                • The source files must be available at /usr/src/linux.
                                                                  E.g. the new Red Hat 7.3 does not have a link to the sources called linux. Instead there is a link called linux-2.4. This is easy to fix. Just create a link to the real source tree. Do not rename! Add a link using this command (replacing the kernel version number with the one you have on your machine)
                                                                  ln -s /usr/src/linux-2.4.18-4 /usr/src/linux -
                                                                • Alternatively you can change the vloopback makefile so that the "LINUXSRC=/usr/src/linux" line is changed to the actual path. I recommend the link solution since this may solve other similar problems that you can get when installing other software. -
                                                                -

                                                                -When compiling on a newer Linux distribution you may get a warning about a header file malloc.h. To remove this warning simply change the header reference as suggested by the warning. -

                                                                +

                                                              • The source files must be available at /usr/src/linux.
                                                                E.g. +the new Red Hat 7.3 does not have a link to the sources called linux. Instead there is a link +called linux-2.4. This is easy to fix. Just create a link to the real source tree. Do not rename! +Add a link using this command (replacing the kernel version number with the one you have on your +machine)
                                                                ln -s /usr/src/linux-2.4.18-4 /usr/src/linux +
                                                              • Alternatively you can change the vloopback makefile so that the "LINUXSRC=/usr/src/linux" line is +changed to the actual path. I recommend the link solution since this may solve other similar problems that you +can get when installing other software. +
                                                              +

                                                              +When compiling on a newer Linux distribution you may get a warning about a header file malloc.h. +To remove this warning simply change the header reference as suggested by the warning. +

                                                              In vloopback.c you replace the line -

                                                              +

                                                              #include <linux/malloc.h> -

                                                              +

                                                              with the line -

                                                              +

                                                              #include <linux/slab.h> -

                                                              -Install the code you built as a Kernel module. There are two options: pipes should be set to the number of video loopbacks that you want. Probably one for each camera. The dev_offset defines which video device number will be the first. If dev_offset is not defined the vloopback module will install itself from the first available video device. If you want the cameras to be assigned to the lower video device numbers you must either load vloopback after loading the video device modules OR use the dev_offset option when loading vloopback. Vloopback then installs itself in the sequence input 0, output 0, input 1, output 1, input 2, output 2 etc. Here is shown the command for our example of 4 cameras and 4 loopback devices and the first loopback device offset to /dev/video4. -

                                                              +

                                                              +Install the code you built as a Kernel module. There are two options: +pipes should be set to the number of video loopbacks that you want. Probably one for each camera. +The dev_offset defines which video device number will be the first. If dev_offset is not defined the +vloopback module will install itself from the first available video device. If you want the cameras to be +assigned to the lower video device numbers you must either load vloopback after loading the video device +modules OR use the dev_offset option when loading vloopback. Vloopback then installs itself in the sequence +input 0, output 0, input 1, output 1, input 2, output 2 etc. Here is shown the command for our example of 4 +cameras and 4 loopback devices and the first loopback device offset to /dev/video4. +

                                                              /sbin/insmod /usr/local/vloopback/vloopback.o pipes=4 dev_offset=4 -

                                                              +

                                                              When you run the command you may get a warning about tainting the Kernel. Just ignore this. You can choose to copy the vloopback.o file into a directory in the /lib/modules tree where the insmod/modprobe programs are already looking for modules. Then the command gets simpler (/sbin/insmod vloopback pipes=.....). -

                                                              +

                                                              If you want the loopback device to load during boot, you can place the call in one of the bootup scripts such as /etc/rc.d/rc.local. Vloopback should be loaded before you start motion. -

                                                              +

                                                              To activate the vloopback device in motion set the 'video_pipe' option in the motion.conf file. You can also view the special motion pictures where you see the changed pixels by setting the option 'motion_video_pipe' in motion.conf. When setting the video_pipe and/or motion_video_pipe options either specify the input device as e.g. /dev/video4. You can also set the parameter to '-' which means that motion will find the first vacant video loopback device input. If you have more than one camera you may want to control which loopback device each thread uses. Then you need to define the specific device name in motion.conf for the first camera and in each thread config file for the other cameras. If you set the video_pipe parameter to '-' in the motion.conf file and not setting it in the thread config files, motion automatically assign video devices in the same sequence as the threads are loaded. You can combine both video_pipe and motion_video_pipe but then naturally you will need twice as many pipes. -

                                                              +

                                                              De-activating should be done with this command -

                                                              +

                                                              /sbin/modprobe -r vloopback -

                                                              -Description of the motion.conf options related to video loopback device. -

                                                              -

                                                              +

                                                              +

                                                              + + + +

                                                              video_pipe

                                                              +

                                                              +
                                                                +
                                                              • Type: String
                                                              • +
                                                              • Range / Valid values: Max 4095 characters
                                                              • +
                                                              • Default:
                                                              • +
                                                              +

                                                              +if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set +The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the +device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate +a free pipe. +

                                                              +

                                                              +

                                                              motion_video_pipe

                                                              -

                                                                +

                                                                • Type: String
                                                                • Range / Valid values: Max 4095 characters
                                                                • Default: Not defined
                                                                • Option Topic
                                                                -

                                                                -The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set -

                                                                -Using this you can view the results in real time. E.g. by using the program camstream. The difference between this option and the video-pipe option is that this option shows the motion version of the images instead of the normal images. -

                                                                -Disable this option by not having it in the config file (or comment it out with "#" or ";"). -

                                                                -

                                                                -

                                                                video_pipe

                                                                -

                                                                  -
                                                                • Type: String -
                                                                • Range / Valid values: Max 4095 characters -
                                                                • Default: Not defined -
                                                                • Option Topic -
                                                                -

                                                                -The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe. If a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. -

                                                                -Using this you can view the results in real time. E.g. by using the program camstream. -

                                                                -Disable this option by not having it in the config file (or comment it out with "#" or ";"). -

                                                                -

                                                                -

                                                                -

                                                                --- KennethLavrsen - 13 Apr 2005 +

                                                                +The video4linux video loopback input device for motion images. +If a particular pipe is to be used then use the device filename of this pipe, +if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set +

                                                                +

                                                                + +

                                                                use_extpipe

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +This option specifies whether to send the output to a +pipe for external encoding into a movie. +

                                                                +Note that this option does not require the install or configure of the videoloop back +

                                                                +

                                                                + + +

                                                                extpipe

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +This option specifies the program name and options for the +program that will receive and process the images during a movie event. +

                                                                +Note that this option does not require the install or configure of the videoloop back +

                                                                +Sample: +

                                                                +extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps + +

                                                                +

                                                                + + +
                                                              + +

                                                              Steam and Webcontrol

                                                              +
                                                                + +Motion has simple webcam server built in. The server can be configured to +stream both the images as well allow for a very basic http control of these Motion parameters. +

                                                                +Each thread can have its own stream and it is enabled by specifying +the port number. If there are multiple cameras, each camera must have +its own unique port number. +

                                                                +The webserver generates a stream in "multipart jpeg" format (mjpeg). Some browsers can not display +images fed in this method. Alternatives are being considered for implementation within Motion to resolve +this limitation. The most straight forward around this limitation is to create a local +HTML page that references the raw stream. + +

                                                                +Open up a text editor and paste in the following. + +<html> +<body bgcolor=000000> +<img src=http://yourmotionpc:yourstreamport/ border="0" width=25%></a> +</body> +</html> + +

                                                                +Change the yourmotionpc with the IP or name of the computer running Motion. Also revise the port +number to be the one referenced for the stream. +

                                                                +Save the file and then open it in your browser. +

                                                                +

                                                                +It may also be possible to view the stream via regular stream players such as VLC, mplayer, ffplay, avplay, etc. +by specifying the network stream as + +http://localhost:myportnumber/stream.mjpg + +

                                                                +

                                                                + +

                                                                +Motion can be remote controlled via a simple http interface. +

                                                                +Most Motion configuration options can be changed while Motion is running except +options related to the size of the captured images and mask files which +are loaded only when Motion starts. +

                                                                +The most obvious tool to use to remote control Motion is any web browser. +All commands are sent using the http GET method which simply means that the information is +sent via the URL and maybe a query string. You can use any browser (Firefox, Mozilla, Internet Explorer +, etc). You can also use the text based browser lynx to control Motion from a console. +It navigates fine through the very simple and minimalistic http control interface of Motion. +

                                                                +

                                                                +But it is probably simpler to connect to the control port with a browser, navigate to the function +you want, and copy the URL from the browser URL entry line. +If your webcontrol_port is 8080 and you browse from the same machine +on which Motion runs simply look up +http://localhost:8080/ and navigate around. +Connecting from a remote machine is done by using a domain name (example + http://mydomain.com:8080/) or the + IP address of the machine (example + http://192.168.1.4:8080/). + The option webcontrol_localhost must be off to allow connection from a remote machine. +

                                                                +If you want to use a script or cron to automatically change Motion settings while Motion runs you use a +program that can fetch a webpage. We simply just throw away the html page that Motion returns. Programs +commonly available on Linux machines are wget and lwp-request. Here is an example of how to start and +stop motion detection via cron. These two lines are added to /etc/crontab. +

                                                                +
                                                                +0 9 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/start > /dev/null
                                                                +0 18 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/pause > /dev/null
                                                                +
                                                                +

                                                                +If you want to use the http remote control from your own software (for example your own PHP front end) +you can set the new motion.conf option html_output off. Then Motion answers back with very basic text +only and no html around it. +

                                                                +To remote control Motion from a web pages you can for example use PHP. +In PHP it takes this simple code line to send a remote commend to Motion. +Here we pause motion detection for camera 2 +

                                                                +readfile('http://localhost:8080/2/detection/pause'); +

                                                                + +

                                                                +ALERT! Security Warning! This feature also means you have to pay attention +to the following. +
                                                                  +
                                                                • Anyone with access to the remote control port (http) can alter the values of any options + and save files anywhere on your server with the same privileges as the user running Motion. + They can execute any command on your computer with the same privileges as the user running Motion. + Anyone can access your control port if you have not either limited access to localhost or limited + access using firewalls in the server. You should always have a router between a machine running + Motion with remote control enabled and the Internet and make sure the Motion control port is not + accessible from the outside.
                                                                • +
                                                                • If you limit control port to localhost you still need to take care of any user logging + into the server with any kind of terminal session.
                                                                • +
                                                                • Run Motion as a harmless user. DO NOT RUN AS ROOT!!
                                                                • +
                                                                + +

                                                                +

                                                                + +

                                                                ipv6_enabled

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +# Enable or disable IPV6 for http control and stream (default: off ) +

                                                                + +

                                                                stream_port

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 65535
                                                                • +
                                                                • Default: 0 (disabled)
                                                                • +
                                                                +

                                                                +# The mini-http server listens to this port for requests (default: 0 = disabled) +TCP port on which motion will listen for incoming connects with its webcam server. +Note that each camera thread must have its own unique port number and it must also be different from the control_port number. +A good value to select is 8081 for camera 1, 8082 for camera 2, 8083 for camera 3 etc etc. + +This must be placed in motion.conf and not in a thread config file. + +

                                                                + +

                                                                stream_quality

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 1 - 100
                                                                • +
                                                                • Default: 50
                                                                • +
                                                                +

                                                                +Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. +The mjpeg stream consists of a header followed by jpeg frames separated by content-length and boundary string. The quality level defines the size of the individual jpeg pictures in the mjpeg stream. If you set it too high you need quite a high bandwidth to view the stream. + +

                                                                + +

                                                                stream_motion

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: off
                                                                • +
                                                                +

                                                                +When set to 'on' slow down the stream to 1 picture per second when no motion is detected. +When motion is detected the stream runs as defined by stream_maxrate +When 'off' the stream always runs as defined by stream_maxrate. +Use this option to save bandwidth when there is not anything important to see from the camera anyway. +

                                                                + +

                                                                stream_maxrate

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 1 - 100
                                                                • +
                                                                • Default: 1
                                                                • +
                                                                +

                                                                +Limit the framerate of the stream in frames per second. Set the value to 100 for practically unlimited. +Don't set this parameter too high unless you only use it on the localhost or on an internal LAN. +

                                                                + +

                                                                stream_localhost

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: on
                                                                • +
                                                                +

                                                                +Limits the access to the stream to the localhost. +By setting this to on, the stream can only be accessed on the same machine on which Motion is running. +

                                                                + +

                                                                stream_limit

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +This parameter limits the maximum number of images per connection and is +determined by multiplying actual stream rate by desired number of seconds +

                                                                + +

                                                                stream_auth_method

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 to 2
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +This parameter establishes desired authentication method for the stream and +web control ports. The parameters have the following meaning. +
                                                                  +
                                                                • 0 = disabled
                                                                • +
                                                                • 1 = Basic authentication
                                                                • +
                                                                • 2 = MD5 digest (the safer authentication)
                                                                • +
                                                                +

                                                                +Note that if you are enabling the webcontrol feature of Motion, you really really really ... should +enable security authentications. No. Seriously. You really should. See the security warnings in this +document regarding how it completely opens up your system. +

                                                                + + +

                                                                stream_authentication

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default: Not Defined
                                                                • +
                                                                +

                                                                +This parameter establishes the username and password to use for the stream. +The syntax is username:password +

                                                                + +

                                                                webcontrol_port

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 65535
                                                                • +
                                                                • Default: 0 (disabled)
                                                                • +
                                                                +

                                                                +Sets the port number for the http based control of the Motion parameters. +This option must be placed in the motion.conf file and not in a thread config file. +Port numbers below 1024 normally require that you have root privileges. +The port 8080 is the typical selection of the port for this purpose. +

                                                                + +

                                                                webcontrol_localhost

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: on
                                                                • +
                                                                +

                                                                +This option restricts the control of the Motion parameters to the localhost. +This option must be placed in motion.conf and not in a thread config file. +By setting this to on, the control using http (browser) can only be accessed on the +same machine on which Motion is running. +

                                                                + +

                                                                webcontrol_html_output

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: on
                                                                • +
                                                                +

                                                                +Enable HTML in the answer sent back to a browser connecting to the webcontrol_port. +This option must be placed in motion.conf and not in a thread config file. +The recommended value for most is "on" which means that you can navigate and control +Motion with a normal browser. By setting this option to "off" the replies are in plain +text which may be easier to parse for 3rd party programs that control Motion. +

                                                                + +

                                                                webcontrol_authentication

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +This parameter establishes the username and password to use for the stream. +The syntax is username:password +

                                                                +

                                                                +
                                                              + +

                                                              Database

                                                              +
                                                                + +Motion can be compiled with MySQL, PostgreSQL or SQLite3 database support. +When enabled Motion can be configured to add a record to a table in the database +as specified by the sql_query. The query can contain the fields that are used and the +value are given by using conversion specifiers for dynamic data like +filename, time, number of detected pixels etc. +Motion does not place any binary images in the database and it cannot remove old records. +

                                                                +Motion only adds records to the database when files are created. +The database contains records of saved files which means to get a +record in the database the feature that enables for example motion +detection, timelapse, snapshots etc must be enabled. +The sql_log options defines which types of files are logged in the database. +

                                                                +The following are sample create table queries for different databases. +

                                                                +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); +

                                                                + + +

                                                                +

                                                                sql_log_picture

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: on
                                                                • +
                                                                +

                                                                +Log to the database when a motion triggered image file is created. +

                                                                + +

                                                                sql_log_snapshot

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: on
                                                                • +
                                                                +

                                                                +Log to the database when creating a snapshot image file. +

                                                                + +

                                                                sql_log_movie

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: off
                                                                • +
                                                                +

                                                                +Log to the database when creating motion triggered movie file. +

                                                                + +

                                                                sql_log_timelapse

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: off
                                                                • +
                                                                +

                                                                +Log to the database when creating timelapse movie file +

                                                                + +

                                                                sql_query

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default: Not Defined
                                                                • +
                                                                +

                                                                +SQL query string that is sent to the database when the sql_log_* item is triggered. +

                                                                +

                                                                +You can use Conversion Specifiers +within the query. +

                                                                +

                                                                +Sample Query +

                                                                +insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') +insert or ignore into images (camera_nbr, file_name, year, month, day, hour, minute) values (8, '%f', '%Y','%m','%d','%H','%M') +

                                                                +

                                                                + +

                                                                database_type

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: mysql, postgresql, sqlite3
                                                                • +
                                                                • Default: Not Defined
                                                                • +
                                                                +

                                                                +This option specifies the database type. +

                                                                + +

                                                                database_dbname

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default: Not Defined
                                                                • +
                                                                +

                                                                +The name of the database. +

                                                                + +

                                                                database_host

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default: localhost
                                                                • +
                                                                +

                                                                +The host on which the database is located +

                                                                + +

                                                                database_user

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +The user account name for database +

                                                                + +

                                                                database_password

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +The user password for database +

                                                                + +

                                                                database_port

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values:
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +The port number that is used for the database. Typical values are: mysql=3306 and postgresql=5432 +

                                                                + +

                                                                sqlite3_db

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +The name of the SQLite3 database. +

                                                                + +

                                                                sqlite3_busy_timeout

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +If the database is busy when the request is issued, this parameter indicates the time to +wait before issuing a timeout message. +

                                                                +

                                                                + +
                                                              + +

                                                              Tracking

                                                              +
                                                                + +

                                                                +This is still at the experimental stage. +

                                                                +Motion can move the camera to a fixed position given in degrees pan (left-right) and tilt (down-up). +Movement can be set with absolute coordinates or relative to current position. There is also an auto tracking +feature for the Logitech Quickcam Sphere/Orbit but it is not very mature. Search the Motion home website +or community development pages for additional information regarding tracking if these features are required. +

                                                                +

                                                                + + +

                                                                +

                                                                track_type

                                                                +

                                                                +
                                                                  +
                                                                • Type: Discrete Strings
                                                                • +
                                                                • Range / Valid values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo)
                                                                • +
                                                                • Default: 0 (None)
                                                                • +
                                                                +

                                                                +Type of tracker. +

                                                                +Motion has special tracking options which use either a serial stepper motor controller, +an iomojo smile cam or a Philips WebCam driver compatible pan/tilt camera such as +the Logitech Quickcam Sphere or Orbit. +

                                                                +To disable tracking, set this to 0 and the other track options are ignored. +

                                                                +Value 1 is for the special Motion Tracking project using a stepper motor and a home made controller. +

                                                                +Value 2 is for the iomojo smilecam +

                                                                +Value 3 is for pwc type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit which is driven +by the pwc (Philips WebCam) driver. To use this camera your version of pwc must be at least 8.12. +

                                                                +Value 4 is the generic track type. Currently it has no other function than enabling some of the +internal Motion features related to tracking. +

                                                                +Value 5 is for uvcvideo type USB tracking cameras such as the Logitech Quickcam Sphere/Orbit MP which is driven +by the uvcvideo driver. +

                                                                + +

                                                                + +

                                                                track_auto

                                                                +

                                                                +
                                                                  +
                                                                • Type: Boolean
                                                                • +
                                                                • Range / Valid values: on, off
                                                                • +
                                                                • Default: off
                                                                • +
                                                                +

                                                                +Enable auto tracking +Requires a tracking camera type supported by Motion. +

                                                                + +

                                                                track_port

                                                                +

                                                                +
                                                                  +
                                                                • Type: String
                                                                • +
                                                                • Range / Valid values: Max 4095 characters
                                                                • +
                                                                • Default:
                                                                • +
                                                                +

                                                                +This is the device name of the serial port to which the stepper motor interface is connected. +Only used for stepper motor tracking. +

                                                                + +

                                                                track_motorx

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +The motor number that is used for controlling the x-axis. +Only used for stepper motor tracking. +

                                                                + +

                                                                track_motorx_reverse

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Description +

                                                                + +

                                                                track_motory

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +The motor number that is used for controlling the y-axis. +Only used for stepper motor tracking. +

                                                                + +

                                                                track_motory_reverse

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                + +

                                                                + +

                                                                track_maxx

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +The maximum position for servo x. +Only used for stepper motor tracking. +

                                                                + +

                                                                track_minx

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                + +

                                                                + +

                                                                track_maxy

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +The maximum position for servo y. +Only used for stepper motor tracking. +

                                                                + +

                                                                track_miny

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                + +

                                                                + +

                                                                track_homex

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                + +

                                                                + +

                                                                track_homey

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                + +

                                                                + +

                                                                track_iomojo_id

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Use this option if you have an iomojo smilecam connected to the serial port instead +of a general stepper motor controller. +Only used for iomojo camera. +

                                                                + +

                                                                track_step_angle_x

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. +Requires a tracking camera type pwc. + +

                                                                + +

                                                                track_step_angle_y

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. +Requires a tracking camera type pwc. +

                                                                +

                                                                + +

                                                                track_move_wait

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Delay during which tracking is disabled after auto tracking has moved the camera. +Delay is defined as number of picture frames. +The actual delay is depending on the chosen framerate. +If you want the camera to move maximum once every 2 seconds and the framerate is 10 then you +need to set the track_move_wait value to 2 * 10 = 20. +

                                                                + +

                                                                track_speed

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Speed to set the motor to. +Only used for stepper motor tracking. + +

                                                                + +

                                                                track_stepsize

                                                                +

                                                                +
                                                                  +
                                                                • Type: Integer
                                                                • +
                                                                • Range / Valid values: 0 - 2147483647
                                                                • +
                                                                • Default: 0
                                                                • +
                                                                +

                                                                +Number of steps to make. +Only used for stepper motor tracking. +

                                                                +
                                                              + +
                                                            \ No newline at end of file From bc7298aa327096429a52fcec8062ba8e01318bf4 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sun, 13 Sep 2015 13:52:40 -0600 Subject: [PATCH 147/233] Revise Sqlite3 into code standard --- CHANGELOG | 1 + INSTALL | 3 +++ conf.c | 26 ++++---------------------- conf.h | 3 +-- event.c | 8 +++++--- motion-dist.conf.in | 12 +++--------- motion.1 | 19 +++---------------- motion.c | 35 ++++++++++++++++++----------------- motion_guide.html | 25 ++++++------------------- 9 files changed, 44 insertions(+), 88 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0a99226..2194291 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Consolidate the Sqlite3 options into the code standard. * Draft revised motion_guide.html with new options. * Revise manual to have current options. * Tab/Space cleanup and validation security issue addressed. (closes 071831) diff --git a/INSTALL b/INSTALL index 3f79cae..429993e 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,8 @@ The following is a brief overview of the building and installing instructions. +For full instructions on how to build and install Motion, see the +motion_guide.html that is distributed with this source code. + The building instructions vary based upon the base system and the desired options. For most installs, it will be desired to include either ffmpeg or libav and these will have associated dependencies which dictate the configuration options. diff --git a/conf.c b/conf.c index 9b157fa..25e3d00 100644 --- a/conf.c +++ b/conf.c @@ -133,10 +133,7 @@ struct config conf_template = { database_user: NULL, database_password: NULL, database_port: 0, -#ifdef HAVE_SQLITE3 - sqlite3_db: NULL, - sqlite3_busy_timeout: 0, -#endif + database_busy_timeout: 0, #endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || define(HAVE_SQLITE3) */ on_picture_save: NULL, on_motion_detected: NULL, @@ -1529,29 +1526,14 @@ config_param config_params[] = { copy_int, print_int }, -#ifdef HAVE_SQLITE3 - { - "sqlite3_db", - "\n############################################################\n" - "# Database Options For SQLite3\n" - "############################################################\n\n" - "# SQLite3 database to log to (default: not defined)", - 0, - CONF_OFFSET(sqlite3_db), - copy_string, - print_string - }, { - "sqlite3_busy_timeout", - "# SQLite3 wait for unlock time (default: 0)", + "database_busy_timeout", + "# Database wait for unlock time (default: 0)", 0, - CONF_OFFSET(sqlite3_busy_timeout), + CONF_OFFSET(database_busy_timeout), copy_int, print_int }, - -#endif /* HAVE_SQLITE3 */ - #endif /* defined(HAVE_MYSQL) || defined(HAVE_PGSQL) || defined(HAVE_SQLITE3) */ { "video_pipe", diff --git a/conf.h b/conf.h index c4c8723..93ae036 100644 --- a/conf.h +++ b/conf.h @@ -112,8 +112,7 @@ struct config { const char *database_host; const char *database_user; const char *database_password; - const char *sqlite3_db; - int sqlite3_busy_timeout; + int database_busy_timeout; int database_port; char *on_picture_save; char *on_area_detected; diff --git a/event.c b/event.c index 8bdd9c5..8ddf709 100644 --- a/event.c +++ b/event.c @@ -241,7 +241,7 @@ static void event_sqlnewfile(struct context *cnt, #endif /* HAVE_PGSQL */ #ifdef HAVE_SQLITE3 - if ((!strcmp(cnt->conf.database_type, "sqlite3")) && (cnt->conf.sqlite3_db)) { + if ((!strcmp(cnt->conf.database_type, "sqlite3")) && (cnt->conf.database_dbname)) { int res; char *errmsg = 0; res = sqlite3_exec(cnt->database_sqlite3, sqlquery, NULL, 0, &errmsg); @@ -703,6 +703,8 @@ static void event_ffmpeg_timelapse(struct context *cnt, if (!cnt->ffmpeg_timelapse) { char tmp[PATH_MAX]; const char *timepath; + char codec_swf[3] = "swf"; + char codec_mpeg[5] = "mpeg4"; /* * conf.timepath would normally be defined but if someone deleted it by control interface @@ -735,14 +737,14 @@ static void event_ffmpeg_timelapse(struct context *cnt, MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using swf codec."); MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be appended to file"); cnt->ffmpeg_timelapse = - ffmpeg_open("swf",cnt->timelapsefilename, y, u, v + ffmpeg_open(codec_swf,cnt->timelapsefilename, y, u, v ,cnt->imgs.width, cnt->imgs.height, 24 ,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_APPEND); } else { MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using mpeg4 codec."); MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be trigger new files"); cnt->ffmpeg_timelapse = - ffmpeg_open("mpeg4",cnt->timelapsefilename, y, u, v + ffmpeg_open(codec_mpeg ,cnt->timelapsefilename, y, u, v ,cnt->imgs.width, cnt->imgs.height, 1 ,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_NEW); } diff --git a/motion-dist.conf.in b/motion-dist.conf.in index f7cbe88..a0f9db0 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -699,6 +699,7 @@ quiet on ; database_type value # database to log to (default: not defined) +# for sqlite3, the full path and name for the database. ; database_dbname value # The host on which the database is located (default: localhost) @@ -714,16 +715,9 @@ quiet on # mysql 3306 , postgresql 5432 (default: not defined) ; database_port value -############################################################ -# Database Options For SQLite3 -############################################################ - -# SQLite3 database (file path) (default: not defined) -; sqlite3_db value - -# SQLite3 wait time in milliseconds for locked database to +# Database wait time in milliseconds for locked database to # be unlocked before returning database locked error (default 0) -; sqlite3_busy_timeout 0 +; database_busy_timeout 0 diff --git a/motion.1 b/motion.1 index 1fb9587..ace5e78 100644 --- a/motion.1 +++ b/motion.1 @@ -1675,7 +1675,7 @@ Default: Not defined Description: .fi .RS -The name of the database being used (dbname) +The name of the database being used (dbname). For Sqlite3, the full path to the database. .RE .RE @@ -1733,20 +1733,7 @@ Default ports: mysql 3306 , postgresql 5432 .RE .TP -.B sqlite3_db -.RS -.nf -Values: User defined string -Default: Not Defined -Description: -.fi -.RS -The full path to the sqlite3 database. -.RE -.RE - -.TP -.B sqlite3_busy_timeout +.B database_busy_timeout .RS .nf Values: 0 to unlimited @@ -1754,7 +1741,7 @@ Default: 0 Description: .fi .RS -SQLite3 wait time in milliseconds for locked database to be unlocked before returning database locked error +Database wait time in milliseconds for locked database to be unlocked before returning database locked error .RE .RE diff --git a/motion.c b/motion.c index 9a51c89..90998e1 100644 --- a/motion.c +++ b/motion.c @@ -826,19 +826,19 @@ static int motion_init(struct context *cnt) * sqlite3 and will need a seperate connection for each thread */ if (cnt->database_sqlite3) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 using shared handle"); - } else if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.sqlite3_db) { + } else if ((!strcmp(cnt->conf.database_type, "sqlite3")) && cnt->conf.database_dbname) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 Database filename %s", - cnt->conf.sqlite3_db); - if (sqlite3_open(cnt->conf.sqlite3_db, &cnt->database_sqlite3) != SQLITE_OK) { + cnt->conf.database_dbname); + if (sqlite3_open(cnt->conf.database_dbname, &cnt->database_sqlite3) != SQLITE_OK) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s", - cnt->conf.sqlite3_db, sqlite3_errmsg(cnt->database_sqlite3)); + cnt->conf.database_dbname, sqlite3_errmsg(cnt->database_sqlite3)); sqlite3_close(cnt->database_sqlite3); exit(1); } - MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %d msec", - cnt->conf.sqlite3_busy_timeout); - if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.sqlite3_busy_timeout) != SQLITE_OK) - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s", + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: database_busy_timeout %d msec", + cnt->conf.database_busy_timeout); + if (sqlite3_busy_timeout(cnt->database_sqlite3, cnt->conf.database_busy_timeout) != SQLITE_OK) + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: database_busy_timeout failed %s", sqlite3_errmsg(cnt->database_sqlite3)); } #endif /* HAVE_SQLITE3 */ @@ -1061,8 +1061,9 @@ static void motion_cleanup(struct context *cnt) #ifdef HAVE_SQLITE3 /* Close the SQLite database */ - if (cnt->conf.sqlite3_db) + if ((!strcmp(cnt->conf.database_type, "sqlite3")) && (cnt->conf.database_dbname)) { sqlite3_close(cnt->database_sqlite3); + } #endif /* HAVE_SQLITE3 */ } } @@ -2677,25 +2678,25 @@ int main (int argc, char **argv) /* database_sqlite3 == NULL if not changed causes each thread to creat their own * sqlite3 connection this will only happens when using a non-threaded sqlite version */ cnt_list[0]->database_sqlite3=NULL; - if (cnt_list[0]->conf.database_type && ((!strcmp(cnt_list[0]->conf.database_type, "sqlite3")) && cnt_list[0]->conf.sqlite3_db)) { + if (cnt_list[0]->conf.database_type && ((!strcmp(cnt_list[0]->conf.database_type, "sqlite3")) && cnt_list[0]->conf.database_dbname)) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 Database filename %s", - cnt_list[0]->conf.sqlite3_db); + cnt_list[0]->conf.database_dbname); int thread_safe = sqlite3_threadsafe(); if (thread_safe > 0) { MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 is threadsafe"); MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: SQLite3 serialized %s", (sqlite3_config(SQLITE_CONFIG_SERIALIZED)?"FAILED":"SUCCESS")); - if (sqlite3_open( cnt_list[0]->conf.sqlite3_db, &cnt_list[0]->database_sqlite3) != SQLITE_OK) { + if (sqlite3_open( cnt_list[0]->conf.database_dbname, &cnt_list[0]->database_sqlite3) != SQLITE_OK) { MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: Can't open database %s : %s", - cnt_list[0]->conf.sqlite3_db, sqlite3_errmsg( cnt_list[0]->database_sqlite3)); + cnt_list[0]->conf.database_dbname, sqlite3_errmsg( cnt_list[0]->database_sqlite3)); sqlite3_close( cnt_list[0]->database_sqlite3); exit(1); } - MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout %d msec", - cnt_list[0]->conf.sqlite3_busy_timeout); - if (sqlite3_busy_timeout( cnt_list[0]->database_sqlite3, cnt_list[0]->conf.sqlite3_busy_timeout) != SQLITE_OK) - MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: sqlite3_busy_timeout failed %s", + MOTION_LOG(NTC, TYPE_DB, NO_ERRNO, "%s: database_busy_timeout %d msec", + cnt_list[0]->conf.database_busy_timeout); + if (sqlite3_busy_timeout( cnt_list[0]->database_sqlite3, cnt_list[0]->conf.database_busy_timeout) != SQLITE_OK) + MOTION_LOG(ERR, TYPE_DB, NO_ERRNO, "%s: database_busy_timeout failed %s", sqlite3_errmsg( cnt_list[0]->database_sqlite3)); } diff --git a/motion_guide.html b/motion_guide.html index 7bc95a4..15f9b50 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -1413,10 +1413,7 @@

                                                            Configuration Options

                                                            database_user database_password database_port sqlite3_db
                                                            sqlite3_busy_timeout database_busy_timeout
                                                            @@ -3977,7 +3974,7 @@

                                                            database_dbname

                                                          • Default: Not Defined

                                                          -The name of the database. +The name of the database. For Sqlite3, the full path and name to the database.

                                                          database_host

                                                          @@ -4024,23 +4021,13 @@

                                                          database_port

                                                          The port number that is used for the database. Typical values are: mysql=3306 and postgresql=5432

                                                          -

                                                          sqlite3_db

                                                          -

                                                          -
                                                            -
                                                          • Type: String
                                                          • -
                                                          • Range / Valid values: Max 4095 characters
                                                          • -
                                                          • Default:
                                                          • -
                                                          -

                                                          -The name of the SQLite3 database. -

                                                          -

                                                          sqlite3_busy_timeout

                                                          +

                                                          database_busy_timeout

                                                            -
                                                          • Type: String
                                                          • -
                                                          • Range / Valid values: Max 4095 characters
                                                          • -
                                                          • Default:
                                                          • +
                                                          • Type: Integer
                                                          • +
                                                          • Range / Valid values:
                                                          • +
                                                          • Default: 0

                                                          If the database is busy when the request is issued, this parameter indicates the time to From 01769dbcad6afa14631d74f35279cad97431a7b5 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 14 Sep 2015 13:26:45 -0600 Subject: [PATCH 148/233] Update to motion guide --- motion_guide.html | 48 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/motion_guide.html b/motion_guide.html index 15f9b50..75b23f1 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -1371,12 +1371,14 @@

                                                          Configuration Options

                                                          stream_auth_method - stream_authentication + stream_authentication + stream_preview_scale + stream_preview_newline webcontrol_port - webcontrol_localhost - webcontrol_html_output + webcontrol_localhost + webcontrol_html_output webcontrol_authentication @@ -3807,6 +3809,46 @@

                                                          stream_authentication

                                                          The syntax is username:password

                                                          +

                                                          stream_preview_scale

                                                          +

                                                          +
                                                            +
                                                          • Type: Integer
                                                          • +
                                                          • Range / Valid values:
                                                          • +
                                                          • Default: 25
                                                          • +
                                                          +

                                                          +If the webcontrol page has HTML enabled, Motion displays all of the streams on the home webcontrol page in HTML +format so that all the images can be viewed by standard browsers. +

                                                          +This parameter indicates the percentage to scale the stream image when it is placed on the page. +Numbers greater than 100 are permitted. +

                                                          +

                                                          + +

                                                          stream_preview_newline

                                                          +

                                                          +
                                                            +
                                                          • Type: string
                                                          • +
                                                          • Range / Valid values:on / off
                                                          • +
                                                          • Default: on
                                                          • +
                                                          +

                                                          +If the webcontrol page has HTML enabled, Motion displays all of the streams on the home webcontrol page +in HTML format so that all the images can be viewed by standard browsers. +

                                                          +This parameter determines whether the image is placed on a new line in the webcontrol web page. +

                                                          +Preview images are placed on to the webcontrol home page in thread number order. This +This parameter allows the user some flexibility in organizing the images on the page. +

                                                          +Setting this parameter to off will set the image to the right of any image from a lower numbered thread. +Setting it to 'on' will place the image on the start of the next line(below). +

                                                          +Full customization of the webcontrol page is NOT planned in the Motion development. Users that require +a more polished and customized preview page are encouraged to create their own local HTML page that references +the streams. +

                                                          +

                                                          webcontrol_port

                                                            From 74fbda2bf06e6a4f043fd790b6f25d9729043a5e Mon Sep 17 00:00:00 2001 From: Rex Feany Date: Fri, 18 Sep 2015 00:12:16 -0700 Subject: [PATCH 149/233] compile against ffmpeg from github@58fe57d5a05ad8d15c320b2bd163debbc412bdd3 fix minor compilation issues use pkg-config --- .gitignore | 1 + Makefile.in | 4 +- aclocal.m4 | 229 +++++++++++++++++++++++++ config.h.in | 6 + configure | 459 +++++++++++++++++++++++++------------------------- configure.ac | 228 +++---------------------- ffmpeg.c | 3 +- ffmpeg.h | 2 + netcam_rtsp.c | 12 +- 9 files changed, 501 insertions(+), 443 deletions(-) create mode 100644 aclocal.m4 diff --git a/.gitignore b/.gitignore index b730f6e..157a954 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.log .svn/ *.o +autom4te.cache .depend motion config.h diff --git a/Makefile.in b/Makefile.in index 32e81f2..6dcc000 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,9 +31,9 @@ examplesdir = $(datadir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/examples # These variables contain compiler flags, object files to build and files to # # install. # ################################################################################ -CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" +CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ @FFMPEG_LIBS@ VIDEO_OBJ = @VIDEO@ OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..7d25fb9 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,229 @@ +# generated automatically by aclocal 1.14.1 -*- Autoconf -*- + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])# PKG_CHECK_MODULES + + +# PKG_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable pkgconfigdir as the location where a module +# should install pkg-config .pc files. By default the directory is +# $libdir/pkgconfig, but the default can be changed by passing +# DIRECTORY. The user can override through the --with-pkgconfigdir +# parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_INSTALLDIR + + +# PKG_NOARCH_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable noarch_pkgconfigdir as the location where a +# module should install arch-independent pkg-config .pc files. By +# default the directory is $datadir/pkgconfig, but the default can be +# changed by passing DIRECTORY. The user can override through the +# --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_NOARCH_INSTALLDIR + + +# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# ------------------------------------------- +# Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])# PKG_CHECK_VAR + diff --git a/config.h.in b/config.h.in index ac42b9c..99cdfd0 100644 --- a/config.h.in +++ b/config.h.in @@ -3,6 +3,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if FFMPEG is around */ +#undef HAVE_FFMPEG + /* Define to 1 if you have the `get_current_dir_name' function. */ #undef HAVE_GET_CURRENT_DIR_NAME @@ -63,6 +66,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_VIDEOIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H diff --git a/configure b/configure index b4c4200..abe833c 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.69 for motion Unofficial-Git-d71cebf. +# Generated by GNU Autoconf 2.69 for motion Unofficial-Git-a044b60. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='Unofficial-Git-d71cebf' -PACKAGE_STRING='motion Unofficial-Git-d71cebf' +PACKAGE_VERSION='Unofficial-Git-a044b60' +PACKAGE_STRING='motion Unofficial-Git-a044b60' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -624,6 +624,11 @@ LIBOBJS BIN_PATH RTPS_OBJ FFMPEG_OBJ +FFMPEG_LIBS +FFMPEG_CFLAGS +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG SDL_OBJ VIDEO EGREP @@ -685,8 +690,6 @@ with_sdl with_jpeg_turbo with_jpeg_mmx with_ffmpeg -with_ffmpeg_headers -with_ffmpeg_libs with_sqlite3 with_mysql with_mysql_lib @@ -705,7 +708,12 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CPP +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +FFMPEG_CFLAGS +FFMPEG_LIBS' # Initialize some variables set by options. @@ -1246,7 +1254,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 Unofficial-Git-d71cebf to adapt to many kinds of systems. +\`configure' configures motion Unofficial-Git-a044b60 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1307,7 +1315,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion Unofficial-Git-d71cebf:";; + short | recursive ) echo "Configuration of motion Unofficial-Git-a044b60:";; esac cat <<\_ACEOF @@ -1337,16 +1345,7 @@ Optional Packages: If this is not specified motion will try to find the library /usr/lib/libjpeg-mmx.a /usr/local/lib/libjpeg-mmx.a. - --with-ffmpeg=DIR Specify the prefix for the install path for - libavcodec/libavformat (part of ffmpeg) be able to - encode mpeg movies realtime. - If this is not specified motion will try to find - the libraries in /usr and /usr/local. - - --with-ffmpeg-headers=DIR Specify the prefix for ffmpeg headers. - - --with-ffmpeg-libs=libs Specify the extra libs for ffmpeg - + --with-ffmpeg=DIR Build with FFMPEG support --without-sqlite3 Disable sqlite3 support in motion. --without-mysql Disable mysql support in motion. @@ -1390,6 +1389,14 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor + PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path + FFMPEG_CFLAGS + C compiler flags for FFMPEG, overriding pkg-config + FFMPEG_LIBS linker flags for FFMPEG, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1457,7 +1464,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure Unofficial-Git-d71cebf +motion configure Unofficial-Git-a044b60 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2059,7 +2066,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 Unofficial-Git-d71cebf, which was +It was created by motion $as_me Unofficial-Git-a044b60, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -5278,249 +5285,247 @@ fi # # Check for libavcodec and libavformat from ffmpeg # - -FFMPEG_DIR="yes" -FFMPEG_OK="no_found" FFMPEG_OBJ="" # Check whether --with-ffmpeg was given. if test "${with_ffmpeg+set}" = set; then : - withval=$with_ffmpeg; FFMPEG_DIR="$withval" - + withval=$with_ffmpeg; with_ffmpeg=$withval +else + with_ffmpeg=no fi -# -# ffmpeg headers custom location -# -FFMPEG_HEADERS_DIR="yes" -# Check whether --with-ffmpeg_headers was given. -if test "${with_ffmpeg_headers+set}" = set; then : - withval=$with_ffmpeg_headers; FFMPEG_HEADERS_DIR="$withval" -fi -# -# ffmpeg custom extra libraries -# -FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " -# Check whether --with-ffmpeg-libs was given. -if test "${with_ffmpeg_libs+set}" = set; then : - withval=$with_ffmpeg_libs; FFMPEG_EXTRALIBS="$withval" + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -# -# --without-ffmpeg or with-ffmpeg=no -# -if test "${FFMPEG_DIR}" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg" >&5 -$as_echo_n "checking for ffmpeg... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: skipping" >&5 -$as_echo "skipping" >&6; } -# -# with-ffmpeg= or nothing -# -else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting libraries" >&5 -$as_echo_n "checking for ffmpeg autodetecting libraries... " >&6; } - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib64" >&5 -$as_echo "found in /usr/lib64" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib" >&5 -$as_echo "found in /usr/lib" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib" - FFMPEG_DIR="/usr" - elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/local/lib" >&5 -$as_echo "found in /usr/local/lib" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" - elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/x86_64-linux-gnu" >&5 -$as_echo "found in /usr/lib/x86_64-linux-gnu" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib/i386-linux-gnu" >&5 -$as_echo "found in /usr/lib/i386-linux-gnu" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/i386-linux-gnu" - FFMPEG_DIR="/usr" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-" >&5 -$as_echo_n "checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-... " >&6; } - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - FFMPEG_OK="found" - FFMPEG_LIB="${FFMPEG_DIR}/lib" - elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 -$as_echo "found" >&6; } - FFMPEG_LIB="${FFMPEG_DIR}" - FFMPEG_OK="found" + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - if test "${FFMPEG_OK}" != "found"; then - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" fi fi +if test "x$with_ffmpeg" != "xno"; then : + if test "x$with_ffmpeg" != "xyes"; then : -# -# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found -# + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${with_ffmpeg}/lib/pkgconfig + export PKG_CONFIG_PATH -AVFORMAT_DIR="" +fi -if test "${FFMPEG_OK}" = "found"; then - if test "${FFMPEG_HEADERS_DIR}" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_DIR}" >&5 -$as_echo_n "checking for ffmpeg headers in ${FFMPEG_DIR}... " >&6; } - AVFORMAT_DIR="${FFMPEG_DIR}" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}" >&5 -$as_echo_n "checking for ffmpeg headers in ${FFMPEG_HEADERS_DIR}... " >&6; } - FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}" - fi +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FFMPEG" >&5 +$as_echo_n "checking for FFMPEG... " >&6; } - if test -f ${FFMPEG_DIR}/include/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" - AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" - elif test -f ${FFMPEG_DIR}/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" - elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/libavformat/avformat.h" >&5 -$as_echo "found ${FFMPEG_DIR}/libavformat/avformat.h" >&6; } - FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I{FFMPEG_DIR}/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - FFMPEG_OK="no_found" - AVFORMAT_DIR="avformat.h" - echo "**********************************************" - echo "* avformat.h not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi +if test -n "$FFMPEG_CFLAGS"; then + pkg_cv_FFMPEG_CFLAGS="$FFMPEG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavutil libavformat libavcodec libswscale\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libavutil libavformat libavcodec libswscale") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_FFMPEG_CFLAGS=`$PKG_CONFIG --cflags "libavutil libavformat libavcodec libswscale" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$FFMPEG_LIBS"; then + pkg_cv_FFMPEG_LIBS="$FFMPEG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavutil libavformat libavcodec libswscale\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libavutil libavformat libavcodec libswscale") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_FFMPEG_LIBS=`$PKG_CONFIG --libs "libavutil libavformat libavcodec libswscale" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi -# -# If ffmpeg libs and headers have been found -# - if test "${FFMPEG_OK}" = "found"; then - TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" - TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" - FFMPEG_OBJ="ffmpeg.o" +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + FFMPEG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libavutil libavformat libavcodec libswscale" 2>&1` + else + FFMPEG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libavutil libavformat libavcodec libswscale" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$FFMPEG_PKG_ERRORS" >&5 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking file_protocol is defined in ffmpeg ?" >&5 -$as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; } - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS + as_fn_error $? "Package requirements (libavutil libavformat libavcodec libswscale) were not met: - CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" +$FFMPEG_PKG_ERRORS - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. +Alternatively, you may set the environment variables FFMPEG_CFLAGS +and FFMPEG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. - #include <${AVFORMAT_DIR}> - URLProtocol test_file_protocol; - int main(void){ - test_file_protocol.url_read = file_protocol.url_read; - return 0; - } +Alternatively, you may set the environment variables FFMPEG_CFLAGS +and FFMPEG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } else + FFMPEG_CFLAGS=$pkg_cv_FFMPEG_CFLAGS + FFMPEG_LIBS=$pkg_cv_FFMPEG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_FFMPEG=yes +fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" +fi + +if test "${HAVE_FFMPEG}" = "yes" ; then : + + FFMPEG_OBJ="ffmpeg.o" + +$as_echo "#define HAVE_FFMPEG 1" >>confdefs.h fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi -fi -fi + # Revised RTSP module so that it can be included # whether or not FFMPEG is found. @@ -7319,7 +7324,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 Unofficial-Git-d71cebf, which was +This file was extended by motion $as_me Unofficial-Git-a044b60, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7381,7 +7386,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 Unofficial-Git-d71cebf +motion config.status Unofficial-Git-a044b60 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -8167,8 +8172,10 @@ else echo "SDL support: No" fi -if test "${FFMPEG_OK}" = "found"; then +if test "${HAVE_FFMPEG}" = "yes"; then echo "FFmpeg support: Yes" + echo " ... FFMPEG_CFLAGS: $FFMPEG_CFLAGS" + echo " ... FFMPEG_LIBS: $FFMPEG_LIBS" else echo "FFmpeg support: No" fi diff --git a/configure.ac b/configure.ac index a426ec4..2076f7a 100755 --- a/configure.ac +++ b/configure.ac @@ -376,215 +376,25 @@ fi # # Check for libavcodec and libavformat from ffmpeg # - -FFMPEG_DIR="yes" -FFMPEG_OK="no_found" FFMPEG_OBJ="" -AC_ARG_WITH(ffmpeg, -[ --with-ffmpeg[=DIR] Specify the prefix for the install path for - libavcodec/libavformat (part of ffmpeg) be able to - encode mpeg movies realtime. - If this is not specified motion will try to find - the libraries in /usr and /usr/local. - ], -FFMPEG_DIR="$withval" -) - -# -# ffmpeg headers custom location -# -FFMPEG_HEADERS_DIR="yes" -AC_ARG_WITH(ffmpeg_headers, -[ --with-ffmpeg-headers[=DIR] Specify the prefix for ffmpeg headers. - ], -FFMPEG_HEADERS_DIR="$withval" -) - -# -# ffmpeg custom extra libraries -# -FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " -AC_ARG_WITH(ffmpeg-libs, -[ --with-ffmpeg-libs[=libs] Specify the extra libs for ffmpeg - ], -FFMPEG_EXTRALIBS="$withval" -) - -# -# --without-ffmpeg or with-ffmpeg=no -# -if test "${FFMPEG_DIR}" = "no"; then - AC_MSG_CHECKING(for ffmpeg) - AC_MSG_RESULT(skipping) -# -# with-ffmpeg= or nothing -# -else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB - AC_MSG_CHECKING(for ffmpeg autodetecting libraries) - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib64) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib" - FFMPEG_DIR="/usr" - elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/local/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" - elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib/x86_64-linux-gnu) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/i386-linux-gnu" - FFMPEG_DIR="/usr" - else - AC_MSG_RESULT(not found) - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi -else - AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_OK="found" - FFMPEG_LIB="${FFMPEG_DIR}/lib" - elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_LIB="${FFMPEG_DIR}" - FFMPEG_OK="found" - else - AC_MSG_RESULT(not found) - if test "${FFMPEG_OK}" != "found"; then - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - fi -fi - - -# -# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found -# - -AVFORMAT_DIR="" - -if test "${FFMPEG_OK}" = "found"; then - if test "${FFMPEG_HEADERS_DIR}" = "yes"; then - AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_DIR}) - AVFORMAT_DIR="${FFMPEG_DIR}" - else - AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_HEADERS_DIR}) - FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}" - fi - - if test -f ${FFMPEG_DIR}/include/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" - AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" - elif test -f ${FFMPEG_DIR}/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" - elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I{FFMPEG_DIR}/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" - else - AC_MSG_RESULT(not found) - FFMPEG_OK="no_found" - AVFORMAT_DIR="avformat.h" - echo "**********************************************" - echo "* avformat.h not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - -# -# If ffmpeg libs and headers have been found -# +AC_ARG_WITH([ffmpeg], + AS_HELP_STRING([--with-ffmpeg[=DIR]], [Build with FFMPEG support]), + [with_ffmpeg=$withval], + [with_ffmpeg=no]) + +AS_IF([test "x$with_ffmpeg" != "xno"], [ + AS_IF([test "x$with_ffmpeg" != "xyes"], [ + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${with_ffmpeg}/lib/pkgconfig + export PKG_CONFIG_PATH + ]) + PKG_CHECK_MODULES([FFMPEG], libavutil libavformat libavcodec libswscale, HAVE_FFMPEG=yes) +]) - if test "${FFMPEG_OK}" = "found"; then - TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" - TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" - - FFMPEG_OBJ="ffmpeg.o" - AC_SUBST(FFMPEG_OBJ) - - AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - - CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" - - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - [ - #include <${AVFORMAT_DIR}> - URLProtocol test_file_protocol; - int main(void){ - test_file_protocol.url_read = file_protocol.url_read; - return 0; - } - ]])], - [AC_MSG_RESULT(yes)], - [ - AC_MSG_RESULT(no) - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" - ] - ) - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi -fi -fi +AS_IF([test "${HAVE_FFMPEG}" = "yes" ], [ + FFMPEG_OBJ="ffmpeg.o" + AC_DEFINE([HAVE_FFMPEG], 1, [Define to 1 if FFMPEG is around]) +]) +AC_SUBST(FFMPEG_OBJ) # Revised RTSP module so that it can be included # whether or not FFMPEG is found. @@ -1357,8 +1167,10 @@ else echo "SDL support: No" fi -if test "${FFMPEG_OK}" = "found"; then +if test "${HAVE_FFMPEG}" = "yes"; then echo "FFmpeg support: Yes" + echo " ... FFMPEG_CFLAGS: $FFMPEG_CFLAGS" + echo " ... FFMPEG_LIBS: $FFMPEG_LIBS" else echo "FFmpeg support: No" fi diff --git a/ffmpeg.c b/ffmpeg.c index 2c2505c..34ba74a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -12,6 +12,7 @@ * 53 are supported. */ +#include "config.h" #ifdef HAVE_FFMPEG @@ -273,7 +274,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->time_base.num = 1; c->time_base.den = rate; c->gop_size = 12; - c->pix_fmt = PIX_FMT_YUV420P; + c->pix_fmt = AV_PIX_FMT_YUV420P; c->max_b_frames = 0; if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; diff --git a/ffmpeg.h b/ffmpeg.h index 46737d4..3557ca2 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -4,6 +4,8 @@ #include #include +#include "config.h" + #ifdef HAVE_FFMPEG #include diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 0bcaca0..7fc5770 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -36,8 +36,8 @@ int netcam_check_pixfmt(netcam_context_ptr netcam){ retcd = -1; - if ((netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUV420P) || - (netcam->rtsp->codec_context->pix_fmt == PIX_FMT_YUVJ420P)) retcd = 0; + if ((netcam->rtsp->codec_context->pix_fmt == AV_PIX_FMT_YUV420P) || + (netcam->rtsp->codec_context->pix_fmt == AV_PIX_FMT_YUVJ420P)) retcd = 0; return retcd; @@ -565,7 +565,7 @@ int netcam_rtsp_open_sws(netcam_context_ptr netcam){ ,netcam->rtsp->codec_context->pix_fmt ,netcam->width ,netcam->height - ,PIX_FMT_YUV420P + ,AV_PIX_FMT_YUV420P ,SWS_BICUBIC,NULL,NULL,NULL); if (netcam->rtsp->swsctx == NULL) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ @@ -576,7 +576,7 @@ int netcam_rtsp_open_sws(netcam_context_ptr netcam){ } netcam->rtsp->swsframe_size = avpicture_get_size( - PIX_FMT_YUV420P + AV_PIX_FMT_YUV420P ,netcam->width ,netcam->height); if (netcam->rtsp->swsframe_size <= 0) { @@ -632,7 +632,7 @@ int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ retcd = avpicture_fill( (AVPicture*)netcam->rtsp->swsframe_out ,buffer_out - ,PIX_FMT_YUV420P + ,AV_PIX_FMT_YUV420P ,netcam->width ,netcam->height); if (retcd < 0) { @@ -663,7 +663,7 @@ int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ retcd = avpicture_layout( (const AVPicture*)netcam->rtsp->swsframe_out - ,PIX_FMT_YUV420P + ,AV_PIX_FMT_YUV420P ,netcam->width ,netcam->height ,(unsigned char *)image From 0c77371ad302aa51ca664fbb03f8472fdccf348a Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 14 Sep 2015 20:43:39 -0600 Subject: [PATCH 150/233] Patch for bad image handling --- CHANGELOG | 1 + netcam_jpeg.c | 15 +++------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2194291..948aa88 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Add patch from JonGuess(issue 151452) for treatment of partial netcam images. * Consolidate the Sqlite3 options into the code standard. * Draft revised motion_guide.html with new options. * Revise manual to have current options. diff --git a/netcam_jpeg.c b/netcam_jpeg.c index f5c0614..1b5c65b 100644 --- a/netcam_jpeg.c +++ b/netcam_jpeg.c @@ -67,24 +67,15 @@ static boolean netcam_fill_input_buffer(j_decompress_ptr cinfo) * path when a new image is to be processed. It is assumed that * this routine will only be called once for the entire image. * If an unexpected call (with start_of_file FALSE) occurs, the - * routine will insert a "fake" "end of image" marker and return - * to the library to process whatever data remains from the original - * image (the one with errors). - * - * I'm not yet clear on what the result (from the application's - * point of view) will be from this logic. If the application - * expects that a completely new image will be started, this will - * give trouble. + * routine calls ERREXIT(). */ if (src->start_of_file) { nbytes = src->length; src->buffer = (JOCTET *) src->data; } else { - /* Insert a fake EOI marker - as per jpeglib recommendation */ - MOTION_LOG(INF, TYPE_NETCAM, NO_ERRNO, "%s: **fake EOI inserted**"); - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; /* 0xD9 */ nbytes = 2; + MOTION_LOG(DBG, TYPE_NETCAM, NO_ERRNO, "%s: Not enough data from netcam."); + ERREXIT(cinfo, JERR_INPUT_EOF); } src->pub.next_input_byte = src->buffer; From b8f657dec5dc99df6652ccc36e95b976a72e802d Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 14 Sep 2015 21:08:15 -0600 Subject: [PATCH 151/233] Patch netcam url with proxy --- CHANGELOG | 1 + netcam.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 948aa88..cc95cf8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Add patch for ports on proxy netcams from GVautier (issue 144906) * Add patch from JonGuess(issue 151452) for treatment of partial netcam images. * Consolidate the Sqlite3 options into the code standard. * Draft revised motion_guide.html with new options. diff --git a/netcam.c b/netcam.c index 77cce1a..1be0d05 100644 --- a/netcam.c +++ b/netcam.c @@ -2186,10 +2186,14 @@ static int netcam_http_build_url(netcam_context_ptr netcam, struct url_t *url) * Allocate space for a working string to contain the path. * The extra 4 is for "://" and string terminator. */ - ptr = mymalloc(strlen(url->service) + strlen(url->host) - + strlen(url->path) + 4); - sprintf((char *)ptr, "http://%s%s", url->host, url->path); - + if (url->port != 0) { + ptr = mymalloc(strlen(url->service) + strlen(url->host) + 7 + strlen(url->path) + 4); + sprintf((char *)ptr, "http://%s:%d%s", url->host, url->port , url->path); + }else { + ptr = mymalloc(strlen(url->service) + strlen(url->host) + strlen(url->path) + 4); + sprintf((char *)ptr, "http://%s%s", url->host, url->path); + } + netcam->connect_keepalive = FALSE; /* Disable Keepalive if proxy */ free((void *)netcam->cnt->conf.netcam_keepalive); netcam->cnt->conf.netcam_keepalive = strdup("off"); From 21994e4b4054e65afb48beac46013a3be786bc83 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 21 Sep 2015 10:30:40 -0600 Subject: [PATCH 152/233] PIX change for older ffmpeg --- ffmpeg.c | 2 +- ffmpeg.h | 13 +++++++++++++ netcam_rtsp.c | 12 ++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index fb4d88d..f123640 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -283,7 +283,7 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->time_base.num = 1; c->time_base.den = rate; c->gop_size = 12; - c->pix_fmt = AV_PIX_FMT_YUV420P; + c->pix_fmt = MY_PIX_FMT_YUV420P; c->max_b_frames = 0; if (c->codec_id == MY_CODEC_ID_H264){ diff --git a/ffmpeg.h b/ffmpeg.h index 1d0a6b7..3cbea4d 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -12,6 +12,19 @@ #include #include +#if (LIBAVFORMAT_VERSION_MAJOR >= 56) + +#define MY_PIX_FMT_YUV420P AV_PIX_FMT_YUV420P +#define MY_PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P + +#else + +#define MY_PIX_FMT_YUV420P PIX_FMT_YUV420P +#define MY_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P + +#endif + + #endif /* HAVE_FFMPEG */ #define TIMELAPSE_NONE 0 /* No timelapse, regular processing */ diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 3ca15f1..671a1a9 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -36,8 +36,8 @@ int netcam_check_pixfmt(netcam_context_ptr netcam){ retcd = -1; - if ((netcam->rtsp->codec_context->pix_fmt == AV_PIX_FMT_YUV420P) || - (netcam->rtsp->codec_context->pix_fmt == AV_PIX_FMT_YUVJ420P)) retcd = 0; + if ((netcam->rtsp->codec_context->pix_fmt == MY_PIX_FMT_YUV420P) || + (netcam->rtsp->codec_context->pix_fmt == MY_PIX_FMT_YUVJ420P)) retcd = 0; return retcd; @@ -565,7 +565,7 @@ int netcam_rtsp_open_sws(netcam_context_ptr netcam){ ,netcam->rtsp->codec_context->pix_fmt ,netcam->width ,netcam->height - ,AV_PIX_FMT_YUV420P + ,MY_PIX_FMT_YUV420P ,SWS_BICUBIC,NULL,NULL,NULL); if (netcam->rtsp->swsctx == NULL) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ @@ -576,7 +576,7 @@ int netcam_rtsp_open_sws(netcam_context_ptr netcam){ } netcam->rtsp->swsframe_size = avpicture_get_size( - AV_PIX_FMT_YUV420P + MY_PIX_FMT_YUV420P ,netcam->width ,netcam->height); if (netcam->rtsp->swsframe_size <= 0) { @@ -632,7 +632,7 @@ int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ retcd = avpicture_fill( (AVPicture*)netcam->rtsp->swsframe_out ,buffer_out - ,AV_PIX_FMT_YUV420P + ,MY_PIX_FMT_YUV420P ,netcam->width ,netcam->height); if (retcd < 0) { @@ -663,7 +663,7 @@ int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ retcd = avpicture_layout( (const AVPicture*)netcam->rtsp->swsframe_out - ,AV_PIX_FMT_YUV420P + ,MY_PIX_FMT_YUV420P ,netcam->width ,netcam->height ,(unsigned char *)image From 8e62b195f22c862e13af035d13da670566626a22 Mon Sep 17 00:00:00 2001 From: Rex Feany Date: Fri, 18 Sep 2015 00:12:16 -0700 Subject: [PATCH 153/233] compile against ffmpeg from github@58fe57d5a05ad8d15c320b2bd163debbc412bdd3 fix minor compilation issues use pkg-config --- .gitignore | 1 + Makefile.in | 4 +- configure.ac | 228 +++++---------------------------------------------- 3 files changed, 23 insertions(+), 210 deletions(-) diff --git a/.gitignore b/.gitignore index f99fee3..ab712ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.log .svn/ *.o +autom4te.cache .depend motion config.h diff --git a/Makefile.in b/Makefile.in index 32e81f2..6dcc000 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,9 +31,9 @@ examplesdir = $(datadir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/examples # These variables contain compiler flags, object files to build and files to # # install. # ################################################################################ -CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" +CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ @FFMPEG_LIBS@ VIDEO_OBJ = @VIDEO@ OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ diff --git a/configure.ac b/configure.ac index 5eb7ddc..58a557b 100755 --- a/configure.ac +++ b/configure.ac @@ -376,215 +376,25 @@ fi # # Check for libavcodec and libavformat from ffmpeg # - -FFMPEG_DIR="yes" -FFMPEG_OK="no_found" FFMPEG_OBJ="" -AC_ARG_WITH(ffmpeg, -[ --with-ffmpeg[=DIR] Specify the prefix for the install path for - libavcodec/libavformat (part of ffmpeg) be able to - encode mpeg movies realtime. - If this is not specified motion will try to find - the libraries in /usr and /usr/local. - ], -FFMPEG_DIR="$withval" -) - -# -# ffmpeg headers custom location -# -FFMPEG_HEADERS_DIR="yes" -AC_ARG_WITH(ffmpeg_headers, -[ --with-ffmpeg-headers[=DIR] Specify the prefix for ffmpeg headers. - ], -FFMPEG_HEADERS_DIR="$withval" -) - -# -# ffmpeg custom extra libraries -# -FFMPEG_EXTRALIBS=" -lavformat -lavcodec -lavutil -lm -lz -lswscale " -AC_ARG_WITH(ffmpeg-libs, -[ --with-ffmpeg-libs[=libs] Specify the extra libs for ffmpeg - ], -FFMPEG_EXTRALIBS="$withval" -) - -# -# --without-ffmpeg or with-ffmpeg=no -# -if test "${FFMPEG_DIR}" = "no"; then - AC_MSG_CHECKING(for ffmpeg) - AC_MSG_RESULT(skipping) -# -# with-ffmpeg= or nothing -# -else if test "${FFMPEG_DIR}" = "yes"; then - # AUTODETECT STATIC/SHARED LIB - AC_MSG_CHECKING(for ffmpeg autodetecting libraries) - - if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib64) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib64" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/libavcodec.a -o -f /usr/lib/libavcodec.so && test -f /usr/lib/libavformat.a -o -f /usr/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib" - FFMPEG_DIR="/usr" - elif test -f /usr/local/lib/libavcodec.a -o -f /usr/local/lib/libavcodec.so && test -f /usr/local/lib/libavformat.a -o -f /usr/local/lib/libavformat.so ; then - AC_MSG_RESULT(found in /usr/local/lib) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/local/lib" - FFMPEG_DIR="/usr/local" - elif test -f /usr/lib/x86_64-linux-gnu/libavcodec.a -o -f /usr/lib/x86_64-linux-gnu/libavcodec.so && test /usr/lib/x86_64-linux-gnu/libavformat.a -o -f /usr/lib/x86_64-linux-gnu/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib/x86_64-linux-gnu) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/x86_64-linux-gnu" - FFMPEG_DIR="/usr" - elif test -f /usr/lib/i386-linux-gnu/libavcodec.a -o -f /usr/lib/i386-linux-gnu/libavcodec.so && test /usr/lib/i386-linux-gnu/libavformat.a -o -f /usr/lib/i386-linux-gnu/libavformat.so ; then - AC_MSG_RESULT(found in /usr/lib/i386-linux-gnu) - FFMPEG_OK="found" - FFMPEG_LIB="/usr/lib/i386-linux-gnu" - FFMPEG_DIR="/usr" - else - AC_MSG_RESULT(not found) - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi -else - AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-) - if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_OK="found" - FFMPEG_LIB="${FFMPEG_DIR}/lib" - elif test -f ${FFMPEG_DIR}/libavcodec.a -o -f ${FFMPEG_DIR}/libavcodec.so && test -f ${FFMPEG_DIR}/libavformat.a -o -f ${FFMPEG_DIR}/libavformat.so ; then - AC_MSG_RESULT(found) - FFMPEG_LIB="${FFMPEG_DIR}" - FFMPEG_OK="found" - else - AC_MSG_RESULT(not found) - if test "${FFMPEG_OK}" != "found"; then - echo "" - echo "**********************************************" - echo "* libavcodec.a or libavcodec.so or *" - echo "* libavformat.a or libavformat.so not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - fi -fi - - -# -# Now check for ffmpeg headers ( avformat.h ) if ffmpeg libs were found -# - -AVFORMAT_DIR="" - -if test "${FFMPEG_OK}" = "found"; then - if test "${FFMPEG_HEADERS_DIR}" = "yes"; then - AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_DIR}) - AVFORMAT_DIR="${FFMPEG_DIR}" - else - AC_MSG_CHECKING(for ffmpeg headers in ${FFMPEG_HEADERS_DIR}) - FFMPEG_DIR="${FFMPEG_HEADERS_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}" - fi - - if test -f ${FFMPEG_DIR}/include/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include" - AVFORMAT_DIR="${FFMPEG_DIR}/include/avformat.h" - elif test -f ${FFMPEG_DIR}/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}" - AVFORMAT_DIR="${FFMPEG_DIR}/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/avformat.h" - elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" - elif test -f ${FFMPEG_DIR}/libavformat/avformat.h; then - AC_MSG_RESULT(found ${FFMPEG_DIR}/libavformat/avformat.h) - FFMPEG_CFLAGS="-I${FFMPEG_DIR} -DFFMPEG_NEW_INCLUDES" - AVFORMAT="-I{FFMPEG_DIR}/libavformat" - AVFORMAT_DIR="${FFMPEG_DIR}/libavformat/avformat.h" - else - AC_MSG_RESULT(not found) - FFMPEG_OK="no_found" - AVFORMAT_DIR="avformat.h" - echo "**********************************************" - echo "* avformat.h not found: *" - echo "* ALL FFMPEG FEATURES DISABLED *" - echo "* *" - echo "* Please read the Motion Guide for help: *" - echo "* http://motion.sourceforge.net *" - echo "**********************************************" - echo "" - fi - -# -# If ffmpeg libs and headers have been found -# - - if test "${FFMPEG_OK}" = "found"; then - TEMP_LIBS="$TEMP_LIBS -L${FFMPEG_LIB} ${FFMPEG_EXTRALIBS}" - TEMP_LDFLAGS="${TEMP_LDFLAGS} -L${FFMPEG_LIB}" - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG ${FFMPEG_CFLAGS}" - - FFMPEG_OBJ="ffmpeg.o" - AC_SUBST(FFMPEG_OBJ) - - AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?]) - saved_CFLAGS=$CFLAGS - saved_LIBS=$LIBS - - CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}" - LIBS="$TEMP_LIBS" +AC_ARG_WITH([ffmpeg], + AS_HELP_STRING([--with-ffmpeg[=DIR]], [Build with FFMPEG support]), + [with_ffmpeg=$withval], + [with_ffmpeg=no]) + +AS_IF([test "x$with_ffmpeg" != "xno"], [ + AS_IF([test "x$with_ffmpeg" != "xyes"], [ + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${with_ffmpeg}/lib/pkgconfig + export PKG_CONFIG_PATH + ]) + PKG_CHECK_MODULES([FFMPEG], libavutil libavformat libavcodec libswscale, HAVE_FFMPEG=yes) +]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - [ - #include <${AVFORMAT_DIR}> - URLProtocol test_file_protocol; - int main(void){ - test_file_protocol.url_read = file_protocol.url_read; - return 0; - } - ]])], - [AC_MSG_RESULT(yes)], - [ - AC_MSG_RESULT(no) - TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_NEW" - ] - ) - CFLAGS=$saved_CFLAGS - LIBS=$saved_LIBS - fi -fi -fi +AS_IF([test "${HAVE_FFMPEG}" = "yes" ], [ + FFMPEG_OBJ="ffmpeg.o" + AC_DEFINE([HAVE_FFMPEG], 1, [Define to 1 if FFMPEG is around]) +]) +AC_SUBST(FFMPEG_OBJ) # Revised RTSP module so that it can be included # whether or not FFMPEG is found. @@ -1372,8 +1182,10 @@ else echo "SDL support: No" fi -if test "${FFMPEG_OK}" = "found"; then +if test "${HAVE_FFMPEG}" = "yes"; then echo "FFmpeg support: Yes" + echo " ... FFMPEG_CFLAGS: $FFMPEG_CFLAGS" + echo " ... FFMPEG_LIBS: $FFMPEG_LIBS" else echo "FFmpeg support: No" fi From 2fdf34a80fb81286ca1bc75bb29c3c6042cd529a Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Mon, 21 Sep 2015 11:16:29 -0600 Subject: [PATCH 154/233] Slight Packaging Changes --- .gitignore | 9 +++++---- Makefile.in | 14 ++++++++++---- configure.ac | 14 ++++---------- motion-dist.conf.in | 8 ++++---- thread1.conf.in => thread1-dist.conf.in | 2 +- thread2.conf.in => thread2-dist.conf.in | 2 +- thread3.conf.in => thread3-dist.conf.in | 2 +- thread4.conf.in => thread4-dist.conf.in | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) mode change 100755 => 100644 configure.ac rename thread1.conf.in => thread1-dist.conf.in (98%) rename thread2.conf.in => thread2-dist.conf.in (98%) rename thread3.conf.in => thread3-dist.conf.in (98%) rename thread4.conf.in => thread4-dist.conf.in (98%) diff --git a/.gitignore b/.gitignore index ab712ae..5d7a35f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .svn/ *.o autom4te.cache +aclocal.m4 .depend motion config.h @@ -14,7 +15,7 @@ motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh motion.spec -thread1.conf -thread2.conf -thread3.conf -thread4.conf +thread1-dist.conf +thread2-dist.conf +thread3-dist.conf +thread4-dist.conf diff --git a/Makefile.in b/Makefile.in index 6dcc000..1863637 100644 --- a/Makefile.in +++ b/Makefile.in @@ -195,6 +195,7 @@ help: @echo "--------------------------------------------------------------------------------" @echo + ################################################################################ # INSTALL installs all relevant files. # ################################################################################ @@ -206,15 +207,20 @@ install: mkdir -p $(DESTDIR)$(sysconfdir)/motion mkdir -p $(DESTDIR)$(docdir) mkdir -p $(DESTDIR)$(examplesdir) + @sed -i 's|$${prefix}|$(prefix)|' motion-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' thread1-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' thread2-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' thread3-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' thread4-dist.conf $(INSTALL_DATA) motion.1 $(DESTDIR)$(mandir)/man1 $(INSTALL_DATA) $(DOC) $(DESTDIR)$(docdir) $(INSTALL_DATA) $(EXAMPLES) $(DESTDIR)$(examplesdir) $(INSTALL) $(EXAMPLES_BIN) $(DESTDIR)$(examplesdir) $(INSTALL_DATA) motion-dist.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread1.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread2.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread3.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread4.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread1-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread2-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread3-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) thread4-dist.conf $(DESTDIR)$(sysconfdir)/motion for prog in $(PROGS); \ do \ ($(INSTALL) $$prog $(DESTDIR)$(bindir) ); \ diff --git a/configure.ac b/configure.ac old mode 100755 new mode 100644 index 58a557b..e1c4b21 --- a/configure.ac +++ b/configure.ac @@ -396,12 +396,6 @@ AS_IF([test "${HAVE_FFMPEG}" = "yes" ], [ ]) AC_SUBST(FFMPEG_OBJ) -# Revised RTSP module so that it can be included -# whether or not FFMPEG is found. - - RTPS_OBJ="netcam_rtsp.o" - AC_SUBST(RTPS_OBJ) - # # Check SQLITE3 # @@ -1097,10 +1091,10 @@ fi AC_SUBST(BIN_PATH) AC_CONFIG_FILES([ -thread1.conf -thread2.conf -thread3.conf -thread4.conf +thread1-dist.conf +thread2-dist.conf +thread3-dist.conf +thread4-dist.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian diff --git a/motion-dist.conf.in b/motion-dist.conf.in index a0f9db0..856c550 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -746,8 +746,8 @@ quiet on # This motion.conf file AND thread1.conf and thread2.conf. # Only put the options that are unique to each camera in the # thread config files. -; thread @prefix@/etc/motion/thread1.conf -; thread @prefix@/etc/motion/thread2.conf -; thread @prefix@/etc/motion/thread3.conf -; thread @prefix@/etc/motion/thread4.conf +; thread @sysconfdir@/motion/thread1.conf +; thread @sysconfdir@/motion/thread2.conf +; thread @sysconfdir@/motion/thread3.conf +; thread @sysconfdir@/motion/thread4.conf diff --git a/thread1.conf.in b/thread1-dist.conf.in similarity index 98% rename from thread1.conf.in rename to thread1-dist.conf.in index b3d1d57..a1b7ea9 100644 --- a/thread1.conf.in +++ b/thread1-dist.conf.in @@ -1,4 +1,4 @@ -# @prefix@/etc/motion/thread1.conf +# @sysconfdir@/motion/thread1.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ diff --git a/thread2.conf.in b/thread2-dist.conf.in similarity index 98% rename from thread2.conf.in rename to thread2-dist.conf.in index d6d81ff..273ee9b 100644 --- a/thread2.conf.in +++ b/thread2-dist.conf.in @@ -1,4 +1,4 @@ -# @prefix@/etc/motion/thread2.conf +# @sysconfdir@/motion/thread2.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ diff --git a/thread3.conf.in b/thread3-dist.conf.in similarity index 98% rename from thread3.conf.in rename to thread3-dist.conf.in index 14a2655..004c68a 100644 --- a/thread3.conf.in +++ b/thread3-dist.conf.in @@ -1,4 +1,4 @@ -# @prefix@/etc/motion/thread3.conf +# @sysconfdir@/motion/thread3.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ diff --git a/thread4.conf.in b/thread4-dist.conf.in similarity index 98% rename from thread4.conf.in rename to thread4-dist.conf.in index b22235e..018c849 100644 --- a/thread4.conf.in +++ b/thread4-dist.conf.in @@ -1,4 +1,4 @@ -# @prefix@/etc/motion/thread4.conf +# @sysconfdir@/motion/thread4.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ From e6aba9b46dda783da978efb2124625b9f6cc9cb2 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Tue, 22 Sep 2015 21:46:38 -0600 Subject: [PATCH 155/233] Change default in configure for ffmpeg --- CHANGELOG | 12 ++++++++--- configure.ac | 2 +- motion_guide.html | 55 +++++++++++++++++++++-------------------------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cc95cf8..84bb8c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,12 +1,18 @@ Summary of Changes + * Change default for ffmpeg in configure.ac (Issue 795002,82) + To compile without ffmpeg now requires --without-ffmpeg option + * Change prefix to use sysconfdir instead. Install threadX.conf files to threadx-dist.conf + * Revise configure.ac to use pkg-config for ffmpeg(Rex Feany) + * Revise PIX_FMT to be able to use older ffmpeg versions. + * Revise PIX_FMT for newer ffmpeg(Rex Feany) * Add patch for ports on proxy netcams from GVautier (issue 144906) * Add patch from JonGuess(issue 151452) for treatment of partial netcam images. * Consolidate the Sqlite3 options into the code standard. * Draft revised motion_guide.html with new options. * Revise manual to have current options. - * Tab/Space cleanup and validation security issue addressed. (closes 071831) - * Add preview to webcontrol page(closes 172526) - * Additional container fixes(closes requests/bugs 201900,110304,001656,050731) + * Tab/Space cleanup and validation security issue addressed. (issue 071831) + * Add preview to webcontrol page(issue 172526) + * Additional container fixes(requests/bugs 201900,110304,001656,050731) * Remove depreciated deinterlace option * Remove avformat_network_init call. Call was not needed and was leaking memory * Add extra container options for ffmpeg videos diff --git a/configure.ac b/configure.ac index e1c4b21..b9070a6 100644 --- a/configure.ac +++ b/configure.ac @@ -380,7 +380,7 @@ FFMPEG_OBJ="" AC_ARG_WITH([ffmpeg], AS_HELP_STRING([--with-ffmpeg[=DIR]], [Build with FFMPEG support]), [with_ffmpeg=$withval], - [with_ffmpeg=no]) + [with_ffmpeg=yes]) AS_IF([test "x$with_ffmpeg" != "xno"], [ AS_IF([test "x$with_ffmpeg" != "xyes"], [ diff --git a/motion_guide.html b/motion_guide.html index 75b23f1..47ace49 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -100,12 +100,13 @@

                                                            Which version to download

                                                            Versions 3.2.12 is the current official version released in June 2010. The trunk of the SVN represents the official development branch of Motion. Additional independent development forks exist on Github that contain additional bug -fixes, enhanced features and updated -documentation. This guide is based upon the features and options included in the Mr-Dave Github repository as of -September 2015. -Note that the majority of the new options and changed names represent differences between the official 3.2.12 version -and the SVN trunk rather than differences between the trunk and the Mr-Dave repository. Users are encouraged to evaluate -the pros and cons for themselves of using any particular source. +fixes, enhanced features and updated documentation. +This guide is based upon the features and options included in the source code with which it is distributed. +It was re-written in September 2015 to reflect the changes and options in the code at that time. +The majority of the new options and changed names represent differences between the official 3.2.12 version +and the SVN trunk and as a result this guide will generally apply to the code in the trunk as well. There may +however be some options and features included in this guide that are not incorporated into the trunk source code. +Users are encouraged to evaluate the pros and cons for themselves of using any particular source.

                                                            Since 3.2.12 many options have been renamed in the development branches to make setting up Motion easier.

                                                            @@ -298,7 +299,8 @@

                                                            @@ -350,6 +352,8 @@

                                                            Important ffmpeg note: The ffmpeg libraries indicated above are provided by a external repository. This may change in the future. Validate that the repository is still valid when doing the install on openSUSE systems. + The default for the configure is to require that ffmpeg or Libav are installed. Use the configure option to + compile without the ffmpeg / libav functionality.

                                                          @@ -379,8 +383,7 @@

                                                          Configure Script

                                                          With the Motion configure script, once it has ended it also lists out all of the optional components that were located. Note that if you KNOW that a particular component is installed yet the configure script reports it as not installed, then it may be necessary to use one or more of the configure options described below to tell the script where to find -the particular component. (This happens frequently with the Libav/ffmpeg libraries since the install location has changed -numerous times). +the particular component.

                                                          To run the configure your current directory must be the motion directory. You type @@ -566,32 +569,24 @@

                                                          Configure Script

                                                          --with-ffmpeg=DIR - Specify the path for the directory prefix in which the library and headers are installed .
                                                          If not specified configure will search in /usr/ and /usr/local/ + Specify the path for the directory prefix in which the + library and headers are installed .
                                                          If not specified configure will search in /usr/ and /usr/local/ DIR is the directory PREFIX in which the ffmpeg shared libraries and their headers are installed.
                                                          If you install ffmpeg from sources and use the default directories or if ffmpeg is installed as a binary package (RPM or deb) you may not need to specify the directory prefix. Configure should find the libraries automatically. If you installed ffmpeg from sources and specified a - different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR). + different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR) + or export that location to be included in the PKG_CONFIG_PATH + The option of --with-ffmpeg is the default for Motion. If the required libraries are not located, the + configure script will stop at the ffmpeg section and report which libraries need to be installed. + Once the required libraries are installed, run the script again. As noted previously, make sure + to install the -dev versions. For more information on FFmpeg see the documentation for the FFmpeg project.
                                                          - - --with-ffmpeg-headers=DIR - Specify the prefix for ffmpeg headers. - DIR is the directory PREFIX in which the ffmpeg headers are installed.
                                                          If you install ffmpeg from sources and use the default directories or - if ffmpeg is installed as a binary package (RPM or deb) you may not need to specify the directory prefix. - Configure should find the libraries automatically. If you installed ffmpeg from sources and specified a - different --prefix when building ffmpeg you must use the same value for the DIR ( --with-ffmpeg=DIR). - For more information on FFmpeg see the documentation for the FFmpeg project.
                                                          - - - --with-ffmpeg-libs=libs - Specify the extra libs ffmpeg. - libs is a list of libraries associated with ffmpeg necessary for linking. - --without-ffmpeg Do not compile with ffmpeg - Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg. + Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you must specify this option for Motion to build without ffmpeg. --with-mysql-lib=DIR @@ -666,13 +661,11 @@

                                                          Make

                                                          If the notifications indicate many many undefined references, then it is most likely that an additional library needs to be added in via the configure switches. Many of these additional libraries are related -to the version of ffmpeg and how it was built or installed. The following is a sample of the configuration -line that needs to be run to add references to the ffmpeg libraries. Note that it is unlikely that ALL of these -libraries would be needed and this sample is only intended to provide some guidance. As indicated, the libraries are -associated with ffmpeg and how that component was created. +to the version of ffmpeg and how it was built or installed. The following is a sample of some of the extra libraries +that may need to be added.

                                                          -./configure --with-ffmpeg-libs=" -lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec " +-lavformat -lswscale -lavcodec -lavutil -lfdk-aac -lswresample -lm -lopus -lz -lva -lvpx -lx264 -lmp3lame -lbz2 -ldl -lvorbisenc -lvorbis -ltheoraenc -ltheoradec

                                                          From b1940b085033373a921db6459e0e74b13fffbc50 Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Tue, 22 Sep 2015 21:52:38 -0600 Subject: [PATCH 156/233] Revised description in configuration file --- CHANGELOG | 1 + motion-dist.conf.in | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 84bb8c8..a4c8612 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Revise description for netcam_url in configuration file. * Change default for ffmpeg in configure.ac (Issue 795002,82) To compile without ffmpeg now requires --without-ffmpeg option * Change prefix to use sysconfdir instead. Install threadX.conf files to threadx-dist.conf diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 856c550..f8af8ff 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -112,7 +112,8 @@ framerate 2 minimum_frame_time 0 # URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///) -# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined +# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. A trailing slash may be required for some cameras. +# Default: Not defined ; netcam_url value # Username and password for network camera (only if required). Default: not defined From e6bc27c01246b56c590f9a7ccecaecf76619a1ab Mon Sep 17 00:00:00 2001 From: momo-i Date: Fri, 25 Sep 2015 16:17:19 +0900 Subject: [PATCH 157/233] HEVC testing --- conf.c | 3 ++- ffmpeg.c | 9 ++++++++- motion-dist.conf.in | 1 + motion.1 | 3 ++- motion_guide.html | 3 ++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/conf.c b/conf.c index 25e3d00..232c311 100644 --- a/conf.c +++ b/conf.c @@ -779,7 +779,8 @@ config_param config_params[] = { "# mov - QuickTime ( testing )\n" "# ogg - Ogg/Theora ( testing )\n" "# mp4 - MPEG-4 Part 14 H264 encoding\n" - "# mkv - Matroska H264 encoding", + "# mkv - Matroska H264 encoding\n" + "# hevc - H.265 / HEVC (High Efficiency Video Coding)", 0, CONF_OFFSET(ffmpeg_video_codec), copy_string, diff --git a/ffmpeg.c b/ffmpeg.c index f123640..190b0d2 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -49,6 +49,7 @@ #define MY_CODEC_ID_NONE AV_CODEC_ID_NONE #define MY_CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO #define MY_CODEC_ID_H264 AV_CODEC_ID_H264 +#define MY_CODEC_ID_HEVC AV_CODEC_ID_HEVC #else @@ -58,6 +59,7 @@ #define MY_CODEC_ID_NONE CODEC_ID_NONE #define MY_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO #define MY_CODEC_ID_H264 CODEC_ID_H264 +#define MY_CODEC_ID_HEVC AV_CODEC_ID_HEVC #endif /*********************************************/ AVFrame *my_frame_alloc(void){ @@ -180,6 +182,10 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename){ ext = ".mkv"; of = av_guess_format ("matroska", NULL, NULL); of->video_codec = MY_CODEC_ID_H264; + } else if (strcmp (codec, "hevc") == 0){ + ext = ".mp4"; + of = av_guess_format ("mp4", NULL, NULL); + of->video_codec = MY_CODEC_ID_HEVC; } else { MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg_video_codec option value" " %s is not supported", codec); @@ -286,7 +292,8 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename, c->pix_fmt = MY_PIX_FMT_YUV420P; c->max_b_frames = 0; - if (c->codec_id == MY_CODEC_ID_H264){ + if (c->codec_id == MY_CODEC_ID_H264 || + c->codec_id == MY_CODEC_ID_HEVC){ av_dict_set(&opts, "preset", "ultrafast", 0); av_dict_set(&opts, "crf", "18", 0); av_dict_set(&opts, "tune", "zerolatency", 0); diff --git a/motion-dist.conf.in b/motion-dist.conf.in index a0f9db0..aed809a 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -324,6 +324,7 @@ ffmpeg_variable_bitrate 0 # ogg - Ogg/Theora ( testing ) # mp4 - MPEG-4 Part 14 H264 encoding # mkv - Matroska H264 encoding +# hevc - H.265 / HEVC (High Efficiency Video Coding) ffmpeg_video_codec mpeg4 # When creating videos, should frames be duplicated in order diff --git a/motion.1 b/motion.1 index ace5e78..ccbad37 100644 --- a/motion.1 +++ b/motion.1 @@ -960,6 +960,7 @@ mov - QuickTime ogg - Ogg/Theora mp4 - MPEG-4 Part 14 H264 encoding mkv - Matroska H264 encoding +hevc - H.265 / HEVC (High Efficiency Video Coding) .RE .RE Default: mpeg4 @@ -2025,4 +2026,4 @@ Jeroen Vreeken (pe1rxq@amsat.org), Folkert van Heusden, Kenneth Lavrsen (kenneth@lavrsen.dk), Juan Angulo Moreno , -and many others \ No newline at end of file +and many others diff --git a/motion_guide.html b/motion_guide.html index 75b23f1..e772afe 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -3334,6 +3334,7 @@

                                                          ffmpeg_video_codec

                                                        • ogg - Ogg/Theora
                                                        • mp4 - MPEG-4 Part 14 H264 encoding
                                                        • mkv - Matroska H264 encoding
                                                        • +
                                                        • hevc - H.265 / HEVC (High Efficiency Video Coding)

                                                        @@ -4344,4 +4345,4 @@

                                                        track_stepsize

                                                      -
                                                    \ No newline at end of file +
                                                  From 2bd79c795ba51b7568faa20be2e469e6c00e25aa Mon Sep 17 00:00:00 2001 From: Mr Dave Date: Sat, 26 Sep 2015 21:19:06 -0600 Subject: [PATCH 158/233] Make/configure changes --- CHANGELOG | 1 + Makefile.in | 29 ++++++++++++++--------------- configure.ac | 6 +----- motion.1 | 26 ++++++++++++++++---------- motion_guide.html | 22 +++++++++++++++++----- 5 files changed, 49 insertions(+), 35 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a4c8612..bae17ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ Summary of Changes + * Makefile changes to align with Debian package and fixes from previous changes * Revise description for netcam_url in configuration file. * Change default for ffmpeg in configure.ac (Issue 795002,82) To compile without ffmpeg now requires --without-ffmpeg option diff --git a/Makefile.in b/Makefile.in index 1863637..b430efb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24,8 +24,8 @@ mandir = @mandir@ sysconfdir = @sysconfdir@ datadir = @datadir@ datarootdir = @datarootdir@ -docdir = $(datadir)/doc/@PACKAGE_NAME@-@PACKAGE_VERSION@ -examplesdir = $(datadir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/examples +docdir = $(datadir)/doc/@PACKAGE_NAME@ +examplesdir = $(datadir)/@PACKAGE_NAME@/examples ################################################################################ # These variables contain compiler flags, object files to build and files to # @@ -66,7 +66,6 @@ pre-build-info: @echo "Welcome to the setup procedure for Motion, the motion detection daemon! If you get" @echo "error messages during this procedure, please report them to the mailing list. The" @echo "Motion Guide contains all information you should need to get Motion up and running." - @echo "Run \"make updateguide\" to download the latest version of the Motion Guide." @echo @echo "Version: @PACKAGE_VERSION@" ifneq (,$(findstring freebsd,$(VIDEO_OBJ))) @@ -155,12 +154,12 @@ svn: svn update autotools: - @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in + @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.ac autoconf ./configure --with-developer-flags autotools-git: - @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in + @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.ac autoconf ./configure --with-developer-flags @@ -168,15 +167,15 @@ autotools-git: build-commit: distclean svn set-version all set-version: - @sed -i 's/.\/version.sh/.\/commit-version.sh/g' configure.in + @sed -i 's/.\/version.sh/.\/commit-version.sh/g' configure.ac autoconf - @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in + @sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.ac ./configure --with-developer-flags set-version-git: - @sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.in + @sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.ac autoconf - @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in + @sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.ac ./configure --with-developer-flags @@ -244,10 +243,10 @@ uninstall remove: pre-build-info done rm -f $(mandir)/man1/motion.1 rm -f $(sysconfdir)/motion/motion-dist.conf - rm -f $(sysconfdir)/motion/thread1.conf - rm -f $(sysconfdir)/motion/thread2.conf - rm -f $(sysconfdir)/motion/thread3.conf - rm -f $(sysconfdir)/motion/thread4.conf + rm -f $(sysconfdir)/motion/thread1-dist.conf + rm -f $(sysconfdir)/motion/thread2-dist.conf + rm -f $(sysconfdir)/motion/thread3-dist.conf + rm -f $(sysconfdir)/motion/thread4-dist.conf rm -rf $(docdir) rm -rf $(examplesdir) @echo "--------------------------------------------------------------------------------" @@ -277,7 +276,7 @@ dist: distclean updateguide distclean: clean @echo "Removing files generated by configure..." @rm -f config.status config.log config.cache Makefile motion.init-Fedora motion.init-Debian motion.init-FreeBSD.sh - @rm -f thread1.conf thread2.conf thread3.conf thread4.conf motion-dist.conf motion-help.conf motion.spec + @rm -f thread1-dist.conf thread2-dist.conf thread3-dist.conf thread4-dist.conf motion-dist.conf motion-help.conf motion.spec @rm -rf autom4te.cache config.h @echo "You will need to re-run configure if you want to build Motion." @echo @@ -292,5 +291,5 @@ updateguide: pre-build-info @echo "Cleaning up and fixing links..." @cat motion_guide.tmp | sed -e 's/\?skin=text//g;s,"/twiki/,"http://www.lavrsen.dk/twiki/,g' > motion_guide.html @rm -f motion_guide.tmp - @echo "All done, you should now have an up-to-date local copy of the Motion guide." + @echo "All done, you should now have a local copy of the Motion guide from the home page." @echo diff --git a/configure.ac b/configure.ac index b9070a6..7b69aa3 100644 --- a/configure.ac +++ b/configure.ac @@ -221,11 +221,7 @@ AC_MSG_CHECKING(for sdl) if test "x$withval" = "xno"; then AC_MSG_RESULT(skipped) else - if test "${FreeBSD}" != ""; then - CONFIG_SDL='sdl11-config' - else - CONFIG_SDL='sdl-config' - fi + CONFIG_SDL='sdl-config' if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then AC_MSG_RESULT(no) if test "$withval" = "yes"; then diff --git a/motion.1 b/motion.1 index ace5e78..7560577 100644 --- a/motion.1 +++ b/motion.1 @@ -1,8 +1,8 @@ -.TH MOTION 1 2007-11-06 "Motion" "Motion Options and Config Files" +.TH MOTION 1 2015-09-26 "Motion" "Motion Options and Config Files" .SH NAME motion \- Detct motion using a video4linux device or network camera .SH SYNOPSIS -.B motion [ -hbnsm ] [ -c config file path ] [ -d level ] [ -k level ] [ -p process_id_file ][ -l log_file ] +.B motion [ \-hbnsm ] [ \-c config file path ] [ \-d level ] [ \-k level ] [ \-p process_id_file ][ \-l log_file ] .SH DESCRIPTION .I Motion uses a video4linux device or network camera to detect motion. If motion is detected both normal @@ -196,11 +196,11 @@ This is ONLY used for FreeBSD. .nf Values: .RS --1 : USB Cameras +\-1 : USB Cameras 0 : video/TV cards or uvideo(4) on OpenBSD 1 : video/TV cards .RE -Default: -1 +Default: \-1 Description: .fi .RS @@ -642,11 +642,17 @@ The trigger is only activated once during an event. one or more areas can be specified with this option. Note that this option is only used to trigger the indicated script. It does not limit all motion detection events to only the area indicated. -.RS -Image Areas -123 -456 -789 +.RS +Image Areas +.RE +.RS +123 +.RE +.RS +456 +.RE +.RS +789 .RE .RE .RE @@ -2025,4 +2031,4 @@ Jeroen Vreeken (pe1rxq@amsat.org), Folkert van Heusden, Kenneth Lavrsen (kenneth@lavrsen.dk), Juan Angulo Moreno , -and many others \ No newline at end of file +and many others diff --git a/motion_guide.html b/motion_guide.html index 47ace49..747bbb0 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -391,10 +391,22 @@

                                                  Configure Script

                                                  ./configure

                                                  You can add the parameter ./configure --help to get help on the different switches. - -The following table lists the current configure options.

                                                  - +When the configure script finishes you should validate that the options desired +were correctly identified by the configure. In particular, the ffmpeg option is occasionally not +found even if it is actually installed. Various users have indicated this to be a particular +problem with the PI. If using a PI and have this issue, you can use the following option +

                                                  +./configure --with-ffmpeg=/usr/lib/arm-linux-gnueabihf +

                                                  +For a long term option, you can edit the file +$HOME/.bashrc +and within it place the following two lines at the end +PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf:$PKG_CONFIG_PATH +export PKG_CONFIG_PATH +

                                                  +The long term option will however only become effective the next time you get into the terminal shell. +

                                                  @@ -651,8 +663,8 @@

                                                  Configure Script

                                                  Make

                                                  - mask1.png + mask1.png
                                                  @@ -3046,7 +3030,7 @@

                                                  Output - Picture Options <

                                                  Motion can output different types of pictures. The normal picture is indicated below.

                                                  -outputnormal1.jpg +outputnormal1.jpg

                                                  The motion type picture or also referred to as a debug picture is shown below. Note that the largest area is blue and only this is counted as Motion. @@ -3055,7 +3039,7 @@

                                                  Output - Picture Options < but a mathematical calculation of the past images. This enlarges real Motion and ensures that it is not easy to sneak in slowly.

                                                  -outputmotion1.jpg +outputmotion1.jpg

                                                  @@ -3395,8 +3379,7 @@

                                                  Output - Pipe Options

                                                  The video4linux driver is written by the same author that first created Motion. You can -find the source and a brief description at the -video4linux loopback device web page. +find the source within apt packages.

                                                  The video4linux device is a Kernel module which installs itself as a video pipe. It has an input and an output. The module simply takes anything that comes on its input @@ -3444,9 +3427,7 @@

                                                  Output - Pipe Options

                                                  Now you need to install the video loopback device.

                                                  -Download the latest -video4linux loopback device . -Place the file in a place of your own choice. +Download the latest via the apt packages and place the file in a place of your own choice.

                                                  Untar and uncompress the file to the place you want the program installed. Editor recommends /usr/local/vloopback.

                                                  @@ -3538,7 +3519,6 @@

                                                  motion_video_pipe

                                                • Type: String
                                                • Range / Valid values: Max 4095 characters
                                                • Default: Not defined -
                                                • Option Topic

                                                The video4linux video loopback input device for motion images. diff --git a/normal.jpg b/normal.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dc1116d674a75489d0358550c4a1a4b580c8fe8b GIT binary patch literal 14286 zcmbW7XHXO2+wKE|D!nL3s0qCY0Yc~jB@mF_o6?(fklqml457DB1nE_JSLuYV^rj+& zE=8&!>hb@+XU>^9pUye=&hD3eX6OFR?#y*R*R_9_{;mUPHIOJIfPer1AozCx{;mQZ z0;tF-?og0X-J!TcO-)6^z{$iwPtU*yV!y{JDj+THI{$eH0W~!>104e|6BDnFl!%nh|8xEA1<;WJP6!Z01l#~ZIszg( zg1>_Rj(>d;6Z}^J{$~*o5&?-xNXh;+{ck}lEr5`Kh=>qKL`)0>{#zaP?>+!XM@-Kp zu1vz9XG6;E%?OQ3EhYo2H1;v+e>#Ck*!o11Q{27B%yOTHmycgSP*Mse4VRI9_(&D0 zrjF7uFf=kYF*P%{vv+WGa&~d`^?U9g5Ev93^CC9xWqd+nT6#uiR(4J<_DxA?S$Rce zRdrKyOKV$uM`u_6z~IpE2yS$2W_E6VVR31B<=e(4ertPYcW?j4>Dl?k<<-yYoBwbT z0Eqq@>)-Xi!Tt{}x_?}RKp+v2^gmn#gaQ9fB03;3mpBQ%vL308Hv=~`ii}YuwYag5 z94w)K!es07iQ+Cq@*B^O|DgRB+5a6_^#2#x{{s8pTq^)dB7%P}kBAPS1c!TV zF)mF+dpE=sX6zQwf3f!os1Xtk{5(Z=WBn)dKA=kUHjaYA?&MEK24V@jq(+1i#{C5d zHbostBu=Gpy~v>2CJa10w4h%B56=wNaQDC=46UX_XZ9D>4TJPEqqD?2W&rf5>3ZeJ zj`2D%tFwJq^!7JyVq4t_-&vWR^YUeWVRB1Yzd~H#cD-}sSll+hBZ(5f(1XWYrkneU zu8z5GvpP)0fZXf};SjPVJVzDtt+O8OAwR+tw;5T&PcsqH$f0a3n$v749N!T_k_I!{ zA$0-%5lSrlLX08Xh72)|xVhcqn;3Ujs$#w|xVX||Y~+r$ar*@F+fe@t&~9}xBZyU~ zyvyyt$yWKj^fU;3t0Ze}J;V0?8L}Q>56Y(&iZGnDO;>44BWBGU>XbRiUeVc!F?1{9 zuuGexuY>5V4W!S;nT&kksMCxgqL+KENE*pIpUfGYpTA&Rgj!z4tS=4u+0NU|W>)BT+Vok2CUO6-|NEG6$$mY0&fUCc%I>Zs~6*SU% zx5U2I!5Vf>lt1@sORk&uTYE|HAI4gs*9b@$Kq(fqCTmdkqWP`~C5?`&bBC}OQthk~ z|G3Rgxb%v#H>`P_B^5HTQwFY9-{c!tKwOlzA(M2lY}b>tLM&5;nR>&{ zggrjB(k{a!UWjA!m8D0~OlXcA&mHV|7C+WEz2#^t+4XZrTipJFu;x|vmdIC<*vd~) zv`Jecoc&QL5(^b5BDQKVlT@v=yKzXAnE0L+@)WPNBm*yxy89rrop1->&tyv}(j?pf zgIx@}NCo21GV9n*@&ap}Opx847M45L!Y=KFz$LsA=wW9}9mLXCBdn5Z?i^3K3`8f| zm?p2eg;8;3=2{YEQk_c~G3j&iJPA{;nGudJi?OHCGg|9u6cFm;{K#EmJyFBzr6#G4 zDO!)Ys1d<8;;rW-I8Ad(*hv?n*b1{lIdTvC<}(DKO8~UP z0e}35w}39t{rxO?`m_=LyZVdC=C~%+%~aX-eXNFjfcwm zDNW^4&8V@JuEt$3*zYI>dWm1uE>$?=jak+tW}0`@-41*yZ5Hbta7KqsKFqT=ZhDtx z_3^HvG5HlT$M9pxAE_t8UL5h? zp&LHwFD^Cydb_V;gzwD|RnyLV!Xd?c9hm{bUz8?9Hwwo_DGYlf?k;>CKk5K4{7|RK1Hj4fA(r#e?vyhA|>pZaoX-vo|n?cqE?J*?QAr`ww#H`XYpe(xDoE^ zRY&c|c{&X>NHBNDS;9Hwyfzmor|)9spU?4RE|oPS-&U&sg0GnIm#G!cS4eR@oV!34 zFTPeOjn$Kt7-CBy0NeyG&Dx*d$hzMoHp@G%NQsSh{uAV@$~7FxefeY~Nk#)_y}1{m zM7yr!clz~6SOW+vI!?zzOP=BVhv+Q``%pAhK=<3&RZQKd zX3>cimC$RY07{)QLOFLG&3ChhUpAcE9!lW(-LCC-0RIGWI!-sw%6D5}jqIX+Qi`lq z^Me4-1XL6ftqSy>i`g@~Sx9iA)6C<3BQ0kxj$_}Psd`^orLvNfbVV%LzguVlH{OYQo#8L#!A#-41eZ7Va71#ud{30`_rI*sGkZkF<6YSL_RNV~<&WWUGoUv;9oxdlDpla=(?1%(xvbT08+yW99jt>Dgd(S2L~t!#l0eKtgY~Y>yK5<5Z+=g<5m;(fCv^Mj+en3ywDcsNv=># zT(`UNo#LXJH3vH`I|`COmOk*F<>QiZQUzi^Z4r+onN6Nzo_s-k2^^vG)Vx!eg0cQb zTT#QRPY#-Z|If+#Y~%B1LXw}XW3Cr`DtKy;mZRO2*fojjmn#ayn#9fIM*a<|N20SyXQ2{PFsi(rvCC)dU005$|ihH(p z#|FNX7NnV#oY~szr41$;03S;L2g79;35>Rg2u*R*?5!5A3Vmclh7at%)M`=wn#+e9 z6v8X9rb}XeoS06=NOb>b0h(GnsP?l~zF>(c)YqI&K)goyC11X=N2TRhBHj--M3&vS z*CjINT5CsF9)1P-^Zc3q2hExYZpgmc>XLGJxtf?koI%W_g2rg%2kA0fM>vT!xm|k)6Dzg$M^~>3zE&y2 zo&4vea-e>95uc|Sqj}8%Zq7C!!>-JR2+Qlmu(KMES{jfYD&%Z#b!P8*;KGmPr#9^0g~Ct zQ@i|C{EP4DFNh*tVX+eVzKeAlC;U9w6_rv94kU~_?REDE6_Q%e`A&QbSap#zQ2lq`dl1lwG)1!wAe8aYRVM6>zs?ZI$F=WIGY!S+TB?NEV zxz96>YlFoEbQWcOoTLprRc0>`gw6g1bSU;1+)A1|dsy@3{INN}T$JMwR4wZ_CNHJN zz6VqkPfxmgFPi{@4WSZ|MMXd_0MjRVP0Y);b*enobl5!1h(cp&w^d{;$ahk>LH?=F zW1^*hvRYjTmog3s0ws+pJ~=1AWSx4foZg-0FrS-Mj+40uzB9}Cif9=5rNCv6y`KV< z^=nMQH619YqaOEW8nyug<=a!tWqsyD*P2kZTu!MP&Z?vAQwA*>iCVP+-B;8HgOXl_ zj<9MACh38iaOpw9iFnG}R-zn>>I_fs#DY32UI|FqD)V*c26je_8T(++M}V^OiE0Kn zs)MdDsPgpFu?rZ-2T9DY>vkw{uR9!4ZF7nQMKk{!@aQ;rrpNnkYwq82v@r==0F1{E z_qgdUm|lu5bfr`XVZC`R*eB_SA)XRDESoOF&aiD09`K5sfwc>dTy*9LYvjIQe7S#0WQA_Zj!nsnBJXck$eTxFE)v%4W<|5(^80x z7H3^29o_jVdH4eV=HF-|3=2V>#v1|CM&3ahMhVuvF(qZbV|mIpFBp5NrsVWKyw16h zxuJN(nmpyLm2ysTCkwvO%#`5s!s8%WBPmKom-Mk;WpsXOK7Ft*`d0%v#5Y+3NX?>5 z-nTa-MOnh46Wr7xXol0tBa+1Y7!mvyfOaaABcMMN^$I$dtd@;Ll%-HD_p(fX(`(y` z$k@c3NB6(LS$mHjK6cL4wNc}HCpX>Cub|EXKh~H2G}Qk1(_0i{5?fYs_Id~|m~;tN4I*!$ZP#+GUwh z1=+a(^SZVIy12PxpCFr2JF|t!=g%R{R_W0lh6-v@d)C)BdQW}C>7IH!d^U^Yig2T(d{Jf5>d3M+PtVClL%>{zQAr$ zr5~8{m{pi@>yIIQgrX%5c>Ow_KC+tO7CQ)_?PjE5_aS!AuaHaFCm}7f-NW$AqkFGI z7(7_3>fZfoXOBWme=t9*Y1#hn*C)lMzM=}uVC%q*xH_+d>y5lqa%~h24#s-SQ%gSp zVTTwW{YY9G<y!h?l=c&g ziME+{eGTd#;$eMjn0dn7!e8Tbcsqi~DVI6~W6ySTPeM&L919|UwkJ-aD3EZf^hSYl{H~f7tD&PCOLK>@hARO~GM&~Te zbO1%rx9g2fDnVB{+Y4cOe;~&4Xzxjrw=_Fp(OW!^qJCQI$ZwQ8Vogc##MGvd}pU9)1GfmNKdYXTI@50rZ8biW-Y|0sa{ChL8GF4)U+a+^Q(4P+x zCivaOon^Z4S9K%hWE@-IW~Q4}OK>x+P=V>Z|;KUWk)YENWYop;6oL z68yUNlW-&BmmDJb?Sk1g%29VdjJ3XlwT|{nM(C&~i%Xv_Da5blWUMO1?(>>c`#YE( zq{&khW?e6S@TDn}|6LTV8ia@10+_6kQQgyB!tsDZVDqHpdoPmh-Zm$7V0FF!iGeUR zyq4!4Eua632Fhw>Tlo5eg(8Om8*T43YT4QGBKMktFTVxe+lXpL6EFjU=Ne6&@;aam zaF)Ib53ABm`5#>+*2>cl_7!AjP19Cig_g9cw=$KuIdrgREGAP@G_Y*)HB=Eb#dK+h zg$c0qjk0jR7}l)lUt~r%s6O2|inzHbsN8?zzB|)0%*{BR`@m}CooLBr^7lQFLslvY zLW>SdQ1VD(McGoGI<=40lunzR@tB5?)>xO`$9GgMuqFQ0Z3PRNsW3tOOce^U+8Ryu zJ1+1qfTE~=J;+9VwU6%|7&q%+HzZg^&9{*CkD^}YcAbfjH*yhxRfsGZs?>&8n z+5Mc+6u35ccwR$cnu3rEc3LP+vQ3hf48a7JrKa1V3TpBNulDqK3;RDN+z^s0X~cf^ zZNR1|P%}RA`>vg2hVP7zraHZhS6;vNg^&Wy3u`5hL0fd`t!Y^Q7bl3#yV%Ke& z#22N^u4=W%2vVZH#@_O`ISlhY&1;7fb}?o|HnL8EQ?ur>zbA&baZN7gceM`tYP^Uupld-_T;y;9QGh>AjiG^=Sy5?hajQJi$)n>=@5 zBPZn~pM2I{x|xQc1t;S)VhnLqr4@pGkv2;^>DRUoh>pG;}=ZfM`J7=J1Nn*a5){IvCHfs z(V^At`Lxu2SM#Y%SUwp9JKte;c9^)^631~8uWgdD_*k(=#P{lMN^d6_!QqexBzm#0 z%{A~@f_=my$43(dGwIGxDgp|m&fZZ(A7uRD=bL{4i{|w77Q!RU_*vl$RR;?1Uf^#n z;nxx;UNlm@%Wluahf&0hUlVQmhPQ|VanlR=iJELB?HXzh^fpsun}lfuR+&br%6$iW zdwR#ihgBV$oqIa@o=JKynK#c$)frS6d@QZIy|vLp5Mg+MtBe^y1X^$=YBxdFLi z2CEsjy50u+cG^;_@s${uLu+#8ynA^&=^m}0`oKq(k~DHi9}EZIFReF<_smn+cko&g z8bM4=TdHCZlO{fwzmH%1}@jX;KxRtt8wAA`QUKa8!3M_hz(<7pWM-$`X*pDEaIwav77 z7LTfvV+ZA@&Ep7~CrS^s6a4}l^BK~-NI@U5X)L)SRqYUAhb7;>${)Ur_Vg5~=T~(B z*PRODkzsUr;-CJzp21$9Z;X^Q3=s-p2iSMDVe6h4U zP=aW-Lc2UawR?cOZQxh)8TAgE%dByl{kWY#PBSe+FhX2U904WO-pKJ#SrddQ+9hVK zyIWE+d>5MSoN}~m(-B1R-MOfXptmUNHd_&&UfMAIDeqLnF}Ps(7~GwR1RQ2s6b9dK zulpSK{sxIq50K~3*sAuMSz5%$lEH^0i9dJXqk~h8Ib&DguLNj>ZIO@*NMce$$xC2c zFwK^wmKgJQLy&iOB07cH9e{pbmE(YN+sqHytgM7kwMM~hh5)P$CHa^)`MnorfX}Ce zLEF`yI8J;>szK1FA<_v=5SqqZxYs)=bDn8Hj6;0nbM>i!BTrQCZLH2<{ zXRL}{lHsO@mzMrRRUefoy!zN+RLfsLEW9SctXylrgG9g_VP+iIq`v-EG6gr;Q<@7{ z7dWrG!vq*PDg*yc*Py8K^@)lJAmTL0O^vfpcKLHsJ!T)MGr?kdRp$LlIt%mWi#Dsg z6Q|L$1PYaH)3c~K!@>TEhlI6)frOlP}|MOs33 z;*^Z*bZFlLbp?KvVCS7}F+U8899DX+4z!W>;QXj5IV1J2w(k3aT3Z?PB&XizOv9#_ z58|PBFNa{fkBlwzFC|Ol{Hu@o(2b?;ot$WfzB`D!-&Z)~LeU+)IKBguCuf?GV#fO4 z6?f$lZi#Kl;;6%|wF6mtD;_pMD*%M>-r;A(CQYqT>V*PBgXuC!87f0ChARxgXjK!y zSOuvAq!u?6apYwgOQFoB9#D$pD5_!2PFm)4N?&Qr$S+u;x0aCb0PMUDE`Wi3z6SpI zQXTq1l!gs{ti5J<+tYwIPO0APxM$BL-V)m5CsRGMHeAn`^>vW~s%paFY)cLX`X6gY z5)Oi>-n1L|FiZMCWB4ejH^hyt*Bod;Q2)`@_S=8EP+RSw;RyD*TOlqt42{8%6mdta zSGBtF*J#AZ)3NIAn&=6n`i_E+5LxvP&r1>IAIVh)UFD3ZLOh!RFp^V{}e+MW( zYTre*cJ&86Y+a&nor2rB?I^Pn&^+JWgLQFD%g6nmB)pU|Jq$x%?IswfKkk( zr+qs;QR_v1yz3g$iGbjP?dL@{y&Wv8{{m>s#_FZ3#U7Ykb+Y-IvSTmGC}Y^2`&h-F}Z~TZJk)I-&-z9 zxhHYD)Zj=?#X2acgKsE4H8*+kkNa$Z8RN?$l7Fp*tj~v7Km5^(c7^c7_YMi0ym$6u zW=)_zIh>8SYW!&J*vV4euCJxf;3=VDLpSn3fEjWUb|4sZhdU+8zn+>pAOwp&FqXat z`>_xFW+{=$hLk1v8Qw}YmvtOWzbNF{`jFl?eeEycwFY<_*3I!yQc=Q zt1Ijk54mbl@JGM|d|T|Ev1hzc~cD^)8#XUwQqzvK{ zXVB2fm7gB#3&=7dt+1B>H%o6V5mb5;&nMfn=S&JI2G3nWSNCXahAclWjz@2-Uy_nE z+4JBX57NyQ(5bsxk>MW7Q`9bW8Akwj(x}4M=9#+3qZG>uR8Rz3jFciw9J?u;#Ya{f zt84;z?fQ_J(v)G8Sj}4xx%2u6n>`^HsY|i>b|#1HU`h<}Z)ALS&tEqtfJ5Lr{8*Ep z2X*I^nx(l{65`08QUzAHxhSz=a)*l8c|af19i|(z%(uNHj$)R2GOr>3$z3kBiL`OM z%$VTBG(XadRA)F+geH?F6hkaM@x{NA2dNBBO!lSBCqx`-veuIU1%?9|2?Sxi|J*_H z0fv~1^6OnBqfa2qkswq#Jxxg#XfJM!U?YZ))8>MWG zdWk37=m|ED4XYqF-|AV>RfUmgr%N;vXzWzU&pFOXT1#}Ye9oUs%}i?W?rx}PsoCnW z_rv@5)k*F{6WW&VxO-?GJKp}W433CZl$p0)(_Rbhtch{f>sYswzp6g1wZ}gIpovfe z4e_B>Yy_z>YWXqkRk*!}020DO%N@qWAh2ilkvQ8=lDzFk2jC7Tk4O!{Mzn+rFl0YM+II9qXMZ8f$xZ zWTxcqPdo4rO6zI0X-0L$ z)VPZ%##7XZ-iItoL=|({`#=iNX?J&8&9eC4gd;$Hq*B=sv?(`1l(zA8+%=iv?`pUH zt>vq-CM_~yY1+@181d_~Yr{vXiUo3Qb{)o6kr)tY=X8BWHKgDZQEM{G6W7jc`q5tt ztjc}z*iX*H7B96b8}H(t<|(#TG0NE>cGXv8m^9RXFzWZLF6US~l|6MK6!1$=QT%qS zG4$vzER8Em!AEUVpGjrJOFaE!V$|o`c}G?+xqzyyu+cbzstoZBuYHRh; zaX#;bpckD{7y;kR;2ybTyN^^7E#w8fKx|e+n|{m9K2c5W(~H!x^i34L3o$d~`$3dE zoCoS*GIU@YEj6M@NKehr*DcLj?oNUF4!e*Ar&)QgHq-#Nb@Jr=Pn3`UcpEPIWCLxo z(XY)jCYS*Hg94+6-TAW!)BdnRlxd_7fUmMohKT|9qbnNr_DS#`!(}JTv)tTLrGA87 zB=r}yZ?h+rUsUlaW^LGOd9qe&x8EN!8==|7tbH+)$#%dz#W7L(!F-Na1_ou^j>p~YA zeM15(3TW^h{7!(><7xHsKC?SA00EQIeRs}Rpv(%(DCMdok)F8alRn@mc zv%~AO^p{F?aTflJ6yw<`;<{t%2O@s~5q6-+b*4(J)bK~~;{zi<)T;1Jq3Z#w2nb7S}ekXEbNh5s}jHyeIR{;23V`Xu6J z{$mO8N6~Q~7g_mN?YNYX1S-9blXGBpYlnlIwQzp&RNbQht~9A|OCb{YDyEey)s7Xb z)mtbgm~VSSygc|bdL~3&1;s!$nKY1ky%3()eE6dl4PbBGJym1-+zm(*B}6CV!%tR5=1j;R#dfV< zUQBXP@fA&i)g3Y#d#7Xrig0vf{<;;~W#F>o>E6)eT(HkxGKm0ua7!R%CFZ z83KG9P%f8t+6U%i*$T%qkxP6ej|mQ)Tg+7Xrp!sNesSvz z;DiLh_g>dg4l(5hLaq)ERmSiz{B=AtX?`#kWp7>9v7+D-A9_b>u>Z@NN0xG|-c4Ev z#T?XpmoCW59s3iF5@%C*SyWl4b_q-0>G=02(>s>YgZutWX-0TnHHXn7ZK3*n8Ky5A z913e!54v1fu^3691jFfD(1nr)1t|4jR89WR8f7MkX|c|Fn(Ezm_&PkU&Xp*QX9be- z9l53E&oV-E^UJWU7d&Xz_@P4b8v{$C?DZmbna1-wg-Z0K>w>HaXFdKG_P+GW zS$*{2OQ=6Tr{dgJk3Tq4>hHJ;iQ@{58r?6E+6(8HCrkg{9?1F^FfaZGnfLZ*z=TLp z1yZ`u{)Kn<=dj=1^C&AT@#k}!+vrLA)sYEeYnfqWu!+vRDP1&FEO=2)s$_U%a(brO z0@(f_Fx;w6kgjltl%y>nC^59B`pQ=3RtP(jcki2_L&zc$#Be&75xXS*Vm){!i1TDX zN(`L7SLkY_94&`w`3|k_-8%z2DI`e(DGcAT4Ot4xFtPU6){U}nV4n1Il@$+pho-KD-m=!*VJ$qc~MB;Gj@P|eBBx1U_I_uXX=qB^EZ}RZl zq*XG#?J7=2zA{6960=8k%@Gs3Py~*&71f3)5>jIxdF)s0^}V;zt&L=A?u=R3;(N7D z4c(+Ow?Z>Vw=augp3=>E_T`hXW&u!Y-?-XwvqaoWpU_{b=H*iwnYG_j0KX=YG|CMB@*qXwDufA6H)tx_I&nNZWjH!9B-!X`B z>UUL5NYc-i-ovg)2tZa`fz%aE$9sq2wVfpoUAYNZW(S*U0j7$Y(h^T)w7;#8;_m39 z2-g>b3dH-pq{HN?Z-O?kUQp5>;ThAyg|f+8+SX(55)}UFFatAdJf-+d0T-z!n}Q&0 znt2qrNt8&iQriCT>pK9dpbrzc$$mbi%qFudJ`?>Z5;6LuclOi2W>|0=l`1eX!rMBG z#X@X6kf1BIFtAD%Kt2Mn&FcV)48ZMTE=tAgT1XtjH(q&VOT!j=h_jv}IliY)?_n`2 zLBd8+mpi)xH-@i%H&%>CR<;x9yyc9#!FG9To4+ddwal!Sk|Brd_21Z5T|b**$@xWT zT-fdU@e2uOq_$v&!y*BPYqMQ|c6jTu$ajdu_)6|6W}dT=ul;d&%kF%M4Z5@_1$DS* zkP~I_Zv2K|?Xtx2A>jzb>0j!F7-~;S6{{fAwwh*bT#9)4LCPSfA_#UQ48N><>|v8~ z$NgF_nDZ|{X{woTY?O2KvP_}nKD|D3dKzi*p_OP%-F2DUTh^-raLQi*N8{C>=eUV9 zR7V_lImKbpJN0$!6obpYG;2Xbyx)U1AuH3!cFxf8kEnmv-_=`*1v5Q!KGAfp z0kD_y)m!Api(&n&?8E#Ypo+zhe*sAn!&vs$L5|PKqss>21Rr*aravpbpKnf@-$1Sw zI+P_u5gW$;N)ak=yVEZDvo4Kkr5gTSV0&KTy?jlGA8(_ca1J%Rh@r5Pi6cihbTe5` zUx+9=R-L<&T-t*fKBP#d`gsCYv_A1mTke6ujbrt=;9y>!%y&|K*X`IY8PT^#aQ
                                              • QD)I5Ih90ed6jSO-n)u@2_hzW4flMUeMZ&O^AxeLiSf6aJ&CtdBY z0b)9UO>fU?8n|4PQ^_3g&_c4(Xihg9+_t{MEzOxT@QkK}`EPd8VXkkplgEf+`I8(Q#_zi>#_Gaa!BJNtxas+qKTV(ztJebc>HQ*G=B_5wgWi>h@W}Mr zAt%xx#!ILa^r?QAn|;s=yS*V@PA9g#jXj5P@d0t+i2F#25qXBhtfStpy4dRu-jqgC z?%dbj2)9NGZJ}ww&E%i-7$lV3)$))Z9mzZF{dg&Ke4iWdZ~+0 zrR<^i*79I6@#1t)o5iYcopD94Th}Juahmgr&@(FUAc)tSG`AHY7wbl>7FKjtw=0C} zYAPWFH7$a6Z2GplET{xInwdJ#ieWCNot*D5>S|lRFDVB)b_L3Ue?N2m?I!|tl<$a3vYzpJ<>uFjA45kf$5(dzb&(IA=@p}y`~*#{8=veE14q% z;8XWHW5*Ru)HznQ+-a6?+lASlem)MB&H6IxzIuNqnLoOo226^+PY;l(t-)@jM)UN7y-dz>SsIWgUSQ7knAD28 zgQqLSJ#R(%-R3QkAk?;pU-FhcPq@{3divg?oYyN9%wVnG_MQw*ind_WGvkK|46=}B zS$oovOrjpciywdS=h`jKCjSkl!|wE`0s`lA+5EWhPzq_)A;X?=2J!llVe>JUFOjQ| zS^~_^2c#$QPR+M>B<^h2i;{nOwNzeTvL!myCBl+1_UTn!YNueev0>jC1K9^rlN!p~ zH6K%lVxei$*Hk@q_i)mp%v*o9b=eNOfBF00thA4)Ie-HF(aThr!|0yqKc3Py@nbhx z2hp*a4ZKURNL_1prJ%on52x>S`7o+!!c`y;J)31XWogwd`T0Is5kDV%zBTSo;dc;K*i-uGs8d9RNIPG6+ z)VH5>;<9*%em81Ki@Ou>#`=zqV_Zt_@<^cC%Pl_MH!^!j#LWb;_g;uEYokhiPO@}u!6S;oT_`_01ZiY7`gZP)fy5uMw2y%C2+8*%SiIZiLgr%PjQUE(vNz@CGXnH{4YR(^ye)5<#K-f(Kk!VyJw`=k^-jwa;(2a zg_iW6ks#`aRy~nZ&`BXA)#A3j z4zDStqUvzYA0XL+zBr*5cfC0>JUM!lz9@cqU10YrM_G_Bp86}iP9~MA$%7$wH_Qb+ z+0BVJL~gKq``-I~E)cg(km4Bs7tk9E!sRij`(E4_25}61c_S^Bnk*|H(Iaqof6a-$ z;`g~=P>N~BdLa#mMko#U8nUsGxBzjxPt(#%LOJ>u5Jr)%UHJ7Ea%oi3=Fw=Hr598H z7MIR9Z!c19ng9Bt?sn2(jinhA^2yitpGUu8I%WF0N033@bi;7^SAV&Psi%)4oP(dS zSKIfts?ZPoT8ieDOt)QJVCsDHcd_=aF=&JZEafr0ZCyVr+_e1YQ_s&Na&7-&>M=8I z)2Nnc=%C%U6k_dRA)CS<8%?%3x)DG0n}_l$QZ`~b52)X!!3x&i{74-R!qe6(V7lZc z8K#2jd2&UH+ezee7RR(%yxXtFIyuXa(|P=Tx8{p0%;iv!^26tJLW4hAV25D&_&c14 za&9wqo*xAtf+B&`Foh?k*6QmWX?#hB;II-u@63^@RJvH-+{B$ZtQhW5s}1U z?@AG99Y9J!qEV-d9Z>J?!OF#9?Y$pJZRQlck^VwAj5qjw&`^dABwLX?y zfA#J+DNsD!%j-xyQ3g0gW(=*d_+!-y#Zx*>2HSHB&0CW(qDva*?Q2P;ciK`K`u(kq zu1X_K{lxViY{QsxoNBdxgHd#Q1-Sz!&I9Ea%2K0R!>H)^;|>qUM~F~>(^>ISx1UP; z^KE~wTzZ#Sx8PbI`t&9lPil1}ZS);P7-|!^)d~6rxCFfd!7?DH%8L4S{D_;#W`aYz z>0(f}kKzEGz5yVPn=Ix+TLT7(Sqn*f*?AB8HON1l<+FiqDGAphG4WrPxKZo7%hlIiRdj#Fj~SO zTJ$nnBt-9r_nh;6>zqGd-m}h+@7e3xdp-BQ*WUZu&t0GMvGZAgQcYP^832I*0CaHx z=ih+a0ECc`h>!q6L_|bP3?U(-AtxgxC1bowO+mxT#LmXb#KOYCCB(yVU4WB?g;$DC zKtvP@g|hR&Wnp3nA#teK+MR4_+ zr~)Ciwk6SZB#l^Ld=7+DvAmU52fN87{?ILmn1qg=fsu*(1`jXaO{j#V6bvqX`;L;b z%3W18UA_DI28Kq)R@OGQcJ_}P+@E-OdZE01fXp1%l>NJxB{l$?^9_9{2;b$&tN zo1(WLDk`h0YijH2+dj2-bYi-?dj^MwzmANKjZe(YFDx$MmRDBSwtj8z?C$L!93EZr z0s-K^)4DkSo!GzeqPpOPhmQ}&C%WVX!t=TSmlleveqtf5hy6i2X0G34ja?x>!6g6>tkUJd5DX#`_oW z-&V#-2va)XVbm&p(-ZRdiU0yuRUY6yZ5d<= zVhOv@H@BYVlxg_AOEXli#@4kJ3=sbO=?W}I1tEt3)|7T~WsJdQ=HgW&RkyXYKq@Ke zZmglz0NTG|H0N*?o9C&bQ(8z?ETXU@@e|E2Sx@FF@wE@>jd38dAYQp58>Z|pZYDEd zS0W@)ojiCa4(f;#lT>)@yR%x84_IQAXaMd10t}vQ2FZvoAZ5Q>zbKh(IW~N&hK!1D zIrLiaV%+a=rCnhs-+jQ#?JVa_Vxr22YGsk?f%Uu8`yBs4ly{<0Iq1PoGHo(L#tiHI zrjds;x&na9$i69T%tYZKZU~ae}FDPROqL2 zU~V&;MLy=BU$aktwQ=1=y60V0YM$g0W{UmV?2k40LY8Q0MF%^T#5q8}s_*0ZW)H_~ zOOcv8F<5Jwla8(x90KDIPcS_41T@TYHt-Kg2%c#Yi3d^Hd298JL* zEdP7y$XI66snry^MB`5%ZTN84I0!h2g3&(vJ15>gyd`E7)JzeHg+g{8DjE)51};43 zZMy}M!M@WYdp_US++S+QV;jhg;E(%PpZa$n`>lBy_P~nos7kox^YM_eP|yC)k{#bi zHLe%#^)WA5NKOCi)8@_IAD3@iJZQW1y>iKB%VpFqcgSwkEK+6QLaiAAlw~(k&@E?;2=c{~hcW&PJ{TYh7jBc)(rNNdmq~{}y9;fD_e(e- zq^!jv5T{beVO>`@?dYAN%^8Kt_jQ%%Et@(~t`VfrYG$2j*Ik*|o1zUNEKz}`qhYTT zmKCd$oo|>5ycia&OegG^5CL>s7&{@l7!Li&Z;UfRuxyH?MkDvVewvxdXLh}oIG9UC zPdbZV9?mj`)PLb@Uw5SZ9rh#ij^$S72TJih{MB>7l&cJW5!d+DKOG^^9HY)pYV!?W zdBWqv6az@9W0rxflQ&?;Ib4!Z-h65y6@ROJff3^<2Mc9Wc>@pU>7cK{YgA!t94e;w zrar48_i10dtIGa^ug_AnCs|`jQNCwXpJ^TyTgBy7cy~2u)GfPTY4@Kl3}xA4a*iX$ z3qa(WhonGk#^1G%X<+K{q@)mRnnar3Yp8`RsWQ#xlzCR%yP|O;6YqhxW5(IL^M9~< z0mYL+G%+FZ7+K8=J)V)hGu~#y*cYyeb=RZ zUK+>}s`<2&eZl-?0RPC`!7Z{g3iXTF$}}_)o=imYhKtiHSua50j3s$?JLc0z8A6?&RRRcPKa2j63G1P5tV0Xd5B}C(T4#0CKy*gM`NhU^ z1Sg{?0Rveb2c;W~hXXt+AyM`AlQ+_nCo^g-p#4{JG|6(3?!Ib2Y&Lo?EL=`@7z*|;( zjWemgyz7J)%+vO&s1b{@*ijlMe(SJzJnx7N8wPR($}FH zn_^Hgt0eAW_Ld;jkq^nrPJ?}MHkx0C@jztheYyo7}(YZlI~Hg?)b+SZpthiucm6TIUTr zjck-hMru+TQx;qJ*JV;SPGsh8%Qh;N?5tZ%n{CI_SmA(-rJ&#dpEwXFoSpwsnH^ox zqZ>KYz19_+Cd$vrw!)YL7TuJ6V@v#>*bO~?vN5FUD45jq7H>(z?cFTzau|6nXgz-2 zJQ?IRF@hj^sHvj%&TTZ_ky7b#gp)BNlbztUKwzQ;%MM5P*eSN_XLdwXi07U}|LQ3H z{?qHDf-~ROt?ZzGw7!>0HEd6iJIS!xkBsug1xUZp<7HWnsro#1V1Bn|xKx6f8N%_g z-fgHaGRzH`Rd5$SaCi}|D)BZP;qc9-)7R?Ommodi&-)Fy06CL`q=!e(Vm)Xi&(yj< z+-cjOc*$tFo;;Pfjy^2aY~o+=yfr6T$@vkTbtIH-#dOPl9!g*f{$&OaF{F11BZKd{au8=I~Zczsob;-;pn^g^}P zHF>(`%CfW8J&GEW)7UfrlaXIX%RiP`y^lsppD&Obd>Wyr^Aw~=5vM1-Gil{y<#xO& zz32*C&miFiS77C?uQAChq4u3hg~=u6t&jO|sJ*#H3VOxDamFSV@hsaj*@~R5ip+=V%om8>5b_-NX=s zOM9j9x?LoyX&(H$xBg*aCtZO2unI=-_QYE+q2-djl~4p)%9PgP)IE zBsEirC!qBEIq)tiuYaKiwvpjJl1cdfShAOG52M{7r8Xq!yuotE908V=ZWB=8MAKg!L68ws@bG7OiYAZgWkH{F#-$J6wr^IlP4BgDN7Ts zqNB3i2<7P4Q;zjb)oIq0lbU0u8=(N6D$f9*RmNi5) zB$WkCA~au9ei@98_mCxQKn2h3MSC%pKiBkEd2C@S-KWY~-ZfDi8I36*X7wiryoG8u zkK27n)S-KF{>6S(9p&5f%xMJd3}0@92o=6kQ-o`&I=nH%nB`4vfp%_bNZG z#IcPD7f>R&8|j}R%I0@R+JX|q5c$o>^v~#Z`kW7U6v}3|XLa~!rf_EI z{e|6`1zZ{*ZKvMrIptjA8>62mW)gvtW}=DDz6*kE4AkzCwTqk_es8=)m$7XauTPxe_vBlRRnraXq(~4n$;kX*wtMuo@2&k+Qy?uicChZx(e0gH4Pv zGMsn%a-v+Kd%wHh?H_mr49EQ9OR@E=hU?EaN-cP-B$^F5;UNhc?lpUvZbVsCBbrAi znx5Vb2Cth-pWHE`#?)sgef{&leb&R~fl1=f}=|}OdsWkI9zCp)FDNo#l6>sIRLe?N0BlOWi8OpAgDERNOP#}_{bP&P-%f$e@4 zOk^cH-RgCoE$S&PAU-e1TZpVn%a0|Y4$MJGjM2OTz#aZtd)JJ-%oFqC#d`(RVi5(U z*~LFcUwwXe#BDcyoPAl#Myr!%SiI8QOg?4uJzYI%(j6w*Z4Mj+d6Xz)MfD90o0;{Z zPuScOGd4wkWh_J;az8;+Y=w@72p1&t(#=oI$-g3$QK!m$EqMjfy^Bx%U1bTDf!O?- zuUxR@c@6}x?3>B^3%X$g5bwoTV8u;BbVDU<^9-Om`mUA9<@=!Nw+|U{M#b{^iys!NsjY1#( zxDfrcYL~mGIa!OLOza@`jY)6LnxR zd#|d@6XZn|^%zXv)i39wL<9PIppKcy3bFKkfO7sJu$Zd0r3SG;kyi!I#sQ0zBCvII zI>wyF=|p7?Hwf+J!`j)1ce?=`{DdII^2PY!9dOPUm6X5Kewig}sofXdu_Ey5%j%YC zZoNncv_}V*&KZ8c=w?NdYD4vpQ^Sk7>A0=k1L2YlzBTlEp84|l&Q86>r7oLC3KlcF zq(cnPM^%@IFwnZ zp|$-|tadaO`@-fL7f0||M9yYj`;k3%RAH?8D8%U(xaIgRSH^M!C@}a74OI)QZcBf1 z`aoJWa^o1f^?699;w7eLrhm>n3G|@#7InID8nnc{Ct~aUd(B{nK4f&UG!ajH6gUI8 z0@{IF8U#eyyj!}tD-1rlhlY>d+akxLQO{X6`hgicMV4!CO(TMbe$9M^E;FykS1xNBXKf>^q8+Z3@G)lF}H2 zqeWS((#bQLGEgckQmSa1@WeKX3pKkCd`{J>{U#@+qp8Qi@{<|SeLTjju?CE^OqD)Cs2Wxpx2WV-(u zzxlGorPp6npjkKYDk`3?8+*Sq$38wOz1Sr%So~*?^E9({14iDATj5^m)TpV9POd z5eJAVENbmTj*xwg?_ra9&wfpcf6GP5yDh(pkXjJD{i&~WjVzq%@Os3rgt%A7>Jz)gHnjpC zI8mMD{UMRgJ!pB1aR2F;vWQ{8cOxpAl-I_v2HeP8I5lRzCs7%l|3iq@oHO7BGkl+` zRP;>CDBEGZc%{0gPqMLSyHo^>ciSqlQvp-u-QS)|5pIDwIVw8~+W~d{wOu3H4eRkn zw{cCg{NTf;aAp9h~Vpsk`YH=a`b1#Q*I)1)HSLu0IO*~g{hLYGKpKK?D rb2Y;aRXnA5=C66?*qcybq^XGwfVF^E09xbU>N5VB%l}_q&&U4;c*3%V literal 0 HcmV?d00001 diff --git a/outputnormal1.jpg b/outputnormal1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9b8da88c16ec035d411231b26fe1105f1bd5c6a4 GIT binary patch literal 15367 zcmbWeWmFtI^zb?8;1n$bLxIlV^59aO;%FcMI@LRZ&F|fPn!3VEjvfzpH@P06bh= zATACb5D3J_$0H!3BqkyxBm$9BkW$jqGQ6Ot1%nx(Jgkf_xgcOLn+Q7>FQ1^GAOowI zq$s}xkANWm|1^SukB?78NJK+SOvBFvX5#<g21Luu!pg?ZAt)p)A}aRkwY-9&lCp}b zo<7XL(8$=t+Q!z--oeqy)63h(*Uvv7A~GuaL(Iq6l+-k2dPZhec2RLjX<2ziW!2}V z=9bpB_KwbP{R4wT!y}`pnc2Ddg~g@imF*q$?%w{vkHeqm7nfJpziJAFfe`pWh^pm940;KsfHVM|w_v;(2)_UB zf+FJUzo{#m{3cdst;9qvQ|GxvTVADAwZaSj0{mv*Ped&T z9DFnRka0g|W0@#-o?Ws*`&djL1X^$g22b$ z`vP-V*-?0sL!W+llCKP`Tsn%!PC}O`K(`-EW>fob;3gBGehzk*e|;F(R`Z?*Bd_~b z{T2xZjonLQ>YkjP+ZkVIV*iZadZtPFc-ALf$zvb$gAj;LG+vnUB)stpF&W-q=7o_ z@Z=Y{ zlnY5c0$kmzDt{*Dx5O!Tkacn^i{E{;Jh3VTvBSXT)rwmCZ3FMfSz+=?yka-9FVJvAn8oYa{ zl_$4wE>Fo(7kFLD6J{09LkUjJMj%lQGCtb@HnT-p{-(f8a)4G87{#v=Bd_$N4oG0?Z513NxYXNG+FY@~#r1r#J;RUBNMdr)7>>EU-6 zADfU*?*2YHjEFIXhA1&VO046~x|Z=)c1q#^Is??k8)C!invqX{{kkYQ&L&#+OQv?fitmR$i&f<${>kFmVaa( z`-+LKhju#M&o0|S6*c(#emCjR>@Q%j+O}oZE1{TxIobLN%Ummp2UJ@U(`cuJ@I3m! zdbcQk9`Pg_ps4iF7V?PM5(3B?_6wizx_?XZOf+u^wSjj33piTT2`TLNu4wHjHuCS( zOmF@eNWBR%I)H0fgbiLuZ;_)unied>JYJt%&U4{e1szHM}mHS^v(QcslJk2@Sd} zoEPYLSmDz5hL*PJE9v7C)rIv_Cd8JC3~)krx~e3j*3FY3CY-pca+vD<$m=M{cm;?Ioz?ALYK z{!yFJJ>QQql=JveeCcZ+#P91FgVAauZ~uK4|;`L>a%@idPs(HTX}{pcGRCPflr zb>>R`uR6b1Bz!wh2D^Tox_MnAMZhme`X5QR%@#7~oU(TWkL45`TRv1NMGYUAo7ZF{ z`wb1P9G-g^_)*rcFUhs{J^Tf5jLkq|)wr!rOi`O81y~rU3Y*?Xtpk%I# z2iMip?4QiKNJpY=APgI$9?~R#0Z}IAxSorc`{KF8+}3)`yWC(sdk&i90mQKg{KRab z&DACEW!p@_*iak(N78fBRIx`5pS+hX_rj&6rjRsc=Jt-rkjA}q&f9Ql+CgRVzkneV z?>nAV<9F#xqLRuHq7~U>(s8vhJyABdk>R||dN)})r2PPf$;K-}=J}}cS^9Li1OgmF z8Tn9sN3eYE-SuH$qO7;J75T{Hr?bEB4A5d`l=AXQk;)SG1WAIY|hU3g?u0 z_-<;tu&;IzhuNs`pD>A_UQA8#|5WEYn_{{DQw*1G&rZX`c>1-bbzPO+sUX#r@sW-> zFP}?$TnSTV!0n+&3sv*84R2*H&1vgf#*p2={ZmevA;H->EXj&mE9NfkB-)f_&blG( z`T=-d=c#?KP&z>E-uPVFIq#Xi{mr{R>BV1lAHMkvp^fs+c)blwJXOvoxT4xEaLCPUDkJ|wYJX|*?cO9*~IoGen=-f*fs z(_={gDmI}L+SRBUD}p0sDHUE=K=)-ljgyGuy3|Kc361^0(? zh}mq}06b?Yi(q`nD?tn_a=%GZr_eH^#Bb%P|80g%$czKet@C=CqZRKP^mDfMlgXN( zzesRIw@%9t!}M%qM|ZT6A0odGVc0eE^v~ISvKPyjpY!@tv^M76k(P)HlNqiTTxCbM z&7QhU49!QgGxgWY4sn!4_K zEmCY>j?UhH;(O+mzzLN88uEzS8BDOe;%MiOami|joH~Ez{uR|xAFm9VzAB@axB))h zR%d)8+7GfGOo{?~KTScONX>Hs^m`z)ZwIFQcbzO@&A+F{2+FOmhlPgxYN#52`AbB9 zhWxtZELh;SnikqFT{Rc|US?F%#hJpb_Chh3SanT#<=4ZnKTkX6N=6Cqr(B<>a0^T? zS>``*WPD%_RvIwK7B2NXI9woCb^#4PH-(341vmc%(3%WdSM&x6(be`fTl#~+5iY=u zyX!$m=gsBp@@Owf*8V|_@jYlm771~W)MewznK}lAa_s3o8zjwiRdcKJVC+&$-1EtL^iV`+oiElCUL+fx_c3llzXGR*Q==#6hH#R{ScIW4Rn)GCMf;E%&rLNy{y9J#PzV3*JS_)OpA(jI50h#N zk=2qnqTg;+BW_z<{_yK3eS76)C9+C`4F69&EEz4-J5?+F0QGR1EzIte4U@M=AZ)>G>-nfSUs32l^F3-JVbk=JiylEd4u%&|d3rHeB!{`Z^CO78l zFj}Rs1)y03rv2omhCTV_mN#^t)gfqPn zo0>hkUBCzrN~PgU%q$iD{27-sMO^pyj6+GC6x~>0R_N5@W*f@V%{psj5!@%_Hoy+&O&-|-R94giM$H#bg^1%eQjJ{>yFCbu{W<@ZIV*`qL6HhDZ13XTa$QBcxh1~ z-7Y=zsYrfYl>1sm+5>(LiCI$s}qMB zqOPAS`q&u0Lr-hpZG|hbqn>iH$DGrn)LB5jjv-U)>OedV3ETv8ewVrRQRYM|ac#(` z0mxcve?nrqHj#p21@7C4{s2-@wvx4C7UHkY8BEjQr~$MjNRSl0!j*g7TBXtsOQ*-S z%xU-yE?eM79Od6XJ_l8m*jLul$Dow;BI56KACX4F-$WlgP%pK$E zT!gMqa%?UW;sCa;CG?_7irKUu9fHs|u~J6F=}Ss=uk;nEm=gndcscG@PuB=?NV@c$ z-3pD4A$cU8Dr-Ul4-KSP^`J7EL=yk%+UF?Va(ZIkfywO%`=1=JK1$lPP!-FR02s(v zW6Yf({cNU{=d1UNJqBTM1Dt`BWOC6_D}I&Q0%R^qA-d^>NvP=Ws(Qx@bh#vs)2gd5 z{6(U^ed1LD=Cj_UaeYsrf;uZ2Ba$4f)a)8P5)VaBglU3HiG{lW?8P7neC~dp9n;Qq zh^}(-RlZ4_Cp(Skuv3pK4IgXHg@R$aK(y!<2}d1l2ru*0pAL|p7VzChPA(!RQSvaJ zfxzfto$o|P7_cJBI16IM!GnB#Sxj^LNo?4OJ`C7M1rnoKPg2GF)*R73dZ(wITmmKn z&yb4*Eing+&zVj^uZ96LSkQ5qMxZk*y9UPD%~ z>q#-t2~lL>FVY=qM~9xL+XB-e~*pOKxOGq=0lpxwwb=I%XBt*cWI3PHj*W_>O_ z)4?rgNWA|alxV@*eAi3Xgt>j#P?8G%C-n)l%z~HSPlDFQLa6HN%_qo@S0N_)sp)T) zc8Ug**Ynqj+|PF@uD2Kt%!4!-TjKy81z*^Yuu%7NW=W;gbcC`; z59$NX4*Kl8&RbI#!Q`*fBwOONe`I$_Oon!|%KHUTt&TB--|MZJ{q z68_~|c%IWZoE>KW78zE{N8h1u8-($*ylp)fY_&e4JDsPpi+FbPH^8Z_; z*XniRz0D{*=71)EWC{2OPDg(@zvi*D)h?F+ zCoRTC#$+O1?vh;~DQDFU*(KacDitJB!*pmsMbeB0C#TLbg-gBvaUM+=`nVTVFy1FE zq*5rnwh^(sv(7GMPLr|*{c+J{g8$mK714s1j7x*ou;WQ0tHCCx3A=LVO(IZvk`~q!>^R4HYG;Qi=1k8<_ zAQbpk)wUA!M+^v(N{b4|^f}1877K@Yukn)}!gk+swVr-0V_)kg)t49BOfdBcVFC)$D75NpWwcKp+7jSo!uODMYW5^f{60)Mv4>wKK8Typr2#oz4w;P{h;W?qu z#}xh_cbLL%&VKo&xxRg<-;e{*3>&2J=tR>|gk3MeO8J-L339K1qE5)Qa<=0h7saRv=2liZ&73}GCGon&c zZ10eL-VE!a``r-Lwzzwai4uuhM#Lc^`;vmOTX_>ftLX8*tebqKD;rkx;}2H>KlQLC zXE7Oq?WE9tI((f zb4wig%MaQP{*Ay)w=YvMpi z1vwvQV@tIuM;QEcOFdJ=Vn5zkL&0b&C;epHWK8&XtKv*1EQzmX1ZAiWIR#K3F#k;m zLCm+e92mXT7h%nfqrWSxvXlrsv{;3Ne<;NE$SlFf2*MDXj6}4vNJJlVYg<884TgDP znCEJ&@9Rb+cLR5Oo>OC+7^^SnFm~wzDsS(FF4ga~1LWwp4oqjClck{CLn8G(DmliV zV`!-xL{_bx942yn`2ePGo{O@vR_<-UN1g`%#4r4~hkcnk=t48=2ngET7}QS}nxYYX zbm|CS5I-k}&sk?@CG)Oe-0kEvrt1Pke@j-q#@{7P|LmH*F2q z7jJP*PfEo;IRrD?3h=FLs4XM@dbwGXFxwaja7%RR@q22G*zqZ`mCFUH0(0}{-ifKrd;I!VS zvHYVO)8oTdp&#?*_2293iRURlu>0ChHfhH{sl7ty zkOmBO&(s!mSh}gbyAAhdyrJ?h9JTCqK|3dA{jS_5!wYX5D26cZlzGj|Lx{b`n!a$h zVX;a)<7ld`DNx0`g6_0I74(o+1D+ZP*LOu^nxBjkp;*bmM|ovrLZ=b2yyl2GG!Rm6 zVrfjK=z~Nj9#9EA#;@qO$f^U$>7RKB#rRj0gsWT1GV&e0 z9?_;=>QC$<)9E~A;2Wk)ejcivWtS)q0U~baSn_^Qbb@*Ea|%WWB{ZSBMq7!ZhdPnc z-#!3qg_)v2lPYI=DC$OGvz%}bzu!W1XRkj3R>WwIbP2;T06b{eZq@}B%l64ajbp4S ze5GWIB=V|i1_12?-_1oxJQKe>daYdI&Uan-kQNPV%0d(_ z+>3y`xtf>EDR0k&B_|XZNtP!io$O^)7!PvvT|s7hm#MF1P?L!rjC)SF5XX@tgE3)u zTn=iO<*B$Xna+}R)KCD-e)1GJQ`>19L(f4SgUAoyUQ#L;8sx=tyMybFA}#p+PdSQ| zF-WJ{so2x_K&*#}bM>BupXJPmr&~#+Un$sIgm!==5Q;McykM-^l?+FV!9okk=QH8n z&~a6FCD!lSP$FrcP?D?2ge~M&;H4%7nkWqZa45(kFwTZI!n#;$u*gF$`C^+AJW@y% z?730j#0kLm2kjD!EFOCk);9^2Ft^$y2iUh=7tuwE%sFv zVl)`4x_M?6*_lx6;*NJ@bgBB8S7R9`TBRG73TFu? zpFEff>$wn7;~;lmX5DOlW;v*MGJ8X^z#sKB46{`1zZm*BQfvX&%ZE|CZR1sm0E6I3 zgtJ6^@_04d*1KJ9<8+5SVR!VqLP-v)PPr~DCcV@)hRGbH7^5LCkJs{v(HG23VM6v1 z!KH^nIu&;2#?V*jjn=(vT|9F{H25-AzpT+v+raZn`wF1WSlgt%u%alTv*ROb`;%C| zZzTxBO)eS>@kH5IYA!d$6_`s`M&i_oYHaj}E%)_K$#CXr!>5Z(m|Y`tdy`I)*Hy=- z9bEWW?Ugd*9tlxEskDhFljAA96uyPe4(YM`!TDb2c~{@IR|_mp^fbWGbb@u@u(fWDTn8#G#cHa7qM7MqYbjK5xdrjip2UV%0RnginVhC?o<9HNRpmj5zl@& zq6xc^F_^t0xwzS7nWZ?^%Gdr~i(z0B1=;AETz)p(QDd84yD4?>oX%Nf1Af0X>qaq! znW~Z~z05V0C1JxTz znWW0uOaaKDs$)t9;#_XT-IXgy8T{-w$YBoJy-1@PhH)+)8l(#@)hN>CFlch5u8a{K z@f?#(mY4dw;UY}I$%F(M%GBo0J_izuk8nr!u9r?b*(kIL~U z9mQk8N#F1vy%b$dph;C5iOoAf4vNjj%Dsh{-L_|n}uU<|0FXZ>+)vVS^AS;xw z>Z5z3fZ`8&oyKlrHczJ8%l6-%`KXeQTIrN0wo?!=Omq`gOrzX5GPc**<3AawZ>tPs z4QHQOinik;PXq$IgfzF^tU32FV_vnju(C3I#EF}J7QyC|EV`c?;C0aWj`zP6ye+n) z>nir$S0}nNd_Rm6Ljdg7uW7yk#I0981&x@3tWYY-rZ5)1pLn1Lr@V(z(@`Ahq#|WjtBszV!-7>_V*0SFXGo)9gNUZtvth+j;9EuL*fKb#c0zo4a>YtkwNBW7E_A{U5 z>}d(bIE>6s``b#Jc#h?4Jv38d_)C!BRhUzXpoWm&`k{!n-Q6UUsHF=T;6k1eD?AYi za#u7+2>*9j6YVXtNs^rs;>_`E%Z{;JWR10YHSf)d+(O4HcpfDN%=xkT?Itah#qG=S zU*-$RkvNIL8j3XtumC10s1m!f&EefJs7lsqB=V$ph;Jbm8+r$y z^RC#=fd)paNX=a%ReXGx+7C74ZFZOz8AAmUvnsxES(eJL1%}P!ji3k%#z;C2bs*~0 zhPG(Otrr_D?uIGy-K0`;d(U4X$G?0gOzz37sZ0_#JQpgJaKhlrPlXRT3uO>#dW0Z@ zvC+2HNb&S8@$v*E^R}qJfceUezW~_@pFEad%X76ot1i+(5&KCJ$(+)CKK$IZg9qt& z$+z&f*^0V$1$Gq>@_YU#QC1=JV#U11D|&)gFXXGH$FcsCHlsc9;+BK*j(pSom4wVz z4?EFy?xDYz*Yb3Vn9#|Pk-BNWsWU+tb06$VDe2@Pe{R9~(vvEql=B+NKV_*s7UTVa zRG<$HpDBR}i8|J&xD#`$bEmIm1=+sDA#a;ze^Hh3_zLf+5!raI&U8JvG5oydY7L~* z%}!HDgKAC?k|)Gh0%jp;k&ygM_wrWuG0GIz)b~_cC`_~vrzv3kn4c8B(%vGt7mT;! z*%&A9zIIdUEw11AgI@+WOFFY1+9rvARaLf)L_(o?1NzM@%04HatlFY1DV+Uon_nz` zT{}!^J+&x|rHhTA8BAg@rp86cMy`wa)6Bmou%xV@ZxF5D{8!ecv6Qh9V=b^uvLQ|$ z5ewz5r1wS0as;JCYT|O;h}GuGYrzdqa`K7hBt4B_tstjL3guFNDEu#AvCIVTbZ#J) zTH&@K@NOpys+rW-6!oL~E5UJm2XYpq;=)RD9LbSG)pvMeAT=-a1t*WIzD~N%tXJkcCGCb-)@b(yDq%H3*`y;@rB5w8_ z4|9^`dLP*SPz9y7^PP}ga$(0ZAsV>hRLh&S`=4OeDD>owhNJxN%c?HVU&GihI*PV+ z`ED>kM|m0|lndLQ*h^f;Cai!bqpFM5H92MPQF?-f5(KUtB++pK61~hwBz$vXgo?C@ zcnzEwWr|il)FHQKjuu1X)~y|)XeM5mN;ZwujM8gcwnG-$%TnOp25{J7L3vJ^w6G*Udt%jdx{jB*y+_)>U7S&Lts41f z5k|6Ev5H7*JGo!omm6hzUy-1f>1DrJR!QcsSTD-_ohVO0idRJnx0))$1r-@2#)hI` zol54Bxp+3q79}l{COSqEQ@65nV}OH+*G2)uD4>L@Xxx=;_F-I$L8zfNSJum8dQ28R_e{ zvTQZxJa4*5Y#wtG@0NzSWZcAnG!xP%vX-dr*qr1*Qj_X~g4<;KqfxTbavPfP_ zCWY&+0GE>?&6)+LKv57_&rL-^6g#oGO+e_043@VA@FkJ_N!v5zLY8&_A{q`4 zh}B~OC8B4kV0&vAKWVnme;mulF@BRh31-%r7}K(&kqqQaw_4rK{goxtH18;gx<0(Q zo~+Mma*lOhqp>faX(=_)UUFD-=*K*NrJQxVHs_+wQJTZr<4m{bLuUkE^Szs2^-VZg zp*F9>;MizcCX!2!w`qHR4#tD+NsiEfs%E*`8jlf3$`_fVR5S)=d_MwzSL!sl!%a{5 z5iNOOf8yk>T`+|%O9ASOoi2P-@?Ts^R{_l^D{+256?W?=8&hZMVyP0uWZ?BUic(ql z)^#nrk{Oj{YIn%XD>ollEk>D;)GhsGO~2vIHz~yzW)Y1v6X3fQ6ATD<|3DdU0Ciqv)802mQ}uTKs@X##7>V;$_sV*QW}#q_x1^Hx)|+n@0d5T@~f`;I|b zD17u{r1)KnCn`LUU^H_tKGbVaFq*i@LF(FL|N9W(%h0@zD#nrO?u^(2uQj6_&CwEa zCeYUJ0@Y_HT3?o8tHG%HDMk{}lFKzd4!~4Fjhmy#zc(W>E?{Lrq5zF{Fh@q_jO*x@ z&xG1OeWA=jDSo3_hJ_uS(zqzAB-fJf( zDIP=$b0v+ZZ`Z0l@FXzVe{IrPVY>()Fn2pL>p)m10k$L3XjmN;<`(@h)vn3VJ*~5Z z2w|4>I@76iUDZN6`-_9tXwInxD2RdXnx?5?y-AD!N)gRjFMT5P|AQJvy^!Hhu zLbz&i(rIGHb@>>-GM?<>RaK9J81{QF68|BM~wDN81Ti zY}M-;aVNn$Ge^{vH_Xb{LY*0x)6sRJ6FTi-b#~;Uu#;iIYAF)X)0+ZP6IyRVJb#a{b{r#sob8PjkHHXhAOKtWNqA2v6x=8{UstxMz?LpG^^wc}d zKBVopG~Y8vWQeayP^=yrY>>6@hAWjjId$T4=wENePRyqvKhd7PjkP2LSXhQ35kT{{JglGI*zugR9M50)+hrjmFOYvw03-o<|;Z8{uQXiXDDzC+e zz613aK*G-siG!~t`r4%?>2p2@-*&jmjPB~qE6e!8LjzzIRVC>z9xA1uf;1WvWp*uQ znlSCW903yOQUQ-1LkSXML*um8Ws>JDTps>`t)XjSQvuKIIMc})cWr(Ze=TKA`M~t{ ztC?PLF508F?3qW}D1*OlF2@`f@Fe_9er?k6N z%bVRk{%1e&C5KI3GbxF>#OvFHi|*slv0VJeBa~`JK)lLi_O5;OYs?0gsgOhBHmlocnoO zkCH^6ym?`LOg~o2I_xS!`hu_{JpmUe?s~i@tQ{+{yjDs?qkU3Rr7SeCG1(QEb9q$( zWpyKY-cXrO=g|V%%jCV&o5Qn;vQmWo)Kr;}2!#?*=Id$6Y3~_+6)UU5%6QW)Cdm=0 zLG(IzjnS0M#%-Zq8htyfYBbMn4X!oHvF${9FGHkF9Kspt(} z#R{+%GH5rWR!lC~mKBBmo(lLBI7%R2_3v|yKNd7x^Z0(=M$RZYl?HfTxuZf0xeQ*w zlFBNls|6U7JV4kCCS|ce=m!O{5_uRFh(V-OM%Du|#dvTe+rr$G%^F$d^Tm=?ff)74I{iaFJD{O({nIGe-9cXmbJzM z&UL7IiIlnyrD-z z^6KzSF#Cq*mSyXWgm=Yn;<4!6yJ@eXYaEZ&3~-yJhBsEY=!t4RC!h6f*oh1maGakV zFJ{u36&$AFNJ5B#d@-jM561K_Z87Y0ENXKgRH9Qpgh-vlB}`ltbFi&-r09YDr33eZ zE3nP$q^u)y9vwVHa%h8lkQHVtwS%2~Jo{0)>$aRCXRZGBM1?dAufQih><3C+Jen*Y zWaiEuQeA%g@{PGHs&Gj=xa*h*aqh(gZT-n+1q_EL((qBK{NV32qY`C3FWGl&%W^Nj zn2`CdYI4lneEA6+m*rZ!@34a<_Fo58F`zo4+c3?oz^=quY*y7(*RaLZA)OULRP(t= z`B`zYK7@xkGBe5OVe@4Z#uk{iu!V6tlT zk0|{sTQePYXku}T(A(W%u`)ruy8Pdd72NShZna%*cAQMu|LI1IBGkOr2;z~!4fvk% zFQi(kd_m1Ap7BXTnK~s1nBln9)0_EpL3=ln0RxMf9+2ipzsPu3&=}G@5=^3{$)547 zSYdC}%|0PdiSXdoIg1?X4R4Gqd^Y^8*+uGI{ytsMfDZpC_rST*JJ)@Xx+6Js`nfd| zEIw_$n=Fov1djAEPUnW$l{2nzg4~OkrS0-)r;~ zEX)>II!PHWvwX+Njt}vXlhQ7BSEClIV^Q!cik26kd5-$p>Tv<6(dGS|%4sK7^&dz$Kz{GDgyn1Sgn&c13wF)Jn})c{tTRC|s@Dvkf(%Sq|SsudO=L~5-;g*VqxDRlwA&YK`1 zy()bp65%*L{xjRmt=UgNJpJyd^QN?L+2KsGr#E8eUCHGTH#}OUtP(Ey6kaaEGYK}c zCJQ&8p?w$P$?+w+23o=la>Zm<%lJI@nyAp*1}t6vm?yhbE(Lz|q%^TDdm&{WmOlfZ zhVahLR7WYc4wBgt=b49Ik(eGT8&IUw$qoU^UGWWoqF5|u$ zfKax^@%)a)EOb~>xkwJ(@>Fq?)NyIQpiF%I&z)ndBV*d^h>Q3(Z`Ng#&WHqKJOv+y zj-WPKQ2?>x@1H*3EAzn047U9^0%5Lu^NF7EMEdS(4UI>6pkOBz0vB?&6_vx+O(r;l z=BN(tJPoE~jGWy$4{}_p&cw9ot_GQIQ6XV#g_JGQv_z+`c_92Z`KTgP+9C+et9oTMyu@hb4qQiP>84QCb@i68!Lg|&Z^w!qcroQJ( zR*8b0M!&~eSrSs;Yo)1XTHbaw47{eXV|->gUzC0KSbNR=T+7(CiPP~0*VKXWlAK|K z&pC=OC>)!>Mqj4|lQTz;Bq$xvec%}(QD`7M8{U1TQQpB3$)y4*tp?K1`D$ zHt>4P3c-<|yen87`WL`<;tFgeYSmqj`!ebR@tPfM$dhfT{oGk&u6mlX@I`!9?w>FSWGrucRUpOa%)Gk<4Nht?hrJm zfey)DPGydMd*+{@!DN)}cm0*(jbpa$tW>?bt}<8h=Aaj}&#~n3EPKQZQy?9iV*u~I zw94^_E8Q30+R;(s`S;qY=K97V5Hq1$j}-{I_R=-XMnX||`_~coeC|Ri(Mt3u?_j&o zl2(!IOpYHI%iwpEe79`zzS!DIG#HAWB%izlm%A>(sq3zIlWkJE>Rop1=#_6qDj>e_ ztTD{ty(Jd``LVjcfNx@4|9SfJMAo}ZCi(7jK}dH=IsF}qU3=?x2?k$sygxneVrOsp zI9zMqv5+vCM3Tofz|4(qP0^9sLu&U$U!eBPYHK@FyXwed6nK Date: Sat, 27 Aug 2016 21:08:51 -0600 Subject: [PATCH 186/233] PTS fixes --- event.c | 6 +++--- ffmpeg.c | 42 ++++++++++++++++++++++++++---------------- ffmpeg.h | 1 + 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/event.c b/event.c index 70ca708..f92018f 100644 --- a/event.c +++ b/event.c @@ -584,8 +584,7 @@ static void event_new_video(struct context *cnt, cnt->movie_fps = cnt->lastrate; - MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s FPS %d", - cnt->movie_fps); + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s Source FPS %d", cnt->movie_fps); if (cnt->movie_fps < 2) cnt->movie_fps = 2; } @@ -785,11 +784,12 @@ static void event_ffmpeg_put(struct context *cnt, unsigned char *u, *v; if (cnt->imgs.type == VIDEO_PALETTE_GREY) - u = cnt->ffmpeg_timelapse->udata; + u = cnt->ffmpeg_output->udata; else u = y + (width * height); v = u + (width * height) / 4; + if (ffmpeg_put_other_image(cnt->ffmpeg_output, y, u, v) == -1) { cnt->finish = 1; cnt->restart = 0; diff --git a/ffmpeg.c b/ffmpeg.c index 95dff3b..2984d3d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -290,7 +290,7 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, */ ffmpeg = mymalloc(sizeof(struct ffmpeg)); - ffmpeg->tlapse = tlapse; + ffmpeg->tlapse = tlapse; /* Store codec name in ffmpeg->codec, with buffer overflow check. */ snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); @@ -358,6 +358,8 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, if (c->codec_id == MY_CODEC_ID_H264 || c->codec_id == MY_CODEC_ID_HEVC){ ffmpeg->vbr = (int)(( (100-vbr) * 51)/100); + } else if (strcmp(ffmpeg_video_codec, "ogg") == 0){ + ffmpeg->vbr = (int)(( (100-vbr) * 10)/100); } else { ffmpeg->vbr =(int)(((100-vbr)*(100-vbr)*(100-vbr) * 8000) / 1000000) + 1; } @@ -380,11 +382,7 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, } if (strcmp(ffmpeg_video_codec, "ffv1") == 0) c->strict_std_compliance = -2; - if (!strcmp(ffmpeg->oc->oformat->name, "mp4") || - !strcmp(ffmpeg->oc->oformat->name, "mov") || - !strcmp(ffmpeg->oc->oformat->name, "3gp")) { - c->flags |= CODEC_FLAG_GLOBAL_HEADER; - } + c->flags |= CODEC_FLAG_GLOBAL_HEADER; pthread_mutex_lock(&global_lock); retcd = avcodec_open2(c, codec, &opts); @@ -415,7 +413,16 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, } av_dict_free(&opts); - MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s Selected Output FPS %d", c->time_base.den); + MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Selected Output FPS %d", c->time_base.den); + + if ((strcmp(ffmpeg_video_codec, "ffv1") == 0) || + (strcmp(ffmpeg_video_codec, "ogg") == 0) ){ + ffmpeg->video_st->time_base.num = 1; + ffmpeg->video_st->time_base.den = 1000; + } else { + ffmpeg->video_st->time_base.num = 1; + ffmpeg->video_st->time_base.den = rate; + } ffmpeg->video_outbuf = NULL; if (!(ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE)) { @@ -439,7 +446,6 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, ffmpeg->picture->linesize[1] = ffmpeg->c->width / 2; ffmpeg->picture->linesize[2] = ffmpeg->c->width / 2; - /* Open the output file, if needed. */ if ((timelapse_exists(filename) == 0) || (ffmpeg->tlapse != TIMELAPSE_APPEND)) { if (!(ffmpeg->oc->oformat->flags & AVFMT_NOFILE)) { @@ -466,6 +472,8 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, } } } + gettimeofday(&ffmpeg->start_time, NULL); + /* Write the stream header, For the TIMELAPSE_APPEND * we write the data via standard file I/O so we close the * items here @@ -481,6 +489,7 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, av_write_trailer(ffmpeg->oc); avio_close(ffmpeg->oc->pb); } + } return ffmpeg; } @@ -630,6 +639,9 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ int got_packet_ptr; AVPacket pkt; char errstr[128]; + struct timeval tv1; + + gettimeofday(&tv1, NULL); av_init_packet(&pkt); /* Init static structure. */ if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { @@ -653,14 +665,12 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ my_packet_unref(pkt); return -2; } - if (pkt.pts != AV_NOPTS_VALUE) - pkt.pts = av_rescale_q(pkt.pts, - ffmpeg->video_st->codec->time_base, - ffmpeg->video_st->time_base); - if (pkt.dts != AV_NOPTS_VALUE) - pkt.dts = av_rescale_q(pkt.dts, - ffmpeg->video_st->codec->time_base, - ffmpeg->video_st->time_base); + pkt.pts = ((1000000L * (tv1.tv_sec - ffmpeg->start_time.tv_sec)) + tv1.tv_usec - ffmpeg->start_time.tv_usec)/10; + pkt.pts = av_rescale_q(pkt.pts,(AVRational){1, 100000},ffmpeg->video_st->time_base); + if (pkt.pts < 1) pkt.pts = 1; + if (pkt.pts < pkt.dts) pkt.pts=pkt.dts; + + // MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d ",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den); } if (ffmpeg->tlapse == TIMELAPSE_APPEND) { retcd = timelapse_append(ffmpeg, pkt); diff --git a/ffmpeg.h b/ffmpeg.h index f44d9a8..c8b4c9f 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -46,6 +46,7 @@ struct ffmpeg { int vbr; /* variable bitrate setting */ char codec[20]; /* codec name */ int tlapse; + struct timeval start_time; #else int dummy; #endif From 96b8fe97c14dc2d426967f78ea55fca3036598a6 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 31 Aug 2016 12:06:15 +0300 Subject: [PATCH 187/233] Updated extpipe examples with ultrafast H264 (ffmpeg, mencoder and x264) Also updated previous example to use %w and %h variables --- motion-dist.conf.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 353a8fb..0ab07fb 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -352,8 +352,10 @@ use_extpipe off # External program (full path and opts) to pipe raw video to # Generally, use '-' for STDIN... -;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps - +;extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps +;extpipe x264 - --input-res %wx%h --fps %fps --bitrate 2000 --preset ultrafast --quiet -o %f.mp4 +;extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%fps -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %fps +;extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -vcodec libx264 -preset ultrafast -f mp4 %f.mp4 ############################################################ From 145374680fc706fc82b0138051b1c8f28ba25c93 Mon Sep 17 00:00:00 2001 From: MrDave Date: Wed, 31 Aug 2016 18:25:35 -0600 Subject: [PATCH 188/233] PTS refinements, add test and remove ogg options --- event.c | 57 +++++++++++++++++++++++++++++++++++++++++---- ffmpeg.c | 34 ++++++++++++++++----------- motion-dist.conf.in | 5 ++-- 3 files changed, 74 insertions(+), 22 deletions(-) diff --git a/event.c b/event.c index f92018f..912a8ad 100644 --- a/event.c +++ b/event.c @@ -608,6 +608,8 @@ static void event_ffmpeg_newfile(struct context *cnt, unsigned char *convbuf, *y, *u, *v; char stamp[PATH_MAX]; const char *moviepath; + char codec[8]; + long codenbr; if (!cnt->conf.ffmpeg_output && !cnt->conf.ffmpeg_output_debug) return; @@ -627,9 +629,54 @@ static void event_ffmpeg_newfile(struct context *cnt, * motion movies get the same name as normal movies plus an appended 'm' * PATH_MAX - 4 to allow for .mpg to be appended without overflow */ - snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%sm", cnt->conf.filepath, stamp); - snprintf(cnt->newfilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); - + /* Set up a testing / evaluation codec which will use a different + * codec for the events. + */ + snprintf(codec, sizeof(codec), "%s", cnt->conf.ffmpeg_video_codec); + if (strcmp(codec, "test") == 0) { + MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Running test of the various output formats."); + codenbr = cnt->event_nr; + while (codenbr > 10){ + codenbr -= 10; + } + switch (codenbr) { + case 1: + snprintf(codec, sizeof(codec), "%s", "mpeg4"); + break; + case 2: + snprintf(codec, sizeof(codec), "%s", "msmpeg4"); + break; + case 3: + snprintf(codec, sizeof(codec), "%s", "swf"); + break; + case 4: + snprintf(codec, sizeof(codec), "%s", "flv"); + break; + case 5: + snprintf(codec, sizeof(codec), "%s", "ffv1"); + break; + case 6: + snprintf(codec, sizeof(codec), "%s", "mov"); + break; + case 7: + snprintf(codec, sizeof(codec), "%s", "mp4"); + break; + case 8: + snprintf(codec, sizeof(codec), "%s", "mkv"); + break; + case 9: + snprintf(codec, sizeof(codec), "%s", "hevc"); + break; + default: + snprintf(codec, sizeof(codec), "%s", "msmpeg4"); + break; + } + snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%s_%sm", cnt->conf.filepath, codec, stamp); + snprintf(cnt->newfilename, PATH_MAX - 4, "%s/%s_%s", cnt->conf.filepath, codec, stamp); + } else { + snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%sm", cnt->conf.filepath, stamp); + snprintf(cnt->newfilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); + } if (cnt->conf.ffmpeg_output) { if (cnt->imgs.type == VIDEO_PALETTE_GREY) { convbuf = mymalloc((width * height) / 2); @@ -645,7 +692,7 @@ static void event_ffmpeg_newfile(struct context *cnt, } if ((cnt->ffmpeg_output = - ffmpeg_open(cnt->conf.ffmpeg_video_codec, cnt->newfilename, y, u, v, + ffmpeg_open(codec, cnt->newfilename, y, u, v, cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, cnt->conf.ffmpeg_vbr,TIMELAPSE_NONE)) == NULL) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (new) file [%s]", @@ -673,7 +720,7 @@ static void event_ffmpeg_newfile(struct context *cnt, } if ((cnt->ffmpeg_output_debug = - ffmpeg_open(cnt->conf.ffmpeg_video_codec, cnt->motionfilename, y, u, v, + ffmpeg_open(codec, cnt->motionfilename, y, u, v, cnt->imgs.width, cnt->imgs.height, cnt->movie_fps, cnt->conf.ffmpeg_bps, cnt->conf.ffmpeg_vbr,TIMELAPSE_NONE)) == NULL) { MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: ffopen_open error creating (motion) file [%s]", diff --git a/ffmpeg.c b/ffmpeg.c index 2984d3d..17452ba 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -232,9 +232,6 @@ static AVOutputFormat *get_oformat(const char *codec, char *filename){ } else if (strcmp(codec, "mov") == 0) { ext = ".mov"; of = av_guess_format("mov", NULL, NULL); - } else if (strcmp (codec, "ogg") == 0){ - ext = ".ogg"; - of = av_guess_format ("ogg", NULL, NULL); } else if (strcmp (codec, "mp4") == 0){ ext = ".mp4"; of = av_guess_format ("mp4", NULL, NULL); @@ -340,6 +337,15 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, return NULL; } + /* Only the newer codec and containers can handle the really fast FPS */ + if (((strcmp(ffmpeg_video_codec, "msmpeg4") == 0) || + (strcmp(ffmpeg_video_codec, "mpeg4") == 0) || + (strcmp(ffmpeg_video_codec, "swf") == 0) ) && (rate >100)){ + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s The frame rate specified is too high for the ffmpeg movie type specified. Choose a different ffmpeg container or lower framerate. "); + ffmpeg_cleanups(ffmpeg); + return NULL; + } + ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); c->codec_id = ffmpeg->oc->oformat->video_codec; c->codec_type = AVMEDIA_TYPE_VIDEO; @@ -358,8 +364,6 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, if (c->codec_id == MY_CODEC_ID_H264 || c->codec_id == MY_CODEC_ID_HEVC){ ffmpeg->vbr = (int)(( (100-vbr) * 51)/100); - } else if (strcmp(ffmpeg_video_codec, "ogg") == 0){ - ffmpeg->vbr = (int)(( (100-vbr) * 10)/100); } else { ffmpeg->vbr =(int)(((100-vbr)*(100-vbr)*(100-vbr) * 8000) / 1000000) + 1; } @@ -415,13 +419,14 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, av_dict_free(&opts); MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Selected Output FPS %d", c->time_base.den); - if ((strcmp(ffmpeg_video_codec, "ffv1") == 0) || - (strcmp(ffmpeg_video_codec, "ogg") == 0) ){ - ffmpeg->video_st->time_base.num = 1; - ffmpeg->video_st->time_base.den = 1000; - } else { + ffmpeg->video_st->time_base.num = 1; + ffmpeg->video_st->time_base.den = 1000; + if (strcmp(ffmpeg_video_codec, "swf") == 0) { ffmpeg->video_st->time_base.num = 1; ffmpeg->video_st->time_base.den = rate; + if (rate > 50){ + MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s The FPS could be too high for the SWF container. Consider other choices."); + } } ffmpeg->video_outbuf = NULL; @@ -640,6 +645,7 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ AVPacket pkt; char errstr[128]; struct timeval tv1; + int64_t pts_interval; gettimeofday(&tv1, NULL); @@ -665,12 +671,12 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ my_packet_unref(pkt); return -2; } - pkt.pts = ((1000000L * (tv1.tv_sec - ffmpeg->start_time.tv_sec)) + tv1.tv_usec - ffmpeg->start_time.tv_usec)/10; - pkt.pts = av_rescale_q(pkt.pts,(AVRational){1, 100000},ffmpeg->video_st->time_base); + pts_interval = ((1000000L * (tv1.tv_sec - ffmpeg->start_time.tv_sec)) + tv1.tv_usec - ffmpeg->start_time.tv_usec) + 10000; + pkt.pts = av_rescale_q(pts_interval,(AVRational){1, 1000000L},ffmpeg->video_st->time_base); if (pkt.pts < 1) pkt.pts = 1; - if (pkt.pts < pkt.dts) pkt.pts=pkt.dts; + pkt.dts = pkt.pts; - // MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d ",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den); +// MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d interval %d",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den,pts_interval); } if (ffmpeg->tlapse == TIMELAPSE_APPEND) { retcd = timelapse_append(ffmpeg, pkt); diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 353a8fb..689dc45 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -320,9 +320,8 @@ ffmpeg_variable_bitrate 0 # it requires no installation of codec on the Windows client. # swf - gives you a flash film with extension .swf # flv - gives you a flash video with extension .flv -# ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) -# mov - QuickTime ( testing ) -# ogg - Ogg/Theora ( testing ) +# ffv1 - FF video codec 1 for Lossless Encoding +# mov - QuickTime # mp4 - MPEG-4 Part 14 H264 encoding # mkv - Matroska H264 encoding # hevc - H.265 / HEVC (High Efficiency Video Coding) From 22b2461cb273dab0eb807e0463dd45d4bb50347b Mon Sep 17 00:00:00 2001 From: MrDave Date: Thu, 1 Sep 2016 20:35:44 -0600 Subject: [PATCH 189/233] Better implementation of the test codec --- event.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/event.c b/event.c index 912a8ad..f5ca2bb 100644 --- a/event.c +++ b/event.c @@ -608,7 +608,7 @@ static void event_ffmpeg_newfile(struct context *cnt, unsigned char *convbuf, *y, *u, *v; char stamp[PATH_MAX]; const char *moviepath; - char codec[8]; + const char *codec; long codenbr; if (!cnt->conf.ffmpeg_output && !cnt->conf.ffmpeg_output_debug) @@ -629,46 +629,50 @@ static void event_ffmpeg_newfile(struct context *cnt, * motion movies get the same name as normal movies plus an appended 'm' * PATH_MAX - 4 to allow for .mpg to be appended without overflow */ - /* Set up a testing / evaluation codec which will use a different - * codec for the events. + + /* The following section allows for testing of all the various containers + * that Motion permits. The container type is pre-pended to the name of the + * file so that we can determine which container type created what movie. + * The intent for this is be used for developer testing when the ffmpeg libs + * change or the code inside our ffmpeg module changes. For each event, the + * container type will change. This way, you can turn on emulate motion, then + * specify a maximum movie time and let Motion run for days creating all the + * different types of movies checking for crashes, warnings, etc. */ - snprintf(codec, sizeof(codec), "%s", cnt->conf.ffmpeg_video_codec); + codec = cnt->conf.ffmpeg_video_codec; if (strcmp(codec, "test") == 0) { MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Running test of the various output formats."); - codenbr = cnt->event_nr; - while (codenbr > 10){ - codenbr -= 10; - } + codenbr = cnt->event_nr % 10; switch (codenbr) { case 1: - snprintf(codec, sizeof(codec), "%s", "mpeg4"); + codec = "mpeg4"; break; case 2: - snprintf(codec, sizeof(codec), "%s", "msmpeg4"); + codec = "msmpeg4"; break; case 3: - snprintf(codec, sizeof(codec), "%s", "swf"); + codec = "swf"; break; case 4: - snprintf(codec, sizeof(codec), "%s", "flv"); + codec = "flv"; break; case 5: - snprintf(codec, sizeof(codec), "%s", "ffv1"); + codec = "ffv1"; break; case 6: - snprintf(codec, sizeof(codec), "%s", "mov"); + codec = "mov"; break; case 7: - snprintf(codec, sizeof(codec), "%s", "mp4"); + codec = "mp4"; break; case 8: - snprintf(codec, sizeof(codec), "%s", "mkv"); + codec = "mkv"; break; case 9: - snprintf(codec, sizeof(codec), "%s", "hevc"); + codec = "hevc"; break; default: - snprintf(codec, sizeof(codec), "%s", "msmpeg4"); + codec = "msmpeg4"; break; } snprintf(cnt->motionfilename, PATH_MAX - 4, "%s/%s_%sm", cnt->conf.filepath, codec, stamp); From 5697db119599e7840895b1419eab84e1c0a9a61a Mon Sep 17 00:00:00 2001 From: MrDave Date: Thu, 1 Sep 2016 21:08:15 -0600 Subject: [PATCH 190/233] Change old containers to defaults --- event.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/event.c b/event.c index f5ca2bb..533afe3 100644 --- a/event.c +++ b/event.c @@ -640,6 +640,10 @@ static void event_ffmpeg_newfile(struct context *cnt, * different types of movies checking for crashes, warnings, etc. */ codec = cnt->conf.ffmpeg_video_codec; + if (strcmp(codec, "ogg") == 0) { + MOTION_LOG(WRN, TYPE_ENCODER, NO_ERRNO, "%s The ogg container is no longer supported. Changing to mpeg4"); + codec = "mpeg4"; + } if (strcmp(codec, "test") == 0) { MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s Running test of the various output formats."); codenbr = cnt->event_nr % 10; @@ -780,7 +784,14 @@ static void event_ffmpeg_timelapse(struct context *cnt, v = u + (width * height) / 4; } - if (strcmp(cnt->conf.ffmpeg_video_codec,"mpg") == 0) { + + if ((strcmp(cnt->conf.ffmpeg_video_codec,"mpg") == 0) || + (strcmp(cnt->conf.ffmpeg_video_codec,"swf") == 0) ){ + + if (strcmp(cnt->conf.ffmpeg_video_codec,"swf") == 0) { + MOTION_LOG(WRN, TYPE_EVENTS, NO_ERRNO, "%s: The swf container for timelapse no longer supported. Using mpg container."); + } + MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using mpg codec."); MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be appended to file"); cnt->ffmpeg_timelapse = From e953b5d14b4ea9a507d707fe8c40337a484e152a Mon Sep 17 00:00:00 2001 From: MrDave Date: Sat, 3 Sep 2016 08:48:38 -0600 Subject: [PATCH 191/233] Timelapse fps and regression fixes --- event.c | 4 ++-- ffmpeg.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/event.c b/event.c index 533afe3..2be1e6d 100644 --- a/event.c +++ b/event.c @@ -796,14 +796,14 @@ static void event_ffmpeg_timelapse(struct context *cnt, MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be appended to file"); cnt->ffmpeg_timelapse = ffmpeg_open(codec_mpg,cnt->timelapsefilename, y, u, v - ,cnt->imgs.width, cnt->imgs.height, 24 + ,cnt->imgs.width, cnt->imgs.height, cnt->conf.frame_limit ,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_APPEND); } else { MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Timelapse using mpeg4 codec."); MOTION_LOG(NTC, TYPE_EVENTS, NO_ERRNO, "%s: Events will be trigger new files"); cnt->ffmpeg_timelapse = ffmpeg_open(codec_mpeg ,cnt->timelapsefilename, y, u, v - ,cnt->imgs.width, cnt->imgs.height, 1 + ,cnt->imgs.width, cnt->imgs.height, cnt->conf.frame_limit ,cnt->conf.ffmpeg_bps,cnt->conf.ffmpeg_vbr,TIMELAPSE_NEW); } diff --git a/ffmpeg.c b/ffmpeg.c index 17452ba..050da61 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -421,10 +421,11 @@ struct ffmpeg *ffmpeg_open(const char *ffmpeg_video_codec, char *filename, ffmpeg->video_st->time_base.num = 1; ffmpeg->video_st->time_base.den = 1000; - if (strcmp(ffmpeg_video_codec, "swf") == 0) { + if ((strcmp(ffmpeg_video_codec, "swf") == 0) || + (ffmpeg->tlapse != TIMELAPSE_NONE) ) { ffmpeg->video_st->time_base.num = 1; ffmpeg->video_st->time_base.den = rate; - if (rate > 50){ + if ((rate > 50) && (strcmp(ffmpeg_video_codec, "swf") == 0)){ MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s The FPS could be too high for the SWF container. Consider other choices."); } } @@ -671,18 +672,19 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic){ my_packet_unref(pkt); return -2; } - pts_interval = ((1000000L * (tv1.tv_sec - ffmpeg->start_time.tv_sec)) + tv1.tv_usec - ffmpeg->start_time.tv_usec) + 10000; - pkt.pts = av_rescale_q(pts_interval,(AVRational){1, 1000000L},ffmpeg->video_st->time_base); - if (pkt.pts < 1) pkt.pts = 1; - pkt.dts = pkt.pts; - -// MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d interval %d",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den,pts_interval); } if (ffmpeg->tlapse == TIMELAPSE_APPEND) { retcd = timelapse_append(ffmpeg, pkt); + } else if (ffmpeg->tlapse == TIMELAPSE_NEW) { + retcd = av_write_frame(ffmpeg->oc, &pkt); } else { + pts_interval = ((1000000L * (tv1.tv_sec - ffmpeg->start_time.tv_sec)) + tv1.tv_usec - ffmpeg->start_time.tv_usec) + 10000; + pkt.pts = av_rescale_q(pts_interval,(AVRational){1, 1000000L},ffmpeg->video_st->time_base); + if (pkt.pts < 1) pkt.pts = 1; + pkt.dts = pkt.pts; retcd = av_write_frame(ffmpeg->oc, &pkt); } +// MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: pts:%d dts:%d stream:%d interval %d",pkt.pts,pkt.dts,ffmpeg->video_st->time_base.den,pts_interval); my_packet_unref(pkt); if (retcd != 0) { From e4b5627a705504cb9029a58679cbbdf9064c9855 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sat, 3 Sep 2016 11:44:36 -0600 Subject: [PATCH 192/233] Revert to standard os file buffering --- conf.c | 2 +- event.c | 2 +- logger.c | 2 +- motion.c | 89 ++++--------------------------------------------------- motion.h | 4 +-- picture.c | 4 +-- 6 files changed, 11 insertions(+), 92 deletions(-) diff --git a/conf.c b/conf.c index 232c311..6a9f891 100644 --- a/conf.c +++ b/conf.c @@ -1796,7 +1796,7 @@ void conf_print(struct context **cnt) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Writing config file to %s", cnt[thread]->conf_filename); - conffile = myfopen(cnt[thread]->conf_filename, "w", 0); + conffile = myfopen(cnt[thread]->conf_filename, "w"); if (!conffile) continue; diff --git a/event.c b/event.c index 533afe3..7a363c4 100644 --- a/event.c +++ b/event.c @@ -512,7 +512,7 @@ static void event_create_extpipe(struct context *cnt, snprintf(cnt->extpipefilename, PATH_MAX - 4, "%s/%s", cnt->conf.filepath, stamp); /* Open a dummy file to check if path is correct */ - fd_dummy = myfopen(cnt->extpipefilename, "w", 0); + fd_dummy = myfopen(cnt->extpipefilename, "w"); /* TODO: trigger some warning instead of only log an error message */ if (fd_dummy == NULL) { diff --git a/logger.c b/logger.c index 2ecf143..6c46041 100644 --- a/logger.c +++ b/logger.c @@ -110,7 +110,7 @@ void set_log_mode(int mode) FILE * set_logfile(const char *logfile_name) { log_mode = LOGMODE_SYSLOG; /* Setup temporary to let log if myfopen fails */ - logfile = myfopen(logfile_name, "a", 0); + logfile = myfopen(logfile_name, "a"); /* If logfile was opened correctly */ if (logfile) diff --git a/motion.c b/motion.c index 90998e1..d0568fa 100644 --- a/motion.c +++ b/motion.c @@ -905,7 +905,7 @@ static int motion_init(struct context *cnt) /* Load the mask file if any */ if (cnt->conf.mask_file) { - if ((picture = myfopen(cnt->conf.mask_file, "r", 0))) { + if ((picture = myfopen(cnt->conf.mask_file, "r"))) { /* * NOTE: The mask is expected to have the output dimensions. I.e., the mask * applies to the already rotated image, not the capture image. Thus, use @@ -2286,7 +2286,7 @@ static void become_daemon(void) * for an enter. */ if (cnt_list[0]->conf.pid_file) { - pidf = myfopen(cnt_list[0]->conf.pid_file, "w+", 0); + pidf = myfopen(cnt_list[0]->conf.pid_file, "w+"); if (pidf) { (void)fprintf(pidf, "%d\n", getpid()); @@ -3029,13 +3029,6 @@ int create_path(const char *path) return 0; } -#define MYBUFCOUNT 32 -struct MyBuffer { - FILE* fh; - char* buffer; - size_t bufsize; -} buffers[MYBUFCOUNT]; - /** * myfopen * @@ -3043,25 +3036,17 @@ struct MyBuffer { * (which is: path does not exist), the path is created and then things are * tried again. This is faster then trying to create that path over and over * again. If someone removes the path after it was created, myfopen will - * recreate the path automatically. If the bufsize is set to > 0, we will - * allocate (or re-use) write buffers to use instead of the default ones. - * This gives us much higher throughput in many cases. + * recreate the path automatically. * * Parameters: * * path - path to the file to open * mode - open mode - * bufsize - size of write buffers, 0 == OS default * * Returns: the file stream object */ -FILE * myfopen(const char *path, const char *mode, size_t bufsize) +FILE * myfopen(const char *path, const char *mode) { - static int bufferInit = 0; - if (!bufferInit) { - bufferInit = 1; - memset(buffers, 0x00, sizeof(buffers)); - } /* first, just try to open the file */ FILE *dummy = fopen(path, mode); @@ -3077,59 +3062,6 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) /* and retry opening the file */ dummy = fopen(path, mode); } - } - - if (dummy) { - if (bufsize > 0) { - int i = 0; - for (i = 0; i < MYBUFCOUNT; i++) { - int first = -1; - if (!buffers[i].fh) { - if (first == -1) - first = i; - if (buffers[i].buffer == NULL || - buffers[i].bufsize >= bufsize || - (i == (MYBUFCOUNT - 1) && first >= 0)) { - if (buffers[i].buffer == NULL) { - /* We are allocating a new buffer */ - buffers[i].fh = dummy; - buffers[i].buffer = mymalloc(bufsize); - buffers[i].bufsize = bufsize; - } - else if (buffers[i].bufsize >= bufsize) { - /* We are using an old buffer */ - buffers[i].fh = dummy; - } - else { - /* - * We are reusing an old buffer, but it is too - * small, realloc it - */ - i = first; - buffers[i].fh = dummy; - buffers[i].buffer = myrealloc(buffers[i].buffer, - bufsize, "myfopen"); - buffers[i].bufsize = bufsize; - } - - if (buffers[i].buffer == NULL) { - /* - * Our allocation failed, so just use the default - * OS buffers - */ - buffers[i].fh = NULL; - buffers[i].bufsize = 0; - } - else { - setvbuf(buffers[i].fh, buffers[i].buffer, - _IOFBF, buffers[i].bufsize); - } - break; - } - } - } - } - } else { /* * Two possibilities * 1: there was an other error while trying to open the file for the @@ -3138,6 +3070,7 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) */ MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error opening file %s with mode %s", path, mode); + return NULL; } return dummy; @@ -3152,23 +3085,11 @@ FILE * myfopen(const char *path, const char *mode, size_t bufsize) */ int myfclose(FILE* fh) { - int i = 0; int rval = fclose(fh); if (rval != 0) MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Error closing file"); - for (i = 0; i < MYBUFCOUNT; i++) { - if (buffers[i].fh == fh) { - buffers[i].fh = NULL; - if ( finish ) { - /* Free the buffers */ - free(buffers[i].buffer); - buffers[i].buffer = NULL; - buffers[i].bufsize = 0; - } - } - } return rval; } diff --git a/motion.h b/motion.h index 3acb4e6..26bcdbc 100644 --- a/motion.h +++ b/motion.h @@ -212,8 +212,6 @@ #define UPDATE_REF_FRAME 1 #define RESET_REF_FRAME 2 -#define BUFSIZE_1MEG (1024 * 1024) - /* Forward declaration, used in track.h */ struct images; @@ -457,7 +455,7 @@ extern pthread_key_t tls_key_threadnr; /* key for thread number */ int http_bindsock(int, int, int); void * mymalloc(size_t); void * myrealloc(void *, size_t, const char *); -FILE * myfopen(const char *, const char *, size_t); +FILE * myfopen(const char *, const char *); int myfclose(FILE *); size_t mystrftime(const struct context *, char *, size_t, const char *, const struct tm *, const char *, int); int create_path(const char *); diff --git a/picture.c b/picture.c index 2e9550f..81be8f3 100644 --- a/picture.c +++ b/picture.c @@ -934,7 +934,7 @@ void put_picture(struct context *cnt, char *file, unsigned char *image, int ftyp { FILE *picture; - picture = myfopen(file, "w", BUFSIZE_1MEG); + picture = myfopen(file, "w"); if (!picture) { /* Report to syslog - suggest solution if the problem is access rights to target dir. */ if (errno == EACCES) { @@ -1037,7 +1037,7 @@ void put_fixed_mask(struct context *cnt, const char *file) { FILE *picture; - picture = myfopen(file, "w", BUFSIZE_1MEG); + picture = myfopen(file, "w"); if (!picture) { /* Report to syslog - suggest solution if the problem is access rights to target dir. */ if (errno == EACCES) { From eb92db98eb6e47354a8e3d13ac6e4090b0e43554 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 4 Sep 2016 07:47:09 -0600 Subject: [PATCH 193/233] Motion guide update to reference release page and fix some wording --- motion_guide.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/motion_guide.html b/motion_guide.html index f723b55..e127b2c 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -95,7 +95,7 @@

                                                Maintenance and Support

                                                Which version to download and use?

                                                -Versions 3.4.1~rc01 is the current version released in August 2016. The master branch of the github +The most current release version can be found on the github releases page here. The master branch of the github repository represents the official development branch of Motion. Additional independent development forks exist in other Github repos that contain additional bug fixes, enhanced features and updated documentation. This guide is based upon the features and options included in the source code with which it is distributed. @@ -206,7 +206,7 @@

                                                How to build Motion from sour

                                                  -While Motion is included in the apt packages for Ubuntu and Debian, it can also be built from the See also the source code +While Motion is included in the apt packages for Ubuntu and Debian, it can also be built from the source code Source code is located in multiple locations depending upon the needs of the user

                                                  From fa1820aeb543ea0fc43c3ba26f82809f4cd6d6a8 Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Mon, 5 Sep 2016 00:43:27 -0400 Subject: [PATCH 194/233] Adding travis-ci to test build code --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d127afa --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: c +compiler: gcc +before_script: autoreconf -fiv +addons: + apt: + packages: + - libavformat-dev + - libavcodec-dev + - libav-tools + - libavutil-dev + - libswscale-dev + - ffmpeg + - libjpeg8-dev + - libv4l-dev + - libzip-dev +script: ./configure && make From 71a16f92138e2be089d2a03208f5986c7a0d4dbb Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sat, 10 Sep 2016 18:30:18 +0100 Subject: [PATCH 195/233] Make some internal functions "static" (and remove the places they were added to .h files) I don't believe these functions were intended to be exposed outside the .c file they're defined in, so make them internal functions. --- ffmpeg.c | 4 ++-- ffmpeg.h | 2 -- netcam_rtsp.c | 14 +++++++------- netcam_rtsp.h | 7 ------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 050da61..5dd348e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -149,7 +149,7 @@ void my_packet_unref(AVPacket pkt){ * 0: File doesn't exist * 1: File exists */ -int timelapse_exists(const char *fname){ +static int timelapse_exists(const char *fname){ FILE *file; file = fopen(fname, "r"); if (file) @@ -159,7 +159,7 @@ int timelapse_exists(const char *fname){ } return 0; } -int timelapse_append(struct ffmpeg *ffmpeg, AVPacket pkt){ +static int timelapse_append(struct ffmpeg *ffmpeg, AVPacket pkt){ FILE *file; file = fopen(ffmpeg->oc->filename, "a"); diff --git a/ffmpeg.h b/ffmpeg.h index c8b4c9f..bc6813d 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -87,8 +87,6 @@ void ffmpeg_close(struct ffmpeg *); void ffmpeg_avcodec_log(void *, int, const char *, va_list); #ifdef HAVE_FFMPEG -int timelapse_exists(const char *fname); -int timelapse_append(struct ffmpeg *ffmpeg, AVPacket pkt); AVFrame *my_frame_alloc(void); void my_frame_free(AVFrame *frame); int ffmpeg_put_frame(struct ffmpeg *, AVFrame *); diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 151e84e..7a3cf01 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -31,7 +31,7 @@ * * Determine whether pix_format is YUV420P */ -int netcam_check_pixfmt(netcam_context_ptr netcam){ +static int netcam_check_pixfmt(netcam_context_ptr netcam){ int retcd; retcd = -1; @@ -47,7 +47,7 @@ int netcam_check_pixfmt(netcam_context_ptr netcam){ * * Null all the context */ -void netcam_rtsp_null_context(netcam_context_ptr netcam){ +static void netcam_rtsp_null_context(netcam_context_ptr netcam){ netcam->rtsp->swsctx = NULL; netcam->rtsp->swsframe_in = NULL; @@ -62,7 +62,7 @@ void netcam_rtsp_null_context(netcam_context_ptr netcam){ * * Close all the context that could be open */ -void netcam_rtsp_close_context(netcam_context_ptr netcam){ +static void netcam_rtsp_close_context(netcam_context_ptr netcam){ if (netcam->rtsp->swsctx != NULL) sws_freeContext(netcam->rtsp->swsctx); if (netcam->rtsp->swsframe_in != NULL) my_frame_free(netcam->rtsp->swsframe_in); @@ -375,7 +375,7 @@ int netcam_read_rtsp_image(netcam_context_ptr netcam){ * Success 0(zero) * */ -int netcam_rtsp_resize_ntc(netcam_context_ptr netcam){ +static int netcam_rtsp_resize_ntc(netcam_context_ptr netcam){ if ((netcam->width != (unsigned)netcam->rtsp->codec_context->width) || (netcam->height != (unsigned)netcam->rtsp->codec_context->height) || @@ -428,7 +428,7 @@ int netcam_rtsp_resize_ntc(netcam_context_ptr netcam){ * Success 0(zero) * */ -int netcam_rtsp_open_context(netcam_context_ptr netcam){ +static int netcam_rtsp_open_context(netcam_context_ptr netcam){ int retcd; char errstr[128]; @@ -534,7 +534,7 @@ int netcam_rtsp_open_context(netcam_context_ptr netcam){ * Success 0(zero) * */ -int netcam_rtsp_open_sws(netcam_context_ptr netcam){ +static int netcam_rtsp_open_sws(netcam_context_ptr netcam){ netcam->width = ((netcam->cnt->conf.width / 8) * 8); netcam->height = ((netcam->cnt->conf.height / 8) * 8); @@ -608,7 +608,7 @@ int netcam_rtsp_open_sws(netcam_context_ptr netcam){ * Success 0(zero) * */ -int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ +static int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam){ int retcd; char errstr[128]; diff --git a/netcam_rtsp.h b/netcam_rtsp.h index 8c01cb1..325ed69 100644 --- a/netcam_rtsp.h +++ b/netcam_rtsp.h @@ -32,13 +32,6 @@ int netcam_connect_rtsp(netcam_context_ptr netcam); int netcam_read_rtsp_image(netcam_context_ptr netcam); int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url); int netcam_next_rtsp(unsigned char *image , netcam_context_ptr netcam); -int netcam_check_pixfmt(netcam_context_ptr netcam); -void netcam_rtsp_null_context(netcam_context_ptr netcam); -void netcam_rtsp_close_context(netcam_context_ptr netcam); -int netcam_rtsp_resize_ntc(netcam_context_ptr netcam); -int netcam_rtsp_open_context(netcam_context_ptr netcam); -int netcam_rtsp_open_sws(netcam_context_ptr netcam); -int netcam_rtsp_resize(unsigned char *image , netcam_context_ptr netcam); #else /* Do not have FFmpeg */ From 068a799d29c2d35fa53f333aa3c46e356137e345 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sat, 10 Sep 2016 17:02:33 +0100 Subject: [PATCH 196/233] Fix build for libavutil prior to 51.42.0 --- ffmpeg.c | 6 +++--- ffmpeg.h | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 050da61..66786b5 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -81,7 +81,7 @@ void my_frame_free(AVFrame *frame){ #endif } /*********************************************/ -int my_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height){ +int my_image_get_buffer_size(enum MyPixelFormat pix_fmt, int width, int height){ int retcd = 0; #if (LIBAVFORMAT_VERSION_MAJOR >= 57) int align = 1; @@ -92,7 +92,7 @@ int my_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height){ return retcd; } /*********************************************/ -int my_image_copy_to_buffer(AVFrame *frame, uint8_t *buffer_ptr, enum AVPixelFormat pix_fmt,int width, int height,int dest_size){ +int my_image_copy_to_buffer(AVFrame *frame, uint8_t *buffer_ptr, enum MyPixelFormat pix_fmt,int width, int height,int dest_size){ int retcd = 0; #if (LIBAVFORMAT_VERSION_MAJOR >= 57) int align = 1; @@ -105,7 +105,7 @@ int my_image_copy_to_buffer(AVFrame *frame, uint8_t *buffer_ptr, enum AVPixelFor return retcd; } /*********************************************/ -int my_image_fill_arrays(AVFrame *frame,uint8_t *buffer_ptr,enum AVPixelFormat pix_fmt,int width,int height){ +int my_image_fill_arrays(AVFrame *frame,uint8_t *buffer_ptr,enum MyPixelFormat pix_fmt,int width,int height){ int retcd = 0; #if (LIBAVFORMAT_VERSION_MAJOR >= 57) int align = 1; diff --git a/ffmpeg.h b/ffmpeg.h index c8b4c9f..59e6b09 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -25,6 +25,15 @@ #endif +/** + * libavutil changed the name from PixelFormat to AVPixelFormat in 51.42.0 + * Add compatibility with older versions. + */ +#ifdef FF_API_PIX_FMT +#define MyPixelFormat AVPixelFormat +#else +#define MyPixelFormat PixelFormat +#endif #endif /* HAVE_FFMPEG */ @@ -95,9 +104,9 @@ int ffmpeg_put_frame(struct ffmpeg *, AVFrame *); void ffmpeg_cleanups(struct ffmpeg *); AVFrame *ffmpeg_prepare_frame(struct ffmpeg *, unsigned char *, unsigned char *, unsigned char *); -int my_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height); -int my_image_copy_to_buffer(AVFrame *frame,uint8_t *buffer_ptr,enum AVPixelFormat pix_fmt,int width,int height,int dest_size); -int my_image_fill_arrays(AVFrame *frame,uint8_t *buffer_ptr,enum AVPixelFormat pix_fmt,int width,int height); +int my_image_get_buffer_size(enum MyPixelFormat pix_fmt, int width, int height); +int my_image_copy_to_buffer(AVFrame *frame,uint8_t *buffer_ptr,enum MyPixelFormat pix_fmt,int width,int height,int dest_size); +int my_image_fill_arrays(AVFrame *frame,uint8_t *buffer_ptr,enum MyPixelFormat pix_fmt,int width,int height); void my_packet_unref(AVPacket pkt); #endif From c895b6667b3ac8c3adb26e9a9f7beea41286d038 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 4 Sep 2016 07:22:00 +0000 Subject: [PATCH 197/233] Initial support for MMAL camera on raspberry pi Originally by dozencrows on github; mostly this commit: https://github.com/dozencrows/motion/commit/6d1ed5bd011d83b6358daf86a20c60cb50d0418c Changes to merge back into motion upstream made by Joseph Heenan (with help from lowflyerUK on github, see https://github.com/dozencrows/motion/pull/1 ): - changed back to using autoconf etc as per the main project - submitted the one change we need to the raspicam files back upstream ( https://github.com/raspberrypi/userland/pull/332 ) - imported latest versions of files in raspicam, now exactly match upstream - added README.txt to raspicam directory with brief explanation - replaced some tabs with spaces - removed dependency on checkout of raspberrypi userland repo; now we use the headers provided by libraspberrypi-dev - merged in a couple of the trivial later bugfix commits - merged in mmalcam_control_params commit to allow config of camera options - fixed many merge conflicts rebased on top of latest upstream motion --- Makefile.in | 7 +- conf.c | 25 + conf.h | 4 + configure.ac | 29 +- mmalcam.c | 403 +++++++++ mmalcam.h | 34 + motion-dist.conf.in | 8 + motion.h | 7 + raspicam/README.txt | 11 + raspicam/RaspiCLI.c | 155 ++++ raspicam/RaspiCLI.h | 56 ++ raspicam/RaspiCamControl.c | 1568 ++++++++++++++++++++++++++++++++++++ raspicam/RaspiCamControl.h | 217 +++++ video_common.c | 28 + 14 files changed, 2548 insertions(+), 4 deletions(-) create mode 100644 mmalcam.c create mode 100644 mmalcam.h create mode 100644 raspicam/README.txt create mode 100644 raspicam/RaspiCLI.c create mode 100644 raspicam/RaspiCLI.h create mode 100644 raspicam/RaspiCamControl.c create mode 100644 raspicam/RaspiCamControl.h diff --git a/Makefile.in b/Makefile.in index 2fdc6e8..4601e75 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,14 +31,15 @@ examplesdir = $(datadir)/@PACKAGE_NAME@/examples # These variables contain compiler flags, object files to build and files to # # install. # ################################################################################ -CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@ +CFLAGS = @CFLAGS@ -Wall -DVERSION=\"@PACKAGE_VERSION@\" -Dsysconfdir=\"$(sysconfdir)\" @FFMPEG_CFLAGS@ @MMAL_CFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ @FFMPEG_LIBS@ +LIBS = @LIBS@ @MMAL_LIBS@ @FFMPEG_LIBS@ VIDEO_OBJ = @VIDEO@ OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $(VIDEO_OBJ) \ netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \ alg.o event.o picture.o rotate.o webhttpd.o \ - stream.o md5.o netcam_rtsp.o @FFMPEG_OBJ@ @SDL_OBJ@ + stream.o md5.o netcam_rtsp.o \ + @FFMPEG_OBJ@ @MMAL_OBJ@ @SDL_OBJ@ SRC = $(OBJ:.o=.c) DOC = CHANGELOG COPYING CREDITS README motion_guide.html mask1.png normal.jpg outputmotion1.jpg outputnormal1.jpg EXAMPLES = *.conf diff --git a/conf.c b/conf.c index 324d066..e94d682 100644 --- a/conf.c +++ b/conf.c @@ -148,6 +148,10 @@ struct config conf_template = { netcam_proxy: NULL, netcam_tolerant_check: 0, rtsp_uses_tcp: 1, +#ifdef HAVE_MMAL + mmalcam_name: NULL, + mmalcam_control_params: NULL, +#endif text_changes: 0, text_left: NULL, text_right: DEF_TIMESTAMP, @@ -421,6 +425,27 @@ config_param config_params[] = { copy_bool, print_bool }, +#ifdef HAVE_MMAL + { + "mmalcam_name", + "# Name of camera to use if you are using a camera accessed through OpenMax/MMAL\n" + "# For the raspberry pi official camera, use vc.ril.camera" + "# Default: Not defined", + 0, + CONF_OFFSET(mmalcam_name), + copy_string, + print_string + }, + { + "mmalcam_control_params", + "# Camera control parameters (see raspivid/raspistill tool documentation)\n" + "# Default: Not defined", + 0, + CONF_OFFSET(mmalcam_control_params), + copy_string, + print_string + }, +#endif { "auto_brightness", "# Let motion regulate the brightness of a video device (default: off).\n" diff --git a/conf.h b/conf.h index 93ae036..09d2187 100644 --- a/conf.h +++ b/conf.h @@ -127,6 +127,10 @@ struct config { const char *netcam_proxy; unsigned int netcam_tolerant_check; unsigned int rtsp_uses_tcp; +#ifdef HAVE_MMAL + const char *mmalcam_name; + const char *mmalcam_control_params; +#endif int text_changes; const char *text_left; const char *text_right; diff --git a/configure.ac b/configure.ac index 458735e..c7af317 100644 --- a/configure.ac +++ b/configure.ac @@ -376,6 +376,24 @@ AC_CHECK_PROG([PKGCONFIG],[pkg-config],[yes],[no]) AM_CONDITIONAL([FOUND_PKGCONFIG], [test "x$PKGCONFIG" = xyes]) AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not found, please check motion_guide.html and install necessary dependencies.])]) +# Check for raspberry pi mmal interface +# +HAVE_MMAL="" +LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal" + +if test -d ${LIBRASPBERRYPIDEVPATH}; then + HAVE_MMAL="yes" +fi + +AS_IF([test "${HAVE_MMAL}" = "yes" ], [ + AC_SUBST(MMAL_CFLAGS) + AC_SUBST(MMAL_OBJ) + AC_SUBST(MMAL_LIBS) + MMAL_OBJ="mmalcam.o raspicam/RaspiCamControl.o raspicam/RaspiCLI.o" + MMAL_CFLAGS="-std=gnu99 -DHAVE_MMAL -Irasppicam -I/opt/vc/include" + MMAL_LIBS="-L/opt/vc/lib -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lvchostif -lvchiq_arm" + AC_DEFINE([HAVE_MMAL], 1, [Define to 1 if we want MMAL]) +]) # # Check for libavcodec and libavformat from ffmpeg @@ -1112,7 +1130,6 @@ else fi fi - AC_SUBST(BIN_PATH) AC_CONFIG_FILES([ @@ -1201,6 +1218,16 @@ else echo "SDL support: No" fi +if test "${HAVE_MMAL}" = "yes"; then + echo "MMAL support: Yes" + echo " ... MMAL_CFLAGS: $MMAL_CFLAGS" + echo " ... MMAL_OBJ: $MMAL_OBJ" + echo " ... MMAL_LIBS: $MMAL_LIBS" +else + echo "MMAL support: No" + echo " ... libraspberrypi-dev package not installed" +fi + if test "${HAVE_FFMPEG}" = "yes"; then echo "FFmpeg support: Yes" echo " ... FFMPEG_CFLAGS: $FFMPEG_CFLAGS" diff --git a/mmalcam.c b/mmalcam.c new file mode 100644 index 0000000..306e72b --- /dev/null +++ b/mmalcam.c @@ -0,0 +1,403 @@ +/* + * mmalcam.c + * + * Raspberry Pi camera module using MMAL API. + * + * Built upon functionality from the Raspberry Pi userland utility raspivid. + * + * Copyright 2013 by Nicholas Tuckett + * This software is distributed under the GNU public license version 2 + * See also the file 'COPYING'. + * + */ + +#include "interface/vcos/vcos.h" +#include "interface/mmal/mmal.h" +#include "interface/mmal/mmal_buffer.h" +#include "interface/mmal/mmal_port.h" +#include "interface/mmal/util/mmal_util.h" +#include "interface/mmal/util/mmal_util_params.h" +#include "interface/mmal/util/mmal_default_components.h" +#include "interface/mmal/util/mmal_connection.h" +#include "raspicam/RaspiCamControl.h" + +#include "motion.h" +#include "rotate.h" + +#define MMALCAM_OK 0 +#define MMALCAM_ERROR -1 + +#define MMAL_CAMERA_PREVIEW_PORT 0 +#define MMAL_CAMERA_VIDEO_PORT 1 +#define MMAL_CAMERA_CAPTURE_PORT 2 +#define VIDEO_FRAME_RATE_NUM 30 +#define VIDEO_FRAME_RATE_DEN 1 +#define VIDEO_OUTPUT_BUFFERS_NUM 3 + +const int MAX_BITRATE = 30000000; // 30Mbits/s + +static void parse_camera_control_params(const char *control_params_str, RASPICAM_CAMERA_PARAMETERS *camera_params) +{ + char *control_params_tok = alloca(strlen(control_params_str) + 1); + strcpy(control_params_tok, control_params_str); + + char *next_param = strtok(control_params_tok, " "); + + while (next_param != NULL) { + char *param_val = strtok(NULL, " "); + if (raspicamcontrol_parse_cmdline(camera_params, next_param + 1, param_val) < 2) { + next_param = param_val; + } else { + next_param = strtok(NULL, " "); + } + } +} + +static void check_disable_port(MMAL_PORT_T *port) +{ + if (port && port->is_enabled) { + mmal_port_disable(port); + } +} + +static void camera_control_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer) +{ + if (buffer->cmd != MMAL_EVENT_PARAMETER_CHANGED) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "Received unexpected camera control callback event, 0x%08x", + buffer->cmd); + } + + mmal_buffer_header_release(buffer); +} + +static void camera_buffer_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer) +{ + mmalcam_context_ptr mmalcam = (mmalcam_context_ptr) port->userdata; + mmal_queue_put(mmalcam->camera_buffer_queue, buffer); +} + +static void set_port_format(mmalcam_context_ptr mmalcam, MMAL_ES_FORMAT_T *format) +{ + format->encoding = MMAL_ENCODING_OPAQUE; + format->encoding_variant = MMAL_ENCODING_I420; + format->es->video.width = mmalcam->width; + format->es->video.height = mmalcam->height; + format->es->video.crop.x = 0; + format->es->video.crop.y = 0; + format->es->video.crop.width = mmalcam->width; + format->es->video.crop.height = mmalcam->height; +} + +static void set_video_port_format(mmalcam_context_ptr mmalcam, MMAL_ES_FORMAT_T *format) +{ + set_port_format(mmalcam, format); + format->es->video.frame_rate.num = mmalcam->framerate; + format->es->video.frame_rate.den = VIDEO_FRAME_RATE_DEN; +} + +static int create_camera_component(mmalcam_context_ptr mmalcam, const char *mmalcam_name) +{ + MMAL_STATUS_T status; + MMAL_COMPONENT_T *camera_component; + MMAL_PORT_T *video_port = NULL; + + status = mmal_component_create(mmalcam_name, &camera_component); + + if (status != MMAL_SUCCESS) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "Failed to create MMAL camera component %s", mmalcam_name); + goto error; + } + + if (camera_component->output_num == 0) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "MMAL camera %s doesn't have output ports", mmalcam_name); + goto error; + } + + video_port = camera_component->output[MMAL_CAMERA_VIDEO_PORT]; + + status = mmal_port_enable(camera_component->control, camera_control_callback); + + if (status) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "Unable to enable control port : error %d", status); + goto error; + } + + // set up the camera configuration + { + MMAL_PARAMETER_CAMERA_CONFIG_T cam_config = { + { MMAL_PARAMETER_CAMERA_CONFIG, sizeof(cam_config) }, + .max_stills_w = mmalcam->width, + .max_stills_h = mmalcam->height, + .stills_yuv422 = 0, + .one_shot_stills = 0, + .max_preview_video_w = mmalcam->width, + .max_preview_video_h = mmalcam->height, + .num_preview_video_frames = 3, + .stills_capture_circular_buffer_height = 0, + .fast_preview_resume = 0, + .use_stc_timestamp = MMAL_PARAM_TIMESTAMP_MODE_RESET_STC }; + mmal_port_parameter_set(camera_component->control, &cam_config.hdr); + } + + set_video_port_format(mmalcam, video_port->format); + video_port->format->encoding = MMAL_ENCODING_I420; + status = mmal_port_format_commit(video_port); + + if (status) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "camera video format couldn't be set"); + goto error; + } + + // Ensure there are enough buffers to avoid dropping frames + if (video_port->buffer_num < VIDEO_OUTPUT_BUFFERS_NUM) { + video_port->buffer_num = VIDEO_OUTPUT_BUFFERS_NUM; + } + + status = mmal_component_enable(camera_component); + + if (status) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "camera component couldn't be enabled"); + goto error; + } + + raspicamcontrol_set_all_parameters(camera_component, mmalcam->camera_parameters); + mmalcam->camera_component = camera_component; + mmalcam->camera_capture_port = video_port; + mmalcam->camera_capture_port->userdata = (struct MMAL_PORT_USERDATA_T*) mmalcam; + MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "MMAL camera component created"); + return MMALCAM_OK; + + error: if (mmalcam->camera_component != NULL ) { + mmal_component_destroy(camera_component); + mmalcam->camera_component = NULL; + } + + return MMALCAM_ERROR; +} + +static void destroy_camera_component(mmalcam_context_ptr mmalcam) +{ + if (mmalcam->camera_component) { + mmal_component_destroy(mmalcam->camera_component); + mmalcam->camera_component = NULL; + } +} + +static int create_camera_buffer_structures(mmalcam_context_ptr mmalcam) +{ + mmalcam->camera_buffer_pool = mmal_pool_create(mmalcam->camera_capture_port->buffer_num, + mmalcam->camera_capture_port->buffer_size); + if (mmalcam->camera_buffer_pool == NULL ) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "MMAL camera buffer pool creation failed"); + return MMALCAM_ERROR; + } + + mmalcam->camera_buffer_queue = mmal_queue_create(); + if (mmalcam->camera_buffer_queue == NULL ) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "MMAL camera buffer queue creation failed"); + return MMALCAM_ERROR; + } + + return MMALCAM_OK; +} + +static int send_pooled_buffers_to_port(MMAL_POOL_T *pool, MMAL_PORT_T *port) +{ + int num = mmal_queue_length(pool->queue); + + for (int i = 0; i < num; i++) { + MMAL_BUFFER_HEADER_T *buffer = mmal_queue_get(pool->queue); + + if (!buffer) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "Unable to get a required buffer %d from pool queue", i); + return MMALCAM_ERROR; + } + + if (mmal_port_send_buffer(port, buffer) != MMAL_SUCCESS) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "Unable to send a buffer to port (%d)", i); + return MMALCAM_ERROR; + } + } + + return MMALCAM_OK; +} + +static void destroy_camera_buffer_structures(mmalcam_context_ptr mmalcam) +{ + if (mmalcam->camera_buffer_queue != NULL ) { + mmal_queue_destroy(mmalcam->camera_buffer_queue); + mmalcam->camera_buffer_queue = NULL; + } + + if (mmalcam->camera_buffer_pool != NULL ) { + mmal_pool_destroy(mmalcam->camera_buffer_pool); + mmalcam->camera_buffer_pool = NULL; + } +} + +/** + * mmalcam_start + * + * This routine is called from the main motion thread. It's job is + * to open up the requested camera device via MMAL and do any required + * initialisation. + * + * Parameters: + * + * cnt Pointer to the motion context structure for this device. + * + * Returns: 0 on success + * -1 on any failure + */ + +int mmalcam_start(struct context *cnt) +{ + mmalcam_context_ptr mmalcam; + + cnt->mmalcam = (mmalcam_context*) mymalloc(sizeof(struct mmalcam_context)); + memset(cnt->mmalcam, 0, sizeof(mmalcam_context)); + mmalcam = cnt->mmalcam; + mmalcam->cnt = cnt; + + MOTION_LOG(ALR, TYPE_VIDEO, NO_ERRNO, + "%s: MMAL Camera thread starting... for camera (%s) of %d x %d at %d fps", + cnt->conf.mmalcam_name, cnt->conf.width, cnt->conf.height, cnt->conf.frame_limit); + + mmalcam->camera_parameters = (RASPICAM_CAMERA_PARAMETERS*)malloc(sizeof(RASPICAM_CAMERA_PARAMETERS)); + if (mmalcam->camera_parameters == NULL) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "camera params couldn't be allocated"); + return MMALCAM_ERROR; + } + + raspicamcontrol_set_defaults(mmalcam->camera_parameters); + mmalcam->width = cnt->conf.width; + mmalcam->height = cnt->conf.height; + mmalcam->framerate = cnt->conf.frame_limit; + + if (cnt->conf.mmalcam_control_params) { + parse_camera_control_params(cnt->conf.mmalcam_control_params, mmalcam->camera_parameters); + } + + cnt->imgs.width = mmalcam->width; + cnt->imgs.height = mmalcam->height; + cnt->imgs.size = (mmalcam->width * mmalcam->height * 3) / 2; + cnt->imgs.motionsize = mmalcam->width * mmalcam->height; + cnt->imgs.type = VIDEO_PALETTE_YUV420P; + + int retval = create_camera_component(mmalcam, cnt->conf.mmalcam_name); + + if (retval == 0) { + retval = create_camera_buffer_structures(mmalcam); + } + + if (retval == 0) { + if (mmal_port_enable(mmalcam->camera_capture_port, camera_buffer_callback)) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "MMAL camera capture port enabling failed"); + retval = MMALCAM_ERROR; + } + } + + if (retval == 0) { + if (mmal_port_parameter_set_boolean(mmalcam->camera_capture_port, MMAL_PARAMETER_CAPTURE, 1) + != MMAL_SUCCESS) { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "MMAL camera capture start failed"); + retval = MMALCAM_ERROR; + } + } + + if (retval == 0) { + retval = send_pooled_buffers_to_port(mmalcam->camera_buffer_pool, mmalcam->camera_capture_port); + } + + return retval; +} + +/** + * mmalcam_cleanup + * + * This routine shuts down any MMAL resources, then releases any allocated data + * within the mmalcam context and frees the context itself. + * This function is also called from motion_init if first time connection + * fails and we start retrying until we get a valid first frame from the + * camera. + * + * Parameters: + * + * mmalcam Pointer to a mmalcam context + * + * Returns: Nothing. + * + */ +void mmalcam_cleanup(struct mmalcam_context *mmalcam) +{ + MOTION_LOG(ALR, TYPE_VIDEO, NO_ERRNO, "MMAL Camera cleanup"); + + if (mmalcam != NULL ) { + if (mmalcam->camera_component) { + check_disable_port(mmalcam->camera_capture_port); + mmal_component_disable(mmalcam->camera_component); + destroy_camera_buffer_structures(mmalcam); + destroy_camera_component(mmalcam); + } + + if (mmalcam->camera_parameters) { + free(mmalcam->camera_parameters); + } + + free(mmalcam); + } +} + +/** + * mmalcam_next + * + * This routine is called when the main 'motion' thread wants a new + * frame of video. It fetches the most recent frame available from + * the Pi camera already in YUV420P, and returns it to motion. + * + * Parameters: + * cnt Pointer to the context for this thread + * image Pointer to a buffer for the returned image + * + * Returns: Error code + */ +int mmalcam_next(struct context *cnt, unsigned char *map) +{ + mmalcam_context_ptr mmalcam; + + if ((!cnt) || (!cnt->mmalcam)) + return NETCAM_FATAL_ERROR; + + mmalcam = cnt->mmalcam; + + MMAL_BUFFER_HEADER_T *camera_buffer = mmal_queue_wait(mmalcam->camera_buffer_queue); + + if (camera_buffer->cmd == 0 && (camera_buffer->flags & MMAL_BUFFER_HEADER_FLAG_FRAME_END) + && camera_buffer->length == cnt->imgs.size) { + mmal_buffer_header_mem_lock(camera_buffer); + memcpy(map, camera_buffer->data, cnt->imgs.size); + mmal_buffer_header_mem_unlock(camera_buffer); + } else { + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "%s: cmd %d flags %08x size %d/%d at %08x", + camera_buffer->cmd, camera_buffer->flags, camera_buffer->length, camera_buffer->alloc_size, camera_buffer->data); + } + + mmal_buffer_header_release(camera_buffer); + + if (mmalcam->camera_capture_port->is_enabled) { + MMAL_STATUS_T status; + MMAL_BUFFER_HEADER_T *new_buffer = mmal_queue_get(mmalcam->camera_buffer_pool->queue); + + if (new_buffer) { + status = mmal_port_send_buffer(mmalcam->camera_capture_port, new_buffer); + } + + if (!new_buffer || status != MMAL_SUCCESS) + MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO, "Unable to return a buffer to the camera video port"); + } + + if (cnt->rotate_data.degrees > 0) + rotate_map(cnt, map); + + return 0; +} diff --git a/mmalcam.h b/mmalcam.h new file mode 100644 index 0000000..c44e6a5 --- /dev/null +++ b/mmalcam.h @@ -0,0 +1,34 @@ +/* + * mmalcam.h + * + * Include file for mmalcam.c + * + * Copyright 2013 by Nicholas Tuckett + * This software is distributed under the GNU public license version 2 + * See also the file 'COPYING'. + */ + +#ifndef MMALCAM_H_ +#define MMALCAM_H_ + +typedef struct mmalcam_context *mmalcam_context_ptr; + +typedef struct mmalcam_context { + struct context *cnt; /* pointer to parent motion + context structure */ + int width; + int height; + int framerate; + + struct MMAL_COMPONENT_T *camera_component; + struct MMAL_PORT_T *camera_capture_port; + struct MMAL_POOL_T *camera_buffer_pool; + struct MMAL_QUEUE_T *camera_buffer_queue; + struct raspicam_camera_parameters_s *camera_parameters; +} mmalcam_context; + +int mmalcam_start (struct context *); +int mmalcam_next (struct context *, unsigned char *); +void mmalcam_cleanup (struct mmalcam_context *); + +#endif /* MMALCAM_H_ */ diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 689dc45..a923852 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -140,6 +140,14 @@ netcam_tolerant_check off # Default: on rtsp_uses_tcp on +# Name of camera to use if you are using a camera accessed through OpenMax/MMAL +# Default: Not defined +; mmalcam_name vc.ril.camera + +# Camera control parameters (see raspivid/raspistill tool documentation) +# Default: Not defined +; mmalcam_control_params -hf + # Let motion regulate the brightness of a video device (default: off). # The auto_brightness feature uses the brightness option as its target value. # If brightness is zero auto_brightness will adjust to average brightness value 128. diff --git a/motion.h b/motion.h index 26bcdbc..b67add3 100644 --- a/motion.h +++ b/motion.h @@ -218,6 +218,10 @@ struct images; #include "track.h" #include "netcam.h" +#ifdef HAVE_MMAL +#include "mmalcam.h" +#endif + /* * Structure to hold images information * The idea is that this should have all information about a picture e.g. diffs, timestamp etc. @@ -353,6 +357,9 @@ struct context { struct images imgs; struct trackoptions track; struct netcam_context *netcam; +#ifdef HAVE_MMAL + struct mmalcam_context *mmalcam; +#endif struct image_data *current_image; /* Pointer to a structure where the image, diffs etc is stored */ unsigned int new_img; diff --git a/raspicam/README.txt b/raspicam/README.txt new file mode 100644 index 0000000..09a1c6b --- /dev/null +++ b/raspicam/README.txt @@ -0,0 +1,11 @@ +The files in this directory are used in the MMAL/RaspberryPI camera +support code. The files were taken from the Raspberry PI userland git +repository: + +https://github.com/raspberrypi/userland + +The files are unchanged from the userland versions. + +They are used to parse an options string and setup the camera +parameters appropriately. The format of the string is the same as +other raspberry pi camera tools. diff --git a/raspicam/RaspiCLI.c b/raspicam/RaspiCLI.c new file mode 100644 index 0000000..9f858f4 --- /dev/null +++ b/raspicam/RaspiCLI.c @@ -0,0 +1,155 @@ +/* +Copyright (c) 2013, Broadcom Europe Ltd +Copyright (c) 2013, James Hughes +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** + * \file RaspiCLI.c + * Code for handling command line parameters + * + * \date 4th March 2013 + * \Author: James Hughes + * + * Description + * + * Some functions/structures for command line parameter parsing + * + */ +#include +#include +#include +#include + +#include "interface/vcos/vcos.h" + +#include "RaspiCLI.h" + + +/** + * Convert a string from command line to a comand_id from the list + * + * @param commands Array of command to check + * @param num_command Number of commands in the array + * @param arg String to search for in the list + * @param num_parameters Returns the number of parameters used by the command + * + * @return command ID if found, -1 if not found + * + */ +int raspicli_get_command_id(const COMMAND_LIST *commands, const int num_commands, const char *arg, int *num_parameters) +{ + int command_id = -1; + int j; + + vcos_assert(commands); + vcos_assert(num_parameters); + vcos_assert(arg); + + if (!commands || !num_parameters || !arg) + return -1; + + for (j = 0; j < num_commands; j++) + { + if (!strcmp(arg, commands[j].command) || + !strcmp(arg, commands[j].abbrev)) + { + // match + command_id = commands[j].id; + *num_parameters = commands[j].num_parameters; + break; + } + } + + return command_id; +} + + +/** + * Display the list of commands in help format + * + * @param commands Array of command to check + * @param num_command Number of commands in the arry + * + * + */ +void raspicli_display_help(const COMMAND_LIST *commands, const int num_commands) +{ + int i; + + vcos_assert(commands); + + if (!commands) + return; + + for (i = 0; i < num_commands; i++) + { + fprintf(stdout, "-%s, -%s\t: %s\n", commands[i].abbrev, + commands[i].command, commands[i].help); + } +} + + +/** + * Function to take a string, a mapping, and return the int equivalent + * @param str Incoming string to match + * @param map Mapping data + * @param num_refs The number of items in the mapping data + * @return The integer match for the string, or -1 if no match + */ +int raspicli_map_xref(const char *str, const XREF_T *map, int num_refs) +{ + int i; + + for (i=0;i +#include +#include + +#include "interface/vcos/vcos.h" + +#include "interface/vmcs_host/vc_vchi_gencmd.h" +#include "interface/mmal/mmal.h" +#include "interface/mmal/mmal_logging.h" +#include "interface/mmal/util/mmal_util.h" +#include "interface/mmal/util/mmal_util_params.h" +#include "interface/mmal/util/mmal_default_components.h" +#include "RaspiCamControl.h" +#include "RaspiCLI.h" + +/// Structure to cross reference exposure strings against the MMAL parameter equivalent +static XREF_T exposure_map[] = +{ + {"off", MMAL_PARAM_EXPOSUREMODE_OFF}, + {"auto", MMAL_PARAM_EXPOSUREMODE_AUTO}, + {"night", MMAL_PARAM_EXPOSUREMODE_NIGHT}, + {"nightpreview", MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW}, + {"backlight", MMAL_PARAM_EXPOSUREMODE_BACKLIGHT}, + {"spotlight", MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT}, + {"sports", MMAL_PARAM_EXPOSUREMODE_SPORTS}, + {"snow", MMAL_PARAM_EXPOSUREMODE_SNOW}, + {"beach", MMAL_PARAM_EXPOSUREMODE_BEACH}, + {"verylong", MMAL_PARAM_EXPOSUREMODE_VERYLONG}, + {"fixedfps", MMAL_PARAM_EXPOSUREMODE_FIXEDFPS}, + {"antishake", MMAL_PARAM_EXPOSUREMODE_ANTISHAKE}, + {"fireworks", MMAL_PARAM_EXPOSUREMODE_FIREWORKS} +}; + +static const int exposure_map_size = sizeof(exposure_map) / sizeof(exposure_map[0]); + +/// Structure to cross reference awb strings against the MMAL parameter equivalent +static XREF_T awb_map[] = +{ + {"off", MMAL_PARAM_AWBMODE_OFF}, + {"auto", MMAL_PARAM_AWBMODE_AUTO}, + {"sun", MMAL_PARAM_AWBMODE_SUNLIGHT}, + {"cloud", MMAL_PARAM_AWBMODE_CLOUDY}, + {"shade", MMAL_PARAM_AWBMODE_SHADE}, + {"tungsten", MMAL_PARAM_AWBMODE_TUNGSTEN}, + {"fluorescent", MMAL_PARAM_AWBMODE_FLUORESCENT}, + {"incandescent", MMAL_PARAM_AWBMODE_INCANDESCENT}, + {"flash", MMAL_PARAM_AWBMODE_FLASH}, + {"horizon", MMAL_PARAM_AWBMODE_HORIZON} +}; + +static const int awb_map_size = sizeof(awb_map) / sizeof(awb_map[0]); + +/// Structure to cross reference image effect against the MMAL parameter equivalent +static XREF_T imagefx_map[] = +{ + {"none", MMAL_PARAM_IMAGEFX_NONE}, + {"negative", MMAL_PARAM_IMAGEFX_NEGATIVE}, + {"solarise", MMAL_PARAM_IMAGEFX_SOLARIZE}, + {"sketch", MMAL_PARAM_IMAGEFX_SKETCH}, + {"denoise", MMAL_PARAM_IMAGEFX_DENOISE}, + {"emboss", MMAL_PARAM_IMAGEFX_EMBOSS}, + {"oilpaint", MMAL_PARAM_IMAGEFX_OILPAINT}, + {"hatch", MMAL_PARAM_IMAGEFX_HATCH}, + {"gpen", MMAL_PARAM_IMAGEFX_GPEN}, + {"pastel", MMAL_PARAM_IMAGEFX_PASTEL}, + {"watercolour", MMAL_PARAM_IMAGEFX_WATERCOLOUR}, + {"film", MMAL_PARAM_IMAGEFX_FILM}, + {"blur", MMAL_PARAM_IMAGEFX_BLUR}, + {"saturation", MMAL_PARAM_IMAGEFX_SATURATION}, + {"colourswap", MMAL_PARAM_IMAGEFX_COLOURSWAP}, + {"washedout", MMAL_PARAM_IMAGEFX_WASHEDOUT}, + {"posterise", MMAL_PARAM_IMAGEFX_POSTERISE}, + {"colourpoint", MMAL_PARAM_IMAGEFX_COLOURPOINT}, + {"colourbalance", MMAL_PARAM_IMAGEFX_COLOURBALANCE}, + {"cartoon", MMAL_PARAM_IMAGEFX_CARTOON} + }; + +static const int imagefx_map_size = sizeof(imagefx_map) / sizeof(imagefx_map[0]); + +static XREF_T metering_mode_map[] = +{ + {"average", MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE}, + {"spot", MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT}, + {"backlit", MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT}, + {"matrix", MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX} +}; + +static const int metering_mode_map_size = sizeof(metering_mode_map)/sizeof(metering_mode_map[0]); + +static XREF_T drc_mode_map[] = +{ + {"off", MMAL_PARAMETER_DRC_STRENGTH_OFF}, + {"low", MMAL_PARAMETER_DRC_STRENGTH_LOW}, + {"med", MMAL_PARAMETER_DRC_STRENGTH_MEDIUM}, + {"high", MMAL_PARAMETER_DRC_STRENGTH_HIGH} +}; + +static const int drc_mode_map_size = sizeof(drc_mode_map)/sizeof(drc_mode_map[0]); + +static XREF_T stereo_mode_map[] = +{ + {"off", MMAL_STEREOSCOPIC_MODE_NONE}, + {"sbs", MMAL_STEREOSCOPIC_MODE_SIDE_BY_SIDE}, + {"tb", MMAL_STEREOSCOPIC_MODE_TOP_BOTTOM}, +}; + +static const int stereo_mode_map_size = sizeof(stereo_mode_map)/sizeof(stereo_mode_map[0]); + + +#define CommandSharpness 0 +#define CommandContrast 1 +#define CommandBrightness 2 +#define CommandSaturation 3 +#define CommandISO 4 +#define CommandVideoStab 5 +#define CommandEVComp 6 +#define CommandExposure 7 +#define CommandAWB 8 +#define CommandImageFX 9 +#define CommandColourFX 10 +#define CommandMeterMode 11 +#define CommandRotation 12 +#define CommandHFlip 13 +#define CommandVFlip 14 +#define CommandROI 15 +#define CommandShutterSpeed 16 +#define CommandAwbGains 17 +#define CommandDRCLevel 18 +#define CommandStatsPass 19 +#define CommandAnnotate 20 +#define CommandStereoMode 21 +#define CommandStereoDecimate 22 +#define CommandStereoSwap 23 +#define CommandAnnotateExtras 24 + +static COMMAND_LIST cmdline_commands[] = +{ + {CommandSharpness, "-sharpness", "sh", "Set image sharpness (-100 to 100)", 1}, + {CommandContrast, "-contrast", "co", "Set image contrast (-100 to 100)", 1}, + {CommandBrightness, "-brightness","br", "Set image brightness (0 to 100)", 1}, + {CommandSaturation, "-saturation","sa", "Set image saturation (-100 to 100)", 1}, + {CommandISO, "-ISO", "ISO","Set capture ISO", 1}, + {CommandVideoStab, "-vstab", "vs", "Turn on video stabilisation", 0}, + {CommandEVComp, "-ev", "ev", "Set EV compensation - steps of 1/6 stop", 1}, + {CommandExposure, "-exposure", "ex", "Set exposure mode (see Notes)", 1}, + {CommandAWB, "-awb", "awb","Set AWB mode (see Notes)", 1}, + {CommandImageFX, "-imxfx", "ifx","Set image effect (see Notes)", 1}, + {CommandColourFX, "-colfx", "cfx","Set colour effect (U:V)", 1}, + {CommandMeterMode, "-metering", "mm", "Set metering mode (see Notes)", 1}, + {CommandRotation, "-rotation", "rot","Set image rotation (0-359)", 1}, + {CommandHFlip, "-hflip", "hf", "Set horizontal flip", 0}, + {CommandVFlip, "-vflip", "vf", "Set vertical flip", 0}, + {CommandROI, "-roi", "roi","Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])", 1}, + {CommandShutterSpeed,"-shutter", "ss", "Set shutter speed in microseconds", 1}, + {CommandAwbGains, "-awbgains", "awbg", "Set AWB gains - AWB mode must be off", 1}, + {CommandDRCLevel, "-drc", "drc", "Set DRC Level (see Notes)", 1}, + {CommandStatsPass, "-stats", "st", "Force recomputation of statistics on stills capture pass"}, + {CommandAnnotate, "-annotate", "a", "Enable/Set annotate flags or text", 1}, + {CommandStereoMode, "-stereo", "3d", "Select stereoscopic mode", 1}, + {CommandStereoDecimate,"-decimate","dec", "Half width/height of stereo image"}, + {CommandStereoSwap, "-3dswap", "3dswap", "Swap camera order for stereoscopic"}, + {CommandAnnotateExtras,"-annotateex","ae", "Set extra annotation parameters (text size, text colour(hex YUV), bg colour(hex YUV))", 2}, +}; + +static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_commands[0]); + + +#define parameter_reset -99999 + +/** + * Update the passed in parameter according to the rest of the parameters + * passed in. + * + * + * @return 0 if reached end of cycle for this parameter, !0 otherwise + */ +static int update_cycle_parameter(int *option, int min, int max, int increment) +{ + vcos_assert(option); + if (!option) + return 0; + + if (*option == parameter_reset) + *option = min - increment; + + *option += increment; + + if (*option > max) + { + *option = parameter_reset; + return 0; + } + else + return 1; +} + + +/** + * Test/Demo code to cycle through a bunch of camera settings + * This code is pretty hacky so please don't complain!! + * It only does stuff that should have a visual impact (hence demo!) + * This will override any user supplied parameters + * + * Each call of this function will move on to the next setting + * + * @param camera Pointer to the camera to change settings on. + * @return 0 if reached end of complete sequence, !0 otherwise + */ + +int raspicamcontrol_cycle_test(MMAL_COMPONENT_T *camera) +{ + static int parameter = 0; + static int parameter_option = parameter_reset; // which value the parameter currently has + + vcos_assert(camera); + + // We are going to cycle through all the relevant entries in the parameter block + // and send options to the camera. + if (parameter == 0) + { + // sharpness + if (update_cycle_parameter(¶meter_option, -100, 100, 10)) + raspicamcontrol_set_sharpness(camera, parameter_option); + else + { + raspicamcontrol_set_sharpness(camera, 0); + parameter++; + } + } + else + if (parameter == 1) + { + // contrast + if (update_cycle_parameter(¶meter_option, -100, 100, 10)) + raspicamcontrol_set_contrast(camera, parameter_option); + else + { + raspicamcontrol_set_contrast(camera, 0); + parameter++; + } + } + else + if (parameter == 2) + { + // brightness + if (update_cycle_parameter(¶meter_option, 0, 100, 10)) + raspicamcontrol_set_brightness(camera, parameter_option); + else + { + raspicamcontrol_set_brightness(camera, 50); + parameter++; + } + } + else + if (parameter == 3) + { + // contrast + if (update_cycle_parameter(¶meter_option, -100, 100, 10)) + raspicamcontrol_set_saturation(camera, parameter_option); + else + { + parameter++; + raspicamcontrol_set_saturation(camera, 0); + } + } + else + if (parameter == 4) + { + // EV + if (update_cycle_parameter(¶meter_option, -10, 10, 4)) + raspicamcontrol_set_exposure_compensation(camera, parameter_option); + else + { + raspicamcontrol_set_exposure_compensation(camera, 0); + parameter++; + } + } + else + if (parameter == 5) + { + // MMAL_PARAM_EXPOSUREMODE_T + if (update_cycle_parameter(¶meter_option, 0, exposure_map_size, 1)) + raspicamcontrol_set_exposure_mode(camera, exposure_map[parameter_option].mmal_mode); + else + { + raspicamcontrol_set_exposure_mode(camera, MMAL_PARAM_EXPOSUREMODE_AUTO); + parameter++; + } + } + else + if (parameter == 6) + { + // MMAL_PARAM_AWB_T + if (update_cycle_parameter(¶meter_option, 0, awb_map_size, 1)) + raspicamcontrol_set_awb_mode(camera, awb_map[parameter_option].mmal_mode); + else + { + raspicamcontrol_set_awb_mode(camera, MMAL_PARAM_AWBMODE_AUTO); + parameter++; + } + } + if (parameter == 7) + { + // MMAL_PARAM_IMAGEFX_T + if (update_cycle_parameter(¶meter_option, 0, imagefx_map_size, 1)) + raspicamcontrol_set_imageFX(camera, imagefx_map[parameter_option].mmal_mode); + else + { + raspicamcontrol_set_imageFX(camera, MMAL_PARAM_IMAGEFX_NONE); + parameter++; + } + } + if (parameter == 8) + { + MMAL_PARAM_COLOURFX_T colfx = {0,0,0}; + switch (parameter_option) + { + case parameter_reset : + parameter_option = 1; + colfx.u = 128; + colfx.v = 128; + break; + case 1 : + parameter_option = 2; + colfx.u = 100; + colfx.v = 200; + break; + case 2 : + parameter_option = parameter_reset; + colfx.enable = 0; + parameter++; + break; + } + raspicamcontrol_set_colourFX(camera, &colfx); + } + + // Orientation + if (parameter == 9) + { + switch (parameter_option) + { + case parameter_reset: + raspicamcontrol_set_rotation(camera, 90); + parameter_option = 1; + break; + + case 1 : + raspicamcontrol_set_rotation(camera, 180); + parameter_option = 2; + break; + + case 2 : + raspicamcontrol_set_rotation(camera, 270); + parameter_option = 3; + break; + + case 3 : + { + raspicamcontrol_set_rotation(camera, 0); + raspicamcontrol_set_flips(camera, 1,0); + parameter_option = 4; + break; + } + case 4 : + { + raspicamcontrol_set_flips(camera, 0,1); + parameter_option = 5; + break; + } + case 5 : + { + raspicamcontrol_set_flips(camera, 1, 1); + parameter_option = 6; + break; + } + case 6 : + { + raspicamcontrol_set_flips(camera, 0, 0); + parameter_option = parameter_reset; + parameter++; + break; + } + } + } + + if (parameter == 10) + { + parameter = 1; + return 0; + } + + return 1; +} + + + +/** + * Convert string to the MMAL parameter for exposure mode + * @param str Incoming string to match + * @return MMAL parameter matching the string, or the AUTO option if no match found + */ +static MMAL_PARAM_EXPOSUREMODE_T exposure_mode_from_string(const char *str) +{ + int i = raspicli_map_xref(str, exposure_map, exposure_map_size); + + if( i != -1) + return (MMAL_PARAM_EXPOSUREMODE_T)i; + + vcos_log_error("Unknown exposure mode: %s", str); + return MMAL_PARAM_EXPOSUREMODE_AUTO; +} + +/** + * Convert string to the MMAL parameter for AWB mode + * @param str Incoming string to match + * @return MMAL parameter matching the string, or the AUTO option if no match found + */ +static MMAL_PARAM_AWBMODE_T awb_mode_from_string(const char *str) +{ + int i = raspicli_map_xref(str, awb_map, awb_map_size); + + if( i != -1) + return (MMAL_PARAM_AWBMODE_T)i; + + vcos_log_error("Unknown awb mode: %s", str); + return MMAL_PARAM_AWBMODE_AUTO; +} + +/** + * Convert string to the MMAL parameter for image effects mode + * @param str Incoming string to match + * @return MMAL parameter matching the strong, or the AUTO option if no match found + */ +MMAL_PARAM_IMAGEFX_T imagefx_mode_from_string(const char *str) +{ + int i = raspicli_map_xref(str, imagefx_map, imagefx_map_size); + + if( i != -1) + return (MMAL_PARAM_IMAGEFX_T)i; + + vcos_log_error("Unknown image fx: %s", str); + return MMAL_PARAM_IMAGEFX_NONE; +} + +/** + * Convert string to the MMAL parameter for exposure metering mode + * @param str Incoming string to match + * @return MMAL parameter matching the string, or the AUTO option if no match found + */ +static MMAL_PARAM_EXPOSUREMETERINGMODE_T metering_mode_from_string(const char *str) +{ + int i = raspicli_map_xref(str, metering_mode_map, metering_mode_map_size); + + if( i != -1) + return (MMAL_PARAM_EXPOSUREMETERINGMODE_T)i; + + vcos_log_error("Unknown metering mode: %s", str); + return MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE; +} + +/** + * Convert string to the MMAL parameter for DRC level + * @param str Incoming string to match + * @return MMAL parameter matching the string, or the AUTO option if no match found + */ +static MMAL_PARAMETER_DRC_STRENGTH_T drc_mode_from_string(const char *str) +{ + int i = raspicli_map_xref(str, drc_mode_map, drc_mode_map_size); + + if( i != -1) + return (MMAL_PARAMETER_DRC_STRENGTH_T)i; + + vcos_log_error("Unknown DRC level: %s", str); + return MMAL_PARAMETER_DRC_STRENGTH_OFF; +} + +/** + * Convert string to the MMAL parameter for exposure metering mode + * @param str Incoming string to match + * @return MMAL parameter matching the string, or the AUTO option if no match found + */ +static MMAL_STEREOSCOPIC_MODE_T stereo_mode_from_string(const char *str) +{ + int i = raspicli_map_xref(str, stereo_mode_map, stereo_mode_map_size); + + if( i != -1) + return (MMAL_STEREOSCOPIC_MODE_T)i; + + vcos_log_error("Unknown metering mode: %s", str); + return MMAL_STEREOSCOPIC_MODE_NONE; +} + +/** + * Parse a possible command pair - command and parameter + * @param arg1 Command + * @param arg2 Parameter (could be NULL) + * @return How many parameters were used, 0,1,2 + */ +int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char *arg1, const char *arg2) +{ + int command_id, used = 0, num_parameters; + + if (!arg1) + return 0; + + command_id = raspicli_get_command_id(cmdline_commands, cmdline_commands_size, arg1, &num_parameters); + + // If invalid command, or we are missing a parameter, drop out + if (command_id==-1 || (command_id != -1 && num_parameters > 0 && arg2 == NULL)) + return 0; + + switch (command_id) + { + case CommandSharpness : // sharpness - needs single number parameter + sscanf(arg2, "%d", ¶ms->sharpness); + used = 2; + break; + + case CommandContrast : // contrast - needs single number parameter + sscanf(arg2, "%d", ¶ms->contrast); + used = 2; + break; + + case CommandBrightness : // brightness - needs single number parameter + sscanf(arg2, "%d", ¶ms->brightness); + used = 2; + break; + + case CommandSaturation : // saturation - needs single number parameter + sscanf(arg2, "%d", ¶ms->saturation); + used = 2; + break; + + case CommandISO : // ISO - needs single number parameter + sscanf(arg2, "%d", ¶ms->ISO); + used = 2; + break; + + case CommandVideoStab : // video stabilisation - if here, its on + params->videoStabilisation = 1; + used = 1; + break; + + case CommandEVComp : // EV - needs single number parameter + sscanf(arg2, "%d", ¶ms->exposureCompensation); + used = 2; + break; + + case CommandExposure : // exposure mode - needs string + params->exposureMode = exposure_mode_from_string(arg2); + used = 2; + break; + + case CommandAWB : // AWB mode - needs single number parameter + params->awbMode = awb_mode_from_string(arg2); + used = 2; + break; + + case CommandImageFX : // Image FX - needs string + params->imageEffect = imagefx_mode_from_string(arg2); + used = 2; + break; + + case CommandColourFX : // Colour FX - needs string "u:v" + sscanf(arg2, "%d:%d", ¶ms->colourEffects.u, ¶ms->colourEffects.v); + params->colourEffects.enable = 1; + used = 2; + break; + + case CommandMeterMode: + params->exposureMeterMode = metering_mode_from_string(arg2); + used = 2; + break; + + case CommandRotation : // Rotation - degree + sscanf(arg2, "%d", ¶ms->rotation); + used = 2; + break; + + case CommandHFlip : + params->hflip = 1; + used = 1; + break; + + case CommandVFlip : + params->vflip = 1; + used = 1; + break; + + case CommandROI : + { + double x,y,w,h; + int args; + + args = sscanf(arg2, "%lf,%lf,%lf,%lf", &x,&y,&w,&h); + + if (args != 4 || x > 1.0 || y > 1.0 || w > 1.0 || h > 1.0) + { + return 0; + } + + // Make sure we stay within bounds + if (x + w > 1.0) + w = 1 - x; + + if (y + h > 1.0) + h = 1 - y; + + params->roi.x = x; + params->roi.y = y; + params->roi.w = w; + params->roi.h = h; + + used = 2; + break; + } + + case CommandShutterSpeed : // Shutter speed needs single number parameter + { + sscanf(arg2, "%d", ¶ms->shutter_speed); + used = 2; + break; + } + + case CommandAwbGains : + { + double r,b; + int args; + + args = sscanf(arg2, "%lf,%lf", &r,&b); + + if (args != 2 || r > 8.0 || b > 8.0) + { + return 0; + } + + params->awb_gains_r = r; + params->awb_gains_b = b; + + used = 2; + break; + } + + case CommandDRCLevel: + { + params->drc_level = drc_mode_from_string(arg2); + used = 2; + break; + } + + case CommandStatsPass: + { + params->stats_pass = MMAL_TRUE; + used = 1; + break; + } + + case CommandAnnotate: + { + char dummy; + unsigned int bitmask; + // If parameter is a number, assume its a bitmask, otherwise a string + if (sscanf(arg2, "%u%c", &bitmask, &dummy) == 1) + { + params->enable_annotate |= bitmask; + } + else + { + params->enable_annotate |= ANNOTATE_USER_TEXT; + //copy string char by char and replace "\n" with newline character + unsigned char c; + char const *s = arg2; + char *t = ¶ms->annotate_string[0]; + int n=0; + while ((c = *s++) && n < MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1) + { + if (c == '\\' && *s) + { + switch (c = *s++) + { + case 'n': + c = '\n'; + break; + + default: + c = '\\'; + s--; + break; + } + } + *(t++) = c; + n++; + } + *t='\0'; + + //params->annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0'; + } + used=2; + break; + } + + case CommandAnnotateExtras: + { + // 3 parameters - text size (6-80), text colour (Hex VVUUYY) and background colour (Hex VVUUYY) + sscanf(arg2, "%u,%X,%X", ¶ms->annotate_text_size, + ¶ms->annotate_text_colour, + ¶ms->annotate_bg_colour); + used=2; + break; + } + + case CommandStereoMode: + { + params->stereo_mode.mode = stereo_mode_from_string(arg2); + used = 2; + break; + } + + case CommandStereoDecimate: + { + params->stereo_mode.decimate = MMAL_TRUE; + used = 1; + break; + } + + case CommandStereoSwap: + { + params->stereo_mode.swap_eyes = MMAL_TRUE; + used = 1; + break; + } + + } + + return used; +} + +/** + * Display help for command line options + */ +void raspicamcontrol_display_help() +{ + int i; + + fprintf(stdout, "\nImage parameter commands\n\n"); + + raspicli_display_help(cmdline_commands, cmdline_commands_size); + + fprintf(stdout, "\n\nNotes\n\nExposure mode options :\n%s", exposure_map[0].mode ); + + for (i=1;iexposureMode, exposure_map, exposure_map_size); + const char *awb_mode = raspicli_unmap_xref(params->awbMode, awb_map, awb_map_size); + const char *image_effect = raspicli_unmap_xref(params->imageEffect, imagefx_map, imagefx_map_size); + const char *metering_mode = raspicli_unmap_xref(params->exposureMeterMode, metering_mode_map, metering_mode_map_size); + + fprintf(stderr, "Sharpness %d, Contrast %d, Brightness %d\n", params->sharpness, params->contrast, params->brightness); + fprintf(stderr, "Saturation %d, ISO %d, Video Stabilisation %s, Exposure compensation %d\n", params->saturation, params->ISO, params->videoStabilisation ? "Yes": "No", params->exposureCompensation); + fprintf(stderr, "Exposure Mode '%s', AWB Mode '%s', Image Effect '%s'\n", exp_mode, awb_mode, image_effect); + fprintf(stderr, "Metering Mode '%s', Colour Effect Enabled %s with U = %d, V = %d\n", metering_mode, params->colourEffects.enable ? "Yes":"No", params->colourEffects.u, params->colourEffects.v); + fprintf(stderr, "Rotation %d, hflip %s, vflip %s\n", params->rotation, params->hflip ? "Yes":"No",params->vflip ? "Yes":"No"); + fprintf(stderr, "ROI x %lf, y %f, w %f h %f\n", params->roi.x, params->roi.y, params->roi.w, params->roi.h); +} + +/** + * Convert a MMAL status return value to a simple boolean of success + * ALso displays a fault if code is not success + * + * @param status The error code to convert + * @return 0 if status is success, 1 otherwise + */ +int mmal_status_to_int(MMAL_STATUS_T status) +{ + if (status == MMAL_SUCCESS) + return 0; + else + { + switch (status) + { + case MMAL_ENOMEM : vcos_log_error("Out of memory"); break; + case MMAL_ENOSPC : vcos_log_error("Out of resources (other than memory)"); break; + case MMAL_EINVAL: vcos_log_error("Argument is invalid"); break; + case MMAL_ENOSYS : vcos_log_error("Function not implemented"); break; + case MMAL_ENOENT : vcos_log_error("No such file or directory"); break; + case MMAL_ENXIO : vcos_log_error("No such device or address"); break; + case MMAL_EIO : vcos_log_error("I/O error"); break; + case MMAL_ESPIPE : vcos_log_error("Illegal seek"); break; + case MMAL_ECORRUPT : vcos_log_error("Data is corrupt \attention FIXME: not POSIX"); break; + case MMAL_ENOTREADY :vcos_log_error("Component is not ready \attention FIXME: not POSIX"); break; + case MMAL_ECONFIG : vcos_log_error("Component is not configured \attention FIXME: not POSIX"); break; + case MMAL_EISCONN : vcos_log_error("Port is already connected "); break; + case MMAL_ENOTCONN : vcos_log_error("Port is disconnected"); break; + case MMAL_EAGAIN : vcos_log_error("Resource temporarily unavailable. Try again later"); break; + case MMAL_EFAULT : vcos_log_error("Bad address"); break; + default : vcos_log_error("Unknown status error"); break; + } + + return 1; + } +} + +/** + * Give the supplied parameter block a set of default values + * @params Pointer to parameter block + */ +void raspicamcontrol_set_defaults(RASPICAM_CAMERA_PARAMETERS *params) +{ + vcos_assert(params); + + params->sharpness = 0; + params->contrast = 0; + params->brightness = 50; + params->saturation = 0; + params->ISO = 0; // 0 = auto + params->videoStabilisation = 0; + params->exposureCompensation = 0; + params->exposureMode = MMAL_PARAM_EXPOSUREMODE_AUTO; + params->exposureMeterMode = MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE; + params->awbMode = MMAL_PARAM_AWBMODE_AUTO; + params->imageEffect = MMAL_PARAM_IMAGEFX_NONE; + params->colourEffects.enable = 0; + params->colourEffects.u = 128; + params->colourEffects.v = 128; + params->rotation = 0; + params->hflip = params->vflip = 0; + params->roi.x = params->roi.y = 0.0; + params->roi.w = params->roi.h = 1.0; + params->shutter_speed = 0; // 0 = auto + params->awb_gains_r = 0; // Only have any function if AWB OFF is used. + params->awb_gains_b = 0; + params->drc_level = MMAL_PARAMETER_DRC_STRENGTH_OFF; + params->stats_pass = MMAL_FALSE; + params->enable_annotate = 0; + params->annotate_string[0] = '\0'; + params->annotate_text_size = 0; //Use firmware default + params->annotate_text_colour = -1; //Use firmware default + params->annotate_bg_colour = -1; //Use firmware default + params->stereo_mode.mode = MMAL_STEREOSCOPIC_MODE_NONE; + params->stereo_mode.decimate = MMAL_FALSE; + params->stereo_mode.swap_eyes = MMAL_FALSE; +} + +/** + * Get all the current camera parameters from specified camera component + * @param camera Pointer to camera component + * @param params Pointer to parameter block to accept settings + * @return 0 if successful, non-zero if unsuccessful + */ +int raspicamcontrol_get_all_parameters(MMAL_COMPONENT_T *camera, RASPICAM_CAMERA_PARAMETERS *params) +{ + vcos_assert(camera); + vcos_assert(params); + + if (!camera || !params) + return 1; + +/* TODO : Write these get functions + params->sharpness = raspicamcontrol_get_sharpness(camera); + params->contrast = raspicamcontrol_get_contrast(camera); + params->brightness = raspicamcontrol_get_brightness(camera); + params->saturation = raspicamcontrol_get_saturation(camera); + params->ISO = raspicamcontrol_get_ISO(camera); + params->videoStabilisation = raspicamcontrol_get_video_stabilisation(camera); + params->exposureCompensation = raspicamcontrol_get_exposure_compensation(camera); + params->exposureMode = raspicamcontrol_get_exposure_mode(camera); + params->awbMode = raspicamcontrol_get_awb_mode(camera); + params->imageEffect = raspicamcontrol_get_image_effect(camera); + params->colourEffects = raspicamcontrol_get_colour_effect(camera); + params->thumbnailConfig = raspicamcontrol_get_thumbnail_config(camera); +*/ + return 0; +} + +/** + * Set the specified camera to all the specified settings + * @param camera Pointer to camera component + * @param params Pointer to parameter block containing parameters + * @return 0 if successful, none-zero if unsuccessful. + */ +int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_CAMERA_PARAMETERS *params) +{ + int result; + + result = raspicamcontrol_set_saturation(camera, params->saturation); + result += raspicamcontrol_set_sharpness(camera, params->sharpness); + result += raspicamcontrol_set_contrast(camera, params->contrast); + result += raspicamcontrol_set_brightness(camera, params->brightness); + result += raspicamcontrol_set_ISO(camera, params->ISO); + result += raspicamcontrol_set_video_stabilisation(camera, params->videoStabilisation); + result += raspicamcontrol_set_exposure_compensation(camera, params->exposureCompensation); + result += raspicamcontrol_set_exposure_mode(camera, params->exposureMode); + result += raspicamcontrol_set_metering_mode(camera, params->exposureMeterMode); + result += raspicamcontrol_set_awb_mode(camera, params->awbMode); + result += raspicamcontrol_set_awb_gains(camera, params->awb_gains_r, params->awb_gains_b); + result += raspicamcontrol_set_imageFX(camera, params->imageEffect); + result += raspicamcontrol_set_colourFX(camera, ¶ms->colourEffects); + //result += raspicamcontrol_set_thumbnail_parameters(camera, ¶ms->thumbnailConfig); TODO Not working for some reason + result += raspicamcontrol_set_rotation(camera, params->rotation); + result += raspicamcontrol_set_flips(camera, params->hflip, params->vflip); + result += raspicamcontrol_set_ROI(camera, params->roi); + result += raspicamcontrol_set_shutter_speed(camera, params->shutter_speed); + result += raspicamcontrol_set_DRC(camera, params->drc_level); + result += raspicamcontrol_set_stats_pass(camera, params->stats_pass); + result += raspicamcontrol_set_annotate(camera, params->enable_annotate, params->annotate_string, + params->annotate_text_size, + params->annotate_text_colour, + params->annotate_bg_colour); + + return result; +} + +/** + * Adjust the saturation level for images + * @param camera Pointer to camera component + * @param saturation Value to adjust, -100 to 100 + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_saturation(MMAL_COMPONENT_T *camera, int saturation) +{ + int ret = 0; + + if (!camera) + return 1; + + if (saturation >= -100 && saturation <= 100) + { + MMAL_RATIONAL_T value = {saturation, 100}; + ret = mmal_status_to_int(mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_SATURATION, value)); + } + else + { + vcos_log_error("Invalid saturation value"); + ret = 1; + } + + return ret; +} + +/** + * Set the sharpness of the image + * @param camera Pointer to camera component + * @param sharpness Sharpness adjustment -100 to 100 + */ +int raspicamcontrol_set_sharpness(MMAL_COMPONENT_T *camera, int sharpness) +{ + int ret = 0; + + if (!camera) + return 1; + + if (sharpness >= -100 && sharpness <= 100) + { + MMAL_RATIONAL_T value = {sharpness, 100}; + ret = mmal_status_to_int(mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_SHARPNESS, value)); + } + else + { + vcos_log_error("Invalid sharpness value"); + ret = 1; + } + + return ret; +} + +/** + * Set the contrast adjustment for the image + * @param camera Pointer to camera component + * @param contrast Contrast adjustment -100 to 100 + * @return + */ +int raspicamcontrol_set_contrast(MMAL_COMPONENT_T *camera, int contrast) +{ + int ret = 0; + + if (!camera) + return 1; + + if (contrast >= -100 && contrast <= 100) + { + MMAL_RATIONAL_T value = {contrast, 100}; + ret = mmal_status_to_int(mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_CONTRAST, value)); + } + else + { + vcos_log_error("Invalid contrast value"); + ret = 1; + } + + return ret; +} + +/** + * Adjust the brightness level for images + * @param camera Pointer to camera component + * @param brightness Value to adjust, 0 to 100 + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_brightness(MMAL_COMPONENT_T *camera, int brightness) +{ + int ret = 0; + + if (!camera) + return 1; + + if (brightness >= 0 && brightness <= 100) + { + MMAL_RATIONAL_T value = {brightness, 100}; + ret = mmal_status_to_int(mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_BRIGHTNESS, value)); + } + else + { + vcos_log_error("Invalid brightness value"); + ret = 1; + } + + return ret; +} + +/** + * Adjust the ISO used for images + * @param camera Pointer to camera component + * @param ISO Value to set TODO : + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_ISO(MMAL_COMPONENT_T *camera, int ISO) +{ + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set_uint32(camera->control, MMAL_PARAMETER_ISO, ISO)); +} + +/** + * Adjust the metering mode for images + * @param camera Pointer to camera component + * @param saturation Value from following + * - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE, + * - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT, + * - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT, + * - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_metering_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMETERINGMODE_T m_mode ) +{ + MMAL_PARAMETER_EXPOSUREMETERINGMODE_T meter_mode = {{MMAL_PARAMETER_EXP_METERING_MODE,sizeof(meter_mode)}, + m_mode}; + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, &meter_mode.hdr)); +} + + +/** + * Set the video stabilisation flag. Only used in video mode + * @param camera Pointer to camera component + * @param saturation Flag 0 off 1 on + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_video_stabilisation(MMAL_COMPONENT_T *camera, int vstabilisation) +{ + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set_boolean(camera->control, MMAL_PARAMETER_VIDEO_STABILISATION, vstabilisation)); +} + +/** + * Adjust the exposure compensation for images (EV) + * @param camera Pointer to camera component + * @param exp_comp Value to adjust, -10 to +10 + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_exposure_compensation(MMAL_COMPONENT_T *camera, int exp_comp) +{ + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set_int32(camera->control, MMAL_PARAMETER_EXPOSURE_COMP , exp_comp)); +} + + +/** + * Set exposure mode for images + * @param camera Pointer to camera component + * @param mode Exposure mode to set from + * - MMAL_PARAM_EXPOSUREMODE_OFF, + * - MMAL_PARAM_EXPOSUREMODE_AUTO, + * - MMAL_PARAM_EXPOSUREMODE_NIGHT, + * - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, + * - MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, + * - MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT, + * - MMAL_PARAM_EXPOSUREMODE_SPORTS, + * - MMAL_PARAM_EXPOSUREMODE_SNOW, + * - MMAL_PARAM_EXPOSUREMODE_BEACH, + * - MMAL_PARAM_EXPOSUREMODE_VERYLONG, + * - MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, + * - MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, + * - MMAL_PARAM_EXPOSUREMODE_FIREWORKS, + * + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_exposure_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMODE_T mode) +{ + MMAL_PARAMETER_EXPOSUREMODE_T exp_mode = {{MMAL_PARAMETER_EXPOSURE_MODE,sizeof(exp_mode)}, mode}; + + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, &exp_mode.hdr)); +} + + +/** + * Set the aWB (auto white balance) mode for images + * @param camera Pointer to camera component + * @param awb_mode Value to set from + * - MMAL_PARAM_AWBMODE_OFF, + * - MMAL_PARAM_AWBMODE_AUTO, + * - MMAL_PARAM_AWBMODE_SUNLIGHT, + * - MMAL_PARAM_AWBMODE_CLOUDY, + * - MMAL_PARAM_AWBMODE_SHADE, + * - MMAL_PARAM_AWBMODE_TUNGSTEN, + * - MMAL_PARAM_AWBMODE_FLUORESCENT, + * - MMAL_PARAM_AWBMODE_INCANDESCENT, + * - MMAL_PARAM_AWBMODE_FLASH, + * - MMAL_PARAM_AWBMODE_HORIZON, + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_awb_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_AWBMODE_T awb_mode) +{ + MMAL_PARAMETER_AWBMODE_T param = {{MMAL_PARAMETER_AWB_MODE,sizeof(param)}, awb_mode}; + + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, ¶m.hdr)); +} + +int raspicamcontrol_set_awb_gains(MMAL_COMPONENT_T *camera, float r_gain, float b_gain) +{ + MMAL_PARAMETER_AWB_GAINS_T param = {{MMAL_PARAMETER_CUSTOM_AWB_GAINS,sizeof(param)}, {0,0}, {0,0}}; + + if (!camera) + return 1; + + if (!r_gain || !b_gain) + return 0; + + param.r_gain.num = (unsigned int)(r_gain * 65536); + param.b_gain.num = (unsigned int)(b_gain * 65536); + param.r_gain.den = param.b_gain.den = 65536; + return mmal_status_to_int(mmal_port_parameter_set(camera->control, ¶m.hdr)); +} + +/** + * Set the image effect for the images + * @param camera Pointer to camera component + * @param imageFX Value from + * - MMAL_PARAM_IMAGEFX_NONE, + * - MMAL_PARAM_IMAGEFX_NEGATIVE, + * - MMAL_PARAM_IMAGEFX_SOLARIZE, + * - MMAL_PARAM_IMAGEFX_POSTERIZE, + * - MMAL_PARAM_IMAGEFX_WHITEBOARD, + * - MMAL_PARAM_IMAGEFX_BLACKBOARD, + * - MMAL_PARAM_IMAGEFX_SKETCH, + * - MMAL_PARAM_IMAGEFX_DENOISE, + * - MMAL_PARAM_IMAGEFX_EMBOSS, + * - MMAL_PARAM_IMAGEFX_OILPAINT, + * - MMAL_PARAM_IMAGEFX_HATCH, + * - MMAL_PARAM_IMAGEFX_GPEN, + * - MMAL_PARAM_IMAGEFX_PASTEL, + * - MMAL_PARAM_IMAGEFX_WATERCOLOUR, + * - MMAL_PARAM_IMAGEFX_FILM, + * - MMAL_PARAM_IMAGEFX_BLUR, + * - MMAL_PARAM_IMAGEFX_SATURATION, + * - MMAL_PARAM_IMAGEFX_COLOURSWAP, + * - MMAL_PARAM_IMAGEFX_WASHEDOUT, + * - MMAL_PARAM_IMAGEFX_POSTERISE, + * - MMAL_PARAM_IMAGEFX_COLOURPOINT, + * - MMAL_PARAM_IMAGEFX_COLOURBALANCE, + * - MMAL_PARAM_IMAGEFX_CARTOON, + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_imageFX(MMAL_COMPONENT_T *camera, MMAL_PARAM_IMAGEFX_T imageFX) +{ + MMAL_PARAMETER_IMAGEFX_T imgFX = {{MMAL_PARAMETER_IMAGE_EFFECT,sizeof(imgFX)}, imageFX}; + + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, &imgFX.hdr)); +} + +/* TODO :what to do with the image effects parameters? + MMAL_PARAMETER_IMAGEFX_PARAMETERS_T imfx_param = {{MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,sizeof(imfx_param)}, + imageFX, 0, {0}}; +mmal_port_parameter_set(camera->control, &imfx_param.hdr); + */ + +/** + * Set the colour effect for images (Set UV component) + * @param camera Pointer to camera component + * @param colourFX Contains enable state and U and V numbers to set (e.g. 128,128 = Black and white) + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_colourFX(MMAL_COMPONENT_T *camera, const MMAL_PARAM_COLOURFX_T *colourFX) +{ + MMAL_PARAMETER_COLOURFX_T colfx = {{MMAL_PARAMETER_COLOUR_EFFECT,sizeof(colfx)}, 0, 0, 0}; + + if (!camera) + return 1; + + colfx.enable = colourFX->enable; + colfx.u = colourFX->u; + colfx.v = colourFX->v; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, &colfx.hdr)); + +} + + +/** + * Set the rotation of the image + * @param camera Pointer to camera component + * @param rotation Degree of rotation (any number, but will be converted to 0,90,180 or 270 only) + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_rotation(MMAL_COMPONENT_T *camera, int rotation) +{ + int ret; + int my_rotation = ((rotation % 360 ) / 90) * 90; + + ret = mmal_port_parameter_set_int32(camera->output[0], MMAL_PARAMETER_ROTATION, my_rotation); + mmal_port_parameter_set_int32(camera->output[1], MMAL_PARAMETER_ROTATION, my_rotation); + mmal_port_parameter_set_int32(camera->output[2], MMAL_PARAMETER_ROTATION, my_rotation); + + return ret; +} + +/** + * Set the flips state of the image + * @param camera Pointer to camera component + * @param hflip If true, horizontally flip the image + * @param vflip If true, vertically flip the image + * + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_flips(MMAL_COMPONENT_T *camera, int hflip, int vflip) +{ + MMAL_PARAMETER_MIRROR_T mirror = {{MMAL_PARAMETER_MIRROR, sizeof(MMAL_PARAMETER_MIRROR_T)}, MMAL_PARAM_MIRROR_NONE}; + + if (hflip && vflip) + mirror.value = MMAL_PARAM_MIRROR_BOTH; + else + if (hflip) + mirror.value = MMAL_PARAM_MIRROR_HORIZONTAL; + else + if (vflip) + mirror.value = MMAL_PARAM_MIRROR_VERTICAL; + + mmal_port_parameter_set(camera->output[0], &mirror.hdr); + mmal_port_parameter_set(camera->output[1], &mirror.hdr); + return mmal_port_parameter_set(camera->output[2], &mirror.hdr); +} + +/** + * Set the ROI of the sensor to use for captures/preview + * @param camera Pointer to camera component + * @param rect Normalised coordinates of ROI rectangle + * + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect) +{ + MMAL_PARAMETER_INPUT_CROP_T crop = {{MMAL_PARAMETER_INPUT_CROP, sizeof(MMAL_PARAMETER_INPUT_CROP_T)}}; + + crop.rect.x = (65536 * rect.x); + crop.rect.y = (65536 * rect.y); + crop.rect.width = (65536 * rect.w); + crop.rect.height = (65536 * rect.h); + + return mmal_port_parameter_set(camera->control, &crop.hdr); +} + +/** + * Adjust the exposure time used for images + * @param camera Pointer to camera component + * @param shutter speed in microseconds + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed) +{ + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set_uint32(camera->control, MMAL_PARAMETER_SHUTTER_SPEED, speed)); +} + +/** + * Adjust the Dynamic range compression level + * @param camera Pointer to camera component + * @param strength Strength of DRC to apply + * MMAL_PARAMETER_DRC_STRENGTH_OFF + * MMAL_PARAMETER_DRC_STRENGTH_LOW + * MMAL_PARAMETER_DRC_STRENGTH_MEDIUM + * MMAL_PARAMETER_DRC_STRENGTH_HIGH + * + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_DRC(MMAL_COMPONENT_T *camera, MMAL_PARAMETER_DRC_STRENGTH_T strength) +{ + MMAL_PARAMETER_DRC_T drc = {{MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, sizeof(MMAL_PARAMETER_DRC_T)}, strength}; + + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, &drc.hdr)); +} + +int raspicamcontrol_set_stats_pass(MMAL_COMPONENT_T *camera, int stats_pass) +{ + if (!camera) + return 1; + + return mmal_status_to_int(mmal_port_parameter_set_boolean(camera->control, MMAL_PARAMETER_CAPTURE_STATS_PASS, stats_pass)); +} + + +/** + * Set the annotate data + * @param camera Pointer to camera component + * @param Bitmask of required annotation data. 0 for off. + * @param If set, a pointer to text string to use instead of bitmask, max length 32 characters + * + * @return 0 if successful, non-zero if any parameters out of range + */ +int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, const char *string, + const int text_size, const int text_colour, const int bg_colour) +{ + MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T annotate = + {{MMAL_PARAMETER_ANNOTATE, sizeof(MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T)}}; + + if (settings) + { + time_t t = time(NULL); + struct tm tm = *localtime(&t); + char tmp[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3]; + int process_datetime = 1; + + annotate.enable = 1; + + if (settings & (ANNOTATE_APP_TEXT | ANNOTATE_USER_TEXT)) + { + if ((settings & (ANNOTATE_TIME_TEXT | ANNOTATE_DATE_TEXT)) && strchr(string,'%') != NULL) + { //string contains strftime parameter? + strftime(annotate.text, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3, string, &tm ); + process_datetime = 0; + }else{ + strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3); + } + annotate.text[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0'; + } + + if (process_datetime && (settings & ANNOTATE_TIME_TEXT)) + { + if(strlen(annotate.text)){ + strftime(tmp, 32, " %X", &tm ); + }else{ + strftime(tmp, 32, "%X", &tm ); + } + strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text) - 1); + } + + if (process_datetime && (settings & ANNOTATE_DATE_TEXT)) + { + if(strlen(annotate.text)){ + strftime(tmp, 32, " %x", &tm ); + }else{ + strftime(tmp, 32, "%x", &tm ); + } + strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text) - 1); + } + + if (settings & ANNOTATE_SHUTTER_SETTINGS) + annotate.show_shutter = MMAL_TRUE; + + if (settings & ANNOTATE_GAIN_SETTINGS) + annotate.show_analog_gain = MMAL_TRUE; + + if (settings & ANNOTATE_LENS_SETTINGS) + annotate.show_lens = MMAL_TRUE; + + if (settings & ANNOTATE_CAF_SETTINGS) + annotate.show_caf = MMAL_TRUE; + + if (settings & ANNOTATE_MOTION_SETTINGS) + annotate.show_motion = MMAL_TRUE; + + if (settings & ANNOTATE_FRAME_NUMBER) + annotate.show_frame_num = MMAL_TRUE; + + if (settings & ANNOTATE_BLACK_BACKGROUND) + annotate.enable_text_background = MMAL_TRUE; + + annotate.text_size = text_size; + + if (text_colour != -1) + { + annotate.custom_text_colour = MMAL_TRUE; + annotate.custom_text_Y = text_colour&0xff; + annotate.custom_text_U = (text_colour>>8)&0xff; + annotate.custom_text_V = (text_colour>>16)&0xff; + } + else + annotate.custom_text_colour = MMAL_FALSE; + + if (bg_colour != -1) + { + annotate.custom_background_colour = MMAL_TRUE; + annotate.custom_background_Y = bg_colour&0xff; + annotate.custom_background_U = (bg_colour>>8)&0xff; + annotate.custom_background_V = (bg_colour>>16)&0xff; + } + else + annotate.custom_background_colour = MMAL_FALSE; + } + else + annotate.enable = 0; + + return mmal_status_to_int(mmal_port_parameter_set(camera->control, &annotate.hdr)); +} + +int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOPIC_MODE_T *stereo_mode) +{ + MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo = { {MMAL_PARAMETER_STEREOSCOPIC_MODE, sizeof(stereo)}, + MMAL_STEREOSCOPIC_MODE_NONE, MMAL_FALSE, MMAL_FALSE }; + if (stereo_mode->mode != MMAL_STEREOSCOPIC_MODE_NONE) + { + stereo.mode = stereo_mode->mode; + stereo.decimate = stereo_mode->decimate; + stereo.swap_eyes = stereo_mode->swap_eyes; + } + return mmal_status_to_int(mmal_port_parameter_set(port, &stereo.hdr)); +} + +/** + * Asked GPU how much memory it has allocated + * + * @return amount of memory in MB + */ +static int raspicamcontrol_get_mem_gpu(void) +{ + char response[80] = ""; + int gpu_mem = 0; + if (vc_gencmd(response, sizeof response, "get_mem gpu") == 0) + vc_gencmd_number_property(response, "gpu", &gpu_mem); + return gpu_mem; +} + +/** + * Ask GPU about its camera abilities + * @param supported None-zero if software supports the camera + * @param detected None-zero if a camera has been detected + */ +static void raspicamcontrol_get_camera(int *supported, int *detected) +{ + char response[80] = ""; + if (vc_gencmd(response, sizeof response, "get_camera") == 0) + { + if (supported) + vc_gencmd_number_property(response, "supported", supported); + if (detected) + vc_gencmd_number_property(response, "detected", detected); + } +} + +/** + * Check to see if camera is supported, and we have allocated enough meooryAsk GPU about its camera abilities + * @param supported None-zero if software supports the camera + * @param detected None-zero if a camera has been detected + */ +void raspicamcontrol_check_configuration(int min_gpu_mem) +{ + int gpu_mem = raspicamcontrol_get_mem_gpu(); + int supported = 0, detected = 0; + raspicamcontrol_get_camera(&supported, &detected); + if (!supported) + vcos_log_error("Camera is not enabled in this build. Try running \"sudo raspi-config\" and ensure that \"camera\" has been enabled\n"); + else if (gpu_mem < min_gpu_mem) + vcos_log_error("Only %dM of gpu_mem is configured. Try running \"sudo raspi-config\" and ensure that \"memory_split\" has a value of %d or greater\n", gpu_mem, min_gpu_mem); + else if (!detected) + vcos_log_error("Camera is not detected. Please check carefully the camera module is installed correctly\n"); + else + vcos_log_error("Failed to run camera app. Please check for firmware updates\n"); +} + diff --git a/raspicam/RaspiCamControl.h b/raspicam/RaspiCamControl.h new file mode 100644 index 0000000..f4c189a --- /dev/null +++ b/raspicam/RaspiCamControl.h @@ -0,0 +1,217 @@ +/* +Copyright (c) 2013, Broadcom Europe Ltd +Copyright (c) 2013, James Hughes +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef RASPICAMCONTROL_H_ +#define RASPICAMCONTROL_H_ + +/* Various parameters + * + * Exposure Mode + * MMAL_PARAM_EXPOSUREMODE_OFF, + MMAL_PARAM_EXPOSUREMODE_AUTO, + MMAL_PARAM_EXPOSUREMODE_NIGHT, + MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, + MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, + MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT, + MMAL_PARAM_EXPOSUREMODE_SPORTS, + MMAL_PARAM_EXPOSUREMODE_SNOW, + MMAL_PARAM_EXPOSUREMODE_BEACH, + MMAL_PARAM_EXPOSUREMODE_VERYLONG, + MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, + MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, + MMAL_PARAM_EXPOSUREMODE_FIREWORKS, + * + * AWB Mode + * MMAL_PARAM_AWBMODE_OFF, + MMAL_PARAM_AWBMODE_AUTO, + MMAL_PARAM_AWBMODE_SUNLIGHT, + MMAL_PARAM_AWBMODE_CLOUDY, + MMAL_PARAM_AWBMODE_SHADE, + MMAL_PARAM_AWBMODE_TUNGSTEN, + MMAL_PARAM_AWBMODE_FLUORESCENT, + MMAL_PARAM_AWBMODE_INCANDESCENT, + MMAL_PARAM_AWBMODE_FLASH, + MMAL_PARAM_AWBMODE_HORIZON, + * + * Image FX + MMAL_PARAM_IMAGEFX_NONE, + MMAL_PARAM_IMAGEFX_NEGATIVE, + MMAL_PARAM_IMAGEFX_SOLARIZE, + MMAL_PARAM_IMAGEFX_POSTERIZE, + MMAL_PARAM_IMAGEFX_WHITEBOARD, + MMAL_PARAM_IMAGEFX_BLACKBOARD, + MMAL_PARAM_IMAGEFX_SKETCH, + MMAL_PARAM_IMAGEFX_DENOISE, + MMAL_PARAM_IMAGEFX_EMBOSS, + MMAL_PARAM_IMAGEFX_OILPAINT, + MMAL_PARAM_IMAGEFX_HATCH, + MMAL_PARAM_IMAGEFX_GPEN, + MMAL_PARAM_IMAGEFX_PASTEL, + MMAL_PARAM_IMAGEFX_WATERCOLOUR, + MMAL_PARAM_IMAGEFX_FILM, + MMAL_PARAM_IMAGEFX_BLUR, + MMAL_PARAM_IMAGEFX_SATURATION, + MMAL_PARAM_IMAGEFX_COLOURSWAP, + MMAL_PARAM_IMAGEFX_WASHEDOUT, + MMAL_PARAM_IMAGEFX_POSTERISE, + MMAL_PARAM_IMAGEFX_COLOURPOINT, + MMAL_PARAM_IMAGEFX_COLOURBALANCE, + MMAL_PARAM_IMAGEFX_CARTOON, + + */ + +/// Annotate bitmask options +/// Supplied by user on command line +#define ANNOTATE_USER_TEXT 1 +/// Supplied by app using this module +#define ANNOTATE_APP_TEXT 2 +/// Insert current date +#define ANNOTATE_DATE_TEXT 4 +// Insert current time +#define ANNOTATE_TIME_TEXT 8 + +#define ANNOTATE_SHUTTER_SETTINGS 16 +#define ANNOTATE_CAF_SETTINGS 32 +#define ANNOTATE_GAIN_SETTINGS 64 +#define ANNOTATE_LENS_SETTINGS 128 +#define ANNOTATE_MOTION_SETTINGS 256 +#define ANNOTATE_FRAME_NUMBER 512 +#define ANNOTATE_BLACK_BACKGROUND 1024 + + +// There isn't actually a MMAL structure for the following, so make one +typedef struct mmal_param_colourfx_s +{ + int enable; /// Turn colourFX on or off + int u,v; /// U and V to use +} MMAL_PARAM_COLOURFX_T; + +typedef struct mmal_param_thumbnail_config_s +{ + int enable; + int width,height; + int quality; +} MMAL_PARAM_THUMBNAIL_CONFIG_T; + +typedef struct param_float_rect_s +{ + double x; + double y; + double w; + double h; +} PARAM_FLOAT_RECT_T; + +/// struct contain camera settings +typedef struct raspicam_camera_parameters_s +{ + int sharpness; /// -100 to 100 + int contrast; /// -100 to 100 + int brightness; /// 0 to 100 + int saturation; /// -100 to 100 + int ISO; /// TODO : what range? + int videoStabilisation; /// 0 or 1 (false or true) + int exposureCompensation; /// -10 to +10 ? + MMAL_PARAM_EXPOSUREMODE_T exposureMode; + MMAL_PARAM_EXPOSUREMETERINGMODE_T exposureMeterMode; + MMAL_PARAM_AWBMODE_T awbMode; + MMAL_PARAM_IMAGEFX_T imageEffect; + MMAL_PARAMETER_IMAGEFX_PARAMETERS_T imageEffectsParameters; + MMAL_PARAM_COLOURFX_T colourEffects; + int rotation; /// 0-359 + int hflip; /// 0 or 1 + int vflip; /// 0 or 1 + PARAM_FLOAT_RECT_T roi; /// region of interest to use on the sensor. Normalised [0,1] values in the rect + int shutter_speed; /// 0 = auto, otherwise the shutter speed in ms + float awb_gains_r; /// AWB red gain + float awb_gains_b; /// AWB blue gain + MMAL_PARAMETER_DRC_STRENGTH_T drc_level; // Strength of Dynamic Range compression to apply + MMAL_BOOL_T stats_pass; /// Stills capture statistics pass on/off + int enable_annotate; /// Flag to enable the annotate, 0 = disabled, otherwise a bitmask of what needs to be displayed + char annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2]; /// String to use for annotate - overrides certain bitmask settings + int annotate_text_size; // Text size for annotation + int annotate_text_colour; // Text colour for annotation + int annotate_bg_colour; // Background colour for annotation + MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo_mode; +} RASPICAM_CAMERA_PARAMETERS; + + +void raspicamcontrol_check_configuration(int min_gpu_mem); + +int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char *arg1, const char *arg2); +void raspicamcontrol_display_help(); +int raspicamcontrol_cycle_test(MMAL_COMPONENT_T *camera); + +int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_CAMERA_PARAMETERS *params); +int raspicamcontrol_get_all_parameters(MMAL_COMPONENT_T *camera, RASPICAM_CAMERA_PARAMETERS *params); +void raspicamcontrol_dump_parameters(const RASPICAM_CAMERA_PARAMETERS *params); + +void raspicamcontrol_set_defaults(RASPICAM_CAMERA_PARAMETERS *params); + +void raspicamcontrol_check_configuration(int min_gpu_mem); + +// Individual setting functions +int raspicamcontrol_set_saturation(MMAL_COMPONENT_T *camera, int saturation); +int raspicamcontrol_set_sharpness(MMAL_COMPONENT_T *camera, int sharpness); +int raspicamcontrol_set_contrast(MMAL_COMPONENT_T *camera, int contrast); +int raspicamcontrol_set_brightness(MMAL_COMPONENT_T *camera, int brightness); +int raspicamcontrol_set_ISO(MMAL_COMPONENT_T *camera, int ISO); +int raspicamcontrol_set_metering_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMETERINGMODE_T mode); +int raspicamcontrol_set_video_stabilisation(MMAL_COMPONENT_T *camera, int vstabilisation); +int raspicamcontrol_set_exposure_compensation(MMAL_COMPONENT_T *camera, int exp_comp); +int raspicamcontrol_set_exposure_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMODE_T mode); +int raspicamcontrol_set_awb_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_AWBMODE_T awb_mode); +int raspicamcontrol_set_awb_gains(MMAL_COMPONENT_T *camera, float r_gain, float b_gain); +int raspicamcontrol_set_imageFX(MMAL_COMPONENT_T *camera, MMAL_PARAM_IMAGEFX_T imageFX); +int raspicamcontrol_set_colourFX(MMAL_COMPONENT_T *camera, const MMAL_PARAM_COLOURFX_T *colourFX); +int raspicamcontrol_set_rotation(MMAL_COMPONENT_T *camera, int rotation); +int raspicamcontrol_set_flips(MMAL_COMPONENT_T *camera, int hflip, int vflip); +int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect); +int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed_ms); +int raspicamcontrol_set_DRC(MMAL_COMPONENT_T *camera, MMAL_PARAMETER_DRC_STRENGTH_T strength); +int raspicamcontrol_set_stats_pass(MMAL_COMPONENT_T *camera, int stats_pass); +int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int bitmask, const char *string, + const int text_size, const int text_colour, const int bg_colour); +int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOPIC_MODE_T *stereo_mode); + +//Individual getting functions +int raspicamcontrol_get_saturation(MMAL_COMPONENT_T *camera); +int raspicamcontrol_get_sharpness(MMAL_COMPONENT_T *camera); +int raspicamcontrol_get_contrast(MMAL_COMPONENT_T *camera); +int raspicamcontrol_get_brightness(MMAL_COMPONENT_T *camera); +int raspicamcontrol_get_ISO(MMAL_COMPONENT_T *camera); +MMAL_PARAM_EXPOSUREMETERINGMODE_T raspicamcontrol_get_metering_mode(MMAL_COMPONENT_T *camera); +int raspicamcontrol_get_video_stabilisation(MMAL_COMPONENT_T *camera); +int raspicamcontrol_get_exposure_compensation(MMAL_COMPONENT_T *camera); +MMAL_PARAM_THUMBNAIL_CONFIG_T raspicamcontrol_get_thumbnail_parameters(MMAL_COMPONENT_T *camera); +MMAL_PARAM_EXPOSUREMODE_T raspicamcontrol_get_exposure_mode(MMAL_COMPONENT_T *camera); +MMAL_PARAM_AWBMODE_T raspicamcontrol_get_awb_mode(MMAL_COMPONENT_T *camera); +MMAL_PARAM_IMAGEFX_T raspicamcontrol_get_imageFX(MMAL_COMPONENT_T *camera); +MMAL_PARAM_COLOURFX_T raspicamcontrol_get_colourFX(MMAL_COMPONENT_T *camera); + + +#endif /* RASPICAMCONTROL_H_ */ diff --git a/video_common.c b/video_common.c index 6575147..976b79c 100644 --- a/video_common.c +++ b/video_common.c @@ -550,6 +550,15 @@ void vid_close(struct context *cnt) #endif /* WITHOUT_V4L */ /* Cleanup the netcam part */ +#ifdef HAVE_MMAL + if (cnt->mmalcam) { + MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: calling mmalcam_cleanup"); + mmalcam_cleanup(cnt->mmalcam); + cnt->mmalcam = NULL; + return; + } + else +#endif if (cnt->netcam) { MOTION_LOG(INF, TYPE_VIDEO, NO_ERRNO, "%s: calling netcam_cleanup"); netcam_cleanup(cnt->netcam, 0); @@ -858,6 +867,16 @@ int vid_start(struct context *cnt) struct config *conf = &cnt->conf; int dev = -1; +#ifdef HAVE_MMAL + if (conf->mmalcam_name) { + dev = mmalcam_start(cnt); + if (dev < 0) { + mmalcam_cleanup(cnt->mmalcam); + cnt->mmalcam = NULL; + } + } + else +#endif if (conf->netcam_url) { dev = netcam_start(cnt); if (dev < 0) { @@ -901,6 +920,15 @@ int vid_next(struct context *cnt, unsigned char *map) int ret = -2; struct config *conf = &cnt->conf; +#ifdef HAVE_MMAL + if (conf->mmalcam_name) { + if (cnt->mmalcam == NULL) { + return NETCAM_GENERAL_ERROR; + } + return mmalcam_next(cnt, map); + } + else +#endif if (conf->netcam_url) { if (cnt->video_dev == -1) return NETCAM_GENERAL_ERROR; From 31ddc676725d76b9a94a01e89282bd6e080f8cca Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sat, 10 Sep 2016 19:40:49 +0100 Subject: [PATCH 198/233] Add camera_name setting to allow each camera to be given a name Based on a commit originally by Chris Roberts <86montecarlo@gmail.com> camera_name allows naming of threads, is displayed in the motion control webpage, and a new specifier (%$) added enabling it to be used for filenames and such. The changes I have made since Chris's commit: 1. Change format specifier for threadname from %E to %$ This avoids clashing with any known strftime format specifiers. (According to the Debian stable strftime man page - it seems we've already used all spare letters to mean other things.) 2. Behaviour if camera_name is not set is now unchanged (Previous it would display "thread 1 -- NULL" if the thread name was unset, and I don't believe how printf deals with NULL values for %s specifiers is guaranteed.) 3. Thread name is reflected into the system thread name Uses pthread_setname_np. There's a autoconf test for it, which looks for the version that takes the thread id and thread name. I believe this should work on all recent linux, and maybe other platforms too. (It won't work on macOS; autoconf will disable it - but I deliberately always use the pthread_setname_np(pthread_self(), name) form so that it could easily be adapted for macOS in the future.) 4. The parameter has been renamed from thread_name to camera_name, as that seems to better reflect how the user will see it. --- conf.c | 10 +++ conf.h | 1 + configure.ac | 11 +++ motion.c | 18 ++++ netcam.c | 11 +++ netcam_rtsp.c | 21 +++++ stream.c | 8 ++ webhttpd.c | 237 +++++++++++++++++++++++++++++++++++--------------- 8 files changed, 249 insertions(+), 68 deletions(-) diff --git a/conf.c b/conf.c index 324d066..fab89dc 100644 --- a/conf.c +++ b/conf.c @@ -43,6 +43,7 @@ char *get_current_dir_name(void) #define stripnewline(x) {if ((x)[strlen(x)-1]=='\n') (x)[strlen(x) - 1] = 0; } struct config conf_template = { + camera_name: NULL, width: DEF_WIDTH, height: DEF_HEIGHT, quality: DEF_QUALITY, @@ -213,6 +214,15 @@ config_param config_params[] = { print_bool }, { + "camera_name", + "# Name given to a camera/thread. Shown in web interface and may be used with the specifier %$ for filenames and such.\n" + "# Default: not defined", + 0, + CONF_OFFSET(camera_name), + copy_string, + print_string + }, + { "logfile", "# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)", 1, diff --git a/conf.h b/conf.h index 93ae036..fe2faf7 100644 --- a/conf.h +++ b/conf.h @@ -19,6 +19,7 @@ * More parameters may be added later. */ struct config { + const char *camera_name; unsigned int log_level; char *log_type_str; char *log_file; diff --git a/configure.ac b/configure.ac index 458735e..2e62407 100644 --- a/configure.ac +++ b/configure.ac @@ -208,6 +208,17 @@ else fi +if test "x$PTHREAD_SUPPORT" = "xyes"; then + AC_MSG_CHECKING([[for pthread_setname_np]]) + CFLAGS="$TEMP_CFLAGS" + LIBS="$TEMP_LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], [[ pthread_setname_np(pthread_self(), "name")]])], + [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP]], [[1]], [Define if you have pthread_setname_np function.]) + AC_MSG_RESULT([[yes]])], + [AC_MSG_RESULT([[no]])] ) +fi + # # Check for sdl library # diff --git a/motion.c b/motion.c index d0568fa..98bfb31 100644 --- a/motion.c +++ b/motion.c @@ -1101,6 +1101,17 @@ static void *motion_loop(void *arg) unsigned int get_image = 1; /* Flag used to signal that we capture new image when we run the loop */ struct image_data *old_image; +#ifdef HAVE_PTHREAD_SETNAME_NP + { + char tname[16]; + snprintf(tname, sizeof(tname), "ml%d%s%s", + cnt->threadnr, + cnt->conf.camera_name ? ":" : "", + cnt->conf.camera_name ? cnt->conf.camera_name : ""); + pthread_setname_np(pthread_self(), tname); + } +#endif + /* * Next two variables are used for snapshot and timelapse feature * time_last_frame is set to 1 so that first coming timelapse or second = 0 @@ -3236,6 +3247,13 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us ++pos_userformat; break; + case '$': // thread name + if (cnt->conf.camera_name && cnt->conf.camera_name[0]) + snprintf(tempstr, PATH_MAX, "%s", cnt->conf.camera_name); + else + ++pos_userformat; + break; + default: // Any other code is copied with the %-sign *format++ = '%'; *format++ = *pos_userformat; diff --git a/netcam.c b/netcam.c index 522ccdc..bf63200 100644 --- a/netcam.c +++ b/netcam.c @@ -1893,6 +1893,17 @@ static void *netcam_handler_loop(void *arg) netcam_context_ptr netcam = arg; struct context *cnt = netcam->cnt; /* Needed for the SETUP macro :-( */ +#ifdef HAVE_PTHREAD_SETNAME_NP + { + char tname[16]; + snprintf(tname, sizeof(tname), "nc%d%s%s", + cnt->threadnr, + cnt->conf.camera_name ? ":" : "", + cnt->conf.camera_name ? cnt->conf.camera_name : ""); + pthread_setname_np(pthread_self(), tname); + } +#endif + /* Store the corresponding motion thread number in TLS also for this * thread (necessary for 'MOTION_LOG' to function properly). */ diff --git a/netcam_rtsp.c b/netcam_rtsp.c index 7a3cf01..5ec33e4 100644 --- a/netcam_rtsp.c +++ b/netcam_rtsp.c @@ -484,7 +484,28 @@ static int netcam_rtsp_open_context(netcam_context_ptr netcam){ return -1; } +#ifdef HAVE_PTHREAD_SETNAME_NP + /* there is no way to set the avcodec thread names, but they inherit + * our thread name - so temporarily change our thread name to the + * desired name */ + { + char curtname[16]; + char newtname[16]; + pthread_getname_np(pthread_self(), curtname, sizeof(curtname)); + snprintf(newtname, sizeof(newtname), "av%d%s%s", + netcam->cnt->threadnr, + netcam->cnt->conf.camera_name ? ":" : "", + netcam->cnt->conf.camera_name ? netcam->cnt->conf.camera_name : ""); + pthread_setname_np(pthread_self(), newtname); +#endif + retcd = netcam_open_codec(&netcam->rtsp->video_stream_index, netcam->rtsp->format_context, AVMEDIA_TYPE_VIDEO); + +#ifdef HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(pthread_self(), curtname); + } +#endif + if (retcd < 0) { if (netcam->rtsp->status == RTSP_NOTCONNECTED){ av_strerror(retcd, errstr, sizeof(errstr)); diff --git a/stream.c b/stream.c index 782a966..ff26abf 100644 --- a/stream.c +++ b/stream.c @@ -179,6 +179,10 @@ static void* handle_basic_auth(void* param) "Pragma: no-cache\r\n" "WWW-Authenticate: Basic realm=\""STREAM_REALM"\"\r\n\r\n"; +#ifdef HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(pthread_self(), "handle_basic_auth"); +#endif + pthread_mutex_lock(&stream_auth_mutex); p->thread_count++; pthread_mutex_unlock(&stream_auth_mutex); @@ -430,6 +434,10 @@ static void* handle_md5_digest(void* param) "

                                                  500 Internal Server Error

                                                  \r\n" "\r\n"; +#ifdef HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(pthread_self(), "handle_md5_digest"); +#endif + pthread_mutex_lock(&stream_auth_mutex); p->thread_count++; pthread_mutex_unlock(&stream_auth_mutex); diff --git a/webhttpd.c b/webhttpd.c index 9d07864..ccad77e 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -418,8 +418,11 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, /*call list*/ if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                  \nThread %hu\n
                                                    ", - thread, thread); + sprintf(res, "<– back

                                                    \nThread %hu%s%s\n
                                                      ", + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); + send_template(client_socket, res); for (i=0; config_params[i].param_name != NULL; i++) { @@ -548,10 +551,13 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back" - "

                                                      \nThread %hu\n" + "

                                                      \nThread %hu%s%s\n" "
                                                      • %s = %s" "
                                                      Done", - thread, thread, thread, config_params[i].param_name, + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, config_params[i].param_name, config_params[i].param_name, Value); send_template_ini_client(client_socket, ini_template); @@ -594,8 +600,11 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                      \n" - "Thread %hu\n
                                                      • %s" - "= %s

                                                      Done", thread, thread, thread, + "Thread %hu%s%s\n
                                                      • %s" + "= %s

                                                      Done", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, config_params[i].param_name, config_params[i].param_name, type); send_template_ini_client(client_socket, ini_template); @@ -661,7 +670,7 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, "\n"); sprintf(res, "<– back

                                                      \n" - "Thread %hu\n" + "Thread %hu%s%s\n" "
                                                      \n" "%s \n" "\n" "    " "[help]" "
                                                      \n
                                                      %s", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", config_params[i].param_name, config_params[i].param_name, value, TWIKI_URL, config_params[i].param_name, text_help); } @@ -709,8 +722,10 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, } else if (length_uri == 0) { if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, set_template); - sprintf(res, "<– back

                                                      \nThread %hu\n" - "
                                                      \n\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); for (i=0; config_params[i].param_name != NULL; i++) { @@ -803,10 +818,13 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                      \n" - "Thread %hu
                                                      \n
                                                      • %s = %s   " + "Thread %hu%s%s
                                                        \n
                                                        %s", - thread, thread, config_params[i].param_name, value, + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + config_params[i].param_name, value, TWIKI_URL, config_params[i].param_name, text_help); send_template(client_socket, res); @@ -837,9 +855,11 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, } else if (length_uri == 0) { if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu
                                                        \n" + sprintf(res, "<– back

                                                        \nThread %hu%s%s
                                                        \n" "\n" - "\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); for (i=0; config_params[i].param_name != NULL; i++) { if ((thread != 0) && (config_params[i].main_thread)) @@ -896,8 +916,10 @@ static unsigned int config(char *pointer, char *res, unsigned int length_uri, conf_print(cnt); if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu write done !\n", - thread, thread); + sprintf(res, "<– back

                                                        \nThread %hu%s%s write done !\n", + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1131,8 +1153,10 @@ static unsigned int detection(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        Thread %hu" + sprintf(res, "<– back

                                                        Thread %hu%s%s" " Detection status %s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", (!cnt[thread]->running)? "NOT RUNNING": (cnt[thread]->pause)? "PAUSE":"ACTIVE"); send_template(client_socket, res); send_template_end_client(client_socket); @@ -1165,8 +1189,10 @@ static unsigned int detection(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu" - " Detection resumed\n", thread, thread); + sprintf(res, "<– back

                                                        \nThread %hu%s%s" + " Detection resumed\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1197,13 +1223,17 @@ static unsigned int detection(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu" - " Detection paused\n", thread, thread); + sprintf(res, "<– back

                                                        \nThread %hu%s%s" + " Detection paused\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); - sprintf(res, "Thread %hu Detection paused\nDone\n", thread); + sprintf(res, "Thread %hu%s%s Detection paused\nDone\n", thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template_raw(client_socket, res); } } else { @@ -1225,13 +1255,17 @@ static unsigned int detection(char *pointer, char *res, unsigned int length_uri, send_template(client_socket, res); if (thread == 0) { do{ - sprintf(res, "Thread %hu %s
                                                        \n", i, + sprintf(res, "Thread %hu%s%s %s
                                                        \n", i, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", (!cnt[i]->running)? "NOT RUNNING" : (cnt[i]->lost_connection)?CONNECTION_KO:CONNECTION_OK); send_template(client_socket, res); } while (cnt[++i]); } else { - sprintf(res, "Thread %hu %s\n", thread, + sprintf(res, "Thread %hu%s%s %s\n", thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", (!cnt[thread]->running)? "NOT RUNNING" : (cnt[thread]->lost_connection)? CONNECTION_KO: CONNECTION_OK); send_template(client_socket, res); @@ -1403,9 +1437,12 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        \n" + "Thread %hu%s%s
                                                        \n" "track set relative pan=%s
                                                        \n", - thread, thread, panvalue); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + panvalue); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1417,7 +1454,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track action */ if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                        " - "Thread %hu\n", thread, thread); + "Thread %hu%s%s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1440,9 +1479,12 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        \n" + "Thread %hu%s%s
                                                        \n" "track set relative tilt=%s\n", - thread, thread, tiltvalue); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + tiltvalue); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1454,7 +1496,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track action */ if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                        " - "Thread %hu\n", thread, thread); + "Thread %hu%s%s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1469,9 +1513,12 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        \n" - "track set absolute x=%s\n", - thread, thread, x_value); + "Thread %hu%s%s
                                                        \n" + "track set absolute x=%s\n", + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + x_value); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1483,7 +1530,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track action */ if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                        " - "Thread %hu\n", thread, thread); + "Thread %hu%s%s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1499,9 +1548,12 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        \n" + "Thread %hu%s%s
                                                        \n" "track set absolute y=%s
                                                        \n", - thread, thread, y_value); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + y_value); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1513,7 +1565,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track action */ if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                        " - "Thread %hu\n", thread, thread); + "Thread %hu%s%s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1671,9 +1725,12 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        \n" + "Thread %hu%s%s
                                                        \n" "track absolute set x=%s y=%s
                                                        \n", - thread, thread, x_value, y_value); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + x_value, y_value); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1685,7 +1742,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track action */ if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                        " - "Thread %hu\n", thread, thread); + "Thread %hu%s%s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1721,9 +1780,12 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        \n" + "Thread %hu%s%s
                                                        \n" "track relative pan=%s tilt=%s\n", - thread, thread, panvalue, tiltvalue); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + panvalue, tiltvalue); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1737,7 +1799,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track tilt */ if (cnt[0]->conf.webcontrol_html_output) { sprintf(res, "<– back

                                                        " - "Thread %hu\n", thread, thread); + "Thread %hu%s%s\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1747,8 +1811,10 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, /* error in track pan */ if (cnt[0]->conf.webcontrol_html_output) { - sprintf(res, "<– back

                                                        Thread %hu\n", - thread, thread); + sprintf(res, "<– back

                                                        Thread %hu%s%s\n", + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); response_client(client_socket, track_error, res); } else { response_client(client_socket, track_error_raw, NULL); @@ -1757,7 +1823,7 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, } else if (length_uri == 0) { if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu
                                                        \n" + sprintf(res, "<– back

                                                        \nThread %hu%s%s
                                                        \n" "\n" "Pan\n" "Tilt\n" @@ -1767,7 +1833,9 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, "X\n" "Y\n" "\n" - "
                                                      • \n", thread, thread); + "\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1793,8 +1861,10 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu" - "
                                                        track set center", thread, thread); + sprintf(res, "<– back

                                                        \nThread %hu%s%s" + "
                                                        track set center", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : ""); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1815,8 +1885,10 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (length_uri==0) { if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu" + sprintf(res, "<– back

                                                        \nThread %hu%s%s" "
                                                        track auto %s", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", (cnt[thread]->track.active)? "enabled":"disabled"); send_template(client_socket, res); send_template_end_client(client_socket); @@ -1856,9 +1928,11 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu
                                                        " - "track auto %s", thread, thread, - (cnt[thread]->track.active)? "enabled":"disabled"); + "Thread %hu%s%s
                                                        " + "track auto %s", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + (cnt[thread]->track.active)? "enabled":"disabled"); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -1877,8 +1951,10 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        " - "Thread %hu" + "Thread %hu%s%s" "
                                                        track auto %s
                                                        ", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", active ? "enabled":"disabled"); send_template(client_socket, res); send_template_end_client(client_socket); @@ -1910,12 +1986,15 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hu\n" + sprintf(res, "<– back

                                                        \nThread %hu%s%s\n" "
                                                        \n" - "
                                                        \n", thread, thread, (cnt[thread]->track.active) ? "selected":"", + "\n", thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + (cnt[thread]->track.active) ? "selected":"", (cnt[thread]->track.active) ? "selected":""); send_template(client_socket, res); send_template_end_client(client_socket); @@ -1974,7 +2053,7 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat sprintf(res, "Motion "VERSION" Running [%hu] Threads
                                                        \n" "All\n", i); send_template(client_socket, res); - + counter = 0; for (y = 1; y < i; y++) { counter++; @@ -1983,7 +2062,9 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat send_template(client_socket, res); counter = 0; } - sprintf(res, "Thread %hu\n", y, y); + sprintf(res, "Thread %hu%s%s\n", y, y, + cnt[y]->conf.camera_name ? " -- " : "", + cnt[y]->conf.camera_name ? cnt[y]->conf.camera_name : ""); send_template(client_socket, res); } sprintf(res, "
                                                        "); @@ -2056,12 +2137,15 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        \n" - "Thread %hd
                                                        \n" + "Thread %hd%s%s
                                                        \n" "list
                                                        \n" "write
                                                        \n" "set
                                                        \n" "get
                                                        \n", - thread, thread, thread, thread, thread, thread); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, thread, thread, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -2089,12 +2173,15 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        \n" - "Thread %hd
                                                        \n" + "Thread %hd%s%s
                                                        \n" "makemovie
                                                        \n" "snapshot
                                                        \n" "restart
                                                        \n" "quit
                                                        \n", - thread, thread, thread, thread, thread, thread); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, thread, thread, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -2123,12 +2210,15 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        \n" - "Thread %hd
                                                        \n" + "Thread %hd%s%s
                                                        \n" "status
                                                        \n" "start
                                                        \n" "pause
                                                        \n" "connection
                                                        \n", - thread, thread, thread, thread, thread, thread); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, thread, thread, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -2154,12 +2244,15 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res, "<– back

                                                        \n" - "Thread %hd
                                                        \n" + "Thread %hd%s%s
                                                        \n" "track set pan/tilt
                                                        \n" "track center
                                                        \n" "track auto
                                                        \n" "track status
                                                        \n", - thread, thread, thread, thread, thread, thread); + thread, thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, thread, thread, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -2203,12 +2296,15 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat /* /thread_number/ requested */ if (cnt[0]->conf.webcontrol_html_output) { send_template_ini_client(client_socket, ini_template); - sprintf(res, "<– back

                                                        \nThread %hd
                                                        \n" + sprintf(res, "<– back

                                                        \nThread %hd%s%s
                                                        \n" "config
                                                        \n" "action
                                                        \n" "detection
                                                        \n" "track
                                                        \n", - thread, thread, thread, thread, thread); + thread, + cnt[thread]->conf.camera_name ? " -- " : "", + cnt[thread]->conf.camera_name ? cnt[thread]->conf.camera_name : "", + thread, thread, thread, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { @@ -2577,6 +2673,11 @@ void httpd_run(struct context **cnt) void *motion_web_control(void *arg) { struct context **cnt = arg; + +#ifdef HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(pthread_self(), "web_control"); +#endif + httpd_run(cnt); /* From 6e10c846a10e3bf59b5d351a40527379144a0fa7 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 11 Sep 2016 08:48:31 +0100 Subject: [PATCH 199/233] Stop "make clean" deleting documentation jpgs make clean currently removes all jpgs, which means it deletes the jpgs used in the documentation (outputnormal1.jpg etc). This seems like it wasn't intended. I can't figure out why it deletes jpgs at all, it seems to date back to the initial import of version 3.2.5 into svn in 2005 - seems safe to remove it. --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 2fdc6e8..78c1752 100644 --- a/Makefile.in +++ b/Makefile.in @@ -259,7 +259,7 @@ uninstall remove: pre-build-info ################################################################################ clean: pre-build-info @echo "Removing compiled files and binaries..." - @rm -f *~ *.jpg *.o $(PROGS) combine $(DEPEND_FILE) + @rm -f *~ *.o $(PROGS) combine $(DEPEND_FILE) ################################################################################ # DIST restores the directory to distribution state. # From 6b7fd95fc0b960ed6ab5f004e647aa4a1afea8d5 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 11 Sep 2016 08:43:58 +0000 Subject: [PATCH 200/233] Fix for whitespace lines in config file The while loop was missing a condition to stop at the start of the line, so we'd carry on beyond the start of the buffer. Closes #88 --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.c b/conf.c index e94d682..8997cde 100644 --- a/conf.c +++ b/conf.c @@ -1750,7 +1750,7 @@ static struct context **conf_process(struct context **cnt, FILE *fp) /* Trim white space and any CR or LF at the end of the line. */ end = line + strlen(line) - 1; /* Point to the last non-null character in the string. */ - while (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r') + while (end >= line && (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r')) end--; *(end+1) = '\0'; From 4595d837465b3bd57bd94b5c9d710984b7ec73dd Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 11 Sep 2016 11:25:49 +0100 Subject: [PATCH 201/233] Possible fix for failure to connect to mysql on startup As per http://dev.mysql.com/doc/refman/5.7/en/mysql-library-init.html we should init the mysql library before starting any threads, as otherwise mysql_init is not thread safe. Closes #103 --- motion.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/motion.c b/motion.c index d0568fa..bb6fc16 100644 --- a/motion.c +++ b/motion.c @@ -2674,6 +2674,12 @@ int main (int argc, char **argv) */ ffmpeg_init(); #endif /* HAVE_FFMPEG */ +#ifdef HAVE_MYSQL + if (mysql_library_init(0, NULL, NULL)) { + fprintf(stderr, "could not initialize MySQL library\n"); + exit(1); + } +#endif /* HAVE_MYSQL */ #ifdef HAVE_SQLITE3 /* database_sqlite3 == NULL if not changed causes each thread to creat their own * sqlite3 connection this will only happens when using a non-threaded sqlite version */ From a2b732713db2eda1daa68e6e41f386dc769b9197 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 11 Sep 2016 13:04:20 +0000 Subject: [PATCH 202/233] Fix cases where gethostname() returns a name that doesn't work for client We currently rely on gethostname() to generate the links from the web control homepage to the camera streams - unfortunately if DNS isn't set up well the hostname won't be one the web browser can resolve (often the case on raspberry pi's, where the hostname is set to "raspberrypi" by default and users access them via IP address). To cater for these situations we look at the "Host:" header in the HTTP headers that came from the browser (which indicate which host the browser has been asked to connect to) and use that to generate the hostname to use in the links. If there's no Host: header (unlikely these days) we default back to the old behaviour. --- webhttpd.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/webhttpd.c b/webhttpd.c index 9d07864..8d003b0 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -15,6 +15,7 @@ #include #include #include +#include /* Timeout in seconds, used for read and write */ const int NONBLOCK_TIMEOUT = 1; @@ -1951,7 +1952,7 @@ static unsigned int track(char *pointer, char *res, unsigned int length_uri, * 0 on action restart or quit * 1 on success */ -static unsigned int handle_get(int client_socket, const char *url, void *userdata) +static unsigned int handle_get(int client_socket, const char *url, void *userdata, const char *httphostname) { struct context **cnt = userdata; @@ -1989,10 +1990,14 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat sprintf(res, "
                                                        "); send_template(client_socket, res); - //Send the preview section - hostname[1023] = '\0'; - gethostname(hostname, 1023); + if (!httphostname) + { + hostname[1023] = '\0'; + gethostname(hostname, 1023); + httphostname = hostname; + } + //Send the preview section for (y = 0; y < i; y++) { if (cnt[y]->conf.stream_port) { if (cnt[y]->conf.stream_preview_newline) { @@ -2001,8 +2006,8 @@ static unsigned int handle_get(int client_socket, const char *url, void *userdat } sprintf(res, " " "\n" - ,hostname,cnt[y]->conf.stream_port - ,hostname,cnt[y]->conf.stream_port + ,httphostname,cnt[y]->conf.stream_port + ,httphostname,cnt[y]->conf.stream_port ,cnt[y]->conf.stream_preview_scale); send_template(client_socket, res); } @@ -2272,6 +2277,7 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) char url[512]={'\0'}; char protocol[10]={'\0'}; char *authentication=NULL; + char *hostname=NULL; buffer[nread] = '\0'; @@ -2346,6 +2352,33 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) return 1; } + if ((hostname = strstr(buffer,"Host:"))) { + /* use the hostname the browser used to connect to us when + * constructing links to the stream ports. If available + * (which it is in all modern browsers) it is more likely to + * work that the result of gethostname(), which is reliant on + * the machine we're running on having it's hostname setup + * correctly and corresponding DNS in place. */ + char *end_host = NULL; + hostname += strlen("Host:"); + while (isspace(*hostname)) + hostname++; + + if ((end_host = strstr(hostname,"\r\n"))) { + /* we have a string that is the hostname followed by + * optionally a colon and a port number - strip off any + * port number & colon */ + char *colon = memchr(hostname, ':', hostname-end_host); + if (colon) + end_host = colon; + while (isspace(end_host[-1])) + end_host--; + hostname = strndup(hostname, end_host - hostname); + } else { + hostname = NULL; + } + } + if (auth != NULL) { if ((authentication = strstr(buffer,"Basic"))) { char *end_auth = NULL; @@ -2357,6 +2390,7 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) char response[1024]; snprintf(response, sizeof (response), request_auth_response_template, method); warningkill = write_nonblock(client_socket, response, strlen(response)); + free(hostname); pthread_mutex_unlock(&httpd_mutex); return 1; } @@ -2365,10 +2399,11 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) char response[1024] = {'\0'}; snprintf(response, sizeof (response), request_auth_response_template, method); warningkill = write_nonblock(client_socket, response, strlen(response)); + free(hostname); pthread_mutex_unlock(&httpd_mutex); return 1; } else { - ret = handle_get(client_socket, url, cnt); + ret = handle_get(client_socket, url, cnt, hostname); /* A valid auth request. Process it. */ } } else { @@ -2376,13 +2411,15 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) char response[1024] = {'\0'}; snprintf(response, sizeof (response), request_auth_response_template, method); warningkill = write_nonblock(client_socket, response, strlen(response)); + free(hostname); pthread_mutex_unlock(&httpd_mutex); return 1; } } else { - ret = handle_get(client_socket, url, cnt); + ret = handle_get(client_socket, url, cnt, hostname); /* A valid request. Process it. */ } + free(hostname); } } pthread_mutex_unlock(&httpd_mutex); From b9f4ca8578730a61ccbcdedf6c785d9633ba026e Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 11 Sep 2016 21:43:13 -0600 Subject: [PATCH 203/233] Revise the condition for the MYPixelFormat to use the AVFORMAT version number --- ffmpeg.c | 12 +++++++++++- ffmpeg.h | 12 ++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 3ec52fa..2949e3f 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -10,7 +10,17 @@ * * This file has been modified so that only major versions greater than * 53 are supported. - */ + * Note that while the conditions are based upon LIBAVFORMAT, not all of the changes are + * specific to libavformat.h. Some changes could be related to other components of ffmpeg. + * This is for simplicity. The avformat version has historically changed at the same time + * as the other components so it is easier to have a single version number to track rather + * than the particular version numbers which are associated with each component. + * The libav variant also has different apis with the same major/minor version numbers. + * As such, it is occasionally necessary to look at the microversion number. Numbers + * greater than 100 for micro version indicate ffmpeg whereas numbers less than 100 + * indicate libav +*/ + #include "config.h" diff --git a/ffmpeg.h b/ffmpeg.h index e89e39d..65d5937 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -17,22 +17,14 @@ #define MY_PIX_FMT_YUV420P AV_PIX_FMT_YUV420P #define MY_PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P +#define MyPixelFormat AVPixelFormat #else #define MY_PIX_FMT_YUV420P PIX_FMT_YUV420P #define MY_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P - -#endif - -/** - * libavutil changed the name from PixelFormat to AVPixelFormat in 51.42.0 - * Add compatibility with older versions. - */ -#ifdef FF_API_PIX_FMT -#define MyPixelFormat AVPixelFormat -#else #define MyPixelFormat PixelFormat + #endif #endif /* HAVE_FFMPEG */ From 6d384fd106e597b68d7d7733f9a6b2b135af590d Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 11 Sep 2016 22:53:17 -0600 Subject: [PATCH 204/233] Suppress excessive and unfixable avcodec messages --- ffmpeg.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 3ec52fa..f1a90ad 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -806,13 +806,22 @@ void ffmpeg_avcodec_log(void *ignoreme ATTRIBUTE_UNUSED, int errno_flag, const c /* Flatten the message coming in from avcodec. */ vsnprintf(buf, sizeof(buf), fmt, vl); - /* If the debug_level is correct then send the message to the motion logging routine. */ - if (errno_flag <= AV_LOG_ERROR) { - MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); - } else if (errno_flag <= AV_LOG_WARNING) { - MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); - } else if (errno_flag < AV_LOG_DEBUG){ - MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); + /* If the debug_level is correct then send the message to the motion logging routine. + * While it is not really desired to look for specific text in the message, there does + * not seem another option. The specific messages indicated are lost camera which we + * have our own message and UE golomb is not something that is possible for us to fix. + * It is caused by the stream sent from the source camera + */ + if(strstr(buf, "No route to host") == NULL){ + if (strstr(buf, "Invalid UE golomb") != NULL) { + MOTION_LOG(DBG, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); + } else if (errno_flag <= AV_LOG_ERROR) { + MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); + } else if (errno_flag <= AV_LOG_WARNING) { + MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); + } else if (errno_flag < AV_LOG_DEBUG){ + MOTION_LOG(INF, TYPE_ENCODER, NO_ERRNO, "%s: %s", buf); + } } } From 12f5cdd0602f3a29ede7be59b7f80c1426ca22b9 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 11 Sep 2016 22:58:14 -0600 Subject: [PATCH 205/233] Remove unused variables of ostatus and loop --- vloopback_motion.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vloopback_motion.c b/vloopback_motion.c index 3433bf8..36f8cf2 100644 --- a/vloopback_motion.c +++ b/vloopback_motion.c @@ -41,11 +41,9 @@ static int v4l_open_vidpipe(void) if (strcmp(minor, "5") < 0) { FILE *vloopbacks; - char *loop; char *input; char *istatus; char *output; - char *ostatus; vloopbacks = fopen("/proc/video/vloopback/vloopbacks", "r"); @@ -76,11 +74,9 @@ static int v4l_open_vidpipe(void) while (fgets(buffer, sizeof(buffer), vloopbacks)) { if (strlen(buffer) > 1) { buffer[strlen(buffer)-1] = 0; - loop = strtok(buffer, "\t"); input = strtok(NULL, "\t"); istatus = strtok(NULL, "\t"); output = strtok(NULL, "\t"); - ostatus = strtok(NULL, "\t"); if (istatus[0] == '-') { snprintf(pipepath, sizeof(pipepath), "/dev/%s", input); From b53b26c180e0c507f2de09cce49c19b984373bae Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Thu, 15 Sep 2016 23:42:50 -0400 Subject: [PATCH 206/233] Adding ubuntu 14.04 to build along with 12.04 in travis-ci --- .travis.yml | 56 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index d127afa..79eb3aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,42 @@ -language: c -compiler: gcc -before_script: autoreconf -fiv -addons: - apt: - packages: - - libavformat-dev - - libavcodec-dev - - libav-tools - - libavutil-dev - - libswscale-dev - - ffmpeg - - libjpeg8-dev - - libv4l-dev - - libzip-dev +before_script: + - autoreconf -fiv + - avplay -version script: ./configure && make + +matrix: + include: + - os: linux + language: c + compiler: gcc + addons: + apt: + packages: + - libavformat-dev + - libavcodec-dev + - libav-tools + - libavutil-dev + - libswscale-dev + - ffmpeg + - libjpeg8-dev + - libv4l-dev + - libzip-dev + - os: linux + language: c + compiler: gcc + sudo: rquired + dist: trusty + addons: + apt: + sources: + - sourceline: 'ppa:mc3man/trusty-media' + packages: + - libavformat-dev + - libavcodec-dev + - libav-tools + - libavutil-dev + - libswscale-dev + - ffmpeg + - libjpeg8-dev + - libv4l-dev + - libzip-dev + From beded86fc5b9e8364bcaf813ac745d78a1e9454c Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Fri, 16 Sep 2016 02:47:04 -0400 Subject: [PATCH 207/233] Renamed thread to camera to more clearly define what thread is. Keeping backwards compatability with thread so that old configs can still be used. --- Makefile.in | 26 +++---- thread1-dist.conf.in => camera1-dist.conf.in | 10 ++- thread2-dist.conf.in => camera2-dist.conf.in | 9 ++- thread3-dist.conf.in => camera3-dist.conf.in | 9 ++- thread4-dist.conf.in => camera4-dist.conf.in | 9 ++- conf.c | 78 +++++++++++++++----- conf.h | 11 +-- configure.ac | 8 +- motion-dist.conf.in | 24 +++--- motion.c | 27 +++---- 10 files changed, 143 insertions(+), 68 deletions(-) rename thread1-dist.conf.in => camera1-dist.conf.in (89%) rename thread2-dist.conf.in => camera2-dist.conf.in (89%) rename thread3-dist.conf.in => camera3-dist.conf.in (89%) rename thread4-dist.conf.in => camera4-dist.conf.in (89%) diff --git a/Makefile.in b/Makefile.in index 80b7c25..5f9977f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -208,19 +208,19 @@ install: mkdir -p $(DESTDIR)$(docdir) mkdir -p $(DESTDIR)$(examplesdir) @sed -i 's|$${prefix}|$(prefix)|' motion-dist.conf - @sed -i 's|$${prefix}|$(prefix)|' thread1-dist.conf - @sed -i 's|$${prefix}|$(prefix)|' thread2-dist.conf - @sed -i 's|$${prefix}|$(prefix)|' thread3-dist.conf - @sed -i 's|$${prefix}|$(prefix)|' thread4-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' camera1-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' camera2-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' camera3-dist.conf + @sed -i 's|$${prefix}|$(prefix)|' camera4-dist.conf $(INSTALL_DATA) motion.1 $(DESTDIR)$(mandir)/man1 $(INSTALL_DATA) $(DOC) $(DESTDIR)$(docdir) $(INSTALL_DATA) $(EXAMPLES) $(DESTDIR)$(examplesdir) $(INSTALL) $(EXAMPLES_BIN) $(DESTDIR)$(examplesdir) $(INSTALL_DATA) motion-dist.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread1-dist.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread2-dist.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread3-dist.conf $(DESTDIR)$(sysconfdir)/motion - $(INSTALL_DATA) thread4-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) camera1-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) camera2-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) camera3-dist.conf $(DESTDIR)$(sysconfdir)/motion + $(INSTALL_DATA) camera4-dist.conf $(DESTDIR)$(sysconfdir)/motion for prog in $(PROGS); \ do \ ($(INSTALL) $$prog $(DESTDIR)$(bindir) ); \ @@ -244,10 +244,10 @@ uninstall remove: pre-build-info done rm -f $(mandir)/man1/motion.1 rm -f $(sysconfdir)/motion/motion-dist.conf - rm -f $(sysconfdir)/motion/thread1-dist.conf - rm -f $(sysconfdir)/motion/thread2-dist.conf - rm -f $(sysconfdir)/motion/thread3-dist.conf - rm -f $(sysconfdir)/motion/thread4-dist.conf + rm -f $(sysconfdir)/motion/camera1-dist.conf + rm -f $(sysconfdir)/motion/camera2-dist.conf + rm -f $(sysconfdir)/motion/camera3-dist.conf + rm -f $(sysconfdir)/motion/camera4-dist.conf rm -rf $(docdir) rm -rf $(examplesdir) @echo "--------------------------------------------------------------------------------" @@ -277,7 +277,7 @@ dist: distclean updateguide distclean: clean @echo "Removing files generated by configure..." @rm -f config.status config.log config.cache Makefile motion.init-Fedora motion.init-Debian motion.init-FreeBSD.sh - @rm -f thread1-dist.conf thread2-dist.conf thread3-dist.conf thread4-dist.conf motion-dist.conf motion-help.conf motion.spec + @rm -f camera1-dist.conf camera2-dist.conf camera3-dist.conf camera4-dist.conf motion-dist.conf motion-help.conf motion.spec @rm -rf autom4te.cache config.h @echo "You will need to re-run configure if you want to build Motion." @echo diff --git a/thread1-dist.conf.in b/camera1-dist.conf.in similarity index 89% rename from thread1-dist.conf.in rename to camera1-dist.conf.in index a1b7ea9..7b11618 100644 --- a/thread1-dist.conf.in +++ b/camera1-dist.conf.in @@ -1,4 +1,4 @@ -# @sysconfdir@/motion/thread1.conf +# @sysconfdir@/motion/camera1.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ @@ -6,6 +6,14 @@ # Capture device options ############################################################ +# +# Camera Id +# Id used to label the camera when inserting data into SQL or saving the +# camera image to disk. This is better than using thread number so that there +# always is a consistent labe +# Default: order when the camera file was read +# camera_id = 1 + # Videodevice to be used for capturing (default /dev/video0) # for FreeBSD default is /dev/bktr0 videodevice /dev/video0 diff --git a/thread2-dist.conf.in b/camera2-dist.conf.in similarity index 89% rename from thread2-dist.conf.in rename to camera2-dist.conf.in index 273ee9b..06b83d9 100644 --- a/thread2-dist.conf.in +++ b/camera2-dist.conf.in @@ -1,4 +1,4 @@ -# @sysconfdir@/motion/thread2.conf +# @sysconfdir@/motion/camera2.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ @@ -6,6 +6,13 @@ # Capture device options ############################################################ +# Camera Id +# Id used to label the camera when inserting data into SQL or saving the +# camera image to disk. This is better than using thread number so that there +# always is a consistent labe +# Default: order when the camera file was read +# camera_id = 2 + # Videodevice to be used for capturing (default /dev/video0) # for FreeBSD default is /dev/bktr0 videodevice /dev/video1 diff --git a/thread3-dist.conf.in b/camera3-dist.conf.in similarity index 89% rename from thread3-dist.conf.in rename to camera3-dist.conf.in index 004c68a..c5174cf 100644 --- a/thread3-dist.conf.in +++ b/camera3-dist.conf.in @@ -1,4 +1,4 @@ -# @sysconfdir@/motion/thread3.conf +# @sysconfdir@/motion/camera3.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ @@ -6,6 +6,13 @@ # Capture device options ############################################################ +# Camera Id +# Id used to label the camera when inserting data into SQL or saving the +# camera image to disk. This is better than using thread number so that there +# always is a consistent labe +# Default: order when the camera file was read +# camera_id = 3 + # Videodevice to be used for capturing (default /dev/video0) # for FreeBSD default is /dev/bktr0 videodevice /dev/video2 diff --git a/thread4-dist.conf.in b/camera4-dist.conf.in similarity index 89% rename from thread4-dist.conf.in rename to camera4-dist.conf.in index 018c849..552f7ef 100644 --- a/thread4-dist.conf.in +++ b/camera4-dist.conf.in @@ -1,4 +1,4 @@ -# @sysconfdir@/motion/thread4.conf +# @sysconfdir@/motion/camera4.conf # # This config file was generated by @PACKAGE_NAME@ @PACKAGE_VERSION@ @@ -6,6 +6,13 @@ # Capture device options ############################################################ +# Camera Id +# Id used to label the camera when inserting data into SQL or saving the +# camera image to disk. This is better than using thread number so that there +# always is a consistent labe +# Default: order when the camera file was read +# camera_id = 4 + # Videodevice to be used for capturing (default /dev/video0) # for FreeBSD default is /dev/bktr0 videodevice /dev/video3 diff --git a/conf.c b/conf.c index 350e942..6753805 100644 --- a/conf.c +++ b/conf.c @@ -47,6 +47,7 @@ struct config conf_template = { width: DEF_WIDTH, height: DEF_HEIGHT, quality: DEF_QUALITY, + camera_id: 0, rotate_deg: 0, max_changes: DEF_CHANGES, threshold_tune: 0, @@ -171,11 +172,16 @@ 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); +static struct context **config_camera(struct context **cnt, const char *str, int val); + static const char *print_bool(struct context **, char **, int, unsigned int); static const char *print_int(struct context **, char **, int, unsigned int); static const char *print_string(struct context **, char **, int, unsigned int); +static const char *print_camera(struct context **, char **, int, unsigned int); + +/* Deprcated thread config functions */ +static struct context **config_thread(struct context **cnt, const char *str, int val); static const char *print_thread(struct context **, char **, int, unsigned int); static void usage(void); @@ -219,7 +225,7 @@ config_param config_params[] = { }, { "camera_name", - "# Name given to a camera/thread. Shown in web interface and may be used with the specifier %$ for filenames and such.\n" + "# Name given to a camera. Shown in web interface and may be used with the specifier %$ for filenames and such.\n" "# Default: not defined", 0, CONF_OFFSET(camera_name), @@ -729,6 +735,16 @@ config_param config_params[] = { print_int }, { + "camera_id", + "Id used to label the camera when inserting data into SQL or saving the\n" + "camera image to disk. This is better than using thread ID so that there\n" + "always is a consistent label\n", + 0, + CONF_OFFSET(camera_id), + copy_int, + print_int + }, + { "picture_type", "# Type of output images\n" "# Valid values: jpeg, ppm (default: jpeg)", @@ -884,7 +900,7 @@ config_param config_params[] = { "# Text Display\n" "# %Y = year, %m = month, %d = date,\n" "# %H = hour, %M = minute, %S = second, %T = HH:MM:SS,\n" - "# %v = event, %q = frame number, %t = thread (camera) number,\n" + "# %v = event, %q = frame number, %t = camera id,\n" "# %D = changed pixels, %N = noise level, \\n = new line,\n" "# %i and %J = width and height of motion area,\n" "# %K and %L = X and Y coordinates of motion center\n" @@ -982,7 +998,7 @@ config_param config_params[] = { "# you can use conversion specifiers\n" "# %Y = year, %m = month, %d = date,\n" "# %H = hour, %M = minute, %S = second,\n" - "# %v = event, %q = frame number, %t = thread (camera) number,\n" + "# %v = event, %q = frame number, %t = camera id,\n" "# %D = changed pixels, %N = noise level,\n" "# %i and %J = width and height of motion area,\n" "# %K and %L = X and Y coordinates of motion center\n" @@ -1593,11 +1609,25 @@ config_param config_params[] = { print_string }, { + "camera", + "\n##############################################################\n" + "# Camera config files - One for each camera.\n" + "# Except if only one camera - You only need this config file.\n" + "# If you have more than one camera you MUST define one camera\n" + "# config file for each camera in addition to this config file.\n" + "##############################################################\n", + 1, + 0, + config_camera, + print_camera + }, + { "thread", "\n##############################################################\n" - "# Thread config files - One for each camera.\n" + "# Deprecated use camera instead of thread.\n" + "# Camera config files - One for each camera.\n" "# Except if only one camera - You only need this config file.\n" - "# If you have more than one camera you MUST define one thread\n" + "# If you have more than one camera you MUST define one camera\n" "# config file for each camera in addition to this config file.\n" "##############################################################\n", 1, @@ -1665,7 +1695,7 @@ static void conf_cmdline(struct context *cnt, int thread) break; case 'm': cnt->pause = 1; - break; + break; case 'h': case '?': default: @@ -1713,6 +1743,7 @@ struct context **conf_cmdparse(struct context **cnt, const char *cmd, const char * If the option is an int, copy_int is called. * If the option is a string, copy_string is called. * If the option is a thread, config_thread is called. + * If the option is a camera, config_camera is called. * The arguments to the function are: * cnt - a pointer to the context structure. * arg1 - a pointer to the new option value (represented as string). @@ -1867,7 +1898,7 @@ void conf_print(struct context **cnt) fprintf(conffile, "%s\n", val); if (strlen(val) == 0) - fprintf(conffile, "; thread %s/motion/thread1.conf\n", sysconfdir); + fprintf(conffile, "; camera %s/motion/camera1.conf\n", sysconfdir); free(val); } else if (thread == 0) { @@ -2335,9 +2366,15 @@ static const char *print_int(struct context **cnt, char **str ATTRIBUTE_UNUSED, return retval; } - static const char *print_thread(struct context **cnt, char **str, int parm ATTRIBUTE_UNUSED, unsigned int threadnr) +{ + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "thread config option deprecated use camera"); + return print_camera(cnt, str, parm, threadnr); +} + +static const char *print_camera(struct context **cnt, char **str, + int parm ATTRIBUTE_UNUSED, unsigned int threadnr) { char *retval; unsigned int i = 0; @@ -2350,8 +2387,8 @@ static const char *print_thread(struct context **cnt, char **str, while (cnt[++i]) { retval = myrealloc(retval, strlen(retval) + strlen(cnt[i]->conf_filename) + 10, - "print_thread"); - sprintf(retval + strlen(retval), "thread %s\n", cnt[i]->conf_filename); + "print_camera"); + sprintf(retval + strlen(retval), "camera %s\n", cnt[i]->conf_filename); } *str = retval; @@ -2359,10 +2396,17 @@ static const char *print_thread(struct context **cnt, char **str, return NULL; } +static struct context **config_thread(struct context **cnt, const char *str, + int val ATTRIBUTE_UNUSED) +{ + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "thread config option deprecated use camera"); + return config_camera(cnt, str, val); +} + /** - * config_thread + * config_camera * Is called during initial config file loading each time Motion - * finds a thread option in motion.conf + * finds a camera option in motion.conf * The size of the context array is increased and the main context's values are * copied to the new thread. * @@ -2371,7 +2415,7 @@ static const char *print_thread(struct context **cnt, char **str, * val - is not used. It is defined to be function header compatible with * copy_int, copy_bool and copy_string. */ -static struct context **config_thread(struct context **cnt, const char *str, +static struct context **config_camera(struct context **cnt, const char *str, int val ATTRIBUTE_UNUSED) { int i; @@ -2383,7 +2427,7 @@ static struct context **config_thread(struct context **cnt, const char *str, fp = fopen(str, "r"); if (!fp) { - MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Thread config file %s not found", + MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Camera config file %s not found", str); return cnt; } @@ -2399,7 +2443,7 @@ static struct context **config_thread(struct context **cnt, const char *str, * First thread is 0 so the number of threads is i + 1 * plus an extra for the NULL pointer. This gives i + 2 */ - cnt = myrealloc(cnt, sizeof(struct context *) * (i + 2), "config_thread"); + cnt = myrealloc(cnt, sizeof(struct context *) * (i + 2), "config_camera"); /* Now malloc space for an additional context structure for thread nr. i */ cnt[i] = mymalloc(sizeof(struct context)); @@ -2421,7 +2465,7 @@ static struct context **config_thread(struct context **cnt, const char *str, /* Process the thread's config file and notify user on console. */ strcpy(cnt[i]->conf_filename, str); - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing config file %s", + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Processing camera config file %s", str); conf_process(cnt + i, fp); diff --git a/conf.h b/conf.h index 6cf5ee6..27ad243 100644 --- a/conf.h +++ b/conf.h @@ -15,7 +15,7 @@ #ifndef _INCLUDE_CONF_H #define _INCLUDE_CONF_H -/* +/* * More parameters may be added later. */ struct config { @@ -26,6 +26,7 @@ struct config { int setup_mode; int width; int height; + int camera_id; int quality; int rotate_deg; int max_changes; @@ -87,7 +88,7 @@ struct config { unsigned long frequency; int tuner_number; int timelapse; - const char *timelapse_mode; + const char *timelapse_mode; #if (defined(BSD) || defined(__FreeBSD_kernel__)) const char *tuner_device; #endif @@ -146,8 +147,8 @@ struct config { char **argv; }; -/** - * typedef for a param copy function. +/** + * typedef for a param copy function. */ typedef struct context ** (* conf_copy_func)(struct context **, const char *, int); typedef const char *(* conf_print_func)(struct context **, char **, int, unsigned int); @@ -162,7 +163,7 @@ typedef struct { int conf_value; /* pointer to a field in struct context */ conf_copy_func copy; /* a function to set the value in 'config' */ conf_print_func print; /* a function to output the value to a file */ -} config_param; +} config_param; extern config_param config_params[]; diff --git a/configure.ac b/configure.ac index 140f4f4..150c94e 100644 --- a/configure.ac +++ b/configure.ac @@ -1144,10 +1144,10 @@ fi AC_SUBST(BIN_PATH) AC_CONFIG_FILES([ -thread1-dist.conf -thread2-dist.conf -thread3-dist.conf -thread4-dist.conf +camera1-dist.conf +camera2-dist.conf +camera3-dist.conf +camera4-dist.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian diff --git a/motion-dist.conf.in b/motion-dist.conf.in index a923852..cc212e2 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -375,7 +375,7 @@ snapshot_interval 0 # Text Display # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera number, # %D = changed pixels, %N = noise level, \n = new line, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center @@ -435,7 +435,7 @@ text_double off # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center @@ -616,7 +616,7 @@ track_stepsize 40 # You can use conversion specifiers for the on_xxxx commands # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center @@ -744,19 +744,19 @@ quiet on ############################################################## -# Thread config files - One for each camera. +# camera config files - One for each camera. # Except if only one camera - You only need this config file. -# If you have more than one camera you MUST define one thread +# If you have more than one camera you MUST define one camera # config file for each camera in addition to this config file. ############################################################## # Remember: If you have more than one camera you must have one -# thread file for each camera. E.g. 2 cameras requires 3 files: -# This motion.conf file AND thread1.conf and thread2.conf. +# camera file for each camera. E.g. 2 cameras requires 3 files: +# This motion.conf file AND camera1.conf and camera2.conf. # Only put the options that are unique to each camera in the -# thread config files. -; thread @sysconfdir@/motion/thread1.conf -; thread @sysconfdir@/motion/thread2.conf -; thread @sysconfdir@/motion/thread3.conf -; thread @sysconfdir@/motion/thread4.conf +# camera config files. +; camera @sysconfdir@/motion/camera.conf +; camera @sysconfdir@/motion/camera.conf +; camera @sysconfdir@/motion/camera.conf +; camera @sysconfdir@/motion/camera.conf diff --git a/motion.c b/motion.c index 1bf0e26..adccbf1 100644 --- a/motion.c +++ b/motion.c @@ -700,8 +700,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 , motion detection %s", - (unsigned long)pthread_getspecific(tls_key_threadnr), cnt->pause ? "Disabled":"Enabled"); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Camera %d started: motion detection %s", + cnt->conf.camera_id, cnt->pause ? "Disabled":"Enabled"); if (!cnt->conf.filepath) cnt->conf.filepath = mystrdup("."); @@ -2761,19 +2761,21 @@ int main (int argc, char **argv) * option is used, so start at 1 then and 0 otherwise. */ for (i = cnt_list[1] != NULL ? 1 : 0; cnt_list[i]; i++) { - /* If i is 0 it means no thread files and we then set the thread number to 1 */ - cnt_list[i]->threadnr = i ? i : 1; + /* camera_id is not defined in the config, then the camera id needs to be gnerated. + * the load order will generate a # that will become the camera_id + */ + cnt_list[i]->conf.camera_id = cnt_list[i]->conf.camera_id ? cnt_list[i]->conf.camera_id: i; if (strcmp(cnt_list[i]->conf_filename, "")) { cnt_list[i]->conf_filename[sizeof(cnt_list[i]->conf_filename) - 1] = '\0'; - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is from %s", - cnt_list[i]->threadnr, cnt_list[i]->conf_filename); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Camera %d is from %s", + cnt_list[i]->conf.camera_id, cnt_list[i]->conf_filename); } - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Thread %d is device: %s input %d", - cnt_list[i]->threadnr, cnt_list[i]->conf.netcam_url ? + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Camera %d is device: %s input %d", + cnt_list[i]->conf.camera_id, cnt_list[i]->conf.netcam_url ? cnt_list[i]->conf.netcam_url : cnt_list[i]->conf.video_device, cnt_list[i]->conf.netcam_url ? -1 : cnt_list[i]->conf.input); @@ -2781,7 +2783,7 @@ int main (int argc, char **argv) cnt_list[i]->conf.stream_port); #ifdef HAVE_SQLITE /* this is done to share the seralized handle - * and supress creation of new handles in the threads */ + * and supress creation of new handles in the threads */ cnt_list[i]->database_sqlite3=cnt_list[0]->database_sqlite3; #endif start_motion_thread(cnt_list[i], &thread_attr); @@ -3053,7 +3055,7 @@ int create_path(const char *path) * (which is: path does not exist), the path is created and then things are * tried again. This is faster then trying to create that path over and over * again. If someone removes the path after it was created, myfopen will - * recreate the path automatically. + * recreate the path automatically. * * Parameters: * @@ -3212,9 +3214,8 @@ size_t mystrftime(const struct context *cnt, char *s, size_t max, const char *us cnt->current_image->total_labels); break; - case 't': // thread number - sprintf(tempstr, "%*d", width, (int)(unsigned long) - pthread_getspecific(tls_key_threadnr)); + case 't': // camera id + sprintf(tempstr, "%*d", width, cnt->conf.camera_id); break; case 'C': // text_event From 4998d465f7837a01c02d88e6d213e5f881e62122 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Fri, 16 Sep 2016 19:51:23 +0200 Subject: [PATCH 208/233] Fix jpeg-turbo detection Do not only check for static libjpeg.a but also for dynamic libjpeg.so Signed-off-by: Fabrice Fontaine --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 140f4f4..f069ccc 100644 --- a/configure.ac +++ b/configure.ac @@ -273,7 +273,7 @@ if test "${JPEG_TURBO}" = "no"; then AC_MSG_RESULT(skipping) else AC_MSG_CHECKING(for libjpeg-turbo in -> [${JPEG_TURBO}] <-) - if test -f ${JPEG_TURBO}/lib/libjpeg.a ; then + if test -f ${JPEG_TURBO}/lib/libjpeg.a -o ${JPEG_TURBO}/lib/libjpeg.so; then AC_MSG_RESULT(found) JPEG_TURBO_OK="found" else From d1a2397daa805b0acc965acf85dfdb7297ba6069 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Fri, 16 Sep 2016 20:25:51 +0200 Subject: [PATCH 209/233] Fix detection of sqlite3 when cross-compiling Replace usage of AC_CHECK_FILE by test -f to check the existence of sqlite3.c as AC_CHECK_FILE does not work when cross-compiling Signed-off-by: Fabrice Fontaine --- configure.ac | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index f069ccc..0f18f08 100644 --- a/configure.ac +++ b/configure.ac @@ -460,16 +460,13 @@ else # first we check to see if the sqlite3 amalgamation (sqlite3.c), is in with our source # this is the prefered way to use sqlite - AC_CHECK_FILE([sqlite3.c], - [ + if test -f sqlite3.c; then SQLITE3_SUPPORT="yes" VIDEO="$VIDEO sqlite3.o" TEMP_LIBS="$TEMP_LIBS -ldl" AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3]) AC_DEFINE([HAVE_SQLITE3_EMBEDDED],1,[Define to 1 if you have SQLITE3 embedded support]) - ] - , - [ + else # if sqlite3.c is not found then we look for the shared library AC_CHECK_LIB(sqlite3, sqlite3_open, [ @@ -478,8 +475,7 @@ else AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 shared library support]) ] ) - ] - ) + fi CFLAGS=$saved_CFLAGS LIBS=$saved_LIBS From 787fad43fe1ef9e80b23a8ee7542ad5f5906e7ec Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 17 Sep 2016 21:18:46 +0300 Subject: [PATCH 210/233] automatically resize mask image if size differs from that of the captured image --- motion_guide.html | 4 ++-- picture.c | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/motion_guide.html b/motion_guide.html index e127b2c..4526324 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -2559,8 +2559,8 @@

                                                        mask_file

                                                      The full path and filename for the masking pgm file. -This picture MUST have the same width and height as the frames being -captured and be in binary format. +If needed, the mask will be resized to match the width and height of the frames being +captured. If you have one or more areas of the camera image in which you do NOT want motion detected (e.g. a tree that moves in the wind or a corner of the picture where you can see cars/pedestrians passing by) you need a mask file. This file is a picture that you create in your favorite photo editing program. The areas that you want detected must diff --git a/picture.c b/picture.c index 81be8f3..7ca4d7e 100644 --- a/picture.c +++ b/picture.c @@ -963,9 +963,9 @@ void put_picture(struct context *cnt, char *file, unsigned char *image, int ftyp */ unsigned char *get_pgm(FILE *picture, int width, int height) { - int x = 0 , y = 0, maxval; + int x, y, mask_width, mask_height, maxval; char line[256]; - unsigned char *image; + unsigned char *image, *resized_image; line[255] = 0; @@ -986,18 +986,12 @@ unsigned char *get_pgm(FILE *picture, int width, int height) if (!fgets(line, 255, picture)) return NULL; - /* Check size */ - if (sscanf(line, "%d %d", &x, &y) != 2) { + /* Read image size */ + if (sscanf(line, "%d %d", &mask_width, &mask_height) != 2) { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading size in pgm file"); return NULL; } - if (x != width || y != height) { - MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Wrong image size %dx%d should be %dx%d", - x, y, width, height); - return NULL; - } - /* Maximum value */ line[0] = '#'; while (line[0] == '#') @@ -1011,15 +1005,34 @@ unsigned char *get_pgm(FILE *picture, int width, int height) /* Read data */ - image = mymalloc(width * height); + image = mymalloc(mask_width * mask_height); - for (y = 0; y < height; y++) { - if ((int)fread(&image[y * width], 1, width, picture) != width) + for (y = 0; y < mask_height; y++) { + if ((int)fread(&image[y * mask_width], 1, mask_width, picture) != mask_width) MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Failed reading image data from pgm file"); - for (x = 0; x < width; x++) - image[y * width + x] = (int)image[y * width + x] * 255 / maxval; + for (x = 0; x < mask_width; x++) + image[y * mask_width + x] = (int)image[y * mask_width + x] * 255 / maxval; + + } + + /* Resize mask if required */ + if (mask_width != width || mask_height != height) { + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Mask needs resizing from %dx%d to %dx%d", + mask_width, mask_height, width, height); + + resized_image = mymalloc(width * height); + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + resized_image[y * width + x] = image[ + (mask_height - 1) * y / (height - 1) * mask_width + + (mask_width - 1) * x / (width - 1)]; + } + } + free(image); + image = resized_image; } return image; From 7d54c3949e1efaa1214d7611a8a4e6c5f29844b4 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sat, 17 Sep 2016 20:13:01 +0100 Subject: [PATCH 211/233] Fix for first captured picture after start up is zero length If the first fopen() failed, then myfopen() always returned NULL even if the second fopen() succeeded. Now it correctly returns the result of the second fopen(). Authored by https://github.com/pcwalden Closes #155 --- motion.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/motion.c b/motion.c index 1bf0e26..b67eef6 100644 --- a/motion.c +++ b/motion.c @@ -3066,19 +3066,20 @@ FILE * myfopen(const char *path, const char *mode) { /* first, just try to open the file */ FILE *dummy = fopen(path, mode); + if (dummy) return dummy; /* could not open file... */ - if (!dummy) { - /* path did not exist? */ - if (errno == ENOENT) { + /* path did not exist? */ + if (errno == ENOENT) { - /* create path for file... */ - if (create_path(path) == -1) - return NULL; + /* create path for file... */ + if (create_path(path) == -1) + return NULL; - /* and retry opening the file */ - dummy = fopen(path, mode); - } + /* and retry opening the file */ + dummy = fopen(path, mode); + } + if (!dummy) { /* * Two possibilities * 1: there was an other error while trying to open the file for the From 736f9bb3f9c0ebae013246f3da6d0612d9185997 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Sun, 18 Sep 2016 20:02:36 +0200 Subject: [PATCH 212/233] Change --without-sdl to --with-sdl=[DIR] With this modification, the user will be able to specify the path to sdl-config which can be outside his path (for example on embedded buildsystem such as buildroot) Signed-off-by: Fabrice Fontaine --- configure.ac | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 0f18f08..2227a0c 100644 --- a/configure.ac +++ b/configure.ac @@ -224,28 +224,25 @@ fi # SDL_SUPPORT="no" AC_ARG_WITH(sdl, -[ --without-sdl Compile without sdl support to get stream in SDL window. +[ --with-sdl[=DIR] Specify the prefix for the install path for + sdl-config to get stream in SDL window (optional). ], [], -[]) -AC_MSG_CHECKING(for sdl) +[withval="no"]) if test "x$withval" = "xno"; then + AC_MSG_CHECKING(for sdl) AC_MSG_RESULT(skipped) else - CONFIG_SDL='sdl-config' + AC_PATH_PROG([CONFIG_SDL], [sdl-config], [], [${PATH}:${withval}:${withval}/bin]) if test -z "`($CONFIG_SDL --version) 2>/dev/null`" ;then - AC_MSG_RESULT(no) - if test "$withval" = "yes"; then - echo "" - echo "****************************************************" - echo "* sdl-config could not be found. Please install it *" - echo "* and remove the --with-sdl configure argument. *" - echo "* libSDL can be found at http://www.libsdl.org *" - echo "****************************************************" - echo "" - fi + echo "" + echo "****************************************************" + echo "* sdl-config could not be found. Please install it *" + echo "* and remove the --with-sdl configure argument. *" + echo "* libSDL can be found at http://www.libsdl.org *" + echo "****************************************************" + echo "" else - AC_MSG_RESULT(yes) SDL_SUPPORT="yes" TEMP_LIBS="$TEMP_LIBS `${CONFIG_SDL} --libs`" TEMP_CFLAGS="${TEMP_CFLAGS} `${CONFIG_SDL} --cflags`" From 41c841f2fbe655b519d801d1bde0a97396f3a164 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Mon, 19 Sep 2016 23:26:54 +0200 Subject: [PATCH 213/233] Fix jpeg-turbo detection Commit number 4998d465f7837a01c02d88e6d213e5f881e62122 added the detection of jpeg-turbo dynamic library through -o but -f argument was missing so test was always true Signed-off-by: Fabrice Fontaine --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0f18f08..1112165 100644 --- a/configure.ac +++ b/configure.ac @@ -273,7 +273,7 @@ if test "${JPEG_TURBO}" = "no"; then AC_MSG_RESULT(skipping) else AC_MSG_CHECKING(for libjpeg-turbo in -> [${JPEG_TURBO}] <-) - if test -f ${JPEG_TURBO}/lib/libjpeg.a -o ${JPEG_TURBO}/lib/libjpeg.so; then + if test -f ${JPEG_TURBO}/lib/libjpeg.a -o -f ${JPEG_TURBO}/lib/libjpeg.so; then AC_MSG_RESULT(found) JPEG_TURBO_OK="found" else From 02bda9d56d3718534883860305211f60be93e99e Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Tue, 20 Sep 2016 22:33:13 +0200 Subject: [PATCH 214/233] Fix LIBS and CFLAGS when jpeg-turbo is enabled When jpeg-turbo was enabled, LIBS was uncorrectly set: -lpthread, -lm, ... was lost. Same issue with CFLAGS. Fixes #17. Signed-off-by: Fabrice Fontaine --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1112165..819e634 100644 --- a/configure.ac +++ b/configure.ac @@ -290,8 +290,8 @@ if test "${JPEG_TURBO_OK}" = "found"; then CFLAGS="$CFLAGS -I${JPEG_TURBO}/include" LIBS="$LIBS -L${JPEG_TURBO}/lib -ljpeg" AC_CHECK_LIB(jpeg, jpeg_start_compress, - [ TEMP_LIBS="$LIBS" - TEMP_CFLAGS="${CFLAGS}" + [ TEMP_LIBS="$TEMP_LIBS -L${JPEG_TURBO}/lib -ljpeg" + TEMP_CFLAGS="${TEMP_CFLAGS} -I${JPEG_TURBO}/include" TEMP_LDFLAGS="$TEMP_LDFLAGS $LDFLAGS" JPEG_SUPPORT="yes"],,) LIBS="$saved_LIBS" From 6b98805913b7383acc4aa071d353abcab7d57595 Mon Sep 17 00:00:00 2001 From: tosiara Date: Wed, 21 Sep 2016 10:56:04 +0300 Subject: [PATCH 215/233] Updated motion_guide.htm with extpipe description and examples --- motion_guide.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/motion_guide.html b/motion_guide.html index f723b55..36e0ea2 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -3538,6 +3538,12 @@

                                                      use_extpipe

                                                      This option specifies whether to send the output to a pipe for external encoding into a movie.

                                                      +Piping raw video to stdout has some advantages comparing to using built-in ffmpeg encoder. +First, this way you can use any encoder that supports RAW frames from stdin so you are not limited to the formats +that are currently implemented in motion. See examples in extpipe +Second, external encoder utilizes separate cpu core on a multi-core system so movie encoding is offloaded +from main motion thread to a separate core(s) giving noticeable performance boost +

                                                      Note that this option does not require the install or configure of the videoloop back

                                                      @@ -3558,8 +3564,13 @@

                                                      extpipe

                                                      Sample:

                                                      -extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps - +extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps +

                                                      +extpipe x264 - --input-res %wx%h --fps %fps --bitrate 2000 --preset ultrafast --quiet -o %f.mp4 +

                                                      +extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%fps -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %fps +

                                                      +extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -vcodec libx264 -preset ultrafast -f mp4 %f.mp4

                                                      From 249967e669dfa3b584fb1f715a5e5112fb7105dc Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Thu, 22 Sep 2016 15:18:48 +0200 Subject: [PATCH 216/233] Fix hostname determination for IPv6 addresses in web server. --- webhttpd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webhttpd.c b/webhttpd.c index 9de76da..76ef95a 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2464,7 +2464,15 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) /* we have a string that is the hostname followed by * optionally a colon and a port number - strip off any * port number & colon */ - char *colon = memchr(hostname, ':', hostname-end_host); + char *colon = NULL; + if (hostname[0] == '[') { + // hostname is a IPv6 address like "[::1]" + char *endbracket = memchr(hostname, ']', hostname-end_host); + // look for the colon after the "]" + colon = memchr(endbracket, ':', hostname-end_host); + } else { + colon = memchr(hostname, ':', hostname-end_host); + } if (colon) end_host = colon; while (isspace(end_host[-1])) From 0a22df15473c8e860b317289f9811843f5a7367b Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Thu, 22 Sep 2016 16:33:31 +0200 Subject: [PATCH 217/233] Fix string length in memchr call. --- webhttpd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webhttpd.c b/webhttpd.c index 76ef95a..e700262 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2467,17 +2467,17 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) char *colon = NULL; if (hostname[0] == '[') { // hostname is a IPv6 address like "[::1]" - char *endbracket = memchr(hostname, ']', hostname-end_host); + char *end_bracket = memchr(hostname, ']', end_host-hostname); // look for the colon after the "]" - colon = memchr(endbracket, ':', hostname-end_host); + colon = memchr(end_bracket, ':', end_host-end_bracket); } else { - colon = memchr(hostname, ':', hostname-end_host); + colon = memchr(hostname, ':', end_host-hostname); } if (colon) end_host = colon; while (isspace(end_host[-1])) end_host--; - hostname = strndup(hostname, end_host - hostname); + hostname = strndup(hostname, end_host-hostname); } else { hostname = NULL; } From aa7ba3984e7fe83f6877336c9a7db1dfa855fb5c Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Thu, 22 Sep 2016 18:36:00 +0200 Subject: [PATCH 218/233] Cleanup HTML. --- stream.c | 30 ++++++++++++++++-------------- webhttpd.c | 24 ++++++++++++++++++++---- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/stream.c b/stream.c index ff26abf..bbdbed7 100644 --- a/stream.c +++ b/stream.c @@ -413,26 +413,28 @@ static void* handle_md5_digest(void* param) "Pragma: no-cache\r\n" "WWW-Authenticate: Digest"; static const char *auth_failed_html_template= - "\r\n" - "\r\n" - "401 Authorization Required\r\n" - "\r\n" - "

                                                      Authorization Required

                                                      \r\n" - "This server could not verify that you are authorized to access the document " + "\n" + "\n" + "401 Authorization Required\n" + "\n" + "

                                                      Authorization Required

                                                      \n" + "

                                                      This server could not verify that you are authorized to access the document " "requested. Either you supplied the wrong credentials (e.g., bad password), " - "or your browser doesn't understand how to supply the credentials required.\r\n" - "\r\n"; + "or your browser doesn't understand how to supply the credentials required.

                                                      \n" + "\n" + "\n"; static const char *internal_error_template= "HTTP/1.0 500 Internal Server Error\r\n" "Server: Motion/"VERSION"\r\n" "Content-Type: text/html\r\n" "Connection: Close\r\n\r\n" - "\r\n" - "\r\n" - "500 Internal Server Error\r\n" - "\r\n" - "

                                                      500 Internal Server Error

                                                      \r\n" - "\r\n"; + "\n" + "\n" + "500 Internal Server Error\n" + "\n" + "

                                                      500 Internal Server Error

                                                      \n" + "\n" + "\n"; #ifdef HAVE_PTHREAD_SETNAME_NP pthread_setname_np(pthread_self(), "handle_md5_digest"); diff --git a/webhttpd.c b/webhttpd.c index 9de76da..7e670dc 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -26,16 +26,23 @@ pthread_mutex_t httpd_mutex; int warningkill; static const char *ini_template = - "Motion "VERSION"\n" + "\n" + "\n" + "Motion "VERSION"\n" "\n"; static const char *set_template = - "\nMotion "VERSION"\n" - "\n"; + "}\n" + "\n" + "\n"; static const char *end_template = "\n" @@ -66,6 +73,7 @@ static const char *ok_response_raw = static const char *bad_request_response = "HTTP/1.0 400 Bad Request\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Bad Request

                                                      \n" @@ -81,6 +89,7 @@ static const char *bad_request_response_raw = static const char *not_found_response_template = "HTTP/1.0 404 Not Found\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Not Found

                                                      \n" @@ -96,6 +105,7 @@ static const char *not_found_response_template_raw = static const char *not_found_response_valid = "HTTP/1.0 404 Not Valid\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Not Valid

                                                      \n" @@ -111,6 +121,7 @@ static const char *not_found_response_valid_raw = static const char *not_valid_syntax = "HTTP/1.0 404 Not Valid Syntax\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Not Valid Syntax

                                                      \n" @@ -125,6 +136,7 @@ static const char *not_valid_syntax_raw = static const char *not_track = "HTTP/1.0 200 OK\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Tracking Not Enabled

                                                      \n"; @@ -137,6 +149,7 @@ static const char *not_track_raw = static const char *track_error = "HTTP/1.0 200 OK\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Track Error

                                                      \n"; @@ -149,6 +162,7 @@ static const char *track_error_raw = static const char *error_value = "HTTP/1.0 200 OK\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Value Error

                                                      \n"; @@ -161,6 +175,7 @@ static const char *error_value_raw = static const char *not_found_response_valid_command = "HTTP/1.0 404 Not Valid Command\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Not Valid Command

                                                      \n" @@ -176,6 +191,7 @@ static const char *not_found_response_valid_command_raw = static const char *bad_method_response_template = "HTTP/1.0 501 Method Not Implemented\r\n" "Content-type: text/html\r\n\r\n" + "\n" "\n" "\n" "

                                                      Method Not Implemented

                                                      \n" From 74e9cbe08182024757eb49279173878faf6a8505 Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Fri, 23 Sep 2016 11:25:10 +0200 Subject: [PATCH 219/233] Fix another hostname issue, where the hostname would contain the next header line, when the Hostname header was empty or malformed. --- webhttpd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/webhttpd.c b/webhttpd.c index e700262..08c269f 100644 --- a/webhttpd.c +++ b/webhttpd.c @@ -2455,12 +2455,13 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) * work that the result of gethostname(), which is reliant on * the machine we're running on having it's hostname setup * correctly and corresponding DNS in place. */ - char *end_host = NULL; hostname += strlen("Host:"); - while (isspace(*hostname)) - hostname++; - - if ((end_host = strstr(hostname,"\r\n"))) { + char *end_host = strstr(hostname,"\r\n"); + if (end_host) { + while (hostname < end_host && isspace(hostname[0])) + hostname++; + while (hostname < end_host && isspace(end_host[-1])) + end_host--; /* we have a string that is the hostname followed by * optionally a colon and a port number - strip off any * port number & colon */ @@ -2475,8 +2476,6 @@ static unsigned int read_client(int client_socket, void *userdata, char *auth) } if (colon) end_host = colon; - while (isspace(end_host[-1])) - end_host--; hostname = strndup(hostname, end_host-hostname); } else { hostname = NULL; From 8cedff6dfe4e39d55173218b7a4d67384d1ad124 Mon Sep 17 00:00:00 2001 From: Philip Walden Date: Fri, 23 Sep 2016 07:57:38 -0700 Subject: [PATCH 220/233] Adds --without-mmal option to configure. As documented in issue 169, the recentlay added MMAL camera support for the Raspberry Pi does not build on the Wheezy version of Raspbian. This option disables the autoconf generation of MMAL dependencies. --- configure.ac | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 819e634..9e945f7 100644 --- a/configure.ac +++ b/configure.ac @@ -389,14 +389,22 @@ AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not f # Check for raspberry pi mmal interface # -HAVE_MMAL="" -LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal" - -if test -d ${LIBRASPBERRYPIDEVPATH}; then +WITHOUT_MMAL="no" +AC_ARG_WITH([mmal], +AS_HELP_STRING([--without-mmal], + [Compile without RaspberyPi mmal camera support]), +WITHOUT_MMAL="yes", +WITHOUT_MMAL="no") + +if test "${WITHOUT_MMAL}" = "no"; then + HAVE_MMAL="" + LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal" + + if test -d ${LIBRASPBERRYPIDEVPATH}; then HAVE_MMAL="yes" -fi + fi -AS_IF([test "${HAVE_MMAL}" = "yes" ], [ + AS_IF([test "${HAVE_MMAL}" = "yes" ], [ AC_SUBST(MMAL_CFLAGS) AC_SUBST(MMAL_OBJ) AC_SUBST(MMAL_LIBS) @@ -404,7 +412,8 @@ AS_IF([test "${HAVE_MMAL}" = "yes" ], [ MMAL_CFLAGS="-std=gnu99 -DHAVE_MMAL -Irasppicam -I/opt/vc/include" MMAL_LIBS="-L/opt/vc/lib -lmmal_core -lmmal_util -lmmal_vc_client -lvcos -lvchostif -lvchiq_arm" AC_DEFINE([HAVE_MMAL], 1, [Define to 1 if we want MMAL]) -]) + ]) +fi # # Check for libavcodec and libavformat from ffmpeg @@ -1230,6 +1239,8 @@ if test "${HAVE_MMAL}" = "yes"; then echo " ... MMAL_CFLAGS: $MMAL_CFLAGS" echo " ... MMAL_OBJ: $MMAL_OBJ" echo " ... MMAL_LIBS: $MMAL_LIBS" +elif test "${WITHOUT_MMAL}" = "yes"; then + echo "MMAL support: disabled" else echo "MMAL support: No" echo " ... libraspberrypi-dev package not installed" From 22b81cfc1acdb4e89200201b6f86503d8ce0c997 Mon Sep 17 00:00:00 2001 From: MrDave Date: Fri, 23 Sep 2016 17:57:13 -0600 Subject: [PATCH 221/233] Additional changes for move to camera instead of thread --- camera1-dist.conf.in | 10 ++++------ camera2-dist.conf.in | 9 ++++----- camera3-dist.conf.in | 9 ++++----- camera4-dist.conf.in | 9 ++++----- motion-dist.conf.in | 14 +++++++------- motion.c | 4 +++- 6 files changed, 26 insertions(+), 29 deletions(-) diff --git a/camera1-dist.conf.in b/camera1-dist.conf.in index 7b11618..12f2410 100644 --- a/camera1-dist.conf.in +++ b/camera1-dist.conf.in @@ -6,12 +6,10 @@ # Capture device options ############################################################ -# # Camera Id -# Id used to label the camera when inserting data into SQL or saving the -# camera image to disk. This is better than using thread number so that there -# always is a consistent labe -# Default: order when the camera file was read +# Consistent identification number to assign to each camera across multiple +# invocations of Motion. +# Default: The order when the camera file was read # camera_id = 1 # Videodevice to be used for capturing (default /dev/video0) @@ -34,7 +32,7 @@ text_left CAMERA 1 # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center diff --git a/camera2-dist.conf.in b/camera2-dist.conf.in index 06b83d9..65d54ea 100644 --- a/camera2-dist.conf.in +++ b/camera2-dist.conf.in @@ -7,10 +7,9 @@ ############################################################ # Camera Id -# Id used to label the camera when inserting data into SQL or saving the -# camera image to disk. This is better than using thread number so that there -# always is a consistent labe -# Default: order when the camera file was read +# Consistent identification number to assign to each camera across multiple +# invocations of Motion. +# Default: The order when the camera file was read # camera_id = 2 # Videodevice to be used for capturing (default /dev/video0) @@ -33,7 +32,7 @@ text_left CAMERA 2 # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center diff --git a/camera3-dist.conf.in b/camera3-dist.conf.in index c5174cf..933f038 100644 --- a/camera3-dist.conf.in +++ b/camera3-dist.conf.in @@ -7,10 +7,9 @@ ############################################################ # Camera Id -# Id used to label the camera when inserting data into SQL or saving the -# camera image to disk. This is better than using thread number so that there -# always is a consistent labe -# Default: order when the camera file was read +# Consistent identification number to assign to each camera across multiple +# invocations of Motion. +# Default: The order when the camera file was read # camera_id = 3 # Videodevice to be used for capturing (default /dev/video0) @@ -33,7 +32,7 @@ text_left CAMERA 3 # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center diff --git a/camera4-dist.conf.in b/camera4-dist.conf.in index 552f7ef..8d3b13a 100644 --- a/camera4-dist.conf.in +++ b/camera4-dist.conf.in @@ -7,10 +7,9 @@ ############################################################ # Camera Id -# Id used to label the camera when inserting data into SQL or saving the -# camera image to disk. This is better than using thread number so that there -# always is a consistent labe -# Default: order when the camera file was read +# Consistent identification number to assign to each camera across multiple +# invocations of Motion. +# Default: The order when the camera file was read # camera_id = 4 # Videodevice to be used for capturing (default /dev/video0) @@ -33,7 +32,7 @@ text_left CAMERA 4 # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = thread (camera) number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center diff --git a/motion-dist.conf.in b/motion-dist.conf.in index cc212e2..5de4b13 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -375,7 +375,7 @@ snapshot_interval 0 # Text Display # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, %T = HH:MM:SS, -# %v = event, %q = frame number, %t = camera number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, \n = new line, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center @@ -435,7 +435,7 @@ text_double off # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = camera number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center @@ -616,7 +616,7 @@ track_stepsize 40 # You can use conversion specifiers for the on_xxxx commands # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, -# %v = event, %q = frame number, %t = camera number, +# %v = event, %q = frame number, %t = camera id number, # %D = changed pixels, %N = noise level, # %i and %J = width and height of motion area, # %K and %L = X and Y coordinates of motion center @@ -755,8 +755,8 @@ quiet on # This motion.conf file AND camera1.conf and camera2.conf. # Only put the options that are unique to each camera in the # camera config files. -; camera @sysconfdir@/motion/camera.conf -; camera @sysconfdir@/motion/camera.conf -; camera @sysconfdir@/motion/camera.conf -; camera @sysconfdir@/motion/camera.conf +; camera @sysconfdir@/motion/camera1.conf +; camera @sysconfdir@/motion/camera2.conf +; camera @sysconfdir@/motion/camera3.conf +; camera @sysconfdir@/motion/camera4.conf diff --git a/motion.c b/motion.c index c21e624..634804d 100644 --- a/motion.c +++ b/motion.c @@ -2761,7 +2761,9 @@ int main (int argc, char **argv) * option is used, so start at 1 then and 0 otherwise. */ for (i = cnt_list[1] != NULL ? 1 : 0; cnt_list[i]; i++) { - /* camera_id is not defined in the config, then the camera id needs to be gnerated. + /* If i is 0 it means no thread files and we then set the thread number to 1 */ + cnt_list[i]->threadnr = i ? i : 1; + /* camera_id is not defined in the config, then the camera id needs to be generated. * the load order will generate a # that will become the camera_id */ cnt_list[i]->conf.camera_id = cnt_list[i]->conf.camera_id ? cnt_list[i]->conf.camera_id: i; From 45f18a4dfe8166dcf583f440d506a44fbfcc7a2c Mon Sep 17 00:00:00 2001 From: MrDave Date: Fri, 23 Sep 2016 20:48:04 -0600 Subject: [PATCH 222/233] Log Level for Mask and Memory Leak Revise the log level to warning when the user has specified a pgm mask file that is different than the size of the image from the camera. Free the memory associated with mask image to close memory leak. --- motion.c | 3 +++ picture.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/motion.c b/motion.c index 1bf0e26..9993b9a 100644 --- a/motion.c +++ b/motion.c @@ -1018,6 +1018,9 @@ static void motion_cleanup(struct context *cnt) free(cnt->imgs.smartmask_buffer); cnt->imgs.smartmask_buffer = NULL; + if (cnt->imgs.mask) free(cnt->imgs.mask); + cnt->imgs.mask = NULL; + free(cnt->imgs.common_buffer); cnt->imgs.common_buffer = NULL; diff --git a/picture.c b/picture.c index 7ca4d7e..79c5207 100644 --- a/picture.c +++ b/picture.c @@ -1018,7 +1018,8 @@ unsigned char *get_pgm(FILE *picture, int width, int height) /* Resize mask if required */ if (mask_width != width || mask_height != height) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Mask needs resizing from %dx%d to %dx%d", + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: The mask file specified is not the same size as image from camera."); + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Attempting to resize mask image from %dx%d to %dx%d", mask_width, mask_height, width, height); resized_image = mymalloc(width * height); From 82ca27beb5029721c1f982e0550f4f30844a41ef Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Sat, 24 Sep 2016 11:56:49 +0200 Subject: [PATCH 223/233] Add systemd service file Remove Fedora initscript (use the systemd service file instead) --- .gitignore | 2 +- Makefile.in | 6 +-- configure.ac | 2 +- motion.init-Fedora.in | 118 ------------------------------------------ motion.service.in | 12 +++++ 5 files changed, 17 insertions(+), 123 deletions(-) delete mode 100644 motion.init-Fedora.in create mode 100644 motion.service.in diff --git a/.gitignore b/.gitignore index 5d7a35f..5d5c6f2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,8 @@ Makefile configure motion-dist.conf motion.init-Debian -motion.init-Fedora motion.init-FreeBSD.sh +motion.service motion.spec thread1-dist.conf thread2-dist.conf diff --git a/Makefile.in b/Makefile.in index 5f9977f..22a77be 100644 --- a/Makefile.in +++ b/Makefile.in @@ -42,8 +42,8 @@ OBJ = motion.o logger.o conf.o draw.o jpegutils.o vloopback_motion.o $( @FFMPEG_OBJ@ @MMAL_OBJ@ @SDL_OBJ@ SRC = $(OBJ:.o=.c) DOC = CHANGELOG COPYING CREDITS README motion_guide.html mask1.png normal.jpg outputmotion1.jpg outputnormal1.jpg -EXAMPLES = *.conf -EXAMPLES_BIN = motion.init-Debian motion.init-Fedora motion.init-FreeBSD.sh +EXAMPLES = *.conf motion.service +EXAMPLES_BIN = motion.init-Debian motion.init-FreeBSD.sh PROGS = motion DEPEND_FILE = .depend @@ -276,7 +276,7 @@ dist: distclean updateguide ################################################################################ distclean: clean @echo "Removing files generated by configure..." - @rm -f config.status config.log config.cache Makefile motion.init-Fedora motion.init-Debian motion.init-FreeBSD.sh + @rm -f config.status config.log config.cache Makefile motion.service motion.init-Debian motion.init-FreeBSD.sh @rm -f camera1-dist.conf camera2-dist.conf camera3-dist.conf camera4-dist.conf motion-dist.conf motion-help.conf motion.spec @rm -rf autom4te.cache config.h @echo "You will need to re-run configure if you want to build Motion." diff --git a/configure.ac b/configure.ac index d085d35..e21fbc3 100644 --- a/configure.ac +++ b/configure.ac @@ -1153,7 +1153,7 @@ camera4-dist.conf motion-dist.conf motion.init-FreeBSD.sh motion.init-Debian -motion.init-Fedora +motion.service motion.spec Makefile ]) diff --git a/motion.init-Fedora.in b/motion.init-Fedora.in deleted file mode 100644 index a21f955..0000000 --- a/motion.init-Fedora.in +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -# -# motion Startup script for the Motion Detection System -# -# chkconfig: - 85 15 -# description: Motion detection system. It is used to detect movement based \ -# on compare images. -# processname: @PACKAGE_NAME@ -# pidfile: /var/run/@PACKAGE_NAME@.pid -# config: /etc/@PACKAGE_NAME@.conf -# -### BEGIN INIT INFO -# Provides: motion -# Required-Start: $local_fs -# Required-Stop: $local_fs -# Default-Start: -# Default-Stop: -# Short-Description: Start and stop motion detection system -# Description: The Motion detection system is used to detect movement based -# on image comparison. -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -motion=${MOTION-/usr/bin/motion} -prog=motion -pidfile=/var/run/motion.pid -lockfile=/var/lock/subsys/motion - -start() { - [ -x $exec ] || exit 5 - [ -f $config ] || exit 6 - echo -n $"Starting $prog: " - # We try to determine which architecture we have so we can - # load libv4l to support more USB cameras. x86_64 and ppc64 - # are both supported by rpmfusion. - case $(uname -i) in - "x86_64" ) - #We load libv4l for 64 Bit x86 architectures - LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; - "ppc64" ) - #We load libv4l for 64 Bit PPC architectures - LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; - * ) - #Default case, we load libv4l for all 32 Bit architectures - LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so daemon $motion 2> /dev/null ;; - esac - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - killproc $motion - retval=$? - echo - [ $retval = 0 ] && rm -f $lockfile -} - -restart() { - stop - start -} - -reload() { - echo -n $"Reloading $prog configuration: " - killproc $motion -HUP - retval=$? - echo - return $retval -} - -rh_status() { - # run checks to determine if the service is running or use generic status - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -# See how we were called. -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - #force_reload - reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 1 -esac -exit $? diff --git a/motion.service.in b/motion.service.in new file mode 100644 index 0000000..03ebd67 --- /dev/null +++ b/motion.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Motion daemon +After=local-fs.target network.target + +[Service] +PIDFile=/var/run/motion.pid +ExecStart=@BIN_PATH@/motion +Type=simple +StandardError=null + +[Install] +WantedBy=multi-user.target From 61e7836e179a43ec589cd04cf67cebaf0f04ea61 Mon Sep 17 00:00:00 2001 From: Mike Terzo Date: Sat, 24 Sep 2016 06:54:24 -0400 Subject: [PATCH 224/233] Camera configuration directory --- conf.c | 68 ++++++++++++++++++++++++++++++++++++++++++++- conf.h | 1 + motion-dist.conf.in | 6 ++++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 6753805..52edeea 100644 --- a/conf.c +++ b/conf.c @@ -23,6 +23,10 @@ * 4. add a entry to the config_params array below, if your * option should be configurable by the config file. */ + +#include +#include + #include "motion.h" #if (defined(BSD) && !defined(PWCBSD)) @@ -31,6 +35,8 @@ #include "video.h" #endif /* BSD */ +#define EXTENSION ".conf" + #ifndef HAVE_GET_CURRENT_DIR_NAME char *get_current_dir_name(void) { @@ -167,13 +173,15 @@ struct config conf_template = { log_file: NULL, log_level: LEVEL_DEFAULT+10, log_type_str: NULL, + camera_dir: sysconfdir"/conf.d" }; static struct context **copy_bool(struct context **, const char *, int); static struct context **copy_int(struct context **, const char *, int); static struct context **config_camera(struct context **cnt, const char *str, int val); - +static struct context **read_camera_dir(struct context **cnt, const char *str, + int val); static const char *print_bool(struct context **, char **, int, unsigned int); static const char *print_int(struct context **, char **, int, unsigned int); @@ -1635,6 +1643,17 @@ config_param config_params[] = { config_thread, print_thread }, + /* using a conf.d style camera addition */ + { + "camera_dir", + "\n##############################################################\n" + "# Camera config directory - One for each camera.\n" + "##############################################################\n", + 1, + CONF_OFFSET(camera_dir), + read_camera_dir, + print_string + }, { NULL, NULL, 0, 0, NULL, NULL } }; @@ -2396,6 +2415,53 @@ static const char *print_camera(struct context **cnt, char **str, return NULL; } +/** + * config_camera_dir + * Read the directory finding all *.conf files in the path + * when calls config_camera + */ + +static struct context **read_camera_dir(struct context **cnt, const char *str, + int val ATTRIBUTE_UNUSED) +{ + DIR *dp; + struct dirent *ep; + int name_len; + + char conf_file[PATH_MAX]; + + dp = opendir(str); + if (dp != NULL) + { + while( (ep = readdir(dp)) ) + { + name_len = strlen(ep->d_name); + if (name_len > strlen(EXTENSION) && + (strncmp(EXTENSION, + (ep->d_name + name_len - strlen(EXTENSION)), + strlen(EXTENSION)) == 0 + ) + ) + { + memset(conf_file, '\0', sizeof(conf_file)); + snprintf(conf_file, sizeof(conf_file) - 1, "%s/%s", + str, ep->d_name); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, + "%s: Processing config file %s", conf_file ); + cnt = config_camera(cnt, conf_file, 0); + } + } + closedir(dp); + } + else + { + MOTION_LOG(ALR, TYPE_ALL, SHOW_ERRNO, "%s: Camera directory config " + "%s not found", str); + } + + return cnt; +} + static struct context **config_thread(struct context **cnt, const char *str, int val ATTRIBUTE_UNUSED) { diff --git a/conf.h b/conf.h index 27ad243..3402043 100644 --- a/conf.h +++ b/conf.h @@ -140,6 +140,7 @@ struct config { int text_double; const char *despeckle_filter; const char *area_detect; + char *camera_dir; int minimum_motion_frames; const char *exif_text; char *pid_file; diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 2269854..55b7a16 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -762,3 +762,9 @@ quiet on ; camera @sysconfdir@/motion/camera3.conf ; camera @sysconfdir@/motion/camera4.conf + +############################################################## +# Camera config directory - One for each camera. +############################################################## +# +; camera_dir @sysconfdir@/motion/conf.d From 7668cb096c52a42a1bdfedbfa25d6af86f61ad94 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 25 Sep 2016 11:59:56 +0100 Subject: [PATCH 225/233] Fix for a couple of warnings in developer builds --- conf.c | 2 +- conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf.c b/conf.c index 52edeea..ba275e5 100644 --- a/conf.c +++ b/conf.c @@ -2426,7 +2426,7 @@ static struct context **read_camera_dir(struct context **cnt, const char *str, { DIR *dp; struct dirent *ep; - int name_len; + size_t name_len; char conf_file[PATH_MAX]; diff --git a/conf.h b/conf.h index 3402043..1e940df 100644 --- a/conf.h +++ b/conf.h @@ -140,7 +140,7 @@ struct config { int text_double; const char *despeckle_filter; const char *area_detect; - char *camera_dir; + const char *camera_dir; int minimum_motion_frames; const char *exif_text; char *pid_file; From 7f16f567c7f86f883234d0729cf713d43a7bb9ff Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 25 Sep 2016 13:41:19 +0100 Subject: [PATCH 226/233] Prevent blank line after ffmpeg log entries ffmpeg seems to put a \n on the end of messages, and MOTION_LOG also adds one, so remove the ffmpeg one. --- ffmpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ffmpeg.c b/ffmpeg.c index 4a5444c..6c94ab3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -812,9 +812,15 @@ AVFrame *ffmpeg_prepare_frame(struct ffmpeg *ffmpeg, unsigned char *y, void ffmpeg_avcodec_log(void *ignoreme ATTRIBUTE_UNUSED, int errno_flag, const char *fmt, va_list vl) { char buf[1024]; + char *end; /* Flatten the message coming in from avcodec. */ vsnprintf(buf, sizeof(buf), fmt, vl); + end = buf + strlen(buf); + if (end > buf && end[-1] == '\n') + { + *--end = 0; + } /* If the debug_level is correct then send the message to the motion logging routine. * While it is not really desired to look for specific text in the message, there does From 3562d7da5bf05b93b1633ee2a47c4e0957d11984 Mon Sep 17 00:00:00 2001 From: Joseph Heenan Date: Sun, 25 Sep 2016 13:42:25 +0100 Subject: [PATCH 227/233] Update .gitignore for thread -> camera rename of config files --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5d5c6f2..9eefd5d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ motion.init-Debian motion.init-FreeBSD.sh motion.service motion.spec -thread1-dist.conf -thread2-dist.conf -thread3-dist.conf -thread4-dist.conf +camera1-dist.conf +camera2-dist.conf +camera3-dist.conf +camera4-dist.conf From 3dcd57ee43d8961e9271a2d1422d328c8e4de35d Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Sun, 25 Sep 2016 18:31:31 +0200 Subject: [PATCH 228/233] Remove old pwc-ioctl.h files, which are not used anywhere in the program --- pwc-ioctl.h-10.0.10 | 334 ------------------------------------------- pwc-ioctl.h-10.0.5 | 292 ------------------------------------- pwc-ioctl.h-pwc8.0 | 229 ----------------------------- pwc-ioctl.h-pwc9.0.1 | 279 ------------------------------------ 4 files changed, 1134 deletions(-) delete mode 100644 pwc-ioctl.h-10.0.10 delete mode 100644 pwc-ioctl.h-10.0.5 delete mode 100644 pwc-ioctl.h-pwc8.0 delete mode 100644 pwc-ioctl.h-pwc9.0.1 diff --git a/pwc-ioctl.h-10.0.10 b/pwc-ioctl.h-10.0.10 deleted file mode 100644 index 48a3861..0000000 --- a/pwc-ioctl.h-10.0.10 +++ /dev/null @@ -1,334 +0,0 @@ -#ifndef PWC_IOCTL_H -#define PWC_IOCTL_H - -/* (C) 2001-2004 Nemosoft Unv. - (C) 2004-2006 Luc Saillard (luc@saillard.org) - - NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx - driver and thus may have bugs that are not present in the original version. - Please send bug reports and support requests to . - The decompression routines have been implemented by reverse-engineering the - Nemosoft binary pwcx module. Caveat emptor. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* This is pwc-ioctl.h belonging to PWC 10.0.10 - It contains structures and defines to communicate from user space - directly to the driver. - */ - -/* - Changes - 2001/08/03 Alvarado Added ioctl constants to access methods for - changing white balance and red/blue gains - 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE - 2003/12/13 Nemosft Unv. Some modifications to make interfacing to - PWCX easier - 2006/01/01 Luc Saillard Add raw format definition - */ - -/* These are private ioctl() commands, specific for the Philips webcams. - They contain functions not found in other webcams, and settings not - specified in the Video4Linux API. - - The #define names are built up like follows: - VIDIOC VIDeo IOCtl prefix - PWC Philps WebCam - G optional: Get - S optional: Set - ... the function - */ - -#if (!defined(BSD)) -#include -#include - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 10) -/* Compatibility for older kernel */ -typedef __u16 __le16; -#endif - -#endif /* ( !BSD ) */ - - /* Enumeration of image sizes */ -#define PSZ_SQCIF 0x00 -#define PSZ_QSIF 0x01 -#define PSZ_QCIF 0x02 -#define PSZ_SIF 0x03 -#define PSZ_CIF 0x04 -#define PSZ_VGA 0x05 -#define PSZ_MAX 6 - - -/* The frame rate is encoded in the video_window.flags parameter using - the upper 16 bits, since some flags are defined nowadays. The following - defines provide a mask and shift to filter out this value. - This value can also be passing using the private flag when using v4l2 and - VIDIOC_S_FMT ioctl. - - In 'Snapshot' mode the camera freezes its automatic exposure and colour - balance controls. - */ -#define PWC_FPS_SHIFT 16 -#define PWC_FPS_MASK 0x00FF0000 -#define PWC_FPS_FRMASK 0x003F0000 -#define PWC_FPS_SNAPSHOT 0x00400000 -#define PWC_QLT_MASK 0x03000000 -#define PWC_QLT_SHIFT 24 - - -/* structure for transferring x & y coordinates */ -struct pwc_coord -{ - int x, y; /* guess what */ - int size; /* size, or offset */ -}; - - -/* Used with VIDIOCPWCPROBE */ -struct pwc_probe -{ - char name[32]; - int type; -}; - -struct pwc_serial -{ - char serial[30]; /* String with serial number. Contains terminating 0 */ -}; - -/* pwc_whitebalance.mode values */ -#define PWC_WB_INDOOR 0 -#define PWC_WB_OUTDOOR 1 -#define PWC_WB_FL 2 -#define PWC_WB_MANUAL 3 -#define PWC_WB_AUTO 4 - -/* Used with VIDIOCPWC[SG]AWB (Auto White Balance). - Set mode to one of the PWC_WB_* values above. - *red and *blue are the respective gains of these colour components inside - the camera; range 0..65535 - When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; - otherwise undefined. - 'read_red' and 'read_blue' are read-only. -*/ -struct pwc_whitebalance -{ - int mode; - int manual_red, manual_blue; /* R/W */ - int read_red, read_blue; /* R/O */ -}; - -/* - 'control_speed' and 'control_delay' are used in automatic whitebalance mode, - and tell the camera how fast it should react to changes in lighting, and - with how much delay. Valid values are 0..65535. -*/ -struct pwc_wb_speed -{ - int control_speed; - int control_delay; - -}; - -/* Used with VIDIOCPWC[SG]LED */ -struct pwc_leds -{ - int led_on; /* Led on-time; range = 0..25000 */ - int led_off; /* Led off-time; range = 0..25000 */ -}; - -/* Image size (used with GREALSIZE) */ -struct pwc_imagesize -{ - int width; - int height; -}; - -/* Defines and structures for Motorized Pan & Tilt */ -#define PWC_MPT_PAN 0x01 -#define PWC_MPT_TILT 0x02 -#define PWC_MPT_TIMEOUT 0x04 /* for status */ - -/* Set angles; when absolute != 0, the angle is absolute and the - driver calculates the relative offset for you. This can only - be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns - absolute angles. - */ -struct pwc_mpt_angles -{ - int absolute; /* write-only */ - int pan; /* degrees * 100 */ - int tilt; /* degress * 100 */ -}; - -/* Range of angles of the camera, both horizontally and vertically. - */ -struct pwc_mpt_range -{ - int pan_min, pan_max; /* degrees * 100 */ - int tilt_min, tilt_max; -}; - -struct pwc_mpt_status -{ - int status; - int time_pan; - int time_tilt; -}; - - -/* This is used for out-of-kernel decompression. With it, you can get - all the necessary information to initialize and use the decompressor - routines in standalone applications. - */ -struct pwc_video_command -{ - int type; /* camera type (645, 675, 730, etc.) */ - int release; /* release number */ - - int size; /* one of PSZ_* */ - int alternate; - int command_len; /* length of USB video command */ - unsigned char command_buf[13]; /* Actual USB video command */ - int bandlength; /* >0 = compressed */ - int frame_size; /* Size of one (un)compressed frame */ -}; - -/* Flags for PWCX subroutines. Not all modules honour all flags. */ -#define PWCX_FLAG_PLANAR 0x0001 -#define PWCX_FLAG_BAYER 0x0008 - - -/* IOCTL definitions */ - - /* Restore user settings */ -#define VIDIOCPWCRUSER _IO('v', 192) - /* Save user settings */ -#define VIDIOCPWCSUSER _IO('v', 193) - /* Restore factory settings */ -#define VIDIOCPWCFACTORY _IO('v', 194) - - /* You can manipulate the compression factor. A compression preference of 0 - means use uncompressed modes when available; 1 is low compression, 2 is - medium and 3 is high compression preferred. Of course, the higher the - compression, the lower the bandwidth used but more chance of artefacts - in the image. The driver automatically chooses a higher compression when - the preferred mode is not available. - */ - /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ -#define VIDIOCPWCSCQUAL _IOW('v', 195, int) - /* Get preferred compression quality */ -#define VIDIOCPWCGCQUAL _IOR('v', 195, int) - - -/* Retrieve serial number of camera */ -#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) - - /* This is a probe function; since so many devices are supported, it - becomes difficult to include all the names in programs that want to - check for the enhanced Philips stuff. So in stead, try this PROBE; - it returns a structure with the original name, and the corresponding - Philips type. - To use, fill the structure with zeroes, call PROBE and if that succeeds, - compare the name with that returned from VIDIOCGCAP; they should be the - same. If so, you can be assured it is a Philips (OEM) cam and the type - is valid. - */ -#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) - - /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ -#define VIDIOCPWCSAGC _IOW('v', 200, int) - /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCGAGC _IOR('v', 200, int) - /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) - - /* Color compensation (Auto White Balance) */ -#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) -#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) - - /* Auto WB speed */ -#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) -#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) - - /* LEDs on/off/blink; int range 0..65535 */ -#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) -#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) - - /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ -#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) -#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) - - /* Backlight compensation; 0 = off, otherwise on */ -#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) -#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) - - /* Flickerless mode; = 0 off, otherwise on */ -#define VIDIOCPWCSFLICKER _IOW('v', 208, int) -#define VIDIOCPWCGFLICKER _IOR('v', 208, int) - - /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ -#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) -#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) - - /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ -#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) - - /* Motorized pan & tilt functions */ -#define VIDIOCPWCMPTRESET _IOW('v', 211, int) -#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) -#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) - - /* Get the USB set-video command; needed for initializing libpwcx */ -#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) -struct pwc_table_init_buffer { - int len; - char *buffer; -}; -#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) - -/* - * This is private command used when communicating with v4l2. - * In the future all private ioctl will be remove/replace to - * use interface offer by v4l2. - */ - -#if (defined(MOTION_V4L2)) && (!defined(BSD)) - -#define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0) -#define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1) -#define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2) -#define V4L2_CID_PRIVATE_COLOUR_MODE (V4L2_CID_PRIVATE_BASE + 3) -#define V4L2_CID_PRIVATE_AUTOCONTOUR (V4L2_CID_PRIVATE_BASE + 4) -#define V4L2_CID_PRIVATE_CONTOUR (V4L2_CID_PRIVATE_BASE + 5) -#define V4L2_CID_PRIVATE_BACKLIGHT (V4L2_CID_PRIVATE_BASE + 6) -#define V4L2_CID_PRIVATE_FLICKERLESS (V4L2_CID_PRIVATE_BASE + 7) -#define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8) - -struct pwc_raw_frame { - __le16 type; /* type of the webcam */ - __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */ - __u8 cmd[4]; /* the four byte of the command (in case of nala, - only the first 3 bytes is filled) */ - __u8 rawframe[0]; /* frame_size = H/4*vbandlength */ -} __attribute__ ((packed)); - -#endif /* MOTION_V4L2 && (! BSD ) */ - -#endif diff --git a/pwc-ioctl.h-10.0.5 b/pwc-ioctl.h-10.0.5 deleted file mode 100644 index 65805ea..0000000 --- a/pwc-ioctl.h-10.0.5 +++ /dev/null @@ -1,292 +0,0 @@ -#ifndef PWC_IOCTL_H -#define PWC_IOCTL_H - -/* (C) 2001-2004 Nemosoft Unv. - (C) 2004 Luc Saillard (luc@saillard.org) - - NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx - driver and thus may have bugs that are not present in the original version. - Please send bug reports and support requests to . - The decompression routines have been implemented by reverse-engineering the - Nemosoft binary pwcx module. Caveat emptor. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* This is pwc-ioctl.h belonging to PWC 8.12.1 - It contains structures and defines to communicate from user space - directly to the driver. - */ - -/* - Changes - 2001/08/03 Alvarado Added ioctl constants to access methods for - changing white balance and red/blue gains - 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE - 2003/12/13 Nemosft Unv. Some modifications to make interfacing to - PWCX easier - */ - -/* These are private ioctl() commands, specific for the Philips webcams. - They contain functions not found in other webcams, and settings not - specified in the Video4Linux API. - - The #define names are built up like follows: - VIDIOC VIDeo IOCtl prefix - PWC Philps WebCam - G optional: Get - S optional: Set - ... the function - */ - - - /* Enumeration of image sizes */ -#define PSZ_SQCIF 0x00 -#define PSZ_QSIF 0x01 -#define PSZ_QCIF 0x02 -#define PSZ_SIF 0x03 -#define PSZ_CIF 0x04 -#define PSZ_VGA 0x05 -#define PSZ_MAX 6 - - -/* The frame rate is encoded in the video_window.flags parameter using - the upper 16 bits, since some flags are defined nowadays. The following - defines provide a mask and shift to filter out this value. - - In 'Snapshot' mode the camera freezes its automatic exposure and colour - balance controls. - */ -#define PWC_FPS_SHIFT 16 -#define PWC_FPS_MASK 0x00FF0000 -#define PWC_FPS_FRMASK 0x003F0000 -#define PWC_FPS_SNAPSHOT 0x00400000 - - -/* structure for transfering x & y coordinates */ -struct pwc_coord -{ - int x, y; /* guess what */ - int size; /* size, or offset */ -}; - - -/* Used with VIDIOCPWCPROBE */ -struct pwc_probe -{ - char name[32]; - int type; -}; - -struct pwc_serial -{ - char serial[30]; /* String with serial number. Contains terminating 0 */ -}; - -/* pwc_whitebalance.mode values */ -#define PWC_WB_INDOOR 0 -#define PWC_WB_OUTDOOR 1 -#define PWC_WB_FL 2 -#define PWC_WB_MANUAL 3 -#define PWC_WB_AUTO 4 - -/* Used with VIDIOCPWC[SG]AWB (Auto White Balance). - Set mode to one of the PWC_WB_* values above. - *red and *blue are the respective gains of these colour components inside - the camera; range 0..65535 - When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; - otherwise undefined. - 'read_red' and 'read_blue' are read-only. -*/ -struct pwc_whitebalance -{ - int mode; - int manual_red, manual_blue; /* R/W */ - int read_red, read_blue; /* R/O */ -}; - -/* - 'control_speed' and 'control_delay' are used in automatic whitebalance mode, - and tell the camera how fast it should react to changes in lighting, and - with how much delay. Valid values are 0..65535. -*/ -struct pwc_wb_speed -{ - int control_speed; - int control_delay; - -}; - -/* Used with VIDIOCPWC[SG]LED */ -struct pwc_leds -{ - int led_on; /* Led on-time; range = 0..25000 */ - int led_off; /* Led off-time; range = 0..25000 */ -}; - -/* Image size (used with GREALSIZE) */ -struct pwc_imagesize -{ - int width; - int height; -}; - -/* Defines and structures for Motorized Pan & Tilt */ -#define PWC_MPT_PAN 0x01 -#define PWC_MPT_TILT 0x02 -#define PWC_MPT_TIMEOUT 0x04 /* for status */ - -/* Set angles; when absolute != 0, the angle is absolute and the - driver calculates the relative offset for you. This can only - be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns - absolute angles. - */ -struct pwc_mpt_angles -{ - int absolute; /* write-only */ - int pan; /* degrees * 100 */ - int tilt; /* degress * 100 */ -}; - -/* Range of angles of the camera, both horizontally and vertically. - */ -struct pwc_mpt_range -{ - int pan_min, pan_max; /* degrees * 100 */ - int tilt_min, tilt_max; -}; - -struct pwc_mpt_status -{ - int status; - int time_pan; - int time_tilt; -}; - - -/* This is used for out-of-kernel decompression. With it, you can get - all the necessary information to initialize and use the decompressor - routines in standalone applications. - */ -struct pwc_video_command -{ - int type; /* camera type (645, 675, 730, etc.) */ - int release; /* release number */ - - int size; /* one of PSZ_* */ - int alternate; - int command_len; /* length of USB video command */ - unsigned char command_buf[13]; /* Actual USB video command */ - int bandlength; /* >0 = compressed */ - int frame_size; /* Size of one (un)compressed frame */ -}; - -/* Flags for PWCX subroutines. Not all modules honour all flags. */ -#define PWCX_FLAG_PLANAR 0x0001 -#define PWCX_FLAG_BAYER 0x0008 - - -/* IOCTL definitions */ - - /* Restore user settings */ -#define VIDIOCPWCRUSER _IO('v', 192) - /* Save user settings */ -#define VIDIOCPWCSUSER _IO('v', 193) - /* Restore factory settings */ -#define VIDIOCPWCFACTORY _IO('v', 194) - - /* You can manipulate the compression factor. A compression preference of 0 - means use uncompressed modes when available; 1 is low compression, 2 is - medium and 3 is high compression preferred. Of course, the higher the - compression, the lower the bandwidth used but more chance of artefacts - in the image. The driver automatically chooses a higher compression when - the preferred mode is not available. - */ - /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ -#define VIDIOCPWCSCQUAL _IOW('v', 195, int) - /* Get preferred compression quality */ -#define VIDIOCPWCGCQUAL _IOR('v', 195, int) - - -/* Retrieve serial number of camera */ -#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) - - /* This is a probe function; since so many devices are supported, it - becomes difficult to include all the names in programs that want to - check for the enhanced Philips stuff. So in stead, try this PROBE; - it returns a structure with the original name, and the corresponding - Philips type. - To use, fill the structure with zeroes, call PROBE and if that succeeds, - compare the name with that returned from VIDIOCGCAP; they should be the - same. If so, you can be assured it is a Philips (OEM) cam and the type - is valid. - */ -#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) - - /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ -#define VIDIOCPWCSAGC _IOW('v', 200, int) - /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCGAGC _IOR('v', 200, int) - /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) - - /* Color compensation (Auto White Balance) */ -#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) -#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) - - /* Auto WB speed */ -#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) -#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) - - /* LEDs on/off/blink; int range 0..65535 */ -#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) -#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) - - /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ -#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) -#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) - - /* Backlight compensation; 0 = off, otherwise on */ -#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) -#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) - - /* Flickerless mode; = 0 off, otherwise on */ -#define VIDIOCPWCSFLICKER _IOW('v', 208, int) -#define VIDIOCPWCGFLICKER _IOR('v', 208, int) - - /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ -#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) -#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) - - /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ -#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) - - /* Motorized pan & tilt functions */ -#define VIDIOCPWCMPTRESET _IOW('v', 211, int) -#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) -#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) - - /* Get the USB set-video command; needed for initializing libpwcx */ -#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) -struct pwc_table_init_buffer { - int len; - char *buffer; - -}; -#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) - -#endif diff --git a/pwc-ioctl.h-pwc8.0 b/pwc-ioctl.h-pwc8.0 deleted file mode 100644 index 0161986..0000000 --- a/pwc-ioctl.h-pwc8.0 +++ /dev/null @@ -1,229 +0,0 @@ -#ifndef PWC_IOCTL_H -#define PWC_IOCTL_H - -/* (C) 2001-2003 Nemosoft Unv. webcam@smcc.demon.nl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* This is pwc-ioctl.h belonging to PWC 8.10 */ - -/* - Changes - 2001/08/03 Alvarado Added ioctl constants to access methods for - changing white balance and red/blue gains - 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE - */ - -/* These are private ioctl() commands, specific for the Philips webcams. - They contain functions not found in other webcams, and settings not - specified in the Video4Linux API. - - The #define names are built up like follows: - VIDIOC VIDeo IOCtl prefix - PWC Philps WebCam - G optional: Get - S optional: Set - ... the function - */ - - - - -/* The frame rate is encoded in the video_window.flags parameter using - the upper 16 bits, since some flags are defined nowadays. The following - defines provide a mask and shift to filter out this value. - - In 'Snapshot' mode the camera freezes its automatic exposure and colour - balance controls. - */ -#define PWC_FPS_SHIFT 16 -#define PWC_FPS_MASK 0x00FF0000 -#define PWC_FPS_FRMASK 0x003F0000 -#define PWC_FPS_SNAPSHOT 0x00400000 - - - -struct pwc_probe -{ - char name[32]; - int type; -}; - - -/* pwc_whitebalance.mode values */ -#define PWC_WB_INDOOR 0 -#define PWC_WB_OUTDOOR 1 -#define PWC_WB_FL 2 -#define PWC_WB_MANUAL 3 -#define PWC_WB_AUTO 4 - -/* Used with VIDIOCPWC[SG]AWB (Auto White Balance). - Set mode to one of the PWC_WB_* values above. - *red and *blue are the respective gains of these colour components inside - the camera; range 0..65535 - When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; - otherwise undefined. - 'read_red' and 'read_blue' are read-only. -*/ - -struct pwc_whitebalance -{ - int mode; - int manual_red, manual_blue; /* R/W */ - int read_red, read_blue; /* R/O */ -}; - -/* - 'control_speed' and 'control_delay' are used in automatic whitebalance mode, - and tell the camera how fast it should react to changes in lighting, and - with how much delay. Valid values are 0..65535. -*/ -struct pwc_wb_speed -{ - int control_speed; - int control_delay; - -}; - -/* Used with VIDIOCPWC[SG]LED */ -struct pwc_leds -{ - int led_on; /* Led on-time; range = 0..25000 */ - int led_off; /* Led off-time; range = 0..25000 */ -}; - -/* Image size (used with GREALSIZE) */ -struct pwc_imagesize -{ - int width; - int height; -}; - -/* Defines and structures for Motorized Pan & Tilt */ -#define PWC_MPT_PAN 0x01 -#define PWC_MPT_TILT 0x02 -#define PWC_MPT_TIMEOUT 0x04 /* for status */ - -/* Set angles; when absolute = 1, the angle is absolute and the - driver calculates the relative offset for you. This can only - be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns - absolute angles. - */ -struct pwc_mpt_angles -{ - int absolute; /* write-only */ - int pan; /* degrees * 100 */ - int tilt; /* degress * 100 */ - int zoom; /* N/A, set to -1 */ -}; - -/* Range of angles of the camera, both horizontally and vertically. - The zoom is not used, maybe in the future... - - */ -struct pwc_mpt_range -{ - int pan_min, pan_max; /* degrees * 100 */ - int tilt_min, tilt_max; - int zoom_min, zoom_max; /* -1, -1 */ -}; - -struct pwc_mpt_status -{ - int status; - int time_pan; - int time_tilt; -}; - - - /* Restore user settings */ -#define VIDIOCPWCRUSER _IO('v', 192) - /* Save user settings */ -#define VIDIOCPWCSUSER _IO('v', 193) - /* Restore factory settings */ -#define VIDIOCPWCFACTORY _IO('v', 194) - - /* You can manipulate the compression factor. A compression preference of 0 - means use uncompressed modes when available; 1 is low compression, 2 is - medium and 3 is high compression preferred. Of course, the higher the - compression, the lower the bandwidth used but more chance of artefacts - in the image. The driver automatically chooses a higher compression when - the preferred mode is not available. - */ - /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ -#define VIDIOCPWCSCQUAL _IOW('v', 195, int) - /* Get preferred compression quality */ -#define VIDIOCPWCGCQUAL _IOR('v', 195, int) - - - /* This is a probe function; since so many devices are supported, it - becomes difficult to include all the names in programs that want to - check for the enhanced Philips stuff. So in stead, try this PROBE; - it returns a structure with the original name, and the corresponding - Philips type. - To use, fill the structure with zeroes, call PROBE and if that succeeds, - compare the name with that returned from VIDIOCGCAP; they should be the - same. If so, you can be assured it is a Philips (OEM) cam and the type - is valid. - */ -#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) - - /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ -#define VIDIOCPWCSAGC _IOW('v', 200, int) - /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCGAGC _IOR('v', 200, int) - /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) - - /* Color compensation (Auto White Balance) */ -#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) -#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) - - /* Auto WB speed */ -#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) -#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) - - /* LEDs on/off/blink; int range 0..65535 */ -#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) -#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) - - /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ -#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) -#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) - - /* Backlight compensation; 0 = off, otherwise on */ -#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) -#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) - - /* Flickerless mode; = 0 off, otherwise on */ -#define VIDIOCPWCSFLICKER _IOW('v', 208, int) -#define VIDIOCPWCGFLICKER _IOR('v', 208, int) - - /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ -#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) -#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) - - /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ -#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) - - /* Motorized pan & tilt functions */ -#define VIDIOCPWCMPTRESET _IOW('v', 211, int) -#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) -#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) - -#endif diff --git a/pwc-ioctl.h-pwc9.0.1 b/pwc-ioctl.h-pwc9.0.1 deleted file mode 100644 index 2535a3c..0000000 --- a/pwc-ioctl.h-pwc9.0.1 +++ /dev/null @@ -1,279 +0,0 @@ -#ifndef PWC_IOCTL_H -#define PWC_IOCTL_H - -/* (C) 2001-2004 Nemosoft Unv. webcam@smcc.demon.nl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* This is pwc-ioctl.h belonging to PWC 8.12.1 - It contains structures and defines to communicate from user space - directly to the driver. - */ - -/* - Changes - 2001/08/03 Alvarado Added ioctl constants to access methods for - changing white balance and red/blue gains - 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE - 2003/12/13 Nemosft Unv. Some modifications to make interfacing to - PWCX easier - */ - -/* These are private ioctl() commands, specific for the Philips webcams. - They contain functions not found in other webcams, and settings not - specified in the Video4Linux API. - - The #define names are built up like follows: - VIDIOC VIDeo IOCtl prefix - PWC Philps WebCam - G optional: Get - S optional: Set - ... the function - */ - - - /* Enumeration of image sizes */ -#define PSZ_SQCIF 0x00 -#define PSZ_QSIF 0x01 -#define PSZ_QCIF 0x02 -#define PSZ_SIF 0x03 -#define PSZ_CIF 0x04 -#define PSZ_VGA 0x05 -#define PSZ_MAX 6 - - -/* The frame rate is encoded in the video_window.flags parameter using - the upper 16 bits, since some flags are defined nowadays. The following - defines provide a mask and shift to filter out this value. - - In 'Snapshot' mode the camera freezes its automatic exposure and colour - balance controls. - */ -#define PWC_FPS_SHIFT 16 -#define PWC_FPS_MASK 0x00FF0000 -#define PWC_FPS_FRMASK 0x003F0000 -#define PWC_FPS_SNAPSHOT 0x00400000 - - -/* structure for transfering x & y coordinates */ -struct pwc_coord -{ - int x, y; /* guess what */ - int size; /* size, or offset */ -}; - - -/* Used with VIDIOCPWCPROBE */ -struct pwc_probe -{ - char name[32]; - int type; -}; - -struct pwc_serial -{ - char serial[30]; /* String with serial number. Contains terminating 0 */ -}; - -/* pwc_whitebalance.mode values */ -#define PWC_WB_INDOOR 0 -#define PWC_WB_OUTDOOR 1 -#define PWC_WB_FL 2 -#define PWC_WB_MANUAL 3 -#define PWC_WB_AUTO 4 - -/* Used with VIDIOCPWC[SG]AWB (Auto White Balance). - Set mode to one of the PWC_WB_* values above. - *red and *blue are the respective gains of these colour components inside - the camera; range 0..65535 - When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read; - otherwise undefined. - 'read_red' and 'read_blue' are read-only. -*/ -struct pwc_whitebalance -{ - int mode; - int manual_red, manual_blue; /* R/W */ - int read_red, read_blue; /* R/O */ -}; - -/* - 'control_speed' and 'control_delay' are used in automatic whitebalance mode, - and tell the camera how fast it should react to changes in lighting, and - with how much delay. Valid values are 0..65535. -*/ -struct pwc_wb_speed -{ - int control_speed; - int control_delay; - -}; - -/* Used with VIDIOCPWC[SG]LED */ -struct pwc_leds -{ - int led_on; /* Led on-time; range = 0..25000 */ - int led_off; /* Led off-time; range = 0..25000 */ -}; - -/* Image size (used with GREALSIZE) */ -struct pwc_imagesize -{ - int width; - int height; -}; - -/* Defines and structures for Motorized Pan & Tilt */ -#define PWC_MPT_PAN 0x01 -#define PWC_MPT_TILT 0x02 -#define PWC_MPT_TIMEOUT 0x04 /* for status */ - -/* Set angles; when absolute != 0, the angle is absolute and the - driver calculates the relative offset for you. This can only - be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns - absolute angles. - */ -struct pwc_mpt_angles -{ - int absolute; /* write-only */ - int pan; /* degrees * 100 */ - int tilt; /* degress * 100 */ -}; - -/* Range of angles of the camera, both horizontally and vertically. - */ -struct pwc_mpt_range -{ - int pan_min, pan_max; /* degrees * 100 */ - int tilt_min, tilt_max; -}; - -struct pwc_mpt_status -{ - int status; - int time_pan; - int time_tilt; -}; - - -/* This is used for out-of-kernel decompression. With it, you can get - all the necessary information to initialize and use the decompressor - routines in standalone applications. - */ -struct pwc_video_command -{ - int type; /* camera type (645, 675, 730, etc.) */ - int release; /* release number */ - - int size; /* one of PSZ_* */ - int alternate; - int command_len; /* length of USB video command */ - unsigned char command_buf[13]; /* Actual USB video command */ - int bandlength; /* >0 = compressed */ - int frame_size; /* Size of one (un)compressed frame */ -}; - -/* Flags for PWCX subroutines. Not all modules honour all flags. */ -#define PWCX_FLAG_PLANAR 0x0001 -#define PWCX_FLAG_BAYER 0x0008 - - -/* IOCTL definitions */ - - /* Restore user settings */ -#define VIDIOCPWCRUSER _IO('v', 192) - /* Save user settings */ -#define VIDIOCPWCSUSER _IO('v', 193) - /* Restore factory settings */ -#define VIDIOCPWCFACTORY _IO('v', 194) - - /* You can manipulate the compression factor. A compression preference of 0 - means use uncompressed modes when available; 1 is low compression, 2 is - medium and 3 is high compression preferred. Of course, the higher the - compression, the lower the bandwidth used but more chance of artefacts - in the image. The driver automatically chooses a higher compression when - the preferred mode is not available. - */ - /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */ -#define VIDIOCPWCSCQUAL _IOW('v', 195, int) - /* Get preferred compression quality */ -#define VIDIOCPWCGCQUAL _IOR('v', 195, int) - - -/* Retrieve serial number of camera */ -#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial) - - /* This is a probe function; since so many devices are supported, it - becomes difficult to include all the names in programs that want to - check for the enhanced Philips stuff. So in stead, try this PROBE; - it returns a structure with the original name, and the corresponding - Philips type. - To use, fill the structure with zeroes, call PROBE and if that succeeds, - compare the name with that returned from VIDIOCGCAP; they should be the - same. If so, you can be assured it is a Philips (OEM) cam and the type - is valid. - */ -#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) - - /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ -#define VIDIOCPWCSAGC _IOW('v', 200, int) - /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCGAGC _IOR('v', 200, int) - /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */ -#define VIDIOCPWCSSHUTTER _IOW('v', 201, int) - - /* Color compensation (Auto White Balance) */ -#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance) -#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance) - - /* Auto WB speed */ -#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed) -#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed) - - /* LEDs on/off/blink; int range 0..65535 */ -#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds) -#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds) - - /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */ -#define VIDIOCPWCSCONTOUR _IOW('v', 206, int) -#define VIDIOCPWCGCONTOUR _IOR('v', 206, int) - - /* Backlight compensation; 0 = off, otherwise on */ -#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int) -#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int) - - /* Flickerless mode; = 0 off, otherwise on */ -#define VIDIOCPWCSFLICKER _IOW('v', 208, int) -#define VIDIOCPWCGFLICKER _IOR('v', 208, int) - - /* Dynamic noise reduction; 0 off, 3 = high noise reduction */ -#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int) -#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int) - - /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */ -#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize) - - /* Motorized pan & tilt functions */ -#define VIDIOCPWCMPTRESET _IOW('v', 211, int) -#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range) -#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) -#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) - - /* Get the USB set-video command; needed for initializing libpwcx */ -#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command) - -#endif From b2f495c4969ea097ae84a5712a5fc452813d4a1d Mon Sep 17 00:00:00 2001 From: Sebastiaan Lokhorst Date: Sun, 25 Sep 2016 18:31:55 +0200 Subject: [PATCH 229/233] Remove README.axis_2100 file which only has trivial instructions --- README.axis_2100 | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 README.axis_2100 diff --git a/README.axis_2100 b/README.axis_2100 deleted file mode 100644 index 67a870e..0000000 --- a/README.axis_2100 +++ /dev/null @@ -1,21 +0,0 @@ -Using motion with the Axis 2100 network camera - -First compile the motion binary as described in README and INSTALL -Then edit motion.conf: Add your axis cameras ip address to the netcam_url -paramter in the "Captute Device Options" section. - - To increase the performance use this urls : - - # for multipart jpeg - http://192.168.1.10/axis-cgi/mjpg/video.cgi?showlength=1 - - or - - # for single jpeg - http://192.168.1.10/axis-cgi/jpg/image.cgi?showlength=1 - -There are only two valid picture sizes for the axis camera: 320x240 and 640x480 - -TODO: - - - Make the IP changeable at run-time. From 7680f25bf83965e541b50e53512ccc9e9485aab7 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Wed, 28 Sep 2016 15:33:59 +0200 Subject: [PATCH 230/233] Fix line endings for man pages man pages are typically for UNIX systems where the line endings are LF not CRLF. The file currently uses a mix of both, urgh. --- motion.1 | 4030 +++++++++++++++++++++++++++--------------------------- 1 file changed, 2015 insertions(+), 2015 deletions(-) diff --git a/motion.1 b/motion.1 index fbbe6b5..02bc238 100644 --- a/motion.1 +++ b/motion.1 @@ -1,647 +1,647 @@ .TH MOTION 1 2016-08-25 "Motion" "Motion Options and Config Files" -.SH NAME -motion \- Detct motion using a video4linux device or network camera -.SH SYNOPSIS +.SH NAME +motion \- Detct motion using a video4linux device or network camera +.SH SYNOPSIS .B motion [ \-hbnsm ] [ \-c config file path ] [ \-d level ] [ \-k level ] [ \-p process_id_file ][ \-l log_file ] -.SH DESCRIPTION -.I Motion -uses a video4linux device or network camera to detect motion. If motion is detected both normal -and motion pictures can be taken. Motion can also take actions to notify you -if needed. Creation of automated snapshots is also possible. -.SH OPTIONS -.TP -.B \-c -Full path and filename of config file. -For example: \fI /home/kurt/motion.conf \fR -The default is \fI /usr/local/etc/motion\fR unless specified differently when building Motion. -Many RPMs and Debian packages will use \fI/etc\fR or \fI/etc/motion\fR as the default. -.TP -.B \-h -Show help screen. -.TP -.B \-b -Run in daemon mode. -.TP -.B \-n -Run in non-daemon mode. -.TP -.B \-s -Run in setup mode. Also forces non-daemon mode -.TP -.B \-d -Run with message log level 1-9. -.TP -.B \-k -Run with message log type 1-9 -.TP -.B \-l -Full path and file name for the log file -.TP -.B \-p -Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. -.TP -.B \-m -Start in pause mode -.TP -.SH "CONFIG FILE OPTIONS" -These are the options that can be used in the config file. -.I They are overridden by the commandline! -All number values are integer numbers (no decimals allowed). -Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). - -.TP -.B daemon -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -When specified as ON, Motion goes into daemon (background process) mode and releases the terminal. -.RE -.RE - -.TP -.B process_id_file -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -File to store the process ID, also called pid file. -.RE -.RE - -.TP -.B setup_mode -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Start in Setup-Mode, daemon disabled. -.RE -.RE - -.TP -.B logfile -.RS -.nf -Values: User specified string -Default: Not Defined -Description: -.fi -.RS -File to save logs messages, if not defined stderr and syslog is used. -.RE -.RE - -.TP -.B log_level -.RS -.nf -Values: 1 to 9 (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL) -Default: 6 / NTC -Description: -.fi -.RS -Specify the level of verbosity in the messages sent to the log. -.RE -.RE - -.TP -.B log_type -.RS -.nf -Values: COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL -Default: ALL -Description: -.fi -.RS -Filter to log messages by type -.RE -.RE - -.TP -.B videodevice -.RS -.nf -Values: User specified string -Default: /dev/video0 -Description: -.fi -.RS -String to specify the videodevice to be used for capturing. -For Linux, the format is usually /dev/videoX where X varies depending upon the video devices connnected to the computer. -For FreeBSD the default device would be /dev/bktr0. -.RE -.RE - -.TP -.B v4l2_palette -.RS -.nf -Values: 0 to 17 -.RS -V4L2_PIX_FMT_SN9C10X : 0 'S910' -V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' -V4L2_PIX_FMT_SBGGR8 : 2 'BA81' -V4L2_PIX_FMT_SPCA561 : 3 'S561' -V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' -V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' -V4L2_PIX_FMT_PAC207 : 6 'P207' -V4L2_PIX_FMT_PJPG : 7 'PJPG' -V4L2_PIX_FMT_MJPEG : 8 'MJPEG' -V4L2_PIX_FMT_JPEG : 9 'JPEG' -V4L2_PIX_FMT_RGB24 : 10 'RGB3' -V4L2_PIX_FMT_SPCA501 : 11 'S501' -V4L2_PIX_FMT_SPCA505 : 12 'S505' -V4L2_PIX_FMT_SPCA508 : 13 'S508' -V4L2_PIX_FMT_UYVY : 14 'UYVY' -V4L2_PIX_FMT_YUYV : 15 'YUYV' -V4L2_PIX_FMT_YUV422P : 16 '422P' -V4L2_PIX_FMT_YUV420 : 17 'YU12' -.RE -Default: 17 -Description: -.fi -.RS -The v4l2_palette option allows users to choose the prefered palette to be use by motion to capture from the video device. -If the prefered palette is not available from the video device, Motion will attempt to use palettes that are supported. -.RE -.RE - -.TP -.B tunerdevice -.RS -.nf -Values: User Specified String -Default: /dev/tuner0 -Description: -.fi -.RS -Tuner device to be used for capturing images. -This is ONLY used for FreeBSD. -.RE -.RE - -.TP -.B input -.RS -.nf -Values: -.RS +.SH DESCRIPTION +.I Motion +uses a video4linux device or network camera to detect motion. If motion is detected both normal +and motion pictures can be taken. Motion can also take actions to notify you +if needed. Creation of automated snapshots is also possible. +.SH OPTIONS +.TP +.B \-c +Full path and filename of config file. +For example: \fI /home/kurt/motion.conf \fR +The default is \fI /usr/local/etc/motion\fR unless specified differently when building Motion. +Many RPMs and Debian packages will use \fI/etc\fR or \fI/etc/motion\fR as the default. +.TP +.B \-h +Show help screen. +.TP +.B \-b +Run in daemon mode. +.TP +.B \-n +Run in non-daemon mode. +.TP +.B \-s +Run in setup mode. Also forces non-daemon mode +.TP +.B \-d +Run with message log level 1-9. +.TP +.B \-k +Run with message log type 1-9 +.TP +.B \-l +Full path and file name for the log file +.TP +.B \-p +Full path and filename for process id file (pid file). E.g /var/run/motion.pid. Default is not defined. Pid file is only created when Motion is started in daemon mode. +.TP +.B \-m +Start in pause mode +.TP +.SH "CONFIG FILE OPTIONS" +These are the options that can be used in the config file. +.I They are overridden by the commandline! +All number values are integer numbers (no decimals allowed). +Boolean options can be on or off (values "1", "yes" and "on" all means true and any other value means false). + +.TP +.B daemon +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +When specified as ON, Motion goes into daemon (background process) mode and releases the terminal. +.RE +.RE + +.TP +.B process_id_file +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +File to store the process ID, also called pid file. +.RE +.RE + +.TP +.B setup_mode +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Start in Setup-Mode, daemon disabled. +.RE +.RE + +.TP +.B logfile +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +File to save logs messages, if not defined stderr and syslog is used. +.RE +.RE + +.TP +.B log_level +.RS +.nf +Values: 1 to 9 (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL) +Default: 6 / NTC +Description: +.fi +.RS +Specify the level of verbosity in the messages sent to the log. +.RE +.RE + +.TP +.B log_type +.RS +.nf +Values: COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL +Default: ALL +Description: +.fi +.RS +Filter to log messages by type +.RE +.RE + +.TP +.B videodevice +.RS +.nf +Values: User specified string +Default: /dev/video0 +Description: +.fi +.RS +String to specify the videodevice to be used for capturing. +For Linux, the format is usually /dev/videoX where X varies depending upon the video devices connnected to the computer. +For FreeBSD the default device would be /dev/bktr0. +.RE +.RE + +.TP +.B v4l2_palette +.RS +.nf +Values: 0 to 17 +.RS +V4L2_PIX_FMT_SN9C10X : 0 'S910' +V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' +V4L2_PIX_FMT_SBGGR8 : 2 'BA81' +V4L2_PIX_FMT_SPCA561 : 3 'S561' +V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' +V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' +V4L2_PIX_FMT_PAC207 : 6 'P207' +V4L2_PIX_FMT_PJPG : 7 'PJPG' +V4L2_PIX_FMT_MJPEG : 8 'MJPEG' +V4L2_PIX_FMT_JPEG : 9 'JPEG' +V4L2_PIX_FMT_RGB24 : 10 'RGB3' +V4L2_PIX_FMT_SPCA501 : 11 'S501' +V4L2_PIX_FMT_SPCA505 : 12 'S505' +V4L2_PIX_FMT_SPCA508 : 13 'S508' +V4L2_PIX_FMT_UYVY : 14 'UYVY' +V4L2_PIX_FMT_YUYV : 15 'YUYV' +V4L2_PIX_FMT_YUV422P : 16 '422P' +V4L2_PIX_FMT_YUV420 : 17 'YU12' +.RE +Default: 17 +Description: +.fi +.RS +The v4l2_palette option allows users to choose the prefered palette to be use by motion to capture from the video device. +If the prefered palette is not available from the video device, Motion will attempt to use palettes that are supported. +.RE +.RE + +.TP +.B tunerdevice +.RS +.nf +Values: User Specified String +Default: /dev/tuner0 +Description: +.fi +.RS +Tuner device to be used for capturing images. +This is ONLY used for FreeBSD. +.RE +.RE + +.TP +.B input +.RS +.nf +Values: +.RS \-1 : USB Cameras -0 : video/TV cards or uvideo(4) on OpenBSD -1 : video/TV cards -.RE +0 : video/TV cards or uvideo(4) on OpenBSD +1 : video/TV cards +.RE Default: \-1 -Description: -.fi -.RS -The video input to be used. -.RE -.RE - -.TP -.B norm -.RS -.nf -Values: -.RS -0 (PAL) -1 (NTSC) -2 (SECAM) -3 (PAL NC no colour) -.RE -Default: 0 (PAL) -Description: -.fi -.RS -The video norm to use when capturing from TV tuner cards -.RE -.RE - -.TP -.B frequency -.RS -.nf -Values: Dependent upon video device -Default: 0 -Description: -.fi -.RS -The frequency to set the tuner in kHz when using a TV tuner card. -.RE -.RE - -.TP -.B power_line_frequency -.RS -.nf -Values: -.RS --1 : Do not modify device setting -0 : Power line frequency Disabled -1 : 50hz -2 : 60hz -3 : Auto -.RE -Default: -1 -Description: -.fi -.RS -Override the power line frequency for the video device. -.RE -.RE - -.TP -.B rotate -.RS -.nf -Values: 0, 90, 180, 270 -Default: 0 -Description: -.fi -.RS -Rotate image this number of degrees. -The rotation affects all saved images as well as movies. -.RE -.RE - -.TP -.B width -.RS -.nf -Values: Dependent upon video device -Default: 352 -Description: -.fi -.RS -Image width in pixels for the video device. -.RE -.RE - -.TP -.B height -.RS -.nf -Values: Dependent upon video device -Default: off -Description: -.fi -.RS -Image height in pixels for the video device -.RE -.RE - -.TP -.B framerate -.RS -.nf -Values: 2 - 100 -Default: 100 -Description: -.fi -.RS -The maximum number of frames to capture in 1 second. -The default of 100 will normally be limited by the capabilities of the video device. -Typical video devices have a maximum rate of 30. -.RE -.RE - -.TP -.B minimum_frame_time -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -The minimum time in seconds between capturing picture frames from the camera. -The default of 0 disables this option and relies upon the capture rate of the camera. -This option is used when you want to capture images at a rate lower than 2 per second. -.RE -.RE - -.TP -.B netcam_url -.RS -.nf -Values: User specified string -Default: None -Description: -.fi -.RS -Full connection URL string to use to connect to a network camera. -The URL must provide a stream of images instead of only a static image. -The following prefixes are recognized - -.RS -http:// -ftp:// -mjpg:// -rtsp:// -mjpeg:// -file:// -.RE - -The connection string is camera specific. -It is usually the same as what other video playing applications would use to connect to the camera stream. -Motion currently only supports basic authentication for the cameras. -Digest is not currently supported. -Basic authentication can be specified in the URL or via the netcam_userpass option. -.RE -.RE - -.TP -.B netcam_userpass -.RS -.nf -Values: User specified string -Default: Not Defined -Description: -.fi -.RS -The user id and password required to access the network camera string. -only basic authentication is supported at this time. -Format is in user:password format when both a user name and password is required. -.RE -.RE - -.TP -.B netcam_keepalive -.RS -.nf -Values: -.RS -.fi -off: The historical implementation using HTTP/1.0, closing the socket after each http request. -.nf - -.fi -force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. -.nf - -.fi -on: Use HTTP/1.1 requests that support keep alive as default. -.nf -.RE -Default: off -Description: -.fi -.RS -This setting is to keep-alive (open) the network socket between requests. -When used, this option should improve performance on compatible net cameras. -This option is not applicable for the rtsp:// and mjpeg:// formats. -.RE -.RE - -.TP -.B netcam_proxy -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -If required, the URL to use for a netcam proxy server. -For example, "http://myproxy". -If a port number other than 80 is needed, append to the specification. -For examplet, "http://myproxy:1234". -.RE -.RE - -.TP -.B netcam_tolerant_check -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Use a less strict jpeg validation for network cameras. -This can assist with cameras that have poor or buggy firmware. -.RE -.RE - -.TP -.B rtsp_uses_tcp -.RS -.nf -Values: on/off -Default: on -Description: -.fi -.RS -When using a RTSP connection for a network camera, use a TCP transport instead of UDP. -The UDP transport frequently results in "smeared" corrupt images. -.RE -.RE - -.TP -.B auto_brightness -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -The auto_brightness feature uses the brightness option as its target value. -If brightness is zero auto_brightness will adjust to average brightness value 128. -only recommended for cameras without auto brightness. -.RE -.RE - -.TP -.B brightness -.RS -.nf -Values: 0 to 255 -Default: 0 (Disabled) -Description: -.fi -.RS -The initial brightness of a video device. -If auto_brightness is enabled, this value defines the average brightness level which Motion will try and adjust to. -.RE -.RE - -.TP -.B contrast -.RS -.nf -Values: 0 to 255 -Default: 0 (Disabled) -Description: -.fi -.RS -The contrast value to set for the video device. -.RE -.RE - -.TP -.B saturation -.RS -.nf -Values: 0 to 255 -Default: 0 (Disabled) -Description: -.fi -.RS -The saturation value to set for the video device. -.RE -.RE - -.TP -.B hue -.RS -.nf -Values: 0 to 255 -Default: 0 (Disabled) -Description: -.fi -.RS -The hue value to set for the video device. -.RE -.RE - -.TP -.B roundrobin_frames -.RS -.nf -Values: 1 to unlimited -Default: 1 -Description: -.fi -.RS -Number of frames to capture in each roundrobin step -.RE -.RE - -.TP -.B roundrobin_skip -.RS -.nf -Values: 1 to unlimited -Default: 1 -Description: -.fi -.RS -Number of frames to skip before each roundrobin step -.RE -.RE - -.TP -.B switchfilter -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Filter out noise generated by roundrobin -.RE -.RE - -.TP -.B threshold -.RS -.nf -Values: 1 to unlimited -Default: 1500 -Description: -.fi -.RS -Threshold for number of changed pixels in an image that triggers motion detection -.RE -.RE - -.TP -.B threshold_tune -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Automatically tune the threshold down if possible. -.RE -.RE - -.TP -.B noise_level -.RS -.nf -Values: 1 to unlimited -Default: 32 -Description: -.fi -.RS -Noise threshold for the motion detection. -.RE -.RE - -.TP -.B noise_tune -.RS -.nf -Values: on/off -Default: on -Description: -.fi -.RS -Automatically tune the noise threshold -.RE -.RE - -.TP -.B despeckle_filter -.RS -.nf -Values: -.RS -e/E : erode -d/D : dilate -l : label -.RE -Default: EedDl -Description: -.fi -.RS -Despeckle motion image using (e)rode or (d)ilate or (l)abel. -The recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. -(l)abeling must only be used once and the 'l' must be the last letter. -Comment out to disable -.RE -.RE - -.TP -.B area_detect -.RS -.nf -Values: 1 to 9 -Default: Not Defined -Description: -.fi -.RS -When motion is detected in the predefined areas indicated below, -trigger the script indicated by the on_area_detected. -The trigger is only activated once during an event. -one or more areas can be specified with this option. -Note that this option is only used to trigger the indicated script. -It does not limit all motion detection events to only the area indicated. +Description: +.fi +.RS +The video input to be used. +.RE +.RE + +.TP +.B norm +.RS +.nf +Values: +.RS +0 (PAL) +1 (NTSC) +2 (SECAM) +3 (PAL NC no colour) +.RE +Default: 0 (PAL) +Description: +.fi +.RS +The video norm to use when capturing from TV tuner cards +.RE +.RE + +.TP +.B frequency +.RS +.nf +Values: Dependent upon video device +Default: 0 +Description: +.fi +.RS +The frequency to set the tuner in kHz when using a TV tuner card. +.RE +.RE + +.TP +.B power_line_frequency +.RS +.nf +Values: +.RS +-1 : Do not modify device setting +0 : Power line frequency Disabled +1 : 50hz +2 : 60hz +3 : Auto +.RE +Default: -1 +Description: +.fi +.RS +Override the power line frequency for the video device. +.RE +.RE + +.TP +.B rotate +.RS +.nf +Values: 0, 90, 180, 270 +Default: 0 +Description: +.fi +.RS +Rotate image this number of degrees. +The rotation affects all saved images as well as movies. +.RE +.RE + +.TP +.B width +.RS +.nf +Values: Dependent upon video device +Default: 352 +Description: +.fi +.RS +Image width in pixels for the video device. +.RE +.RE + +.TP +.B height +.RS +.nf +Values: Dependent upon video device +Default: off +Description: +.fi +.RS +Image height in pixels for the video device +.RE +.RE + +.TP +.B framerate +.RS +.nf +Values: 2 - 100 +Default: 100 +Description: +.fi +.RS +The maximum number of frames to capture in 1 second. +The default of 100 will normally be limited by the capabilities of the video device. +Typical video devices have a maximum rate of 30. +.RE +.RE + +.TP +.B minimum_frame_time +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +The minimum time in seconds between capturing picture frames from the camera. +The default of 0 disables this option and relies upon the capture rate of the camera. +This option is used when you want to capture images at a rate lower than 2 per second. +.RE +.RE + +.TP +.B netcam_url +.RS +.nf +Values: User specified string +Default: None +Description: +.fi +.RS +Full connection URL string to use to connect to a network camera. +The URL must provide a stream of images instead of only a static image. +The following prefixes are recognized + +.RS +http:// +ftp:// +mjpg:// +rtsp:// +mjpeg:// +file:// +.RE + +The connection string is camera specific. +It is usually the same as what other video playing applications would use to connect to the camera stream. +Motion currently only supports basic authentication for the cameras. +Digest is not currently supported. +Basic authentication can be specified in the URL or via the netcam_userpass option. +.RE +.RE + +.TP +.B netcam_userpass +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +The user id and password required to access the network camera string. +only basic authentication is supported at this time. +Format is in user:password format when both a user name and password is required. +.RE +.RE + +.TP +.B netcam_keepalive +.RS +.nf +Values: +.RS +.fi +off: The historical implementation using HTTP/1.0, closing the socket after each http request. +.nf + +.fi +force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. +.nf + +.fi +on: Use HTTP/1.1 requests that support keep alive as default. +.nf +.RE +Default: off +Description: +.fi +.RS +This setting is to keep-alive (open) the network socket between requests. +When used, this option should improve performance on compatible net cameras. +This option is not applicable for the rtsp:// and mjpeg:// formats. +.RE +.RE + +.TP +.B netcam_proxy +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +If required, the URL to use for a netcam proxy server. +For example, "http://myproxy". +If a port number other than 80 is needed, append to the specification. +For examplet, "http://myproxy:1234". +.RE +.RE + +.TP +.B netcam_tolerant_check +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use a less strict jpeg validation for network cameras. +This can assist with cameras that have poor or buggy firmware. +.RE +.RE + +.TP +.B rtsp_uses_tcp +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +When using a RTSP connection for a network camera, use a TCP transport instead of UDP. +The UDP transport frequently results in "smeared" corrupt images. +.RE +.RE + +.TP +.B auto_brightness +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +The auto_brightness feature uses the brightness option as its target value. +If brightness is zero auto_brightness will adjust to average brightness value 128. +only recommended for cameras without auto brightness. +.RE +.RE + +.TP +.B brightness +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The initial brightness of a video device. +If auto_brightness is enabled, this value defines the average brightness level which Motion will try and adjust to. +.RE +.RE + +.TP +.B contrast +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The contrast value to set for the video device. +.RE +.RE + +.TP +.B saturation +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The saturation value to set for the video device. +.RE +.RE + +.TP +.B hue +.RS +.nf +Values: 0 to 255 +Default: 0 (Disabled) +Description: +.fi +.RS +The hue value to set for the video device. +.RE +.RE + +.TP +.B roundrobin_frames +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +Number of frames to capture in each roundrobin step +.RE +.RE + +.TP +.B roundrobin_skip +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +Number of frames to skip before each roundrobin step +.RE +.RE + +.TP +.B switchfilter +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Filter out noise generated by roundrobin +.RE +.RE + +.TP +.B threshold +.RS +.nf +Values: 1 to unlimited +Default: 1500 +Description: +.fi +.RS +Threshold for number of changed pixels in an image that triggers motion detection +.RE +.RE + +.TP +.B threshold_tune +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Automatically tune the threshold down if possible. +.RE +.RE + +.TP +.B noise_level +.RS +.nf +Values: 1 to unlimited +Default: 32 +Description: +.fi +.RS +Noise threshold for the motion detection. +.RE +.RE + +.TP +.B noise_tune +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Automatically tune the noise threshold +.RE +.RE + +.TP +.B despeckle_filter +.RS +.nf +Values: +.RS +e/E : erode +d/D : dilate +l : label +.RE +Default: EedDl +Description: +.fi +.RS +Despeckle motion image using (e)rode or (d)ilate or (l)abel. +The recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. +(l)abeling must only be used once and the 'l' must be the last letter. +Comment out to disable +.RE +.RE + +.TP +.B area_detect +.RS +.nf +Values: 1 to 9 +Default: Not Defined +Description: +.fi +.RS +When motion is detected in the predefined areas indicated below, +trigger the script indicated by the on_area_detected. +The trigger is only activated once during an event. +one or more areas can be specified with this option. +Note that this option is only used to trigger the indicated script. +It does not limit all motion detection events to only the area indicated. .RS Image Areas .RE @@ -653,1382 +653,1382 @@ Image Areas .RE .RS 789 -.RE -.RE -.RE - -.TP -.B mask_file -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -When particular area should be ignored for motion, it can be accomplished using a PGM mask file. -The PGM mask file is a specially constructed mask file that allows the user to indicate the areas -for which motion should be monitored. -This option specifies the full path and name for the mask file. -.RE -.RE - -.TP -.B smart_mask_speed -.RS -.nf -Values: 0 to 10 -Default: 0 (off) -Description: -.fi -.RS -Speed of mask changes when creating a dynamic mask file. -.RE -.RE - -.TP -.B lightswitch -.RS -.nf -Values: 0 to 100 -Default: 0 -Description: -.fi -.RS -Ignore sudden massive light intensity changes. -Value is a percentage of the picture area that changed intensity. -.RE -.RE - -.TP -.B minimum_motion_frames -.RS -.nf -Values: 1 to unlimited -Default: 1 -Description: -.fi -.RS -The minimum number of picture frames in a row that must contain motion before a event is triggered. -The default of 1 means that all motion is detected. -The recommended range is 1 to 5. -.RE -.RE - -.TP -.B pre_capture -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -The number of pre-captured (buffered) pictures from before motion was detected that will be output upon motion detection. -The recommended range is 0 to 5. -It is not recommended to use large values since it will cause Motion to skip frames. -To smooth movies use larger values of post_capture instead. -.RE -.RE - -.TP -.B post_capture -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -Number of frames to capture after motion is no longer detected. -.RE -.RE - -.TP -.B event_gap -.RS -.nf -Values: -1 to unlimited -Default: 60 -Description: -.fi -.RS -The number of seconds of no motion that triggers the end of an event. -An event is defined as a series of motion images taken within a short timeframe. -The recommended value is 60 seconds. The value -1 is allowed and disables -events causing all Motion to be written to one single movie file and no pre_capture. -If set to 0, motion is running in gapless mode. -Movies don't have gaps anymore. -An event ends right after no more motion is detected and post_capture is over. -.RE -.RE - -.TP -.B max_movie_time -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -Maximum length in seconds of a movie. -When value is exceeded a new movie file is created. -The value of 0 means that there is no limit. -.RE -.RE - -.TP -.B emulate_motion -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Always save images even if there was no motion. -.RE -.RE - -.TP -.B output_pictures -.RS -.nf -Values: on, off, first, best, center -Default: on -Description: -.fi -.RS -Output pictures when motion is detected. -When set to 'first', only the first picture of an event is saved. -Picture with most motion of an event is saved when set to 'best'. -Picture with motion nearest center of picture is saved when set to 'center'. -Can be used as preview shot for the corresponding movie. -.RE -.RE - -.TP -.B output_debug_pictures -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Output pictures with only the pixels moving object (ghost images) -.RE -.RE - -.TP -.B quality -.RS -.nf -Values: 1 to 100 -Default: 75 -Description: -.fi -.RS -The quality (in percent) to be used by the jpeg compression -.RE -.RE - -.TP -.B picture_type -.RS -.nf -Values: jpeg/ppm -Default: jpeg -Description: -.fi -.RS -The file type of output images -.RE -.RE - -.TP -.B ffmpeg_output_movies -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Use ffmpeg to encode movies of the motion. -.RE -.RE - -.TP -.B ffmpeg_output_debug_movies -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Use ffmpeg to encode movies with only the pixels moving object (ghost images) -.RE -.RE - -.TP -.B ffmpeg_timelapse -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -Number of seconds between frame captures for a timelapse movie. -Specify 0 to disable the timelapse. -.RE -.RE - -.TP -.B ffmpeg_timelapse_mode -.RS -.nf -Values: -.RS -hourly -.br -daily -.br -weekly-sunday -.br -weekly-monday -.br -monthly -.br -manual -.RE -Default: daily -Description: -.fi -.RS -File rollover mode for the timelapse video. -.RE -.RE - -.TP -.B ffmpeg_bps -.RS -.nf -Values: 0 to unlimited -Default: 400000 -Description: -.fi -.RS -Bitrate to be used by the ffmpeg encoder. -This option is ignored if ffmpeg_variable_bitrate is not 0. -.RE -.RE - -.TP -.B ffmpeg_variable_bitrate -.RS -.nf +.RE +.RE +.RE + +.TP +.B mask_file +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +When particular area should be ignored for motion, it can be accomplished using a PGM mask file. +The PGM mask file is a specially constructed mask file that allows the user to indicate the areas +for which motion should be monitored. +This option specifies the full path and name for the mask file. +.RE +.RE + +.TP +.B smart_mask_speed +.RS +.nf +Values: 0 to 10 +Default: 0 (off) +Description: +.fi +.RS +Speed of mask changes when creating a dynamic mask file. +.RE +.RE + +.TP +.B lightswitch +.RS +.nf +Values: 0 to 100 +Default: 0 +Description: +.fi +.RS +Ignore sudden massive light intensity changes. +Value is a percentage of the picture area that changed intensity. +.RE +.RE + +.TP +.B minimum_motion_frames +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +The minimum number of picture frames in a row that must contain motion before a event is triggered. +The default of 1 means that all motion is detected. +The recommended range is 1 to 5. +.RE +.RE + +.TP +.B pre_capture +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +The number of pre-captured (buffered) pictures from before motion was detected that will be output upon motion detection. +The recommended range is 0 to 5. +It is not recommended to use large values since it will cause Motion to skip frames. +To smooth movies use larger values of post_capture instead. +.RE +.RE + +.TP +.B post_capture +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Number of frames to capture after motion is no longer detected. +.RE +.RE + +.TP +.B event_gap +.RS +.nf +Values: -1 to unlimited +Default: 60 +Description: +.fi +.RS +The number of seconds of no motion that triggers the end of an event. +An event is defined as a series of motion images taken within a short timeframe. +The recommended value is 60 seconds. The value -1 is allowed and disables +events causing all Motion to be written to one single movie file and no pre_capture. +If set to 0, motion is running in gapless mode. +Movies don't have gaps anymore. +An event ends right after no more motion is detected and post_capture is over. +.RE +.RE + +.TP +.B max_movie_time +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Maximum length in seconds of a movie. +When value is exceeded a new movie file is created. +The value of 0 means that there is no limit. +.RE +.RE + +.TP +.B emulate_motion +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Always save images even if there was no motion. +.RE +.RE + +.TP +.B output_pictures +.RS +.nf +Values: on, off, first, best, center +Default: on +Description: +.fi +.RS +Output pictures when motion is detected. +When set to 'first', only the first picture of an event is saved. +Picture with most motion of an event is saved when set to 'best'. +Picture with motion nearest center of picture is saved when set to 'center'. +Can be used as preview shot for the corresponding movie. +.RE +.RE + +.TP +.B output_debug_pictures +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Output pictures with only the pixels moving object (ghost images) +.RE +.RE + +.TP +.B quality +.RS +.nf +Values: 1 to 100 +Default: 75 +Description: +.fi +.RS +The quality (in percent) to be used by the jpeg compression +.RE +.RE + +.TP +.B picture_type +.RS +.nf +Values: jpeg/ppm +Default: jpeg +Description: +.fi +.RS +The file type of output images +.RE +.RE + +.TP +.B ffmpeg_output_movies +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use ffmpeg to encode movies of the motion. +.RE +.RE + +.TP +.B ffmpeg_output_debug_movies +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use ffmpeg to encode movies with only the pixels moving object (ghost images) +.RE +.RE + +.TP +.B ffmpeg_timelapse +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Number of seconds between frame captures for a timelapse movie. +Specify 0 to disable the timelapse. +.RE +.RE + +.TP +.B ffmpeg_timelapse_mode +.RS +.nf +Values: +.RS +hourly +.br +daily +.br +weekly-sunday +.br +weekly-monday +.br +monthly +.br +manual +.RE +Default: daily +Description: +.fi +.RS +File rollover mode for the timelapse video. +.RE +.RE + +.TP +.B ffmpeg_bps +.RS +.nf +Values: 0 to unlimited +Default: 400000 +Description: +.fi +.RS +Bitrate to be used by the ffmpeg encoder. +This option is ignored if ffmpeg_variable_bitrate is not 0. +.RE +.RE + +.TP +.B ffmpeg_variable_bitrate +.RS +.nf Values: 0 to 100 -Default: 0 -Description: -.fi -.RS -Enable and define the variable bitrate for the ffmpeg encoder. -ffmpeg_bps is ignored if variable bitrate is enabled. -When specified as 0, use the fixed bitrate defined by ffmpeg_bps. +Default: 0 +Description: +.fi +.RS +Enable and define the variable bitrate for the ffmpeg encoder. +ffmpeg_bps is ignored if variable bitrate is enabled. +When specified as 0, use the fixed bitrate defined by ffmpeg_bps. When defined as 1 - 100 varies the quality of the movie. A value of 1 is worst quality versus a value of 100 is best quality. -.RE -.RE - -.TP -.B ffmpeg_video_codec -.RS -.nf -Values: -.RS -Timelapse videos: -.RS -mpg - Creates mpg file with mpeg-2 encoding. -mpeg4 - Creates avi file with the default encoding. -.RE -Motion videos: -.RS -mpeg4 - Creates .avi file -msmpeg4 - Creates .avi file -swf - Flash film with extension .swf -flv - Flash video with extension .flv -ffv1 - FF video codec 1 for Lossless Encoding -mov - QuickTime -ogg - Ogg/Theora -mp4 - MPEG-4 Part 14 H264 encoding -mkv - Matroska H264 encoding -hevc - H.265 / HEVC (High Efficiency Video Coding) -.RE -.RE -Default: mpeg4 -Description: -.fi -.RS -The container and codec to use when creating videos. -When creating timelapse videos, there are only two options and the processing varies due to container/codec limitations. -For mpg timelapse videos, if motion is shutdown and restarted, new pics will be appended -to any previously created file with name indicated for timelapse. -For mpeg4 timelapse videos, if motion is shutdown and restarted, new pics will create a -new file with the name indicated for timelapse. -For regular motion videos, the container/codec must be available in the ffmpeg installed on the computer. -.RE -.RE - -.TP -.B ffmpeg_duplicate_frames -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -When creating videos, should frames be duplicated in order to keep up with the requested frames per second -.RE -.RE - -.TP -.B sdl_threadnr -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -Number of motion thread to show in SDL Window -.RE -.RE - -.TP -.B use_extpipe -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Use the external pipe in order to encode videos. -This is a replacement option for the FFMPEG builtin encoder for ffmpeg_output_movies only. -The options movie_filename and timelapse_filename are also used from the ffmpeg feature -.RE -.RE - -.TP -.B extpipe -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -Command line string to receive and process a pipe of images to encode. -Generally, use '-' for STDIN -.RE -.RE - -.TP -.B snapshot_interval -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -When specified as 0, the snapshot feature is disabled. -When a value is specified, the value indicates the number of seconds between snapshots. -.RE -.RE - -.TP -.B locate_motion_mode -.RS -.nf -Values: on/off/preview -Default: off -Description: -.fi -.RS -When specified as 'on', locate and draw a box around the moving object. -When set 'preview', only draw a box in preview_shot pictures. -.RE -.RE - -.TP -.B locate_motion_style -.RS -.nf -Values: -.RS -.fi -box : Draw traditional box around the part of the image generating the motion -.nf - -.fi -redbox : Draw a red box around the part of the image generating the motion -.nf - -.fi -cross : Draw a cross on the part of the image generating the motion -.nf - -.fi -redcross : Draw a red cross on the part of the image generating the motion -.nf -.RE -Default: box -Description: -.fi -.RS -When locate_motion_mode is enable, this option specifies how the motion will be indicated on the image. -.RE -.RE - -.TP -.B text_right -.RS -.nf -Values: User specified string -Default: %Y-%m-%d\n%T-%q -Description: -.fi -.RS -Text to place in lower right corner of image. Format specifiers follow C function strftime(3) -.RE -.RE - -.TP -.B text_left -.RS -.nf -Values: User specified string -Default: CAMERA %t -Description: -.fi -.RS -Text to place in lower left corner of image. Format specifiers follow C function strftime(3) -.RE -.RE - -.TP -.B text_changes -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -When specified, draw the number of changed pixed on the images. -This option will normally be set to off except when you setup and adjust the motion settings. -The text is placed in upper right corner of the image. -.RE -.RE - -.TP -.B text_event -.RS -.nf -Values: User specified string -Default: %Y%m%d%H%M%S -Description: -.fi -.RS -Define the value of the special event conversion specifier %C. -The user can use any conversion specifier in this option except %C. -Date and time values are from the timestamp of the first image in the current event. -The %C can be used filenames and text_left/right for creating -a unique identifier for each event. -.RE -.RE - -.TP -.B text_double -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Draw characters at twice normal size on images. -.RE -.RE - -.TP -.B exif_text -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -Text to include in a JPEG EXIF comment -.RE -.RE - -.TP -.B target_dir -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -Target base directory for pictures and films. -It is recommended to use an absolute path. -If this option is not defined, the current working directory is used. -This option accepts the conversion specifiers included at the end of this manual. -.RE -.RE - -.TP -.B snapshot_filename -.RS -.nf -Values: User specified string -Default: %v-%Y%m%d%H%M%S-snapshot -Description: -.fi -.RS -The file path for snapshots relative to target_dir. -The file extension .jpg or .ppm is automatically added so do not include this. -A symbolic link called lastsnap.jpg created in the target_dir will always -point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' -This option accepts the conversion specifiers included at the end of this manual. -.RE -.RE - -.TP -.B picture_filename -.RS -.nf -Values: User specified string -Default: %v-%Y%m%d%H%M%S-%q -Description: -.fi -.RS -The file path for motion triggered images (jpeg or ppm) relative to target_dir. -The file extension of .jpg or .ppm is automatically added so do not include this. -Set to 'preview' together with best-preview feature enables special naming -convention for preview shots. -This option accepts the conversion specifiers included at the end of this manual. -.RE -.RE - -.TP -.B movie_filename -.RS -.nf -Values: User specified string -Default: %v-%Y%m%d%H%M%S -Description: -.fi -.RS -File path for motion triggered ffmpeg films (movies) relative to target_dir. -The extensions(.swf, .avi, etc) are automatically added so do not include them -This option accepts the conversion specifiers included at the end of this manual. -.RE -.RE - -.TP -.B timelapse_filename -.RS -.nf -Values: User specified string -Default: %Y%m%d-timelapse -Description: -.fi -.RS -File path for timelapse movies relative to target_dir. -The file extensions(.mpg .avi) are automatically added so do not include them -This option accepts the conversion specifiers included at the end of this manual. -.RE -.RE - -.TP -.B ipv6_enabled -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Enable or disable IPV6 for http control and stream -.RE -.RE - -.TP -.B stream_port -.RS -.nf -Values: 0 to port number limit -Default: 0 -Description: -.fi -.RS -This option is the port number that the mini-http server listens on for streams of the pictures. -.RE -.RE - -.TP -.B stream_quality -.RS -.nf -Values: 1 to 100 -Default: 50 -Description: -.fi -.RS -The quality in percent for the jpg images streamed. -.RE -.RE - -.TP -.B stream_motion -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Output frames at 1 fps when no motion is detected and increase to the rate given by stream_maxrate when motion is detected -.RE -.RE - -.TP -.B stream_maxrate -.RS -.nf -Values: 1 to unlimited -Default: 1 -Description: -.fi -.RS -Maximum frame rate to send to stream -.RE -.RE - -.TP -.B stream_localhost -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Restrict stream connections to localhost only -.RE -.RE - -.TP -.B stream_limit -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -Limits the number of images per connection. -The default value of 0 means unlimited. -The number can be defined by multiplying actual stream rate by the desired number of seconds. -The actual stream rate is the smallest of the framerate and stream_maxrate. -.RE -.RE - -.TP -.B stream_auth_method -.RS -.nf -Values: -.RS -0 = disabled -1 = Basic authentication -2 = MD5 digest (the safer authentication) -.RE -Default: 0 -Description: -.fi -.RS -The authentication method to use for viewing the stream. -.RE -.RE - -.TP -.B stream_authentication -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -The username and password to use for authentication of the stream. -The format is Username:Password -.RE -.RE - -.TP -.B stream_preview_scale -.RS -.nf -Values: 1 to 100 -Default: 25 -Description: -.fi -.RS -This defines what percentage the stream image should be scaled to for the preview page -.RE -.RE - -.TP -.B stream_preview_newline -.RS -.nf -Values: yes/no -Default: no -Description: -.fi -.RS -When the image is put on the preview page, should the image start on a new line. -This option allows the user to specify whether the preview images should be side by side -or stacked on the page. -.RE -.RE - -.TP -.B webcontrol_port -.RS -.nf -Values: 0 to maximum port number -Default: 0 -Description: -.fi -.RS -Port number for the web control / preview page. -.RE -.RE - -.TP -.B webcontrol_localhost -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Restrict control connections to localhost only -.RE -.RE - -.TP -.B webcontrol_html_output -.RS -.nf -Values: on/off -Default: on -Description: -.fi -.RS -Specified whether the web control/preview page should be raw or html format. Preview page is always html. -.RE -.RE - -.TP -.B webcontrol_authentication -.RS -.nf -Values: -.RS -0 = disabled -1 = Basic authentication -2 = MD5 digest (the safer authentication) -.RE -Default: 0 -Description: -.fi -.RS -The authentication method to use for viewing the web control. -.RE -.RE - -.TP -.B track_type -.RS -.nf -Values: -.RS -0 = none -1 = stepper -2 = iomojo -3 = pwc -4 = generic -5 = uvcvideo -6 = servo -.RE -Default: 0 -Description: -.fi -.RS -This option specifies the type of tracker. -The generic type enables the definition of motion center and motion size to -be used with the conversion specifiers for options like on_motion_detected -.RE -.RE - -.TP -.B track_auto -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Enables/disables the automatic tracking. -.RE -.RE - -.TP -.B track_port -.RS -.nf -Values: User specified string -Default: Not defined -Description: -.fi -.RS -The serial port of the motor. For example /dev/ttyS0 -.RE -.RE - -.TP -.B Tracking options -.RS -.nf -track_motorx, track_motorx_reverse, track_motory, track_motory_reverse -track_maxx, track_minx, track_maxy, track_miny, track_homex, track_homey -track_iomojo_id, track_step_angle_x, track_step_angle_y, track_move_wait -track_speed, track_stepsize - -.fi -.RE -.RS -.nf -Values: device dependent -Default: 0 -Description: -.fi -.RS -These options specify the parameters for cameras with tracking capabilities. -.RE -.RE - -.TP -.B quiet -.RS -.nf -Values: on/off -Default: on -Description: -.fi -.RS -Do not sound beeps when detecting motion -.RE -.RE - -.TP -.B Script Options -.RS -.nf -on_event_start, on_event_end, on_picture_save -on_motion_detected, on_area_detected, on_movie_start -on_movie_end, on_camera_lost - -.fi -.RE -.RS -.nf -Values: User defined string -Default: Not defined -Description: -.fi -.RS -Specify the full path and file name for the script to execute when the indicated event occurs. -When a file name is required for the script, append a %f to the script string. -.RE -.RE - -.TP -.B sql_log_picture -.RS -.nf -Values: on/off -Default: on -Description: -.fi -.RS -Log to the database when creating motion triggered picture file -.RE -.RE - -.TP -.B sql_log_snapshot -.RS -.nf -Values: on/off -Default: on -Description: -.fi -.RS -Log to the database when creating a snapshot image file -.RE -.RE - -.TP -.B sql_log_movie -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Log to the database when creating motion triggered movie file -.RE -.RE - -.TP -.B sql_log_timelapse -.RS -.nf -Values: on/off -Default: off -Description: -.fi -.RS -Log to the database when creating timelapse movies file -.RE -.RE - -.TP -.B sql_query -.RS -.nf -Values: User defined string -Default: Not defined -Description: -.fi -.RS -SQL statement to execute when a event occurs. -Use same conversion specifiers as for text features -Additional special conversion specifiers are -.RS -%n = the number representing the file_type -%f = filename with full path -.RE -Sample table set up (not sql_query): -.RS -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)); -.RE -.RS -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); -.RE -Sample sql_query -.RS -insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') -.RE -.RE -.RE - -.TP -.B database_type -.RS -.nf -Values: mysql, postgresql, sqlite3 -Default: Not defined -Description: -.fi -.RS -The type of database being used. -.RE -.RE - -.TP -.B database_dbname -.RS -.nf -Values: User defined string -Default: Not defined -Description: -.fi -.RS -The name of the database being used (dbname). For Sqlite3, the full path to the database. -.RE -.RE - -.TP -.B database_host -.RS -.nf -Values: User defined string -Default: Not Defined -Description: -.fi -.RS -The name of the host on which the database is running. -.RE -.RE - -.TP -.B database_user -.RS -.nf -Values: User defined string -Default: Not Defined -Description: -.fi -.RS -The username to access the database -.RE -.RE - -.TP -.B database_password -.RS -.nf -Values: User defined string -Default: Not Defined -Description: -.fi -.RS -The database password for the user to access the database. -.RE -.RE - -.TP -.B database_port -.RS -.nf -Values: 0 to maximum port number -Default: Not defined -Description: -.fi -.RS -The port to use in order to access the database. -Default ports: mysql 3306 , postgresql 5432 -.RE -.RE - -.TP -.B database_busy_timeout -.RS -.nf -Values: 0 to unlimited -Default: 0 -Description: -.fi -.RS -Database wait time in milliseconds for locked database to be unlocked before returning database locked error -.RE -.RE - -.TP -.B video_pipe -.RS -.nf -Values: User specified string -Default: Not Defined -Description: -.fi -.RS -Output images to a video4linux loopback device. The value '-' means next available -.RE -.RE - -.TP -.B motion_video_pipe -.RS -.nf -Values: User specified string -Default: Not Defined -Description: -.fi -.RS -Output motion images to a video4linux loopback device. The value '-' means next available -.RE -.RE - -.TP -.B thread -.RS -.nf -Values: User specified string -Default: Not Defined -Description: -.fi -.RS -This option specifies the full path and file name to individual thread files. -This option can be listed multiple times. -Each thread file should contain the options that are unique to that camera/video device. -Common options are obtained from the motion.conf file and values are overwritten from each -thread file. While the motion.conf includes four sample thread options, the actual -limit of threads is only dependent upon the machine capabilities. -Remember: If you have more than one camera you must have one -thread file for each camera. For example, 2 cameras would require 3 files: -The motion.conf file AND thread1.conf and thread2.conf. -only put the options that are unique to each camera in the -thread config files. -.RE -.RE - - - - - - -.SH SIGNALS -Motion responds to the following signals: -.TP -.B SIGHUP -The config file will be reread. -.TP -.B SIGTERM -If needed motion will create an mpeg file of the last event and exit -.TP -.B SIGUSR1 -Motion will create an mpeg file of the current event. -.SH NOTES -.TP -.B Snapshot -A snapshot is a picture taken at regular intervals independently of any movement in the picture. -.TP -.B Motion image -A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. -.TP -.B Normal image -A "normal" image is the real image taken by the camera with text overlayed. -.TP -.B Threads and config files -If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. -.br -If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: -.br -1. Current directory from where motion was invoked -.br -2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf -.br -3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) -.br -If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. -.br -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. -.br -The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. -.br -If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. -.br -So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. -.br -An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). -.br -An option that is unique to a camera must be defined in each thread file. -.br -The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. -.br -Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. -.br -Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins. -.br -1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. -.br -2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. -.br -3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. -.br -4. Motion reads the command line option again overruling any previously defined options. -.br -So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. -.br -If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. -.br -If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. -.TP -.B Conversion Specifiers for Advanced Filename and Text Features -The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. -.br -In text_left and text_right you can additionally use '\n' for new line. - -.TP -.B %a -The abbreviated weekday name according to the current locale. -.TP -.B %A -The full weekday name according to the current locale. -.TP -.B %b -The abbreviated month name according to the current locale. -.TP -.B %B -The full month name according to the current locale. -.TP -.B %c -The preferred date and time representation for the current locale. -.TP -.B %C -Text defined by the text_event feature -.TP -.B %d -The day of the month as a decimal number (range 01 to 31). -.TP -.B %D -Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. -.TP -.B %E -Modifier: use alternative format, see below. -.TP -.B %f -File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. -.TP -.B %F -Equivalent to %Y-%m-%d (the ISO 8601 date format). -.TP -.B %H -The hour as a decimal number using a 24-hour clock (range 00 to 23). -.TP -.B %i -Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). -.TP -.B %I -The hour as a decimal number using a 12-hour clock (range 01 to 12). -.TP -.B %j -The day of the year as a decimal number (range 001 to 366). -.TP -.B %J -Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). -.TP -.B %k -The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) -.TP -.B %K -X coordinate in pixels of the center point of motion. Origin is upper left corner. -.TP -.B %l -The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) -.TP -.B %L -Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). -.TP -.B %m -The month as a decimal number (range 01 to 12). -.TP -.B %M -The minute as a decimal number (range 00 to 59). -.TP -.B %n -Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. -.TP -.B %N -Noise level. -.TP -.B %o -Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. -.TP -.B %p -Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. -.TP -.B %P -Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. -.TP -.B %q -Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. -.TP -.B %Q -Number of detected labels found by the despeckle feature -.TP -.B %r -The time in a.m. or p.m. notation. -.TP -.B %R -The time in 24-hour notation (%H:%M). -.TP -.B %s -The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. -.TP -.B %S -The second as a decimal number (range 00 to 61). -.TP -.B %t -Thread number (camera number) -.TP -.B %T -The time in 24-hour notation (%H:%M:%S). -.TP -.B %u -The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. -.TP -.B %U -The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. -.TP -.B %v -Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. -.TP -.B %V -The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. -.TP -.B %w -The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. -.TP -.B %W -The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. -.TP -.B %x -The preferred date representation for the current locale without the time. -.TP -.B %X -The preferred time representation for the current locale without the date. -.TP -.B %y -The year as a decimal number without a century (range 00 to 99). -.TP -.B %Y -The year as a decimal number including the century. -.TP -.B %z -The time-zone as hour offset from GMT. -.TP -.B %Z -The time zone or name or abbreviation. - -.TP -.B More information -Motion homepage: https://motion-project.github.io/ - -Motion Guide (user and installation guide): -.br /usr/share/doc/motion/motion_guide.html -.SH AUTHORS -Jeroen Vreeken (pe1rxq@amsat.org), -Folkert van Heusden, -Kenneth Lavrsen (kenneth@lavrsen.dk), -Juan Angulo Moreno , +.RE +.RE + +.TP +.B ffmpeg_video_codec +.RS +.nf +Values: +.RS +Timelapse videos: +.RS +mpg - Creates mpg file with mpeg-2 encoding. +mpeg4 - Creates avi file with the default encoding. +.RE +Motion videos: +.RS +mpeg4 - Creates .avi file +msmpeg4 - Creates .avi file +swf - Flash film with extension .swf +flv - Flash video with extension .flv +ffv1 - FF video codec 1 for Lossless Encoding +mov - QuickTime +ogg - Ogg/Theora +mp4 - MPEG-4 Part 14 H264 encoding +mkv - Matroska H264 encoding +hevc - H.265 / HEVC (High Efficiency Video Coding) +.RE +.RE +Default: mpeg4 +Description: +.fi +.RS +The container and codec to use when creating videos. +When creating timelapse videos, there are only two options and the processing varies due to container/codec limitations. +For mpg timelapse videos, if motion is shutdown and restarted, new pics will be appended +to any previously created file with name indicated for timelapse. +For mpeg4 timelapse videos, if motion is shutdown and restarted, new pics will create a +new file with the name indicated for timelapse. +For regular motion videos, the container/codec must be available in the ffmpeg installed on the computer. +.RE +.RE + +.TP +.B ffmpeg_duplicate_frames +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +When creating videos, should frames be duplicated in order to keep up with the requested frames per second +.RE +.RE + +.TP +.B sdl_threadnr +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Number of motion thread to show in SDL Window +.RE +.RE + +.TP +.B use_extpipe +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Use the external pipe in order to encode videos. +This is a replacement option for the FFMPEG builtin encoder for ffmpeg_output_movies only. +The options movie_filename and timelapse_filename are also used from the ffmpeg feature +.RE +.RE + +.TP +.B extpipe +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +Command line string to receive and process a pipe of images to encode. +Generally, use '-' for STDIN +.RE +.RE + +.TP +.B snapshot_interval +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +When specified as 0, the snapshot feature is disabled. +When a value is specified, the value indicates the number of seconds between snapshots. +.RE +.RE + +.TP +.B locate_motion_mode +.RS +.nf +Values: on/off/preview +Default: off +Description: +.fi +.RS +When specified as 'on', locate and draw a box around the moving object. +When set 'preview', only draw a box in preview_shot pictures. +.RE +.RE + +.TP +.B locate_motion_style +.RS +.nf +Values: +.RS +.fi +box : Draw traditional box around the part of the image generating the motion +.nf + +.fi +redbox : Draw a red box around the part of the image generating the motion +.nf + +.fi +cross : Draw a cross on the part of the image generating the motion +.nf + +.fi +redcross : Draw a red cross on the part of the image generating the motion +.nf +.RE +Default: box +Description: +.fi +.RS +When locate_motion_mode is enable, this option specifies how the motion will be indicated on the image. +.RE +.RE + +.TP +.B text_right +.RS +.nf +Values: User specified string +Default: %Y-%m-%d\n%T-%q +Description: +.fi +.RS +Text to place in lower right corner of image. Format specifiers follow C function strftime(3) +.RE +.RE + +.TP +.B text_left +.RS +.nf +Values: User specified string +Default: CAMERA %t +Description: +.fi +.RS +Text to place in lower left corner of image. Format specifiers follow C function strftime(3) +.RE +.RE + +.TP +.B text_changes +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +When specified, draw the number of changed pixed on the images. +This option will normally be set to off except when you setup and adjust the motion settings. +The text is placed in upper right corner of the image. +.RE +.RE + +.TP +.B text_event +.RS +.nf +Values: User specified string +Default: %Y%m%d%H%M%S +Description: +.fi +.RS +Define the value of the special event conversion specifier %C. +The user can use any conversion specifier in this option except %C. +Date and time values are from the timestamp of the first image in the current event. +The %C can be used filenames and text_left/right for creating +a unique identifier for each event. +.RE +.RE + +.TP +.B text_double +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Draw characters at twice normal size on images. +.RE +.RE + +.TP +.B exif_text +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +Text to include in a JPEG EXIF comment +.RE +.RE + +.TP +.B target_dir +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +Target base directory for pictures and films. +It is recommended to use an absolute path. +If this option is not defined, the current working directory is used. +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B snapshot_filename +.RS +.nf +Values: User specified string +Default: %v-%Y%m%d%H%M%S-snapshot +Description: +.fi +.RS +The file path for snapshots relative to target_dir. +The file extension .jpg or .ppm is automatically added so do not include this. +A symbolic link called lastsnap.jpg created in the target_dir will always +point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B picture_filename +.RS +.nf +Values: User specified string +Default: %v-%Y%m%d%H%M%S-%q +Description: +.fi +.RS +The file path for motion triggered images (jpeg or ppm) relative to target_dir. +The file extension of .jpg or .ppm is automatically added so do not include this. +Set to 'preview' together with best-preview feature enables special naming +convention for preview shots. +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B movie_filename +.RS +.nf +Values: User specified string +Default: %v-%Y%m%d%H%M%S +Description: +.fi +.RS +File path for motion triggered ffmpeg films (movies) relative to target_dir. +The extensions(.swf, .avi, etc) are automatically added so do not include them +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B timelapse_filename +.RS +.nf +Values: User specified string +Default: %Y%m%d-timelapse +Description: +.fi +.RS +File path for timelapse movies relative to target_dir. +The file extensions(.mpg .avi) are automatically added so do not include them +This option accepts the conversion specifiers included at the end of this manual. +.RE +.RE + +.TP +.B ipv6_enabled +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Enable or disable IPV6 for http control and stream +.RE +.RE + +.TP +.B stream_port +.RS +.nf +Values: 0 to port number limit +Default: 0 +Description: +.fi +.RS +This option is the port number that the mini-http server listens on for streams of the pictures. +.RE +.RE + +.TP +.B stream_quality +.RS +.nf +Values: 1 to 100 +Default: 50 +Description: +.fi +.RS +The quality in percent for the jpg images streamed. +.RE +.RE + +.TP +.B stream_motion +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Output frames at 1 fps when no motion is detected and increase to the rate given by stream_maxrate when motion is detected +.RE +.RE + +.TP +.B stream_maxrate +.RS +.nf +Values: 1 to unlimited +Default: 1 +Description: +.fi +.RS +Maximum frame rate to send to stream +.RE +.RE + +.TP +.B stream_localhost +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Restrict stream connections to localhost only +.RE +.RE + +.TP +.B stream_limit +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Limits the number of images per connection. +The default value of 0 means unlimited. +The number can be defined by multiplying actual stream rate by the desired number of seconds. +The actual stream rate is the smallest of the framerate and stream_maxrate. +.RE +.RE + +.TP +.B stream_auth_method +.RS +.nf +Values: +.RS +0 = disabled +1 = Basic authentication +2 = MD5 digest (the safer authentication) +.RE +Default: 0 +Description: +.fi +.RS +The authentication method to use for viewing the stream. +.RE +.RE + +.TP +.B stream_authentication +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +The username and password to use for authentication of the stream. +The format is Username:Password +.RE +.RE + +.TP +.B stream_preview_scale +.RS +.nf +Values: 1 to 100 +Default: 25 +Description: +.fi +.RS +This defines what percentage the stream image should be scaled to for the preview page +.RE +.RE + +.TP +.B stream_preview_newline +.RS +.nf +Values: yes/no +Default: no +Description: +.fi +.RS +When the image is put on the preview page, should the image start on a new line. +This option allows the user to specify whether the preview images should be side by side +or stacked on the page. +.RE +.RE + +.TP +.B webcontrol_port +.RS +.nf +Values: 0 to maximum port number +Default: 0 +Description: +.fi +.RS +Port number for the web control / preview page. +.RE +.RE + +.TP +.B webcontrol_localhost +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Restrict control connections to localhost only +.RE +.RE + +.TP +.B webcontrol_html_output +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Specified whether the web control/preview page should be raw or html format. Preview page is always html. +.RE +.RE + +.TP +.B webcontrol_authentication +.RS +.nf +Values: +.RS +0 = disabled +1 = Basic authentication +2 = MD5 digest (the safer authentication) +.RE +Default: 0 +Description: +.fi +.RS +The authentication method to use for viewing the web control. +.RE +.RE + +.TP +.B track_type +.RS +.nf +Values: +.RS +0 = none +1 = stepper +2 = iomojo +3 = pwc +4 = generic +5 = uvcvideo +6 = servo +.RE +Default: 0 +Description: +.fi +.RS +This option specifies the type of tracker. +The generic type enables the definition of motion center and motion size to +be used with the conversion specifiers for options like on_motion_detected +.RE +.RE + +.TP +.B track_auto +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Enables/disables the automatic tracking. +.RE +.RE + +.TP +.B track_port +.RS +.nf +Values: User specified string +Default: Not defined +Description: +.fi +.RS +The serial port of the motor. For example /dev/ttyS0 +.RE +.RE + +.TP +.B Tracking options +.RS +.nf +track_motorx, track_motorx_reverse, track_motory, track_motory_reverse +track_maxx, track_minx, track_maxy, track_miny, track_homex, track_homey +track_iomojo_id, track_step_angle_x, track_step_angle_y, track_move_wait +track_speed, track_stepsize + +.fi +.RE +.RS +.nf +Values: device dependent +Default: 0 +Description: +.fi +.RS +These options specify the parameters for cameras with tracking capabilities. +.RE +.RE + +.TP +.B quiet +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Do not sound beeps when detecting motion +.RE +.RE + +.TP +.B Script Options +.RS +.nf +on_event_start, on_event_end, on_picture_save +on_motion_detected, on_area_detected, on_movie_start +on_movie_end, on_camera_lost + +.fi +.RE +.RS +.nf +Values: User defined string +Default: Not defined +Description: +.fi +.RS +Specify the full path and file name for the script to execute when the indicated event occurs. +When a file name is required for the script, append a %f to the script string. +.RE +.RE + +.TP +.B sql_log_picture +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Log to the database when creating motion triggered picture file +.RE +.RE + +.TP +.B sql_log_snapshot +.RS +.nf +Values: on/off +Default: on +Description: +.fi +.RS +Log to the database when creating a snapshot image file +.RE +.RE + +.TP +.B sql_log_movie +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Log to the database when creating motion triggered movie file +.RE +.RE + +.TP +.B sql_log_timelapse +.RS +.nf +Values: on/off +Default: off +Description: +.fi +.RS +Log to the database when creating timelapse movies file +.RE +.RE + +.TP +.B sql_query +.RS +.nf +Values: User defined string +Default: Not defined +Description: +.fi +.RS +SQL statement to execute when a event occurs. +Use same conversion specifiers as for text features +Additional special conversion specifiers are +.RS +%n = the number representing the file_type +%f = filename with full path +.RE +Sample table set up (not sql_query): +.RS +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)); +.RE +.RS +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); +.RE +Sample sql_query +.RS +insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') +.RE +.RE +.RE + +.TP +.B database_type +.RS +.nf +Values: mysql, postgresql, sqlite3 +Default: Not defined +Description: +.fi +.RS +The type of database being used. +.RE +.RE + +.TP +.B database_dbname +.RS +.nf +Values: User defined string +Default: Not defined +Description: +.fi +.RS +The name of the database being used (dbname). For Sqlite3, the full path to the database. +.RE +.RE + +.TP +.B database_host +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The name of the host on which the database is running. +.RE +.RE + +.TP +.B database_user +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The username to access the database +.RE +.RE + +.TP +.B database_password +.RS +.nf +Values: User defined string +Default: Not Defined +Description: +.fi +.RS +The database password for the user to access the database. +.RE +.RE + +.TP +.B database_port +.RS +.nf +Values: 0 to maximum port number +Default: Not defined +Description: +.fi +.RS +The port to use in order to access the database. +Default ports: mysql 3306 , postgresql 5432 +.RE +.RE + +.TP +.B database_busy_timeout +.RS +.nf +Values: 0 to unlimited +Default: 0 +Description: +.fi +.RS +Database wait time in milliseconds for locked database to be unlocked before returning database locked error +.RE +.RE + +.TP +.B video_pipe +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +Output images to a video4linux loopback device. The value '-' means next available +.RE +.RE + +.TP +.B motion_video_pipe +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +Output motion images to a video4linux loopback device. The value '-' means next available +.RE +.RE + +.TP +.B thread +.RS +.nf +Values: User specified string +Default: Not Defined +Description: +.fi +.RS +This option specifies the full path and file name to individual thread files. +This option can be listed multiple times. +Each thread file should contain the options that are unique to that camera/video device. +Common options are obtained from the motion.conf file and values are overwritten from each +thread file. While the motion.conf includes four sample thread options, the actual +limit of threads is only dependent upon the machine capabilities. +Remember: If you have more than one camera you must have one +thread file for each camera. For example, 2 cameras would require 3 files: +The motion.conf file AND thread1.conf and thread2.conf. +only put the options that are unique to each camera in the +thread config files. +.RE +.RE + + + + + + +.SH SIGNALS +Motion responds to the following signals: +.TP +.B SIGHUP +The config file will be reread. +.TP +.B SIGTERM +If needed motion will create an mpeg file of the last event and exit +.TP +.B SIGUSR1 +Motion will create an mpeg file of the current event. +.SH NOTES +.TP +.B Snapshot +A snapshot is a picture taken at regular intervals independently of any movement in the picture. +.TP +.B Motion image +A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in read. +.TP +.B Normal image +A "normal" image is the real image taken by the camera with text overlayed. +.TP +.B Threads and config files +If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. +.br +If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: +.br +1. Current directory from where motion was invoked +.br +2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf +.br +3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) +.br +If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. +.br +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. +.br +The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. +.br +If you have more than one camera you should not try and invoke Motion more times. Motion is made to work with more than one camera in a very elegant way and the way to do it is to create a number of thread config files. Motion will then create an extra tread of itself for each camera. If you only have one camera you only need the motion.conf file. The minute you have two or more cameras you must have one thread config file per camera besides the motion.conf file. +.br +So if you have for example two cameras you need motion.conf and two thread config files. Total of 3 config files. +.br +An option that is common to all cameras can be placed in motion.conf. (You can also put all parameters in the thread files but that makes a lot of editing when you change a common thing). +.br +An option that is unique to a camera must be defined in each thread file. +.br +The first camera is defined in the first thread file called from motion.conf. The 2nd camera is defined in the 2nd thread file called from motion.conf etc. +.br +Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file. +.br +Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins. +.br +1. Motion reads the configuration file motion.conf from the beginning of the file going down line by line. +.br +2. If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read. +.br +3. Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file. +.br +4. Motion reads the command line option again overruling any previously defined options. +.br +So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf. +.br +If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out. +.br +If you run the http control command http://host:port/0/config/writeyes, motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. +.TP +.B Conversion Specifiers for Advanced Filename and Text Features +The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. +.br +In text_left and text_right you can additionally use '\n' for new line. + +.TP +.B %a +The abbreviated weekday name according to the current locale. +.TP +.B %A +The full weekday name according to the current locale. +.TP +.B %b +The abbreviated month name according to the current locale. +.TP +.B %B +The full month name according to the current locale. +.TP +.B %c +The preferred date and time representation for the current locale. +.TP +.B %C +Text defined by the text_event feature +.TP +.B %d +The day of the month as a decimal number (range 01 to 31). +.TP +.B %D +Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. +.TP +.B %E +Modifier: use alternative format, see below. +.TP +.B %f +File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. +.TP +.B %F +Equivalent to %Y-%m-%d (the ISO 8601 date format). +.TP +.B %H +The hour as a decimal number using a 24-hour clock (range 00 to 23). +.TP +.B %i +Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). +.TP +.B %I +The hour as a decimal number using a 12-hour clock (range 01 to 12). +.TP +.B %j +The day of the year as a decimal number (range 001 to 366). +.TP +.B %J +Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). +.TP +.B %k +The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) +.TP +.B %K +X coordinate in pixels of the center point of motion. Origin is upper left corner. +.TP +.B %l +The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) +.TP +.B %L +Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). +.TP +.B %m +The month as a decimal number (range 01 to 12). +.TP +.B %M +The minute as a decimal number (range 00 to 59). +.TP +.B %n +Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. +.TP +.B %N +Noise level. +.TP +.B %o +Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. +.TP +.B %p +Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. +.TP +.B %P +Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. +.TP +.B %q +Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. +.TP +.B %Q +Number of detected labels found by the despeckle feature +.TP +.B %r +The time in a.m. or p.m. notation. +.TP +.B %R +The time in 24-hour notation (%H:%M). +.TP +.B %s +The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. +.TP +.B %S +The second as a decimal number (range 00 to 61). +.TP +.B %t +Thread number (camera number) +.TP +.B %T +The time in 24-hour notation (%H:%M:%S). +.TP +.B %u +The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. +.TP +.B %U +The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. +.TP +.B %v +Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. +.TP +.B %V +The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. +.TP +.B %w +The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. +.TP +.B %W +The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. +.TP +.B %x +The preferred date representation for the current locale without the time. +.TP +.B %X +The preferred time representation for the current locale without the date. +.TP +.B %y +The year as a decimal number without a century (range 00 to 99). +.TP +.B %Y +The year as a decimal number including the century. +.TP +.B %z +The time-zone as hour offset from GMT. +.TP +.B %Z +The time zone or name or abbreviation. + +.TP +.B More information +Motion homepage: https://motion-project.github.io/ + +Motion Guide (user and installation guide): +.br /usr/share/doc/motion/motion_guide.html +.SH AUTHORS +Jeroen Vreeken (pe1rxq@amsat.org), +Folkert van Heusden, +Kenneth Lavrsen (kenneth@lavrsen.dk), +Juan Angulo Moreno , and many others From f6ff8573f0204be168c03851b678d1f381389942 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Wed, 28 Sep 2016 15:58:31 +0200 Subject: [PATCH 231/233] Fix paths in documentation Motion already installs motion-dist.conf to @sysconfdir@/motion/, but some documentation was not updated to reflect this yet. --- motion.1 | 6 +++--- motion_guide.html | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/motion.1 b/motion.1 index 02bc238..88e49d5 100644 --- a/motion.1 +++ b/motion.1 @@ -1837,11 +1837,11 @@ If you do not specify -c or the filename you give Motion does not exist, Motion .br 2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf .br -3. The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) +3. The motion/ subdirectory inside the directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) .br -If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory. +If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file in the default /usr/local/etc/motion directory. .br -Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc directory. +Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this files gets copied to the /usr/local/etc/motion directory. .br The configuration file needs to be renamed from motion-dist.conf to motion.conf. The original file is called motion-dist.conf so that your perfectly working motion.conf file does not accidentally get overwritten when you re-install or upgrade to a newer version of Motion. .br diff --git a/motion_guide.html b/motion_guide.html index 3f79558..ecb12ea 100644 --- a/motion_guide.html +++ b/motion_guide.html @@ -459,7 +459,7 @@

                                                      Configure Script

                                                      --prefix=PREFIX install architecture-independent files in PREFIX
                                                      [/usr/local] - The default /usr/local means that

                                                      The executable binary "motion" is installed in /usr/local/bin
                                                      The manual page in /usr/local/man/man1
                                                      The document files in /usr/local/docs/motion-version
                                                      The configuration file in /usr/local/etc
                                                      The example config files in /usr/local/examples/motion-version

                                                      The editor recommends keeping this default setting.
                                                      If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                      This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                      If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                      Example: --prefix=$HOME + The default /usr/local means that

                                                      The executable binary "motion" is installed in /usr/local/bin
                                                      The manual page in /usr/local/man/man1
                                                      The document files in /usr/local/docs/motion-version
                                                      The configuration file in /usr/local/etc/motion
                                                      The example config files in /usr/local/examples/motion-version

                                                      The editor recommends keeping this default setting.
                                                      If you are experimenting with many parallel versions it may be interesting to set the PREFIX to e.g. /usr/local/motion and then add /usr/local/motion/bin to your search path (or simply cd /usr/local/motion/bin before execution).
                                                      This way you can change version just by changing the symbolic link in /usr/local/motion as suggested earlier in this guide.
                                                      If you are installing the software on a machine where you have no access to the /usr/local but have write access to a home directory, then you should change this to point to a directory within your home tree.
                                                      Example: --prefix=$HOME --exec-prefix=EPREFIX @@ -495,7 +495,7 @@

                                                      Configure Script



                                                        1. Current directory from where motion was invoked
                                                        2. $HOME/.motion -
                                                        3. The sysconfig directory set by this switch. If not defined the default is /usr/local/etc/
                                                        +
                                                        3. The motion/ subdirectory inside the sysconfig directory set by this switch. If not defined the default is /usr/local/etc/

                                                      Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion-dist.conf file that you may have edited. @@ -691,7 +691,7 @@

                                                      Make Install

                                                      • /usr/local/bin
                                                      • usr/local/man/man1
                                                      • -
                                                      • /usr/local/etc
                                                      • +
                                                      • /usr/local/etc/motion
                                                      • /usr/local/share/doc/motion-version
                                                      • /usr/local/share/doc/examples/motion-version
                                                      @@ -704,7 +704,7 @@

                                                      Make Install

                                                    • Manual page "motion.1" to /usr/local/man/man1
                                                    • Document files "CHANGELOG, COPYING, CREDITS, INSTALL, and README to /usr/local/share/doc/motion-version
                                                    • Example configuration files "*.conf" to /usr/local/share/doc/examples/motion-version
                                                    • -
                                                    • Configuration file "motion-dist.conf" to /usr/local/etc
                                                    • +
                                                    • Configuration file "motion-dist.conf" to /usr/local/etc/motion
                                                    Note that the any existing files are overwritten. The default config file motion-dist.conf is named like From 8ea65f7a1fbbfcf879f3d74f3c934a20e7db7fce Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Wed, 28 Sep 2016 16:40:10 +0200 Subject: [PATCH 232/233] Fix spelling/grammar mistakes --- conf.c | 2 +- configure.ac | 2 +- event.c | 2 +- motion-dist.conf.in | 2 +- motion.1 | 6 +++--- picture.c | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conf.c b/conf.c index ba275e5..2080525 100644 --- a/conf.c +++ b/conf.c @@ -278,7 +278,7 @@ config_param config_params[] = { }, { "v4l2_palette", - "# v4l2_palette allows to choose preferable palette to be use by motion\n" + "# v4l2_palette allows one to choose preferable palette to be use by motion\n" "# to capture from those supported by your videodevice. (default: 17)\n" "# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and\n" "# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG.\n" diff --git a/configure.ac b/configure.ac index e21fbc3..5782fd6 100644 --- a/configure.ac +++ b/configure.ac @@ -465,7 +465,7 @@ else saved_LIBS=$LIBS # first we check to see if the sqlite3 amalgamation (sqlite3.c), is in with our source - # this is the prefered way to use sqlite + # this is the preferred way to use sqlite if test -f sqlite3.c; then SQLITE3_SUPPORT="yes" VIDEO="$VIDEO sqlite3.o" diff --git a/event.c b/event.c index cadd8c9..8ca59b0 100644 --- a/event.c +++ b/event.c @@ -565,7 +565,7 @@ static void event_extpipe_put(struct context *cnt, /* Check that is open */ if ((cnt->extpipe_open) && (fileno(cnt->extpipe) > 0)) { if (!fwrite(img, cnt->imgs.size, 1, cnt->extpipe)) - MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Error writting in pipe , state error %d", + MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO, "%s: Error writing in pipe , state error %d", ferror(cnt->extpipe)); } else { MOTION_LOG(ERR, TYPE_EVENTS, NO_ERRNO, "%s: pipe %s not created or closed already ", diff --git a/motion-dist.conf.in b/motion-dist.conf.in index 55b7a16..881b41d 100644 --- a/motion-dist.conf.in +++ b/motion-dist.conf.in @@ -38,7 +38,7 @@ log_type all # for FreeBSD default is /dev/bktr0 videodevice /dev/video0 -# v4l2_palette allows to choose preferable palette to be use by motion +# v4l2_palette allows one to choose preferable palette to be use by motion # to capture from those supported by your videodevice. (default: 17) # E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and # V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. diff --git a/motion.1 b/motion.1 index 88e49d5..bc8498e 100644 --- a/motion.1 +++ b/motion.1 @@ -137,7 +137,7 @@ Description: .fi .RS String to specify the videodevice to be used for capturing. -For Linux, the format is usually /dev/videoX where X varies depending upon the video devices connnected to the computer. +For Linux, the format is usually /dev/videoX where X varies depending upon the video devices connected to the computer. For FreeBSD the default device would be /dev/bktr0. .RE .RE @@ -171,8 +171,8 @@ Default: 17 Description: .fi .RS -The v4l2_palette option allows users to choose the prefered palette to be use by motion to capture from the video device. -If the prefered palette is not available from the video device, Motion will attempt to use palettes that are supported. +The v4l2_palette option allows users to choose the preferred palette to be use by motion to capture from the video device. +If the preferred palette is not available from the video device, Motion will attempt to use palettes that are supported. .RE .RE diff --git a/picture.c b/picture.c index 79c5207..a29e8c7 100644 --- a/picture.c +++ b/picture.c @@ -903,7 +903,7 @@ int put_picture_memory(struct context *cnt, unsigned char* dest_image, int image return put_jpeg_grey_memory(dest_image, image_size, image, cnt->imgs.width, cnt->imgs.height, quality); default: - MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknow image type %d", + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknown image type %d", cnt->imgs.type); } @@ -923,7 +923,7 @@ void put_picture_fd(struct context *cnt, FILE *picture, unsigned char *image, in put_jpeg_grey_file(picture, image, cnt->imgs.width, cnt->imgs.height, quality); break; default: - MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknow image type %d", + MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Unknown image type %d", cnt->imgs.type); } } From 08095ad1e90120acbccb15823a35333c60902b95 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Wed, 28 Sep 2016 17:09:03 +0200 Subject: [PATCH 233/233] Fix some under-escaping in motion.1 manpage Certain symbols like - and \ need to be escaped in the man format --- motion.1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/motion.1 b/motion.1 index bc8498e..4a31ffa 100644 --- a/motion.1 +++ b/motion.1 @@ -1829,15 +1829,15 @@ A "motion" image/mpeg shows the pixels that have actually changed during the las A "normal" image is the real image taken by the camera with text overlayed. .TP .B Threads and config files -If Motion was invoked with command line option -c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything. +If Motion was invoked with command line option \-c pathname Motion will expect the config file to be as specified. When you specify the config file on the command line with \-c you can call it anything. .br -If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: +If you do not specify \-c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order: .br 1. Current directory from where motion was invoked .br 2. Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf .br -3. The motion/ subdirectory inside the directory defined by the --sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) +3. The motion/ subdirectory inside the directory defined by the \-\-sysconfdir=DIR when running .configure during installation of Motion (If this option was not defined the default is /usr/local/etc/) .br If you have write access to /usr/local/etc/motion then the editor recommends having only one motion.conf file in the default /usr/local/etc/motion directory. .br @@ -1876,7 +1876,7 @@ If you run the http control command http://host:port/0/config/writeyes, motion w .B Conversion Specifiers for Advanced Filename and Text Features The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename, on_event_start, on_event_end, on_picture_save, on_movie_start, on_movie_end, and on_motion_detected. .br -In text_left and text_right you can additionally use '\n' for new line. +In text_left and text_right you can additionally use '\\n' for new line. .TP .B %a