summaryrefslogtreecommitdiffstats
path: root/gst/multipart/multipartmux.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd@luon.net>2006-07-28 16:17:17 +0000
committerWim Taymans <wim.taymans@gmail.com>2006-07-28 16:17:17 +0000
commit4441dc23ee2a222b947dd001d31728064ca91ad3 (patch)
tree79c1e5a6d920571189cf5bf3b7c0554904e2f43d /gst/multipart/multipartmux.c
parentda5c3416e7f3f518e6dca76179914186131bd65c (diff)
gst/multipart/multipartdemux.c: Uses GstAdapter instead of own buffering.
Original commit message from CVS: Patch by: Sjoerd Simons <sjoerd at luon dot net> * gst/multipart/multipartdemux.c: (gst_multipart_demux_base_init), (gst_multipart_demux_class_init), (gst_multipart_demux_init), (gst_multipart_demux_finalize), (get_line_end), (multipart_parse_header), (multipart_find_boundary), (gst_multipart_demux_chain), (gst_multipart_demux_change_state), (gst_multipart_set_property), (gst_multipart_get_property): Uses GstAdapter instead of own buffering. Actually parses the mime-type correctly (In tests the mime-type was always "" with the old version). Uses the Content-length header if available to speed up things. Reliably autoscans the boundary name by default. Fixes #349068. * gst/multipart/multipartmux.c: (gst_multipart_mux_collected): Don't start the stream with a \n.
Diffstat (limited to 'gst/multipart/multipartmux.c')
-rw-r--r--gst/multipart/multipartmux.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gst/multipart/multipartmux.c b/gst/multipart/multipartmux.c
index 1cc61a9a..bc79fab5 100644
--- a/gst/multipart/multipartmux.c
+++ b/gst/multipart/multipartmux.c
@@ -445,6 +445,8 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
size_t newlen, headerlen;
GstBuffer *newbuf = NULL;
GstStructure *structure = NULL;
+ guint8 *data;
+ guint datasize;
GST_DEBUG_OBJECT (mux, "all pads are collected");
@@ -483,11 +485,14 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
goto beach;
}
- header = g_strdup_printf ("\n--%s\nContent-type: %s\n\n",
+ header = g_strdup_printf ("--%s\nContent-type: %s\n\n",
mux->boundary, gst_structure_get_name (structure));
+ datasize = GST_BUFFER_SIZE (best->buffer);
+
headerlen = strlen (header);
- newlen = headerlen + GST_BUFFER_SIZE (best->buffer);
+ /* header, data, trailing \n */
+ newlen = headerlen + datasize + 1;
ret =
gst_pad_alloc_buffer_and_set_caps (mux->srcpad, GST_BUFFER_OFFSET_NONE,
@@ -498,9 +503,13 @@ gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
goto beach;
}
- memcpy (GST_BUFFER_DATA (newbuf), header, headerlen);
- memcpy (GST_BUFFER_DATA (newbuf) + headerlen,
- GST_BUFFER_DATA (best->buffer), GST_BUFFER_SIZE (best->buffer));
+ data = GST_BUFFER_DATA (newbuf);
+
+ memcpy (data, header, headerlen);
+ memcpy (data + headerlen, GST_BUFFER_DATA (best->buffer), datasize);
+
+ /* trailing \n */
+ data[headerlen + datasize] = '\n';
gst_buffer_stamp (newbuf, best->buffer);
GST_BUFFER_OFFSET (newbuf) = mux->offset;