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_SENDER_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
pwestin@webrtc.org | 26f8d9c | 2012-01-19 15:53:09 +0000 | [diff] [blame] | 14 | #include <map> |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 15 | #include <memory> |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 16 | #include <set> |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 17 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 18 | #include <vector> |
pwestin@webrtc.org | 26f8d9c | 2012-01-19 15:53:09 +0000 | [diff] [blame] | 19 | |
Danil Chapovalov | d264df5 | 2018-06-14 12:59:38 +0200 | [diff] [blame] | 20 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "api/call/transport.h" |
Erik Språng | eeaa8f9 | 2018-05-17 12:35:56 +0200 | [diff] [blame] | 22 | #include "api/video/video_bitrate_allocation.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 24 | #include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
| 25 | #include "modules/rtp_rtcp/include/receive_statistics.h" |
Mirko Bonadei | 9b1f24d | 2019-07-12 17:32:28 +0000 | [diff] [blame] | 26 | #include "modules/rtp_rtcp/include/rtp_rtcp.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 27 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 28 | #include "modules/rtp_rtcp/source/rtcp_nack_stats.h" |
| 29 | #include "modules/rtp_rtcp/source/rtcp_packet.h" |
| 30 | #include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h" |
| 31 | #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
| 32 | #include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 33 | #include "rtc_base/constructor_magic.h" |
| 34 | #include "rtc_base/critical_section.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 35 | #include "rtc_base/random.h" |
| 36 | #include "rtc_base/thread_annotations.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
| 38 | namespace webrtc { |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 39 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 40 | class ModuleRtpRtcpImpl; |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 41 | class RtcEventLog; |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 42 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 43 | class RTCPSender { |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 44 | public: |
| 45 | struct FeedbackState { |
| 46 | FeedbackState(); |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 47 | FeedbackState(const FeedbackState&); |
| 48 | FeedbackState(FeedbackState&&); |
| 49 | |
| 50 | ~FeedbackState(); |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 51 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 52 | uint32_t packets_sent; |
| 53 | size_t media_bytes_sent; |
| 54 | uint32_t send_bitrate; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 55 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 56 | uint32_t last_rr_ntp_secs; |
| 57 | uint32_t last_rr_ntp_frac; |
| 58 | uint32_t remote_sr; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 59 | |
Mirta Dvornicic | b1f063d | 2018-04-16 11:16:21 +0200 | [diff] [blame] | 60 | std::vector<rtcp::ReceiveTimeInfo> last_xr_rtis; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 61 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 62 | // Used when generating TMMBR. |
| 63 | ModuleRtpRtcpImpl* module; |
| 64 | }; |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 65 | |
Mirko Bonadei | 9b1f24d | 2019-07-12 17:32:28 +0000 | [diff] [blame] | 66 | explicit RTCPSender(const RtpRtcp::Configuration& config); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 67 | virtual ~RTCPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 69 | RtcpMode Status() const; |
| 70 | void SetRTCPStatus(RtcpMode method); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 72 | bool Sending() const; |
| 73 | int32_t SetSendingStatus(const FeedbackState& feedback_state, |
| 74 | bool enabled); // combine the functions |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 76 | int32_t SetNackStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
danilchap | 71fead2 | 2016-08-18 02:01:49 -0700 | [diff] [blame] | 78 | void SetTimestampOffset(uint32_t timestamp_offset); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 79 | |
Ilya Nikolaevskiy | 5e58bcb | 2018-10-24 13:34:32 +0200 | [diff] [blame] | 80 | // TODO(bugs.webrtc.org/6458): Remove default parameter value when all the |
| 81 | // depending projects are updated to correctly set payload type. |
| 82 | void SetLastRtpTime(uint32_t rtp_timestamp, |
| 83 | int64_t capture_time_ms, |
| 84 | int8_t payload_type = -1); |
| 85 | |
| 86 | void SetRtpClockRate(int8_t payload_type, int rtp_clock_rate_hz); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 87 | |
Erik Språng | e8a6bc3 | 2019-10-15 11:54:23 +0000 | [diff] [blame^] | 88 | uint32_t SSRC() const; |
| 89 | |
| 90 | void SetSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 92 | void SetRemoteSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 94 | int32_t SetCNAME(const char* cName); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 96 | int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 98 | int32_t RemoveMixedCNAME(uint32_t SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 100 | bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 102 | int32_t SendRTCP(const FeedbackState& feedback_state, |
| 103 | RTCPPacketType packetType, |
| 104 | int32_t nackSize = 0, |
nisse | cd386eb | 2017-03-14 08:54:43 -0700 | [diff] [blame] | 105 | const uint16_t* nackList = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 107 | int32_t SendCompoundRTCP(const FeedbackState& feedback_state, |
| 108 | const std::set<RTCPPacketType>& packetTypes, |
| 109 | int32_t nackSize = 0, |
nisse | cd386eb | 2017-03-14 08:54:43 -0700 | [diff] [blame] | 110 | const uint16_t* nackList = 0); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 111 | |
Elad Alon | 7d6a4c0 | 2019-02-25 13:00:51 +0100 | [diff] [blame] | 112 | int32_t SendLossNotification(const FeedbackState& feedback_state, |
| 113 | uint16_t last_decoded_seq_num, |
| 114 | uint16_t last_received_seq_num, |
Elad Alon | e86af2c | 2019-06-03 14:37:50 +0200 | [diff] [blame] | 115 | bool decodability_flag, |
| 116 | bool buffering_allowed); |
Elad Alon | 7d6a4c0 | 2019-02-25 13:00:51 +0100 | [diff] [blame] | 117 | |
Danil Chapovalov | 1de4b62 | 2017-12-13 13:35:10 +0100 | [diff] [blame] | 118 | void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
Danil Chapovalov | f74d641 | 2017-10-18 13:32:57 +0200 | [diff] [blame] | 120 | void UnsetRemb(); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 121 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 122 | bool TMMBR() const; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 123 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 124 | void SetTMMBRStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 125 | |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 126 | void SetMaxRtpPacketSize(size_t max_packet_size); |
danilchap | 41befce | 2016-03-30 11:11:51 -0700 | [diff] [blame] | 127 | |
danilchap | 853ecb2 | 2016-08-22 08:26:15 -0700 | [diff] [blame] | 128 | void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 130 | int32_t SetApplicationSpecificData(uint8_t subType, |
| 131 | uint32_t name, |
| 132 | const uint8_t* data, |
| 133 | uint16_t length); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 134 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 135 | void SendRtcpXrReceiverReferenceTime(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 136 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 137 | bool RtcpXrReceiverReferenceTime() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 139 | void SetCsrcs(const std::vector<uint32_t>& csrcs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 141 | void SetTargetBitrate(unsigned int target_bitrate); |
Erik Språng | 566124a | 2018-04-23 12:32:22 +0200 | [diff] [blame] | 142 | void SetVideoBitrateAllocation(const VideoBitrateAllocation& bitrate); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 143 | bool SendFeedbackPacket(const rtcp::TransportFeedback& packet); |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 144 | bool SendNetworkStateEstimatePacket(const rtcp::RemoteEstimate& packet); |
Per Kjellander | 1699981 | 2019-10-10 12:57:28 +0200 | [diff] [blame] | 145 | void SendCombinedRtcpPacket( |
| 146 | std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets); |
mflodman@webrtc.org | 117c119 | 2012-01-13 08:52:58 +0000 | [diff] [blame] | 147 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 148 | private: |
| 149 | class RtcpContext; |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 150 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 151 | // Determine which RTCP messages should be sent and setup flags. |
Danil Chapovalov | 70ffead | 2016-07-20 15:26:59 +0200 | [diff] [blame] | 152 | void PrepareReport(const FeedbackState& feedback_state) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 153 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 154 | |
danilchap | 96b69bd | 2017-07-25 09:15:14 -0700 | [diff] [blame] | 155 | std::vector<rtcp::ReportBlock> CreateReportBlocks( |
| 156 | const FeedbackState& feedback_state) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 157 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 158 | |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 159 | std::unique_ptr<rtcp::RtcpPacket> BuildSR(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 160 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 161 | std::unique_ptr<rtcp::RtcpPacket> BuildRR(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 162 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 163 | std::unique_ptr<rtcp::RtcpPacket> BuildSDES(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 164 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 165 | std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 166 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 167 | std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 168 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 169 | std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 170 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 171 | std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 172 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 173 | std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 174 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
Elad Alon | 7d6a4c0 | 2019-02-25 13:00:51 +0100 | [diff] [blame] | 175 | std::unique_ptr<rtcp::RtcpPacket> BuildLossNotification( |
| 176 | const RtcpContext& context) |
| 177 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 178 | std::unique_ptr<rtcp::RtcpPacket> BuildExtendedReports( |
| 179 | const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 180 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 181 | std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 182 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 183 | std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 184 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 185 | std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 186 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 187 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 188 | private: |
| 189 | const bool audio_; |
| 190 | Clock* const clock_; |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 191 | Random random_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 192 | RtcpMode method_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 193 | |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 194 | RtcEventLog* const event_log_; |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 195 | Transport* const transport_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 196 | |
Jiawei Ou | 8b5d9d8 | 2018-11-15 16:44:37 -0800 | [diff] [blame] | 197 | const int report_interval_ms_; |
Jiawei Ou | 3587b83 | 2018-01-31 22:08:26 -0800 | [diff] [blame] | 198 | |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 199 | rtc::CriticalSection critical_section_rtcp_sender_; |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 200 | bool sending_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 201 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 202 | int64_t next_time_to_send_rtcp_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 203 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 204 | uint32_t timestamp_offset_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 205 | uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 206 | int64_t last_frame_capture_time_ms_ |
| 207 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | e8a6bc3 | 2019-10-15 11:54:23 +0000 | [diff] [blame^] | 208 | uint32_t ssrc_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 209 | // SSRC that we receive on our RTP channel |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 210 | uint32_t remote_ssrc_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 211 | std::string cname_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 212 | |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 213 | ReceiveStatisticsProvider* receive_statistics_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 214 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 215 | std::map<uint32_t, std::string> csrc_cnames_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 216 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 217 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 218 | // send CSRCs |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 219 | std::vector<uint32_t> csrcs_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 220 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 221 | // Full intra request |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 222 | uint8_t sequence_number_fir_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 223 | |
Elad Alon | 7d6a4c0 | 2019-02-25 13:00:51 +0100 | [diff] [blame] | 224 | // Loss Notification |
| 225 | struct LossNotificationState { |
| 226 | uint16_t last_decoded_seq_num; |
| 227 | uint16_t last_received_seq_num; |
| 228 | bool decodability_flag; |
| 229 | }; |
| 230 | LossNotificationState loss_notification_state_ |
| 231 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 232 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 233 | // REMB |
Danil Chapovalov | 1de4b62 | 2017-12-13 13:35:10 +0100 | [diff] [blame] | 234 | int64_t remb_bitrate_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 235 | std::vector<uint32_t> remb_ssrcs_ |
| 236 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 237 | |
danilchap | 6eaa3a4 | 2016-05-09 10:59:50 -0700 | [diff] [blame] | 238 | std::vector<rtcp::TmmbItem> tmmbn_to_send_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 239 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 240 | uint32_t tmmbr_send_bps_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 241 | uint32_t packet_oh_send_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 242 | size_t max_packet_size_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 244 | // APP |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 245 | uint8_t app_sub_type_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 246 | uint32_t app_name_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 247 | std::unique_ptr<uint8_t[]> app_data_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 248 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 249 | uint16_t app_length_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 250 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 251 | // True if sending of XR Receiver reference time report is enabled. |
| 252 | bool xr_send_receiver_reference_time_enabled_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 253 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 254 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 255 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
| 256 | RtcpPacketTypeCounter packet_type_counter_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 257 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 258 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 259 | RtcpNackStats nack_stats_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 260 | |
Erik Språng | 8782a58 | 2018-10-04 15:36:06 +0200 | [diff] [blame] | 261 | VideoBitrateAllocation video_bitrate_allocation_ |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 262 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 8782a58 | 2018-10-04 15:36:06 +0200 | [diff] [blame] | 263 | bool send_video_bitrate_allocation_ |
| 264 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
Ilya Nikolaevskiy | 5e58bcb | 2018-10-24 13:34:32 +0200 | [diff] [blame] | 265 | |
| 266 | std::map<int8_t, int> rtp_clock_rates_khz_ |
| 267 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 268 | int8_t last_payload_type_ RTC_GUARDED_BY(critical_section_rtcp_sender_); |
| 269 | |
Erik Språng | 1cd7391 | 2018-10-05 12:57:59 +0200 | [diff] [blame] | 270 | absl::optional<VideoBitrateAllocation> CheckAndUpdateLayerStructure( |
| 271 | const VideoBitrateAllocation& bitrate) const |
Erik Språng | 8782a58 | 2018-10-04 15:36:06 +0200 | [diff] [blame] | 272 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 273 | |
| 274 | void SetFlag(uint32_t type, bool is_volatile) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 275 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 276 | void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 277 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 278 | bool IsFlagPresent(uint32_t type) const |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 279 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 280 | bool ConsumeFlag(uint32_t type, bool forced = false) |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 281 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 282 | bool AllVolatileFlagsConsumed() const |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 283 | RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 284 | struct ReportFlag { |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 285 | ReportFlag(uint32_t type, bool is_volatile) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 286 | : type(type), is_volatile(is_volatile) {} |
| 287 | bool operator<(const ReportFlag& flag) const { return type < flag.type; } |
| 288 | bool operator==(const ReportFlag& flag) const { return type == flag.type; } |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 289 | const uint32_t type; |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 290 | const bool is_volatile; |
| 291 | }; |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 292 | |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 293 | std::set<ReportFlag> report_flags_ |
| 294 | RTC_GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 295 | |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 296 | typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)( |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 297 | const RtcpContext&); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 298 | // Map from RTCPPacketType to builder. |
| 299 | std::map<uint32_t, BuilderFunc> builders_; |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 300 | |
| 301 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 302 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 303 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 304 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 305 | #endif // MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |