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

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Mon Feb 7 13:45:30 PST 2005


Author: giles
Date: 2005-02-07 13:45:30 -0800 (Mon, 07 Feb 2005)
New Revision: 8864

Modified:
   trunk/xiph-rtp/vorbisrtp.c
Log:
Send the three vorbis header packets inline verbatim. For convenience
of structure we also remember them, which comes in handy if we ever
want to elide chaining boundaries.


Modified: trunk/xiph-rtp/vorbisrtp.c
===================================================================
--- trunk/xiph-rtp/vorbisrtp.c	2005-02-07 21:19:28 UTC (rev 8863)
+++ trunk/xiph-rtp/vorbisrtp.c	2005-02-07 21:45:30 UTC (rev 8864)
@@ -96,21 +96,6 @@
 } VorbisBitfields;
 
 /*****************************************************************************/
-/*  Vorbis configuration packet                                              */
-/*****************************************************************************/
-
-struct VorbisConfig {
-    unsigned int bsz0:4;
-    unsigned int bsz1:4;
-    unsigned char channels;
-    unsigned long version:32;
-    unsigned long samplerate:32;
-    unsigned long bitratemax:32;
-    unsigned long bitratenom:32;
-    unsigned long bitratemin:32;
-} VorbisConfig;
-
-/*****************************************************************************/
 /*  RTP header                                                               */
 /*****************************************************************************/
 
@@ -244,25 +229,6 @@
 }
 
 /*****************************************************************************/
-/*  Creates and send configuration packet                                    */
-/*****************************************************************************/
-
-void configpacket (struct VorbisConfig *Config, int bsz0, int bsz1, vorbis_info vi) 
-{
-    Config -> bsz0 = bsz0;
-    Config -> bsz1 = bsz1;
-    Config -> channels = htons (vi.channels);
-    Config -> version = htonl (vi.version);
-    Config -> samplerate = htonl (vi.rate);
-    Config -> bitratemin = htonl (vi.bitrate_lower);
-    Config -> bitratenom = htonl (vi.bitrate_nominal);
-    Config -> bitratemax = htonl (vi.bitrate_upper);
-
-    creatertp ((unsigned char*) Config, 22, vi.rate, &VorbisBitfields, 1);
-    progressmarker (6);
-}
-
-/*****************************************************************************/
 /*  Creates RTP socket                                                       */
 /*****************************************************************************/
 
@@ -577,13 +543,31 @@
 }
 
 /*****************************************************************************/
+/*  Duplicates an Ogg packet                                                 */
+/*****************************************************************************/
+int ogg_copy_packet(ogg_packet *dst, ogg_packet *src)
+{
+  dst->packet = malloc(src->bytes);
+  memcpy(dst->packet, src->packet, src->bytes);
+  dst->bytes = src->bytes;
+  dst->b_o_s = src->b_o_s;
+  dst->e_o_s = src->e_o_s;
 
+  dst->granulepos = src->granulepos;
+  dst->packetno = src->packetno;
+
+  return 0;
+}
+
+/*****************************************************************************/
+
 int main (int argc, char **argv) 
 {
     ogg_sync_state oy;
     ogg_stream_state os;
     ogg_page og;
     ogg_packet op;
+    ogg_packet header[3];
   
     vorbis_info vi; 
 
@@ -720,6 +704,8 @@
         exit (1);
     }
 
+    ogg_copy_packet(&(header[i]), &op);
+
 /*===========================================================================*/
 /*  Process comment and codebook headers                                     */
 /*===========================================================================*/
@@ -747,6 +733,8 @@
 
                     vorbis_synthesis_headerin (&vi, &vc, &op);
                     i++;
+
+                    ogg_copy_packet(&(header[i]), &op);
                 }
             }
         }
@@ -781,16 +769,16 @@
     fprintf (stdout, "||  Processing\n||  ");
 
 /*===========================================================================*/
-/*  Create configuration header                                              */
+/*  Send the three headers inline                                            */
 /*===========================================================================*/
 
-    configpacket (&VorbisConfig, vorbis_info_blocksize (&vi, 0), vorbis_info_blocksize (&vi, 1), vi);
+    creatertp(header[0].packet, header[0].bytes, vi.rate, &VorbisBitfields, 6);
+    progressmarker (6);
 
-/*===========================================================================*/
-/*  Create and send codebook                                                 */
-/*===========================================================================*/
+    creatertp(header[1].packet, header[1].bytes, vi.rate, &VorbisBitfields, 3);
+    progressmarker (3);
 
-    creatertp ((char*) &vd, sizeof (vd), vi.rate, &VorbisBitfields, 2);
+    creatertp(header[2].packet, header[2].bytes, vi.rate, &VorbisBitfields, 4);
     progressmarker (4);
 
 /*===========================================================================*/
@@ -834,6 +822,10 @@
         }
     }
 
+    ogg_packet_clear (&(header[0]));
+    ogg_packet_clear (&(header[1]));
+    ogg_packet_clear (&(header[2]));
+
     ogg_stream_clear (&os);
   
     vorbis_block_clear (&vb);



More information about the commits mailing list