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 | |
| 11 | #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |
| 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 <sstream> |
| 18 | #include <string> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 19 | #include <vector> |
pwestin@webrtc.org | 26f8d9c | 2012-01-19 15:53:09 +0000 | [diff] [blame] | 20 | |
aleloi | a8eb756 | 2016-11-28 07:02:13 -0800 | [diff] [blame] | 21 | #include "webrtc/api/call/transport.h" |
kwiberg | 84f6a3f | 2017-09-05 08:43:13 -0700 | [diff] [blame^] | 22 | #include "webrtc/api/optional.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 23 | #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 24 | #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 25 | #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
| 26 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
danilchap | 8443238 | 2017-02-09 05:21:42 -0800 | [diff] [blame] | 27 | #include "webrtc/modules/rtp_rtcp/source/rtcp_nack_stats.h" |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 28 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
danilchap | 798896a | 2016-09-28 02:54:25 -0700 | [diff] [blame] | 29 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" |
danilchap | 34ed2b9 | 2016-01-18 02:43:32 -0800 | [diff] [blame] | 30 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
danilchap | 13deaad | 2016-05-24 13:25:27 -0700 | [diff] [blame] | 31 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 32 | #include "webrtc/rtc_base/constructormagic.h" |
| 33 | #include "webrtc/rtc_base/criticalsection.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 34 | #include "webrtc/rtc_base/random.h" |
| 35 | #include "webrtc/rtc_base/thread_annotations.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 36 | #include "webrtc/typedefs.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 NACKStringBuilder { |
| 44 | public: |
| 45 | NACKStringBuilder(); |
| 46 | ~NACKStringBuilder(); |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame] | 47 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 48 | void PushNACK(uint16_t nack); |
| 49 | std::string GetResult(); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 50 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 51 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 52 | std::ostringstream stream_; |
| 53 | int count_; |
| 54 | uint16_t prevNack_; |
| 55 | bool consecutive_; |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 58 | class RTCPSender { |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 59 | public: |
| 60 | struct FeedbackState { |
| 61 | FeedbackState(); |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 62 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 63 | uint32_t packets_sent; |
| 64 | size_t media_bytes_sent; |
| 65 | uint32_t send_bitrate; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 66 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 67 | uint32_t last_rr_ntp_secs; |
| 68 | uint32_t last_rr_ntp_frac; |
| 69 | uint32_t remote_sr; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 70 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 71 | bool has_last_xr_rr; |
danilchap | 798896a | 2016-09-28 02:54:25 -0700 | [diff] [blame] | 72 | rtcp::ReceiveTimeInfo last_xr_rr; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 73 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 74 | // Used when generating TMMBR. |
| 75 | ModuleRtpRtcpImpl* module; |
| 76 | }; |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 77 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 78 | RTCPSender(bool audio, |
| 79 | Clock* clock, |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 80 | ReceiveStatisticsProvider* receive_statistics, |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 81 | RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 82 | RtcEventLog* event_log, |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 83 | Transport* outgoing_transport); |
| 84 | virtual ~RTCPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 86 | RtcpMode Status() const; |
| 87 | void SetRTCPStatus(RtcpMode method); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 89 | bool Sending() const; |
| 90 | int32_t SetSendingStatus(const FeedbackState& feedback_state, |
| 91 | bool enabled); // combine the functions |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 93 | int32_t SetNackStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 94 | |
danilchap | 71fead2 | 2016-08-18 02:01:49 -0700 | [diff] [blame] | 95 | void SetTimestampOffset(uint32_t timestamp_offset); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 96 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 97 | void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 98 | |
nisse | 14adba7 | 2017-03-20 03:52:39 -0700 | [diff] [blame] | 99 | uint32_t SSRC() const; |
| 100 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 101 | void SetSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 102 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 103 | void SetRemoteSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 105 | int32_t SetCNAME(const char* cName); |
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 AddMixedCNAME(uint32_t SSRC, const char* c_name); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 109 | int32_t RemoveMixedCNAME(uint32_t SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 110 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 111 | bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 113 | int32_t SendRTCP(const FeedbackState& feedback_state, |
| 114 | RTCPPacketType packetType, |
| 115 | int32_t nackSize = 0, |
nisse | cd386eb | 2017-03-14 08:54:43 -0700 | [diff] [blame] | 116 | const uint16_t* nackList = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 118 | int32_t SendCompoundRTCP(const FeedbackState& feedback_state, |
| 119 | const std::set<RTCPPacketType>& packetTypes, |
| 120 | int32_t nackSize = 0, |
nisse | cd386eb | 2017-03-14 08:54:43 -0700 | [diff] [blame] | 121 | const uint16_t* nackList = 0); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 122 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 123 | bool REMB() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 125 | void SetREMBStatus(bool enable); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 126 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 127 | void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 128 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 129 | bool TMMBR() const; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 130 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 131 | void SetTMMBRStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 133 | void SetMaxRtpPacketSize(size_t max_packet_size); |
danilchap | 41befce | 2016-03-30 11:11:51 -0700 | [diff] [blame] | 134 | |
danilchap | 853ecb2 | 2016-08-22 08:26:15 -0700 | [diff] [blame] | 135 | void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set); |
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 | int32_t SetApplicationSpecificData(uint8_t subType, |
| 138 | uint32_t name, |
| 139 | const uint8_t* data, |
| 140 | uint16_t length); |
| 141 | int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 142 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 143 | void SendRtcpXrReceiverReferenceTime(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 144 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 145 | bool RtcpXrReceiverReferenceTime() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 146 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 147 | void SetCsrcs(const std::vector<uint32_t>& csrcs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 148 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 149 | void SetTargetBitrate(unsigned int target_bitrate); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 150 | void SetVideoBitrateAllocation(const BitrateAllocation& bitrate); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 151 | bool SendFeedbackPacket(const rtcp::TransportFeedback& packet); |
mflodman@webrtc.org | 117c119 | 2012-01-13 08:52:58 +0000 | [diff] [blame] | 152 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 153 | private: |
| 154 | class RtcpContext; |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 155 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 156 | // Determine which RTCP messages should be sent and setup flags. |
Danil Chapovalov | 70ffead | 2016-07-20 15:26:59 +0200 | [diff] [blame] | 157 | void PrepareReport(const FeedbackState& feedback_state) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 158 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 159 | |
danilchap | 96b69bd | 2017-07-25 09:15:14 -0700 | [diff] [blame] | 160 | std::vector<rtcp::ReportBlock> CreateReportBlocks( |
| 161 | const FeedbackState& feedback_state) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 162 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 163 | |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 164 | std::unique_ptr<rtcp::RtcpPacket> BuildSR(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 165 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 166 | std::unique_ptr<rtcp::RtcpPacket> BuildRR(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 167 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 168 | std::unique_ptr<rtcp::RtcpPacket> BuildSDES(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 169 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 170 | std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 171 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 172 | std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 173 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 174 | std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 175 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 176 | std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 177 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 178 | std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 179 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 180 | std::unique_ptr<rtcp::RtcpPacket> BuildExtendedReports( |
| 181 | const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 182 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 183 | std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 184 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 185 | std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 186 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 187 | std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 188 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 189 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 190 | private: |
| 191 | const bool audio_; |
| 192 | Clock* const clock_; |
danilchap | 47a740b | 2015-12-15 00:30:07 -0800 | [diff] [blame] | 193 | Random random_ GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 194 | RtcpMode method_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 195 | |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 196 | RtcEventLog* const event_log_; |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 197 | Transport* const transport_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 198 | |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 199 | rtc::CriticalSection critical_section_rtcp_sender_; |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 200 | bool using_nack_ GUARDED_BY(critical_section_rtcp_sender_); |
| 201 | bool sending_ GUARDED_BY(critical_section_rtcp_sender_); |
| 202 | bool remb_enabled_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 203 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 204 | int64_t next_time_to_send_rtcp_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 205 | |
danilchap | 71fead2 | 2016-08-18 02:01:49 -0700 | [diff] [blame] | 206 | uint32_t timestamp_offset_ GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 207 | uint32_t last_rtp_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 208 | int64_t last_frame_capture_time_ms_ GUARDED_BY(critical_section_rtcp_sender_); |
| 209 | uint32_t ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
| 210 | // SSRC that we receive on our RTP channel |
| 211 | uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
| 212 | std::string cname_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 213 | |
danilchap | f5f793c | 2017-07-27 04:44:18 -0700 | [diff] [blame] | 214 | ReceiveStatisticsProvider* receive_statistics_ |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 215 | GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 216 | std::map<uint32_t, std::string> csrc_cnames_ |
| 217 | GUARDED_BY(critical_section_rtcp_sender_); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 218 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 219 | // send CSRCs |
| 220 | std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 221 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 222 | // Full intra request |
| 223 | uint8_t sequence_number_fir_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 224 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 225 | // REMB |
| 226 | uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_); |
| 227 | std::vector<uint32_t> remb_ssrcs_ GUARDED_BY(critical_section_rtcp_sender_); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 228 | |
danilchap | 6eaa3a4 | 2016-05-09 10:59:50 -0700 | [diff] [blame] | 229 | std::vector<rtcp::TmmbItem> tmmbn_to_send_ |
| 230 | GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 2b61639 | 2016-08-18 06:17:42 -0700 | [diff] [blame] | 231 | uint32_t tmmbr_send_bps_ GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 232 | uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_); |
nisse | 6f142eb | 2017-02-21 07:32:47 -0800 | [diff] [blame] | 233 | size_t max_packet_size_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 234 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 235 | // APP |
| 236 | uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_); |
| 237 | uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_); |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 238 | std::unique_ptr<uint8_t[]> app_data_ |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 239 | GUARDED_BY(critical_section_rtcp_sender_); |
| 240 | uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 241 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 242 | // True if sending of XR Receiver reference time report is enabled. |
| 243 | bool xr_send_receiver_reference_time_enabled_ |
| 244 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 245 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 246 | // XR VoIP metric |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 247 | rtc::Optional<RTCPVoIPMetric> xr_voip_metric_ |
| 248 | GUARDED_BY(critical_section_rtcp_sender_); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 249 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 250 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
| 251 | RtcpPacketTypeCounter packet_type_counter_ |
| 252 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 253 | |
danilchap | 8443238 | 2017-02-09 05:21:42 -0800 | [diff] [blame] | 254 | RtcpNackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 255 | |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 256 | rtc::Optional<BitrateAllocation> video_bitrate_allocation_ |
| 257 | GUARDED_BY(critical_section_rtcp_sender_); |
| 258 | |
| 259 | void SetFlag(uint32_t type, bool is_volatile) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 260 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 261 | void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) |
| 262 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 263 | bool IsFlagPresent(uint32_t type) const |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 264 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 265 | bool ConsumeFlag(uint32_t type, bool forced = false) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 266 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 267 | bool AllVolatileFlagsConsumed() const |
| 268 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 269 | struct ReportFlag { |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 270 | ReportFlag(uint32_t type, bool is_volatile) |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 271 | : type(type), is_volatile(is_volatile) {} |
| 272 | bool operator<(const ReportFlag& flag) const { return type < flag.type; } |
| 273 | bool operator==(const ReportFlag& flag) const { return type == flag.type; } |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 274 | const uint32_t type; |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 275 | const bool is_volatile; |
| 276 | }; |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 277 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 278 | std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 279 | |
danilchap | 56036ff | 2016-03-22 11:14:09 -0700 | [diff] [blame] | 280 | typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)( |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 281 | const RtcpContext&); |
sprang | 5e38c96 | 2016-12-01 05:18:09 -0800 | [diff] [blame] | 282 | // Map from RTCPPacketType to builder. |
| 283 | std::map<uint32_t, BuilderFunc> builders_; |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 284 | |
| 285 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 286 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 287 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 288 | |
danilchap | 162abd3 | 2015-12-10 02:39:40 -0800 | [diff] [blame] | 289 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |