diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2021-06-10 11:42:24 +0300 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-06-24 16:33:49 +0100 |
commit | f116788693b59a73f86d7dea0cb401ba07ba27e0 (patch) | |
tree | ab5cb5b961602146ba9b914f52308540c65b7b3e | |
parent | f88b4df4331bbd85cc2d76fd71763515fb173684 (diff) | |
download | gstreamer-plugins-bad-f116788693b59a73f86d7dea0cb401ba07ba27e0.tar.gz |
tsmux: When selecting random PIDs, name the pads according to those PIDs
Some elements will make use of the automatically generated names to
create new pads in future muxer instances, for example splitmuxsink.
Previously we would've created a pad with a random pid that would become
"sink_0", and then on a new muxer instance a pad "sink_0" and tsmux
would've then failed because 0 is not a valid PID.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2358>
-rw-r--r-- | gst/mpegtsmux/gstbasetsmux.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gst/mpegtsmux/gstbasetsmux.c b/gst/mpegtsmux/gstbasetsmux.c index 79c890d02..99172574c 100644 --- a/gst/mpegtsmux/gstbasetsmux.c +++ b/gst/mpegtsmux/gstbasetsmux.c @@ -1291,6 +1291,7 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, GstBaseTsMux *mux = GST_BASE_TS_MUX (element); gint pid = -1; GstPad *pad = NULL; + gchar *free_name = NULL; if (name != NULL && sscanf (name, "sink_%d", &pid) == 1) { if (tsmux_find_stream (mux->tsmux, pid)) @@ -1303,6 +1304,9 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, do { pid = tsmux_get_new_pid (mux->tsmux); } while (gst_base_ts_mux_has_pad_with_pid (mux, pid)); + + /* Name the pad correctly after the selected pid */ + name = free_name = g_strdup_printf ("sink_%d", pid); } pad = (GstPad *) @@ -1312,6 +1316,8 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, gst_base_ts_mux_pad_reset (GST_BASE_TS_MUX_PAD (pad)); GST_BASE_TS_MUX_PAD (pad)->pid = pid; + g_free (free_name); + return pad; /* ERRORS */ @@ -1325,7 +1331,7 @@ stream_exists: invalid_stream_pid: { GST_ELEMENT_ERROR (element, STREAM, MUX, - ("Invalid Elementary stream PID (< 0x40)"), (NULL)); + ("Invalid Elementary stream PID (0x%02u < 0x40)", pid), (NULL)); return NULL; } } |