blob: 696e0fbd7e53567542988ea7dac8e58168632e19 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
12#define MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +020014#include <list>
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +000015#include <map>
danilchap95321242016-09-27 07:05:32 -070016#include <string>
danilchapb8b6fbb2015-12-10 05:05:27 -080017#include <vector>
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +000018
Ivo Creusen2562cf02021-09-03 14:51:22 +000019#include "absl/types/optional.h"
Danil Chapovalov443f2662020-03-11 12:24:40 +010020#include "api/array_view.h"
Tommi08be9ba2021-06-15 23:01:57 +020021#include "api/sequence_checker.h"
Ivo Creusen2562cf02021-09-03 14:51:22 +000022#include "api/units/time_delta.h"
Henrik Boströmf2047872019-05-16 13:32:20 +020023#include "modules/rtp_rtcp/include/report_block_data.h"
Niels Möller53382cb2018-11-27 14:05:08 +010024#include "modules/rtp_rtcp/include/rtcp_statistics.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
26#include "modules/rtp_rtcp/source/rtcp_nack_stats.h"
27#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
Stephan Hartmann26946722021-05-03 11:06:23 +000028#include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020029#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
Victor Boivief7156182021-07-06 23:14:51 +020030#include "rtc_base/containers/flat_map.h"
Markus Handelle7c015e2020-07-07 11:44:28 +020031#include "rtc_base/synchronization/mutex.h"
Tommi08be9ba2021-06-15 23:01:57 +020032#include "rtc_base/system/no_unique_address.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020033#include "rtc_base/thread_annotations.h"
34#include "system_wrappers/include/ntp_time.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000035
36namespace webrtc {
Tommi08be9ba2021-06-15 23:01:57 +020037
38class ModuleRtpRtcpImpl2;
spranga790d832016-12-02 07:29:44 -080039class VideoBitrateAllocationObserver;
Tommi08be9ba2021-06-15 23:01:57 +020040
danilchap59cb2bd2016-08-29 11:08:47 -070041namespace rtcp {
danilchap1b1863a2016-09-20 01:39:54 -070042class CommonHeader;
danilchap1b1863a2016-09-20 01:39:54 -070043class ReportBlock;
44class Rrtr;
spranga790d832016-12-02 07:29:44 -080045class TargetBitrate;
danilchap59cb2bd2016-08-29 11:08:47 -070046class TmmbItem;
47} // namespace rtcp
pwestin@webrtc.org741da942011-09-20 13:52:04 +000048
Danil Chapovalov443f2662020-03-11 12:24:40 +010049class RTCPReceiver final {
danilchapda161d72016-08-19 07:29:46 -070050 public:
danilchap59cb2bd2016-08-29 11:08:47 -070051 class ModuleRtpRtcp {
52 public:
53 virtual void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) = 0;
54 virtual void OnRequestSendReport() = 0;
55 virtual void OnReceivedNack(
56 const std::vector<uint16_t>& nack_sequence_numbers) = 0;
57 virtual void OnReceivedRtcpReportBlocks(
58 const ReportBlockList& report_blocks) = 0;
59
60 protected:
61 virtual ~ModuleRtpRtcp() = default;
62 };
Ivo Creusen2562cf02021-09-03 14:51:22 +000063 // Standardized stats derived from the non-sender RTT.
64 class NonSenderRttStats {
65 public:
66 NonSenderRttStats() = default;
67 NonSenderRttStats(const NonSenderRttStats&) = default;
68 NonSenderRttStats& operator=(const NonSenderRttStats&) = default;
69 ~NonSenderRttStats() = default;
70 void Update(TimeDelta non_sender_rtt_seconds) {
71 round_trip_time_ = non_sender_rtt_seconds;
72 total_round_trip_time_ += non_sender_rtt_seconds;
73 round_trip_time_measurements_++;
74 }
75 void Invalidate() { round_trip_time_.reset(); }
76 // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime
77 absl::optional<TimeDelta> round_trip_time() const {
78 return round_trip_time_;
79 }
80 // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime
81 TimeDelta total_round_trip_time() const { return total_round_trip_time_; }
82 // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements
83 int round_trip_time_measurements() const {
84 return round_trip_time_measurements_;
85 }
86
87 private:
88 absl::optional<TimeDelta> round_trip_time_;
89 TimeDelta total_round_trip_time_ = TimeDelta::Zero();
90 int round_trip_time_measurements_ = 0;
91 };
danilchap59cb2bd2016-08-29 11:08:47 -070092
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020093 RTCPReceiver(const RtpRtcpInterface::Configuration& config,
94 ModuleRtpRtcp* owner);
Tommi08be9ba2021-06-15 23:01:57 +020095
96 RTCPReceiver(const RtpRtcpInterface::Configuration& config,
97 ModuleRtpRtcpImpl2* owner);
98
Danil Chapovalov443f2662020-03-11 12:24:40 +010099 ~RTCPReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
Harald Alvestrand1f206b82023-02-01 11:12:46 +0000101 [[deprecated("Use ArrayView verwsion")]] void IncomingPacket(
102 const uint8_t* packet,
103 size_t packet_size) {
Danil Chapovalov443f2662020-03-11 12:24:40 +0100104 IncomingPacket(rtc::MakeArrayView(packet, packet_size));
105 }
106 void IncomingPacket(rtc::ArrayView<const uint8_t> packet);
danilchap59cb2bd2016-08-29 11:08:47 -0700107
Danil Chapovalov760c4b42017-09-27 13:25:24 +0200108 int64_t LastReceivedReportBlockMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
Tommi08be9ba2021-06-15 23:01:57 +0200110 void set_local_media_ssrc(uint32_t ssrc);
111 uint32_t local_media_ssrc() const;
112
danilchapda161d72016-08-19 07:29:46 -0700113 void SetRemoteSSRC(uint32_t ssrc);
114 uint32_t RemoteSSRC() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
Tommi08be9ba2021-06-15 23:01:57 +0200116 bool receiver_only() const { return receiver_only_; }
117
danilchap8bab7962016-12-20 02:46:46 -0800118 // Get received NTP.
Alessio Bazzica048adc72021-03-10 15:05:55 +0100119 // The types for the arguments below derive from the specification:
120 // - `remote_sender_packet_count`: `RTCSentRtpStreamStats.packetsSent` [1]
121 // - `remote_sender_octet_count`: `RTCSentRtpStreamStats.bytesSent` [1]
122 // - `remote_sender_reports_count`:
123 // `RTCRemoteOutboundRtpStreamStats.reportsSent` [2]
124 // [1] https://www.w3.org/TR/webrtc-stats/#remoteoutboundrtpstats-dict*
125 // [2] https://www.w3.org/TR/webrtc-stats/#dom-rtcsentrtpstreamstats
danilchap8bab7962016-12-20 02:46:46 -0800126 bool NTP(uint32_t* received_ntp_secs,
127 uint32_t* received_ntp_frac,
128 uint32_t* rtcp_arrival_time_secs,
129 uint32_t* rtcp_arrival_time_frac,
Alessio Bazzica048adc72021-03-10 15:05:55 +0100130 uint32_t* rtcp_timestamp,
131 uint32_t* remote_sender_packet_count,
132 uint64_t* remote_sender_octet_count,
133 uint64_t* remote_sender_reports_count) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000134
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200135 std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo();
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000136
danilchap28b03eb2016-10-05 06:59:44 -0700137 // Get rtt.
138 int32_t RTT(uint32_t remote_ssrc,
139 int64_t* last_rtt_ms,
140 int64_t* avg_rtt_ms,
141 int64_t* min_rtt_ms,
142 int64_t* max_rtt_ms) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000143
Ivo Creusen2562cf02021-09-03 14:51:22 +0000144 // Returns non-sender RTT metrics for the remote SSRC.
145 NonSenderRttStats GetNonSenderRTT() const;
146
Ivo Creusen8c40d512021-07-13 12:53:22 +0000147 void SetNonSenderRttMeasurement(bool enabled);
danilchapda161d72016-08-19 07:29:46 -0700148 bool GetAndResetXrRrRtt(int64_t* rtt_ms);
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000149
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200150 // Called once per second on the worker thread to do rtt calculations.
151 // Returns an optional rtt value if one is available.
152 absl::optional<TimeDelta> OnPeriodicRttUpdate(Timestamp newer_than,
153 bool sending);
154
Henrik Boströmf2047872019-05-16 13:32:20 +0200155 // A snapshot of Report Blocks with additional data of interest to statistics.
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200156 // Within this list, the source SSRC is unique and ReportBlockData represents
157 // the latest Report Block that was received for that SSRC.
Henrik Boströmf2047872019-05-16 13:32:20 +0200158 std::vector<ReportBlockData> GetLatestReportBlockData() const;
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +0000159
danilchapda161d72016-08-19 07:29:46 -0700160 // Returns true if we haven't received an RTCP RR for several RTCP
161 // intervals, but only triggers true once.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800162 bool RtcpRrTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000163
danilchapda161d72016-08-19 07:29:46 -0700164 // Returns true if we haven't received an RTCP RR telling the receive side
165 // has not received RTP packets for too long, i.e. extended highest sequence
166 // number hasn't increased for several RTCP intervals. The function only
167 // returns true once until a new RR is received.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800168 bool RtcpRrSequenceNumberTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000169
danilchap7851bda2016-09-29 15:28:07 -0700170 std::vector<rtcp::TmmbItem> TmmbrReceived();
danilchap9bf610e2017-02-20 06:03:01 -0800171 // Return true if new bandwidth should be set.
172 bool UpdateTmmbrTimers();
danilchapda161d72016-08-19 07:29:46 -0700173 std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
danilchap9bf610e2017-02-20 06:03:01 -0800174 // Set new bandwidth and notify remote clients about it.
175 void NotifyTmmbrUpdated();
niklase@google.com470e71d2011-07-07 08:21:25 +0000176
danilchapdd128922016-09-13 12:23:29 -0700177 private:
Tommi08be9ba2021-06-15 23:01:57 +0200178#if RTC_DCHECK_IS_ON
179 class CustomSequenceChecker : public SequenceChecker {
Victor Boivie306b1392021-04-27 10:33:58 +0200180 public:
Tommi08be9ba2021-06-15 23:01:57 +0200181 explicit CustomSequenceChecker(bool disable_checks)
182 : disable_checks_(disable_checks) {}
183 bool IsCurrent() const {
184 if (disable_checks_)
185 return true;
186 return SequenceChecker::IsCurrent();
Victor Boivie306b1392021-04-27 10:33:58 +0200187 }
188
189 private:
Tommi08be9ba2021-06-15 23:01:57 +0200190 const bool disable_checks_;
191 };
192#else
193 class CustomSequenceChecker : public SequenceChecker {
194 public:
195 explicit CustomSequenceChecker(bool) {}
196 };
197#endif
198
199 // A lightweight inlined set of local SSRCs.
200 class RegisteredSsrcs {
201 public:
202 static constexpr size_t kMediaSsrcIndex = 0;
203 static constexpr size_t kMaxSsrcs = 3;
204 // Initializes the set of registered local SSRCS by extracting them from the
205 // provided `config`. The `disable_sequence_checker` flag is a workaround
206 // to be able to use a sequence checker without breaking downstream
207 // code that currently doesn't follow the same threading rules as webrtc.
208 RegisteredSsrcs(bool disable_sequence_checker,
209 const RtpRtcpInterface::Configuration& config);
210
211 // Indicates if `ssrc` is in the set of registered local SSRCs.
212 bool contains(uint32_t ssrc) const;
213 uint32_t media_ssrc() const;
214 void set_media_ssrc(uint32_t ssrc);
215
216 private:
217 RTC_NO_UNIQUE_ADDRESS CustomSequenceChecker packet_sequence_checker_;
218 absl::InlinedVector<uint32_t, kMaxSsrcs> ssrcs_
219 RTC_GUARDED_BY(packet_sequence_checker_);
Victor Boivie306b1392021-04-27 10:33:58 +0200220 };
221
danilchap92ea6012016-09-23 10:36:03 -0700222 struct PacketInformation;
Stephan Hartmann26946722021-05-03 11:06:23 +0000223
224 // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104,
225 // section 3.5.4).
226 struct TmmbrInformation {
227 struct TimedTmmbrItem {
228 rtcp::TmmbItem tmmbr_item;
229 int64_t last_updated_ms;
230 };
231
232 int64_t last_time_received_ms = 0;
233
234 bool ready_for_delete = false;
235
236 std::vector<rtcp::TmmbItem> tmmbn;
237 std::map<uint32_t, TimedTmmbrItem> tmmbr;
238 };
239
240 // Structure for storing received RRTR RTCP messages (RFC3611, section 4.4).
241 struct RrtrInformation {
242 RrtrInformation(uint32_t ssrc,
243 uint32_t received_remote_mid_ntp_time,
244 uint32_t local_receive_mid_ntp_time)
245 : ssrc(ssrc),
246 received_remote_mid_ntp_time(received_remote_mid_ntp_time),
247 local_receive_mid_ntp_time(local_receive_mid_ntp_time) {}
248
249 uint32_t ssrc;
250 // Received NTP timestamp in compact representation.
251 uint32_t received_remote_mid_ntp_time;
252 // NTP time when the report was received in compact representation.
253 uint32_t local_receive_mid_ntp_time;
254 };
255
256 struct LastFirStatus {
257 LastFirStatus(int64_t now_ms, uint8_t sequence_number)
258 : request_ms(now_ms), sequence_number(sequence_number) {}
259 int64_t request_ms;
260 uint8_t sequence_number;
261 };
Victor Boivie0c563a42021-04-27 10:24:01 +0200262
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200263 class RttStats {
264 public:
265 RttStats() = default;
266 RttStats(const RttStats&) = default;
267 RttStats& operator=(const RttStats&) = default;
Victor Boivie0c563a42021-04-27 10:24:01 +0200268
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200269 void AddRtt(TimeDelta rtt);
270
271 TimeDelta last_rtt() const { return last_rtt_; }
272 TimeDelta min_rtt() const { return min_rtt_; }
273 TimeDelta max_rtt() const { return max_rtt_; }
274 TimeDelta average_rtt() const { return sum_rtt_ / num_rtts_; }
275
276 private:
277 TimeDelta last_rtt_ = TimeDelta::Zero();
278 TimeDelta min_rtt_ = TimeDelta::PlusInfinity();
279 TimeDelta max_rtt_ = TimeDelta::MinusInfinity();
280 TimeDelta sum_rtt_ = TimeDelta::Zero();
281 size_t num_rtts_ = 0;
282 };
danilchapdd128922016-09-13 12:23:29 -0700283
Danil Chapovalov443f2662020-03-11 12:24:40 +0100284 bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
danilchap92ea6012016-09-23 10:36:03 -0700285 PacketInformation* packet_information);
danilchapdd128922016-09-13 12:23:29 -0700286
danilchap8bab7962016-12-20 02:46:46 -0800287 void TriggerCallbacksFromRtcpPacket(
danilchap92ea6012016-09-23 10:36:03 -0700288 const PacketInformation& packet_information);
danilchapdd128922016-09-13 12:23:29 -0700289
danilchapec067e92017-02-21 05:38:19 -0800290 TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700291 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapec067e92017-02-21 05:38:19 -0800292 // Update TmmbrInformation (if present) is alive.
293 void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700294 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800295 TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700296 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000297
danilchap92ea6012016-09-23 10:36:03 -0700298 void HandleSenderReport(const rtcp::CommonHeader& rtcp_block,
299 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700300 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Danil Chapovalov91511f12016-09-15 16:24:02 +0200301
danilchap92ea6012016-09-23 10:36:03 -0700302 void HandleReceiverReport(const rtcp::CommonHeader& rtcp_block,
303 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700304 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000305
danilchap1b1863a2016-09-20 01:39:54 -0700306 void HandleReportBlock(const rtcp::ReportBlock& report_block,
danilchap92ea6012016-09-23 10:36:03 -0700307 PacketInformation* packet_information,
danilchap8bab7962016-12-20 02:46:46 -0800308 uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700309 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000310
danilchap8bab7962016-12-20 02:46:46 -0800311 void HandleSdes(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700312 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700313 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000314
danilchap1b1863a2016-09-20 01:39:54 -0700315 void HandleXr(const rtcp::CommonHeader& rtcp_block,
Ivo Creusen2562cf02021-09-03 14:51:22 +0000316 PacketInformation* packet_information,
317 bool& contains_dlrr,
318 uint32_t& ssrc)
danilchap56359be2017-09-07 07:53:45 -0700319 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000320
danilchap92ea6012016-09-23 10:36:03 -0700321 void HandleXrReceiveReferenceTime(uint32_t sender_ssrc,
322 const rtcp::Rrtr& rrtr)
danilchap56359be2017-09-07 07:53:45 -0700323 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000324
Ivo Creusen2562cf02021-09-03 14:51:22 +0000325 void HandleXrDlrrReportBlock(uint32_t ssrc, const rtcp::ReceiveTimeInfo& rti)
danilchap56359be2017-09-07 07:53:45 -0700326 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700327
sprangb32aaf92017-08-28 05:49:12 -0700328 void HandleXrTargetBitrate(uint32_t ssrc,
329 const rtcp::TargetBitrate& target_bitrate,
spranga790d832016-12-02 07:29:44 -0800330 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700331 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
spranga790d832016-12-02 07:29:44 -0800332
danilchap8bab7962016-12-20 02:46:46 -0800333 void HandleNack(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700334 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700335 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700336
Sebastian Janssone1795f42019-07-24 11:38:03 +0200337 void HandleApp(const rtcp::CommonHeader& rtcp_block,
338 PacketInformation* packet_information)
339 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
340
danilchap8bab7962016-12-20 02:46:46 -0800341 void HandleBye(const rtcp::CommonHeader& rtcp_block)
danilchap56359be2017-09-07 07:53:45 -0700342 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700343
danilchap8bab7962016-12-20 02:46:46 -0800344 void HandlePli(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700345 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700346 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700347
danilchap1b1863a2016-09-20 01:39:54 -0700348 void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700349 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700350 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700351
danilchap8bab7962016-12-20 02:46:46 -0800352 void HandleTmmbr(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700353 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700354 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000355
danilchap8bab7962016-12-20 02:46:46 -0800356 void HandleTmmbn(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700357 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700358 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000359
danilchap8bab7962016-12-20 02:46:46 -0800360 void HandleSrReq(const rtcp::CommonHeader& rtcp_block,
361 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700362 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000363
danilchap8bab7962016-12-20 02:46:46 -0800364 void HandleFir(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700365 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700366 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700367
danilchap92ea6012016-09-23 10:36:03 -0700368 void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block,
369 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700370 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Erik Språng6b8d3552015-09-24 15:06:57 +0200371
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200372 bool RtcpRrTimeoutLocked(Timestamp now)
373 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
374
375 bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now)
376 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
377
danilchap8bab7962016-12-20 02:46:46 -0800378 Clock* const clock_;
Peter Boströmfe7a80c2015-04-23 17:53:17 +0200379 const bool receiver_only_;
danilchap8bab7962016-12-20 02:46:46 -0800380 ModuleRtpRtcp* const rtp_rtcp_;
Victor Boivie306b1392021-04-27 10:33:58 +0200381 // The set of registered local SSRCs.
Tommi08be9ba2021-06-15 23:01:57 +0200382 RegisteredSsrcs registered_ssrcs_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000383
spranga790d832016-12-02 07:29:44 -0800384 RtcpBandwidthObserver* const rtcp_bandwidth_observer_;
385 RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
Elad Alon0a8562e2019-04-09 11:55:13 +0200386 RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
Sebastian Janssone1795f42019-07-24 11:38:03 +0200387 NetworkStateEstimateObserver* const network_state_estimate_observer_;
spranga790d832016-12-02 07:29:44 -0800388 TransportFeedbackObserver* const transport_feedback_observer_;
389 VideoBitrateAllocationObserver* const bitrate_allocation_observer_;
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200390 const TimeDelta report_interval_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000391
Markus Handelle7c015e2020-07-07 11:44:28 +0200392 mutable Mutex rtcp_receiver_lock_;
danilchap56359be2017-09-07 07:53:45 -0700393 uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000394
danilchap8bab7962016-12-20 02:46:46 -0800395 // Received sender report.
danilchap56359be2017-09-07 07:53:45 -0700396 NtpTime remote_sender_ntp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
397 uint32_t remote_sender_rtp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap0b4b7272016-10-06 09:24:45 -0700398 // When did we receive the last send report.
danilchap56359be2017-09-07 07:53:45 -0700399 NtpTime last_received_sr_ntp_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Alessio Bazzica048adc72021-03-10 15:05:55 +0100400 uint32_t remote_sender_packet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
401 uint64_t remote_sender_octet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
402 uint64_t remote_sender_reports_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000403
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200404 // Received RRTR information in ascending receive time order.
405 std::list<RrtrInformation> received_rrtrs_
406 RTC_GUARDED_BY(rtcp_receiver_lock_);
407 // Received RRTR information mapped by remote ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200408 flat_map<uint32_t, std::list<RrtrInformation>::iterator>
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200409 received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_);
410
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000411 // Estimated rtt, zero when there is no valid estimate.
Ivo Creusen8c40d512021-07-13 12:53:22 +0000412 bool xr_rrtr_status_ RTC_GUARDED_BY(rtcp_receiver_lock_);
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000413 int64_t xr_rr_rtt_ms_;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000414
danilchap56359be2017-09-07 07:53:45 -0700415 int64_t oldest_tmmbr_info_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800416 // Mapped by remote ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200417 flat_map<uint32_t, TmmbrInformation> tmmbr_infos_
danilchap56359be2017-09-07 07:53:45 -0700418 RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800419
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200420 // Round-Trip Time per remote sender ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200421 flat_map<uint32_t, RttStats> rtts_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Ivo Creusen2562cf02021-09-03 14:51:22 +0000422 // Non-sender Round-trip time per remote ssrc.
423 flat_map<uint32_t, NonSenderRttStats> non_sender_rtts_
424 RTC_GUARDED_BY(rtcp_receiver_lock_);
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200425
426 // Report blocks per local source ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200427 flat_map<uint32_t, ReportBlockData> received_report_blocks_
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200428 RTC_GUARDED_BY(rtcp_receiver_lock_);
Victor Boivief7156182021-07-06 23:14:51 +0200429 flat_map<uint32_t, LastFirStatus> last_fir_
danilchap56359be2017-09-07 07:53:45 -0700430 RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000431
Danil Chapovalov760c4b42017-09-27 13:25:24 +0200432 // The last time we received an RTCP Report block for this module.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200433 Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) =
434 Timestamp::PlusInfinity();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000435
asapersson@webrtc.orgcb791412014-12-18 14:30:32 +0000436 // The time we last received an RTCP RR telling we have successfully
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000437 // delivered RTP packet to the remote side.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200438 Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity();
stefan@webrtc.org8ca8a712013-04-23 16:48:32 +0000439
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100440 RtcpCnameCallback* const cname_callback_;
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100441 ReportBlockDataObserver* const report_block_data_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000442
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000443 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000444 RtcpPacketTypeCounter packet_type_counter_;
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000445
danilchap84432382017-02-09 05:21:42 -0800446 RtcpNackStats nack_stats_;
Erik Språng6b8d3552015-09-24 15:06:57 +0200447
448 size_t num_skipped_packets_;
danilchap8bab7962016-12-20 02:46:46 -0800449 int64_t last_skipped_packets_warning_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000450};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000451} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200452#endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_