diff --git a/gst/mpegtsmux/gstbasetsmux.c b/gst/mpegtsmux/gstbasetsmux.c index fd6138af8a..50009af4b2 100644 --- a/gst/mpegtsmux/gstbasetsmux.c +++ b/gst/mpegtsmux/gstbasetsmux.c @@ -1325,6 +1325,26 @@ write_fail: } /* GstElement implementation */ +static gboolean +gst_base_ts_mux_has_pad_with_pid (GstBaseTsMux * mux, guint16 pid) +{ + GList *l; + gboolean res = FALSE; + + GST_OBJECT_LOCK (mux); + + for (l = GST_ELEMENT_CAST (mux)->sinkpads; l; l = l->next) { + GstBaseTsMuxPad *tpad = GST_BASE_TS_MUX_PAD (l->data); + + if (tpad->pid == pid) { + res = TRUE; + break; + } + } + + GST_OBJECT_UNLOCK (mux); + return res; +} static GstPad * gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, @@ -1342,7 +1362,9 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, if (pid < TSMUX_START_ES_PID) goto invalid_stream_pid; } else { - pid = tsmux_get_new_pid (mux->tsmux); + do { + pid = tsmux_get_new_pid (mux->tsmux); + } while (gst_base_ts_mux_has_pad_with_pid (mux, pid)); } pad = (GstPad *)