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" |
| 25 | #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 26 | #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 27 | #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
pbos@webrtc.org | a048d7c | 2013-05-29 14:27:38 +0000 | [diff] [blame] | 28 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
| 30 | namespace webrtc { |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 31 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 32 | class ModuleRtpRtcpImpl; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 33 | class RTCPReceiver; |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 34 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 35 | class NACKStringBuilder { |
| 36 | public: |
| 37 | NACKStringBuilder(); |
| 38 | ~NACKStringBuilder(); |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame] | 39 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 40 | void PushNACK(uint16_t nack); |
| 41 | std::string GetResult(); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 42 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 43 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 44 | std::ostringstream stream_; |
| 45 | int count_; |
| 46 | uint16_t prevNack_; |
| 47 | bool consecutive_; |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
asapersson@webrtc.org | 9ffd8fe | 2015-01-21 08:22:50 +0000 | [diff] [blame] | 50 | class RTCPSender { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | public: |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 52 | struct FeedbackState { |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 53 | FeedbackState(); |
| 54 | |
| 55 | uint8_t send_payload_type; |
| 56 | uint32_t frequency_hz; |
pbos@webrtc.org | 2f4b14e | 2014-07-15 15:25:39 +0000 | [diff] [blame] | 57 | uint32_t packets_sent; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 58 | size_t media_bytes_sent; |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 59 | uint32_t send_bitrate; |
| 60 | |
| 61 | uint32_t last_rr_ntp_secs; |
| 62 | uint32_t last_rr_ntp_frac; |
| 63 | uint32_t remote_sr; |
| 64 | |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 65 | bool has_last_xr_rr; |
| 66 | RtcpReceiveTimeInfo last_xr_rr; |
| 67 | |
pbos@webrtc.org | 59f20bb | 2013-09-09 16:02:19 +0000 | [diff] [blame] | 68 | // Used when generating TMMBR. |
| 69 | ModuleRtpRtcpImpl* module; |
| 70 | }; |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 71 | |
pbos@webrtc.org | d16e839 | 2014-12-19 13:49:55 +0000 | [diff] [blame] | 72 | RTCPSender(int32_t id, |
| 73 | bool audio, |
| 74 | Clock* clock, |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 75 | ReceiveStatistics* receive_statistics, |
| 76 | RtcpPacketTypeCounterObserver* packet_type_counter_observer); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 77 | virtual ~RTCPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 79 | int32_t RegisterSendTransport(Transport* outgoingTransport); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 81 | RTCPMethod Status() const; |
| 82 | void SetRTCPStatus(RTCPMethod method); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 83 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 84 | bool Sending() const; |
| 85 | int32_t SetSendingStatus(const FeedbackState& feedback_state, |
| 86 | bool enabled); // combine the functions |
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 | int32_t SetNackStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 90 | void SetStartTimestamp(uint32_t start_timestamp); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 91 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 92 | void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms); |
stefan@webrtc.org | 7c3523c | 2012-09-11 07:00:42 +0000 | [diff] [blame] | 93 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 94 | void SetSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 96 | void SetRemoteSSRC(uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
Peter Boström | 9ba52f8 | 2015-06-01 14:12:28 +0200 | [diff] [blame^] | 98 | int32_t SetCNAME(const char* cName); |
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 | int32_t AddMixedCNAME(uint32_t SSRC, const char cName[RTCP_CNAME_SIZE]); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 102 | int32_t RemoveMixedCNAME(uint32_t SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 104 | int64_t SendTimeOfSendReport(uint32_t sendReport); |
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 | bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const; |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 107 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 108 | bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const; |
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 | int32_t SendRTCP(const FeedbackState& feedback_state, |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 111 | RTCPPacketType packetType, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 112 | int32_t nackSize = 0, |
| 113 | const uint16_t* nackList = 0, |
| 114 | bool repeat = false, |
| 115 | uint64_t pictureID = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 116 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 117 | int32_t SendCompoundRTCP(const FeedbackState& feedback_state, |
| 118 | const std::set<RTCPPacketType>& packetTypes, |
| 119 | int32_t nackSize = 0, |
| 120 | const uint16_t* nackList = 0, |
| 121 | bool repeat = false, |
| 122 | uint64_t pictureID = 0); |
| 123 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 124 | bool REMB() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 125 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 126 | void SetREMBStatus(bool enable); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 127 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 128 | void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 129 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 130 | bool TMMBR() const; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 131 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 132 | void SetTMMBRStatus(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 134 | int32_t SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 135 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 136 | // Extended jitter report |
| 137 | bool IJ() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 139 | void SetIJStatus(bool enable); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 140 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 141 | int32_t SetApplicationSpecificData(uint8_t subType, |
| 142 | uint32_t name, |
| 143 | const uint8_t* data, |
| 144 | uint16_t length); |
| 145 | int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 146 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 147 | void SendRtcpXrReceiverReferenceTime(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 148 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 149 | bool RtcpXrReceiverReferenceTime() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 150 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 151 | void SetCsrcs(const std::vector<uint32_t>& csrcs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 152 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 153 | void SetTargetBitrate(unsigned int target_bitrate); |
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 | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 179 | RTCPSender::BuildResult WriteAllReportBlocksToBuffer( |
| 180 | RtcpContext* context, |
| 181 | uint8_t* numberOfReportBlocks) |
| 182 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 183 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 184 | void WriteReportBlocksToBuffer( |
| 185 | RtcpContext* context, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 186 | const std::map<uint32_t, RTCPReportBlock*>& report_blocks); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 187 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 188 | int32_t AddReportBlock(uint32_t SSRC, |
| 189 | std::map<uint32_t, RTCPReportBlock*>* report_blocks, |
| 190 | const RTCPReportBlock* receiveBlock); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 191 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 192 | bool PrepareReport(const FeedbackState& feedback_state, |
| 193 | StreamStatistician* statistician, |
| 194 | RTCPReportBlock* report_block, |
| 195 | uint32_t* ntp_secs, |
| 196 | uint32_t* ntp_frac); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 197 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 198 | int PrepareRTCP(const FeedbackState& feedback_state, |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 199 | const std::set<RTCPPacketType>& packetTypes, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 200 | int32_t nackSize, |
| 201 | const uint16_t* nackList, |
| 202 | bool repeat, |
| 203 | uint64_t pictureID, |
| 204 | uint8_t* rtcp_buffer, |
| 205 | int buffer_size); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 206 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 207 | BuildResult BuildSR(RtcpContext* context) |
| 208 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 209 | BuildResult BuildRR(RtcpContext* context) |
| 210 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 211 | BuildResult BuildExtendedJitterReport(RtcpContext* context) |
| 212 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 213 | BuildResult BuildSDEC(RtcpContext* context) |
| 214 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 215 | BuildResult BuildPLI(RtcpContext* context) |
| 216 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 217 | BuildResult BuildREMB(RtcpContext* context) |
| 218 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 219 | BuildResult BuildTMMBR(RtcpContext* context) |
| 220 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 221 | BuildResult BuildTMMBN(RtcpContext* context) |
| 222 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 223 | BuildResult BuildAPP(RtcpContext* context) |
| 224 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 225 | BuildResult BuildVoIPMetric(RtcpContext* context) |
| 226 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 227 | BuildResult BuildBYE(RtcpContext* context) |
| 228 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 229 | BuildResult BuildFIR(RtcpContext* context) |
| 230 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 231 | BuildResult BuildSLI(RtcpContext* context) |
| 232 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 233 | BuildResult BuildRPSI(RtcpContext* context) |
| 234 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 235 | BuildResult BuildNACK(RtcpContext* context) |
| 236 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 237 | BuildResult BuildReceiverReferenceTime(RtcpContext* context) |
| 238 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 239 | BuildResult BuildDlrr(RtcpContext* context) |
| 240 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 241 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 242 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 243 | const int32_t id_; |
| 244 | const bool audio_; |
| 245 | Clock* const clock_; |
| 246 | RTCPMethod method_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 247 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 248 | rtc::scoped_ptr<CriticalSectionWrapper> critical_section_transport_; |
| 249 | Transport* cbTransport_ GUARDED_BY(critical_section_transport_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 250 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 251 | rtc::scoped_ptr<CriticalSectionWrapper> critical_section_rtcp_sender_; |
| 252 | bool using_nack_ GUARDED_BY(critical_section_rtcp_sender_); |
| 253 | bool sending_ GUARDED_BY(critical_section_rtcp_sender_); |
| 254 | bool remb_enabled_ GUARDED_BY(critical_section_rtcp_sender_); |
| 255 | bool extended_jitter_report_enabled_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 256 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 257 | 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] | 258 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 259 | uint32_t start_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 260 | uint32_t last_rtp_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 261 | int64_t last_frame_capture_time_ms_ GUARDED_BY(critical_section_rtcp_sender_); |
| 262 | uint32_t ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 263 | // SSRC that we receive on our RTP channel |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 264 | uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
| 265 | char cname_[RTCP_CNAME_SIZE] GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 266 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 267 | ReceiveStatistics* receive_statistics_ |
| 268 | GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 269 | std::map<uint32_t, RTCPReportBlock*> internal_report_blocks_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 270 | GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 271 | std::map<uint32_t, RTCPUtility::RTCPCnameInformation*> csrc_cnames_ |
| 272 | GUARDED_BY(critical_section_rtcp_sender_); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 273 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 274 | // Sent |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 275 | uint32_t last_send_report_[RTCP_NUMBER_OF_SR] GUARDED_BY( |
| 276 | critical_section_rtcp_sender_); // allow packet loss and RTT above 1 sec |
| 277 | int64_t last_rtcp_time_[RTCP_NUMBER_OF_SR] GUARDED_BY( |
| 278 | critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 279 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 280 | // Sent XR receiver reference time report. |
| 281 | // <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] | 282 | std::map<uint32_t, int64_t> last_xr_rr_ |
| 283 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 284 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 285 | // send CSRCs |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 286 | std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 287 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 288 | // Full intra request |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 289 | uint8_t sequence_number_fir_ 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 | // REMB |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 292 | uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_); |
| 293 | 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] | 294 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 295 | TMMBRHelp tmmbr_help_ GUARDED_BY(critical_section_rtcp_sender_); |
| 296 | uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_); |
| 297 | uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 298 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 299 | // APP |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 300 | uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_); |
| 301 | uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_); |
| 302 | rtc::scoped_ptr<uint8_t[]> app_data_ GUARDED_BY(critical_section_rtcp_sender_); |
| 303 | uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 304 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 305 | // True if sending of XR Receiver reference time report is enabled. |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 306 | bool xr_send_receiver_reference_time_enabled_ |
| 307 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 308 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 309 | // XR VoIP metric |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 310 | RTCPVoIPMetric xr_voip_metric_ GUARDED_BY(critical_section_rtcp_sender_); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 311 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 312 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
| 313 | RtcpPacketTypeCounter packet_type_counter_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 314 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 315 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame] | 316 | RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_); |
| 317 | |
| 318 | void SetFlag(RTCPPacketType type, bool is_volatile) |
| 319 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 320 | void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) |
| 321 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 322 | bool IsFlagPresent(RTCPPacketType type) const |
| 323 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 324 | bool ConsumeFlag(RTCPPacketType type, bool forced = false) |
| 325 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 326 | bool AllVolatileFlagsConsumed() const |
| 327 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 328 | struct ReportFlag { |
| 329 | ReportFlag(RTCPPacketType type, bool is_volatile) |
| 330 | : type(type), is_volatile(is_volatile) {} |
| 331 | bool operator<(const ReportFlag& flag) const { return type < flag.type; } |
| 332 | bool operator==(const ReportFlag& flag) const { return type == flag.type; } |
| 333 | const RTCPPacketType type; |
| 334 | const bool is_volatile; |
| 335 | }; |
| 336 | |
| 337 | std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_); |
| 338 | |
| 339 | typedef BuildResult (RTCPSender::*Builder)(RtcpContext*); |
| 340 | std::map<RTCPPacketType, Builder> builders_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 341 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 342 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | |
| 344 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |