niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 3 | * |
| 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 Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 13 | |
Mirta Dvornicic | b1f063d | 2018-04-16 09:16:21 | [diff] [blame] | 14 | #include <list> |
pwestin@webrtc.org | 26f8d9c | 2012-01-19 15:53:09 | [diff] [blame] | 15 | #include <map> |
danilchap | 9532124 | 2016-09-27 14:05:32 | [diff] [blame] | 16 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 13:05:27 | [diff] [blame] | 17 | #include <vector> |
perkj@webrtc.org | ce5990c | 2012-01-11 13:00:08 | [diff] [blame] | 18 | |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
Danil Chapovalov | 443f266 | 2020-03-11 11:24:40 | [diff] [blame] | 20 | #include "api/array_view.h" |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 21 | #include "api/sequence_checker.h" |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 22 | #include "api/units/time_delta.h" |
Danil Chapovalov | aa8faa6 | 2023-07-13 09:00:28 | [diff] [blame] | 23 | #include "api/units/timestamp.h" |
Henrik Boström | f204787 | 2019-05-16 11:32:20 | [diff] [blame] | 24 | #include "modules/rtp_rtcp/include/report_block_data.h" |
Niels Möller | 53382cb | 2018-11-27 13:05:08 | [diff] [blame] | 25 | #include "modules/rtp_rtcp/include/rtcp_statistics.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 26 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 27 | #include "modules/rtp_rtcp/source/rtcp_nack_stats.h" |
| 28 | #include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h" |
Stephan Hartmann | 2694672 | 2021-05-03 11:06:23 | [diff] [blame] | 29 | #include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 30 | #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" |
Victor Boivie | f715618 | 2021-07-06 21:14:51 | [diff] [blame] | 31 | #include "rtc_base/containers/flat_map.h" |
Markus Handell | e7c015e | 2020-07-07 09:44:28 | [diff] [blame] | 32 | #include "rtc_base/synchronization/mutex.h" |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 33 | #include "rtc_base/system/no_unique_address.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 34 | #include "rtc_base/thread_annotations.h" |
| 35 | #include "system_wrappers/include/ntp_time.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 36 | |
| 37 | namespace webrtc { |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 38 | |
| 39 | class ModuleRtpRtcpImpl2; |
sprang | a790d83 | 2016-12-02 15:29:44 | [diff] [blame] | 40 | class VideoBitrateAllocationObserver; |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 41 | |
danilchap | 59cb2bd | 2016-08-29 18:08:47 | [diff] [blame] | 42 | namespace rtcp { |
danilchap | 1b1863a | 2016-09-20 08:39:54 | [diff] [blame] | 43 | class CommonHeader; |
danilchap | 1b1863a | 2016-09-20 08:39:54 | [diff] [blame] | 44 | class ReportBlock; |
| 45 | class Rrtr; |
sprang | a790d83 | 2016-12-02 15:29:44 | [diff] [blame] | 46 | class TargetBitrate; |
danilchap | 59cb2bd | 2016-08-29 18:08:47 | [diff] [blame] | 47 | class TmmbItem; |
| 48 | } // namespace rtcp |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 | [diff] [blame] | 49 | |
Danil Chapovalov | 443f266 | 2020-03-11 11:24:40 | [diff] [blame] | 50 | class RTCPReceiver final { |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 51 | public: |
danilchap | 59cb2bd | 2016-08-29 18:08:47 | [diff] [blame] | 52 | class ModuleRtpRtcp { |
| 53 | public: |
| 54 | virtual void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) = 0; |
| 55 | virtual void OnRequestSendReport() = 0; |
| 56 | virtual void OnReceivedNack( |
| 57 | const std::vector<uint16_t>& nack_sequence_numbers) = 0; |
| 58 | virtual void OnReceivedRtcpReportBlocks( |
Danil Chapovalov | e641a97 | 2023-05-23 08:39:09 | [diff] [blame] | 59 | rtc::ArrayView<const ReportBlockData> report_blocks) = 0; |
danilchap | 59cb2bd | 2016-08-29 18:08:47 | [diff] [blame] | 60 | |
| 61 | protected: |
| 62 | virtual ~ModuleRtpRtcp() = default; |
| 63 | }; |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 64 | // Standardized stats derived from the non-sender RTT. |
| 65 | class NonSenderRttStats { |
| 66 | public: |
| 67 | NonSenderRttStats() = default; |
| 68 | NonSenderRttStats(const NonSenderRttStats&) = default; |
| 69 | NonSenderRttStats& operator=(const NonSenderRttStats&) = default; |
| 70 | ~NonSenderRttStats() = default; |
| 71 | void Update(TimeDelta non_sender_rtt_seconds) { |
| 72 | round_trip_time_ = non_sender_rtt_seconds; |
| 73 | total_round_trip_time_ += non_sender_rtt_seconds; |
| 74 | round_trip_time_measurements_++; |
| 75 | } |
| 76 | void Invalidate() { round_trip_time_.reset(); } |
| 77 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime |
| 78 | absl::optional<TimeDelta> round_trip_time() const { |
| 79 | return round_trip_time_; |
| 80 | } |
| 81 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime |
| 82 | TimeDelta total_round_trip_time() const { return total_round_trip_time_; } |
| 83 | // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements |
| 84 | int round_trip_time_measurements() const { |
| 85 | return round_trip_time_measurements_; |
| 86 | } |
| 87 | |
| 88 | private: |
| 89 | absl::optional<TimeDelta> round_trip_time_; |
| 90 | TimeDelta total_round_trip_time_ = TimeDelta::Zero(); |
| 91 | int round_trip_time_measurements_ = 0; |
| 92 | }; |
danilchap | 59cb2bd | 2016-08-29 18:08:47 | [diff] [blame] | 93 | |
Tomas Gunnarsson | f25761d | 2020-06-03 20:55:33 | [diff] [blame] | 94 | RTCPReceiver(const RtpRtcpInterface::Configuration& config, |
| 95 | ModuleRtpRtcp* owner); |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 96 | |
| 97 | RTCPReceiver(const RtpRtcpInterface::Configuration& config, |
| 98 | ModuleRtpRtcpImpl2* owner); |
| 99 | |
Danil Chapovalov | 443f266 | 2020-03-11 11:24:40 | [diff] [blame] | 100 | ~RTCPReceiver(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 101 | |
Danil Chapovalov | 443f266 | 2020-03-11 11:24:40 | [diff] [blame] | 102 | void IncomingPacket(rtc::ArrayView<const uint8_t> packet); |
danilchap | 59cb2bd | 2016-08-29 18:08:47 | [diff] [blame] | 103 | |
Danil Chapovalov | 760c4b4 | 2017-09-27 11:25:24 | [diff] [blame] | 104 | int64_t LastReceivedReportBlockMs() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 105 | |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 106 | void set_local_media_ssrc(uint32_t ssrc); |
| 107 | uint32_t local_media_ssrc() const; |
| 108 | |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 109 | void SetRemoteSSRC(uint32_t ssrc); |
| 110 | uint32_t RemoteSSRC() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 111 | |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 112 | bool receiver_only() const { return receiver_only_; } |
| 113 | |
Danil Chapovalov | 0f43da2 | 2023-02-28 16:03:21 | [diff] [blame] | 114 | // Returns stats based on the received RTCP Sender Reports. |
| 115 | absl::optional<RtpRtcpInterface::SenderReportStats> GetSenderReportStats() |
| 116 | const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 117 | |
Mirta Dvornicic | b1f063d | 2018-04-16 09:16:21 | [diff] [blame] | 118 | std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo(); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 | [diff] [blame] | 119 | |
Danil Chapovalov | 71f80c0 | 2023-05-11 08:35:37 | [diff] [blame] | 120 | absl::optional<TimeDelta> AverageRtt() const; |
Danil Chapovalov | 8095d02 | 2023-05-09 07:59:46 | [diff] [blame] | 121 | absl::optional<TimeDelta> LastRtt() const; |
| 122 | |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 123 | // Returns non-sender RTT metrics for the remote SSRC. |
| 124 | NonSenderRttStats GetNonSenderRTT() const; |
| 125 | |
Ivo Creusen | 8c40d51 | 2021-07-13 12:53:22 | [diff] [blame] | 126 | void SetNonSenderRttMeasurement(bool enabled); |
Danil Chapovalov | 4d2a219 | 2023-06-16 14:12:06 | [diff] [blame] | 127 | absl::optional<TimeDelta> GetAndResetXrRrRtt(); |
asapersson@webrtc.org | 7d6bd22 | 2013-10-31 12:14:34 | [diff] [blame] | 128 | |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 06:53:21 | [diff] [blame] | 129 | // Called once per second on the worker thread to do rtt calculations. |
| 130 | // Returns an optional rtt value if one is available. |
| 131 | absl::optional<TimeDelta> OnPeriodicRttUpdate(Timestamp newer_than, |
| 132 | bool sending); |
| 133 | |
Henrik Boström | f204787 | 2019-05-16 11:32:20 | [diff] [blame] | 134 | // A snapshot of Report Blocks with additional data of interest to statistics. |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 135 | // Within this list, the source SSRC is unique and ReportBlockData represents |
| 136 | // the latest Report Block that was received for that SSRC. |
Henrik Boström | f204787 | 2019-05-16 11:32:20 | [diff] [blame] | 137 | std::vector<ReportBlockData> GetLatestReportBlockData() const; |
perkj@webrtc.org | ce5990c | 2012-01-11 13:00:08 | [diff] [blame] | 138 | |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 139 | // Returns true if we haven't received an RTCP RR for several RTCP |
| 140 | // intervals, but only triggers true once. |
Jiawei Ou | 8b5d9d8 | 2018-11-16 00:44:37 | [diff] [blame] | 141 | bool RtcpRrTimeout(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 | [diff] [blame] | 142 | |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 143 | // Returns true if we haven't received an RTCP RR telling the receive side |
| 144 | // has not received RTP packets for too long, i.e. extended highest sequence |
| 145 | // number hasn't increased for several RTCP intervals. The function only |
| 146 | // returns true once until a new RR is received. |
Jiawei Ou | 8b5d9d8 | 2018-11-16 00:44:37 | [diff] [blame] | 147 | bool RtcpRrSequenceNumberTimeout(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 | [diff] [blame] | 148 | |
danilchap | 7851bda | 2016-09-29 22:28:07 | [diff] [blame] | 149 | std::vector<rtcp::TmmbItem> TmmbrReceived(); |
danilchap | 9bf610e | 2017-02-20 14:03:01 | [diff] [blame] | 150 | // Return true if new bandwidth should be set. |
| 151 | bool UpdateTmmbrTimers(); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 152 | std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner); |
danilchap | 9bf610e | 2017-02-20 14:03:01 | [diff] [blame] | 153 | // Set new bandwidth and notify remote clients about it. |
| 154 | void NotifyTmmbrUpdated(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 155 | |
danilchap | dd12892 | 2016-09-13 19:23:29 | [diff] [blame] | 156 | private: |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 157 | #if RTC_DCHECK_IS_ON |
| 158 | class CustomSequenceChecker : public SequenceChecker { |
Victor Boivie | 306b139 | 2021-04-27 08:33:58 | [diff] [blame] | 159 | public: |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 160 | explicit CustomSequenceChecker(bool disable_checks) |
| 161 | : disable_checks_(disable_checks) {} |
| 162 | bool IsCurrent() const { |
| 163 | if (disable_checks_) |
| 164 | return true; |
| 165 | return SequenceChecker::IsCurrent(); |
Victor Boivie | 306b139 | 2021-04-27 08:33:58 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | private: |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 169 | const bool disable_checks_; |
| 170 | }; |
| 171 | #else |
| 172 | class CustomSequenceChecker : public SequenceChecker { |
| 173 | public: |
| 174 | explicit CustomSequenceChecker(bool) {} |
| 175 | }; |
| 176 | #endif |
| 177 | |
| 178 | // A lightweight inlined set of local SSRCs. |
| 179 | class RegisteredSsrcs { |
| 180 | public: |
| 181 | static constexpr size_t kMediaSsrcIndex = 0; |
| 182 | static constexpr size_t kMaxSsrcs = 3; |
| 183 | // Initializes the set of registered local SSRCS by extracting them from the |
| 184 | // provided `config`. The `disable_sequence_checker` flag is a workaround |
| 185 | // to be able to use a sequence checker without breaking downstream |
| 186 | // code that currently doesn't follow the same threading rules as webrtc. |
| 187 | RegisteredSsrcs(bool disable_sequence_checker, |
| 188 | const RtpRtcpInterface::Configuration& config); |
| 189 | |
| 190 | // Indicates if `ssrc` is in the set of registered local SSRCs. |
| 191 | bool contains(uint32_t ssrc) const; |
| 192 | uint32_t media_ssrc() const; |
| 193 | void set_media_ssrc(uint32_t ssrc); |
| 194 | |
| 195 | private: |
| 196 | RTC_NO_UNIQUE_ADDRESS CustomSequenceChecker packet_sequence_checker_; |
| 197 | absl::InlinedVector<uint32_t, kMaxSsrcs> ssrcs_ |
| 198 | RTC_GUARDED_BY(packet_sequence_checker_); |
Victor Boivie | 306b139 | 2021-04-27 08:33:58 | [diff] [blame] | 199 | }; |
| 200 | |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 201 | struct PacketInformation; |
Stephan Hartmann | 2694672 | 2021-05-03 11:06:23 | [diff] [blame] | 202 | |
| 203 | // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104, |
| 204 | // section 3.5.4). |
| 205 | struct TmmbrInformation { |
| 206 | struct TimedTmmbrItem { |
| 207 | rtcp::TmmbItem tmmbr_item; |
Danil Chapovalov | aa8faa6 | 2023-07-13 09:00:28 | [diff] [blame] | 208 | Timestamp last_updated = Timestamp::Zero(); |
Stephan Hartmann | 2694672 | 2021-05-03 11:06:23 | [diff] [blame] | 209 | }; |
| 210 | |
Danil Chapovalov | aa8faa6 | 2023-07-13 09:00:28 | [diff] [blame] | 211 | Timestamp last_time_received = Timestamp::Zero(); |
Stephan Hartmann | 2694672 | 2021-05-03 11:06:23 | [diff] [blame] | 212 | |
| 213 | bool ready_for_delete = false; |
| 214 | |
| 215 | std::vector<rtcp::TmmbItem> tmmbn; |
| 216 | std::map<uint32_t, TimedTmmbrItem> tmmbr; |
| 217 | }; |
| 218 | |
| 219 | // Structure for storing received RRTR RTCP messages (RFC3611, section 4.4). |
| 220 | struct RrtrInformation { |
| 221 | RrtrInformation(uint32_t ssrc, |
| 222 | uint32_t received_remote_mid_ntp_time, |
| 223 | uint32_t local_receive_mid_ntp_time) |
| 224 | : ssrc(ssrc), |
| 225 | received_remote_mid_ntp_time(received_remote_mid_ntp_time), |
| 226 | local_receive_mid_ntp_time(local_receive_mid_ntp_time) {} |
| 227 | |
| 228 | uint32_t ssrc; |
| 229 | // Received NTP timestamp in compact representation. |
| 230 | uint32_t received_remote_mid_ntp_time; |
| 231 | // NTP time when the report was received in compact representation. |
| 232 | uint32_t local_receive_mid_ntp_time; |
| 233 | }; |
| 234 | |
| 235 | struct LastFirStatus { |
Danil Chapovalov | aa8faa6 | 2023-07-13 09:00:28 | [diff] [blame] | 236 | LastFirStatus(Timestamp now, uint8_t sequence_number) |
| 237 | : request(now), sequence_number(sequence_number) {} |
| 238 | Timestamp request; |
Stephan Hartmann | 2694672 | 2021-05-03 11:06:23 | [diff] [blame] | 239 | uint8_t sequence_number; |
| 240 | }; |
Victor Boivie | 0c563a4 | 2021-04-27 08:24:01 | [diff] [blame] | 241 | |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 242 | class RttStats { |
| 243 | public: |
| 244 | RttStats() = default; |
| 245 | RttStats(const RttStats&) = default; |
| 246 | RttStats& operator=(const RttStats&) = default; |
Victor Boivie | 0c563a4 | 2021-04-27 08:24:01 | [diff] [blame] | 247 | |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 248 | void AddRtt(TimeDelta rtt); |
| 249 | |
| 250 | TimeDelta last_rtt() const { return last_rtt_; } |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 251 | TimeDelta average_rtt() const { return sum_rtt_ / num_rtts_; } |
| 252 | |
| 253 | private: |
| 254 | TimeDelta last_rtt_ = TimeDelta::Zero(); |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 255 | TimeDelta sum_rtt_ = TimeDelta::Zero(); |
| 256 | size_t num_rtts_ = 0; |
| 257 | }; |
danilchap | dd12892 | 2016-09-13 19:23:29 | [diff] [blame] | 258 | |
Danil Chapovalov | 443f266 | 2020-03-11 11:24:40 | [diff] [blame] | 259 | bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 260 | PacketInformation* packet_information); |
danilchap | dd12892 | 2016-09-13 19:23:29 | [diff] [blame] | 261 | |
danilchap | 8bab796 | 2016-12-20 10:46:46 | [diff] [blame] | 262 | void TriggerCallbacksFromRtcpPacket( |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 263 | const PacketInformation& packet_information); |
danilchap | dd12892 | 2016-09-13 19:23:29 | [diff] [blame] | 264 | |
danilchap | ec067e9 | 2017-02-21 13:38:19 | [diff] [blame] | 265 | TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 266 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | ec067e9 | 2017-02-21 13:38:19 | [diff] [blame] | 267 | // Update TmmbrInformation (if present) is alive. |
| 268 | void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 269 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 14:03:01 | [diff] [blame] | 270 | TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 271 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 272 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 273 | bool HandleSenderReport(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 274 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 275 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
Danil Chapovalov | 91511f1 | 2016-09-15 14:24:02 | [diff] [blame] | 276 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 277 | bool HandleReceiverReport(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 278 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 279 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 280 | |
danilchap | 1b1863a | 2016-09-20 08:39:54 | [diff] [blame] | 281 | void HandleReportBlock(const rtcp::ReportBlock& report_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 282 | PacketInformation* packet_information, |
danilchap | 8bab796 | 2016-12-20 10:46:46 | [diff] [blame] | 283 | uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 284 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 285 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 286 | bool HandleSdes(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 287 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 288 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 289 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 290 | bool HandleXr(const rtcp::CommonHeader& rtcp_block, |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 291 | PacketInformation* packet_information, |
| 292 | bool& contains_dlrr, |
| 293 | uint32_t& ssrc) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 294 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 295 | |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 296 | void HandleXrReceiveReferenceTime(uint32_t sender_ssrc, |
| 297 | const rtcp::Rrtr& rrtr) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 298 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 299 | |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 300 | void HandleXrDlrrReportBlock(uint32_t ssrc, const rtcp::ReceiveTimeInfo& rti) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 301 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 302 | |
sprang | b32aaf9 | 2017-08-28 12:49:12 | [diff] [blame] | 303 | void HandleXrTargetBitrate(uint32_t ssrc, |
| 304 | const rtcp::TargetBitrate& target_bitrate, |
sprang | a790d83 | 2016-12-02 15:29:44 | [diff] [blame] | 305 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 306 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
sprang | a790d83 | 2016-12-02 15:29:44 | [diff] [blame] | 307 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 308 | bool HandleNack(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 309 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 310 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 311 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 312 | bool HandleApp(const rtcp::CommonHeader& rtcp_block, |
Sebastian Jansson | e1795f4 | 2019-07-24 09:38:03 | [diff] [blame] | 313 | PacketInformation* packet_information) |
| 314 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 315 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 316 | bool HandleBye(const rtcp::CommonHeader& rtcp_block) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 317 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 318 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 319 | bool HandlePli(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 320 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 321 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 322 | |
danilchap | 1b1863a | 2016-09-20 08:39:54 | [diff] [blame] | 323 | void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 324 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 325 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 326 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 327 | bool HandleTmmbr(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 328 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 329 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 330 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 331 | bool HandleTmmbn(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 332 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 333 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 334 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 335 | bool HandleSrReq(const rtcp::CommonHeader& rtcp_block, |
danilchap | 8bab796 | 2016-12-20 10:46:46 | [diff] [blame] | 336 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 337 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 338 | |
Danil Chapovalov | 6a0997d | 2023-03-08 11:34:34 | [diff] [blame] | 339 | bool HandleFir(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 340 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 341 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 14:29:46 | [diff] [blame] | 342 | |
danilchap | 92ea601 | 2016-09-23 17:36:03 | [diff] [blame] | 343 | void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block, |
| 344 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 345 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
Erik Språng | 6b8d355 | 2015-09-24 13:06:57 | [diff] [blame] | 346 | |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 06:53:21 | [diff] [blame] | 347 | bool RtcpRrTimeoutLocked(Timestamp now) |
| 348 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 349 | |
| 350 | bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now) |
| 351 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 352 | |
danilchap | 8bab796 | 2016-12-20 10:46:46 | [diff] [blame] | 353 | Clock* const clock_; |
Peter Boström | fe7a80c | 2015-04-23 15:53:17 | [diff] [blame] | 354 | const bool receiver_only_; |
danilchap | 8bab796 | 2016-12-20 10:46:46 | [diff] [blame] | 355 | ModuleRtpRtcp* const rtp_rtcp_; |
Victor Boivie | 306b139 | 2021-04-27 08:33:58 | [diff] [blame] | 356 | // The set of registered local SSRCs. |
Tommi | 08be9ba | 2021-06-15 21:01:57 | [diff] [blame] | 357 | RegisteredSsrcs registered_ssrcs_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 358 | |
Danil Chapovalov | 5251863 | 2023-05-09 15:11:49 | [diff] [blame] | 359 | NetworkLinkRtcpObserver* const network_link_rtcp_observer_; |
sprang | a790d83 | 2016-12-02 15:29:44 | [diff] [blame] | 360 | RtcpIntraFrameObserver* const rtcp_intra_frame_observer_; |
Elad Alon | 0a8562e | 2019-04-09 09:55:13 | [diff] [blame] | 361 | RtcpLossNotificationObserver* const rtcp_loss_notification_observer_; |
Sebastian Jansson | e1795f4 | 2019-07-24 09:38:03 | [diff] [blame] | 362 | NetworkStateEstimateObserver* const network_state_estimate_observer_; |
sprang | a790d83 | 2016-12-02 15:29:44 | [diff] [blame] | 363 | VideoBitrateAllocationObserver* const bitrate_allocation_observer_; |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 06:53:21 | [diff] [blame] | 364 | const TimeDelta report_interval_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 365 | |
Markus Handell | e7c015e | 2020-07-07 09:44:28 | [diff] [blame] | 366 | mutable Mutex rtcp_receiver_lock_; |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 367 | uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 368 | |
danilchap | 8bab796 | 2016-12-20 10:46:46 | [diff] [blame] | 369 | // Received sender report. |
Danil Chapovalov | 0f43da2 | 2023-02-28 16:03:21 | [diff] [blame] | 370 | RtpRtcpInterface::SenderReportStats remote_sender_ |
| 371 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 372 | |
Mirta Dvornicic | b1f063d | 2018-04-16 09:16:21 | [diff] [blame] | 373 | // Received RRTR information in ascending receive time order. |
| 374 | std::list<RrtrInformation> received_rrtrs_ |
| 375 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 376 | // Received RRTR information mapped by remote ssrc. |
Victor Boivie | f715618 | 2021-07-06 21:14:51 | [diff] [blame] | 377 | flat_map<uint32_t, std::list<RrtrInformation>::iterator> |
Mirta Dvornicic | b1f063d | 2018-04-16 09:16:21 | [diff] [blame] | 378 | received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 379 | |
Danil Chapovalov | 4d2a219 | 2023-06-16 14:12:06 | [diff] [blame] | 380 | // Estimated rtt, nullopt when there is no valid estimate. |
Ivo Creusen | 8c40d51 | 2021-07-13 12:53:22 | [diff] [blame] | 381 | bool xr_rrtr_status_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
Danil Chapovalov | 4d2a219 | 2023-06-16 14:12:06 | [diff] [blame] | 382 | absl::optional<TimeDelta> xr_rr_rtt_; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 | [diff] [blame] | 383 | |
Danil Chapovalov | aa8faa6 | 2023-07-13 09:00:28 | [diff] [blame] | 384 | Timestamp oldest_tmmbr_info_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 14:03:01 | [diff] [blame] | 385 | // Mapped by remote ssrc. |
Victor Boivie | f715618 | 2021-07-06 21:14:51 | [diff] [blame] | 386 | flat_map<uint32_t, TmmbrInformation> tmmbr_infos_ |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 387 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 14:03:01 | [diff] [blame] | 388 | |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 389 | // Round-Trip Time per remote sender ssrc. |
Victor Boivie | f715618 | 2021-07-06 21:14:51 | [diff] [blame] | 390 | flat_map<uint32_t, RttStats> rtts_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
Ivo Creusen | 2562cf0 | 2021-09-03 14:51:22 | [diff] [blame] | 391 | // Non-sender Round-trip time per remote ssrc. |
| 392 | flat_map<uint32_t, NonSenderRttStats> non_sender_rtts_ |
| 393 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 394 | |
| 395 | // Report blocks per local source ssrc. |
Victor Boivie | f715618 | 2021-07-06 21:14:51 | [diff] [blame] | 396 | flat_map<uint32_t, ReportBlockData> received_report_blocks_ |
Danil Chapovalov | 510c94c | 2021-07-02 11:51:19 | [diff] [blame] | 397 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
Victor Boivie | f715618 | 2021-07-06 21:14:51 | [diff] [blame] | 398 | flat_map<uint32_t, LastFirStatus> last_fir_ |
danilchap | 56359be | 2017-09-07 14:53:45 | [diff] [blame] | 399 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 400 | |
Danil Chapovalov | 760c4b4 | 2017-09-27 11:25:24 | [diff] [blame] | 401 | // The last time we received an RTCP Report block for this module. |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 06:53:21 | [diff] [blame] | 402 | Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) = |
| 403 | Timestamp::PlusInfinity(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 | [diff] [blame] | 404 | |
asapersson@webrtc.org | cb79141 | 2014-12-18 14:30:32 | [diff] [blame] | 405 | // The time we last received an RTCP RR telling we have successfully |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 | [diff] [blame] | 406 | // delivered RTP packet to the remote side. |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 06:53:21 | [diff] [blame] | 407 | Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity(); |
stefan@webrtc.org | 8ca8a71 | 2013-04-23 16:48:32 | [diff] [blame] | 408 | |
Danil Chapovalov | bd74d5c | 2020-03-12 08:22:44 | [diff] [blame] | 409 | RtcpCnameCallback* const cname_callback_; |
Danil Chapovalov | bd74d5c | 2020-03-12 08:22:44 | [diff] [blame] | 410 | ReportBlockDataObserver* const report_block_data_observer_; |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 411 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 | [diff] [blame] | 412 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 | [diff] [blame] | 413 | RtcpPacketTypeCounter packet_type_counter_; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 | [diff] [blame] | 414 | |
danilchap | 8443238 | 2017-02-09 13:21:42 | [diff] [blame] | 415 | RtcpNackStats nack_stats_; |
Erik Språng | 6b8d355 | 2015-09-24 13:06:57 | [diff] [blame] | 416 | |
| 417 | size_t num_skipped_packets_; |
Danil Chapovalov | aa8faa6 | 2023-07-13 09:00:28 | [diff] [blame] | 418 | Timestamp last_skipped_packets_warning_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 419 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 | [diff] [blame] | 420 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 421 | #endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_ |