mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
gst/multipart/: Small updates, fix a memleak
Original commit message from CVS: * gst/multipart/multipartdemux.c: (gst_multipart_demux_base_init), (gst_multipart_find_pad_by_mime), (gst_multipart_demux_chain), (gst_multipart_demux_plugin_init): * gst/multipart/multipartmux.c: (gst_multipart_mux_class_init), (gst_multipart_mux_init), (gst_multipart_mux_loop), (gst_multipart_mux_change_state): Small updates, fix a memleak
This commit is contained in:
parent
ef2468c353
commit
6a59b1923e
3 changed files with 66 additions and 70 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2004-06-07 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/multipart/multipartdemux.c: (gst_multipart_demux_base_init),
|
||||||
|
(gst_multipart_find_pad_by_mime), (gst_multipart_demux_chain),
|
||||||
|
(gst_multipart_demux_plugin_init):
|
||||||
|
* gst/multipart/multipartmux.c: (gst_multipart_mux_class_init),
|
||||||
|
(gst_multipart_mux_init), (gst_multipart_mux_loop),
|
||||||
|
(gst_multipart_mux_change_state):
|
||||||
|
Small updates, fix a memleak
|
||||||
|
|
||||||
2004-06-07 Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
|
2004-06-07 Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
|
||||||
|
|
||||||
* configure.ac: OSS portability
|
* configure.ac: OSS portability
|
||||||
|
|
|
@ -40,7 +40,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_multipart_demux_debug);
|
||||||
typedef struct _GstMultipartDemux GstMultipartDemux;
|
typedef struct _GstMultipartDemux GstMultipartDemux;
|
||||||
typedef struct _GstMultipartDemuxClass GstMultipartDemuxClass;
|
typedef struct _GstMultipartDemuxClass GstMultipartDemuxClass;
|
||||||
|
|
||||||
static gchar *toFind = "--ThisRandomString\nContent-type: "; //image/jpeg\n\n";
|
static gchar *toFind = "--ThisRandomString\nContent-type: ";
|
||||||
static gint toFindLen;
|
static gint toFindLen;
|
||||||
|
|
||||||
/* all information needed for one multipart stream */
|
/* all information needed for one multipart stream */
|
||||||
|
@ -272,7 +272,7 @@ gst_multipart_demux_chain (GstPad * pad, GstData * buffer)
|
||||||
// find \n
|
// find \n
|
||||||
while (multipart->scanpos < multipart->bufsize) {
|
while (multipart->scanpos < multipart->bufsize) {
|
||||||
if (multipart->buffer[multipart->scanpos] == '\n') {
|
if (multipart->buffer[multipart->scanpos] == '\n') {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
multipart->scanpos++;
|
multipart->scanpos++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,12 +61,6 @@ struct _GstMultipartMux
|
||||||
GSList *sinkpads;
|
GSList *sinkpads;
|
||||||
gint numpads;
|
gint numpads;
|
||||||
|
|
||||||
/* the pad we are currently pulling from to fill a page */
|
|
||||||
GstMultipartPad *pulling;
|
|
||||||
|
|
||||||
/* next timestamp for the page */
|
|
||||||
GstClockTime next_ts;
|
|
||||||
|
|
||||||
/* offset in stream */
|
/* offset in stream */
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
|
|
||||||
|
@ -222,7 +216,6 @@ gst_multipart_mux_init (GstMultipartMux * multipart_mux)
|
||||||
GST_FLAG_SET (GST_ELEMENT (multipart_mux), GST_ELEMENT_EVENT_AWARE);
|
GST_FLAG_SET (GST_ELEMENT (multipart_mux), GST_ELEMENT_EVENT_AWARE);
|
||||||
|
|
||||||
multipart_mux->sinkpads = NULL;
|
multipart_mux->sinkpads = NULL;
|
||||||
multipart_mux->pulling = NULL;
|
|
||||||
multipart_mux->boundary = g_strdup (DEFAULT_BOUNDARY);
|
multipart_mux->boundary = g_strdup (DEFAULT_BOUNDARY);
|
||||||
multipart_mux->negotiated = FALSE;
|
multipart_mux->negotiated = FALSE;
|
||||||
|
|
||||||
|
@ -468,75 +461,70 @@ static void
|
||||||
gst_multipart_mux_loop (GstElement * element)
|
gst_multipart_mux_loop (GstElement * element)
|
||||||
{
|
{
|
||||||
GstMultipartMux *mux;
|
GstMultipartMux *mux;
|
||||||
|
GstMultipartPad *pad;
|
||||||
|
GstBuffer *newbuf, *buf;
|
||||||
|
gchar *header;
|
||||||
|
gint headerlen;
|
||||||
|
gint newlen;
|
||||||
|
|
||||||
mux = GST_MULTIPART_MUX (element);
|
mux = GST_MULTIPART_MUX (element);
|
||||||
|
|
||||||
/* if we don't know which pad to pull on, find one */
|
/* we don't know which pad to pull on, find one */
|
||||||
if (mux->pulling == NULL) {
|
pad = gst_multipart_mux_queue_pads (mux);
|
||||||
mux->pulling = gst_multipart_mux_queue_pads (mux);
|
if (pad == NULL) {
|
||||||
/* remember timestamp of first buffer for this new pad */
|
/* no pad to pull on, send EOS */
|
||||||
if (mux->pulling != NULL) {
|
if (GST_PAD_IS_USABLE (mux->srcpad))
|
||||||
mux->next_ts = GST_BUFFER_TIMESTAMP (mux->pulling->buffer);
|
gst_pad_push (mux->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
||||||
} else {
|
gst_element_set_eos (element);
|
||||||
/* no pad to pull on, send EOS */
|
return;
|
||||||
if (GST_PAD_IS_USABLE (mux->srcpad))
|
}
|
||||||
gst_pad_push (mux->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
|
|
||||||
gst_element_set_eos (element);
|
/* now see if we have a buffer */
|
||||||
|
buf = pad->buffer;
|
||||||
|
if (buf == NULL) {
|
||||||
|
/* no buffer, get one */
|
||||||
|
buf = gst_multipart_mux_next_buffer (pad);
|
||||||
|
if (buf == NULL) {
|
||||||
|
/* data exhausted on this pad (EOS) */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->pulling != NULL) {
|
/* FIXME, negotiated is not set to FALSE properly after
|
||||||
GstMultipartPad *pad = mux->pulling;
|
* reconnect */
|
||||||
GstBuffer *newbuf, *buf;
|
if (!mux->negotiated) {
|
||||||
gchar *header;
|
GstCaps *newcaps;
|
||||||
gint headerlen;
|
|
||||||
|
|
||||||
/* now see if we have a buffer */
|
newcaps = gst_caps_new_simple ("multipart/x-mixed-replace",
|
||||||
buf = pad->buffer;
|
"boundary", G_TYPE_STRING, mux->boundary, NULL);
|
||||||
if (buf == NULL) {
|
|
||||||
/* no buffer, get one */
|
if (GST_PAD_LINK_FAILED (gst_pad_try_set_caps (mux->srcpad, newcaps))) {
|
||||||
buf = gst_multipart_mux_next_buffer (pad);
|
GST_ELEMENT_ERROR (mux, CORE, NEGOTIATION, (NULL), (NULL));
|
||||||
/* data exhausted on this pad (EOS) */
|
return;
|
||||||
if (buf == NULL) {
|
|
||||||
/* stop pulling from the pad */
|
|
||||||
mux->pulling = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mux->negotiated = TRUE;
|
||||||
/* FIXME, negotiated is not set to FALSE properly after
|
|
||||||
* reconnect */
|
|
||||||
if (!mux->negotiated) {
|
|
||||||
GstCaps *newcaps;
|
|
||||||
|
|
||||||
newcaps = gst_caps_new_simple ("multipart/x-mixed-replace",
|
|
||||||
"boundary", G_TYPE_STRING, mux->boundary, NULL);
|
|
||||||
|
|
||||||
if (GST_PAD_LINK_FAILED (gst_pad_try_set_caps (mux->srcpad, newcaps))) {
|
|
||||||
GST_ELEMENT_ERROR (mux, CORE, NEGOTIATION, (NULL), (NULL));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mux->negotiated = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
header = g_strdup_printf ("\n--%s\nContent-type: %s\n\n",
|
|
||||||
mux->boundary, pad->mimetype);
|
|
||||||
headerlen = strlen (header);
|
|
||||||
newbuf =
|
|
||||||
gst_pad_alloc_buffer (mux->srcpad, GST_BUFFER_OFFSET_NONE, headerlen);
|
|
||||||
GST_BUFFER_DATA (newbuf) = header;
|
|
||||||
GST_BUFFER_SIZE (newbuf) = headerlen;
|
|
||||||
GST_BUFFER_TIMESTAMP (newbuf) = GST_BUFFER_TIMESTAMP (buf);
|
|
||||||
gst_pad_push (mux->srcpad, GST_DATA (newbuf));
|
|
||||||
gst_pad_push (mux->srcpad, GST_DATA (buf));
|
|
||||||
|
|
||||||
pad->buffer = NULL;
|
|
||||||
|
|
||||||
/* we're done pulling on this pad, make sure to choose a new
|
|
||||||
* pad for pulling in the next iteration */
|
|
||||||
mux->pulling = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header = g_strdup_printf ("\n--%s\nContent-type: %s\n\n",
|
||||||
|
mux->boundary, pad->mimetype);
|
||||||
|
headerlen = strlen (header);
|
||||||
|
newlen = headerlen + GST_BUFFER_SIZE (buf);
|
||||||
|
newbuf = gst_pad_alloc_buffer (mux->srcpad, GST_BUFFER_OFFSET_NONE, newlen);
|
||||||
|
|
||||||
|
memcpy (GST_BUFFER_DATA (newbuf), header, headerlen);
|
||||||
|
memcpy (GST_BUFFER_DATA (newbuf) + headerlen,
|
||||||
|
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||||
|
GST_BUFFER_TIMESTAMP (newbuf) = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf);
|
||||||
|
GST_BUFFER_OFFSET (newbuf) = mux->offset;
|
||||||
|
|
||||||
|
g_free (header);
|
||||||
|
|
||||||
|
mux->offset += newlen;
|
||||||
|
|
||||||
|
gst_pad_push (mux->srcpad, GST_DATA (newbuf));
|
||||||
|
|
||||||
|
pad->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -589,9 +577,7 @@ gst_multipart_mux_change_state (GstElement * element)
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_NULL_TO_READY:
|
case GST_STATE_NULL_TO_READY:
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
case GST_STATE_READY_TO_PAUSED:
|
||||||
multipart_mux->next_ts = 0;
|
|
||||||
multipart_mux->offset = 0;
|
multipart_mux->offset = 0;
|
||||||
multipart_mux->pulling = NULL;
|
|
||||||
multipart_mux->negotiated = FALSE;
|
multipart_mux->negotiated = FALSE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
|
|
Loading…
Reference in a new issue