diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-06-05 12:17:26 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2012-06-06 10:31:43 +0200 |
commit | c195a015e1c9062f7a3a6d0b61baace15fce9207 (patch) | |
tree | 40f2e3cb0fec71828dfb4a5c2f6dbb834f331f89 /gst/mpegtsmux | |
parent | ec109c390f452e0185b9547aa1227a63a2ca5326 (diff) | |
download | gstreamer-plugins-bad-c195a015e1c9062f7a3a6d0b61baace15fce9207.tar.gz |
mpegtsmux: also properly reset and free pad data
Diffstat (limited to 'gst/mpegtsmux')
-rw-r--r-- | gst/mpegtsmux/mpegtsmux.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index 54cad30cc..bc36f4686 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -252,8 +252,36 @@ mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class) } static void +mpegtsmux_pad_reset (MpegTsPadData * pad_data) +{ + pad_data->pid = 0; + pad_data->last_ts = GST_CLOCK_TIME_NONE; + pad_data->cur_ts = GST_CLOCK_TIME_NONE; + pad_data->prog_id = -1; + pad_data->eos = FALSE; + + if (pad_data->free_func) + pad_data->free_func (pad_data->prepare_data); + pad_data->prepare_data = NULL; + pad_data->prepare_func = NULL; + pad_data->free_func = NULL; + + if (pad_data->queued_buf) + gst_buffer_replace (&pad_data->queued_buf, NULL); + + if (pad_data->codec_data) + gst_buffer_replace (&pad_data->codec_data, NULL); + + /* reference owned elsewhere */ + pad_data->stream = NULL; + pad_data->prog = NULL; +} + +static void mpegtsmux_reset (MpegTsMux * mux, gboolean alloc) { + GSList *walk; + mux->first = TRUE; mux->last_flow_ret = GST_FLOW_OK; mux->first_pcr = TRUE; @@ -286,6 +314,11 @@ mpegtsmux_reset (MpegTsMux * mux, gboolean alloc) gst_event_replace (&mux->force_key_unit_event, NULL); gst_buffer_replace (&mux->out_buffer, NULL); + GST_COLLECT_PADS2_STREAM_LOCK (mux->collect); + for (walk = mux->collect->data; walk != NULL; walk = g_slist_next (walk)) + mpegtsmux_pad_reset ((MpegTsPadData *) walk->data); + GST_COLLECT_PADS2_STREAM_UNLOCK (mux->collect); + if (alloc) { mux->tsmux = tsmux_new (); tsmux_set_write_func (mux->tsmux, new_packet_cb, mux); @@ -1008,19 +1041,14 @@ mpegtsmux_request_new_pad (GstElement * element, pad = gst_pad_new_from_template (templ, pad_name); g_free (pad_name); - pad_data = (MpegTsPadData *) gst_collect_pads2_add_pad (mux->collect, pad, - sizeof (MpegTsPadData)); + pad_data = (MpegTsPadData *) + gst_collect_pads2_add_pad_full (mux->collect, pad, sizeof (MpegTsPadData), + (GstCollectData2DestroyNotify) (mpegtsmux_pad_reset), TRUE); if (pad_data == NULL) goto pad_failure; + mpegtsmux_pad_reset (pad_data); pad_data->pid = pid; - pad_data->last_ts = GST_CLOCK_TIME_NONE; - pad_data->codec_data = NULL; - pad_data->prepare_data = NULL; - pad_data->prepare_func = NULL; - pad_data->free_func = NULL; - pad_data->prog_id = -1; - pad_data->prog = NULL; if (G_UNLIKELY (!gst_element_add_pad (element, pad))) goto could_not_add; |