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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 17 06:31:40 CDT 2007


Author: rizzo
Date: Mon Sep 17 06:31:39 2007
New Revision: 82567

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82567
Log:
more debugging


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=82567&r1=82566&r2=82567
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Mon Sep 17 06:31:39 2007
@@ -163,7 +163,7 @@
 #define CONSOLE_FORMAT_VIDEO	AST_FORMAT_H263_PLUS
 
 static struct _cm video_formats[] = {
-	{ AST_FORMAT_H263_PLUS,	CODEC_ID_H263 },
+	{ AST_FORMAT_H263_PLUS,	CODEC_ID_H263 }, /* XXX H263P ? */
 	{ 0,			0 },
 };
 
@@ -285,6 +285,7 @@
  */
 static int video_read(struct video_out_desc *v)
 {
+	// fprintf(stderr, "video_read %p buf %p image %p\n", v, v->buf.data, v->image);
 	if (v->buf.data == NULL)	/* not initialized */
 		return 0;
 
@@ -493,11 +494,18 @@
 	v->context->pix_fmt = v->pix_fmt;
 	v->context->width = v->w;
 	v->context->height = v->h;
+	/* XXX rtp_callback ?
+	 * rtp_mode so ffmpeg inserts as many start codes as possible.
+	 */
 	v->context->rtp_mode = 1;
 	v->context->rtp_payload_size = v->mtu / 2; // mtu/2
-	v->context->flags|=CODEC_FLAG_H263P_UMV;
-	v->context->flags|=CODEC_FLAG_AC_PRED;
-	v->context->flags|=CODEC_FLAG_H263P_SLICE_STRUCT;
+	if (0) {	/* normal h263 */
+		// v->context->codec = CODEC_ID_H263;
+	} else {
+		v->context->flags|=CODEC_FLAG_H263P_UMV;
+		v->context->flags|=CODEC_FLAG_AC_PRED;
+		v->context->flags|=CODEC_FLAG_H263P_SLICE_STRUCT;
+	}
 	v->context->bit_rate = v->bitrate;
 	v->context->gop_size = (int) v->fps*5; // emit I frame every 5 seconds
  
@@ -762,8 +770,8 @@
 			ast_log(LOG_WARNING, "no buffer for show frame\n");
 		} else {
 			bcopy(src, bmp->pixels[0], 4*l4);
-			bcopy(src + 4*l4, bmp->pixels[2], l4);
-			bcopy(src + 5*l4, bmp->pixels[1], l4);
+			bcopy(src + 5*l4, bmp->pixels[2], l4);
+			bcopy(src + 4*l4, bmp->pixels[1], l4);
 		}
 	} else {	/* decode */
 #ifdef OLD_FFMPEG /* XXX img_convert is deprecated */
@@ -909,36 +917,44 @@
 {
 	uint8_t *data;
 	struct ast_frame *cur = NULL, *first = NULL;
-	int header = 0; // the first frag contains the PSC
 	uint8_t *start = out->decbuf.data;
 	int have_psc = 0;	/* did we skip 2 bytes for this frame ? */
-
-	while (len > 0) {
-		/* first try to split on a psc. if not, then create an artificial break */
-		struct ast_frame *f = ast_malloc(sizeof(*f));
-		int size = MIN(len, out->mtu + 2);
-		uint8_t *p;
-		for (p = start; p < start + size -2; p++) {
-			if (p[0] == 0 && p[1] == 0)
+	int l;	/* size of the current fragment */
+
+	for (;len > 0; start += l, len -= l) {
+		/* First try to split on a psc. If not, create an artificial break */
+		struct ast_frame *f;
+#if 0
+		int max_size = len;
+		max_size = MIN(len, out->mtu + 2);
+		for (l = 0; l < max_size -2; l++) {
+			if (start[l] == 0 && start[l+1] == 0)
 				break;
 		}
-		if (p == 0) {
-			start += 2;
+		if (l == 0) {
+			l = 2;
 			have_psc = 1;	/* info for next frame */
 			continue;
 		}
-		if (p - start > out->mtu) {
+		if (l > out->mtu) {
 			ast_log(LOG_WARNING, "no psc in frame sized %d\n", len);
-			size = out->mtu;
-		}
-		if (cur)
-			AST_LIST_NEXT(cur, frame_list) = f;
-		else
-			first = f;
-		cur = f;
-
-		data = ast_malloc(size+2);
-		memcpy(data+2, start, size);
+			l = out->mtu;
+		}
+#endif
+		/* temporary - assume we have psc, drop first 2 bytes, send one large packet */
+		have_psc = 1;
+		start += 2;
+		l = len - 2;
+
+		ast_log(LOG_WARNING, "len %d\n", l);
+		f = ast_calloc(1, sizeof(*f));
+		data = ast_calloc(1, l+2);
+		f->mallocd = AST_MALLOCD_DATA | AST_MALLOCD_HDR;
+
+		data[0] = data[1] = 0; // P == 0
+		if (have_psc)
+			data[0] |= 0x04; // P == 1
+		memcpy(data+2, start, l);
 
 		f->has_timing_info = 1;
 		f->ts = ast_tvdiff_ms(ast_tvnow(), out->ts);
@@ -947,29 +963,27 @@
 		f->samples = 0;
 		f->offset = 0;
 		f->src = "Console";
-		// This flags teels asterisk that the data and
+		// This flags tells asterisk that the data and
 		// the header are dinamically allocated
-		f->mallocd = AST_MALLOCD_DATA | AST_MALLOCD_HDR;
 		f->delivery.tv_sec = 0;
 		f->delivery.tv_usec = 0;
 		f->seqno = ++(out->lasttxframe);
-		f->datalen = size+header;
+		f->datalen = l + 2;
 		f->data = data;
 		AST_LIST_NEXT(f, frame_list) = NULL;
 
-		data[0] = data[1] = 0; // P == 0
-		if (have_psc)
-			data[0] |= 0x04; // P == 1
-		
-		if (p - start > out->mtu)
-			have_psc = 0;	/* info for next frame */
-		start += size;
-		len -= size;
+		if (cur)
+			AST_LIST_NEXT(cur, frame_list) = f;
+		else
+			first = f;
+		cur = f;
+		have_psc = (l <= out->mtu);
 	}
 
 	if (cur)
 		cur->subclass |= 1; // RTP Marker
 
+	ast_log(LOG_WARNING, "done, first %p\n", first);
 	return first;
 }
 
@@ -981,7 +995,7 @@
 
 	if (!video_read(&env->out))
 		return NULL;
-	//fprintf(stderr, "webcam read\n");
+	// fprintf(stderr, "video read\n");
 
 	// XXX - questa porzione di codice limita la generazione dei
 	// frame al framerate specificato nel file di configurazione




More information about the asterisk-commits mailing list