niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [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 06:47:31 +0200 | [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 +0000 | [diff] [blame] | 13 | |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 14 | #include <list> |
pwestin@webrtc.org | 26f8d9c | 2012-01-19 15:53:09 +0000 | [diff] [blame] | 15 | #include <map> |
danilchap | 9532124 | 2016-09-27 07:05:32 -0700 | [diff] [blame] | 16 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 17 | #include <vector> |
perkj@webrtc.org | ce5990c | 2012-01-11 13:00:08 +0000 | [diff] [blame] | 18 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 19 | #include "api/array_view.h" |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 20 | #include "api/sequence_checker.h" |
Henrik Boström | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 21 | #include "modules/rtp_rtcp/include/report_block_data.h" |
Niels Möller | 53382cb | 2018-11-27 14:05:08 +0100 | [diff] [blame] | 22 | #include "modules/rtp_rtcp/include/rtcp_statistics.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #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 Hartmann | 2694672 | 2021-05-03 11:06:23 +0000 | [diff] [blame] | 26 | #include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 22:55:33 +0200 | [diff] [blame] | 27 | #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" |
Victor Boivie | f715618 | 2021-07-06 23:14:51 +0200 | [diff] [blame] | 28 | #include "rtc_base/containers/flat_map.h" |
Markus Handell | e7c015e | 2020-07-07 11:44:28 +0200 | [diff] [blame] | 29 | #include "rtc_base/synchronization/mutex.h" |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 30 | #include "rtc_base/system/no_unique_address.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 31 | #include "rtc_base/thread_annotations.h" |
| 32 | #include "system_wrappers/include/ntp_time.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
| 34 | namespace webrtc { |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 35 | |
| 36 | class ModuleRtpRtcpImpl2; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 37 | class VideoBitrateAllocationObserver; |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 38 | |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 39 | namespace rtcp { |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 40 | class CommonHeader; |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 41 | class ReportBlock; |
| 42 | class Rrtr; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 43 | class TargetBitrate; |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 44 | class TmmbItem; |
| 45 | } // namespace rtcp |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 46 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 47 | class RTCPReceiver final { |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 48 | public: |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 49 | 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 Gunnarsson | f25761d | 2020-06-03 22:55:33 +0200 | [diff] [blame] | 62 | RTCPReceiver(const RtpRtcpInterface::Configuration& config, |
| 63 | ModuleRtpRtcp* owner); |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 64 | |
| 65 | RTCPReceiver(const RtpRtcpInterface::Configuration& config, |
| 66 | ModuleRtpRtcpImpl2* owner); |
| 67 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 68 | ~RTCPReceiver(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 70 | 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); |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 74 | |
Danil Chapovalov | 760c4b4 | 2017-09-27 13:25:24 +0200 | [diff] [blame] | 75 | int64_t LastReceivedReportBlockMs() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 77 | void set_local_media_ssrc(uint32_t ssrc); |
| 78 | uint32_t local_media_ssrc() const; |
| 79 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 80 | void SetRemoteSSRC(uint32_t ssrc); |
| 81 | uint32_t RemoteSSRC() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 83 | bool receiver_only() const { return receiver_only_; } |
| 84 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 85 | // Get received NTP. |
Alessio Bazzica | 048adc7 | 2021-03-10 15:05:55 +0100 | [diff] [blame] | 86 | // 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 |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 93 | 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 Bazzica | 048adc7 | 2021-03-10 15:05:55 +0100 | [diff] [blame] | 97 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 102 | std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo(); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 103 | |
danilchap | 28b03eb | 2016-10-05 06:59:44 -0700 | [diff] [blame] | 104 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 110 | |
Ivo Creusen | 8c40d51 | 2021-07-13 12:53:22 +0000 | [diff] [blame] | 111 | void SetNonSenderRttMeasurement(bool enabled); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 112 | bool GetAndResetXrRrRtt(int64_t* rtt_ms); |
asapersson@webrtc.org | 7d6bd22 | 2013-10-31 12:14:34 +0000 | [diff] [blame] | 113 | |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 114 | // 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öm | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 119 | // A snapshot of Report Blocks with additional data of interest to statistics. |
Danil Chapovalov | 510c94c | 2021-07-02 13:51:19 +0200 | [diff] [blame] | 120 | // Within this list, the source SSRC is unique and ReportBlockData represents |
| 121 | // the latest Report Block that was received for that SSRC. |
Henrik Boström | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 122 | std::vector<ReportBlockData> GetLatestReportBlockData() const; |
perkj@webrtc.org | ce5990c | 2012-01-11 13:00:08 +0000 | [diff] [blame] | 123 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 124 | // Returns true if we haven't received an RTCP RR for several RTCP |
| 125 | // intervals, but only triggers true once. |
Jiawei Ou | 8b5d9d8 | 2018-11-15 16:44:37 -0800 | [diff] [blame] | 126 | bool RtcpRrTimeout(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 127 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 128 | // 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 Ou | 8b5d9d8 | 2018-11-15 16:44:37 -0800 | [diff] [blame] | 132 | bool RtcpRrSequenceNumberTimeout(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 133 | |
danilchap | 7851bda | 2016-09-29 15:28:07 -0700 | [diff] [blame] | 134 | std::vector<rtcp::TmmbItem> TmmbrReceived(); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 135 | // Return true if new bandwidth should be set. |
| 136 | bool UpdateTmmbrTimers(); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 137 | std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 138 | // Set new bandwidth and notify remote clients about it. |
| 139 | void NotifyTmmbrUpdated(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 141 | private: |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 142 | #if RTC_DCHECK_IS_ON |
| 143 | class CustomSequenceChecker : public SequenceChecker { |
Victor Boivie | 306b139 | 2021-04-27 10:33:58 +0200 | [diff] [blame] | 144 | public: |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 145 | 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 Boivie | 306b139 | 2021-04-27 10:33:58 +0200 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | private: |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 154 | 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 Boivie | 306b139 | 2021-04-27 10:33:58 +0200 | [diff] [blame] | 184 | }; |
| 185 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 186 | struct PacketInformation; |
Stephan Hartmann | 2694672 | 2021-05-03 11:06:23 +0000 | [diff] [blame] | 187 | |
| 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 Boivie | 0c563a4 | 2021-04-27 10:24:01 +0200 | [diff] [blame] | 226 | |
Danil Chapovalov | 510c94c | 2021-07-02 13:51:19 +0200 | [diff] [blame] | 227 | class RttStats { |
| 228 | public: |
| 229 | RttStats() = default; |
| 230 | RttStats(const RttStats&) = default; |
| 231 | RttStats& operator=(const RttStats&) = default; |
Victor Boivie | 0c563a4 | 2021-04-27 10:24:01 +0200 | [diff] [blame] | 232 | |
Danil Chapovalov | 510c94c | 2021-07-02 13:51:19 +0200 | [diff] [blame] | 233 | 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 | }; |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 247 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 248 | bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 249 | PacketInformation* packet_information); |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 250 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 251 | void TriggerCallbacksFromRtcpPacket( |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 252 | const PacketInformation& packet_information); |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 253 | |
danilchap | ec067e9 | 2017-02-21 05:38:19 -0800 | [diff] [blame] | 254 | TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 255 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | ec067e9 | 2017-02-21 05:38:19 -0800 | [diff] [blame] | 256 | // Update TmmbrInformation (if present) is alive. |
| 257 | void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 258 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 259 | TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 260 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 261 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 262 | void HandleSenderReport(const rtcp::CommonHeader& rtcp_block, |
| 263 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 264 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
Danil Chapovalov | 91511f1 | 2016-09-15 16:24:02 +0200 | [diff] [blame] | 265 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 266 | void HandleReceiverReport(const rtcp::CommonHeader& rtcp_block, |
| 267 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 268 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 269 | |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 270 | void HandleReportBlock(const rtcp::ReportBlock& report_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 271 | PacketInformation* packet_information, |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 272 | uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 273 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 274 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 275 | void HandleSdes(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 276 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 277 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 278 | |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 279 | void HandleXr(const rtcp::CommonHeader& rtcp_block, |
Björn Terelius | 2c41cba | 2021-09-01 16:03:26 +0000 | [diff] [blame] | 280 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 281 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 282 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 283 | void HandleXrReceiveReferenceTime(uint32_t sender_ssrc, |
| 284 | const rtcp::Rrtr& rrtr) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 285 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 286 | |
Björn Terelius | 2c41cba | 2021-09-01 16:03:26 +0000 | [diff] [blame] | 287 | void HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 288 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 289 | |
sprang | b32aaf9 | 2017-08-28 05:49:12 -0700 | [diff] [blame] | 290 | void HandleXrTargetBitrate(uint32_t ssrc, |
| 291 | const rtcp::TargetBitrate& target_bitrate, |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 292 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 293 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 294 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 295 | void HandleNack(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 296 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 297 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 298 | |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 299 | void HandleApp(const rtcp::CommonHeader& rtcp_block, |
| 300 | PacketInformation* packet_information) |
| 301 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 302 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 303 | void HandleBye(const rtcp::CommonHeader& rtcp_block) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 304 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 305 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 306 | void HandlePli(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 307 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 308 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 309 | |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 310 | void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 311 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 312 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 313 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 314 | void HandleTmmbr(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 315 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 316 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 317 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 318 | void HandleTmmbn(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 319 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 320 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 321 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 322 | void HandleSrReq(const rtcp::CommonHeader& rtcp_block, |
| 323 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 324 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 325 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 326 | void HandleFir(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 327 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 328 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 329 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 330 | void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block, |
| 331 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 332 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 333 | |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 334 | 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 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 340 | Clock* const clock_; |
Peter Boström | fe7a80c | 2015-04-23 17:53:17 +0200 | [diff] [blame] | 341 | const bool receiver_only_; |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 342 | ModuleRtpRtcp* const rtp_rtcp_; |
Erik Språng | 6841d25 | 2019-10-15 14:29:11 +0200 | [diff] [blame] | 343 | const uint32_t main_ssrc_; |
Victor Boivie | 306b139 | 2021-04-27 10:33:58 +0200 | [diff] [blame] | 344 | // The set of registered local SSRCs. |
Tommi | 08be9ba | 2021-06-15 23:01:57 +0200 | [diff] [blame] | 345 | RegisteredSsrcs registered_ssrcs_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 346 | |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 347 | RtcpBandwidthObserver* const rtcp_bandwidth_observer_; |
| 348 | RtcpIntraFrameObserver* const rtcp_intra_frame_observer_; |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 349 | RtcpLossNotificationObserver* const rtcp_loss_notification_observer_; |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 350 | NetworkStateEstimateObserver* const network_state_estimate_observer_; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 351 | TransportFeedbackObserver* const transport_feedback_observer_; |
| 352 | VideoBitrateAllocationObserver* const bitrate_allocation_observer_; |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 353 | const TimeDelta report_interval_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 354 | |
Markus Handell | e7c015e | 2020-07-07 11:44:28 +0200 | [diff] [blame] | 355 | mutable Mutex rtcp_receiver_lock_; |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 356 | uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 357 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 358 | // Received sender report. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 359 | NtpTime remote_sender_ntp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 360 | uint32_t remote_sender_rtp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 0b4b727 | 2016-10-06 09:24:45 -0700 | [diff] [blame] | 361 | // When did we receive the last send report. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 362 | NtpTime last_received_sr_ntp_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
Alessio Bazzica | 048adc7 | 2021-03-10 15:05:55 +0100 | [diff] [blame] | 363 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 366 | |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 367 | // 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 Boivie | f715618 | 2021-07-06 23:14:51 +0200 | [diff] [blame] | 371 | flat_map<uint32_t, std::list<RrtrInformation>::iterator> |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 372 | received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 373 | |
asapersson@webrtc.org | 7d6bd22 | 2013-10-31 12:14:34 +0000 | [diff] [blame] | 374 | // Estimated rtt, zero when there is no valid estimate. |
Ivo Creusen | 8c40d51 | 2021-07-13 12:53:22 +0000 | [diff] [blame] | 375 | bool xr_rrtr_status_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
pkasting@chromium.org | 16825b1 | 2015-01-12 21:51:21 +0000 | [diff] [blame] | 376 | int64_t xr_rr_rtt_ms_; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 377 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 378 | int64_t oldest_tmmbr_info_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 379 | // Mapped by remote ssrc. |
Victor Boivie | f715618 | 2021-07-06 23:14:51 +0200 | [diff] [blame] | 380 | flat_map<uint32_t, TmmbrInformation> tmmbr_infos_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 381 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 382 | |
Danil Chapovalov | 510c94c | 2021-07-02 13:51:19 +0200 | [diff] [blame] | 383 | // Round-Trip Time per remote sender ssrc. |
Victor Boivie | f715618 | 2021-07-06 23:14:51 +0200 | [diff] [blame] | 384 | flat_map<uint32_t, RttStats> rtts_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
Danil Chapovalov | 510c94c | 2021-07-02 13:51:19 +0200 | [diff] [blame] | 385 | |
| 386 | // Report blocks per local source ssrc. |
Victor Boivie | f715618 | 2021-07-06 23:14:51 +0200 | [diff] [blame] | 387 | flat_map<uint32_t, ReportBlockData> received_report_blocks_ |
Danil Chapovalov | 510c94c | 2021-07-02 13:51:19 +0200 | [diff] [blame] | 388 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
Victor Boivie | f715618 | 2021-07-06 23:14:51 +0200 | [diff] [blame] | 389 | flat_map<uint32_t, LastFirStatus> last_fir_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 390 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 391 | |
Danil Chapovalov | 760c4b4 | 2017-09-27 13:25:24 +0200 | [diff] [blame] | 392 | // The last time we received an RTCP Report block for this module. |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 393 | Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) = |
| 394 | Timestamp::PlusInfinity(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 395 | |
asapersson@webrtc.org | cb79141 | 2014-12-18 14:30:32 +0000 | [diff] [blame] | 396 | // The time we last received an RTCP RR telling we have successfully |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 397 | // delivered RTP packet to the remote side. |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 398 | Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity(); |
stefan@webrtc.org | 8ca8a71 | 2013-04-23 16:48:32 +0000 | [diff] [blame] | 399 | |
Danil Chapovalov | bd74d5c | 2020-03-12 09:22:44 +0100 | [diff] [blame] | 400 | RtcpCnameCallback* const cname_callback_; |
Danil Chapovalov | bd74d5c | 2020-03-12 09:22:44 +0100 | [diff] [blame] | 401 | ReportBlockDataObserver* const report_block_data_observer_; |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 402 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 403 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 404 | RtcpPacketTypeCounter packet_type_counter_; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 405 | |
danilchap | 8443238 | 2017-02-09 05:21:42 -0800 | [diff] [blame] | 406 | RtcpNackStats nack_stats_; |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 407 | |
| 408 | size_t num_skipped_packets_; |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 409 | int64_t last_skipped_packets_warning_ms_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 410 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 411 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 412 | #endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_ |