blob: 134a6fb2e9a6e578378bd7b8d54c0105de03573e [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_
12#define MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "api/call/transport.h"
22#include "api/optional.h"
23#include "modules/remote_bitrate_estimator/include/bwe_defines.h"
24#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
25#include "modules/rtp_rtcp/include/receive_statistics.h"
26#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
27#include "modules/rtp_rtcp/source/rtcp_nack_stats.h"
28#include "modules/rtp_rtcp/source/rtcp_packet.h"
29#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
30#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
31#include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
32#include "rtc_base/constructormagic.h"
33#include "rtc_base/criticalsection.h"
34#include "rtc_base/random.h"
35#include "rtc_base/thread_annotations.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020036#include "typedefs.h" // NOLINT(build/include)
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;
terelius429c3452016-01-21 05:42:04 -080041class RtcEventLog;
pwestin@webrtc.org741da942011-09-20 13:52:04 +000042
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000043class NACKStringBuilder {
44 public:
45 NACKStringBuilder();
46 ~NACKStringBuilder();
pbos@webrtc.orgf3e4cee2013-07-31 15:17:19 +000047
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000048 void PushNACK(uint16_t nack);
49 std::string GetResult();
edjee@google.com79b02892013-04-04 19:43:34 +000050
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000051 private:
Erik Språng242e22b2015-05-11 10:17:43 +020052 std::ostringstream stream_;
53 int count_;
54 uint16_t prevNack_;
55 bool consecutive_;
edjee@google.com79b02892013-04-04 19:43:34 +000056};
57
asapersson@webrtc.org9ffd8fe2015-01-21 08:22:50 +000058class RTCPSender {
danilchap162abd32015-12-10 02:39:40 -080059 public:
60 struct FeedbackState {
61 FeedbackState();
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000062
danilchap162abd32015-12-10 02:39:40 -080063 uint32_t packets_sent;
64 size_t media_bytes_sent;
65 uint32_t send_bitrate;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000066
danilchap162abd32015-12-10 02:39:40 -080067 uint32_t last_rr_ntp_secs;
68 uint32_t last_rr_ntp_frac;
69 uint32_t remote_sr;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000070
danilchap162abd32015-12-10 02:39:40 -080071 bool has_last_xr_rr;
danilchap798896a2016-09-28 02:54:25 -070072 rtcp::ReceiveTimeInfo last_xr_rr;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +000073
danilchap162abd32015-12-10 02:39:40 -080074 // Used when generating TMMBR.
75 ModuleRtpRtcpImpl* module;
76 };
Erik Språng61be2a42015-04-27 13:32:52 +020077
danilchap162abd32015-12-10 02:39:40 -080078 RTCPSender(bool audio,
79 Clock* clock,
danilchapf5f793c2017-07-27 04:44:18 -070080 ReceiveStatisticsProvider* receive_statistics,
danilchap162abd32015-12-10 02:39:40 -080081 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
terelius429c3452016-01-21 05:42:04 -080082 RtcEventLog* event_log,
Jiawei Ou3587b832018-01-31 22:08:26 -080083 Transport* outgoing_transport,
84 RtcpIntervalConfig interval_config);
danilchap162abd32015-12-10 02:39:40 -080085 virtual ~RTCPSender();
niklase@google.com470e71d2011-07-07 08:21:25 +000086
danilchap162abd32015-12-10 02:39:40 -080087 RtcpMode Status() const;
88 void SetRTCPStatus(RtcpMode method);
niklase@google.com470e71d2011-07-07 08:21:25 +000089
danilchap162abd32015-12-10 02:39:40 -080090 bool Sending() const;
91 int32_t SetSendingStatus(const FeedbackState& feedback_state,
92 bool enabled); // combine the functions
niklase@google.com470e71d2011-07-07 08:21:25 +000093
danilchap162abd32015-12-10 02:39:40 -080094 int32_t SetNackStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000095
danilchap71fead22016-08-18 02:01:49 -070096 void SetTimestampOffset(uint32_t timestamp_offset);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000097
danilchap162abd32015-12-10 02:39:40 -080098 void SetLastRtpTime(uint32_t rtp_timestamp, int64_t capture_time_ms);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000099
nisse14adba72017-03-20 03:52:39 -0700100 uint32_t SSRC() const;
101
danilchap162abd32015-12-10 02:39:40 -0800102 void SetSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
danilchap162abd32015-12-10 02:39:40 -0800104 void SetRemoteSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
danilchap162abd32015-12-10 02:39:40 -0800106 int32_t SetCNAME(const char* cName);
niklase@google.com470e71d2011-07-07 08:21:25 +0000107
danilchap162abd32015-12-10 02:39:40 -0800108 int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name);
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
danilchap162abd32015-12-10 02:39:40 -0800110 int32_t RemoveMixedCNAME(uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
danilchap162abd32015-12-10 02:39:40 -0800112 bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
danilchap162abd32015-12-10 02:39:40 -0800114 int32_t SendRTCP(const FeedbackState& feedback_state,
115 RTCPPacketType packetType,
116 int32_t nackSize = 0,
nissecd386eb2017-03-14 08:54:43 -0700117 const uint16_t* nackList = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000118
danilchap162abd32015-12-10 02:39:40 -0800119 int32_t SendCompoundRTCP(const FeedbackState& feedback_state,
120 const std::set<RTCPPacketType>& packetTypes,
121 int32_t nackSize = 0,
nissecd386eb2017-03-14 08:54:43 -0700122 const uint16_t* nackList = 0);
Erik Språng242e22b2015-05-11 10:17:43 +0200123
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100124 void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000125
Danil Chapovalovf74d6412017-10-18 13:32:57 +0200126 void UnsetRemb();
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000127
danilchap162abd32015-12-10 02:39:40 -0800128 bool TMMBR() const;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000129
danilchap162abd32015-12-10 02:39:40 -0800130 void SetTMMBRStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000131
nisse284542b2017-01-10 08:58:32 -0800132 void SetMaxRtpPacketSize(size_t max_packet_size);
danilchap41befce2016-03-30 11:11:51 -0700133
danilchap853ecb22016-08-22 08:26:15 -0700134 void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set);
niklase@google.com470e71d2011-07-07 08:21:25 +0000135
danilchap162abd32015-12-10 02:39:40 -0800136 int32_t SetApplicationSpecificData(uint8_t subType,
137 uint32_t name,
138 const uint8_t* data,
139 uint16_t length);
140 int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric);
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000141
danilchap162abd32015-12-10 02:39:40 -0800142 void SendRtcpXrReceiverReferenceTime(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000143
danilchap162abd32015-12-10 02:39:40 -0800144 bool RtcpXrReceiverReferenceTime() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000145
danilchap162abd32015-12-10 02:39:40 -0800146 void SetCsrcs(const std::vector<uint32_t>& csrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000147
danilchap162abd32015-12-10 02:39:40 -0800148 void SetTargetBitrate(unsigned int target_bitrate);
sprang5e38c962016-12-01 05:18:09 -0800149 void SetVideoBitrateAllocation(const BitrateAllocation& bitrate);
danilchap162abd32015-12-10 02:39:40 -0800150 bool SendFeedbackPacket(const rtcp::TransportFeedback& packet);
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000151
Jiawei Ou3587b832018-01-31 22:08:26 -0800152 int64_t RtcpAudioReportInverval() const;
153 int64_t RtcpVideoReportInverval() const;
154
danilchap162abd32015-12-10 02:39:40 -0800155 private:
156 class RtcpContext;
Erik Språng242e22b2015-05-11 10:17:43 +0200157
danilchap162abd32015-12-10 02:39:40 -0800158 // Determine which RTCP messages should be sent and setup flags.
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200159 void PrepareReport(const FeedbackState& feedback_state)
danilchap56359be2017-09-07 07:53:45 -0700160 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000161
danilchap96b69bd2017-07-25 09:15:14 -0700162 std::vector<rtcp::ReportBlock> CreateReportBlocks(
163 const FeedbackState& feedback_state)
danilchap56359be2017-09-07 07:53:45 -0700164 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000165
danilchap56036ff2016-03-22 11:14:09 -0700166 std::unique_ptr<rtcp::RtcpPacket> BuildSR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700167 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700168 std::unique_ptr<rtcp::RtcpPacket> BuildRR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700169 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700170 std::unique_ptr<rtcp::RtcpPacket> BuildSDES(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700171 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700172 std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700173 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700174 std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700175 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700176 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700177 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700178 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700179 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700180 std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700181 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800182 std::unique_ptr<rtcp::RtcpPacket> BuildExtendedReports(
183 const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700184 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700185 std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700186 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700187 std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700188 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700189 std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700190 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000191
danilchap162abd32015-12-10 02:39:40 -0800192 private:
193 const bool audio_;
194 Clock* const clock_;
danilchap56359be2017-09-07 07:53:45 -0700195 Random random_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
196 RtcpMode method_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000197
terelius429c3452016-01-21 05:42:04 -0800198 RtcEventLog* const event_log_;
danilchap162abd32015-12-10 02:39:40 -0800199 Transport* const transport_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000200
Jiawei Ou3587b832018-01-31 22:08:26 -0800201 const RtcpIntervalConfig interval_config_;
202
danilchap56036ff2016-03-22 11:14:09 -0700203 rtc::CriticalSection critical_section_rtcp_sender_;
danilchap56359be2017-09-07 07:53:45 -0700204 bool using_nack_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
205 bool sending_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000206
danilchap56359be2017-09-07 07:53:45 -0700207 int64_t next_time_to_send_rtcp_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000208
danilchap56359be2017-09-07 07:53:45 -0700209 uint32_t timestamp_offset_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
210 uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
211 int64_t last_frame_capture_time_ms_
212 RTC_GUARDED_BY(critical_section_rtcp_sender_);
213 uint32_t ssrc_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800214 // SSRC that we receive on our RTP channel
danilchap56359be2017-09-07 07:53:45 -0700215 uint32_t remote_ssrc_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
216 std::string cname_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000217
danilchapf5f793c2017-07-27 04:44:18 -0700218 ReceiveStatisticsProvider* receive_statistics_
danilchap56359be2017-09-07 07:53:45 -0700219 RTC_GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800220 std::map<uint32_t, std::string> csrc_cnames_
danilchap56359be2017-09-07 07:53:45 -0700221 RTC_GUARDED_BY(critical_section_rtcp_sender_);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000222
danilchap162abd32015-12-10 02:39:40 -0800223 // send CSRCs
danilchap56359be2017-09-07 07:53:45 -0700224 std::vector<uint32_t> csrcs_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000225
danilchap162abd32015-12-10 02:39:40 -0800226 // Full intra request
danilchap56359be2017-09-07 07:53:45 -0700227 uint8_t sequence_number_fir_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000228
danilchap162abd32015-12-10 02:39:40 -0800229 // REMB
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100230 int64_t remb_bitrate_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
danilchap56359be2017-09-07 07:53:45 -0700231 std::vector<uint32_t> remb_ssrcs_
232 RTC_GUARDED_BY(critical_section_rtcp_sender_);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000233
danilchap6eaa3a42016-05-09 10:59:50 -0700234 std::vector<rtcp::TmmbItem> tmmbn_to_send_
danilchap56359be2017-09-07 07:53:45 -0700235 RTC_GUARDED_BY(critical_section_rtcp_sender_);
236 uint32_t tmmbr_send_bps_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
237 uint32_t packet_oh_send_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
238 size_t max_packet_size_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000239
danilchap162abd32015-12-10 02:39:40 -0800240 // APP
danilchap56359be2017-09-07 07:53:45 -0700241 uint8_t app_sub_type_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
242 uint32_t app_name_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700243 std::unique_ptr<uint8_t[]> app_data_
danilchap56359be2017-09-07 07:53:45 -0700244 RTC_GUARDED_BY(critical_section_rtcp_sender_);
245 uint16_t app_length_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000246
danilchap162abd32015-12-10 02:39:40 -0800247 // True if sending of XR Receiver reference time report is enabled.
248 bool xr_send_receiver_reference_time_enabled_
danilchap56359be2017-09-07 07:53:45 -0700249 RTC_GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000250
danilchap162abd32015-12-10 02:39:40 -0800251 // XR VoIP metric
sprang5e38c962016-12-01 05:18:09 -0800252 rtc::Optional<RTCPVoIPMetric> xr_voip_metric_
danilchap56359be2017-09-07 07:53:45 -0700253 RTC_GUARDED_BY(critical_section_rtcp_sender_);
edjee@google.com79b02892013-04-04 19:43:34 +0000254
danilchap162abd32015-12-10 02:39:40 -0800255 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
256 RtcpPacketTypeCounter packet_type_counter_
danilchap56359be2017-09-07 07:53:45 -0700257 RTC_GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000258
danilchap56359be2017-09-07 07:53:45 -0700259 RtcpNackStats nack_stats_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200260
sprang5e38c962016-12-01 05:18:09 -0800261 rtc::Optional<BitrateAllocation> video_bitrate_allocation_
danilchap56359be2017-09-07 07:53:45 -0700262 RTC_GUARDED_BY(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800263
264 void SetFlag(uint32_t type, bool is_volatile)
danilchap56359be2017-09-07 07:53:45 -0700265 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800266 void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile)
danilchap56359be2017-09-07 07:53:45 -0700267 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800268 bool IsFlagPresent(uint32_t type) const
danilchap56359be2017-09-07 07:53:45 -0700269 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800270 bool ConsumeFlag(uint32_t type, bool forced = false)
danilchap56359be2017-09-07 07:53:45 -0700271 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800272 bool AllVolatileFlagsConsumed() const
danilchap56359be2017-09-07 07:53:45 -0700273 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800274 struct ReportFlag {
sprang5e38c962016-12-01 05:18:09 -0800275 ReportFlag(uint32_t type, bool is_volatile)
danilchap162abd32015-12-10 02:39:40 -0800276 : type(type), is_volatile(is_volatile) {}
277 bool operator<(const ReportFlag& flag) const { return type < flag.type; }
278 bool operator==(const ReportFlag& flag) const { return type == flag.type; }
sprang5e38c962016-12-01 05:18:09 -0800279 const uint32_t type;
danilchap162abd32015-12-10 02:39:40 -0800280 const bool is_volatile;
281 };
Erik Språng242e22b2015-05-11 10:17:43 +0200282
danilchap56359be2017-09-07 07:53:45 -0700283 std::set<ReportFlag> report_flags_
284 RTC_GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200285
danilchap56036ff2016-03-22 11:14:09 -0700286 typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)(
danilchap162abd32015-12-10 02:39:40 -0800287 const RtcpContext&);
sprang5e38c962016-12-01 05:18:09 -0800288 // Map from RTCPPacketType to builder.
289 std::map<uint32_t, BuilderFunc> builders_;
terelius429c3452016-01-21 05:42:04 -0800290
291 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender);
niklase@google.com470e71d2011-07-07 08:21:25 +0000292};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000293} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000294
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200295#endif // MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_