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 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 98 | int32_t SetCNAME(const char cName[RTCP_CNAME_SIZE]); |
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 | int32_t AddExternalReportBlock(uint32_t SSRC, |
| 125 | const RTCPReportBlock* receiveBlock); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 127 | int32_t RemoveExternalReportBlock(uint32_t SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 129 | bool REMB() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 130 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 131 | void SetREMBStatus(bool enable); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 132 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 133 | void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs); |
pwestin@webrtc.org | 741da94 | 2011-09-20 13:52:04 +0000 | [diff] [blame] | 134 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 135 | bool TMMBR() const; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 136 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 137 | void SetTMMBRStatus(bool enable); |
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 | int32_t SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 141 | // Extended jitter report |
| 142 | bool IJ() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 143 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 144 | void SetIJStatus(bool enable); |
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 | int32_t SetApplicationSpecificData(uint8_t subType, |
| 147 | uint32_t name, |
| 148 | const uint8_t* data, |
| 149 | uint16_t length); |
| 150 | int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 151 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 152 | void SendRtcpXrReceiverReferenceTime(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 153 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 154 | bool RtcpXrReceiverReferenceTime() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 155 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 156 | void SetCsrcs(const std::vector<uint32_t>& csrcs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 157 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 158 | void SetTargetBitrate(unsigned int target_bitrate); |
mflodman@webrtc.org | 117c119 | 2012-01-13 08:52:58 +0000 | [diff] [blame] | 159 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 160 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 161 | struct RtcpContext; |
| 162 | |
| 163 | // The BuildResult indicates the outcome of a call to a builder method, |
| 164 | // constructing a part of an RTCP packet: |
| 165 | // |
| 166 | // kError |
| 167 | // Building RTCP packet failed, propagate error out to caller. |
| 168 | // kAbort |
| 169 | // The (partial) block being build should not be included. Reset current |
| 170 | // buffer position to the state before the method call and proceed to the |
| 171 | // next packet type. |
| 172 | // kTruncated |
| 173 | // There is not enough room in the buffer to fit the data being constructed. |
| 174 | // (IP packet is full). Proceed to the next packet type, and call this |
| 175 | // method again when a new buffer has been allocated. |
| 176 | // TODO(sprang): Actually allocate multiple packets if needed. |
| 177 | // kSuccess |
| 178 | // Data has been successfully placed in the buffer. |
| 179 | |
| 180 | enum class BuildResult { kError, kAborted, kTruncated, kSuccess }; |
| 181 | |
pbos@webrtc.org | d16e839 | 2014-12-19 13:49:55 +0000 | [diff] [blame] | 182 | int32_t SendToNetwork(const uint8_t* dataBuffer, size_t length); |
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 | RTCPSender::BuildResult WriteAllReportBlocksToBuffer( |
| 185 | RtcpContext* context, |
| 186 | uint8_t* numberOfReportBlocks) |
| 187 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 188 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 189 | void WriteReportBlocksToBuffer( |
| 190 | RtcpContext* context, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 191 | const std::map<uint32_t, RTCPReportBlock*>& report_blocks); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 192 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 193 | int32_t AddReportBlock(uint32_t SSRC, |
| 194 | std::map<uint32_t, RTCPReportBlock*>* report_blocks, |
| 195 | const RTCPReportBlock* receiveBlock); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 196 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 197 | bool PrepareReport(const FeedbackState& feedback_state, |
| 198 | StreamStatistician* statistician, |
| 199 | RTCPReportBlock* report_block, |
| 200 | uint32_t* ntp_secs, |
| 201 | uint32_t* ntp_frac); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 202 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 203 | int PrepareRTCP(const FeedbackState& feedback_state, |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 204 | const std::set<RTCPPacketType>& packetTypes, |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 205 | int32_t nackSize, |
| 206 | const uint16_t* nackList, |
| 207 | bool repeat, |
| 208 | uint64_t pictureID, |
| 209 | uint8_t* rtcp_buffer, |
| 210 | int buffer_size); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 211 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 212 | BuildResult BuildSR(RtcpContext* context) |
| 213 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 214 | BuildResult BuildRR(RtcpContext* context) |
| 215 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 216 | BuildResult BuildExtendedJitterReport(RtcpContext* context) |
| 217 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 218 | BuildResult BuildSDEC(RtcpContext* context) |
| 219 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 220 | BuildResult BuildPLI(RtcpContext* context) |
| 221 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 222 | BuildResult BuildREMB(RtcpContext* context) |
| 223 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 224 | BuildResult BuildTMMBR(RtcpContext* context) |
| 225 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 226 | BuildResult BuildTMMBN(RtcpContext* context) |
| 227 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 228 | BuildResult BuildAPP(RtcpContext* context) |
| 229 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 230 | BuildResult BuildVoIPMetric(RtcpContext* context) |
| 231 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 232 | BuildResult BuildBYE(RtcpContext* context) |
| 233 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 234 | BuildResult BuildFIR(RtcpContext* context) |
| 235 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 236 | BuildResult BuildSLI(RtcpContext* context) |
| 237 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 238 | BuildResult BuildRPSI(RtcpContext* context) |
| 239 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 240 | BuildResult BuildNACK(RtcpContext* context) |
| 241 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 242 | BuildResult BuildReceiverReferenceTime(RtcpContext* context) |
| 243 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 244 | BuildResult BuildDlrr(RtcpContext* context) |
| 245 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 246 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 247 | private: |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 248 | const int32_t id_; |
| 249 | const bool audio_; |
| 250 | Clock* const clock_; |
| 251 | RTCPMethod method_ 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 | rtc::scoped_ptr<CriticalSectionWrapper> critical_section_transport_; |
| 254 | Transport* cbTransport_ GUARDED_BY(critical_section_transport_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 255 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 256 | rtc::scoped_ptr<CriticalSectionWrapper> critical_section_rtcp_sender_; |
| 257 | bool using_nack_ GUARDED_BY(critical_section_rtcp_sender_); |
| 258 | bool sending_ GUARDED_BY(critical_section_rtcp_sender_); |
| 259 | bool remb_enabled_ GUARDED_BY(critical_section_rtcp_sender_); |
| 260 | bool extended_jitter_report_enabled_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 261 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 262 | 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] | 263 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 264 | uint32_t start_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 265 | uint32_t last_rtp_timestamp_ GUARDED_BY(critical_section_rtcp_sender_); |
| 266 | int64_t last_frame_capture_time_ms_ GUARDED_BY(critical_section_rtcp_sender_); |
| 267 | uint32_t ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 268 | // SSRC that we receive on our RTP channel |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 269 | uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_); |
| 270 | char cname_[RTCP_CNAME_SIZE] GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 271 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 272 | ReceiveStatistics* receive_statistics_ |
| 273 | GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 274 | std::map<uint32_t, RTCPReportBlock*> internal_report_blocks_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 275 | GUARDED_BY(critical_section_rtcp_sender_); |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 276 | std::map<uint32_t, RTCPReportBlock*> external_report_blocks_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 277 | GUARDED_BY(critical_section_rtcp_sender_); |
| 278 | std::map<uint32_t, RTCPUtility::RTCPCnameInformation*> csrc_cnames_ |
| 279 | GUARDED_BY(critical_section_rtcp_sender_); |
stefan@webrtc.org | 286fe0b | 2013-08-21 20:58:21 +0000 | [diff] [blame] | 280 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 281 | // Sent |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 282 | uint32_t last_send_report_[RTCP_NUMBER_OF_SR] GUARDED_BY( |
| 283 | critical_section_rtcp_sender_); // allow packet loss and RTT above 1 sec |
| 284 | int64_t last_rtcp_time_[RTCP_NUMBER_OF_SR] GUARDED_BY( |
| 285 | critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 286 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 287 | // Sent XR receiver reference time report. |
| 288 | // <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^] | 289 | std::map<uint32_t, int64_t> last_xr_rr_ |
| 290 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 291 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 292 | // send CSRCs |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 293 | std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 294 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 295 | // Full intra request |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 296 | uint8_t sequence_number_fir_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 297 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 298 | // REMB |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 299 | uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_); |
| 300 | 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] | 301 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 302 | TMMBRHelp tmmbr_help_ GUARDED_BY(critical_section_rtcp_sender_); |
| 303 | uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_); |
| 304 | uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 305 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 306 | // APP |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 307 | uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_); |
| 308 | uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_); |
| 309 | rtc::scoped_ptr<uint8_t[]> app_data_ GUARDED_BY(critical_section_rtcp_sender_); |
| 310 | uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 311 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 312 | // True if sending of XR Receiver reference time report is enabled. |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 313 | bool xr_send_receiver_reference_time_enabled_ |
| 314 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 8469f7b | 2013-10-02 13:15:34 +0000 | [diff] [blame] | 315 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 316 | // XR VoIP metric |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 317 | RTCPVoIPMetric xr_voip_metric_ GUARDED_BY(critical_section_rtcp_sender_); |
edjee@google.com | 79b0289 | 2013-04-04 19:43:34 +0000 | [diff] [blame] | 318 | |
Erik Språng | 61be2a4 | 2015-04-27 13:32:52 +0200 | [diff] [blame] | 319 | RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
| 320 | RtcpPacketTypeCounter packet_type_counter_ |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 321 | GUARDED_BY(critical_section_rtcp_sender_); |
asapersson@webrtc.org | 2dd3134 | 2014-10-29 12:42:30 +0000 | [diff] [blame] | 322 | |
Erik Språng | 242e22b | 2015-05-11 10:17:43 +0200 | [diff] [blame^] | 323 | RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_); |
| 324 | |
| 325 | void SetFlag(RTCPPacketType type, bool is_volatile) |
| 326 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 327 | void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) |
| 328 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 329 | bool IsFlagPresent(RTCPPacketType type) const |
| 330 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 331 | bool ConsumeFlag(RTCPPacketType type, bool forced = false) |
| 332 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 333 | bool AllVolatileFlagsConsumed() const |
| 334 | EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 335 | struct ReportFlag { |
| 336 | ReportFlag(RTCPPacketType type, bool is_volatile) |
| 337 | : type(type), is_volatile(is_volatile) {} |
| 338 | bool operator<(const ReportFlag& flag) const { return type < flag.type; } |
| 339 | bool operator==(const ReportFlag& flag) const { return type == flag.type; } |
| 340 | const RTCPPacketType type; |
| 341 | const bool is_volatile; |
| 342 | }; |
| 343 | |
| 344 | std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_); |
| 345 | |
| 346 | typedef BuildResult (RTCPSender::*Builder)(RtcpContext*); |
| 347 | std::map<RTCPPacketType, Builder> builders_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 348 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 349 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 350 | |
| 351 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |