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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 1 10:50:57 CDT 2007


Author: rizzo
Date: Mon Oct  1 10:50:57 2007
New Revision: 84175

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84175
Log:
cannot use AST_LIST_INSERT_TAIL to join two lists


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

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=84175&r1=84174&r2=84175
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Mon Oct  1 10:50:57 2007
@@ -1079,7 +1079,7 @@
 /*
  * Create RTP/H.263 fragmets to avoid IP fragmentation
  */
-static struct ast_frame *split_frame(struct video_out_desc *out, int len)
+static struct ast_frame *split_frame(struct video_out_desc *out, int len, struct ast_frame **tail)
 {
 	struct ast_frame *cur = NULL, *first = NULL;
 	uint8_t *d = out->enc_out.data;
@@ -1156,17 +1156,24 @@
 		cur->subclass |= 1; // RTP Marker
 
 	//ast_log(LOG_WARNING, "done, totlen %d frags %d\n", totlen, frags);
+	*tail = cur;	/* end of the list */
 	return first;
 }
 
 /*! \brief read a frame from webcam or X11 through video_read(),
  * display it,  then encode and split it.
  * Return a list of ast_frame representing the video fragments.
- */
-static struct ast_frame *get_video_frames(struct video_desc *env)
+ * The head pointer is returned by the function, the tail pointer
+ * is returned as an argument.
+ */
+static struct ast_frame *get_video_frames(struct video_desc *env, struct ast_frame **tail)
 {
 	struct video_out_desc *v = &env->out;
 	struct fbuf_t *b = &v->enc_out;
+	struct ast_frame *dummy;
+
+	if (tail == NULL)
+		tail = &dummy;
 
 	if (!v->loc_src.data) {
 		static volatile int a = 0;
@@ -1178,6 +1185,7 @@
 	if (!video_read(v))
 		return NULL;	/* can happen, e.g. we are reading too early */
 
+	*tail = NULL;
 	/* get frame and put them in the queue */
 	my_scale(&v->loc_src, NULL, &v->enc_in, NULL);
 	show_frame(env, 1);
@@ -1188,7 +1196,7 @@
 	if (!v->sendvideo)
 		return NULL;
 	b->used = avcodec_encode_video(v->enc_ctx, b->data, b->size, v->frame);
-	return split_frame(v, b->used);
+	return split_frame(v, b->used, tail);
 }
 
 /*
@@ -1204,6 +1212,7 @@
 		/* XXX 20 times/sec */
 		struct timeval t = { 0, 50000 };
 		struct ast_frame *p, *f;
+		
 		struct ast_channel *chan = env->owner;
 		int fd = chan->alertpipe[1];
 
@@ -1213,16 +1222,23 @@
 		}
 		/* sleep for a while */
 		ast_select(0, NULL, NULL, NULL, &t);
-		f = get_video_frames(env);
+		f = get_video_frames(env, &p);
 		if (!f)
 			continue;
 		chan = env->owner;
 		ast_channel_lock(chan);
+		/* AST_LIST_INSERT_TAIL is only good for one frame, cannot use */
+		if (chan->readq.first == NULL) {
+			chan->readq.first = f;
+		} else {
+			chan->readq.last->frame_list.next = f;
+		}
+		chan->readq.last = p;
 		/*
 		 * more or less same as ast_queue_frame, but extra
 		 * write on the alertpipe to signal frames.
 		 */
-		AST_LIST_INSERT_TAIL(&(chan->readq), f, frame_list);
+
 		if (fd > -1) {
 			int blah = 1, l = sizeof(blah);
 			for (p = f; p; p = AST_LIST_NEXT(p, frame_list)) {




More information about the asterisk-commits mailing list