blob: 206b63ae8fd1051caf1784642e05d09e6377a15e [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
Ivo Creusen8c40d512021-07-13 12:53:22 +0000111 void SetNonSenderRttMeasurement(bool enabled);
danilchapda161d72016-08-19 07:29:46 -0700112 bool GetAndResetXrRrRtt(int64_t* rtt_ms);
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000113
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200114 // Called once per second on the worker thread to do rtt calculations.
115 // Returns an optional rtt value if one is available.
116 absl::optional<TimeDelta> OnPeriodicRttUpdate(Timestamp newer_than,
117 bool sending);
118
Henrik Boströmf2047872019-05-16 13:32:20 +0200119 // A snapshot of Report Blocks with additional data of interest to statistics.
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200120 // Within this list, the source SSRC is unique and ReportBlockData represents
121 // the latest Report Block that was received for that SSRC.
Henrik Boströmf2047872019-05-16 13:32:20 +0200122 std::vector<ReportBlockData> GetLatestReportBlockData() const;
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +0000123
danilchapda161d72016-08-19 07:29:46 -0700124 // Returns true if we haven't received an RTCP RR for several RTCP
125 // intervals, but only triggers true once.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800126 bool RtcpRrTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000127
danilchapda161d72016-08-19 07:29:46 -0700128 // Returns true if we haven't received an RTCP RR telling the receive side
129 // has not received RTP packets for too long, i.e. extended highest sequence
130 // number hasn't increased for several RTCP intervals. The function only
131 // returns true once until a new RR is received.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800132 bool RtcpRrSequenceNumberTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000133
danilchap7851bda2016-09-29 15:28:07 -0700134 std::vector<rtcp::TmmbItem> TmmbrReceived();
danilchap9bf610e2017-02-20 06:03:01 -0800135 // Return true if new bandwidth should be set.
136 bool UpdateTmmbrTimers();
danilchapda161d72016-08-19 07:29:46 -0700137 std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
danilchap9bf610e2017-02-20 06:03:01 -0800138 // Set new bandwidth and notify remote clients about it.
139 void NotifyTmmbrUpdated();
niklase@google.com470e71d2011-07-07 08:21:25 +0000140
danilchapdd128922016-09-13 12:23:29 -0700141 private:
Tommi08be9ba2021-06-15 23:01:57 +0200142#if RTC_DCHECK_IS_ON
143 class CustomSequenceChecker : public SequenceChecker {
Victor Boivie306b1392021-04-27 10:33:58 +0200144 public:
Tommi08be9ba2021-06-15 23:01:57 +0200145 explicit CustomSequenceChecker(bool disable_checks)
146 : disable_checks_(disable_checks) {}
147 bool IsCurrent() const {
148 if (disable_checks_)
149 return true;
150 return SequenceChecker::IsCurrent();
Victor Boivie306b1392021-04-27 10:33:58 +0200151 }
152
153 private:
Tommi08be9ba2021-06-15 23:01:57 +0200154 const bool disable_checks_;
155 };
156#else
157 class CustomSequenceChecker : public SequenceChecker {
158 public:
159 explicit CustomSequenceChecker(bool) {}
160 };
161#endif
162
163 // A lightweight inlined set of local SSRCs.
164 class RegisteredSsrcs {
165 public:
166 static constexpr size_t kMediaSsrcIndex = 0;
167 static constexpr size_t kMaxSsrcs = 3;
168 // Initializes the set of registered local SSRCS by extracting them from the
169 // provided `config`. The `disable_sequence_checker` flag is a workaround
170 // to be able to use a sequence checker without breaking downstream
171 // code that currently doesn't follow the same threading rules as webrtc.
172 RegisteredSsrcs(bool disable_sequence_checker,
173 const RtpRtcpInterface::Configuration& config);
174
175 // Indicates if `ssrc` is in the set of registered local SSRCs.
176 bool contains(uint32_t ssrc) const;
177 uint32_t media_ssrc() const;
178 void set_media_ssrc(uint32_t ssrc);
179
180 private:
181 RTC_NO_UNIQUE_ADDRESS CustomSequenceChecker packet_sequence_checker_;
182 absl::InlinedVector<uint32_t, kMaxSsrcs> ssrcs_
183 RTC_GUARDED_BY(packet_sequence_checker_);
Victor Boivie306b1392021-04-27 10:33:58 +0200184 };
185
danilchap92ea6012016-09-23 10:36:03 -0700186 struct PacketInformation;
Stephan Hartmann26946722021-05-03 11:06:23 +0000187
188 // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104,
189 // section 3.5.4).
190 struct TmmbrInformation {
191 struct TimedTmmbrItem {
192 rtcp::TmmbItem tmmbr_item;
193 int64_t last_updated_ms;
194 };
195
196 int64_t last_time_received_ms = 0;
197
198 bool ready_for_delete = false;
199
200 std::vector<rtcp::TmmbItem> tmmbn;
201 std::map<uint32_t, TimedTmmbrItem> tmmbr;
202 };
203
204 // Structure for storing received RRTR RTCP messages (RFC3611, section 4.4).
205 struct RrtrInformation {
206 RrtrInformation(uint32_t ssrc,
207 uint32_t received_remote_mid_ntp_time,
208 uint32_t local_receive_mid_ntp_time)
209 : ssrc(ssrc),
210 received_remote_mid_ntp_time(received_remote_mid_ntp_time),
211 local_receive_mid_ntp_time(local_receive_mid_ntp_time) {}
212
213 uint32_t ssrc;
214 // Received NTP timestamp in compact representation.
215 uint32_t received_remote_mid_ntp_time;
216 // NTP time when the report was received in compact representation.
217 uint32_t local_receive_mid_ntp_time;
218 };
219
220 struct LastFirStatus {
221 LastFirStatus(int64_t now_ms, uint8_t sequence_number)
222 : request_ms(now_ms), sequence_number(sequence_number) {}
223 int64_t request_ms;
224 uint8_t sequence_number;
225 };
Victor Boivie0c563a42021-04-27 10:24:01 +0200226
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200227 class RttStats {
228 public:
229 RttStats() = default;
230 RttStats(const RttStats&) = default;
231 RttStats& operator=(const RttStats&) = default;
Victor Boivie0c563a42021-04-27 10:24:01 +0200232
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200233 void AddRtt(TimeDelta rtt);
234
235 TimeDelta last_rtt() const { return last_rtt_; }
236 TimeDelta min_rtt() const { return min_rtt_; }
237 TimeDelta max_rtt() const { return max_rtt_; }
238 TimeDelta average_rtt() const { return sum_rtt_ / num_rtts_; }
239
240 private:
241 TimeDelta last_rtt_ = TimeDelta::Zero();
242 TimeDelta min_rtt_ = TimeDelta::PlusInfinity();
243 TimeDelta max_rtt_ = TimeDelta::MinusInfinity();
244 TimeDelta sum_rtt_ = TimeDelta::Zero();
245 size_t num_rtts_ = 0;
246 };
danilchapdd128922016-09-13 12:23:29 -0700247
Danil Chapovalov443f2662020-03-11 12:24:40 +0100248 bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
danilchap92ea6012016-09-23 10:36:03 -0700249 PacketInformation* packet_information);
danilchapdd128922016-09-13 12:23:29 -0700250
danilchap8bab7962016-12-20 02:46:46 -0800251 void TriggerCallbacksFromRtcpPacket(
danilchap92ea6012016-09-23 10:36:03 -0700252 const PacketInformation& packet_information);
danilchapdd128922016-09-13 12:23:29 -0700253
danilchapec067e92017-02-21 05:38:19 -0800254 TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700255 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapec067e92017-02-21 05:38:19 -0800256 // Update TmmbrInformation (if present) is alive.
257 void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700258 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800259 TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700260 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000261
danilchap92ea6012016-09-23 10:36:03 -0700262 void HandleSenderReport(const rtcp::CommonHeader& rtcp_block,
263 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700264 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Danil Chapovalov91511f12016-09-15 16:24:02 +0200265
danilchap92ea6012016-09-23 10:36:03 -0700266 void HandleReceiverReport(const rtcp::CommonHeader& rtcp_block,
267 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700268 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000269
danilchap1b1863a2016-09-20 01:39:54 -0700270 void HandleReportBlock(const rtcp::ReportBlock& report_block,
danilchap92ea6012016-09-23 10:36:03 -0700271 PacketInformation* packet_information,
danilchap8bab7962016-12-20 02:46:46 -0800272 uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700273 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000274
danilchap8bab7962016-12-20 02:46:46 -0800275 void HandleSdes(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700276 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700277 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000278
danilchap1b1863a2016-09-20 01:39:54 -0700279 void HandleXr(const rtcp::CommonHeader& rtcp_block,
Björn Terelius2c41cba2021-09-01 16:03:26 +0000280 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700281 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000282
danilchap92ea6012016-09-23 10:36:03 -0700283 void HandleXrReceiveReferenceTime(uint32_t sender_ssrc,
284 const rtcp::Rrtr& rrtr)
danilchap56359be2017-09-07 07:53:45 -0700285 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000286
Björn Terelius2c41cba2021-09-01 16:03:26 +0000287 void HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti)
danilchap56359be2017-09-07 07:53:45 -0700288 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700289
sprangb32aaf92017-08-28 05:49:12 -0700290 void HandleXrTargetBitrate(uint32_t ssrc,
291 const rtcp::TargetBitrate& target_bitrate,
spranga790d832016-12-02 07:29:44 -0800292 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700293 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
spranga790d832016-12-02 07:29:44 -0800294
danilchap8bab7962016-12-20 02:46:46 -0800295 void HandleNack(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700296 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700297 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700298
Sebastian Janssone1795f42019-07-24 11:38:03 +0200299 void HandleApp(const rtcp::CommonHeader& rtcp_block,
300 PacketInformation* packet_information)
301 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
302
danilchap8bab7962016-12-20 02:46:46 -0800303 void HandleBye(const rtcp::CommonHeader& rtcp_block)
danilchap56359be2017-09-07 07:53:45 -0700304 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700305
danilchap8bab7962016-12-20 02:46:46 -0800306 void HandlePli(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700307 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700308 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700309
danilchap1b1863a2016-09-20 01:39:54 -0700310 void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700311 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700312 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700313
danilchap8bab7962016-12-20 02:46:46 -0800314 void HandleTmmbr(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700315 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700316 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000317
danilchap8bab7962016-12-20 02:46:46 -0800318 void HandleTmmbn(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700319 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700320 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000321
danilchap8bab7962016-12-20 02:46:46 -0800322 void HandleSrReq(const rtcp::CommonHeader& rtcp_block,
323 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700324 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000325
danilchap8bab7962016-12-20 02:46:46 -0800326 void HandleFir(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700327 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700328 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700329
danilchap92ea6012016-09-23 10:36:03 -0700330 void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block,
331 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700332 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Erik Språng6b8d3552015-09-24 15:06:57 +0200333
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200334 bool RtcpRrTimeoutLocked(Timestamp now)
335 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
336
337 bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now)
338 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
339
danilchap8bab7962016-12-20 02:46:46 -0800340 Clock* const clock_;
Peter Boströmfe7a80c2015-04-23 17:53:17 +0200341 const bool receiver_only_;
danilchap8bab7962016-12-20 02:46:46 -0800342 ModuleRtpRtcp* const rtp_rtcp_;
Erik Språng6841d252019-10-15 14:29:11 +0200343 const uint32_t main_ssrc_;
Victor Boivie306b1392021-04-27 10:33:58 +0200344 // The set of registered local SSRCs.
Tommi08be9ba2021-06-15 23:01:57 +0200345 RegisteredSsrcs registered_ssrcs_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000346
spranga790d832016-12-02 07:29:44 -0800347 RtcpBandwidthObserver* const rtcp_bandwidth_observer_;
348 RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
Elad Alon0a8562e2019-04-09 11:55:13 +0200349 RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
Sebastian Janssone1795f42019-07-24 11:38:03 +0200350 NetworkStateEstimateObserver* const network_state_estimate_observer_;
spranga790d832016-12-02 07:29:44 -0800351 TransportFeedbackObserver* const transport_feedback_observer_;
352 VideoBitrateAllocationObserver* const bitrate_allocation_observer_;
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200353 const TimeDelta report_interval_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000354
Markus Handelle7c015e2020-07-07 11:44:28 +0200355 mutable Mutex rtcp_receiver_lock_;
danilchap56359be2017-09-07 07:53:45 -0700356 uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000357
danilchap8bab7962016-12-20 02:46:46 -0800358 // Received sender report.
danilchap56359be2017-09-07 07:53:45 -0700359 NtpTime remote_sender_ntp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
360 uint32_t remote_sender_rtp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap0b4b7272016-10-06 09:24:45 -0700361 // When did we receive the last send report.
danilchap56359be2017-09-07 07:53:45 -0700362 NtpTime last_received_sr_ntp_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Alessio Bazzica048adc72021-03-10 15:05:55 +0100363 uint32_t remote_sender_packet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
364 uint64_t remote_sender_octet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
365 uint64_t remote_sender_reports_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000366
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200367 // Received RRTR information in ascending receive time order.
368 std::list<RrtrInformation> received_rrtrs_
369 RTC_GUARDED_BY(rtcp_receiver_lock_);
370 // Received RRTR information mapped by remote ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200371 flat_map<uint32_t, std::list<RrtrInformation>::iterator>
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200372 received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_);
373
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000374 // Estimated rtt, zero when there is no valid estimate.
Ivo Creusen8c40d512021-07-13 12:53:22 +0000375 bool xr_rrtr_status_ RTC_GUARDED_BY(rtcp_receiver_lock_);
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000376 int64_t xr_rr_rtt_ms_;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000377
danilchap56359be2017-09-07 07:53:45 -0700378 int64_t oldest_tmmbr_info_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800379 // Mapped by remote ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200380 flat_map<uint32_t, TmmbrInformation> tmmbr_infos_
danilchap56359be2017-09-07 07:53:45 -0700381 RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800382
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200383 // Round-Trip Time per remote sender ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200384 flat_map<uint32_t, RttStats> rtts_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200385
386 // Report blocks per local source ssrc.
Victor Boivief7156182021-07-06 23:14:51 +0200387 flat_map<uint32_t, ReportBlockData> received_report_blocks_
Danil Chapovalov510c94c2021-07-02 13:51:19 +0200388 RTC_GUARDED_BY(rtcp_receiver_lock_);
Victor Boivief7156182021-07-06 23:14:51 +0200389 flat_map<uint32_t, LastFirStatus> last_fir_
danilchap56359be2017-09-07 07:53:45 -0700390 RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000391
Danil Chapovalov760c4b42017-09-27 13:25:24 +0200392 // The last time we received an RTCP Report block for this module.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200393 Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) =
394 Timestamp::PlusInfinity();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000395
asapersson@webrtc.orgcb791412014-12-18 14:30:32 +0000396 // The time we last received an RTCP RR telling we have successfully
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000397 // delivered RTP packet to the remote side.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200398 Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity();
stefan@webrtc.org8ca8a712013-04-23 16:48:32 +0000399
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100400 RtcpCnameCallback* const cname_callback_;
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100401 ReportBlockDataObserver* const report_block_data_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000402
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000403 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000404 RtcpPacketTypeCounter packet_type_counter_;
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000405
danilchap84432382017-02-09 05:21:42 -0800406 RtcpNackStats nack_stats_;
Erik Språng6b8d3552015-09-24 15:06:57 +0200407
408 size_t num_skipped_packets_;
danilchap8bab7962016-12-20 02:46:46 -0800409 int64_t last_skipped_packets_warning_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000410};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000411} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200412#endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_