From 048791e449a49c632021d993260b0d08d5a2a3ee Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 13 Jun 2014 19:52:34 -0600 Subject: [PATCH 01/38] 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 02/38] 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 03/38] 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 04/38] 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 05/38] 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 06/38] 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 07/38] 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 08/38] 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 09/38] 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 10/38] 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 11/38] 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 12/38] 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 13/38] 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 14/38] 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 15/38] 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 16/38] 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 17/38] 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 18/38] 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 19/38] 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 20/38] 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 21/38] 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 22/38] 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 23/38] 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 24/38] 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 25/38] 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 26/38] 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 27/38] 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 28/38] 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 29/38] 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 30/38] 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 31/38] 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 32/38] 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 33/38] 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 34/38] 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 35/38] 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 36/38] 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 37/38] 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 38/38] 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" +