[xiph-commits] r10578 - trunk/xiph-rtp

lu_zero at svn.xiph.org lu_zero at svn.xiph.org
Sat Dec 10 19:17:23 PST 2005


Author: lu_zero
Date: 2005-12-10 19:17:19 -0800 (Sat, 10 Dec 2005)
New Revision: 10578

Modified:
   trunk/xiph-rtp/theorartp-client.c
   trunk/xiph-rtp/theorartp.c
   trunk/xiph-rtp/vorbisrtp-client.c
   trunk/xiph-rtp/xiph_rtp.c
Log:
Fixed theora-rtp, the timestamp are still wrong

Modified: trunk/xiph-rtp/theorartp-client.c
===================================================================
--- trunk/xiph-rtp/theorartp-client.c	2005-12-11 03:14:02 UTC (rev 10577)
+++ trunk/xiph-rtp/theorartp-client.c	2005-12-11 03:17:19 UTC (rev 10578)
@@ -209,11 +209,10 @@
   ogg_packet id,co,cb;
   unsigned char comment[] = 
 /*quite minimal comment*/
-   { 0x83,'t','h','e','o','r','a', 
+   { 0x81,'t','h','e','o','r','a',
    	10,0,0,0, 
    		't','h','e','o','r','a','-','r','t','p',
-   		0,0,0,0, 
-                1};
+   		0,0,0,0};
   
 /* get the identification packet*/
   id.packet = ogg->op.packet;
@@ -363,11 +362,16 @@
   switch (F) {
 
   case 0:
-    
+    op->bytes = data[offset++]<<8;
+    op->bytes += data[offset++];
+    op->packet = &data[offset];
+    op->packetno++;
+    offset += op->bytes;
     break;
   case 1:
     op->bytes = 0;
-    op->packetno++;
+    if (op->packet) free (op->packet);
+    op->packet = NULL;
   case 2:
     length = data[offset++] << 8;
     length += data[offset++];
@@ -376,13 +380,11 @@
     op->bytes += length;
     return 0;
   case 3:
-    op->packetno++;
     length = data[offset++] << 8;
     length += data[offset++];
     op->packet = realloc (op->packet, length+op->bytes);
     memcpy (op->packet + op->bytes, data + offset, length);
     op->bytes += length;
-    pkts=1;
     break;
   default:
     fprintf (stderr, " unknown frament?!\n");
@@ -392,7 +394,10 @@
   switch (VDT) {
 
   case 0:
-  for (i = 0; i < pkts; i++)
+
+  count += pkt_repack(ogg, timestamp, out);
+  
+  for (i = 1; i < pkts; i++)
     {
       if (offset >= len)
 	{
@@ -403,10 +408,9 @@
       op->bytes += data[offset++];
       op->packet = &data[offset];
       op->packetno++;
-      count += pkt_repack(ogg, i ? 0 : timestamp, out);
+      count += pkt_repack(ogg, 0, out);
       offset += op->bytes;
-      op->b_o_s=0;
-    }   
+    }
     break;
   case 1:
     count = cfg_repack(ogg, out);
@@ -416,8 +420,11 @@
     break;
     
   }
-  if (F == 3) free(op->packet);
-
+  if (F == 3) 
+  {
+	  free(op->packet);
+	  op->packet = NULL;
+  }
   return count;
 }
 
@@ -434,11 +441,13 @@
   unsigned int port = 4044;
 
   ogg_context_t ogg;
-  memset(&ogg,0,sizeof(ogg_context_t)); 
+  memset(&ogg,0,sizeof(ogg_context_t));
+  ogg.prev_gp=-1;
+
   fprintf (stderr,
 	   "||---------------------------------------------------------------------------||\n");
 
-  fprintf (stderr, "||  Vorbis RTP Client (draft-kerr-avt-vorbis-rtp-05)\n");
+  fprintf (stderr, "||  Vorbis RTP Client (draft-barbato-avt-rtp-theora-05)\n");
 
   while ((opt = getopt (argc, argv, "i:p:f:v")) != -1)
     {

Modified: trunk/xiph-rtp/theorartp.c
===================================================================
--- trunk/xiph-rtp/theorartp.c	2005-12-11 03:14:02 UTC (rev 10577)
+++ trunk/xiph-rtp/theorartp.c	2005-12-11 03:17:19 UTC (rev 10578)
@@ -101,12 +101,11 @@
 
 	int i = 0;
 	int opt;
-	long int acc=0;
 
 	char *ip = "227.0.0.1";
 	unsigned int port = 4044;
 	unsigned int ttl  = 1;
-	long timestamp = 0, prev = 0;
+	long timestamp = 0;
 
     	fprintf (stderr, "Theora RTP Server (draft-barbato-avt-rtp-theora-01)\n");
 	memset (&xr,0,sizeof(xiph_rtp_t));
@@ -260,16 +259,16 @@
 /*===========================================================================*/
 /*  Print details                                                            */
 /*===========================================================================*/
-    fprintf(stdout," Theora %dx%d %.02f fps video\n"
+    fprintf(stdout,"Theora %dx%d %.02f fps video\n"
 		    "Encoded frame content is %dx%d with %dx%d offset\n",
             xr.ti.width,xr.ti.height, 
 	    (double)xr.ti.fps_numerator/xr.ti.fps_denominator,
             xr.ti.frame_width, xr.ti.frame_height, 
 	    xr.ti.offset_x, xr.ti.offset_y);
 
-    fprintf (stdout, "  Decode setup ident is 0x%06x\n", xr.bitfield.cbident);
+    fprintf (stdout, "Decode setup ident is 0x%06x\n", xr.bitfield.cbident);
     fprintf (stdout, "\n");
-    fprintf (stdout, "  Processing\n");
+    fprintf (stdout, "Processing\n");
 
 /*===========================================================================*/
 /*  Send the three headers inline                                            */
@@ -313,9 +312,11 @@
 			theora_decode_packetin(&xr.td,&xr.op);   
 #ifdef DEBUG
 			printf("  bytes %ld bos %ld eos %ld gp %lld pno %lld\n", xr.op.bytes, xr.op.b_o_s, xr.op.e_o_s, xr.op.granulepos, xr.op.packetno);
-#endif		
+#endif
+			if (xr.op.granulepos != -1)
 			timestamp =  (xr.op.granulepos>>xr.gp_shift)+
 			(xr.op.granulepos & ((1<<xr.gp_shift)-1));
+			else timestamp++ ;
 			creatertp ( &xr, xr.op.packet, xr.op.bytes, 
 					timestamp, 0);
             	    }

Modified: trunk/xiph-rtp/vorbisrtp-client.c
===================================================================
--- trunk/xiph-rtp/vorbisrtp-client.c	2005-12-11 03:14:02 UTC (rev 10577)
+++ trunk/xiph-rtp/vorbisrtp-client.c	2005-12-11 03:17:19 UTC (rev 10578)
@@ -548,11 +548,15 @@
   switch (F) {
 
   case 0:
-    
+    op->bytes = data[offset++]<<8;
+    op->bytes += data[offset++];
+    op->packet = &data[offset];
+    op->packetno++;
+    offset += op->bytes;
     break;
   case 1:
     op->bytes = 0;
-    op->packetno++;
+    op->packet = NULL;
   case 2:
     length = data[offset++] << 8;
     length += data[offset++];
@@ -561,7 +565,6 @@
     op->bytes += length;
     return 0;
   case 3:
-    op->packetno++;
     length = data[offset++] << 8;
     length += data[offset++];
     op->packet = realloc (op->packet, length+op->bytes);
@@ -577,7 +580,12 @@
   switch (VDT) {
 
   case 0:
-  for (i = 0; i < pkts; i++)
+  ogg->curr_bs = pkt_blocksize(ogg);
+  if(ogg->prev_bs)
+      op->granulepos += (ogg->curr_bs + ogg->prev_bs)/4;
+  ogg->prev_bs = ogg->curr_bs;
+  count += pkt_repack(ogg,out);
+  for (i = 1; i < pkts; i++)
     {
       if (offset >= len)
 	{
@@ -609,8 +617,11 @@
     break;
     
   }
-  if (F == 3) free(op->packet);
-
+  if (F == 3)
+  {
+	  free(op->packet);
+	  op->packet = NULL;
+  }
   return count;
 }
 

Modified: trunk/xiph-rtp/xiph_rtp.c
===================================================================
--- trunk/xiph-rtp/xiph_rtp.c	2005-12-11 03:14:02 UTC (rev 10577)
+++ trunk/xiph-rtp/xiph_rtp.c	2005-12-11 03:17:19 UTC (rev 10578)
@@ -379,7 +379,7 @@
 	/* Vorbis and Theora header */
 	if (length < sizeof(header_bitfield_t)) return -1;
 	
-	printf( "\tident %06x, frag type %d,"
+	printf( "ident %06x, frag type %d,"
 		" data type %d, pkts %02d, size %d\n", xr->bitfield.cbident,
 		xr->bitfield.frag_type, xr->bitfield.data_type,
 		xr->bitfield.pkts, length);
@@ -409,7 +409,7 @@
 	dst->packetno = src->packetno;
 
 #ifdef DEBUG
-  	printf(" bytes %ld bos %ld eos %ld gp %lld pno %lld\n",
+  	printf("- bytes %ld bos %ld eos %ld gp %lld pno %lld\n",
   	dst->bytes, dst->b_o_s, dst->e_o_s, dst->granulepos, dst->packetno);
 #endif
 



More information about the commits mailing list