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

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Sun Feb 6 23:35:59 PST 2005


Author: giles
Date: 2005-02-06 23:35:58 -0800 (Sun, 06 Feb 2005)
New Revision: 8853

Modified:
   trunk/xiph-rtp/vorbisrtp.c
Log:
Make the maximum vorbis data payload size a local variable. This will
eventually become the path MTU minus the overhead when we go to 16
bit payload sizes.


Modified: trunk/xiph-rtp/vorbisrtp.c
===================================================================
--- trunk/xiph-rtp/vorbisrtp.c	2005-02-07 07:27:04 UTC (rev 8852)
+++ trunk/xiph-rtp/vorbisrtp.c	2005-02-07 07:35:58 UTC (rev 8853)
@@ -362,6 +362,8 @@
     unsigned char framesize;
     unsigned char *packet;
 
+    const unsigned int max_payload = 256;
+
     static int stacksize;
     static int stackcount;
     static unsigned char* framestack;
@@ -373,7 +375,7 @@
 /*    vorbheader -> cbident = htonl (0xc0deb00c); */
 
 /*===========================================================================*/
-/*  Set sleeptime value (todo: this should use the granulepos)                                                     */
+/*  Set sleeptime value (todo: this should use the granulepos)               */
 /*===========================================================================*/
 
     sleeptime = ((1 / (float) bitrate) * 1000000);
@@ -382,32 +384,32 @@
 /*  Frame fragmentation                                                      */
 /*===========================================================================*/
 
-    if (length > 256) {
+    if (length > max_payload) {
         cont = 0;
         frag = 1;
-        while (length > 256) {        
+        while (length > max_payload) {        
             /*  Set Vorbis header flags  */
             vorbheader -> continuation = cont;
             vorbheader -> fragment = frag;
             vorbheader -> reserved = 0;
             vorbheader -> pkts = 0;
 
-            packet = malloc (262);
+            packet = malloc (max_payload + 6);
 
-            makevorbisheader (packet, 262, vorbheader);
+            makevorbisheader (packet, max_payload + 6, vorbheader);
             memcpy (packet + 5, &framesize, 1);
-            memmove (packet + 6, vorbdata, 256);
+            memmove (packet + 6, vorbdata, max_payload);
 
             /*  Swap RTP headers from host to network order  */
             RTPHeaders.sequence = htons (RTPHeaders.sequence);
 
-            sendrtp (&RTPHeaders, rtpsocket, &rtpsock, packet, 262);
+            sendrtp (&RTPHeaders, rtpsocket, &rtpsock, packet, max_payload + 6);
 
             /*  Swap headers back to host order  */
             RTPHeaders.sequence = ntohs (RTPHeaders.sequence);
 
-            length -= 256;
-            position += 256;
+            length -= max_payload;
+            position += max_payload;
             cont = 1;
             frag = 0;
 
@@ -456,8 +458,8 @@
 /*  Frame packing.  Used only for type 0 packets (raw Vorbis data)           */
 /*===========================================================================*/
 
-    if (length < 256 && type == 0) {
-        if (length + stacksize < 256 && stackcount < 15) {
+    if (length < max_payload && type == 0) {
+        if (length + stacksize < max_payload && stackcount < 15) {
 
             framestack = realloc (framestack, (stacksize + (length + 1)));
 
@@ -467,7 +469,7 @@
             stacksize += (length + 1);
         }  
 
-        if (length + stacksize > 256 || stackcount > 15) {
+        if (length + stacksize > max_payload || stackcount > 15) {
 
             /*  Set Vorbis header flags  */
             vorbheader -> continuation = 0;
@@ -509,10 +511,10 @@
     } 
 
 /*===========================================================================*/
-/*  Send header packets (under 256 octets) - No Packing                      */
+/*  Send header packets (under max_payload octets) - No Packing              */
 /*===========================================================================*/
 
-    else if (length < 256) {
+    else if (length < max_payload) {
 
         /*  Set Vorbis header flags  */
         vorbheader -> continuation = 0;



More information about the commits mailing list