blob: 32c1e1dbc1085d826f1f2c8df9bb12270b757f0b [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 <string>
danilchapb8b6fbb2015-12-10 05:05:27 -080018#include <vector>
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +000019
Danil Chapovalovd264df52018-06-14 12:59:38 +020020#include "absl/types/optional.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "api/call/transport.h"
Erik Språngeeaa8f92018-05-17 12:35:56 +020022#include "api/video/video_bitrate_allocation.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#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"
Mirko Bonadei9b1f24d2019-07-12 17:32:28 +000026#include "modules/rtp_rtcp/include/rtp_rtcp.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
28#include "modules/rtp_rtcp/source/rtcp_nack_stats.h"
29#include "modules/rtp_rtcp/source/rtcp_packet.h"
30#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
31#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
32#include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
Steve Anton10542f22019-01-11 09:11:00 -080033#include "rtc_base/constructor_magic.h"
34#include "rtc_base/critical_section.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020035#include "rtc_base/random.h"
36#include "rtc_base/thread_annotations.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;
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 RTCPSender {
danilchap162abd32015-12-10 02:39:40 -080044 public:
45 struct FeedbackState {
46 FeedbackState();
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +020047 FeedbackState(const FeedbackState&);
48 FeedbackState(FeedbackState&&);
49
50 ~FeedbackState();
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000051
danilchap162abd32015-12-10 02:39:40 -080052 uint32_t packets_sent;
53 size_t media_bytes_sent;
54 uint32_t send_bitrate;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000055
danilchap162abd32015-12-10 02:39:40 -080056 uint32_t last_rr_ntp_secs;
57 uint32_t last_rr_ntp_frac;
58 uint32_t remote_sr;
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000059
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +020060 std::vector<rtcp::ReceiveTimeInfo> last_xr_rtis;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +000061
danilchap162abd32015-12-10 02:39:40 -080062 // Used when generating TMMBR.
63 ModuleRtpRtcpImpl* module;
64 };
Erik Språng61be2a42015-04-27 13:32:52 +020065
Mirko Bonadei9b1f24d2019-07-12 17:32:28 +000066 explicit RTCPSender(const RtpRtcp::Configuration& config);
danilchap162abd32015-12-10 02:39:40 -080067 virtual ~RTCPSender();
niklase@google.com470e71d2011-07-07 08:21:25 +000068
danilchap162abd32015-12-10 02:39:40 -080069 RtcpMode Status() const;
70 void SetRTCPStatus(RtcpMode method);
niklase@google.com470e71d2011-07-07 08:21:25 +000071
danilchap162abd32015-12-10 02:39:40 -080072 bool Sending() const;
73 int32_t SetSendingStatus(const FeedbackState& feedback_state,
74 bool enabled); // combine the functions
niklase@google.com470e71d2011-07-07 08:21:25 +000075
danilchap162abd32015-12-10 02:39:40 -080076 int32_t SetNackStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000077
danilchap71fead22016-08-18 02:01:49 -070078 void SetTimestampOffset(uint32_t timestamp_offset);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000079
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +020080 // TODO(bugs.webrtc.org/6458): Remove default parameter value when all the
81 // depending projects are updated to correctly set payload type.
82 void SetLastRtpTime(uint32_t rtp_timestamp,
83 int64_t capture_time_ms,
84 int8_t payload_type = -1);
85
86 void SetRtpClockRate(int8_t payload_type, int rtp_clock_rate_hz);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000087
Erik Språng6841d252019-10-15 14:29:11 +020088 uint32_t SSRC() const { return ssrc_; }
niklase@google.com470e71d2011-07-07 08:21:25 +000089
danilchap162abd32015-12-10 02:39:40 -080090 void SetRemoteSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +000091
danilchap162abd32015-12-10 02:39:40 -080092 int32_t SetCNAME(const char* cName);
niklase@google.com470e71d2011-07-07 08:21:25 +000093
danilchap162abd32015-12-10 02:39:40 -080094 int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name);
niklase@google.com470e71d2011-07-07 08:21:25 +000095
danilchap162abd32015-12-10 02:39:40 -080096 int32_t RemoveMixedCNAME(uint32_t SSRC);
niklase@google.com470e71d2011-07-07 08:21:25 +000097
danilchap162abd32015-12-10 02:39:40 -080098 bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000099
danilchap162abd32015-12-10 02:39:40 -0800100 int32_t SendRTCP(const FeedbackState& feedback_state,
101 RTCPPacketType packetType,
102 int32_t nackSize = 0,
nissecd386eb2017-03-14 08:54:43 -0700103 const uint16_t* nackList = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
danilchap162abd32015-12-10 02:39:40 -0800105 int32_t SendCompoundRTCP(const FeedbackState& feedback_state,
106 const std::set<RTCPPacketType>& packetTypes,
107 int32_t nackSize = 0,
nissecd386eb2017-03-14 08:54:43 -0700108 const uint16_t* nackList = 0);
Erik Språng242e22b2015-05-11 10:17:43 +0200109
Elad Alon7d6a4c02019-02-25 13:00:51 +0100110 int32_t SendLossNotification(const FeedbackState& feedback_state,
111 uint16_t last_decoded_seq_num,
112 uint16_t last_received_seq_num,
Elad Alone86af2c2019-06-03 14:37:50 +0200113 bool decodability_flag,
114 bool buffering_allowed);
Elad Alon7d6a4c02019-02-25 13:00:51 +0100115
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100116 void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
Danil Chapovalovf74d6412017-10-18 13:32:57 +0200118 void UnsetRemb();
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000119
danilchap162abd32015-12-10 02:39:40 -0800120 bool TMMBR() const;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000121
danilchap162abd32015-12-10 02:39:40 -0800122 void SetTMMBRStatus(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000123
nisse284542b2017-01-10 08:58:32 -0800124 void SetMaxRtpPacketSize(size_t max_packet_size);
danilchap41befce2016-03-30 11:11:51 -0700125
danilchap853ecb22016-08-22 08:26:15 -0700126 void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set);
niklase@google.com470e71d2011-07-07 08:21:25 +0000127
danilchap162abd32015-12-10 02:39:40 -0800128 int32_t SetApplicationSpecificData(uint8_t subType,
129 uint32_t name,
130 const uint8_t* data,
131 uint16_t length);
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000132
danilchap162abd32015-12-10 02:39:40 -0800133 void SendRtcpXrReceiverReferenceTime(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +0000134
danilchap162abd32015-12-10 02:39:40 -0800135 bool RtcpXrReceiverReferenceTime() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
danilchap162abd32015-12-10 02:39:40 -0800137 void SetCsrcs(const std::vector<uint32_t>& csrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000138
danilchap162abd32015-12-10 02:39:40 -0800139 void SetTargetBitrate(unsigned int target_bitrate);
Erik Språng566124a2018-04-23 12:32:22 +0200140 void SetVideoBitrateAllocation(const VideoBitrateAllocation& bitrate);
Per Kjellander16999812019-10-10 12:57:28 +0200141 void SendCombinedRtcpPacket(
142 std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets);
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000143
danilchap162abd32015-12-10 02:39:40 -0800144 private:
145 class RtcpContext;
Erik Språng242e22b2015-05-11 10:17:43 +0200146
danilchap162abd32015-12-10 02:39:40 -0800147 // Determine which RTCP messages should be sent and setup flags.
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200148 void PrepareReport(const FeedbackState& feedback_state)
danilchap56359be2017-09-07 07:53:45 -0700149 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000150
danilchap96b69bd2017-07-25 09:15:14 -0700151 std::vector<rtcp::ReportBlock> CreateReportBlocks(
152 const FeedbackState& feedback_state)
danilchap56359be2017-09-07 07:53:45 -0700153 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000154
danilchap56036ff2016-03-22 11:14:09 -0700155 std::unique_ptr<rtcp::RtcpPacket> BuildSR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700156 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700157 std::unique_ptr<rtcp::RtcpPacket> BuildRR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700158 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700159 std::unique_ptr<rtcp::RtcpPacket> BuildSDES(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700160 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700161 std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700162 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700163 std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700164 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700165 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700166 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700167 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700168 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700169 std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700170 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
Elad Alon7d6a4c02019-02-25 13:00:51 +0100171 std::unique_ptr<rtcp::RtcpPacket> BuildLossNotification(
172 const RtcpContext& context)
173 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800174 std::unique_ptr<rtcp::RtcpPacket> BuildExtendedReports(
175 const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700176 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700177 std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700178 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700179 std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700180 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap56036ff2016-03-22 11:14:09 -0700181 std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context)
danilchap56359be2017-09-07 07:53:45 -0700182 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000183
danilchap162abd32015-12-10 02:39:40 -0800184 private:
185 const bool audio_;
Erik Språng6841d252019-10-15 14:29:11 +0200186 const uint32_t ssrc_;
danilchap162abd32015-12-10 02:39:40 -0800187 Clock* const clock_;
danilchap56359be2017-09-07 07:53:45 -0700188 Random random_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
189 RtcpMode method_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000190
terelius429c3452016-01-21 05:42:04 -0800191 RtcEventLog* const event_log_;
danilchap162abd32015-12-10 02:39:40 -0800192 Transport* const transport_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000193
Jiawei Ou8b5d9d82018-11-15 16:44:37 -0800194 const int report_interval_ms_;
Jiawei Ou3587b832018-01-31 22:08:26 -0800195
danilchap56036ff2016-03-22 11:14:09 -0700196 rtc::CriticalSection critical_section_rtcp_sender_;
danilchap56359be2017-09-07 07:53:45 -0700197 bool sending_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000198
danilchap56359be2017-09-07 07:53:45 -0700199 int64_t next_time_to_send_rtcp_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000200
danilchap56359be2017-09-07 07:53:45 -0700201 uint32_t timestamp_offset_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
202 uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
203 int64_t last_frame_capture_time_ms_
204 RTC_GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800205 // SSRC that we receive on our RTP channel
danilchap56359be2017-09-07 07:53:45 -0700206 uint32_t remote_ssrc_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
207 std::string cname_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000208
danilchapf5f793c2017-07-27 04:44:18 -0700209 ReceiveStatisticsProvider* receive_statistics_
danilchap56359be2017-09-07 07:53:45 -0700210 RTC_GUARDED_BY(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800211 std::map<uint32_t, std::string> csrc_cnames_
danilchap56359be2017-09-07 07:53:45 -0700212 RTC_GUARDED_BY(critical_section_rtcp_sender_);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000213
danilchap162abd32015-12-10 02:39:40 -0800214 // send CSRCs
danilchap56359be2017-09-07 07:53:45 -0700215 std::vector<uint32_t> csrcs_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000216
danilchap162abd32015-12-10 02:39:40 -0800217 // Full intra request
danilchap56359be2017-09-07 07:53:45 -0700218 uint8_t sequence_number_fir_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000219
Elad Alon7d6a4c02019-02-25 13:00:51 +0100220 // Loss Notification
221 struct LossNotificationState {
222 uint16_t last_decoded_seq_num;
223 uint16_t last_received_seq_num;
224 bool decodability_flag;
225 };
226 LossNotificationState loss_notification_state_
227 RTC_GUARDED_BY(critical_section_rtcp_sender_);
228
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 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_;
252 RtcpPacketTypeCounter packet_type_counter_
danilchap56359be2017-09-07 07:53:45 -0700253 RTC_GUARDED_BY(critical_section_rtcp_sender_);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000254
danilchap56359be2017-09-07 07:53:45 -0700255 RtcpNackStats nack_stats_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200256
Erik Språng8782a582018-10-04 15:36:06 +0200257 VideoBitrateAllocation video_bitrate_allocation_
danilchap56359be2017-09-07 07:53:45 -0700258 RTC_GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng8782a582018-10-04 15:36:06 +0200259 bool send_video_bitrate_allocation_
260 RTC_GUARDED_BY(critical_section_rtcp_sender_);
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +0200261
262 std::map<int8_t, int> rtp_clock_rates_khz_
263 RTC_GUARDED_BY(critical_section_rtcp_sender_);
264 int8_t last_payload_type_ RTC_GUARDED_BY(critical_section_rtcp_sender_);
265
Erik Språng1cd73912018-10-05 12:57:59 +0200266 absl::optional<VideoBitrateAllocation> CheckAndUpdateLayerStructure(
267 const VideoBitrateAllocation& bitrate) const
Erik Språng8782a582018-10-04 15:36:06 +0200268 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800269
270 void SetFlag(uint32_t type, bool is_volatile)
danilchap56359be2017-09-07 07:53:45 -0700271 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800272 void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile)
danilchap56359be2017-09-07 07:53:45 -0700273 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800274 bool IsFlagPresent(uint32_t type) const
danilchap56359be2017-09-07 07:53:45 -0700275 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800276 bool ConsumeFlag(uint32_t type, bool forced = false)
danilchap56359be2017-09-07 07:53:45 -0700277 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800278 bool AllVolatileFlagsConsumed() const
danilchap56359be2017-09-07 07:53:45 -0700279 RTC_EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_);
danilchap162abd32015-12-10 02:39:40 -0800280 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
danilchap56359be2017-09-07 07:53:45 -0700289 std::set<ReportFlag> report_flags_
290 RTC_GUARDED_BY(critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200291
danilchap56036ff2016-03-22 11:14:09 -0700292 typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)(
danilchap162abd32015-12-10 02:39:40 -0800293 const RtcpContext&);
sprang5e38c962016-12-01 05:18:09 -0800294 // Map from RTCPPacketType to builder.
295 std::map<uint32_t, BuilderFunc> builders_;
terelius429c3452016-01-21 05:42:04 -0800296
297 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender);
niklase@google.com470e71d2011-07-07 08:21:25 +0000298};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000299} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000300
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200301#endif // MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_