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

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Mon Feb 7 10:50:48 PST 2005


Author: giles
Date: 2005-02-07 10:50:47 -0800 (Mon, 07 Feb 2005)
New Revision: 8858

Modified:
   trunk/xiph-rtp/vorbisrtp-client.c
   trunk/xiph-rtp/vorbisrtp.c
Log:
Fix a UMR and an off-by-one error in the packed packet case. The test
client is now parsing all the header fields for these packet types.


Modified: trunk/xiph-rtp/vorbisrtp-client.c
===================================================================
--- trunk/xiph-rtp/vorbisrtp-client.c	2005-02-07 10:01:50 UTC (rev 8857)
+++ trunk/xiph-rtp/vorbisrtp-client.c	2005-02-07 18:50:47 UTC (rev 8858)
@@ -117,6 +117,7 @@
   F = (data[offset] & 0x40) >> 6;
   R = (data[offset] & 0x20) >> 5;
   pkts = (data[offset] & 0x1F);
+  offset++;
 
   fprintf(out, " Vorbis payload ident 0x%08x  C:%d F:%d R:%d",
     ident, C, F, R);
@@ -129,17 +130,19 @@
     fprintf(out, " frag cont.\n");
   else /* C == 1 && F == 1 */
     fprintf(out, " frag end\n");
-  offset++;
 
   for (i = 0; i < pkts; i++) {
-    length = data[offset++];
-    fprintf(out, "  data: %d bytes in block %d\n", length, i);
-    offset += length;
     if (offset >= len) {
       fprintf(stderr, "payload length overflow. corrupt packet?\n");
       return -1;
     }
+    length = data[offset++];
+    fprintf(out, "  data: %d bytes in block %d\n", length, i);
+    offset += length;
   }
+  if (len - offset > 0)
+    fprintf(out, "  %d unused bytes at the end of the packet!\n", 
+      len - offset);
 
   return 0;
 }

Modified: trunk/xiph-rtp/vorbisrtp.c
===================================================================
--- trunk/xiph-rtp/vorbisrtp.c	2005-02-07 10:01:50 UTC (rev 8857)
+++ trunk/xiph-rtp/vorbisrtp.c	2005-02-07 18:50:47 UTC (rev 8858)
@@ -364,9 +364,10 @@
 
     const unsigned int max_payload = 256;
 
-    static int stacksize;
-    static int stackcount;
-    static unsigned char* framestack;
+    /* we accumulate short frames between calls */
+    static int stacksize = 0;
+    static int stackcount = 0;
+    static unsigned char* framestack = NULL;
 
 /*===========================================================================*/
 /*  Test Codebook Ident (used for debug)                                     */
@@ -467,7 +468,7 @@
             memcpy (framestack + (stacksize + 1), vorbdata, length);
             stackcount++;
             stacksize += (length + 1);
-        }  
+        }
 
         if (length + stacksize > max_payload || stackcount > 15) {
 
@@ -477,16 +478,16 @@
             vorbheader -> reserved = 0;
             vorbheader -> pkts = stackcount;
 
-            packet = malloc (stacksize + 6);
+            packet = malloc (stacksize + 5);
 
-            makevorbisheader (packet, stacksize + 6, vorbheader);
-            memmove (packet + 6, framestack, stacksize);
+            makevorbisheader (packet, stacksize + 5, vorbheader);
+            memcpy (packet + 5, framestack, stacksize);
 
             /*  Swap RTP headers from host to network order  */
             RTPHeaders.sequence = htons (RTPHeaders.sequence);
             RTPHeaders.timestamp = htonl (RTPHeaders.timestamp);
 
-            sendrtp (&RTPHeaders, rtpsocket, &rtpsock, packet, stacksize + 6);
+            sendrtp (&RTPHeaders, rtpsocket, &rtpsock, packet, stacksize + 5);
 
             /*  Swap headers back to host order  */
             RTPHeaders.sequence = htons (RTPHeaders.sequence);



More information about the commits mailing list