[asterisk-commits] rizzo: branch rizzo/video_v2 r85232 - /team/rizzo/video_v2/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 10 05:27:05 CDT 2007


Author: rizzo
Date: Wed Oct 10 05:27:04 2007
New Revision: 85232

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85232
Log:
move some common code to console_video.c


Modified:
    team/rizzo/video_v2/channels/chan_oss.c
    team/rizzo/video_v2/channels/console_video.c

Modified: team/rizzo/video_v2/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/chan_oss.c?view=diff&rev=85232&r1=85231&r2=85232
==============================================================================
--- team/rizzo/video_v2/channels/chan_oss.c (original)
+++ team/rizzo/video_v2/channels/chan_oss.c Wed Oct 10 05:27:04 2007
@@ -1142,16 +1142,8 @@
 	if (value)	/* handle setting */
 		store_config_core(o, var, value);
 	/* XXX these should be moved to console_video.c */
-	if (!strcasecmp(var, "videodevice")) {
-		ast_cli(a->fd, "videodevice is [%s]\n", o->env->videodevice);
-	} else if (!strcasecmp(var, "videowidth")) {
-		ast_cli(a->fd, "videowidth is [%d]\n", o->env->w);
-	} else if (!strcasecmp(var, "videoheight")) {
-		ast_cli(a->fd, "videoheight is [%d]\n", o->env->h);
-	} else if (!strcasecmp(var, "bitrate")) {
-		ast_cli(a->fd, "bitrate is [%d]\n", o->env->bitrate);
-	} else if (!strcasecmp(var, "fps")) {
-		ast_cli(a->fd, "fps is [%d]\n", o->env->fps);
+	if (console_video_cli(o->env, var, a->fd)) {
+		/* nothing */
 	} else if (!strcasecmp(var, "device")) {
 		ast_cli(a->fd, "device is [%s]\n", o->device);
 	}

Modified: team/rizzo/video_v2/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/console_video.c?view=diff&rev=85232&r1=85231&r2=85232
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Wed Oct 10 05:27:04 2007
@@ -49,6 +49,11 @@
 #define CONSOLE_FORMAT_VIDEO	0
 #define	console_write_video	NULL
 
+static int console_video_cli(struct video_desc *penv, const char *var, int fd)
+{
+	return 0;	/* not recognised */
+}
+
 static int console_video_config(struct video_desc **penv,
 	const char *var, const char *val)
 {
@@ -184,7 +189,7 @@
 	 * If we are successful, webcam_bufsize > 0 and we can read.
 	 */
 	/* all the following is config file info copied from the parent */
-	const char *	device;		/* device name (or X11) */
+	char		videodevice[64];
 	int 		w;		/* geometry and other info,  */
 	int 		h;
 	int		fps;
@@ -272,7 +277,6 @@
 	int 			h;
 	int 			fps;	/* framerate */
 	int 			bitrate;
-	char			videodevice[64];
 	char			codec_name[64];
 
 	pthread_t		vthread;	/* video thread */
@@ -846,7 +850,7 @@
 	/*
 	 * if the device is "X11", then open the x11 grabber
 	 */
-    if (!strcasecmp(v->device, "X11")) {
+    if (!strcasecmp(v->videodevice, "X11")) {
 	int x_ofs = 0;
 	int y_ofs = 0;
 	XImage *im;
@@ -886,10 +890,11 @@
 	struct video_window vw = { 0 };	/* camera attributes */
 	struct video_picture vp;
 	int i;
-
-	v->fd = open(v->device, O_RDONLY | O_NONBLOCK);
+	const char *dev = v->videodevice;
+
+	v->fd = open(dev, O_RDONLY | O_NONBLOCK);
 	if (v->fd < 0) {
-		ast_log(LOG_WARNING, "error opening camera %s\n", v->device);
+		ast_log(LOG_WARNING, "error opening camera %s\n", v->videodevice);
 		return v->fd;
 	}
 
@@ -897,7 +902,7 @@
 	if (-1 == fcntl(v->fd, F_SETFL, i | O_NONBLOCK)) {
 		/* non fatal, just emit a warning */
 		ast_log(LOG_WARNING, "error F_SETFL for %s [%s]\n",
-			v->device, strerror(errno));
+			dev, strerror(errno));
 	}
 	/* set format for the camera.
 	 * In principle we could retry with a different format if the
@@ -908,7 +913,7 @@
 	vw.flags = v->fps << 16;
 	if (ioctl(v->fd, VIDIOCSWIN, &vw) == -1) {
 		ast_log(LOG_WARNING, "error setting format for %s [%s]\n",
-			v->device, strerror(errno));
+			dev, strerror(errno));
 		goto error;
 	}
 	if (ioctl(v->fd, VIDIOCGPICT, &vp) == -1) {
@@ -937,7 +942,7 @@
 	 */
 	b->size = (b->w * b->h * 3)/2;	/* yuv411 */
 	ast_log(LOG_WARNING, "videodev %s opened, size %dx%d %d\n",
-		v->device, b->w, b->h, b->size);
+		dev, b->w, b->h, b->size);
 	v->loc_src.data = ast_calloc(1, b->size);
 	if (!b->data) {
 		ast_log(LOG_WARNING, "error allocating buffer %d bytes\n",
@@ -1220,7 +1225,7 @@
 		return video_out_uninit(v);
 	}
 
-	/* Here we assume that the encoder has some 411 format */
+	/* parameters for PIX_FMT_YUV420P */
 	size = enc_in->w * enc_in->h;
 	v->frame->data[0] = enc_in->data;
 	v->frame->data[1] = v->frame->data[0] + size;
@@ -1298,7 +1303,7 @@
 		struct video_desc x = *env; /* make a copy */
 		bzero(env, sizeof(struct video_desc));
 		/* restore fields... */
-		bcopy(x.videodevice, env->videodevice, sizeof(env->videodevice));
+		bcopy(x.out.videodevice, env->out.videodevice, sizeof(env->out.videodevice));
 		bcopy(x.codec_name, env->codec_name, sizeof(env->codec_name));
 		env->w = x.w;
 		env->h = x.h;
@@ -1328,6 +1333,10 @@
 		break;
 	case PIX_FMT_RGBA32:
 		len *= 4;
+		luv = 0;
+		break;
+	case PIX_FMT_YUYV422:	/* Packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr */
+		len *= 2;	/* all data in first plane, probably */
 		luv = 0;
 		break;
 	}
@@ -1747,9 +1756,6 @@
 	 * now handle the local video source
 	 */
 	/* copy video source config from parent */
-	env->out.device = env->videodevice;
-	env->out.w = env->w;
-	env->out.h = env->h;
 	if (env->fps == 0) {
 		env->fps = 15;
 		ast_log(LOG_WARNING, "fps unset, forcing to %d\n", env->fps);
@@ -1791,7 +1797,29 @@
 	return sscanf(s, "%dx%d", &b->w, &b->h);
 }
 
-/*! parse config command for video support */
+/* extend ast_cli with video commands. Called by console_video_config */
+static int console_video_cli(struct video_desc *env, const char *var, int fd)
+{
+	if (env == NULL)
+		return 0;	/* unrecognised */
+
+        if (!strcasecmp(var, "videodevice")) {
+		ast_cli(fd, "videodevice is [%s]\n", env->out.videodevice);
+        } else if (!strcasecmp(var, "videowidth")) {
+		ast_cli(fd, "videowidth is [%d]\n", env->w);
+        } else if (!strcasecmp(var, "videoheight")) {
+		ast_cli(fd, "videoheight is [%d]\n", env->h);
+        } else if (!strcasecmp(var, "bitrate")) {
+		ast_cli(fd, "bitrate is [%d]\n", env->bitrate);
+        } else if (!strcasecmp(var, "fps")) {
+		ast_cli(fd, "fps is [%d]\n", env->fps);
+        } else {
+		return 0;	/* unrecognised */
+	}
+	return 1;	/* recognised */
+}
+
+/*! parse config command for video support. */
 static int console_video_config(struct video_desc **penv,
 	const char *var, const char *val)
 {
@@ -1812,7 +1840,7 @@
 		}
 		env->out.sendvideo = 1;
 	}
-        M_STR("videodevice", env->videodevice)
+        M_STR("videodevice", env->out.videodevice)
         M_BOOL("sendvideo", env->out.sendvideo)
         M_UINT("videowidth", env->w)
         M_F("camera_format", video_geom(&env->out.loc_src, val))




More information about the asterisk-commits mailing list