亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? netcam.c

?? video motion detection of linux base
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* *      netcam.c * *      Module for handling network cameras. * *      This code was inspired by the original netcam.c module *      written by Jeroen Vreeken and enhanced by several Motion *      project contributors, particularly Angel Carpintero and *      Christopher Price. * *      Copyright 2005, William M. Brack *      This software is distributed under the GNU Public license *      Version 2.  See also the file 'COPYING'. * * *      When a netcam has been configured, instead of using the routines *      within video.c (which handle a CCTV-type camera) the routines *      within this module are used.  There are only four entry points - *      one for "starting up" the camera (netcam_start), for "fetching a *      picture" from it (netcam_next), one for cleanup at the end of a *      run (netcam_cleanup), and a utility routine for receiving data *      from the camera (netcam_recv). * *      Two quite different types of netcams are handled.  The simplest *      one is the type which supplies a single JPEG frame each time it *      is accessed.  The other type is one which supplies an mjpeg *      stream of data. * *      For each of these cameras, the routine taking care of the netcam *      will start up a completely separate thread (which I call the "camera *      handler thread" within subsequent comments).  For a streaming camera, *      this handler will receive the mjpeg stream of data from the camera, *      and save the latest complete image when it begins to work on the next *      one.  For the non-streaming version, this handler will be "triggered" *      (signalled) whenever the main motion-loop asks for a new image, and *      will start to fetch the next image at that time.  For either type, *      the most recent image received from the camera will be returned to *      motion. */#include "motion.h"#include <netdb.h>#include <netinet/in.h>#include <regex.h>                  /* For parsing of the URL */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/socket.h>#include <sys/types.h>#include "netcam_ftp.h"#define CONNECT_TIMEOUT        10   /* timeout on remote connection attempt */#define READ_TIMEOUT            5   /* default timeout on recv requests */#define MAX_HEADER_RETRIES      5   /* Max tries to find a header record */#define MINVAL(x, y) ((x) < (y) ? (x) : (y))/* * The macro NETCAM_DEBUG is for development testing of this module. * The macro SETUP is to assure that "configuration-setup" type messages * are also printed when NETCAM_DEBUG is set.  Set the following #if to * 1 to enable it, or 0 (normal setting) to disable it. */#define SETUP    ((cnt->conf.setup_mode) || (debug_level >= CAMERA_INFO))/* These strings are used for the HTTP connection */static const char    *connect_req = "GET %s HTTP/1.0\r\n"                      "Host: %s\r\n"                      "User-Agent: Motion-netcam/" VERSION "\r\n"                      "Connection: close\r\n";static const char    *connect_auth_req = "Authorization: Basic %s\r\n";/* * The following three routines (netcam_url_match, netcam_url_parse and * netcam_url_free are for 'parsing' (i.e. separating into the relevant * components) the URL provided by the user.  They make use of regular * expressions (which is outside the scope of this module, so detailed * comments are not provided).  netcam_url_parse is called from netcam_start, * and puts the "broken-up" components of the URL into the "url" element of * the netcam_context structure. * * Note that the routines are not "very clever", but they work sufficiently * well for the limited requirements of this module.  The expression: *   (http)://(((.*):(.*))@)?([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*)) * requires *   1) a string which begins with 'http', followed by '://' *   2) optionally a '@' which is preceded by two strings *      (with 0 or more characters each) separated by a ':' *      [this is for an optional username:password] *   3) a string comprising alpha-numerics, '-' and '.' characters *      [this is for the hostname] *   4) optionally a ':' followed by one or more numeric characters *      [this is for an optional port number] *   5) finally, either an end of line or a series of segments, *      each of which begins with a '/', and contains anything *      except a ':' *//** * netcam_url_match * *      Finds the matched part of a regular expression * * Parameters: * *      m          A structure containing the regular expression to be used *      input      The input string * * Returns:        The string which was matched * */static char *netcam_url_match(regmatch_t m, const char *input){	char *match = NULL;	int len;	if (m.rm_so != -1) {		len = m.rm_eo - m.rm_so;		if ((match = (char *) malloc(len + 1)) != NULL) {			strncpy(match, input + m.rm_so, len);			match[len] = '\0';		}	}	return (match);}/** * netcam_url_parse * *      parses a string containing a URL into it's components * * Parameters: *      parse_url          A structure which will receive the results *                         of the parsing *      text_url           The input string containing the URL * * Returns:                Nothing * */static void netcam_url_parse(struct url_t *parse_url, const char *text_url){	char *s;	int i;	const char *re = "(http|ftp)://(((.*):(.*))@)?"	                 "([^/:]|[-.a-z0-9]+)(:([0-9]+))?($|(/[^:]*))";	regex_t pattbuf;	regmatch_t matches[10];	memset(parse_url, 0, sizeof(struct url_t));	/*	 * regcomp compiles regular expressions into a form that is	 * suitable for regexec searches	 * regexec matches the URL string against the regular expression	 * and returns an array of pointers to strings matching each match	 * within (). The results that we need are finally placed in parse_url	 */	if (!regcomp(&pattbuf, re, REG_EXTENDED | REG_ICASE)) {		if (regexec(&pattbuf, text_url, 10, matches, 0) != REG_NOMATCH) {			for (i = 0; i < 10; i++) {				if ((s = netcam_url_match(matches[i], text_url)) != NULL) {					switch (i) {						case 1:							parse_url->service = s;							break;						case 3:							parse_url->userpass = s;							break;						case 6:							parse_url->host = s;							break;						case 8:							parse_url->port = atoi(s);							free(s);							break;						case 9:							parse_url->path = s;							break;						/* other components ignored */						default:							free(s);							break;					}				}			}		}	}	if ((!parse_url->port) && (parse_url->service)){		if (!strcmp(parse_url->service, "http"))			parse_url->port = 80;		else if (!strcmp(parse_url->service, "ftp"))			parse_url->port = 21;	}	regfree(&pattbuf);}/** * netcam_url_free * *      General cleanup of the URL structure, called from netcam_cleanup. * * Parameters: * *      parse_url       Structure containing the parsed data * * Returns:             Nothing * */static void netcam_url_free(struct url_t *parse_url){	if (parse_url->service) {		free(parse_url->service);		parse_url->service = NULL;	}	if (parse_url->userpass) {		free(parse_url->userpass);		parse_url->userpass = NULL;	}	if (parse_url->host) {		free(parse_url->host);		parse_url->host = NULL;	}	if (parse_url->path) {		free(parse_url->path);		parse_url->path = NULL;	}}/** * check_quote * *      Checks a string to see if it's quoted, and if so removes the *      quotes. * * Parameters: * *      str             Pointer to a string * * Returns:             Nothing, but updates the target if necessary * */static void check_quote(char *str){	int len;	char ch;	ch = *str;	if ((ch == '"') || (ch == '\'')) {		len = strlen(str) - 1;		if (str[len] == ch) {			memmove(str, str+1, len-1);			str[len-1] = 0;		}	}}/** * netcam_check_content_length * * 	Analyse an HTTP-header line to see if it is a Content-length * * Parameters: * *      header          Pointer to a string containing the header line * * Returns: *      -1              Not a Content-length line *      >=0             Value of Content-length field * */static long netcam_check_content_length(char *header){	long length=-1;	/* note this is a long, not an int */	if (!header_process(header, "Content-Length", header_extract_number, &length)) {		/*		 * Some netcams deliver some bad-format data, but if		 * we were able to recognize the header section and the		 * number we might as well try to use it.		 */		if (length > 0)			return length;		return -1;	}	return length;}/** * netcam_check_content_type * * 	Analyse an HTTP-header line to see if it is a Content-type * * Parameters: * *      header          Pointer to a string containing the header line * * Returns: *      -1              Not a Content-type line *      0               Content-type not recognized *      1               image/jpeg *      2               multipart/x-mixed-replace or multipart/mixed * */static int netcam_check_content_type(char *header){	char *content_type = NULL;	int ret;	if (!header_process(header, "Content-type", http_process_type, &content_type))		return -1;	if (!strcmp(content_type, "image/jpeg")) {		ret = 1;	} else if (!strcmp(content_type, "multipart/x-mixed-replace") ||	           !strcmp(content_type, "multipart/mixed")) {		ret = 2;	} else		ret = 0;	if (content_type)		free(content_type);	return ret;}/** * netcam_read_next_header * *      Read the next header record from the camera. * * Parameters * *      netcam          pointer to a netcam_context * * Returns:             0 for success, -1 if any error * */static int netcam_read_next_header(netcam_context_ptr netcam){	int retval;	char *header;	/*	 * return if not connected	 */	if (netcam->sock == -1) return -1;	/*	 * We are expecting a header which *must* contain a mime-type of	 * image/jpeg, and *might* contain a Content-Length.	 *	 * If this is a "streaming" camera, the header *must* be preceded	 * by a "boundary" string.	 *	 */	netcam->caps.content_length = 0;	/*	 * If this is a "streaming" camera, the stream header must be	 * preceded by a "boundary" string	 */	if (netcam->caps.streaming) {		while (1) {			retval = header_get(netcam, &header, HG_NONE);			if (retval != HG_OK) {				motion_log(LOG_ERR, 0, "Error reading image header");				free(header);				return -1;			}			retval = (strstr(header, netcam->boundary) == NULL);			free(header);			if (!retval)				break;		}	}	while (1) {		retval = header_get(netcam, &header, HG_NONE);		if (retval != HG_OK) {			motion_log(LOG_ERR, 0, "Error reading image header");			free(header);			return -1;		}		if (*header == 0)			break;		if ((retval = netcam_check_content_type(header)) >= 0) {			if (retval != 1) {				motion_log(LOG_ERR, 0, "Header not JPEG");				free(header);				return -1;			}		}		if ((retval = (int) netcam_check_content_length(header)) > 0) {			netcam->caps.content_length = 1;       /* set flag */			netcam->receiving->content_length = (int) retval;		}		free(header);	}	if (debug_level > CAMERA_INFO)		motion_log(-1, 0, "Found image header record");	free(header);	return 0;}/** * netcam_read_first_header * * This routine attempts to read a header record from the netcam.  If * successful, it analyses the header to determine whether the camera is * a "streaming" type.  If it is, the routine looks for the Boundary-string; * if found, it positions just past the string so that the image header can * be read.  It then reads the image header and continues processing that * header as well. * * If the camera does not appear to be a streaming type, it is assumed that the * header just read was the image header.  It is processed to determine whether * a Content-length is present. * * After this processing, the routine returns to the caller. * * Parameters: *      netcam            Pointer to the netcam_context structure * * Returns:               Content-type code if successful, -1 if not * */static int netcam_read_first_header(netcam_context_ptr netcam){	int retval = -2;                         /* "Unknown err" */	int ret;	int firstflag = 1;	char *header;	char *boundary;	struct context *cnt = netcam->cnt;       /* for conf debug_level */	/* Send the initial command to the camera */	if (send(netcam->sock, netcam->connect_request,	         strlen(netcam->connect_request), 0) < 0) {		motion_log(LOG_ERR, 1, "Error sending 'connect' request");		return -1;	}	/*	 * We expect to get back an HTTP header from the camera.	 * Successive calls to header_get will return each line	 * of the header received.  We will continue reading until	 * a blank line is received.	 *	 * As we process the header, we are looking for either of	 * header lines Content-type or Content-length.  Content-type	 * is used to determine whether the camera is "streaming" or	 * "non-streaming", and Content-length will be used to determine	 * whether future reads of images will be controlled by the	 * length specified before the image, or by a boundary string.	 *	 * The Content-length will only be present "just before" an	 * image is sent (if it is present at all).  That means that, if	 * this is a "streaming" camera, it will not be present in the	 * "first header", but will occur later (after a boundary-string).	 * For a non-streaming camera, however, there is no boundary-string,	 * and the first header is, in fact, the only header.  In this case,	 * there may be a Content-length.	 *	 */	while (1) {                                 /* 'Do forever' */		ret = header_get(netcam, &header, HG_NONE);		if (ret != HG_OK) {			if (debug_level > 5)				motion_log(LOG_ERR, 0, "Error reading first header (%s)", header);			free(header);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产精品免费| 欧美三级视频在线观看| 偷拍与自拍一区| 亚洲高清不卡在线观看| 亚洲国产精品久久一线不卡| 狠狠色综合日日| 精品亚洲免费视频| 成人网男人的天堂| 91影视在线播放| 欧美日韩国产影片| 精品国产青草久久久久福利| 久久在线观看免费| 亚洲人成电影网站色mp4| 一卡二卡欧美日韩| 老司机精品视频一区二区三区| 91免费视频网| 国产精品国产精品国产专区不蜜 | 国产成人在线影院 | 久久99精品国产麻豆婷婷洗澡| 色综合av在线| 日韩一区二区视频在线观看| 久久亚洲综合色一区二区三区| 亚洲国产成人va在线观看天堂| a4yy欧美一区二区三区| 在线国产亚洲欧美| 精品国产露脸精彩对白| 免费在线观看视频一区| 99精品国产视频| 日韩欧美一区二区三区在线| 国产精品美女一区二区三区| 日韩专区中文字幕一区二区| 91麻豆精品国产91久久久久| 日韩视频一区二区三区| 日韩和欧美的一区| 欧美一区二区三区免费在线看| 中文字幕久久午夜不卡| 日日摸夜夜添夜夜添精品视频| 欧美伊人久久大香线蕉综合69 | 久久久99精品久久| 艳妇臀荡乳欲伦亚洲一区| 99精品国产视频| 亚洲一区二区影院| 成人免费毛片嘿嘿连载视频| 中文字幕不卡三区| 成人性视频免费网站| 综合av第一页| 国产成人免费9x9x人网站视频| 国产亚洲成年网址在线观看| 成人丝袜18视频在线观看| 中文字幕一区二区三区四区 | 中文字幕亚洲欧美在线不卡| 99精品视频一区二区| 亚洲精品视频免费看| 国产福利一区在线观看| 国产精品久久久一本精品 | 日韩精品专区在线影院重磅| 奇米影视一区二区三区| 亚洲精品一区二区三区香蕉| 波多野结衣中文字幕一区二区三区 | 欧美日韩亚洲国产综合| 免费欧美日韩国产三级电影| 久久久久久一二三区| 青青青伊人色综合久久| 久久午夜电影网| 色系网站成人免费| 男女男精品视频| 中文字幕在线不卡视频| 91精品国产手机| 成人精品视频一区二区三区尤物| 自拍偷拍亚洲激情| 日韩欧美激情四射| 91在线国内视频| 麻豆精品视频在线观看免费| 欧美一二三四在线| 91亚洲精华国产精华精华液| 日本中文在线一区| 精品国产乱码久久久久久夜甘婷婷 | 国产亚洲欧美色| 色婷婷久久久亚洲一区二区三区| 免费成人在线视频观看| 亚洲美女电影在线| 久久久蜜桃精品| 欧美日韩1区2区| 91丨九色丨黑人外教| 国产精品18久久久久久vr| 亚洲精品在线免费播放| 欧美性xxxxxxxx| 成人国产一区二区三区精品| 男男gaygay亚洲| 偷拍自拍另类欧美| 一区二区三区中文免费| 国产精品视频yy9299一区| 欧美成人性战久久| 成人自拍视频在线| 另类小说色综合网站| 一二三四社区欧美黄| 中文字幕欧美一区| 国产日韩成人精品| 欧洲另类一二三四区| 成人激情动漫在线观看| 国产精品资源在线观看| 久久精品久久精品| 免费一级欧美片在线观看| 视频一区视频二区中文| 亚洲一区精品在线| 亚洲小说春色综合另类电影| 亚洲婷婷国产精品电影人久久| 国产日韩欧美精品综合| 久久久综合视频| 国产亚洲综合av| 欧美国产在线观看| 国产精品毛片无遮挡高清| 国产日韩影视精品| 国产精品久久久久久亚洲伦| 国产精品美女久久久久aⅴ | 不卡的av网站| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 欧美国产在线观看| 中文字幕av不卡| 国产精品久久午夜| 最新国产成人在线观看| 亚洲欧美激情插| 一区二区久久久久| 亚洲国产欧美日韩另类综合| 亚洲成人av在线电影| 亚洲国产精品v| 亚洲欧洲99久久| 亚洲综合激情另类小说区| 亚洲国产精品一区二区久久| 亚洲自拍欧美精品| 男女视频一区二区| 国产精品综合视频| 91亚洲精品一区二区乱码| 欧美日韩在线三级| 欧美大片在线观看| 日韩在线一区二区| 日韩二区在线观看| 国产麻豆9l精品三级站| 午夜精品在线视频一区| 免费成人结看片| 大胆欧美人体老妇| 欧美三电影在线| 日韩精品最新网址| 成人免费在线视频观看| 亚洲大片在线观看| 国产精品性做久久久久久| 不卡区在线中文字幕| 欧美日韩1区2区| 亚洲国产精品精华液ab| 亚洲国产欧美在线人成| 国产精一区二区三区| 在线观看亚洲a| 久久久亚洲精品石原莉奈| 亚洲精品va在线观看| 国产一区二区三区免费看 | 亚洲国产精品二十页| 亚洲成a人v欧美综合天堂下载| 狠狠色丁香久久婷婷综合丁香| 色噜噜狠狠色综合欧洲selulu| 成人app在线观看| 欧美一级在线视频| 国产精品精品国产色婷婷| 日精品一区二区三区| 99精品欧美一区二区蜜桃免费| 日韩视频在线观看一区二区| 一区二区中文视频| 久国产精品韩国三级视频| 欧美中文字幕一区二区三区亚洲| 精品国产乱码久久久久久图片 | 亚洲gay无套男同| www.亚洲人| 久久久激情视频| 秋霞电影网一区二区| 91福利在线观看| 国产农村妇女毛片精品久久麻豆| 五月综合激情网| 在线免费亚洲电影| 国产精品美女一区二区在线观看| 另类小说一区二区三区| 欧美日韩日日夜夜| 亚洲老妇xxxxxx| 99久久免费视频.com| 久久一区二区三区四区| 久久精品国产在热久久| 678五月天丁香亚洲综合网| 亚洲精品视频在线观看网站| fc2成人免费人成在线观看播放| 欧美精品一区二区三区蜜桃视频 | 黑人精品欧美一区二区蜜桃| 欧美高清dvd| 亚洲国产精品二十页| 国产一区二区h| 欧美不卡一区二区三区| 日韩国产欧美一区二区三区| 欧美性感一区二区三区| 亚洲激情自拍视频| 欧美亚洲综合网| 亚欧色一区w666天堂| 欧美色视频在线观看| 亚洲电影在线播放|