diff --git a/ext/webrtc/gstwebrtcstats.c b/ext/webrtc/gstwebrtcstats.c index 4799e7eca1..bf3830413f 100644 --- a/ext/webrtc/gstwebrtcstats.c +++ b/ext/webrtc/gstwebrtcstats.c @@ -402,7 +402,8 @@ _get_stats_from_dtls_transport (GstWebRTCBin * webrtc, static void _get_stats_from_transport_channel (GstWebRTCBin * webrtc, - TransportStream * stream, const gchar * codec_id, GstStructure * s) + TransportStream * stream, const gchar * codec_id, guint ssrc, + GstStructure * s) { GstWebRTCDTLSTransport *transport; GObject *rtp_session; @@ -439,12 +440,15 @@ _get_stats_from_transport_channel (GstWebRTCBin * webrtc, const GstStructure *stats; const GValue *val = g_value_array_get_nth (source_stats, i); gboolean internal; + guint stats_ssrc = 0; stats = gst_value_get_structure (val); - /* skip internal sources */ - gst_structure_get (stats, "internal", G_TYPE_BOOLEAN, &internal, NULL); - if (internal) + /* skip internal or foreign sources */ + gst_structure_get (stats, + "internal", G_TYPE_BOOLEAN, &internal, + "ssrc", G_TYPE_UINT, &stats_ssrc, NULL); + if (internal || (ssrc && stats_ssrc && ssrc != stats_ssrc)) continue; _get_stats_from_rtp_source_stats (webrtc, stats, codec_id, transport_id, s); @@ -459,12 +463,13 @@ _get_stats_from_transport_channel (GstWebRTCBin * webrtc, /* https://www.w3.org/TR/webrtc-stats/#codec-dict* */ static void _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, - GstStructure * s, gchar ** out_id) + GstStructure * s, gchar ** out_id, guint * out_ssrc) { GstStructure *stats; GstCaps *caps; gchar *id; double ts; + guint ssrc = 0; gst_structure_get_double (s, "timestamp", &ts); @@ -483,6 +488,9 @@ _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, if (gst_structure_get_int (caps_s, "clock-rate", &clock_rate)) gst_structure_set (stats, "clock-rate", G_TYPE_UINT, clock_rate, NULL); + if (gst_structure_get_uint (caps_s, "ssrc", &ssrc)) + gst_structure_set (stats, "ssrc", G_TYPE_UINT, ssrc, NULL); + /* FIXME: codecType, mimeType, channels, sdpFmtpLine, implementation, transportId */ } @@ -496,6 +504,9 @@ _get_codec_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, *out_id = id; else g_free (id); + + if (out_ssrc) + *out_ssrc = ssrc; } static gboolean @@ -504,8 +515,9 @@ _get_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, GstStructure * s) GstWebRTCBinPad *wpad = GST_WEBRTC_BIN_PAD (pad); TransportStream *stream; gchar *codec_id; + guint ssrc; - _get_codec_stats_from_pad (webrtc, pad, s, &codec_id); + _get_codec_stats_from_pad (webrtc, pad, s, &codec_id, &ssrc); if (!wpad->trans) goto out; @@ -514,7 +526,7 @@ _get_stats_from_pad (GstWebRTCBin * webrtc, GstPad * pad, GstStructure * s) if (!stream) goto out; - _get_stats_from_transport_channel (webrtc, stream, codec_id, s); + _get_stats_from_transport_channel (webrtc, stream, codec_id, ssrc, s); out: g_free (codec_id);