blob: 57dd1c06b46675acb20b7930259306b72c48288a [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>
stefan@webrtc.org28a331e2013-09-17 07:49:56 +000016#include <set>
danilchap95321242016-09-27 07:05:32 -070017#include <string>
Victor Boivie0c563a42021-04-27 10:24:01 +020018#include <unordered_map>
danilchapb8b6fbb2015-12-10 05:05:27 -080019#include <vector>
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +000020
Danil Chapovalov443f2662020-03-11 12:24:40 +010021#include "api/array_view.h"
Tommi08be9ba2021-06-15 23:01:57 +020022#include "api/sequence_checker.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"
Markus Handelle7c015e2020-07-07 11:44:28 +020030#include "rtc_base/synchronization/mutex.h"
Tommi08be9ba2021-06-15 23:01:57 +020031#include "rtc_base/system/no_unique_address.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020032#include "rtc_base/thread_annotations.h"
33#include "system_wrappers/include/ntp_time.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000034
35namespace webrtc {
Tommi08be9ba2021-06-15 23:01:57 +020036
37class ModuleRtpRtcpImpl2;
spranga790d832016-12-02 07:29:44 -080038class VideoBitrateAllocationObserver;
Tommi08be9ba2021-06-15 23:01:57 +020039
danilchap59cb2bd2016-08-29 11:08:47 -070040namespace rtcp {
danilchap1b1863a2016-09-20 01:39:54 -070041class CommonHeader;
danilchap1b1863a2016-09-20 01:39:54 -070042class ReportBlock;
43class Rrtr;
spranga790d832016-12-02 07:29:44 -080044class TargetBitrate;
danilchap59cb2bd2016-08-29 11:08:47 -070045class TmmbItem;
46} // namespace rtcp
pwestin@webrtc.org741da942011-09-20 13:52:04 +000047
Danil Chapovalov443f2662020-03-11 12:24:40 +010048class RTCPReceiver final {
danilchapda161d72016-08-19 07:29:46 -070049 public:
danilchap59cb2bd2016-08-29 11:08:47 -070050 class ModuleRtpRtcp {
51 public:
52 virtual void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) = 0;
53 virtual void OnRequestSendReport() = 0;
54 virtual void OnReceivedNack(
55 const std::vector<uint16_t>& nack_sequence_numbers) = 0;
56 virtual void OnReceivedRtcpReportBlocks(
57 const ReportBlockList& report_blocks) = 0;
58
59 protected:
60 virtual ~ModuleRtpRtcp() = default;
61 };
62
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020063 RTCPReceiver(const RtpRtcpInterface::Configuration& config,
64 ModuleRtpRtcp* owner);
Tommi08be9ba2021-06-15 23:01:57 +020065
66 RTCPReceiver(const RtpRtcpInterface::Configuration& config,
67 ModuleRtpRtcpImpl2* owner);
68
Danil Chapovalov443f2662020-03-11 12:24:40 +010069 ~RTCPReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +000070
Danil Chapovalov443f2662020-03-11 12:24:40 +010071 void IncomingPacket(const uint8_t* packet, size_t packet_size) {
72 IncomingPacket(rtc::MakeArrayView(packet, packet_size));
73 }
74 void IncomingPacket(rtc::ArrayView<const uint8_t> packet);
danilchap59cb2bd2016-08-29 11:08:47 -070075
Danil Chapovalov760c4b42017-09-27 13:25:24 +020076 int64_t LastReceivedReportBlockMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000077
Tommi08be9ba2021-06-15 23:01:57 +020078 void set_local_media_ssrc(uint32_t ssrc);
79 uint32_t local_media_ssrc() const;
80
danilchapda161d72016-08-19 07:29:46 -070081 void SetRemoteSSRC(uint32_t ssrc);
82 uint32_t RemoteSSRC() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
Tommi08be9ba2021-06-15 23:01:57 +020084 bool receiver_only() const { return receiver_only_; }
85
danilchap8bab7962016-12-20 02:46:46 -080086 // Get received NTP.
Alessio Bazzica048adc72021-03-10 15:05:55 +010087 // The types for the arguments below derive from the specification:
88 // - `remote_sender_packet_count`: `RTCSentRtpStreamStats.packetsSent` [1]
89 // - `remote_sender_octet_count`: `RTCSentRtpStreamStats.bytesSent` [1]
90 // - `remote_sender_reports_count`:
91 // `RTCRemoteOutboundRtpStreamStats.reportsSent` [2]
92 // [1] https://www.w3.org/TR/webrtc-stats/#remoteoutboundrtpstats-dict*
93 // [2] https://www.w3.org/TR/webrtc-stats/#dom-rtcsentrtpstreamstats
danilchap8bab7962016-12-20 02:46:46 -080094 bool NTP(uint32_t* received_ntp_secs,
95 uint32_t* received_ntp_frac,
96 uint32_t* rtcp_arrival_time_secs,
97 uint32_t* rtcp_arrival_time_frac,
Alessio Bazzica048adc72021-03-10 15:05:55 +010098 uint32_t* rtcp_timestamp,
99 uint32_t* remote_sender_packet_count,
100 uint64_t* remote_sender_octet_count,
101 uint64_t* remote_sender_reports_count) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200103 std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo();
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000104
danilchap28b03eb2016-10-05 06:59:44 -0700105 // Get rtt.
106 int32_t RTT(uint32_t remote_ssrc,
107 int64_t* last_rtt_ms,
108 int64_t* avg_rtt_ms,
109 int64_t* min_rtt_ms,
110 int64_t* max_rtt_ms) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
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.
120 // Within this list, the sender-source SSRC pair is unique and per-pair the
121 // ReportBlockData represents the latest Report Block that was received for
122 // that pair.
123 std::vector<ReportBlockData> GetLatestReportBlockData() const;
perkj@webrtc.orgce5990c2012-01-11 13:00:08 +0000124
danilchapda161d72016-08-19 07:29:46 -0700125 // Returns true if we haven't received an RTCP RR for several RTCP
126 // intervals, but only triggers true once.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800127 bool RtcpRrTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000128
danilchapda161d72016-08-19 07:29:46 -0700129 // Returns true if we haven't received an RTCP RR telling the receive side
130 // has not received RTP packets for too long, i.e. extended highest sequence
131 // number hasn't increased for several RTCP intervals. The function only
132 // returns true once until a new RR is received.
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800133 bool RtcpRrSequenceNumberTimeout();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000134
danilchap7851bda2016-09-29 15:28:07 -0700135 std::vector<rtcp::TmmbItem> TmmbrReceived();
danilchap9bf610e2017-02-20 06:03:01 -0800136 // Return true if new bandwidth should be set.
137 bool UpdateTmmbrTimers();
danilchapda161d72016-08-19 07:29:46 -0700138 std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
danilchap9bf610e2017-02-20 06:03:01 -0800139 // Set new bandwidth and notify remote clients about it.
140 void NotifyTmmbrUpdated();
niklase@google.com470e71d2011-07-07 08:21:25 +0000141
danilchapdd128922016-09-13 12:23:29 -0700142 private:
Tommi08be9ba2021-06-15 23:01:57 +0200143#if RTC_DCHECK_IS_ON
144 class CustomSequenceChecker : public SequenceChecker {
Victor Boivie306b1392021-04-27 10:33:58 +0200145 public:
Tommi08be9ba2021-06-15 23:01:57 +0200146 explicit CustomSequenceChecker(bool disable_checks)
147 : disable_checks_(disable_checks) {}
148 bool IsCurrent() const {
149 if (disable_checks_)
150 return true;
151 return SequenceChecker::IsCurrent();
Victor Boivie306b1392021-04-27 10:33:58 +0200152 }
153
154 private:
Tommi08be9ba2021-06-15 23:01:57 +0200155 const bool disable_checks_;
156 };
157#else
158 class CustomSequenceChecker : public SequenceChecker {
159 public:
160 explicit CustomSequenceChecker(bool) {}
161 };
162#endif
163
164 // A lightweight inlined set of local SSRCs.
165 class RegisteredSsrcs {
166 public:
167 static constexpr size_t kMediaSsrcIndex = 0;
168 static constexpr size_t kMaxSsrcs = 3;
169 // Initializes the set of registered local SSRCS by extracting them from the
170 // provided `config`. The `disable_sequence_checker` flag is a workaround
171 // to be able to use a sequence checker without breaking downstream
172 // code that currently doesn't follow the same threading rules as webrtc.
173 RegisteredSsrcs(bool disable_sequence_checker,
174 const RtpRtcpInterface::Configuration& config);
175
176 // Indicates if `ssrc` is in the set of registered local SSRCs.
177 bool contains(uint32_t ssrc) const;
178 uint32_t media_ssrc() const;
179 void set_media_ssrc(uint32_t ssrc);
180
181 private:
182 RTC_NO_UNIQUE_ADDRESS CustomSequenceChecker packet_sequence_checker_;
183 absl::InlinedVector<uint32_t, kMaxSsrcs> ssrcs_
184 RTC_GUARDED_BY(packet_sequence_checker_);
Victor Boivie306b1392021-04-27 10:33:58 +0200185 };
186
danilchap92ea6012016-09-23 10:36:03 -0700187 struct PacketInformation;
Stephan Hartmann26946722021-05-03 11:06:23 +0000188
189 // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104,
190 // section 3.5.4).
191 struct TmmbrInformation {
192 struct TimedTmmbrItem {
193 rtcp::TmmbItem tmmbr_item;
194 int64_t last_updated_ms;
195 };
196
197 int64_t last_time_received_ms = 0;
198
199 bool ready_for_delete = false;
200
201 std::vector<rtcp::TmmbItem> tmmbn;
202 std::map<uint32_t, TimedTmmbrItem> tmmbr;
203 };
204
205 // Structure for storing received RRTR RTCP messages (RFC3611, section 4.4).
206 struct RrtrInformation {
207 RrtrInformation(uint32_t ssrc,
208 uint32_t received_remote_mid_ntp_time,
209 uint32_t local_receive_mid_ntp_time)
210 : ssrc(ssrc),
211 received_remote_mid_ntp_time(received_remote_mid_ntp_time),
212 local_receive_mid_ntp_time(local_receive_mid_ntp_time) {}
213
214 uint32_t ssrc;
215 // Received NTP timestamp in compact representation.
216 uint32_t received_remote_mid_ntp_time;
217 // NTP time when the report was received in compact representation.
218 uint32_t local_receive_mid_ntp_time;
219 };
220
221 struct LastFirStatus {
222 LastFirStatus(int64_t now_ms, uint8_t sequence_number)
223 : request_ms(now_ms), sequence_number(sequence_number) {}
224 int64_t request_ms;
225 uint8_t sequence_number;
226 };
Victor Boivie0c563a42021-04-27 10:24:01 +0200227
228 // TODO(boivie): `ReportBlockDataMap` and `ReportBlockMap` should be converted
229 // to std::unordered_map, but as there are too many tests that assume a
230 // specific order, it's not easily done.
231
danilchap28b03eb2016-10-05 06:59:44 -0700232 // RTCP report blocks mapped by remote SSRC.
Henrik Boströmf2047872019-05-16 13:32:20 +0200233 using ReportBlockDataMap = std::map<uint32_t, ReportBlockData>;
danilchap28b03eb2016-10-05 06:59:44 -0700234 // RTCP report blocks map mapped by source SSRC.
Henrik Boströmf2047872019-05-16 13:32:20 +0200235 using ReportBlockMap = std::map<uint32_t, ReportBlockDataMap>;
danilchapdd128922016-09-13 12:23:29 -0700236
Danil Chapovalov443f2662020-03-11 12:24:40 +0100237 bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
danilchap92ea6012016-09-23 10:36:03 -0700238 PacketInformation* packet_information);
danilchapdd128922016-09-13 12:23:29 -0700239
danilchap8bab7962016-12-20 02:46:46 -0800240 void TriggerCallbacksFromRtcpPacket(
danilchap92ea6012016-09-23 10:36:03 -0700241 const PacketInformation& packet_information);
danilchapdd128922016-09-13 12:23:29 -0700242
danilchapec067e92017-02-21 05:38:19 -0800243 TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700244 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapec067e92017-02-21 05:38:19 -0800245 // Update TmmbrInformation (if present) is alive.
246 void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700247 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800248 TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700249 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000250
danilchap92ea6012016-09-23 10:36:03 -0700251 void HandleSenderReport(const rtcp::CommonHeader& rtcp_block,
252 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700253 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Danil Chapovalov91511f12016-09-15 16:24:02 +0200254
danilchap92ea6012016-09-23 10:36:03 -0700255 void HandleReceiverReport(const rtcp::CommonHeader& rtcp_block,
256 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700257 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000258
danilchap1b1863a2016-09-20 01:39:54 -0700259 void HandleReportBlock(const rtcp::ReportBlock& report_block,
danilchap92ea6012016-09-23 10:36:03 -0700260 PacketInformation* packet_information,
danilchap8bab7962016-12-20 02:46:46 -0800261 uint32_t remote_ssrc)
danilchap56359be2017-09-07 07:53:45 -0700262 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000263
danilchap8bab7962016-12-20 02:46:46 -0800264 void HandleSdes(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700265 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700266 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000267
danilchap1b1863a2016-09-20 01:39:54 -0700268 void HandleXr(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700269 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700270 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000271
danilchap92ea6012016-09-23 10:36:03 -0700272 void HandleXrReceiveReferenceTime(uint32_t sender_ssrc,
273 const rtcp::Rrtr& rrtr)
danilchap56359be2017-09-07 07:53:45 -0700274 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000275
danilchap92ea6012016-09-23 10:36:03 -0700276 void HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti)
danilchap56359be2017-09-07 07:53:45 -0700277 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700278
sprangb32aaf92017-08-28 05:49:12 -0700279 void HandleXrTargetBitrate(uint32_t ssrc,
280 const rtcp::TargetBitrate& target_bitrate,
spranga790d832016-12-02 07:29:44 -0800281 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700282 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
spranga790d832016-12-02 07:29:44 -0800283
danilchap8bab7962016-12-20 02:46:46 -0800284 void HandleNack(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700285 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700286 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700287
Sebastian Janssone1795f42019-07-24 11:38:03 +0200288 void HandleApp(const rtcp::CommonHeader& rtcp_block,
289 PacketInformation* packet_information)
290 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
291
danilchap8bab7962016-12-20 02:46:46 -0800292 void HandleBye(const rtcp::CommonHeader& rtcp_block)
danilchap56359be2017-09-07 07:53:45 -0700293 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700294
danilchap8bab7962016-12-20 02:46:46 -0800295 void HandlePli(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
danilchap1b1863a2016-09-20 01:39:54 -0700299 void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700300 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700301 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700302
danilchap8bab7962016-12-20 02:46:46 -0800303 void HandleTmmbr(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700304 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700305 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000306
danilchap8bab7962016-12-20 02:46:46 -0800307 void HandleTmmbn(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700308 PacketInformation* packet_information)
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 HandleSrReq(const rtcp::CommonHeader& rtcp_block,
312 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
danilchap8bab7962016-12-20 02:46:46 -0800315 void HandleFir(const rtcp::CommonHeader& rtcp_block,
danilchap92ea6012016-09-23 10:36:03 -0700316 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700317 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
danilchapda161d72016-08-19 07:29:46 -0700318
danilchap92ea6012016-09-23 10:36:03 -0700319 void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block,
320 PacketInformation* packet_information)
danilchap56359be2017-09-07 07:53:45 -0700321 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Erik Språng6b8d3552015-09-24 15:06:57 +0200322
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200323 bool RtcpRrTimeoutLocked(Timestamp now)
324 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
325
326 bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now)
327 RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
328
danilchap8bab7962016-12-20 02:46:46 -0800329 Clock* const clock_;
Peter Boströmfe7a80c2015-04-23 17:53:17 +0200330 const bool receiver_only_;
danilchap8bab7962016-12-20 02:46:46 -0800331 ModuleRtpRtcp* const rtp_rtcp_;
Erik Språng6841d252019-10-15 14:29:11 +0200332 const uint32_t main_ssrc_;
Victor Boivie306b1392021-04-27 10:33:58 +0200333 // The set of registered local SSRCs.
Tommi08be9ba2021-06-15 23:01:57 +0200334 RegisteredSsrcs registered_ssrcs_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000335
spranga790d832016-12-02 07:29:44 -0800336 RtcpBandwidthObserver* const rtcp_bandwidth_observer_;
337 RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
Elad Alon0a8562e2019-04-09 11:55:13 +0200338 RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
Sebastian Janssone1795f42019-07-24 11:38:03 +0200339 NetworkStateEstimateObserver* const network_state_estimate_observer_;
spranga790d832016-12-02 07:29:44 -0800340 TransportFeedbackObserver* const transport_feedback_observer_;
341 VideoBitrateAllocationObserver* const bitrate_allocation_observer_;
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200342 const TimeDelta report_interval_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000343
Markus Handelle7c015e2020-07-07 11:44:28 +0200344 mutable Mutex rtcp_receiver_lock_;
danilchap56359be2017-09-07 07:53:45 -0700345 uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000346
danilchap8bab7962016-12-20 02:46:46 -0800347 // Received sender report.
danilchap56359be2017-09-07 07:53:45 -0700348 NtpTime remote_sender_ntp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
349 uint32_t remote_sender_rtp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap0b4b7272016-10-06 09:24:45 -0700350 // When did we receive the last send report.
danilchap56359be2017-09-07 07:53:45 -0700351 NtpTime last_received_sr_ntp_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Alessio Bazzica048adc72021-03-10 15:05:55 +0100352 uint32_t remote_sender_packet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
353 uint64_t remote_sender_octet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
354 uint64_t remote_sender_reports_count_ RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000355
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200356 // Received RRTR information in ascending receive time order.
357 std::list<RrtrInformation> received_rrtrs_
358 RTC_GUARDED_BY(rtcp_receiver_lock_);
359 // Received RRTR information mapped by remote ssrc.
Victor Boivie0c563a42021-04-27 10:24:01 +0200360 std::unordered_map<uint32_t, std::list<RrtrInformation>::iterator>
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200361 received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_);
362
asapersson@webrtc.org7d6bd222013-10-31 12:14:34 +0000363 // Estimated rtt, zero when there is no valid estimate.
Niels Möllerbe810cb2020-12-02 14:25:03 +0100364 const bool xr_rrtr_status_;
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000365 int64_t xr_rr_rtt_ms_;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000366
danilchap56359be2017-09-07 07:53:45 -0700367 int64_t oldest_tmmbr_info_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800368 // Mapped by remote ssrc.
Victor Boivie0c563a42021-04-27 10:24:01 +0200369 std::unordered_map<uint32_t, TmmbrInformation> tmmbr_infos_
danilchap56359be2017-09-07 07:53:45 -0700370 RTC_GUARDED_BY(rtcp_receiver_lock_);
danilchap9bf610e2017-02-20 06:03:01 -0800371
danilchap56359be2017-09-07 07:53:45 -0700372 ReportBlockMap received_report_blocks_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Victor Boivie0c563a42021-04-27 10:24:01 +0200373 std::unordered_map<uint32_t, LastFirStatus> last_fir_
danilchap56359be2017-09-07 07:53:45 -0700374 RTC_GUARDED_BY(rtcp_receiver_lock_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000375
Danil Chapovalov760c4b42017-09-27 13:25:24 +0200376 // The last time we received an RTCP Report block for this module.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200377 Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) =
378 Timestamp::PlusInfinity();
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000379
asapersson@webrtc.orgcb791412014-12-18 14:30:32 +0000380 // The time we last received an RTCP RR telling we have successfully
mflodman@webrtc.org2f225ca2013-01-09 13:54:43 +0000381 // delivered RTP packet to the remote side.
Tomas Gunnarssonba0ba712020-07-01 08:53:21 +0200382 Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity();
stefan@webrtc.org8ca8a712013-04-23 16:48:32 +0000383
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100384 RtcpCnameCallback* const cname_callback_;
Danil Chapovalovbd74d5c2020-03-12 09:22:44 +0100385 ReportBlockDataObserver* const report_block_data_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000386
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000387 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
asapersson@webrtc.org8098e072014-02-19 11:59:02 +0000388 RtcpPacketTypeCounter packet_type_counter_;
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000389
danilchap84432382017-02-09 05:21:42 -0800390 RtcpNackStats nack_stats_;
Erik Språng6b8d3552015-09-24 15:06:57 +0200391
392 size_t num_skipped_packets_;
danilchap8bab7962016-12-20 02:46:46 -0800393 int64_t last_skipped_packets_warning_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000394};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000395} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200396#endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_