Commit f88b4df4 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵 Committed by Tim-Philipp Müller
Browse files

tsmux: Recheck existing pad PIDs when requesting a new pad with a random pid

Previously pads might have been requested already (e.g. in NULL state),
then reset was called (e.g. because changing state) and then a new pad
was requested. Resetting is re-creating the internal muxer object and as
such resetting the pid counter, so the next requested pad would get the
same pid as the first requested pad which then leads to collisions.

Part-of: <!2357>
parent 13ef9840
......@@ -1263,6 +1263,26 @@ write_fail:
/* GstElement implementation */
static gboolean
gst_base_ts_mux_has_pad_with_pid (GstBaseTsMux * mux, guint16 pid)
GList *l;
gboolean res = FALSE;
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;
return res;
static GstPad *
gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
......@@ -1280,7 +1300,9 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
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 *)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment