rtpssrcdemux: make naming consistent

Use plural for GstRtpSsrcDemuxPads, since it contains two pads, and
use the variable-name 'dpads' everywhere.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/992>
This commit is contained in:
Havard Graff 2021-05-21 18:30:28 +02:00 committed by GStreamer Marge Bot
parent 80966ed0a3
commit c721c6fe72
2 changed files with 52 additions and 53 deletions

View file

@ -145,24 +145,24 @@ static guint gst_rtp_ssrc_demux_signals[LAST_SIGNAL] = { 0 };
/*
* Item for storing GstPad <-> SSRC pairs.
*/
struct _GstRtpSsrcDemuxPad
typedef struct
{
guint32 ssrc;
GstPad *rtp_pad;
GstCaps *caps;
GstPad *rtcp_pad;
};
} GstRtpSsrcDemuxPads;
/* find a src pad for a given SSRC, returns NULL if the SSRC was not found
* MUST be called with object lock
*/
static GstRtpSsrcDemuxPad *
find_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
static GstRtpSsrcDemuxPads *
find_demux_pads_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
{
GSList *walk;
for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
GstRtpSsrcDemuxPad *pad = (GstRtpSsrcDemuxPad *) walk->data;
GstRtpSsrcDemuxPads *pad = (GstRtpSsrcDemuxPads *) walk->data;
if (pad->ssrc == ssrc)
return pad;
@ -174,23 +174,23 @@ find_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
static GstPad *
get_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc, PadType padtype)
{
GstRtpSsrcDemuxPad *demuxpad;
GstRtpSsrcDemuxPads *dpads;
GstPad *retpad;
GST_OBJECT_LOCK (demux);
demuxpad = find_demux_pad_for_ssrc (demux, ssrc);
if (!demuxpad) {
dpads = find_demux_pads_for_ssrc (demux, ssrc);
if (!dpads) {
GST_OBJECT_UNLOCK (demux);
return NULL;
}
switch (padtype) {
case RTP_PAD:
retpad = gst_object_ref (demuxpad->rtp_pad);
retpad = gst_object_ref (dpads->rtp_pad);
break;
case RTCP_PAD:
retpad = gst_object_ref (demuxpad->rtcp_pad);
retpad = gst_object_ref (dpads->rtcp_pad);
break;
default:
retpad = NULL;
@ -280,7 +280,7 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
GstElementClass *klass;
GstPadTemplate *templ;
gchar *padname;
GstRtpSsrcDemuxPad *demuxpad;
GstRtpSsrcDemuxPads *dpads;
GstPad *retpad;
guint num_streams;
@ -313,16 +313,16 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
g_free (padname);
/* wrap in structure and add to list */
demuxpad = g_new0 (GstRtpSsrcDemuxPad, 1);
demuxpad->ssrc = ssrc;
demuxpad->rtp_pad = rtp_pad;
demuxpad->rtcp_pad = rtcp_pad;
dpads = g_new0 (GstRtpSsrcDemuxPads, 1);
dpads->ssrc = ssrc;
dpads->rtp_pad = rtp_pad;
dpads->rtcp_pad = rtcp_pad;
gst_pad_set_element_private (rtp_pad, demuxpad);
gst_pad_set_element_private (rtcp_pad, demuxpad);
gst_pad_set_element_private (rtp_pad, dpads);
gst_pad_set_element_private (rtcp_pad, dpads);
GST_OBJECT_LOCK (demux);
demux->srcpads = g_slist_prepend (demux->srcpads, demuxpad);
demux->srcpads = g_slist_prepend (demux->srcpads, dpads);
GST_OBJECT_UNLOCK (demux);
gst_pad_set_query_function (rtp_pad, gst_rtp_ssrc_demux_src_query);
@ -346,10 +346,10 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc,
switch (padtype) {
case RTP_PAD:
retpad = gst_object_ref (demuxpad->rtp_pad);
retpad = gst_object_ref (dpads->rtp_pad);
break;
case RTCP_PAD:
retpad = gst_object_ref (demuxpad->rtcp_pad);
retpad = gst_object_ref (dpads->rtcp_pad);
break;
default:
retpad = NULL;
@ -521,14 +521,14 @@ gst_rtp_ssrc_demux_reset (GstRtpSsrcDemux * demux)
GSList *walk;
for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
GstRtpSsrcDemuxPads *dpads = (GstRtpSsrcDemuxPads *) walk->data;
gst_pad_set_active (dpad->rtp_pad, FALSE);
gst_pad_set_active (dpad->rtcp_pad, FALSE);
gst_pad_set_active (dpads->rtp_pad, FALSE);
gst_pad_set_active (dpads->rtcp_pad, FALSE);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpad->rtp_pad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpad->rtcp_pad);
g_free (dpad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpads->rtp_pad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpads->rtcp_pad);
g_free (dpads);
}
g_slist_free (demux->srcpads);
demux->srcpads = NULL;
@ -560,31 +560,31 @@ gst_rtp_ssrc_demux_finalize (GObject * object)
static void
gst_rtp_ssrc_demux_clear_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
{
GstRtpSsrcDemuxPad *dpad;
GstRtpSsrcDemuxPads *dpads;
GST_OBJECT_LOCK (demux);
dpad = find_demux_pad_for_ssrc (demux, ssrc);
if (dpad == NULL) {
dpads = find_demux_pads_for_ssrc (demux, ssrc);
if (dpads == NULL) {
GST_OBJECT_UNLOCK (demux);
goto unknown_pad;
}
GST_DEBUG_OBJECT (demux, "clearing pad for SSRC %08x", ssrc);
demux->srcpads = g_slist_remove (demux->srcpads, dpad);
demux->srcpads = g_slist_remove (demux->srcpads, dpads);
GST_OBJECT_UNLOCK (demux);
gst_pad_set_active (dpad->rtp_pad, FALSE);
gst_pad_set_active (dpad->rtcp_pad, FALSE);
gst_pad_set_active (dpads->rtp_pad, FALSE);
gst_pad_set_active (dpads->rtcp_pad, FALSE);
g_signal_emit (G_OBJECT (demux),
gst_rtp_ssrc_demux_signals[SIGNAL_REMOVED_SSRC_PAD], 0, ssrc,
dpad->rtp_pad);
dpads->rtp_pad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpad->rtp_pad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpad->rtcp_pad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpads->rtp_pad);
gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpads->rtcp_pad);
g_free (dpad);
g_free (dpads);
return;
@ -613,10 +613,10 @@ forward_event (GstPad * pad, gpointer user_data)
GST_OBJECT_LOCK (fdata->demux);
for (walk = fdata->demux->srcpads; walk; walk = walk->next) {
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
GstRtpSsrcDemuxPads *dpads = (GstRtpSsrcDemuxPads *) walk->data;
if (pad == dpad->rtp_pad || pad == dpad->rtcp_pad) {
newevent = add_ssrc_and_ref (fdata->event, dpad->ssrc);
if (pad == dpads->rtp_pad || pad == dpads->rtcp_pad) {
newevent = add_ssrc_and_ref (fdata->event, dpads->ssrc);
break;
}
}
@ -806,15 +806,15 @@ create_failed:
}
}
static GstRtpSsrcDemuxPad *
static GstRtpSsrcDemuxPads *
find_demux_pad_for_pad (GstRtpSsrcDemux * demux, GstPad * pad)
{
GSList *walk;
for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) {
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) walk->data;
if (dpad->rtp_pad == pad || dpad->rtcp_pad == pad) {
return dpad;
GstRtpSsrcDemuxPads *dpads = (GstRtpSsrcDemuxPads *) walk->data;
if (dpads->rtp_pad == pad || dpads->rtcp_pad == pad) {
return dpads;
}
}
@ -837,14 +837,14 @@ gst_rtp_ssrc_demux_src_event (GstPad * pad, GstObject * parent,
case GST_EVENT_CUSTOM_BOTH_OOB:
s = gst_event_get_structure (event);
if (s && !gst_structure_has_field (s, "ssrc")) {
GstRtpSsrcDemuxPad *dpad = find_demux_pad_for_pad (demux, pad);
GstRtpSsrcDemuxPads *dpads = find_demux_pad_for_pad (demux, pad);
if (dpad) {
if (dpads) {
GstStructure *ws;
event = gst_event_make_writable (event);
ws = gst_event_writable_structure (event);
gst_structure_set (ws, "ssrc", G_TYPE_UINT, dpad->ssrc, NULL);
gst_structure_set (ws, "ssrc", G_TYPE_UINT, dpads->ssrc, NULL);
}
}
break;
@ -867,12 +867,12 @@ gst_rtp_ssrc_demux_iterate_internal_links_src (GstPad * pad, GstObject * parent)
GST_OBJECT_LOCK (demux);
for (current = demux->srcpads; current; current = g_slist_next (current)) {
GstRtpSsrcDemuxPad *dpad = (GstRtpSsrcDemuxPad *) current->data;
GstRtpSsrcDemuxPads *dpads = (GstRtpSsrcDemuxPads *) current->data;
if (pad == dpad->rtp_pad) {
if (pad == dpads->rtp_pad) {
otherpad = demux->rtp_sink;
break;
} else if (pad == dpad->rtcp_pad) {
} else if (pad == dpads->rtcp_pad) {
otherpad = demux->rtcp_sink;
break;
}
@ -949,16 +949,16 @@ gst_rtp_ssrc_demux_src_query (GstPad * pad, GstObject * parent,
if ((res = gst_pad_peer_query (demux->rtp_sink, query))) {
gboolean live;
GstClockTime min_latency, max_latency;
GstRtpSsrcDemuxPad *demuxpad;
GstRtpSsrcDemuxPads *dpads;
demuxpad = gst_pad_get_element_private (pad);
dpads = gst_pad_get_element_private (pad);
gst_query_parse_latency (query, &live, &min_latency, &max_latency);
GST_DEBUG_OBJECT (demux, "peer min latency %" GST_TIME_FORMAT,
GST_TIME_ARGS (min_latency));
GST_DEBUG_OBJECT (demux, "latency for SSRC %08x", demuxpad->ssrc);
GST_DEBUG_OBJECT (demux, "latency for SSRC %08x", dpads->ssrc);
gst_query_set_latency (query, live, min_latency, max_latency);
}

View file

@ -30,7 +30,6 @@
typedef struct _GstRtpSsrcDemux GstRtpSsrcDemux;
typedef struct _GstRtpSsrcDemuxClass GstRtpSsrcDemuxClass;
typedef struct _GstRtpSsrcDemuxPad GstRtpSsrcDemuxPad;
struct _GstRtpSsrcDemux
{