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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Sep 16 13:25:04 CDT 2007


Author: rizzo
Date: Sun Sep 16 13:25:03 2007
New Revision: 82512

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82512
Log:
interim commit trying to cleanup the frame splitting.


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=82512&r1=82511&r2=82512
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Sun Sep 16 13:25:03 2007
@@ -481,7 +481,6 @@
 	v->lasttxframe		= -1;
 	v->decbuf.data		= NULL;
 
-	ast_log(LOG_WARNING, "video_out_init start 0x%x", format);
 	codec = map_video_format(format);
 	v->codec = avcodec_find_encoder(codec);
 	if (!v->codec) {
@@ -537,7 +536,6 @@
 	v->msts = ast_tvnow();
 
 	v->mtu = 1400;
-	ast_log(LOG_VERBOSE, "video_out_init done");
 
 	return 0;
 }
@@ -817,18 +815,9 @@
 	struct timeval now = ast_tvnow();
 	int i;
 
-	ast_log(LOG_WARNING, "received video frame %d\n", f->seqno);
 	if(!env->initialized) {
 		ast_log(LOG_WARNING, "here env should be already initialized\n");
 		return -1;	/* error */
-	}
-
-	if (0) {	/* echo frames back to the sender */
-		struct ast_frame *f1, **fp;
-		f1 = ast_frdup(f);
-		for (fp = &env->echo; (*fp) != NULL ; fp = &AST_LIST_NEXT((*fp), frame_list) )
-			;
-		*fp = f1;
 	}
 
 	i = ast_tvdiff_ms(now, env->in.ts);
@@ -880,6 +869,7 @@
 	}
 
 	len = f->datalen;
+	ast_log(LOG_WARNING, "received video frame %d size %d\n", f->seqno, f->datalen);
 	data = pre_process_data(f->data, &len);
 
 	/* allocate buffer as we see fit. ffmpeg wants an extra FF_INPUT_BUFFER_PADDING_SIZE
@@ -909,7 +899,8 @@
 
  
 /*
- * Find the next PSC (Picture Start Code) of the frame
+ * Find the next PSC (Picture Start Code) of the frame.
+ * If everything is correct, we have a couple of 0 bytes in the psc.
  */
 static uint8_t *get_psc(uint8_t *begin, uint8_t *end, int packet_size)
 {
@@ -933,6 +924,9 @@
 			break;
 		}
 	}
+	if ( (p && ret - begin > 1400) || (!p && end - begin > 1400))
+	    fprintf(stderr, "get_psc in %d size %d found %p %d\n",
+		end - begin, packet_size, p, ret - begin);
 #endif
 	return ret;
 }
@@ -947,18 +941,21 @@
 static struct ast_frame *create_video_segment(struct video_out_desc *out, uint8_t *start, uint8_t *end, int last_packet)
 {
 	int len = end-start;
-	int size = MIN(len, out->mtu);
 	uint8_t *data;
-	struct ast_frame *f, *fp = NULL, *ftop = NULL;
+	struct ast_frame *cur = NULL, *first = NULL;
 	int header = 0; // the first frag contains the PSC
 
-	do {
-		f = ast_malloc(sizeof(*f));
-		if(fp)
-			AST_LIST_NEXT(fp, frame_list) = f;
+	if (len > out->mtu)
+		ast_log(LOG_WARNING, "watch out, oversized frame %d\n", len);
+	while (len > 0) {
+		struct ast_frame *f = ast_malloc(sizeof(*f));
+		int size = len; // MIN(len, out->mtu);
+
+		if (cur)
+			AST_LIST_NEXT(cur, frame_list) = f;
 		else
-			ftop = f;
-		fp = f;
+			first = f;
+		cur = f;
 
 		data = ast_malloc(size+header);
 		memcpy(data+header, start, size);
@@ -980,7 +977,7 @@
 		f->data = data;
 		AST_LIST_NEXT(f, frame_list) = NULL;
 
-		if(header == 2)
+		if (header == 2)
 			data[0] = data[1] = 0; // P == 0
 		else {
 			data[0] |= 0x04; // P == 1
@@ -988,15 +985,13 @@
 		}
 
 		start += size;
-		len = end-start;
-		size = MIN(len, out->mtu);
-		if (len > 0)
-			ast_log(LOG_WARNING, "create_video_segment %d leftover bytes\n", len);
-	} while(len > 0);
-
-	f->subclass |= last_packet; // RTP Marker
-
-	return ftop;
+		len -= size;
+	}
+
+	if (cur)
+		cur->subclass |= last_packet; // RTP Marker
+
+	return first;
 }
 
 /*




More information about the asterisk-commits mailing list