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> |
stefan@webrtc.org | 28a331e | 2013-09-17 07:49:56 +0000 | [diff] [blame] | 16 | #include <set> |
danilchap | 9532124 | 2016-09-27 07:05:32 -0700 | [diff] [blame] | 17 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 18 | #include <vector> |
perkj@webrtc.org | ce5990c | 2012-01-11 13:00:08 +0000 | [diff] [blame] | 19 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 20 | #include "api/array_view.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" |
Tomas Gunnarsson | f25761d | 2020-06-03 22:55:33 +0200 | [diff] [blame] | 26 | #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" |
Markus Handell | e7c015e | 2020-07-07 11:44:28 +0200 | [diff] [blame] | 27 | #include "rtc_base/synchronization/mutex.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 28 | #include "rtc_base/thread_annotations.h" |
| 29 | #include "system_wrappers/include/ntp_time.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
| 31 | namespace webrtc { |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 32 | class VideoBitrateAllocationObserver; |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 33 | namespace rtcp { |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 34 | class CommonHeader; |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 35 | class ReportBlock; |
| 36 | class Rrtr; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 37 | class TargetBitrate; |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 38 | class TmmbItem; |
| 39 | } // namespace rtcp |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 40 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 41 | class RTCPReceiver final { |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 42 | public: |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 43 | class ModuleRtpRtcp { |
| 44 | public: |
| 45 | virtual void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) = 0; |
| 46 | virtual void OnRequestSendReport() = 0; |
| 47 | virtual void OnReceivedNack( |
| 48 | const std::vector<uint16_t>& nack_sequence_numbers) = 0; |
| 49 | virtual void OnReceivedRtcpReportBlocks( |
| 50 | const ReportBlockList& report_blocks) = 0; |
| 51 | |
| 52 | protected: |
| 53 | virtual ~ModuleRtpRtcp() = default; |
| 54 | }; |
| 55 | |
Tomas Gunnarsson | f25761d | 2020-06-03 22:55:33 +0200 | [diff] [blame] | 56 | RTCPReceiver(const RtpRtcpInterface::Configuration& config, |
| 57 | ModuleRtpRtcp* owner); |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 58 | ~RTCPReceiver(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 60 | void IncomingPacket(const uint8_t* packet, size_t packet_size) { |
| 61 | IncomingPacket(rtc::MakeArrayView(packet, packet_size)); |
| 62 | } |
| 63 | void IncomingPacket(rtc::ArrayView<const uint8_t> packet); |
danilchap | 59cb2bd | 2016-08-29 11:08:47 -0700 | [diff] [blame] | 64 | |
Danil Chapovalov | 760c4b4 | 2017-09-27 13:25:24 +0200 | [diff] [blame] | 65 | int64_t LastReceivedReportBlockMs() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 67 | void SetRemoteSSRC(uint32_t ssrc); |
| 68 | uint32_t RemoteSSRC() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 70 | // Get received NTP. |
Alessio Bazzica | 048adc7 | 2021-03-10 15:05:55 +0100 | [diff] [blame^] | 71 | // The types for the arguments below derive from the specification: |
| 72 | // - `remote_sender_packet_count`: `RTCSentRtpStreamStats.packetsSent` [1] |
| 73 | // - `remote_sender_octet_count`: `RTCSentRtpStreamStats.bytesSent` [1] |
| 74 | // - `remote_sender_reports_count`: |
| 75 | // `RTCRemoteOutboundRtpStreamStats.reportsSent` [2] |
| 76 | // [1] https://www.w3.org/TR/webrtc-stats/#remoteoutboundrtpstats-dict* |
| 77 | // [2] https://www.w3.org/TR/webrtc-stats/#dom-rtcsentrtpstreamstats |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 78 | bool NTP(uint32_t* received_ntp_secs, |
| 79 | uint32_t* received_ntp_frac, |
| 80 | uint32_t* rtcp_arrival_time_secs, |
| 81 | uint32_t* rtcp_arrival_time_frac, |
Alessio Bazzica | 048adc7 | 2021-03-10 15:05:55 +0100 | [diff] [blame^] | 82 | uint32_t* rtcp_timestamp, |
| 83 | uint32_t* remote_sender_packet_count, |
| 84 | uint64_t* remote_sender_octet_count, |
| 85 | uint64_t* remote_sender_reports_count) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 86 | |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 87 | std::vector<rtcp::ReceiveTimeInfo> ConsumeReceivedXrReferenceTimeInfo(); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 88 | |
danilchap | 28b03eb | 2016-10-05 06:59:44 -0700 | [diff] [blame] | 89 | // Get rtt. |
| 90 | int32_t RTT(uint32_t remote_ssrc, |
| 91 | int64_t* last_rtt_ms, |
| 92 | int64_t* avg_rtt_ms, |
| 93 | int64_t* min_rtt_ms, |
| 94 | int64_t* max_rtt_ms) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 96 | bool GetAndResetXrRrRtt(int64_t* rtt_ms); |
asapersson@webrtc.org | 7d6bd22 | 2013-10-31 12:14:34 +0000 | [diff] [blame] | 97 | |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 98 | // Called once per second on the worker thread to do rtt calculations. |
| 99 | // Returns an optional rtt value if one is available. |
| 100 | absl::optional<TimeDelta> OnPeriodicRttUpdate(Timestamp newer_than, |
| 101 | bool sending); |
| 102 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 103 | // Get statistics. |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 104 | int32_t StatisticsReceived(std::vector<RTCPReportBlock>* receiveBlocks) const; |
Henrik Boström | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 105 | // A snapshot of Report Blocks with additional data of interest to statistics. |
| 106 | // Within this list, the sender-source SSRC pair is unique and per-pair the |
| 107 | // ReportBlockData represents the latest Report Block that was received for |
| 108 | // that pair. |
| 109 | std::vector<ReportBlockData> GetLatestReportBlockData() const; |
perkj@webrtc.org | ce5990c | 2012-01-11 13:00:08 +0000 | [diff] [blame] | 110 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 111 | // Returns true if we haven't received an RTCP RR for several RTCP |
| 112 | // intervals, but only triggers true once. |
Jiawei Ou | 8b5d9d8 | 2018-11-15 16:44:37 -0800 | [diff] [blame] | 113 | bool RtcpRrTimeout(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 114 | |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 115 | // Returns true if we haven't received an RTCP RR telling the receive side |
| 116 | // has not received RTP packets for too long, i.e. extended highest sequence |
| 117 | // number hasn't increased for several RTCP intervals. The function only |
| 118 | // returns true once until a new RR is received. |
Jiawei Ou | 8b5d9d8 | 2018-11-15 16:44:37 -0800 | [diff] [blame] | 119 | bool RtcpRrSequenceNumberTimeout(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 120 | |
danilchap | 7851bda | 2016-09-29 15:28:07 -0700 | [diff] [blame] | 121 | std::vector<rtcp::TmmbItem> TmmbrReceived(); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 122 | // Return true if new bandwidth should be set. |
| 123 | bool UpdateTmmbrTimers(); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 124 | std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 125 | // Set new bandwidth and notify remote clients about it. |
| 126 | void NotifyTmmbrUpdated(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 127 | |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 128 | private: |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 129 | struct PacketInformation; |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 130 | struct TmmbrInformation; |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 131 | struct RrtrInformation; |
danilchap | efa966b | 2017-02-17 06:23:15 -0800 | [diff] [blame] | 132 | struct LastFirStatus; |
danilchap | 28b03eb | 2016-10-05 06:59:44 -0700 | [diff] [blame] | 133 | // RTCP report blocks mapped by remote SSRC. |
Henrik Boström | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 134 | using ReportBlockDataMap = std::map<uint32_t, ReportBlockData>; |
danilchap | 28b03eb | 2016-10-05 06:59:44 -0700 | [diff] [blame] | 135 | // RTCP report blocks map mapped by source SSRC. |
Henrik Boström | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 136 | using ReportBlockMap = std::map<uint32_t, ReportBlockDataMap>; |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 137 | |
Danil Chapovalov | 443f266 | 2020-03-11 12:24:40 +0100 | [diff] [blame] | 138 | bool ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 139 | PacketInformation* packet_information); |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 140 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 141 | void TriggerCallbacksFromRtcpPacket( |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 142 | const PacketInformation& packet_information); |
danilchap | dd12892 | 2016-09-13 12:23:29 -0700 | [diff] [blame] | 143 | |
danilchap | ec067e9 | 2017-02-21 05:38:19 -0800 | [diff] [blame] | 144 | TmmbrInformation* FindOrCreateTmmbrInfo(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 145 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | ec067e9 | 2017-02-21 05:38:19 -0800 | [diff] [blame] | 146 | // Update TmmbrInformation (if present) is alive. |
| 147 | void UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 148 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 149 | TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 150 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 152 | void HandleSenderReport(const rtcp::CommonHeader& rtcp_block, |
| 153 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 154 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
Danil Chapovalov | 91511f1 | 2016-09-15 16:24:02 +0200 | [diff] [blame] | 155 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 156 | void HandleReceiverReport(const rtcp::CommonHeader& rtcp_block, |
| 157 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 158 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 159 | |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 160 | void HandleReportBlock(const rtcp::ReportBlock& report_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 161 | PacketInformation* packet_information, |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 162 | uint32_t remote_ssrc) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 163 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 164 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 165 | void HandleSdes(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 166 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 167 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 168 | |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 169 | void HandleXr(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 170 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 171 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 172 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 173 | void HandleXrReceiveReferenceTime(uint32_t sender_ssrc, |
| 174 | const rtcp::Rrtr& rrtr) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 175 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 176 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 177 | void HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 178 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 179 | |
sprang | b32aaf9 | 2017-08-28 05:49:12 -0700 | [diff] [blame] | 180 | void HandleXrTargetBitrate(uint32_t ssrc, |
| 181 | const rtcp::TargetBitrate& target_bitrate, |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 182 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 183 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 184 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 185 | void HandleNack(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 186 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 187 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 188 | |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 189 | void HandleApp(const rtcp::CommonHeader& rtcp_block, |
| 190 | PacketInformation* packet_information) |
| 191 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 192 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 193 | void HandleBye(const rtcp::CommonHeader& rtcp_block) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 194 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 195 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 196 | void HandlePli(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 197 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 198 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 199 | |
danilchap | 1b1863a | 2016-09-20 01:39:54 -0700 | [diff] [blame] | 200 | void HandlePsfbApp(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 201 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 202 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 203 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 204 | void HandleTmmbr(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 205 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 206 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 207 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 208 | void HandleTmmbn(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 209 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 210 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 211 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 212 | void HandleSrReq(const rtcp::CommonHeader& rtcp_block, |
| 213 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 214 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 215 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 216 | void HandleFir(const rtcp::CommonHeader& rtcp_block, |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 217 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 218 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
danilchap | da161d7 | 2016-08-19 07:29:46 -0700 | [diff] [blame] | 219 | |
danilchap | 92ea601 | 2016-09-23 10:36:03 -0700 | [diff] [blame] | 220 | void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_block, |
| 221 | PacketInformation* packet_information) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 222 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 223 | |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 224 | bool RtcpRrTimeoutLocked(Timestamp now) |
| 225 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 226 | |
| 227 | bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now) |
| 228 | RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_); |
| 229 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 230 | Clock* const clock_; |
Peter Boström | fe7a80c | 2015-04-23 17:53:17 +0200 | [diff] [blame] | 231 | const bool receiver_only_; |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 232 | ModuleRtpRtcp* const rtp_rtcp_; |
Erik Språng | 6841d25 | 2019-10-15 14:29:11 +0200 | [diff] [blame] | 233 | const uint32_t main_ssrc_; |
| 234 | const std::set<uint32_t> registered_ssrcs_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 235 | |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 236 | RtcpBandwidthObserver* const rtcp_bandwidth_observer_; |
| 237 | RtcpIntraFrameObserver* const rtcp_intra_frame_observer_; |
Elad Alon | 0a8562e | 2019-04-09 11:55:13 +0200 | [diff] [blame] | 238 | RtcpLossNotificationObserver* const rtcp_loss_notification_observer_; |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 239 | NetworkStateEstimateObserver* const network_state_estimate_observer_; |
sprang | a790d83 | 2016-12-02 07:29:44 -0800 | [diff] [blame] | 240 | TransportFeedbackObserver* const transport_feedback_observer_; |
| 241 | VideoBitrateAllocationObserver* const bitrate_allocation_observer_; |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 242 | const TimeDelta report_interval_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | |
Markus Handell | e7c015e | 2020-07-07 11:44:28 +0200 | [diff] [blame] | 244 | mutable Mutex rtcp_receiver_lock_; |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 245 | uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 246 | |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 247 | // Received sender report. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 248 | NtpTime remote_sender_ntp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 249 | uint32_t remote_sender_rtp_time_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 0b4b727 | 2016-10-06 09:24:45 -0700 | [diff] [blame] | 250 | // When did we receive the last send report. |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 251 | NtpTime last_received_sr_ntp_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
Alessio Bazzica | 048adc7 | 2021-03-10 15:05:55 +0100 | [diff] [blame^] | 252 | uint32_t remote_sender_packet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 253 | uint64_t remote_sender_octet_count_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 254 | 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] | 255 | |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 256 | // Received RRTR information in ascending receive time order. |
| 257 | std::list<RrtrInformation> received_rrtrs_ |
| 258 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 259 | // Received RRTR information mapped by remote ssrc. |
| 260 | std::map<uint32_t, std::list<RrtrInformation>::iterator> |
| 261 | received_rrtrs_ssrc_it_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 262 | |
asapersson@webrtc.org | 7d6bd22 | 2013-10-31 12:14:34 +0000 | [diff] [blame] | 263 | // Estimated rtt, zero when there is no valid estimate. |
Niels Möller | be810cb | 2020-12-02 14:25:03 +0100 | [diff] [blame] | 264 | const bool xr_rrtr_status_; |
pkasting@chromium.org | 16825b1 | 2015-01-12 21:51:21 +0000 | [diff] [blame] | 265 | int64_t xr_rr_rtt_ms_; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 266 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 267 | int64_t oldest_tmmbr_info_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 268 | // Mapped by remote ssrc. |
| 269 | std::map<uint32_t, TmmbrInformation> tmmbr_infos_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 270 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
danilchap | 9bf610e | 2017-02-20 06:03:01 -0800 | [diff] [blame] | 271 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 272 | ReportBlockMap received_report_blocks_ RTC_GUARDED_BY(rtcp_receiver_lock_); |
| 273 | std::map<uint32_t, LastFirStatus> last_fir_ |
| 274 | RTC_GUARDED_BY(rtcp_receiver_lock_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 275 | |
Danil Chapovalov | 760c4b4 | 2017-09-27 13:25:24 +0200 | [diff] [blame] | 276 | // The last time we received an RTCP Report block for this module. |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 277 | Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) = |
| 278 | Timestamp::PlusInfinity(); |
mflodman@webrtc.org | 2f225ca | 2013-01-09 13:54:43 +0000 | [diff] [blame] | 279 | |
asapersson@webrtc.org | cb79141 | 2014-12-18 14:30:32 +0000 | [diff] [blame] | 280 | // 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] | 281 | // delivered RTP packet to the remote side. |
Tomas Gunnarsson | ba0ba71 | 2020-07-01 08:53:21 +0200 | [diff] [blame] | 282 | Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity(); |
stefan@webrtc.org | 8ca8a71 | 2013-04-23 16:48:32 +0000 | [diff] [blame] | 283 | |
Danil Chapovalov | bd74d5c | 2020-03-12 09:22:44 +0100 | [diff] [blame] | 284 | RtcpStatisticsCallback* const stats_callback_; |
| 285 | RtcpCnameCallback* const cname_callback_; |
Henrik Boström | f204787 | 2019-05-16 13:32:20 +0200 | [diff] [blame] | 286 | // TODO(hbos): Remove RtcpStatisticsCallback in favor of |
| 287 | // ReportBlockDataObserver; the ReportBlockData contains a superset of the |
| 288 | // RtcpStatistics data. |
Danil Chapovalov | bd74d5c | 2020-03-12 09:22:44 +0100 | [diff] [blame] | 289 | ReportBlockDataObserver* const report_block_data_observer_; |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 290 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 291 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
asapersson@webrtc.org | 8098e07 | 2014-02-19 11:59:02 +0000 | [diff] [blame] | 292 | RtcpPacketTypeCounter packet_type_counter_; |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 293 | |
danilchap | 8443238 | 2017-02-09 05:21:42 -0800 | [diff] [blame] | 294 | RtcpNackStats nack_stats_; |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 295 | |
| 296 | size_t num_skipped_packets_; |
danilchap | 8bab796 | 2016-12-20 02:46:46 -0800 | [diff] [blame] | 297 | int64_t last_skipped_packets_warning_ms_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 298 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 299 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 300 | #endif // MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_ |