blob: 143fef7a8900b6c665cfe2f48111ebd6b3a2b5ab [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org26f8d9c2012-01-19 15:53:09 +000014#include <map>
Erik Språng242e22b2015-05-11 10:17:43 +020015#include <set>
edjee@google.com79b02892013-04-04 19:43:34 +000016#include <sstream>
17#include <string>
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +000018
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000019#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org38344ed2014-09-24 06:05:00 +000020#include "webrtc/base/thread_annotations.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000021#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
22#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
wu@webrtc.org822fbd82013-08-15 23:38:54 +000023#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000024#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.orga048d7c2013-05-29 14:27:38 +000028#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000029
30namespace webrtc {
pwestin@webrtc.org741da942011-09-20 13:52:04 +000031
wu@webrtc.org822fbd82013-08-15 23:38:54 +000032class ModuleRtpRtcpImpl;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000033class RTCPReceiver;
pwestin@webrtc.org741da942011-09-20 13:52:04 +000034
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000035class NACKStringBuilder {
36 public:
37 NACKStringBuilder();
38 ~NACKStringBuilder();
pbos@webrtc.orgf3e4cee2013-07-31 15:17:19 +000039
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000040 void PushNACK(uint16_t nack);
41 std::string GetResult();
edjee@google.com79b02892013-04-04 19:43:34 +000042
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000043 private:
Erik Språng242e22b2015-05-11 10:17:43 +020044 std::ostringstream stream_;
45 int count_;
46 uint16_t prevNack_;
47 bool consecutive_;
edjee@google.com79b02892013-04-04 19:43:34 +000048};
49
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000050class RTCPSender {
niklase@google.com470e71d2011-07-07 08:21:25 +000051public:
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000052 struct FeedbackState {
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000053 FeedbackState();
54
55 uint8_t send_payload_type;
56 uint32_t frequency_hz;
pbos@webrtc.org2f4b14e2014-07-15 15:25:39 +000057 uint32_t packets_sent;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000058 size_t media_bytes_sent;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000059 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.org8469f7b2013-10-02 13:15:34 +000065 bool has_last_xr_rr;
66 RtcpReceiveTimeInfo last_xr_rr;
67
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000068 // Used when generating TMMBR.
69 ModuleRtpRtcpImpl* module;
70 };
Erik Språng61be2a42015-04-27 13:32:52 +020071
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +000072 RTCPSender(int32_t id,
73 bool audio,
74 Clock* clock,
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +000075 ReceiveStatistics* receive_statistics,
76 RtcpPacketTypeCounterObserver* packet_type_counter_observer);
Erik Språng61be2a42015-04-27 13:32:52 +020077 virtual ~RTCPSender();
niklase@google.com470e71d2011-07-07 08:21:25 +000078
Erik Språng61be2a42015-04-27 13:32:52 +020079 int32_t RegisterSendTransport(Transport* outgoingTransport);
niklase@google.com470e71d2011-07-07 08:21:25 +000080
Erik Språng61be2a42015-04-27 13:32:52 +020081 RTCPMethod Status() const;
82 void SetRTCPStatus(RTCPMethod method);
niklase@google.com470e71d2011-07-07 08:21:25 +000083
Erik Språng61be2a42015-04-27 13:32:52 +020084 bool Sending() const;
85 int32_t SetSendingStatus(const FeedbackState& feedback_state,
86 bool enabled); // combine the functions
niklase@google.com470e71d2011-07-07 08:21:25 +000087
Erik Språng61be2a42015-04-27 13:32:52 +020088 int32_t SetNackStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000089
Erik Språng61be2a42015-04-27 13:32:52 +020090 void SetStartTimestamp(uint32_t start_timestamp);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000091
Erik Språng61be2a42015-04-27 13:32:52 +020092 void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000093
Erik Språng61be2a42015-04-27 13:32:52 +020094 void SetSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +000095
Erik Språng61be2a42015-04-27 13:32:52 +020096 void SetRemoteSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +000097
Peter Boström9ba52f82015-06-01 14:12:28 +020098 int32_t SetCNAME(const char* cName);
niklase@google.com470e71d2011-07-07 08:21:25 +000099
Erik Språng61be2a42015-04-27 13:32:52 +0200100 int32_t AddMixedCNAME(uint32_t SSRC, const char cName[RTCP_CNAME_SIZE]);
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
Erik Språng61be2a42015-04-27 13:32:52 +0200102 int32_t RemoveMixedCNAME(uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
Erik Språng61be2a42015-04-27 13:32:52 +0200104 int64_t SendTimeOfSendReport(uint32_t sendReport);
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
Erik Språng61be2a42015-04-27 13:32:52 +0200106 bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000107
Erik Språng61be2a42015-04-27 13:32:52 +0200108 bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
Erik Språng61be2a42015-04-27 13:32:52 +0200110 int32_t SendRTCP(const FeedbackState& feedback_state,
Erik Språng242e22b2015-05-11 10:17:43 +0200111 RTCPPacketType packetType,
Erik Språng61be2a42015-04-27 13:32:52 +0200112 int32_t nackSize = 0,
113 const uint16_t* nackList = 0,
114 bool repeat = false,
115 uint64_t pictureID = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000116
Erik Språng242e22b2015-05-11 10:17:43 +0200117 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ång61be2a42015-04-27 13:32:52 +0200124 bool REMB() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000125
Erik Språng61be2a42015-04-27 13:32:52 +0200126 void SetREMBStatus(bool enable);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000127
Erik Språng61be2a42015-04-27 13:32:52 +0200128 void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000129
Erik Språng61be2a42015-04-27 13:32:52 +0200130 bool TMMBR() const;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000131
Erik Språng61be2a42015-04-27 13:32:52 +0200132 void SetTMMBRStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000133
Erik Språng61be2a42015-04-27 13:32:52 +0200134 int32_t SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit);
niklase@google.com470e71d2011-07-07 08:21:25 +0000135
Erik Språng61be2a42015-04-27 13:32:52 +0200136 // Extended jitter report
137 bool IJ() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000138
Erik Språng61be2a42015-04-27 13:32:52 +0200139 void SetIJStatus(bool enable);
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000140
Erik Språng61be2a42015-04-27 13:32:52 +0200141 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.org5249cc82011-12-16 14:31:37 +0000146
Erik Språng61be2a42015-04-27 13:32:52 +0200147 void SendRtcpXrReceiverReferenceTime(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000148
Erik Språng61be2a42015-04-27 13:32:52 +0200149 bool RtcpXrReceiverReferenceTime() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000150
Erik Språng61be2a42015-04-27 13:32:52 +0200151 void SetCsrcs(const std::vector<uint32_t>& csrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000152
Erik Språng61be2a42015-04-27 13:32:52 +0200153 void SetTargetBitrate(unsigned int target_bitrate);
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000154
niklase@google.com470e71d2011-07-07 08:21:25 +0000155private:
Erik Språng242e22b2015-05-11 10:17:43 +0200156 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.orgd16e8392014-12-19 13:49:55 +0000177 int32_t SendToNetwork(const uint8_t* dataBuffer, size_t length);
niklase@google.com470e71d2011-07-07 08:21:25 +0000178
Erik Språng242e22b2015-05-11 10:17:43 +0200179 RTCPSender::BuildResult WriteAllReportBlocksToBuffer(
180 RtcpContext* context,
181 uint8_t* numberOfReportBlocks)
182 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000183
Erik Språng242e22b2015-05-11 10:17:43 +0200184 void WriteReportBlocksToBuffer(
185 RtcpContext* context,
Erik Språng61be2a42015-04-27 13:32:52 +0200186 const std::map<uint32_t, RTCPReportBlock*>& report_blocks);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000187
Erik Språng61be2a42015-04-27 13:32:52 +0200188 int32_t AddReportBlock(uint32_t SSRC,
189 std::map<uint32_t, RTCPReportBlock*>* report_blocks,
190 const RTCPReportBlock* receiveBlock);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000191
Erik Språng61be2a42015-04-27 13:32:52 +0200192 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.org286fe0b2013-08-21 20:58:21 +0000197
Erik Språng61be2a42015-04-27 13:32:52 +0200198 int PrepareRTCP(const FeedbackState& feedback_state,
Erik Språng242e22b2015-05-11 10:17:43 +0200199 const std::set<RTCPPacketType>& packetTypes,
Erik Språng61be2a42015-04-27 13:32:52 +0200200 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.org286fe0b2013-08-21 20:58:21 +0000206
Erik Språng242e22b2015-05-11 10:17:43 +0200207 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.org8469f7b2013-10-02 13:15:34 +0000241
niklase@google.com470e71d2011-07-07 08:21:25 +0000242private:
Erik Språng242e22b2015-05-11 10:17:43 +0200243 const int32_t id_;
244 const bool audio_;
245 Clock* const clock_;
246 RTCPMethod method_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000247
Erik Språng242e22b2015-05-11 10:17:43 +0200248 rtc::scoped_ptr<CriticalSectionWrapper> critical_section_transport_;
249 Transport* cbTransport_ GUARDED_BY(critical_section_transport_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000250
Erik Språng242e22b2015-05-11 10:17:43 +0200251 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.com470e71d2011-07-07 08:21:25 +0000256
Erik Språng242e22b2015-05-11 10:17:43 +0200257 int64_t next_time_to_send_rtcp_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000258
Erik Språng242e22b2015-05-11 10:17:43 +0200259 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ång61be2a42015-04-27 13:32:52 +0200263 // SSRC that we receive on our RTP channel
Erik Språng242e22b2015-05-11 10:17:43 +0200264 uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_);
265 char cname_[RTCP_CNAME_SIZE] GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000266
Erik Språng242e22b2015-05-11 10:17:43 +0200267 ReceiveStatistics* receive_statistics_
268 GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng61be2a42015-04-27 13:32:52 +0200269 std::map<uint32_t, RTCPReportBlock*> internal_report_blocks_
Erik Språng242e22b2015-05-11 10:17:43 +0200270 GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200271 std::map<uint32_t, RTCPUtility::RTCPCnameInformation*> csrc_cnames_
272 GUARDED_BY(critical_section_rtcp_sender_);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000273
Erik Språng61be2a42015-04-27 13:32:52 +0200274 // Sent
Erik Språng242e22b2015-05-11 10:17:43 +0200275 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.com470e71d2011-07-07 08:21:25 +0000279
Erik Språng61be2a42015-04-27 13:32:52 +0200280 // Sent XR receiver reference time report.
281 // <mid ntp (mid 32 bits of the 64 bits NTP timestamp), send time in ms>.
Erik Språng242e22b2015-05-11 10:17:43 +0200282 std::map<uint32_t, int64_t> last_xr_rr_
283 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000284
Erik Språng61be2a42015-04-27 13:32:52 +0200285 // send CSRCs
Erik Språng242e22b2015-05-11 10:17:43 +0200286 std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000287
Erik Språng61be2a42015-04-27 13:32:52 +0200288 // Full intra request
Erik Språng242e22b2015-05-11 10:17:43 +0200289 uint8_t sequence_number_fir_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000290
Erik Språng61be2a42015-04-27 13:32:52 +0200291 // REMB
Erik Språng242e22b2015-05-11 10:17:43 +0200292 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.org741da942011-09-20 13:52:04 +0000294
Erik Språng242e22b2015-05-11 10:17:43 +0200295 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.com470e71d2011-07-07 08:21:25 +0000298
Erik Språng61be2a42015-04-27 13:32:52 +0200299 // APP
Erik Språng242e22b2015-05-11 10:17:43 +0200300 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.com470e71d2011-07-07 08:21:25 +0000304
Erik Språng61be2a42015-04-27 13:32:52 +0200305 // True if sending of XR Receiver reference time report is enabled.
Erik Språng242e22b2015-05-11 10:17:43 +0200306 bool xr_send_receiver_reference_time_enabled_
307 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000308
Erik Språng61be2a42015-04-27 13:32:52 +0200309 // XR VoIP metric
Erik Språng242e22b2015-05-11 10:17:43 +0200310 RTCPVoIPMetric xr_voip_metric_ GUARDED_BY(critical_section_rtcp_sender_);
edjee@google.com79b02892013-04-04 19:43:34 +0000311
Erik Språng61be2a42015-04-27 13:32:52 +0200312 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
313 RtcpPacketTypeCounter packet_type_counter_
Erik Språng242e22b2015-05-11 10:17:43 +0200314 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000315
Erik Språng242e22b2015-05-11 10:17:43 +0200316 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.com470e71d2011-07-07 08:21:25 +0000341};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000342} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000343
344#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_