[asterisk-commits] rizzo: branch rizzo/video_v2 r82747 - /team/rizzo/video_v2/channels/chan_alsa.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 18 05:03:22 CDT 2007


Author: rizzo
Date: Tue Sep 18 05:03:22 2007
New Revision: 82747

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82747
Log:
add hooks for webcam and video processing to chan_alsa

Modified:
    team/rizzo/video_v2/channels/chan_alsa.c

Modified: team/rizzo/video_v2/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/chan_alsa.c?view=diff&rev=82747&r1=82746&r2=82747
==============================================================================
--- team/rizzo/video_v2/channels/chan_alsa.c (original)
+++ team/rizzo/video_v2/channels/chan_alsa.c Tue Sep 18 05:03:22 2007
@@ -72,6 +72,8 @@
 #include "alsa-monitor.h"
 #endif
 
+#include "console_video.c"
+
 /*! Global jitterbuffer configuration - by default, jb is disabled */
 static struct ast_jb_conf default_jbconf = {
 	.flags = 0,
@@ -161,7 +163,14 @@
 #endif
 	snd_pcm_t *icard, *ocard;
 
+	struct video_desc env;
 } alsa;
+
+static struct video_desc *get_video_desc(struct ast_channel *c)
+{
+	struct chan_alsa_pvt *o = c->tech_pvt;
+	return o ? &(o->env) : NULL;
+}
 
 /* Number of buffers...  Each is FRAMESIZE/8 ms long.  For example
    with 160 sample frames, and a buffer size of 3, we have a 60ms buffer, 
@@ -198,7 +207,11 @@
 static const struct ast_channel_tech alsa_tech = {
 	.type = "Console",
 	.description = tdesc,
-	.capabilities = AST_FORMAT_SLINEAR,
+	/*
+	 * Format that we need to process.
+	 * This option is overriden by the configuration file.
+	 */
+	.capabilities = AST_FORMAT_SLINEAR | CONSOLE_FORMAT_VIDEO,
 	.requester = alsa_request,
 	.send_digit_end = alsa_digit,
 	.send_text = alsa_text,
@@ -207,6 +220,8 @@
 	.read = alsa_read,
 	.call = alsa_call,
 	.write = alsa_write,
+	/* We need this to declare the capabilities to process video frame */
+	.write_video = console_write_video,
 	.indicate = alsa_indicate,
 	.fixup = alsa_fixup,
 };
@@ -289,6 +304,11 @@
 			if (writedev > max)
 				max = writedev;
 		}
+		/*if (alsa.env.out.fd > -1) {
+			FD_SET(alsa.env.out.fd, &rfds);
+			if (alsa.env.out.fd > max)
+			max = alsa.env.out.fd;
+		  }*/
 #ifdef ALSA_MONITOR
 		if (!alsa.owner) {
 			FD_SET(readdev, &rfds);
@@ -570,11 +590,16 @@
 static int alsa_hangup(struct ast_channel *c)
 {
 	int res;
+	struct chan_alsa_pvt *o = c->tech_pvt;
+
 	ast_mutex_lock(&alsalock);
 	cursound = -1;
 	c->tech_pvt = NULL;
 	alsa.owner = NULL;
 	ast_verbose(" << Hangup on console >> \n");
+
+	console_video_uninit(&o->env);
+
 	ast_module_unref(ast_module_info->self);
 	if (hookstate) {
 		hookstate = 0;
@@ -664,8 +689,10 @@
 	snd_pcm_state_t state;
 	int r = 0;
 	int off = 0;
-
-	ast_mutex_lock(&alsalock);
+	struct ast_frame *fv = get_video_frames(get_video_desc(chan));
+
+	ast_mutex_lock(&alsalock);
+	AST_LIST_NEXT(&f, frame_list) = fv;
 	/* Acknowledge any pending cmd */
 	f.frametype = AST_FRAME_NULL;
 	f.subclass = 0;
@@ -791,6 +818,10 @@
 	tmp->tech = &alsa_tech;
 	ast_channel_set_fd(tmp, 0, readdev);
 	tmp->nativeformats = AST_FORMAT_SLINEAR;
+
+	/* if the console makes the call, add video */
+	if (state == 5)
+		tmp-> nativeformats |= CONSOLE_FORMAT_VIDEO;
 	tmp->readformat = AST_FORMAT_SLINEAR;
 	tmp->writeformat = AST_FORMAT_SLINEAR;
 	tmp->tech_pvt = p;
@@ -810,6 +841,8 @@
 			tmp = NULL;
 		}
 	}
+
+	console_video_start(get_video_desc(tmp), p->owner);
 
 	return tmp;
 }
@@ -1116,6 +1149,16 @@
 			ast_copy_string(outdevname, v->value, sizeof(outdevname));
 		else if (!strcasecmp(v->name, "mohinterpret"))
 			ast_copy_string(mohinterpret, v->value, sizeof(mohinterpret));
+		else if (!strcasecmp(v->name, "videodevice"))
+			ast_copy_string(alsa.env.videodevice, v->value, sizeof(alsa.env.videodevice));
+		else if (!strcasecmp(v->name, "videowidth"))
+			alsa.env.w = atoi(v->value);
+		else if (!strcasecmp(v->name, "bitrate"))
+			alsa.env.bitrate = atoi(v->value);
+		else if (!strcasecmp(v->name, "videoheight"))
+			alsa.env.h = atoi(v->value);
+		else if (!strcasecmp(v->name, "fps"))
+			alsa.env.fps = atoi(v->value);
 	}
 	ast_config_destroy(cfg);
 




More information about the asterisk-commits mailing list