blob: 50500ff12c93e59c911d300447b2bc4d5666852e [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"
Erik Språngbdc0b0d2015-06-22 15:21:24 +020025#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000026#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.orga048d7c2013-05-29 14:27:38 +000029#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000030
31namespace webrtc {
pwestin@webrtc.org741da942011-09-20 13:52:04 +000032
wu@webrtc.org822fbd82013-08-15 23:38:54 +000033class ModuleRtpRtcpImpl;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000034class RTCPReceiver;
pwestin@webrtc.org741da942011-09-20 13:52:04 +000035
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000036class NACKStringBuilder {
37 public:
38 NACKStringBuilder();
39 ~NACKStringBuilder();
pbos@webrtc.orgf3e4cee2013-07-31 15:17:19 +000040
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000041 void PushNACK(uint16_t nack);
42 std::string GetResult();
edjee@google.com79b02892013-04-04 19:43:34 +000043
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000044 private:
Erik Språng242e22b2015-05-11 10:17:43 +020045 std::ostringstream stream_;
46 int count_;
47 uint16_t prevNack_;
48 bool consecutive_;
edjee@google.com79b02892013-04-04 19:43:34 +000049};
50
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000051class RTCPSender {
niklase@google.com470e71d2011-07-07 08:21:25 +000052public:
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000053 struct FeedbackState {
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000054 FeedbackState();
55
56 uint8_t send_payload_type;
57 uint32_t frequency_hz;
pbos@webrtc.org2f4b14e2014-07-15 15:25:39 +000058 uint32_t packets_sent;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000059 size_t media_bytes_sent;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000060 uint32_t send_bitrate;
61
62 uint32_t last_rr_ntp_secs;
63 uint32_t last_rr_ntp_frac;
64 uint32_t remote_sr;
65
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +000066 bool has_last_xr_rr;
67 RtcpReceiveTimeInfo last_xr_rr;
68
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000069 // Used when generating TMMBR.
70 ModuleRtpRtcpImpl* module;
71 };
Erik Språng61be2a42015-04-27 13:32:52 +020072
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +000073 RTCPSender(int32_t id,
74 bool audio,
75 Clock* clock,
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +000076 ReceiveStatistics* receive_statistics,
77 RtcpPacketTypeCounterObserver* packet_type_counter_observer);
Erik Språng61be2a42015-04-27 13:32:52 +020078 virtual ~RTCPSender();
niklase@google.com470e71d2011-07-07 08:21:25 +000079
Erik Språng61be2a42015-04-27 13:32:52 +020080 int32_t RegisterSendTransport(Transport* outgoingTransport);
niklase@google.com470e71d2011-07-07 08:21:25 +000081
Erik Språng61be2a42015-04-27 13:32:52 +020082 RTCPMethod Status() const;
83 void SetRTCPStatus(RTCPMethod method);
niklase@google.com470e71d2011-07-07 08:21:25 +000084
Erik Språng61be2a42015-04-27 13:32:52 +020085 bool Sending() const;
86 int32_t SetSendingStatus(const FeedbackState& feedback_state,
87 bool enabled); // combine the functions
niklase@google.com470e71d2011-07-07 08:21:25 +000088
Erik Språng61be2a42015-04-27 13:32:52 +020089 int32_t SetNackStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000090
Erik Språng61be2a42015-04-27 13:32:52 +020091 void SetStartTimestamp(uint32_t start_timestamp);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000092
Erik Språng61be2a42015-04-27 13:32:52 +020093 void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000094
Erik Språng61be2a42015-04-27 13:32:52 +020095 void SetSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +000096
Erik Språng61be2a42015-04-27 13:32:52 +020097 void SetRemoteSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +000098
Peter Boström9ba52f82015-06-01 14:12:28 +020099 int32_t SetCNAME(const char* cName);
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
Erik Språng61be2a42015-04-27 13:32:52 +0200101 int32_t AddMixedCNAME(uint32_t SSRC, const char cName[RTCP_CNAME_SIZE]);
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
Erik Språng61be2a42015-04-27 13:32:52 +0200103 int32_t RemoveMixedCNAME(uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
Erik Språng61be2a42015-04-27 13:32:52 +0200105 int64_t SendTimeOfSendReport(uint32_t sendReport);
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
Erik Språng61be2a42015-04-27 13:32:52 +0200107 bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000108
Erik Språng61be2a42015-04-27 13:32:52 +0200109 bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000110
Erik Språng61be2a42015-04-27 13:32:52 +0200111 int32_t SendRTCP(const FeedbackState& feedback_state,
Erik Språng242e22b2015-05-11 10:17:43 +0200112 RTCPPacketType packetType,
Erik Språng61be2a42015-04-27 13:32:52 +0200113 int32_t nackSize = 0,
114 const uint16_t* nackList = 0,
115 bool repeat = false,
116 uint64_t pictureID = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
Erik Språng242e22b2015-05-11 10:17:43 +0200118 int32_t SendCompoundRTCP(const FeedbackState& feedback_state,
119 const std::set<RTCPPacketType>& packetTypes,
120 int32_t nackSize = 0,
121 const uint16_t* nackList = 0,
122 bool repeat = false,
123 uint64_t pictureID = 0);
124
Erik Språng61be2a42015-04-27 13:32:52 +0200125 bool REMB() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
Erik Språng61be2a42015-04-27 13:32:52 +0200127 void SetREMBStatus(bool enable);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000128
Erik Språng61be2a42015-04-27 13:32:52 +0200129 void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000130
Erik Språng61be2a42015-04-27 13:32:52 +0200131 bool TMMBR() const;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000132
Erik Språng61be2a42015-04-27 13:32:52 +0200133 void SetTMMBRStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000134
Erik Språng61be2a42015-04-27 13:32:52 +0200135 int32_t SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit);
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
Erik Språng61be2a42015-04-27 13:32:52 +0200137 // Extended jitter report
138 bool IJ() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000139
Erik Språng61be2a42015-04-27 13:32:52 +0200140 void SetIJStatus(bool enable);
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000141
Erik Språng61be2a42015-04-27 13:32:52 +0200142 int32_t SetApplicationSpecificData(uint8_t subType,
143 uint32_t name,
144 const uint8_t* data,
145 uint16_t length);
146 int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric);
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000147
Erik Språng61be2a42015-04-27 13:32:52 +0200148 void SendRtcpXrReceiverReferenceTime(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000149
Erik Språng61be2a42015-04-27 13:32:52 +0200150 bool RtcpXrReceiverReferenceTime() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000151
Erik Språng61be2a42015-04-27 13:32:52 +0200152 void SetCsrcs(const std::vector<uint32_t>& csrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000153
Erik Språng61be2a42015-04-27 13:32:52 +0200154 void SetTargetBitrate(unsigned int target_bitrate);
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000155
niklase@google.com470e71d2011-07-07 08:21:25 +0000156private:
Erik Språng242e22b2015-05-11 10:17:43 +0200157 struct RtcpContext;
158
159 // The BuildResult indicates the outcome of a call to a builder method,
160 // constructing a part of an RTCP packet:
161 //
162 // kError
163 // Building RTCP packet failed, propagate error out to caller.
164 // kAbort
165 // The (partial) block being build should not be included. Reset current
166 // buffer position to the state before the method call and proceed to the
167 // next packet type.
168 // kTruncated
169 // There is not enough room in the buffer to fit the data being constructed.
170 // (IP packet is full). Proceed to the next packet type, and call this
171 // method again when a new buffer has been allocated.
172 // TODO(sprang): Actually allocate multiple packets if needed.
173 // kSuccess
174 // Data has been successfully placed in the buffer.
175
176 enum class BuildResult { kError, kAborted, kTruncated, kSuccess };
177
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000178 int32_t SendToNetwork(const uint8_t* dataBuffer, size_t length);
niklase@google.com470e71d2011-07-07 08:21:25 +0000179
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200180 int32_t AddReportBlock(const RTCPReportBlock& report_block)
Erik Språng242e22b2015-05-11 10:17:43 +0200181 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000182
Erik Språng61be2a42015-04-27 13:32:52 +0200183 bool PrepareReport(const FeedbackState& feedback_state,
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200184 uint32_t ssrc,
Erik Språng61be2a42015-04-27 13:32:52 +0200185 StreamStatistician* statistician,
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200186 RTCPReportBlock* report_block);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000187
Erik Språng61be2a42015-04-27 13:32:52 +0200188 int PrepareRTCP(const FeedbackState& feedback_state,
Erik Språng242e22b2015-05-11 10:17:43 +0200189 const std::set<RTCPPacketType>& packetTypes,
Erik Språng61be2a42015-04-27 13:32:52 +0200190 int32_t nackSize,
191 const uint16_t* nackList,
192 bool repeat,
193 uint64_t pictureID,
194 uint8_t* rtcp_buffer,
195 int buffer_size);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000196
Erik Språng242e22b2015-05-11 10:17:43 +0200197 BuildResult BuildSR(RtcpContext* context)
198 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
199 BuildResult BuildRR(RtcpContext* context)
200 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
201 BuildResult BuildExtendedJitterReport(RtcpContext* context)
202 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
203 BuildResult BuildSDEC(RtcpContext* context)
204 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
205 BuildResult BuildPLI(RtcpContext* context)
206 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
207 BuildResult BuildREMB(RtcpContext* context)
208 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
209 BuildResult BuildTMMBR(RtcpContext* context)
210 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
211 BuildResult BuildTMMBN(RtcpContext* context)
212 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
213 BuildResult BuildAPP(RtcpContext* context)
214 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
215 BuildResult BuildVoIPMetric(RtcpContext* context)
216 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
217 BuildResult BuildBYE(RtcpContext* context)
218 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
219 BuildResult BuildFIR(RtcpContext* context)
220 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
221 BuildResult BuildSLI(RtcpContext* context)
222 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
223 BuildResult BuildRPSI(RtcpContext* context)
224 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
225 BuildResult BuildNACK(RtcpContext* context)
226 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
227 BuildResult BuildReceiverReferenceTime(RtcpContext* context)
228 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
229 BuildResult BuildDlrr(RtcpContext* context)
230 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000231
niklase@google.com470e71d2011-07-07 08:21:25 +0000232private:
Erik Språng242e22b2015-05-11 10:17:43 +0200233 const int32_t id_;
234 const bool audio_;
235 Clock* const clock_;
236 RTCPMethod method_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000237
Erik Språng242e22b2015-05-11 10:17:43 +0200238 rtc::scoped_ptr<CriticalSectionWrapper> critical_section_transport_;
239 Transport* cbTransport_ GUARDED_BY(critical_section_transport_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000240
Erik Språng242e22b2015-05-11 10:17:43 +0200241 rtc::scoped_ptr<CriticalSectionWrapper> critical_section_rtcp_sender_;
242 bool using_nack_ GUARDED_BY(critical_section_rtcp_sender_);
243 bool sending_ GUARDED_BY(critical_section_rtcp_sender_);
244 bool remb_enabled_ GUARDED_BY(critical_section_rtcp_sender_);
245 bool extended_jitter_report_enabled_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000246
Erik Språng242e22b2015-05-11 10:17:43 +0200247 int64_t next_time_to_send_rtcp_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000248
Erik Språng242e22b2015-05-11 10:17:43 +0200249 uint32_t start_timestamp_ GUARDED_BY(critical_section_rtcp_sender_);
250 uint32_t last_rtp_timestamp_ GUARDED_BY(critical_section_rtcp_sender_);
251 int64_t last_frame_capture_time_ms_ GUARDED_BY(critical_section_rtcp_sender_);
252 uint32_t ssrc_ GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng61be2a42015-04-27 13:32:52 +0200253 // SSRC that we receive on our RTP channel
Erik Språng242e22b2015-05-11 10:17:43 +0200254 uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_);
255 char cname_[RTCP_CNAME_SIZE] GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000256
Erik Språng242e22b2015-05-11 10:17:43 +0200257 ReceiveStatistics* receive_statistics_
258 GUARDED_BY(critical_section_rtcp_sender_);
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200259 std::map<uint32_t, rtcp::ReportBlock> report_blocks_
Erik Språng242e22b2015-05-11 10:17:43 +0200260 GUARDED_BY(critical_section_rtcp_sender_);
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200261 // TODO(sprang): Can we avoid pointers here?
Erik Språng242e22b2015-05-11 10:17:43 +0200262 std::map<uint32_t, RTCPUtility::RTCPCnameInformation*> csrc_cnames_
263 GUARDED_BY(critical_section_rtcp_sender_);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000264
Erik Språng61be2a42015-04-27 13:32:52 +0200265 // Sent
Erik Språng242e22b2015-05-11 10:17:43 +0200266 uint32_t last_send_report_[RTCP_NUMBER_OF_SR] GUARDED_BY(
267 critical_section_rtcp_sender_); // allow packet loss and RTT above 1 sec
268 int64_t last_rtcp_time_[RTCP_NUMBER_OF_SR] GUARDED_BY(
269 critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000270
Erik Språng61be2a42015-04-27 13:32:52 +0200271 // Sent XR receiver reference time report.
272 // <mid ntp (mid 32 bits of the 64 bits NTP timestamp), send time in ms>.
Erik Språng242e22b2015-05-11 10:17:43 +0200273 std::map<uint32_t, int64_t> last_xr_rr_
274 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000275
Erik Språng61be2a42015-04-27 13:32:52 +0200276 // send CSRCs
Erik Språng242e22b2015-05-11 10:17:43 +0200277 std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000278
Erik Språng61be2a42015-04-27 13:32:52 +0200279 // Full intra request
Erik Språng242e22b2015-05-11 10:17:43 +0200280 uint8_t sequence_number_fir_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000281
Erik Språng61be2a42015-04-27 13:32:52 +0200282 // REMB
Erik Språng242e22b2015-05-11 10:17:43 +0200283 uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_);
284 std::vector<uint32_t> remb_ssrcs_ GUARDED_BY(critical_section_rtcp_sender_);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000285
Erik Språng242e22b2015-05-11 10:17:43 +0200286 TMMBRHelp tmmbr_help_ GUARDED_BY(critical_section_rtcp_sender_);
287 uint32_t tmmbr_send_ GUARDED_BY(critical_section_rtcp_sender_);
288 uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000289
Erik Språng61be2a42015-04-27 13:32:52 +0200290 // APP
Erik Språng242e22b2015-05-11 10:17:43 +0200291 uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_);
292 uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_);
293 rtc::scoped_ptr<uint8_t[]> app_data_ GUARDED_BY(critical_section_rtcp_sender_);
294 uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000295
Erik Språng61be2a42015-04-27 13:32:52 +0200296 // True if sending of XR Receiver reference time report is enabled.
Erik Språng242e22b2015-05-11 10:17:43 +0200297 bool xr_send_receiver_reference_time_enabled_
298 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000299
Erik Språng61be2a42015-04-27 13:32:52 +0200300 // XR VoIP metric
Erik Språng242e22b2015-05-11 10:17:43 +0200301 RTCPVoIPMetric xr_voip_metric_ GUARDED_BY(critical_section_rtcp_sender_);
edjee@google.com79b02892013-04-04 19:43:34 +0000302
Erik Språng61be2a42015-04-27 13:32:52 +0200303 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
304 RtcpPacketTypeCounter packet_type_counter_
Erik Språng242e22b2015-05-11 10:17:43 +0200305 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000306
Erik Språng242e22b2015-05-11 10:17:43 +0200307 RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_);
308
309 void SetFlag(RTCPPacketType type, bool is_volatile)
310 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
311 void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile)
312 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
313 bool IsFlagPresent(RTCPPacketType type) const
314 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
315 bool ConsumeFlag(RTCPPacketType type, bool forced = false)
316 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
317 bool AllVolatileFlagsConsumed() const
318 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
319 struct ReportFlag {
320 ReportFlag(RTCPPacketType type, bool is_volatile)
321 : type(type), is_volatile(is_volatile) {}
322 bool operator<(const ReportFlag& flag) const { return type < flag.type; }
323 bool operator==(const ReportFlag& flag) const { return type == flag.type; }
324 const RTCPPacketType type;
325 const bool is_volatile;
326 };
327
328 std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_);
329
330 typedef BuildResult (RTCPSender::*Builder)(RtcpContext*);
331 std::map<RTCPPacketType, Builder> builders_;
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200332
333 class PacketBuiltCallback;
niklase@google.com470e71d2011-07-07 08:21:25 +0000334};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000335} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000336
337#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_