diff --git a/gst/mpegtsmux/gstbasetsmux.c b/gst/mpegtsmux/gstbasetsmux.c index 0123f61769..94940c8cf5 100644 --- a/gst/mpegtsmux/gstbasetsmux.c +++ b/gst/mpegtsmux/gstbasetsmux.c @@ -270,11 +270,21 @@ gst_base_ts_mux_set_header_on_caps (GstBaseTsMux * mux) gst_caps_unref (caps); } +static gboolean +steal_si_section (GstMpegtsSectionType * type, TsMuxSection * section, + TsMux * mux) +{ + g_hash_table_insert (mux->si_sections, type, section); + + return TRUE; +} + static void gst_base_ts_mux_reset (GstBaseTsMux * mux, gboolean alloc) { GstBuffer *buf; GstBaseTsMuxClass *klass = GST_BASE_TS_MUX_GET_CLASS (mux); + GHashTable *si_sections = NULL; mux->first = TRUE; mux->last_flow_ret = GST_FLOW_OK; @@ -290,6 +300,9 @@ gst_base_ts_mux_reset (GstBaseTsMux * mux, gboolean alloc) gst_adapter_clear (mux->out_adapter); if (mux->tsmux) { + if (mux->tsmux->si_sections) + si_sections = g_hash_table_ref (mux->tsmux->si_sections); + tsmux_free (mux->tsmux); mux->tsmux = NULL; } @@ -309,8 +322,16 @@ gst_base_ts_mux_reset (GstBaseTsMux * mux, gboolean alloc) g_assert (klass->create_ts_mux); mux->tsmux = klass->create_ts_mux (mux); + + /* Preserve user-specified sections across resets */ + if (si_sections) + g_hash_table_foreach_steal (si_sections, (GHRFunc) steal_si_section, + mux->tsmux); } + if (si_sections) + g_hash_table_unref (si_sections); + if (klass->reset) klass->reset (mux); } diff --git a/gst/mpegtsmux/tsmux/tsmux.c b/gst/mpegtsmux/tsmux/tsmux.c index 290da032d6..ea5f512ed7 100644 --- a/gst/mpegtsmux/tsmux/tsmux.c +++ b/gst/mpegtsmux/tsmux/tsmux.c @@ -382,7 +382,7 @@ tsmux_free (TsMux * mux) g_list_free (mux->streams); /* Free SI table sections */ - g_hash_table_destroy (mux->si_sections); + g_hash_table_unref (mux->si_sections); g_slice_free (TsMux, mux); }