From 99723bc1c1812ccecf811cb5997e32b3f8d7cdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Thu, 15 Oct 2020 21:42:40 -0400 Subject: [PATCH] rtpsource: Report for which local SSRC is a remote RB reporting on This is useful in the Bundle case because there may be multiple local and remote SSRCs in the same session. Part-of: --- docs/gst_plugins_cache.json | 2 +- gst/rtpmanager/rtpsession.c | 6 ++++-- gst/rtpmanager/rtpsource.c | 19 +++++++++++++------ gst/rtpmanager/rtpsource.h | 4 ++-- gst/rtpmanager/rtpstats.h | 2 +- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/docs/gst_plugins_cache.json b/docs/gst_plugins_cache.json index 420897e0a5..00ea2de190 100644 --- a/docs/gst_plugins_cache.json +++ b/docs/gst_plugins_cache.json @@ -19243,7 +19243,7 @@ "construct": false, "construct-only": false, "controllable": false, - "default": "application/x-rtp-source-stats, ssrc=(uint)0, internal=(boolean)false, validated=(boolean)false, received-bye=(boolean)false, is-csrc=(boolean)false, is-sender=(boolean)false, seqnum-base=(int)-1, clock-rate=(int)-1, octets-sent=(guint64)0, packets-sent=(guint64)0, octets-received=(guint64)0, packets-received=(guint64)0, bytes-received=(guint64)0, bitrate=(guint64)0, packets-lost=(int)0, jitter=(uint)0, sent-pli-count=(uint)0, recv-pli-count=(uint)0, sent-fir-count=(uint)0, recv-fir-count=(uint)0, sent-nack-count=(uint)0, recv-nack-count=(uint)0, recv-packet-rate=(uint)0, have-sr=(boolean)false, sr-ntptime=(guint64)0, sr-rtptime=(uint)0, sr-octet-count=(uint)0, sr-packet-count=(uint)0, sent-rb=(boolean)false, sent-rb-fractionlost=(uint)0, sent-rb-packetslost=(int)0, sent-rb-exthighestseq=(uint)0, sent-rb-jitter=(uint)0, sent-rb-lsr=(uint)0, sent-rb-dlsr=(uint)0, have-rb=(boolean)false, rb-fractionlost=(uint)0, rb-packetslost=(int)0, rb-exthighestseq=(uint)0, rb-jitter=(uint)0, rb-lsr=(uint)0, rb-dlsr=(uint)0, rb-round-trip=(uint)0;", + "default": "application/x-rtp-source-stats, ssrc=(uint)0, internal=(boolean)false, validated=(boolean)false, received-bye=(boolean)false, is-csrc=(boolean)false, is-sender=(boolean)false, seqnum-base=(int)-1, clock-rate=(int)-1, octets-sent=(guint64)0, packets-sent=(guint64)0, octets-received=(guint64)0, packets-received=(guint64)0, bytes-received=(guint64)0, bitrate=(guint64)0, packets-lost=(int)0, jitter=(uint)0, sent-pli-count=(uint)0, recv-pli-count=(uint)0, sent-fir-count=(uint)0, recv-fir-count=(uint)0, sent-nack-count=(uint)0, recv-nack-count=(uint)0, recv-packet-rate=(uint)0, have-sr=(boolean)false, sr-ntptime=(guint64)0, sr-rtptime=(uint)0, sr-octet-count=(uint)0, sr-packet-count=(uint)0, sent-rb=(boolean)false, sent-rb-fractionlost=(uint)0, sent-rb-packetslost=(int)0, sent-rb-exthighestseq=(uint)0, sent-rb-jitter=(uint)0, sent-rb-lsr=(uint)0, sent-rb-dlsr=(uint)0, have-rb=(boolean)false, rb-ssrc=(uint)0, rb-fractionlost=(uint)0, rb-packetslost=(int)0, rb-exthighestseq=(uint)0, rb-jitter=(uint)0, rb-lsr=(uint)0, rb-dlsr=(uint)0, rb-round-trip=(uint)0;", "mutable": "null", "readable": true, "type": "GstStructure", diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index dcfb1d796f..fe84448f95 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -2393,7 +2393,7 @@ rtp_session_process_rb (RTPSession * sess, RTPSource * source, * the sender of the RTCP message. We could also compare our stats against * the other sender to see if we are better or worse. */ /* FIXME, need to keep track who the RB block is from */ - rtp_source_process_rb (source, pinfo->ntpnstime, fractionlost, + rtp_source_process_rb (source, ssrc, pinfo->ntpnstime, fractionlost, packetslost, exthighestseq, jitter, lsr, dlsr); } } @@ -2726,7 +2726,8 @@ rtp_session_request_local_key_unit (RTPSession * sess, RTPSource * src, { guint32 round_trip = 0; - rtp_source_get_last_rb (src, NULL, NULL, NULL, NULL, NULL, NULL, &round_trip); + rtp_source_get_last_rb (src, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + &round_trip); if (src->last_keyframe_request != GST_CLOCK_TIME_NONE && round_trip) { GstClockTime round_trip_in_ns = gst_util_uint64_scale (round_trip, @@ -3694,6 +3695,7 @@ session_report_blocks (const gchar * key, RTPSource * source, ReportData * data) /* store last generated RR packet */ source->last_rr.is_valid = TRUE; + source->last_rr.ssrc = data->source->ssrc; source->last_rr.fractionlost = fractionlost; source->last_rr.packetslost = packetslost; source->last_rr.exthighestseq = exthighestseq; diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c index 12aa125499..628005e5bb 100644 --- a/gst/rtpmanager/rtpsource.c +++ b/gst/rtpmanager/rtpsource.c @@ -373,6 +373,7 @@ rtp_source_create_stats (RTPSource * src) gboolean internal = src->internal; gchar *address_str; gboolean have_rb; + guint32 ssrc = 0; guint8 fractionlost = 0; gint32 packetslost = 0; guint32 exthighestseq = 0; @@ -453,11 +454,12 @@ rtp_source_create_stats (RTPSource * src) (guint) src->last_rr.dlsr, NULL); /* get the last RB */ - have_rb = rtp_source_get_last_rb (src, &fractionlost, &packetslost, - &exthighestseq, &jitter, &lsr, &dlsr, &round_trip); + have_rb = rtp_source_get_last_rb (src, &ssrc, &fractionlost, + &packetslost, &exthighestseq, &jitter, &lsr, &dlsr, &round_trip); gst_structure_set (s, "have-rb", G_TYPE_BOOLEAN, have_rb, + "rb-ssrc", G_TYPE_UINT, ssrc, "rb-fractionlost", G_TYPE_UINT, (guint) fractionlost, "rb-packetslost", G_TYPE_INT, (gint) packetslost, "rb-exthighestseq", G_TYPE_UINT, (guint) exthighestseq, @@ -1445,6 +1447,7 @@ rtp_source_process_sr (RTPSource * src, GstClockTime time, guint64 ntptime, /** * rtp_source_process_rb: * @src: an #RTPSource + * @ssrc: SSRC of the local source for this this RB was sent * @ntpnstime: the current time in nanoseconds since 1970 * @fractionlost: fraction lost since last SR/RR * @packetslost: the cumulative number of packets lost @@ -1458,7 +1461,7 @@ rtp_source_process_sr (RTPSource * src, GstClockTime time, guint64 ntptime, * Update the report block in @src. */ void -rtp_source_process_rb (RTPSource * src, guint64 ntpnstime, +rtp_source_process_rb (RTPSource * src, guint32 ssrc, guint64 ntpnstime, guint8 fractionlost, gint32 packetslost, guint32 exthighestseq, guint32 jitter, guint32 lsr, guint32 dlsr) { @@ -1479,6 +1482,7 @@ rtp_source_process_rb (RTPSource * src, guint64 ntpnstime, /* update current */ curr->is_valid = TRUE; + curr->ssrc = ssrc; curr->fractionlost = fractionlost; curr->packetslost = packetslost; curr->exthighestseq = exthighestseq; @@ -1732,6 +1736,7 @@ rtp_source_get_last_sr (RTPSource * src, GstClockTime * time, guint64 * ntptime, /** * rtp_source_get_last_rb: * @src: an #RTPSource + * @ssrc: SSRC of the local source for this this RB was sent * @fractionlost: fraction lost since last SR/RR * @packetslost: the cumulative number of packets lost * @exthighestseq: the extended last sequence number received @@ -1748,9 +1753,9 @@ rtp_source_get_last_sr (RTPSource * src, GstClockTime * time, guint64 * ntptime, * Returns: %TRUE if there was a valid SB report. */ gboolean -rtp_source_get_last_rb (RTPSource * src, guint8 * fractionlost, - gint32 * packetslost, guint32 * exthighestseq, guint32 * jitter, - guint32 * lsr, guint32 * dlsr, guint32 * round_trip) +rtp_source_get_last_rb (RTPSource * src, guint32 * ssrc, + guint8 * fractionlost, gint32 * packetslost, guint32 * exthighestseq, + guint32 * jitter, guint32 * lsr, guint32 * dlsr, guint32 * round_trip) { RTPReceiverReport *curr; @@ -1760,6 +1765,8 @@ rtp_source_get_last_rb (RTPSource * src, guint8 * fractionlost, if (!curr->is_valid) return FALSE; + if (ssrc) + *ssrc = curr->ssrc; if (fractionlost) *fractionlost = curr->fractionlost; if (packetslost) diff --git a/gst/rtpmanager/rtpsource.h b/gst/rtpmanager/rtpsource.h index dff7b313f8..20e65f1324 100644 --- a/gst/rtpmanager/rtpsource.h +++ b/gst/rtpmanager/rtpsource.h @@ -249,7 +249,7 @@ GstFlowReturn rtp_source_send_rtp (RTPSource *src, RTPPacketInfo *p /* RTCP messages */ void rtp_source_process_sr (RTPSource *src, GstClockTime time, guint64 ntptime, guint32 rtptime, guint32 packet_count, guint32 octet_count); -void rtp_source_process_rb (RTPSource *src, guint64 ntpnstime, guint8 fractionlost, +void rtp_source_process_rb (RTPSource *src, guint32 ssrc, guint64 ntpnstime, guint8 fractionlost, gint32 packetslost, guint32 exthighestseq, guint32 jitter, guint32 lsr, guint32 dlsr); @@ -263,7 +263,7 @@ gboolean rtp_source_get_new_rb (RTPSource *src, GstClockTime tim gboolean rtp_source_get_last_sr (RTPSource *src, GstClockTime *time, guint64 *ntptime, guint32 *rtptime, guint32 *packet_count, guint32 *octet_count); -gboolean rtp_source_get_last_rb (RTPSource *src, guint8 *fractionlost, gint32 *packetslost, +gboolean rtp_source_get_last_rb (RTPSource *src, guint32 * ssrc, guint8 *fractionlost, gint32 *packetslost, guint32 *exthighestseq, guint32 *jitter, guint32 *lsr, guint32 *dlsr, guint32 *round_trip); diff --git a/gst/rtpmanager/rtpstats.h b/gst/rtpmanager/rtpstats.h index 776651f444..1804aa6cf3 100644 --- a/gst/rtpmanager/rtpstats.h +++ b/gst/rtpmanager/rtpstats.h @@ -51,7 +51,7 @@ typedef struct { */ typedef struct { gboolean is_valid; - guint32 ssrc; /* who the report is from */ + guint32 ssrc; /* which source is the report about */ guint8 fractionlost; guint32 packetslost; guint32 exthighestseq;