From: George Kiagiadakis Date: Fri, 4 Sep 2020 11:18:13 +0000 (+0300) Subject: rtpsrc: re-use the same src pad for streams that have the same payload type X-Git-Tag: 1.19.3~507^2~1226 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fcbb4386bc6cb73082a56ed207392f9f4848f53;p=platform%2Fupstream%2Fgstreamer.git rtpsrc: re-use the same src pad for streams that have the same payload type Also use payload type when naming pads, this will make it easier to identify pads and simplify the code. Fixes #1395 Part-of: --- diff --git a/gst/rtp/gstrtpsrc.c b/gst/rtp/gstrtpsrc.c index f8c29a7252..3e576facd7 100644 --- a/gst/rtp/gstrtpsrc.c +++ b/gst/rtp/gstrtpsrc.c @@ -426,7 +426,9 @@ gst_rtp_src_rtpbin_pad_added_cb (GstElement * element, GstPad * pad, { GstRtpSrc *self = GST_RTP_SRC (data); GstCaps *caps = gst_pad_query_caps (pad, NULL); - GstPad *upad; + const GstStructure *s; + GstPad *upad = NULL; + gint pt = -1; gchar name[48]; /* Expose RTP data pad only */ @@ -458,15 +460,26 @@ gst_rtp_src_rtpbin_pad_added_cb (GstElement * element, GstPad * pad, return; } + + s = gst_caps_get_structure (caps, 0); + gst_structure_get_int (s, "payload", &pt); gst_caps_unref (caps); GST_RTP_SRC_LOCK (self); - g_snprintf (name, 48, "src_%u", GST_ELEMENT (self)->numpads); - upad = gst_ghost_pad_new (name, pad); + g_snprintf (name, 48, "src_%u", pt); + upad = gst_element_get_static_pad (GST_ELEMENT (self), name); - gst_pad_set_active (upad, TRUE); - gst_element_add_pad (GST_ELEMENT (self), upad); + if (!upad) { + GST_DEBUG_OBJECT (self, "Adding new pad: %s", name); + upad = gst_ghost_pad_new (name, pad); + gst_pad_set_active (upad, TRUE); + gst_element_add_pad (GST_ELEMENT (self), upad); + } else { + GST_DEBUG_OBJECT (self, "Re-using existing pad: %s", GST_PAD_NAME (upad)); + gst_ghost_pad_set_target (GST_GHOST_PAD (upad), pad); + gst_object_unref (upad); + } GST_RTP_SRC_UNLOCK (self); }