blob: a8bd275eeaee2b962ffccac74f9b2c2b97a5079f [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>
danilchap56036ff2016-03-22 11:14:09 -070015#include <memory>
Erik Språng242e22b2015-05-11 10:17:43 +020016#include <set>
edjee@google.com79b02892013-04-04 19:43:34 +000017#include <sstream>
18#include <string>
danilchapb8b6fbb2015-12-10 05:05:27 -080019#include <vector>
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +000020
aleloia8eb7562016-11-28 07:02:13 -080021#include "webrtc/api/call/transport.h"
kwiberg4485ffb2016-04-26 08:14:39 -070022#include "webrtc/base/constructormagic.h"
danilchap56036ff2016-03-22 11:14:09 -070023#include "webrtc/base/criticalsection.h"
sprang5e38c962016-12-01 05:18:09 -080024#include "webrtc/base/optional.h"
danilchap47a740b2015-12-15 00:30:07 -080025#include "webrtc/base/random.h"
pbos@webrtc.org38344ed2014-09-24 06:05:00 +000026#include "webrtc/base/thread_annotations.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000027#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
28#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010029#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
30#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Erik Språngbdc0b0d2015-06-22 15:21:24 +020031#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
danilchap798896a2016-09-28 02:54:25 -070032#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
danilchap34ed2b92016-01-18 02:43:32 -080033#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
danilchap13deaad2016-05-24 13:25:27 -070034#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000035#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000036#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38namespace webrtc {
pwestin@webrtc.org741da942011-09-20 13:52:04 +000039
wu@webrtc.org822fbd82013-08-15 23:38:54 +000040class ModuleRtpRtcpImpl;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000041class RTCPReceiver;
terelius429c3452016-01-21 05:42:04 -080042class RtcEventLog;
pwestin@webrtc.org741da942011-09-20 13:52:04 +000043
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000044class NACKStringBuilder {
45 public:
46 NACKStringBuilder();
47 ~NACKStringBuilder();
pbos@webrtc.orgf3e4cee2013-07-31 15:17:19 +000048
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000049 void PushNACK(uint16_t nack);
50 std::string GetResult();
edjee@google.com79b02892013-04-04 19:43:34 +000051
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000052 private:
Erik Språng242e22b2015-05-11 10:17:43 +020053 std::ostringstream stream_;
54 int count_;
55 uint16_t prevNack_;
56 bool consecutive_;
edjee@google.com79b02892013-04-04 19:43:34 +000057};
58
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000059class RTCPSender {
danilchap162abd32015-12-10 02:39:40 -080060 public:
61 struct FeedbackState {
62 FeedbackState();
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000063
danilchap162abd32015-12-10 02:39:40 -080064 uint8_t send_payload_type;
danilchap162abd32015-12-10 02:39:40 -080065 uint32_t packets_sent;
66 size_t media_bytes_sent;
67 uint32_t send_bitrate;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000068
danilchap162abd32015-12-10 02:39:40 -080069 uint32_t last_rr_ntp_secs;
70 uint32_t last_rr_ntp_frac;
71 uint32_t remote_sr;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000072
danilchap162abd32015-12-10 02:39:40 -080073 bool has_last_xr_rr;
danilchap798896a2016-09-28 02:54:25 -070074 rtcp::ReceiveTimeInfo last_xr_rr;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +000075
danilchap162abd32015-12-10 02:39:40 -080076 // Used when generating TMMBR.
77 ModuleRtpRtcpImpl* module;
78 };
Erik Språng61be2a42015-04-27 13:32:52 +020079
danilchap162abd32015-12-10 02:39:40 -080080 RTCPSender(bool audio,
81 Clock* clock,
82 ReceiveStatistics* receive_statistics,
83 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
terelius429c3452016-01-21 05:42:04 -080084 RtcEventLog* event_log,
danilchap162abd32015-12-10 02:39:40 -080085 Transport* outgoing_transport);
86 virtual ~RTCPSender();
niklase@google.com470e71d2011-07-07 08:21:25 +000087
danilchap162abd32015-12-10 02:39:40 -080088 RtcpMode Status() const;
89 void SetRTCPStatus(RtcpMode method);
niklase@google.com470e71d2011-07-07 08:21:25 +000090
danilchap162abd32015-12-10 02:39:40 -080091 bool Sending() const;
92 int32_t SetSendingStatus(const FeedbackState& feedback_state,
93 bool enabled); // combine the functions
niklase@google.com470e71d2011-07-07 08:21:25 +000094
danilchap162abd32015-12-10 02:39:40 -080095 int32_t SetNackStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000096
danilchap71fead22016-08-18 02:01:49 -070097 void SetTimestampOffset(uint32_t timestamp_offset);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000098
danilchap162abd32015-12-10 02:39:40 -080099 void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000100
danilchap162abd32015-12-10 02:39:40 -0800101 void SetSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
danilchap162abd32015-12-10 02:39:40 -0800103 void SetRemoteSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
danilchap162abd32015-12-10 02:39:40 -0800105 int32_t SetCNAME(const char* cName);
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
danilchap162abd32015-12-10 02:39:40 -0800107 int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name);
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
danilchap162abd32015-12-10 02:39:40 -0800109 int32_t RemoveMixedCNAME(uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000110
danilchap162abd32015-12-10 02:39:40 -0800111 bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112
danilchap162abd32015-12-10 02:39:40 -0800113 int32_t SendRTCP(const FeedbackState& feedback_state,
114 RTCPPacketType packetType,
115 int32_t nackSize = 0,
116 const uint16_t* nackList = 0,
117 bool repeat = false,
118 uint64_t pictureID = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000119
danilchap162abd32015-12-10 02:39:40 -0800120 int32_t SendCompoundRTCP(const FeedbackState& feedback_state,
121 const std::set<RTCPPacketType>& packetTypes,
122 int32_t nackSize = 0,
123 const uint16_t* nackList = 0,
124 bool repeat = false,
125 uint64_t pictureID = 0);
Erik Språng242e22b2015-05-11 10:17:43 +0200126
danilchap162abd32015-12-10 02:39:40 -0800127 bool REMB() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000128
danilchap162abd32015-12-10 02:39:40 -0800129 void SetREMBStatus(bool enable);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000130
danilchap162abd32015-12-10 02:39:40 -0800131 void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000132
danilchap162abd32015-12-10 02:39:40 -0800133 bool TMMBR() const;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000134
danilchap162abd32015-12-10 02:39:40 -0800135 void SetTMMBRStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
danilchap41befce2016-03-30 11:11:51 -0700137 void SetMaxPayloadLength(size_t max_payload_length);
138
danilchap853ecb22016-08-22 08:26:15 -0700139 void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set);
niklase@google.com470e71d2011-07-07 08:21:25 +0000140
danilchap162abd32015-12-10 02:39:40 -0800141 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
danilchap162abd32015-12-10 02:39:40 -0800147 void SendRtcpXrReceiverReferenceTime(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000148
danilchap162abd32015-12-10 02:39:40 -0800149 bool RtcpXrReceiverReferenceTime() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000150
danilchap162abd32015-12-10 02:39:40 -0800151 void SetCsrcs(const std::vector<uint32_t>& csrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000152
danilchap162abd32015-12-10 02:39:40 -0800153 void SetTargetBitrate(unsigned int target_bitrate);
sprang5e38c962016-12-01 05:18:09 -0800154 void SetVideoBitrateAllocation(const BitrateAllocation& bitrate);
danilchap162abd32015-12-10 02:39:40 -0800155 bool SendFeedbackPacket(const rtcp::TransportFeedback& packet);
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000156
danilchap162abd32015-12-10 02:39:40 -0800157 private:
158 class RtcpContext;
Erik Språng242e22b2015-05-11 10:17:43 +0200159
danilchap162abd32015-12-10 02:39:40 -0800160 // Determine which RTCP messages should be sent and setup flags.
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200161 void PrepareReport(const FeedbackState& feedback_state)
danilchap162abd32015-12-10 02:39:40 -0800162 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000163
danilchapa72e7342015-12-22 08:07:45 -0800164 bool AddReportBlock(const FeedbackState& feedback_state,
165 uint32_t ssrc,
166 StreamStatistician* statistician)
danilchap162abd32015-12-10 02:39:40 -0800167 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000168
danilchap56036ff2016-03-22 11:14:09 -0700169 std::unique_ptr<rtcp::RtcpPacket> BuildSR(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800170 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700171 std::unique_ptr<rtcp::RtcpPacket> BuildRR(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800172 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700173 std::unique_ptr<rtcp::RtcpPacket> BuildSDES(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800174 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700175 std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800176 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700177 std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800178 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700179 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800180 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700181 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800182 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700183 std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800184 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800185 std::unique_ptr<rtcp::RtcpPacket> BuildExtendedReports(
186 const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800187 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700188 std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800189 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700190 std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800191 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700192 std::unique_ptr<rtcp::RtcpPacket> BuildSLI(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800193 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700194 std::unique_ptr<rtcp::RtcpPacket> BuildRPSI(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800195 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700196 std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context)
danilchap162abd32015-12-10 02:39:40 -0800197 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000198
danilchap162abd32015-12-10 02:39:40 -0800199 private:
200 const bool audio_;
201 Clock* const clock_;
danilchap47a740b2015-12-15 00:30:07 -0800202 Random random_ GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800203 RtcpMode method_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000204
terelius429c3452016-01-21 05:42:04 -0800205 RtcEventLog* const event_log_;
danilchap162abd32015-12-10 02:39:40 -0800206 Transport* const transport_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000207
danilchap56036ff2016-03-22 11:14:09 -0700208 rtc::CriticalSection critical_section_rtcp_sender_;
danilchap162abd32015-12-10 02:39:40 -0800209 bool using_nack_ GUARDED_BY(critical_section_rtcp_sender_);
210 bool sending_ GUARDED_BY(critical_section_rtcp_sender_);
211 bool remb_enabled_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000212
danilchap162abd32015-12-10 02:39:40 -0800213 int64_t next_time_to_send_rtcp_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000214
danilchap71fead22016-08-18 02:01:49 -0700215 uint32_t timestamp_offset_ GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800216 uint32_t last_rtp_timestamp_ GUARDED_BY(critical_section_rtcp_sender_);
217 int64_t last_frame_capture_time_ms_ GUARDED_BY(critical_section_rtcp_sender_);
218 uint32_t ssrc_ GUARDED_BY(critical_section_rtcp_sender_);
219 // SSRC that we receive on our RTP channel
220 uint32_t remote_ssrc_ GUARDED_BY(critical_section_rtcp_sender_);
221 std::string cname_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000222
danilchap162abd32015-12-10 02:39:40 -0800223 ReceiveStatistics* receive_statistics_
224 GUARDED_BY(critical_section_rtcp_sender_);
225 std::map<uint32_t, rtcp::ReportBlock> report_blocks_
226 GUARDED_BY(critical_section_rtcp_sender_);
227 std::map<uint32_t, std::string> csrc_cnames_
228 GUARDED_BY(critical_section_rtcp_sender_);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000229
danilchap162abd32015-12-10 02:39:40 -0800230 // send CSRCs
231 std::vector<uint32_t> csrcs_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000232
danilchap162abd32015-12-10 02:39:40 -0800233 // Full intra request
234 uint8_t sequence_number_fir_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000235
danilchap162abd32015-12-10 02:39:40 -0800236 // REMB
237 uint32_t remb_bitrate_ GUARDED_BY(critical_section_rtcp_sender_);
238 std::vector<uint32_t> remb_ssrcs_ GUARDED_BY(critical_section_rtcp_sender_);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000239
danilchap6eaa3a42016-05-09 10:59:50 -0700240 std::vector<rtcp::TmmbItem> tmmbn_to_send_
241 GUARDED_BY(critical_section_rtcp_sender_);
danilchap2b616392016-08-18 06:17:42 -0700242 uint32_t tmmbr_send_bps_ GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800243 uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_);
danilchap41befce2016-03-30 11:11:51 -0700244 size_t max_payload_length_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000245
danilchap162abd32015-12-10 02:39:40 -0800246 // APP
247 uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_);
248 uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700249 std::unique_ptr<uint8_t[]> app_data_
danilchap162abd32015-12-10 02:39:40 -0800250 GUARDED_BY(critical_section_rtcp_sender_);
251 uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000252
danilchap162abd32015-12-10 02:39:40 -0800253 // True if sending of XR Receiver reference time report is enabled.
254 bool xr_send_receiver_reference_time_enabled_
255 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000256
danilchap162abd32015-12-10 02:39:40 -0800257 // XR VoIP metric
sprang5e38c962016-12-01 05:18:09 -0800258 rtc::Optional<RTCPVoIPMetric> xr_voip_metric_
259 GUARDED_BY(critical_section_rtcp_sender_);
edjee@google.com79b02892013-04-04 19:43:34 +0000260
danilchap162abd32015-12-10 02:39:40 -0800261 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
262 RtcpPacketTypeCounter packet_type_counter_
263 GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000264
danilchap162abd32015-12-10 02:39:40 -0800265 RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200266
sprang5e38c962016-12-01 05:18:09 -0800267 rtc::Optional<BitrateAllocation> video_bitrate_allocation_
268 GUARDED_BY(critical_section_rtcp_sender_);
269
270 void SetFlag(uint32_t type, bool is_volatile)
danilchap162abd32015-12-10 02:39:40 -0800271 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
272 void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile)
273 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800274 bool IsFlagPresent(uint32_t type) const
danilchap162abd32015-12-10 02:39:40 -0800275 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800276 bool ConsumeFlag(uint32_t type, bool forced = false)
danilchap162abd32015-12-10 02:39:40 -0800277 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
278 bool AllVolatileFlagsConsumed() const
279 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
280 struct ReportFlag {
sprang5e38c962016-12-01 05:18:09 -0800281 ReportFlag(uint32_t type, bool is_volatile)
danilchap162abd32015-12-10 02:39:40 -0800282 : type(type), is_volatile(is_volatile) {}
283 bool operator<(const ReportFlag& flag) const { return type < flag.type; }
284 bool operator==(const ReportFlag& flag) const { return type == flag.type; }
sprang5e38c962016-12-01 05:18:09 -0800285 const uint32_t type;
danilchap162abd32015-12-10 02:39:40 -0800286 const bool is_volatile;
287 };
Erik Språng242e22b2015-05-11 10:17:43 +0200288
danilchap162abd32015-12-10 02:39:40 -0800289 std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200290
danilchap56036ff2016-03-22 11:14:09 -0700291 typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)(
danilchap162abd32015-12-10 02:39:40 -0800292 const RtcpContext&);
sprang5e38c962016-12-01 05:18:09 -0800293 // Map from RTCPPacketType to builder.
294 std::map<uint32_t, BuilderFunc> builders_;
terelius429c3452016-01-21 05:42:04 -0800295
296 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender);
niklase@google.com470e71d2011-07-07 08:21:25 +0000297};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000298} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000299
danilchap162abd32015-12-10 02:39:40 -0800300#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_