oggmux: factor the header packet creation code
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Wed, 17 Aug 2011 16:39:18 +0000 (17:39 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 18 Aug 2011 09:13:59 +0000 (11:13 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=656775

ext/ogg/gstoggmux.c

index 60e92a0..40348ac 100644 (file)
@@ -1116,6 +1116,19 @@ gst_ogg_mux_set_header_on_caps (GstCaps * caps, GList * buffers)
   return caps;
 }
 
+static void
+create_header_packet (ogg_packet * packet, GstBuffer * buf, GstOggPadData * pad)
+{
+  packet->packet = GST_BUFFER_DATA (buf);
+  packet->bytes = GST_BUFFER_SIZE (buf);
+  packet->granulepos = 0;
+  /* mark BOS and packet number */
+  packet->b_o_s = (pad->packetno == 0);
+  packet->packetno = pad->packetno++;
+  /* mark EOS */
+  packet->e_o_s = 0;
+}
+
 /*
  * For each pad we need to write out one (small) header in one
  * page that allows decoders to identify the type of the stream.
@@ -1196,14 +1209,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
     }
 
     /* create a packet from the buffer */
-    packet.packet = GST_BUFFER_DATA (buf);
-    packet.bytes = GST_BUFFER_SIZE (buf);
-    packet.granulepos = 0;
-    /* mark BOS and packet number */
-    packet.b_o_s = (pad->packetno == 0);
-    packet.packetno = pad->packetno++;
-    /* mark EOS */
-    packet.e_o_s = 0;
+    create_header_packet (&packet, buf, pad);
 
     /* swap the packet in */
     ogg_stream_packetin (&pad->map.stream, &packet);
@@ -1263,14 +1269,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
       hwalk = hwalk->next;
 
       /* create a packet from the buffer */
-      packet.packet = GST_BUFFER_DATA (buf);
-      packet.bytes = GST_BUFFER_SIZE (buf);
-      packet.granulepos = 0;
-      /* mark BOS and packet number */
-      packet.b_o_s = (pad->packetno == 0);
-      packet.packetno = pad->packetno++;
-      /* mark EOS */
-      packet.e_o_s = 0;
+      create_header_packet (&packet, buf, pad);
 
       /* swap the packet in */
       ogg_stream_packetin (&pad->map.stream, &packet);