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> |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 15 | #include <set> |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 16 | #include <sstream> |
| 17 | #include <string> |
pwestin@webrtc.org | 26f8d9c | 2012-01-19 15:53:09 +0000 | [diff] [blame] | 18 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 19 | #include "webrtc/base/scoped_ptr.h" |
pbos@webrtc.org | 38344ed | 2014-09-24 06:05:00 +0000 | [diff] [blame] | 20 | #include "webrtc/base/thread_annotations.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 21 | #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 22 | #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 23 | #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 24 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 25 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 26 | #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 27 | #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 28 | #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 29 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
| 31 | namespace webrtc { |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 32 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 33 | class ModuleRtpRtcpImpl; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 34 | class RTCPReceiver; |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 35 | |
sprang | 233bd87 | 2015-09-08 13:25:16 -0700 | [diff] [blame^] | 36 | namespace rtcp { |
| 37 | class TransportFeedback; |
| 38 | } |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 39 | class NACKStringBuilder { |
| 40 | public: |
| 41 | NACKStringBuilder(); |
| 42 | ~NACKStringBuilder(); |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame] | 43 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 44 | void PushNACK(uint16_t nack); |
| 45 | std::string GetResult(); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 46 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 47 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 48 | std::ostringstream stream_; |
| 49 | int count_; |
| 50 | uint16_t prevNack_; |
| 51 | bool consecutive_; |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 54 | class RTCPSender { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | public: |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 56 | struct FeedbackState { |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 57 | FeedbackState(); |
| 58 | |
| 59 | uint8_t send_payload_type; |
| 60 | uint32_t frequency_hz; |
pbos@webrtc.org | 2f4b14e | 2014-07-15 15:25:39 +0000 | [diff] [blame] | 61 | uint32_t packets_sent; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 62 | size_t media_bytes_sent; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 63 | uint32_t send_bitrate; |
| 64 | |
| 65 | uint32_t last_rr_ntp_secs; |
| 66 | uint32_t last_rr_ntp_frac; |
| 67 | uint32_t remote_sr; |
| 68 | |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 69 | bool has_last_xr_rr; |
| 70 | RtcpReceiveTimeInfo last_xr_rr; |
| 71 | |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 72 | // Used when generating TMMBR. |
| 73 | ModuleRtpRtcpImpl* module; |
| 74 | }; |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 75 | |
pbos@webrtc.org | d16e839 | 2014-12-19 13:49:55 +0000 | [diff] [blame] | 76 | RTCPSender(int32_t id, |
| 77 | bool audio, |
| 78 | Clock* clock, |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 79 | ReceiveStatistics* receive_statistics, |
| 80 | RtcpPacketTypeCounterObserver* packet_type_counter_observer); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 81 | virtual ~RTCPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 83 | int32_t RegisterSendTransport(Transport* outgoingTransport); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 85 | RTCPMethod Status() const; |
| 86 | void SetRTCPStatus(RTCPMethod method); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 88 | bool Sending() const; |
| 89 | int32_t SetSendingStatus(const FeedbackState& feedback_state, |
| 90 | bool enabled); // combine the functions |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 92 | int32_t SetNackStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 94 | void SetStartTimestamp(uint32_t start_timestamp); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 95 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 96 | void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 97 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 98 | void SetSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 100 | void SetRemoteSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
Peter Boström | 9ba52f8 | 2015-06-01 14:12:28 +0200 | [diff] [blame] | 102 | int32_t SetCNAME(const char* cName); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | |
Erik Språng | 0ea42d3 | 2015-06-25 14:46:16 +0200 | [diff] [blame] | 104 | int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 106 | int32_t RemoveMixedCNAME(uint32_t SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 108 | int64_t SendTimeOfSendReport(uint32_t sendReport); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 110 | bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 111 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 112 | bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 114 | int32_t SendRTCP(const FeedbackState& feedback_state, |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 115 | RTCPPacketType packetType, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 116 | int32_t nackSize = 0, |
| 117 | const uint16_t* nackList = 0, |
| 118 | bool repeat = false, |
| 119 | uint64_t pictureID = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 121 | int32_t SendCompoundRTCP(const FeedbackState& feedback_state, |
| 122 | const std::set<RTCPPacketType>& packetTypes, |
| 123 | int32_t nackSize = 0, |
| 124 | const uint16_t* nackList = 0, |
| 125 | bool repeat = false, |
| 126 | uint64_t pictureID = 0); |
| 127 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 128 | bool REMB() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 130 | void SetREMBStatus(bool enable); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 131 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 132 | void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 133 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 134 | bool TMMBR() const; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 135 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 136 | void SetTMMBRStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 137 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 138 | int32_t SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 140 | int32_t SetApplicationSpecificData(uint8_t subType, |
| 141 | uint32_t name, |
| 142 | const uint8_t* data, |
| 143 | uint16_t length); |
| 144 | int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 145 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 146 | void SendRtcpXrReceiverReferenceTime(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 147 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 148 | bool RtcpXrReceiverReferenceTime() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 149 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 150 | void SetCsrcs(const std::vector<uint32_t>& csrcs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 152 | void SetTargetBitrate(unsigned int target_bitrate); |
sprang | 233bd87 | 2015-09-08 13:25:16 -0700 | [diff] [blame^] | 153 | bool SendFeedbackPacket(const rtcp::TransportFeedback& packet); |
mflodman@webrtc.org | 117c119 | 2012-01-13 08:52:58 +0000 | [diff] [blame] | 154 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 155 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 156 | struct RtcpContext; |
| 157 | |
| 158 | // The BuildResult indicates the outcome of a call to a builder method, |
| 159 | // constructing a part of an RTCP packet: |
| 160 | // |
| 161 | // kError |
| 162 | // Building RTCP packet failed, propagate error out to caller. |
| 163 | // kAbort |
| 164 | // The (partial) block being build should not be included. Reset current |
| 165 | // buffer position to the state before the method call and proceed to the |
| 166 | // next packet type. |
| 167 | // kTruncated |
| 168 | // There is not enough room in the buffer to fit the data being constructed. |
| 169 | // (IP packet is full). Proceed to the next packet type, and call this |
| 170 | // method again when a new buffer has been allocated. |
| 171 | // TODO(sprang): Actually allocate multiple packets if needed. |
| 172 | // kSuccess |
| 173 | // Data has been successfully placed in the buffer. |
| 174 | |
| 175 | enum class BuildResult { kError, kAborted, kTruncated, kSuccess }; |
| 176 | |
pbos@webrtc.org | d16e839 | 2014-12-19 13:49:55 +0000 | [diff] [blame] | 177 | int32_t SendToNetwork(const uint8_t* dataBuffer, size_t length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 178 | |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 179 | int32_t AddReportBlock(const RTCPReportBlock& report_block) |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 180 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 181 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 182 | bool PrepareReport(const FeedbackState& feedback_state, |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 183 | uint32_t ssrc, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 184 | StreamStatistician* statistician, |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 185 | RTCPReportBlock* report_block); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 186 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 187 | int PrepareRTCP(const FeedbackState& feedback_state, |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 188 | const std::set<RTCPPacketType>& packetTypes, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 189 | int32_t nackSize, |
| 190 | const uint16_t* nackList, |
| 191 | bool repeat, |
| 192 | uint64_t pictureID, |
| 193 | uint8_t* rtcp_buffer, |
| 194 | int buffer_size); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 195 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 196 | BuildResult BuildSR(RtcpContext* context) |
| 197 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 198 | BuildResult BuildRR(RtcpContext* context) |
| 199 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
Erik Språng | 0ea42d3 | 2015-06-25 14:46:16 +0200 | [diff] [blame] | 200 | BuildResult BuildSDES(RtcpContext* context) |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 201 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 202 | BuildResult BuildPLI(RtcpContext* context) |
| 203 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 204 | BuildResult BuildREMB(RtcpContext* context) |
| 205 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 206 | BuildResult BuildTMMBR(RtcpContext* context) |
| 207 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 208 | BuildResult BuildTMMBN(RtcpContext* context) |
| 209 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 210 | BuildResult BuildAPP(RtcpContext* context) |
| 211 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 212 | BuildResult BuildVoIPMetric(RtcpContext* context) |
| 213 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 214 | BuildResult BuildBYE(RtcpContext* context) |
| 215 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 216 | BuildResult BuildFIR(RtcpContext* context) |
| 217 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 218 | BuildResult BuildSLI(RtcpContext* context) |
| 219 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 220 | BuildResult BuildRPSI(RtcpContext* context) |
| 221 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 222 | BuildResult BuildNACK(RtcpContext* context) |
| 223 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 224 | BuildResult BuildReceiverReferenceTime(RtcpContext* context) |
| 225 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 226 | BuildResult BuildDlrr(RtcpContext* context) |
| 227 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 228 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 229 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 230 | const int32_t id_; |
| 231 | const bool audio_; |
| 232 | Clock* const clock_; |
| 233 | RTCPMethod method_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 234 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 235 | rtc::scoped_ptr<CriticalSectionWrapper> critical_section_transport_; |
| 236 | Transport* cbTransport_ GUARDED_BY(critical_section_transport_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 237 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 238 | rtc::scoped_ptr<CriticalSectionWrapper> critical_section_rtcp_sender_; |
| 239 | bool using_nack_ GUARDED_BY(critical_section_rtcp_sender_); |
| 240 | bool sending_ GUARDED_BY(critical_section_rtcp_sender_); |
| 241 | bool remb_enabled_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 242 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 243 | 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] | 244 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 245 | uint32_t start_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 246 | uint32_t last_rtp_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 247 | int64_t last_frame_capture_time_ms_ GUARDED_BY(critical_section_rtcp_sender_); |
| 248 | uint32_t ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 249 | // SSRC that we receive on our RTP channel |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 250 | uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 0ea42d3 | 2015-06-25 14:46:16 +0200 | [diff] [blame] | 251 | std::string cname_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 252 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 253 | ReceiveStatistics* receive_statistics_ |
| 254 | GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 255 | std::map<uint32_t, rtcp::ReportBlock> report_blocks_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 256 | GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 0ea42d3 | 2015-06-25 14:46:16 +0200 | [diff] [blame] | 257 | std::map<uint32_t, std::string> csrc_cnames_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 258 | GUARDED_BY(critical_section_rtcp_sender_); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 259 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 260 | // Sent |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 261 | uint32_t last_send_report_[RTCP_NUMBER_OF_SR] GUARDED_BY( |
| 262 | critical_section_rtcp_sender_); // allow packet loss and RTT above 1 sec |
| 263 | int64_t last_rtcp_time_[RTCP_NUMBER_OF_SR] GUARDED_BY( |
| 264 | critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 265 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 266 | // Sent XR receiver reference time report. |
| 267 | // <mid ntp (mid 32 bits of the 64 bits NTP timestamp), send time in ms>. |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 268 | std::map<uint32_t, int64_t> last_xr_rr_ |
| 269 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 270 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 271 | // send CSRCs |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 272 | std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 273 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 274 | // Full intra request |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 275 | uint8_t sequence_number_fir_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 276 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 277 | // REMB |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 278 | uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_); |
| 279 | 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] | 280 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 281 | TMMBRHelp tmmbr_help_ GUARDED_BY(critical_section_rtcp_sender_); |
| 282 | uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_); |
| 283 | uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 284 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 285 | // APP |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 286 | uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_); |
| 287 | uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_); |
| 288 | rtc::scoped_ptr<uint8_t[]> app_data_ GUARDED_BY(critical_section_rtcp_sender_); |
| 289 | uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 290 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 291 | // True if sending of XR Receiver reference time report is enabled. |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 292 | bool xr_send_receiver_reference_time_enabled_ |
| 293 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 294 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 295 | // XR VoIP metric |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 296 | RTCPVoIPMetric xr_voip_metric_ GUARDED_BY(critical_section_rtcp_sender_); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 297 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 298 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
| 299 | RtcpPacketTypeCounter packet_type_counter_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 300 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 301 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 302 | RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_); |
| 303 | |
| 304 | void SetFlag(RTCPPacketType type, bool is_volatile) |
| 305 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 306 | void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) |
| 307 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 308 | bool IsFlagPresent(RTCPPacketType type) const |
| 309 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 310 | bool ConsumeFlag(RTCPPacketType type, bool forced = false) |
| 311 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 312 | bool AllVolatileFlagsConsumed() const |
| 313 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 314 | struct ReportFlag { |
| 315 | ReportFlag(RTCPPacketType type, bool is_volatile) |
| 316 | : type(type), is_volatile(is_volatile) {} |
| 317 | bool operator<(const ReportFlag& flag) const { return type < flag.type; } |
| 318 | bool operator==(const ReportFlag& flag) const { return type == flag.type; } |
| 319 | const RTCPPacketType type; |
| 320 | const bool is_volatile; |
| 321 | }; |
| 322 | |
| 323 | std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_); |
| 324 | |
| 325 | typedef BuildResult (RTCPSender::*Builder)(RtcpContext*); |
| 326 | std::map<RTCPPacketType, Builder> builders_; |
Erik Språng | bdc0b0d | 2015-06-22 15:21:24 +0200 | [diff] [blame] | 327 | |
| 328 | class PacketBuiltCallback; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 329 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 330 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 331 | |
| 332 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |