blob: fa9f367c9e38dd1584e524c942f5815c60adb088 [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
Danil Chapovalov443f2662020-03-11 12:24:40 +010019#include "api/array_view.h"
Tommi08be9ba2021-06-15 23:01:57 +020020#include "api/sequence_checker.h"
Henrik Boströmf2047872019-05-16 13:32:20 +020021#include "modules/rtp_rtcp/include/report_block_data.h"
Niels Möller53382cb2018-11-27 14:05:08 +010022#include "modules/rtp_rtcp/include/rtcp_statistics.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
24#include "modules/rtp_rtcp/source/rtcp_nack_stats.h"
25#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
Stephan Hartmann26946722021-05-03 11:06:23 +000026#include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020027#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
Victor Boivief7156182021-07-06 23:14:51 +020028#include "rtc_base/containers/flat_map.h"
Markus Handelle7c015e2020-07-07 11:44:28 +020029#include "rtc_base/synchronization/mutex.h"
Tommi08be9ba2021-06-15 23:01:57 +020030#include "rtc_base/system/no_unique_address.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020031#include "rtc_base/thread_annotations.h"
32#include "system_wrappers/include/ntp_time.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000033
34namespace webrtc {
Tommi08be9ba2021-06-15 23:01:57 +020035
36class ModuleRtpRtcpImpl2;
spranga790d832016-12-02 07:29:44 -080037class VideoBitrateAllocationObserver;
Tommi08be9ba2021-06-15 23:01:57 +020038
danilchap59cb2bd2016-08-29 11:08:47 -070039namespace rtcp {
danilchap1b1863a2016-09-20 01:39:54 -070040class CommonHeader;
danilchap1b1863a2016-09-20 01:39:54 -070041class ReportBlock;
42class Rrtr;
spranga790d832016-12-02 07:29:44 -080043class TargetBitrate;
danilchap59cb2bd2016-08-29 11:08:47 -070044class TmmbItem;
45} // namespace rtcp
pwestin@webrtc.org741da942011-09-20 13:52:04 +000046
Danil Chapovalov443f2662020-03-11 12:24:40 +010047class RTCPReceiver final {
danilchapda161d72016-08-19 07:29:46 -070048 public:
danilchap59cb2bd2016-08-29 11:08:47 -070049 class ModuleRtpRtcp {
50 public:
51 virtual void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) = 0;
52 virtual void OnRequestSendReport() = 0;
53 virtual void OnReceivedNack(
54 const std::vector<uint16_t>& nack_sequence_numbers) = 0;
55 virtual void OnReceivedRtcpReportBlocks(
56 const ReportBlockList& report_blocks) = 0;
57
58 protected:
59 virtual ~ModuleRtpRtcp() = default;
60 };
61
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020062 RTCPReceiver(const RtpRtcpInterface::Configuration& config,
63 ModuleRtpRtcp* owner);
Tommi08be9ba2021-06-15 23:01:57 +020064
65 RTCPReceiver(const RtpRtcpInterface::Configuration& config,
66 ModuleRtpRtcpImpl2* owner);
67
Danil Chapovalov443f2662020-03-11 12:24:40 +010068 ~RTCPReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +000069
Danil Chapovalov443f2662020-03-11 12:24:40 +010070 void IncomingPacket(const uint8_t* packet, size_t packet_size) {
71 IncomingPacket(rtc::MakeArrayView(packet, packet_size));
72 }
73 void IncomingPacket(rtc::ArrayView<const uint8_t> packet);
danilchap59cb2bd2016-08-29 11:08:47 -070074
Danil Chapovalov760c4b42017-09-27 13:25:24 +020075 int64_t LastReceivedReportBlockMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000076
Tommi08be9ba2021-06-15 23:01:57 +020077 void set_local_media_ssrc(uint32_t ssrc);
78 uint32_t local_media_ssrc() const;
79
danilchapda161d72016-08-19 07:29:46 -070080 void SetRemoteSSRC(uint32_t ssrc);
81 uint32_t RemoteSSRC() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000082
Tommi08be9ba2021-06-15 23:01:57 +020083 bool receiver_only() const { return receiver_only_; }
84
danilchap8bab7962016-12-20 02:46:46 -080085 // Get received NTP.
Alessio Bazzica048adc72021-03-10 15:05:55 +010086 // The types for the arguments below derive from the specification:
87 // - `remote_sender_packet_count`: `RTCSentRtpStreamStats.packetsSent` [1]
88 // - `remote_sender_octet_count`: `RTCSentRtpStreamStats.bytesSent` [1]
89 // - `remote_sender_reports_count`:
90 // `RTCRemoteOutboundRtpStreamStats.reportsSent` [2]
91 // [1] https://www.w3.org/TR/webrtc-stats/#remoteoutboundrtpstats-dict*
92 // [2] https://www.w3.org/TR/webrtc-stats/#dom-rtcsentrtpstreamstats
danilchap8bab7962016-12-20 02:46:46 -080093 bool NTP(uint32_t* received_ntp_secs,
94 uint32_t* received_ntp_frac,
95 uint32_t* rtcp_arrival_time_secs,
96 uint32_t* rtcp_arrival_time_frac,
Alessio Bazzica048adc72021-03-10 15:05:55 +010097 uint32_t* rtcp_timestamp,
98 uint32_t* remote_sender_packet_count,
99 uint64_t* remote_sender_octet_count,
100 uint64_t* remote_sender_reports_count) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200102 std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo();
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000103
danilchap28b03eb2016-10-05 06:59:44 -0700104 // Get rtt.
105 int32_t RTT(uint32_t remote_ssrc,
106 int64_t* last_rtt_ms,
107 int64_t* avg_rtt_ms,
108 int64_t* min_rtt_ms,
109 int64_t* max_rtt_ms) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000110
danilchapda161d72016-08-19 07:29:46 -0700111 bool GetAndResetXrRrRtt(int64_t* rtt_ms);
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000112
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200113 // Called once per second on the worker thread to do rtt calculations.
114 // Returns an optional rtt value if one is available.
115 absl::optional<TimeDelta> OnPeriodicRttUpdate(Timestamp newer_than,
116 bool sending);
117
Henrik Boströmf2047872019-05-16 13:32:20 +0200118 // A snapshot of Report Blocks with additional data of interest to statistics.
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200119 // Within this list, the source SSRC is unique and ReportBlockData represents
120 // the latest Report Block that was received for that SSRC.
Henrik Boströmf2047872019-05-16 13:32:20 +0200121 std::vector<ReportBlockData> GetLatestReportBlockData() const;
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +0000122
danilchapda161d72016-08-19 07:29:46 -0700123 // Returns true if we haven't received an RTCP RR for several RTCP
124 // intervals, but only triggers true once.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800125 bool RtcpRrTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000126
danilchapda161d72016-08-19 07:29:46 -0700127 // Returns true if we haven't received an RTCP RR telling the receive side
128 // has not received RTP packets for too long, i.e. extended highest sequence
129 // number hasn't increased for several RTCP intervals. The function only
130 // returns true once until a new RR is received.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800131 bool RtcpRrSequenceNumberTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000132
danilchap7851bda2016-09-29 15:28:07 -0700133 std::vector<rtcp::TmmbItem> TmmbrReceived();
danilchap9bf610e2017-02-20 06:03:01 -0800134 // Return true if new bandwidth should be set.
135 bool UpdateTmmbrTimers();
danilchapda161d72016-08-19 07:29:46 -0700136 std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
danilchap9bf610e2017-02-20 06:03:01 -0800137 // Set new bandwidth and notify remote clients about it.
138 void NotifyTmmbrUpdated();
niklase@google.com470e71d2011-07-07 08:21:25 +0000139
danilchapdd128922016-09-13 12:23:29 -0700140 private:
Tommi08be9ba2021-06-15 23:01:57 +0200141#if RTC_DCHECK_IS_ON
142 class CustomSequenceChecker : public SequenceChecker {
Victor Boivie306b1392021-04-27 10:33:58 +0200143 public:
Tommi08be9ba2021-06-15 23:01:57 +0200144 explicit CustomSequenceChecker(bool disable_checks)
145 : disable_checks_(disable_checks) {}
146 bool IsCurrent() const {
147 if (disable_checks_)
148 return true;
149 return SequenceChecker::IsCurrent();
Victor Boivie306b1392021-04-27 10:33:58 +0200150 }
151
152 private:
Tommi08be9ba2021-06-15 23:01:57 +0200153 const bool disable_checks_;
154 };
155#else
156 class CustomSequenceChecker : public SequenceChecker {
157 public:
158 explicit CustomSequenceChecker(bool) {}
159 };
160#endif
161
162 // A lightweight inlined set of local SSRCs.
163 class RegisteredSsrcs {
164 public:
165 static constexpr size_t kMediaSsrcIndex = 0;
166 static constexpr size_t kMaxSsrcs = 3;
167 // Initializes the set of registered local SSRCS by extracting them from the
168 // provided `config`. The `disable_sequence_checker` flag is a workaround
169 // to be able to use a sequence checker without breaking downstream
170 // code that currently doesn't follow the same threading rules as webrtc.
171 RegisteredSsrcs(bool disable_sequence_checker,
172 const RtpRtcpInterface::Configuration& config);
173
174 // Indicates if `ssrc` is in the set of registered local SSRCs.
175 bool contains(uint32_t ssrc) const;
176 uint32_t media_ssrc() const;
177 void set_media_ssrc(uint32_t ssrc);
178
179 private:
180 RTC_NO_UNIQUE_ADDRESS CustomSequenceChecker packet_sequence_checker_;
181 absl::InlinedVector<uint32_t, kMaxSsrcs> ssrcs_
182 RTC_GUARDED_BY(packet_sequence_checker_);
Victor Boivie306b1392021-04-27 10:33:58 +0200183 };
184
danilchap92ea6012016-09-23 10:36:03 -0700185 struct PacketInformation;
Stephan Hartmann26946722021-05-03 11:06:23 +0000186
187 // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104,
188 // section 3.5.4).
189 struct TmmbrInformation {
190 struct TimedTmmbrItem {
191 rtcp::TmmbItem tmmbr_item;
192 int64_t last_updated_ms;
193 };
194
195 int64_t last_time_received_ms = 0;
196
197 bool ready_for_delete = false;
198
199 std::vector<rtcp::TmmbItem> tmmbn;
200 std::map<uint32_t, TimedTmmbrItem> tmmbr;
201 };
202
203 // Structure for storing received RRTR RTCP messages (RFC3611, section 4.4).
204 struct RrtrInformation {
205 RrtrInformation(uint32_t ssrc,
206 uint32_t received_remote_mid_ntp_time,
207 uint32_t local_receive_mid_ntp_time)
208 : ssrc(ssrc),
209 received_remote_mid_ntp_time(received_remote_mid_ntp_time),
210 local_receive_mid_ntp_time(local_receive_mid_ntp_time) {}
211
212 uint32_t ssrc;
213 // Received NTP timestamp in compact representation.
214 uint32_t received_remote_mid_ntp_time;
215 // NTP time when the report was received in compact representation.
216 uint32_t local_receive_mid_ntp_time;
217 };
218
219 struct LastFirStatus {
220 LastFirStatus(int64_t now_ms, uint8_t sequence_number)
221 : request_ms(now_ms), sequence_number(sequence_number) {}
222 int64_t request_ms;
223 uint8_t sequence_number;
224 };
Victor Boivie0c563a42021-04-27 10:24:01 +0200225
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200226 class RttStats {
227 public:
228 RttStats() = default;
229 RttStats(const RttStats&) = default;
230 RttStats& operator=(const RttStats&) = default;
Victor Boivie0c563a42021-04-27 10:24:01 +0200231
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200232 void AddRtt(TimeDelta rtt);
233
234 TimeDelta last_rtt() const { return last_rtt_; }
235 TimeDelta min_rtt() const { return min_rtt_; }
236 TimeDelta max_rtt() const { return max_rtt_; }
237 TimeDelta average_rtt() const { return sum_rtt_ / num_rtts_; }
238
239 private:
240 TimeDelta last_rtt_ = TimeDelta::Zero();
241 TimeDelta min_rtt_ = TimeDelta::PlusInfinity();
242 TimeDelta max_rtt_ = TimeDelta::MinusInfinity();
243 TimeDelta sum_rtt_ = TimeDelta::Zero();
244 size_t num_rtts_ = 0;
245 };
danilchapdd128922016-09-13 12:23:29 -0700246
Danil Chapovalov443f2662020-03-11 12:24:40 +0100247 bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
danilchap92ea6012016-09-23 10:36:03 -0700248 PacketInformation* packet_information);
danilchapdd128922016-09-13 12:23:29 -0700249
danilchap8bab7962016-12-20 02:46:46 -0800250 void TriggerCallbacksFromRtcpPacket(
danilchap92ea6012016-09-23 10:36:03 -0700251 const PacketInformation& packet_information);
danilchapdd128922016-09-13 12:23:29 -0700252
danilchapec067e92017-02-21 05:38:19 -0800253 TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700254 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapec067e92017-02-21 05:38:19 -0800255 // Update TmmbrInformation (if present) is alive.
256 void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700257 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800258 TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700259 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000260
danilchap92ea6012016-09-23 10:36:03 -0700261 void HandleSenderReport(const rtcp::CommonHeader& rtcp_block,
262 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700263 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Danil Chapovalov91511f12016-09-15 16:24:02 +0200264
danilchap92ea6012016-09-23 10:36:03 -0700265 void HandleReceiverReport(const rtcp::CommonHeader& rtcp_block,
266 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700267 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000268
danilchap1b1863a2016-09-20 01:39:54 -0700269 void HandleReportBlock(const rtcp::ReportBlock& report_block,
danilchap92ea6012016-09-23 10:36:03 -0700270 PacketInformation* packet_information,
danilchap8bab7962016-12-20 02:46:46 -0800271 uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700272 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000273
danilchap8bab7962016-12-20 02:46:46 -0800274 void HandleSdes(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700275 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700276 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000277
danilchap1b1863a2016-09-20 01:39:54 -0700278 void HandleXr(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700279 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700280 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000281
danilchap92ea6012016-09-23 10:36:03 -0700282 void HandleXrReceiveReferenceTime(uint32_t sender_ssrc,
283 const rtcp::Rrtr& rrtr)
danilchap56359be2017-09-07 07:53:45 -0700284 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000285
danilchap92ea6012016-09-23 10:36:03 -0700286 void HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti)
danilchap56359be2017-09-07 07:53:45 -0700287 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700288
sprangb32aaf92017-08-28 05:49:12 -0700289 void HandleXrTargetBitrate(uint32_t ssrc,
290 const rtcp::TargetBitrate& target_bitrate,
spranga790d832016-12-02 07:29:44 -0800291 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700292 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
spranga790d832016-12-02 07:29:44 -0800293
danilchap8bab7962016-12-20 02:46:46 -0800294 void HandleNack(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700295 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700296 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700297
Sebastian Janssone1795f42019-07-24 11:38:03 +0200298 void HandleApp(const rtcp::CommonHeader& rtcp_block,
299 PacketInformation* packet_information)
300 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
301
danilchap8bab7962016-12-20 02:46:46 -0800302 void HandleBye(const rtcp::CommonHeader& rtcp_block)
danilchap56359be2017-09-07 07:53:45 -0700303 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700304
danilchap8bab7962016-12-20 02:46:46 -0800305 void HandlePli(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700306 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700307 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700308
danilchap1b1863a2016-09-20 01:39:54 -0700309 void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700310 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700311 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700312
danilchap8bab7962016-12-20 02:46:46 -0800313 void HandleTmmbr(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700314 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700315 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000316
danilchap8bab7962016-12-20 02:46:46 -0800317 void HandleTmmbn(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700318 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700319 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000320
danilchap8bab7962016-12-20 02:46:46 -0800321 void HandleSrReq(const rtcp::CommonHeader& rtcp_block,
322 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700323 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000324
danilchap8bab7962016-12-20 02:46:46 -0800325 void HandleFir(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700326 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700327 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700328
danilchap92ea6012016-09-23 10:36:03 -0700329 void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block,
330 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700331 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Erik Språng6b8d3552015-09-24 15:06:57 +0200332
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200333 bool RtcpRrTimeoutLocked(Timestamp now)
334 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
335
336 bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now)
337 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
338
danilchap8bab7962016-12-20 02:46:46 -0800339 Clock* const clock_;
Peter Boströmfe7a80c2015-04-23 17:53:17 +0200340 const bool receiver_only_;
danilchap8bab7962016-12-20 02:46:46 -0800341 ModuleRtpRtcp* const rtp_rtcp_;
Erik Språng6841d252019-10-15 14:29:11 +0200342 const uint32_t main_ssrc_;
Victor Boivie306b1392021-04-27 10:33:58 +0200343 // The set of registered local SSRCs.
Tommi08be9ba2021-06-15 23:01:57 +0200344 RegisteredSsrcs registered_ssrcs_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000345
spranga790d832016-12-02 07:29:44 -0800346 RtcpBandwidthObserver* const rtcp_bandwidth_observer_;
347 RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
Elad Alon0a8562e2019-04-09 11:55:13 +0200348 RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
Sebastian Janssone1795f42019-07-24 11:38:03 +0200349 NetworkStateEstimateObserver* const network_state_estimate_observer_;
spranga790d832016-12-02 07:29:44 -0800350 TransportFeedbackObserver* const transport_feedback_observer_;
351 VideoBitrateAllocationObserver* const bitrate_allocation_observer_;
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200352 const TimeDelta report_interval_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000353
Markus Handelle7c015e2020-07-07 11:44:28 +0200354 mutable Mutex rtcp_receiver_lock_;
danilchap56359be2017-09-07 07:53:45 -0700355 uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000356
danilchap8bab7962016-12-20 02:46:46 -0800357 // Received sender report.
danilchap56359be2017-09-07 07:53:45 -0700358 NtpTime remote_sender_ntp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
359 uint32_t remote_sender_rtp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap0b4b7272016-10-06 09:24:45 -0700360 // When did we receive the last send report.
danilchap56359be2017-09-07 07:53:45 -0700361 NtpTime last_received_sr_ntp_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Alessio Bazzica048adc72021-03-10 15:05:55 +0100362 uint32_t remote_sender_packet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
363 uint64_t remote_sender_octet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
364 uint64_t remote_sender_reports_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000365
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200366 // Received RRTR information in ascending receive time order.
367 std::list<RrtrInformation> received_rrtrs_
368 RTC_GUARDED_BY(rtcp_receiver_lock_);
369 // Received RRTR information mapped by remote ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200370 flat_map<uint32_t, std::list<RrtrInformation>::iterator>
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200371 received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_);
372
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000373 // Estimated rtt, zero when there is no valid estimate.
Niels Möllerbe810cb2020-12-02 14:25:03 +0100374 const bool xr_rrtr_status_;
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000375 int64_t xr_rr_rtt_ms_;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000376
danilchap56359be2017-09-07 07:53:45 -0700377 int64_t oldest_tmmbr_info_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800378 // Mapped by remote ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200379 flat_map<uint32_t, TmmbrInformation> tmmbr_infos_
danilchap56359be2017-09-07 07:53:45 -0700380 RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800381
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200382 // Round-Trip Time per remote sender ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200383 flat_map<uint32_t, RttStats> rtts_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200384
385 // Report blocks per local source ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200386 flat_map<uint32_t, ReportBlockData> received_report_blocks_
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200387 RTC_GUARDED_BY(rtcp_receiver_lock_);
Victor Boivief7156182021-07-06 23:14:51 +0200388 flat_map<uint32_t, LastFirStatus> last_fir_
danilchap56359be2017-09-07 07:53:45 -0700389 RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000390
Danil Chapovalov760c4b42017-09-27 13:25:24 +0200391 // The last time we received an RTCP Report block for this module.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200392 Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) =
393 Timestamp::PlusInfinity();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000394
asapersson@webrtc.orgcb791412014-12-18 14:30:32 +0000395 // The time we last received an RTCP RR telling we have successfully
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000396 // delivered RTP packet to the remote side.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200397 Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity();
stefan@webrtc.org8ca8a712013-04-23 16:48:32 +0000398
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100399 RtcpCnameCallback* const cname_callback_;
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100400 ReportBlockDataObserver* const report_block_data_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000401
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000402 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000403 RtcpPacketTypeCounter packet_type_counter_;
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000404
danilchap84432382017-02-09 05:21:42 -0800405 RtcpNackStats nack_stats_;
Erik Språng6b8d3552015-09-24 15:06:57 +0200406
407 size_t num_skipped_packets_;
danilchap8bab7962016-12-20 02:46:46 -0800408 int64_t last_skipped_packets_warning_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000409};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000410} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200411#endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_