mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
qtdemux: fix mem leaks and prevent excessive buffering in push based mode
This commit is contained in:
parent
b39d090a49
commit
21fc435c71
1 changed files with 18 additions and 9 deletions
|
@ -2121,6 +2121,10 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
|
||||||
|
|
||||||
gst_adapter_push (demux->adapter, inbuf);
|
gst_adapter_push (demux->adapter, inbuf);
|
||||||
|
|
||||||
|
/* we never really mean to buffer that much */
|
||||||
|
if (demux->neededbytes == -1)
|
||||||
|
goto eos;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (demux, "pushing in inbuf %p, neededbytes:%u, available:%u",
|
GST_DEBUG_OBJECT (demux, "pushing in inbuf %p, neededbytes:%u, available:%u",
|
||||||
inbuf, demux->neededbytes, gst_adapter_available (demux->adapter));
|
inbuf, demux->neededbytes, gst_adapter_available (demux->adapter));
|
||||||
|
|
||||||
|
@ -2157,6 +2161,9 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
|
||||||
demux->state = QTDEMUX_STATE_MOVIE;
|
demux->state = QTDEMUX_STATE_MOVIE;
|
||||||
demux->neededbytes = next_entry_size (demux);
|
demux->neededbytes = next_entry_size (demux);
|
||||||
} else {
|
} else {
|
||||||
|
/* sanity check */
|
||||||
|
if (size > 10 * (2 << 20))
|
||||||
|
goto no_moov;
|
||||||
demux->state = QTDEMUX_STATE_BUFFER_MDAT;
|
demux->state = QTDEMUX_STATE_BUFFER_MDAT;
|
||||||
demux->neededbytes = size;
|
demux->neededbytes = size;
|
||||||
demux->mdatoffset = demux->offset;
|
demux->mdatoffset = demux->offset;
|
||||||
|
@ -2221,9 +2228,7 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
|
||||||
demux->mdatoffset);
|
demux->mdatoffset);
|
||||||
if (demux->mdatbuffer)
|
if (demux->mdatbuffer)
|
||||||
gst_buffer_unref (demux->mdatbuffer);
|
gst_buffer_unref (demux->mdatbuffer);
|
||||||
demux->mdatbuffer = gst_buffer_new ();
|
demux->mdatbuffer = gst_adapter_take_buffer (demux->adapter,
|
||||||
gst_buffer_set_data (demux->mdatbuffer,
|
|
||||||
gst_adapter_take (demux->adapter, demux->neededbytes),
|
|
||||||
demux->neededbytes);
|
demux->neededbytes);
|
||||||
GST_DEBUG_OBJECT (demux, "mdatbuffer starts with %" GST_FOURCC_FORMAT,
|
GST_DEBUG_OBJECT (demux, "mdatbuffer starts with %" GST_FOURCC_FORMAT,
|
||||||
GST_FOURCC_ARGS (QT_UINT32 (demux->mdatbuffer)));
|
GST_FOURCC_ARGS (QT_UINT32 (demux->mdatbuffer)));
|
||||||
|
@ -2235,7 +2240,6 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QTDEMUX_STATE_MOVIE:{
|
case QTDEMUX_STATE_MOVIE:{
|
||||||
guint8 *data;
|
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
QtDemuxStream *stream = NULL;
|
QtDemuxStream *stream = NULL;
|
||||||
int i = -1;
|
int i = -1;
|
||||||
|
@ -2274,15 +2278,13 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
|
||||||
0, GST_CLOCK_TIME_NONE, 0));
|
0, GST_CLOCK_TIME_NONE, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get data */
|
|
||||||
data = gst_adapter_take (demux->adapter, demux->neededbytes);
|
|
||||||
|
|
||||||
/* Put data in a buffer, set timestamps, caps, ... */
|
/* Put data in a buffer, set timestamps, caps, ... */
|
||||||
outbuf = gst_buffer_new ();
|
outbuf = gst_adapter_take_buffer (demux->adapter, demux->neededbytes);
|
||||||
gst_buffer_set_data (outbuf, data, demux->neededbytes);
|
|
||||||
GST_DEBUG_OBJECT (demux, "stream : %" GST_FOURCC_FORMAT,
|
GST_DEBUG_OBJECT (demux, "stream : %" GST_FOURCC_FORMAT,
|
||||||
GST_FOURCC_ARGS (stream->fourcc));
|
GST_FOURCC_ARGS (stream->fourcc));
|
||||||
|
|
||||||
|
g_return_val_if_fail (outbuf != NULL, GST_FLOW_ERROR);
|
||||||
|
|
||||||
if (stream->samples[stream->sample_index].pts_offset) {
|
if (stream->samples[stream->sample_index].pts_offset) {
|
||||||
demux->last_ts = stream->samples[stream->sample_index].timestamp;
|
demux->last_ts = stream->samples[stream->sample_index].timestamp;
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = demux->last_ts +
|
GST_BUFFER_TIMESTAMP (outbuf) = demux->last_ts +
|
||||||
|
@ -2358,6 +2360,13 @@ invalid_state:
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
no_moov:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (demux, STREAM, FAILED,
|
||||||
|
(NULL), ("no 'moov' atom withing first 10 MB"));
|
||||||
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue