blob: 6b266cb66e317838629d5a54b8837889ee65833e [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#include "modules/rtp_rtcp/source/rtcp_sender.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
stefan@webrtc.org9354cc92012-06-07 08:10:14 +000013#include <string.h> // memcpy
niklase@google.com470e71d2011-07-07 08:21:25 +000014
Danil Chapovalov70ffead2016-07-20 15:26:59 +020015#include <utility>
16
Mirko Bonadei71207422017-09-15 13:58:09 +020017#include "common_types.h" // NOLINT(build/include)
Elad Alon4a87e1c2017-10-03 16:11:34 +020018#include "logging/rtc_event_log/events/rtc_event_rtcp_packet_outgoing.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "logging/rtc_event_log/rtc_event_log.h"
20#include "modules/rtp_rtcp/source/rtcp_packet/app.h"
21#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
22#include "modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
23#include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
24#include "modules/rtp_rtcp/source/rtcp_packet/fir.h"
25#include "modules/rtp_rtcp/source/rtcp_packet/nack.h"
26#include "modules/rtp_rtcp/source/rtcp_packet/pli.h"
27#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
28#include "modules/rtp_rtcp/source/rtcp_packet/remb.h"
29#include "modules/rtp_rtcp/source/rtcp_packet/sdes.h"
30#include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
31#include "modules/rtp_rtcp/source/rtcp_packet/tmmbn.h"
32#include "modules/rtp_rtcp/source/rtcp_packet/tmmbr.h"
33#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
34#include "modules/rtp_rtcp/source/rtp_rtcp_impl.h"
35#include "modules/rtp_rtcp/source/time_util.h"
36#include "modules/rtp_rtcp/source/tmmbr_help.h"
37#include "rtc_base/checks.h"
38#include "rtc_base/constructormagic.h"
39#include "rtc_base/logging.h"
Jiawei Ou3587b832018-01-31 22:08:26 -080040#include "rtc_base/numerics/safe_conversions.h"
Elad Alon4a87e1c2017-10-03 16:11:34 +020041#include "rtc_base/ptr_util.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020042#include "rtc_base/trace_event.h"
pwestin@webrtc.org741da942011-09-20 13:52:04 +000043
niklase@google.com470e71d2011-07-07 08:21:25 +000044namespace webrtc {
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +000045
sprang5e38c962016-12-01 05:18:09 -080046namespace {
47const uint32_t kRtcpAnyExtendedReports =
48 kRtcpXrVoipMetric | kRtcpXrReceiverReferenceTime | kRtcpXrDlrrReportBlock |
49 kRtcpXrTargetBitrate;
50} // namespace
51
Erik Språng61be2a42015-04-27 13:32:52 +020052NACKStringBuilder::NACKStringBuilder()
danilchap162abd32015-12-10 02:39:40 -080053 : stream_(""), count_(0), prevNack_(0), consecutive_(false) {}
edjee@google.com79b02892013-04-04 19:43:34 +000054
pbos@webrtc.orgf3e4cee2013-07-31 15:17:19 +000055NACKStringBuilder::~NACKStringBuilder() {}
56
danilchap162abd32015-12-10 02:39:40 -080057void NACKStringBuilder::PushNACK(uint16_t nack) {
Erik Språng242e22b2015-05-11 10:17:43 +020058 if (count_ == 0) {
59 stream_ << nack;
60 } else if (nack == prevNack_ + 1) {
61 consecutive_ = true;
Erik Språng61be2a42015-04-27 13:32:52 +020062 } else {
Erik Språng242e22b2015-05-11 10:17:43 +020063 if (consecutive_) {
64 stream_ << "-" << prevNack_;
65 consecutive_ = false;
edjee@google.com79b02892013-04-04 19:43:34 +000066 }
Erik Språng242e22b2015-05-11 10:17:43 +020067 stream_ << "," << nack;
Erik Språng61be2a42015-04-27 13:32:52 +020068 }
Erik Språng242e22b2015-05-11 10:17:43 +020069 count_++;
70 prevNack_ = nack;
edjee@google.com79b02892013-04-04 19:43:34 +000071}
72
Erik Språng61be2a42015-04-27 13:32:52 +020073std::string NACKStringBuilder::GetResult() {
Erik Språng242e22b2015-05-11 10:17:43 +020074 if (consecutive_) {
75 stream_ << "-" << prevNack_;
76 consecutive_ = false;
Erik Språng61be2a42015-04-27 13:32:52 +020077 }
Erik Språng242e22b2015-05-11 10:17:43 +020078 return stream_.str();
edjee@google.com79b02892013-04-04 19:43:34 +000079}
80
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000081RTCPSender::FeedbackState::FeedbackState()
nisse40ba3ad2017-03-17 07:04:00 -070082 : packets_sent(0),
pbos@webrtc.org2f4b14e2014-07-15 15:25:39 +000083 media_bytes_sent(0),
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000084 send_bitrate(0),
85 last_rr_ntp_secs(0),
86 last_rr_ntp_frac(0),
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +000087 remote_sr(0),
danilchap162abd32015-12-10 02:39:40 -080088 module(nullptr) {}
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000089
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +020090RTCPSender::FeedbackState::FeedbackState(const FeedbackState&) = default;
91
92RTCPSender::FeedbackState::FeedbackState(FeedbackState&&) = default;
93
94RTCPSender::FeedbackState::~FeedbackState() = default;
95
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010096class PacketContainer : public rtcp::CompoundPacket {
Erik Språngf7c57762015-12-04 10:40:35 +010097 public:
terelius429c3452016-01-21 05:42:04 -080098 PacketContainer(Transport* transport, RtcEventLog* event_log)
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010099 : transport_(transport), event_log_(event_log) {}
Danil Chapovalov2a5ce2b2018-02-07 09:38:31 +0100100 ~PacketContainer() override {
Erik Språngf7c57762015-12-04 10:40:35 +0100101 for (RtcpPacket* packet : appended_packets_)
102 delete packet;
103 }
104
danilchap41befce2016-03-30 11:11:51 -0700105 size_t SendPackets(size_t max_payload_length) {
Danil Chapovalov5c3cc412017-12-07 10:15:53 +0100106 size_t bytes_sent = 0;
107 Build(max_payload_length, [&](rtc::ArrayView<const uint8_t> packet) {
108 if (transport_->SendRtcp(packet.data(), packet.size())) {
109 bytes_sent += packet.size();
110 if (event_log_) {
111 event_log_->Log(rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(packet));
112 }
113 }
114 });
115 return bytes_sent;
Erik Språngf7c57762015-12-04 10:40:35 +0100116 }
117
118 private:
119 Transport* transport_;
terelius429c3452016-01-21 05:42:04 -0800120 RtcEventLog* const event_log_;
terelius429c3452016-01-21 05:42:04 -0800121
122 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer);
Erik Språngf7c57762015-12-04 10:40:35 +0100123};
124
125class RTCPSender::RtcpContext {
126 public:
Erik Språng242e22b2015-05-11 10:17:43 +0200127 RtcpContext(const FeedbackState& feedback_state,
128 int32_t nack_size,
129 const uint16_t* nack_list,
danilchap51813b32016-12-16 02:44:36 -0800130 NtpTime now)
Erik Språngf7c57762015-12-04 10:40:35 +0100131 : feedback_state_(feedback_state),
132 nack_size_(nack_size),
133 nack_list_(nack_list),
danilchap51813b32016-12-16 02:44:36 -0800134 now_(now) {}
Erik Språng242e22b2015-05-11 10:17:43 +0200135
Erik Språngf7c57762015-12-04 10:40:35 +0100136 const FeedbackState& feedback_state_;
137 const int32_t nack_size_;
138 const uint16_t* nack_list_;
danilchap51813b32016-12-16 02:44:36 -0800139 const NtpTime now_;
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200140};
141
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000142RTCPSender::RTCPSender(
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000143 bool audio,
144 Clock* clock,
danilchapf5f793c2017-07-27 04:44:18 -0700145 ReceiveStatisticsProvider* receive_statistics,
sprang86fd9ed2015-09-29 04:45:43 -0700146 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
terelius429c3452016-01-21 05:42:04 -0800147 RtcEventLog* event_log,
Jiawei Ou3587b832018-01-31 22:08:26 -0800148 Transport* outgoing_transport,
149 RtcpIntervalConfig interval_config)
Peter Boströmac547a62015-09-17 23:03:57 +0200150 : audio_(audio),
Erik Språng242e22b2015-05-11 10:17:43 +0200151 clock_(clock),
danilchap47a740b2015-12-15 00:30:07 -0800152 random_(clock_->TimeInMicroseconds()),
pbosda903ea2015-10-02 02:36:56 -0700153 method_(RtcpMode::kOff),
terelius429c3452016-01-21 05:42:04 -0800154 event_log_(event_log),
sprang86fd9ed2015-09-29 04:45:43 -0700155 transport_(outgoing_transport),
Jiawei Ou3587b832018-01-31 22:08:26 -0800156 interval_config_(interval_config),
Erik Språng242e22b2015-05-11 10:17:43 +0200157 using_nack_(false),
158 sending_(false),
Erik Språng242e22b2015-05-11 10:17:43 +0200159 next_time_to_send_rtcp_(0),
danilchap71fead22016-08-18 02:01:49 -0700160 timestamp_offset_(0),
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000161 last_rtp_timestamp_(0),
162 last_frame_capture_time_ms_(-1),
Erik Språng242e22b2015-05-11 10:17:43 +0200163 ssrc_(0),
164 remote_ssrc_(0),
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000165 receive_statistics_(receive_statistics),
niklase@google.com470e71d2011-07-07 08:21:25 +0000166
Erik Språng242e22b2015-05-11 10:17:43 +0200167 sequence_number_fir_(0),
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000168
Erik Språng242e22b2015-05-11 10:17:43 +0200169 remb_bitrate_(0),
niklase@google.com470e71d2011-07-07 08:21:25 +0000170
danilchap2b616392016-08-18 06:17:42 -0700171 tmmbr_send_bps_(0),
Erik Språng242e22b2015-05-11 10:17:43 +0200172 packet_oh_send_(0),
nisse284542b2017-01-10 08:58:32 -0800173 max_packet_size_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000174
Erik Språng242e22b2015-05-11 10:17:43 +0200175 app_sub_type_(0),
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200176 app_name_(0),
Erik Språng242e22b2015-05-11 10:17:43 +0200177 app_data_(nullptr),
178 app_length_(0),
niklase@google.com470e71d2011-07-07 08:21:25 +0000179
Erik Språng242e22b2015-05-11 10:17:43 +0200180 xr_send_receiver_reference_time_enabled_(false),
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000181 packet_type_counter_observer_(packet_type_counter_observer) {
sprang86fd9ed2015-09-29 04:45:43 -0700182 RTC_DCHECK(transport_ != nullptr);
Erik Språng242e22b2015-05-11 10:17:43 +0200183
184 builders_[kRtcpSr] = &RTCPSender::BuildSR;
185 builders_[kRtcpRr] = &RTCPSender::BuildRR;
Erik Språng0ea42d32015-06-25 14:46:16 +0200186 builders_[kRtcpSdes] = &RTCPSender::BuildSDES;
Erik Språng242e22b2015-05-11 10:17:43 +0200187 builders_[kRtcpPli] = &RTCPSender::BuildPLI;
188 builders_[kRtcpFir] = &RTCPSender::BuildFIR;
Erik Språng242e22b2015-05-11 10:17:43 +0200189 builders_[kRtcpRemb] = &RTCPSender::BuildREMB;
190 builders_[kRtcpBye] = &RTCPSender::BuildBYE;
191 builders_[kRtcpApp] = &RTCPSender::BuildAPP;
192 builders_[kRtcpTmmbr] = &RTCPSender::BuildTMMBR;
193 builders_[kRtcpTmmbn] = &RTCPSender::BuildTMMBN;
194 builders_[kRtcpNack] = &RTCPSender::BuildNACK;
sprang5e38c962016-12-01 05:18:09 -0800195 builders_[kRtcpAnyExtendedReports] = &RTCPSender::BuildExtendedReports;
niklase@google.com470e71d2011-07-07 08:21:25 +0000196}
197
danilchap162abd32015-12-10 02:39:40 -0800198RTCPSender::~RTCPSender() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000199
pbosda903ea2015-10-02 02:36:56 -0700200RtcpMode RTCPSender::Status() const {
danilchap56036ff2016-03-22 11:14:09 -0700201 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200202 return method_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000203}
204
skvlad1c392cc2016-04-01 14:46:44 -0700205void RTCPSender::SetRTCPStatus(RtcpMode new_method) {
danilchap56036ff2016-03-22 11:14:09 -0700206 rtc::CritScope lock(&critical_section_rtcp_sender_);
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000207
skvlad1c392cc2016-04-01 14:46:44 -0700208 if (method_ == RtcpMode::kOff && new_method != RtcpMode::kOff) {
209 // When switching on, reschedule the next packet
Jiawei Ou3587b832018-01-31 22:08:26 -0800210 int64_t interval_ms = audio_ ? interval_config_.audio_interval_ms
211 : interval_config_.video_interval_ms;
212 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + (interval_ms / 2);
skvlad1c392cc2016-04-01 14:46:44 -0700213 }
214 method_ = new_method;
niklase@google.com470e71d2011-07-07 08:21:25 +0000215}
216
Erik Språng61be2a42015-04-27 13:32:52 +0200217bool RTCPSender::Sending() const {
danilchap56036ff2016-03-22 11:14:09 -0700218 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200219 return sending_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000220}
221
Erik Språng61be2a42015-04-27 13:32:52 +0200222int32_t RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
223 bool sending) {
224 bool sendRTCPBye = false;
225 {
danilchap56036ff2016-03-22 11:14:09 -0700226 rtc::CritScope lock(&critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000227
pbosda903ea2015-10-02 02:36:56 -0700228 if (method_ != RtcpMode::kOff) {
Erik Språng242e22b2015-05-11 10:17:43 +0200229 if (sending == false && sending_ == true) {
Erik Språng61be2a42015-04-27 13:32:52 +0200230 // Trigger RTCP bye
231 sendRTCPBye = true;
232 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000233 }
Erik Språng242e22b2015-05-11 10:17:43 +0200234 sending_ = sending;
Erik Språng61be2a42015-04-27 13:32:52 +0200235 }
236 if (sendRTCPBye)
237 return SendRTCP(feedback_state, kRtcpBye);
238 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000239}
240
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100241void RTCPSender::SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
242 RTC_CHECK_GE(bitrate_bps, 0);
danilchap56036ff2016-03-22 11:14:09 -0700243 rtc::CritScope lock(&critical_section_rtcp_sender_);
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100244 remb_bitrate_ = bitrate_bps;
245 remb_ssrcs_ = std::move(ssrcs);
stefan@webrtc.org4ef438e2014-07-11 09:55:30 +0000246
Danil Chapovalovf74d6412017-10-18 13:32:57 +0200247 SetFlag(kRtcpRemb, /*is_volatile=*/false);
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000248 // Send a REMB immediately if we have a new REMB. The frequency of REMBs is
249 // throttled by the caller.
Erik Språng242e22b2015-05-11 10:17:43 +0200250 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds();
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000251}
252
Danil Chapovalovf74d6412017-10-18 13:32:57 +0200253void RTCPSender::UnsetRemb() {
254 rtc::CritScope lock(&critical_section_rtcp_sender_);
255 // Stop sending REMB each report until it is reenabled and REMB data set.
256 ConsumeFlag(kRtcpRemb, /*forced=*/true);
257}
258
Erik Språng61be2a42015-04-27 13:32:52 +0200259bool RTCPSender::TMMBR() const {
danilchap56036ff2016-03-22 11:14:09 -0700260 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200261 return IsFlagPresent(RTCPPacketType::kRtcpTmmbr);
niklase@google.com470e71d2011-07-07 08:21:25 +0000262}
263
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000264void RTCPSender::SetTMMBRStatus(bool enable) {
danilchap56036ff2016-03-22 11:14:09 -0700265 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200266 if (enable) {
267 SetFlag(RTCPPacketType::kRtcpTmmbr, false);
268 } else {
269 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true);
270 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000271}
272
nisse284542b2017-01-10 08:58:32 -0800273void RTCPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
nisse6f142eb2017-02-21 07:32:47 -0800274 rtc::CritScope lock(&critical_section_rtcp_sender_);
nisse284542b2017-01-10 08:58:32 -0800275 max_packet_size_ = max_packet_size;
danilchap41befce2016-03-30 11:11:51 -0700276}
277
danilchap71fead22016-08-18 02:01:49 -0700278void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) {
danilchap56036ff2016-03-22 11:14:09 -0700279 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap71fead22016-08-18 02:01:49 -0700280 timestamp_offset_ = timestamp_offset;
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000281}
282
283void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
284 int64_t capture_time_ms) {
danilchap56036ff2016-03-22 11:14:09 -0700285 rtc::CritScope lock(&critical_section_rtcp_sender_);
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000286 last_rtp_timestamp_ = rtp_timestamp;
287 if (capture_time_ms < 0) {
288 // We don't currently get a capture time from VoiceEngine.
Erik Språng242e22b2015-05-11 10:17:43 +0200289 last_frame_capture_time_ms_ = clock_->TimeInMilliseconds();
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000290 } else {
291 last_frame_capture_time_ms_ = capture_time_ms;
292 }
293}
294
nisse14adba72017-03-20 03:52:39 -0700295uint32_t RTCPSender::SSRC() const {
296 rtc::CritScope lock(&critical_section_rtcp_sender_);
297 return ssrc_;
298}
299
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000300void RTCPSender::SetSSRC(uint32_t ssrc) {
danilchap56036ff2016-03-22 11:14:09 -0700301 rtc::CritScope lock(&critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000302
Erik Språng242e22b2015-05-11 10:17:43 +0200303 if (ssrc_ != 0) {
Erik Språng61be2a42015-04-27 13:32:52 +0200304 // not first SetSSRC, probably due to a collision
305 // schedule a new RTCP report
306 // make sure that we send a RTP packet
Erik Språng242e22b2015-05-11 10:17:43 +0200307 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + 100;
Erik Språng61be2a42015-04-27 13:32:52 +0200308 }
Erik Språng242e22b2015-05-11 10:17:43 +0200309 ssrc_ = ssrc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000310}
311
Erik Språng61be2a42015-04-27 13:32:52 +0200312void RTCPSender::SetRemoteSSRC(uint32_t ssrc) {
danilchap56036ff2016-03-22 11:14:09 -0700313 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200314 remote_ssrc_ = ssrc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000315}
316
Peter Boström9ba52f82015-06-01 14:12:28 +0200317int32_t RTCPSender::SetCNAME(const char* c_name) {
318 if (!c_name)
tommi@webrtc.orga990e122012-04-26 15:28:22 +0000319 return -1;
320
kwiberg352444f2016-11-28 15:58:53 -0800321 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE);
danilchap56036ff2016-03-22 11:14:09 -0700322 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng0ea42d32015-06-25 14:46:16 +0200323 cname_ = c_name;
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +0000324 return 0;
325}
326
Erik Språng0ea42d32015-06-25 14:46:16 +0200327int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) {
danilchap56036ff2016-03-22 11:14:09 -0700328 RTC_DCHECK(c_name);
kwiberg352444f2016-11-28 15:58:53 -0800329 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE);
danilchap56036ff2016-03-22 11:14:09 -0700330 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap74e8df8f2017-03-16 08:04:08 -0700331 // One spot is reserved for ssrc_/cname_.
332 // TODO(danilchap): Add support for more than 30 contributes by sending
333 // several sdes packets.
334 if (csrc_cnames_.size() >= rtcp::Sdes::kMaxNumberOfChunks - 1)
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000335 return -1;
Erik Språng0ea42d32015-06-25 14:46:16 +0200336
337 csrc_cnames_[SSRC] = c_name;
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000338 return 0;
339}
340
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000341int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) {
danilchap56036ff2016-03-22 11:14:09 -0700342 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng0ea42d32015-06-25 14:46:16 +0200343 auto it = csrc_cnames_.find(SSRC);
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000344
Erik Språng242e22b2015-05-11 10:17:43 +0200345 if (it == csrc_cnames_.end())
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000346 return -1;
Erik Språng61be2a42015-04-27 13:32:52 +0200347
Erik Språng242e22b2015-05-11 10:17:43 +0200348 csrc_cnames_.erase(it);
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000349 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000350}
351
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000352bool RTCPSender::TimeToSendRTCPReport(bool sendKeyframeBeforeRTP) const {
danilchap162abd32015-12-10 02:39:40 -0800353 /*
Jiawei Ou3587b832018-01-31 22:08:26 -0800354 For audio we use a configurable interval (default: 5 seconds)
niklase@google.com470e71d2011-07-07 08:21:25 +0000355
Jiawei Ou3587b832018-01-31 22:08:26 -0800356 For video we use a configurable interval (default: 1 second) for a BW
357 smaller than 360 kbit/s, technicaly we break the max 5% RTCP BW for
358 video below 10 kbit/s but that should be extremely rare
niklase@google.com470e71d2011-07-07 08:21:25 +0000359
360
danilchap162abd32015-12-10 02:39:40 -0800361 From RFC 3550
niklase@google.com470e71d2011-07-07 08:21:25 +0000362
danilchap162abd32015-12-10 02:39:40 -0800363 MAX RTCP BW is 5% if the session BW
364 A send report is approximately 65 bytes inc CNAME
365 A receiver report is approximately 28 bytes
niklase@google.com470e71d2011-07-07 08:21:25 +0000366
danilchap162abd32015-12-10 02:39:40 -0800367 The RECOMMENDED value for the reduced minimum in seconds is 360
368 divided by the session bandwidth in kilobits/second. This minimum
369 is smaller than 5 seconds for bandwidths greater than 72 kb/s.
niklase@google.com470e71d2011-07-07 08:21:25 +0000370
danilchap162abd32015-12-10 02:39:40 -0800371 If the participant has not yet sent an RTCP packet (the variable
Jiawei Ou3587b832018-01-31 22:08:26 -0800372 initial is true), the constant Tmin is set to half of the configured
373 interval.
niklase@google.com470e71d2011-07-07 08:21:25 +0000374
danilchap162abd32015-12-10 02:39:40 -0800375 The interval between RTCP packets is varied randomly over the
376 range [0.5,1.5] times the calculated interval to avoid unintended
377 synchronization of all participants
niklase@google.com470e71d2011-07-07 08:21:25 +0000378
danilchap162abd32015-12-10 02:39:40 -0800379 if we send
380 If the participant is a sender (we_sent true), the constant C is
381 set to the average RTCP packet size (avg_rtcp_size) divided by 25%
382 of the RTCP bandwidth (rtcp_bw), and the constant n is set to the
383 number of senders.
niklase@google.com470e71d2011-07-07 08:21:25 +0000384
danilchap162abd32015-12-10 02:39:40 -0800385 if we receive only
386 If we_sent is not true, the constant C is set
387 to the average RTCP packet size divided by 75% of the RTCP
388 bandwidth. The constant n is set to the number of receivers
389 (members - senders). If the number of senders is greater than
390 25%, senders and receivers are treated together.
niklase@google.com470e71d2011-07-07 08:21:25 +0000391
danilchap162abd32015-12-10 02:39:40 -0800392 reconsideration NOT required for peer-to-peer
393 "timer reconsideration" is
394 employed. This algorithm implements a simple back-off mechanism
395 which causes users to hold back RTCP packet transmission if the
396 group sizes are increasing.
niklase@google.com470e71d2011-07-07 08:21:25 +0000397
danilchap162abd32015-12-10 02:39:40 -0800398 n = number of members
399 C = avg_size/(rtcpBW/4)
niklase@google.com470e71d2011-07-07 08:21:25 +0000400
danilchap162abd32015-12-10 02:39:40 -0800401 3. The deterministic calculated interval Td is set to max(Tmin, n*C).
niklase@google.com470e71d2011-07-07 08:21:25 +0000402
danilchap162abd32015-12-10 02:39:40 -0800403 4. The calculated interval T is set to a number uniformly distributed
404 between 0.5 and 1.5 times the deterministic calculated interval.
niklase@google.com470e71d2011-07-07 08:21:25 +0000405
danilchap162abd32015-12-10 02:39:40 -0800406 5. The resulting value of T is divided by e-3/2=1.21828 to compensate
407 for the fact that the timer reconsideration algorithm converges to
408 a value of the RTCP bandwidth below the intended average
409 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000410
Erik Språng242e22b2015-05-11 10:17:43 +0200411 int64_t now = clock_->TimeInMilliseconds();
xians@webrtc.org8738d272011-11-25 13:43:53 +0000412
danilchap56036ff2016-03-22 11:14:09 -0700413 rtc::CritScope lock(&critical_section_rtcp_sender_);
xians@webrtc.org8738d272011-11-25 13:43:53 +0000414
pbosda903ea2015-10-02 02:36:56 -0700415 if (method_ == RtcpMode::kOff)
niklase@google.com470e71d2011-07-07 08:21:25 +0000416 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000417
Erik Språng242e22b2015-05-11 10:17:43 +0200418 if (!audio_ && sendKeyframeBeforeRTP) {
Erik Språng61be2a42015-04-27 13:32:52 +0200419 // for video key-frames we want to send the RTCP before the large key-frame
420 // if we have a 100 ms margin
421 now += RTCP_SEND_BEFORE_KEY_FRAME_MS;
422 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000423
Erik Språng242e22b2015-05-11 10:17:43 +0200424 if (now >= next_time_to_send_rtcp_) {
Erik Språng61be2a42015-04-27 13:32:52 +0200425 return true;
426 } else if (now < 0x0000ffff &&
Erik Språng242e22b2015-05-11 10:17:43 +0200427 next_time_to_send_rtcp_ > 0xffff0000) { // 65 sec margin
Erik Språng61be2a42015-04-27 13:32:52 +0200428 // wrap
429 return true;
430 }
431 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000432}
433
danilchap56036ff2016-03-22 11:14:09 -0700434std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSR(const RtcpContext& ctx) {
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200435 // Timestamp shouldn't be estimated before first media frame.
436 RTC_DCHECK_GE(last_frame_capture_time_ms_, 0);
Erik Språng61be2a42015-04-27 13:32:52 +0200437 // The timestamp of this RTCP packet should be estimated as the timestamp of
438 // the frame being captured at this moment. We are calculating that
439 // timestamp as the last frame's timestamp + the time since the last frame
440 // was captured.
solenbergb19d2882016-10-03 06:22:25 -0700441 uint32_t rtp_rate =
442 (audio_ ? kBogusRtpRateForAudioRtcp : kVideoPayloadTypeFrequency) / 1000;
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200443 uint32_t rtp_timestamp =
danilchap71fead22016-08-18 02:01:49 -0700444 timestamp_offset_ + last_rtp_timestamp_ +
solenbergb19d2882016-10-03 06:22:25 -0700445 (clock_->TimeInMilliseconds() - last_frame_capture_time_ms_) * rtp_rate;
niklase@google.com470e71d2011-07-07 08:21:25 +0000446
Erik Språngf7c57762015-12-04 10:40:35 +0100447 rtcp::SenderReport* report = new rtcp::SenderReport();
danilchap822a16f2016-09-27 09:27:47 -0700448 report->SetSenderSsrc(ssrc_);
danilchap51813b32016-12-16 02:44:36 -0800449 report->SetNtp(ctx.now_);
danilchap822a16f2016-09-27 09:27:47 -0700450 report->SetRtpTimestamp(rtp_timestamp);
451 report->SetPacketCount(ctx.feedback_state_.packets_sent);
452 report->SetOctetCount(ctx.feedback_state_.media_bytes_sent);
danilchap96b69bd2017-07-25 09:15:14 -0700453 report->SetReportBlocks(CreateReportBlocks(ctx.feedback_state_));
Erik Språngf7c57762015-12-04 10:40:35 +0100454
danilchap56036ff2016-03-22 11:14:09 -0700455 return std::unique_ptr<rtcp::RtcpPacket>(report);
niklase@google.com470e71d2011-07-07 08:21:25 +0000456}
457
danilchap56036ff2016-03-22 11:14:09 -0700458std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES(
Erik Språngf7c57762015-12-04 10:40:35 +0100459 const RtcpContext& ctx) {
Erik Språng0ea42d32015-06-25 14:46:16 +0200460 size_t length_cname = cname_.length();
kwiberg352444f2016-11-28 15:58:53 -0800461 RTC_CHECK_LT(length_cname, RTCP_CNAME_SIZE);
niklase@google.com470e71d2011-07-07 08:21:25 +0000462
Erik Språngf7c57762015-12-04 10:40:35 +0100463 rtcp::Sdes* sdes = new rtcp::Sdes();
danilchap822a16f2016-09-27 09:27:47 -0700464 sdes->AddCName(ssrc_, cname_);
Erik Språng0ea42d32015-06-25 14:46:16 +0200465
danilchap74e8df8f2017-03-16 08:04:08 -0700466 for (const auto& it : csrc_cnames_)
467 RTC_CHECK(sdes->AddCName(it.first, it.second));
Erik Språng0ea42d32015-06-25 14:46:16 +0200468
danilchap56036ff2016-03-22 11:14:09 -0700469 return std::unique_ptr<rtcp::RtcpPacket>(sdes);
niklase@google.com470e71d2011-07-07 08:21:25 +0000470}
471
danilchap56036ff2016-03-22 11:14:09 -0700472std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildRR(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100473 rtcp::ReceiverReport* report = new rtcp::ReceiverReport();
danilchap822a16f2016-09-27 09:27:47 -0700474 report->SetSenderSsrc(ssrc_);
danilchap96b69bd2017-07-25 09:15:14 -0700475 report->SetReportBlocks(CreateReportBlocks(ctx.feedback_state_));
Erik Språng61be2a42015-04-27 13:32:52 +0200476
danilchap56036ff2016-03-22 11:14:09 -0700477 return std::unique_ptr<rtcp::RtcpPacket>(report);
niklase@google.com470e71d2011-07-07 08:21:25 +0000478}
479
danilchap56036ff2016-03-22 11:14:09 -0700480std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildPLI(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100481 rtcp::Pli* pli = new rtcp::Pli();
danilchap822a16f2016-09-27 09:27:47 -0700482 pli->SetSenderSsrc(ssrc_);
483 pli->SetMediaSsrc(remote_ssrc_);
Erik Språng61be2a42015-04-27 13:32:52 +0200484
Erik Språng242e22b2015-05-11 10:17:43 +0200485 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
486 "RTCPSender::PLI");
487 ++packet_type_counter_.pli_packets;
488 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_PLICount",
489 ssrc_, packet_type_counter_.pli_packets);
490
danilchap56036ff2016-03-22 11:14:09 -0700491 return std::unique_ptr<rtcp::RtcpPacket>(pli);
Erik Språng61be2a42015-04-27 13:32:52 +0200492}
493
danilchap56036ff2016-03-22 11:14:09 -0700494std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildFIR(const RtcpContext& ctx) {
danilchap498ee8e2017-02-08 05:24:31 -0800495 ++sequence_number_fir_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000496
Erik Språngf7c57762015-12-04 10:40:35 +0100497 rtcp::Fir* fir = new rtcp::Fir();
danilchap822a16f2016-09-27 09:27:47 -0700498 fir->SetSenderSsrc(ssrc_);
499 fir->AddRequestTo(remote_ssrc_, sequence_number_fir_);
Erik Språng242e22b2015-05-11 10:17:43 +0200500
501 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
502 "RTCPSender::FIR");
503 ++packet_type_counter_.fir_packets;
504 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_FIRCount",
505 ssrc_, packet_type_counter_.fir_packets);
506
danilchap56036ff2016-03-22 11:14:09 -0700507 return std::unique_ptr<rtcp::RtcpPacket>(fir);
niklase@google.com470e71d2011-07-07 08:21:25 +0000508}
509
danilchap56036ff2016-03-22 11:14:09 -0700510std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildREMB(
Erik Språngf7c57762015-12-04 10:40:35 +0100511 const RtcpContext& ctx) {
512 rtcp::Remb* remb = new rtcp::Remb();
danilchap822a16f2016-09-27 09:27:47 -0700513 remb->SetSenderSsrc(ssrc_);
514 remb->SetBitrateBps(remb_bitrate_);
515 remb->SetSsrcs(remb_ssrcs_);
Erik Språng61be2a42015-04-27 13:32:52 +0200516
Erik Språng242e22b2015-05-11 10:17:43 +0200517 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
518 "RTCPSender::REMB");
519
danilchap56036ff2016-03-22 11:14:09 -0700520 return std::unique_ptr<rtcp::RtcpPacket>(remb);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000521}
522
Erik Språng61be2a42015-04-27 13:32:52 +0200523void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) {
danilchap56036ff2016-03-22 11:14:09 -0700524 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap2b616392016-08-18 06:17:42 -0700525 tmmbr_send_bps_ = target_bitrate;
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000526}
527
danilchap56036ff2016-03-22 11:14:09 -0700528std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
Erik Språngf7c57762015-12-04 10:40:35 +0100529 const RtcpContext& ctx) {
530 if (ctx.feedback_state_.module == nullptr)
531 return nullptr;
Erik Språng61be2a42015-04-27 13:32:52 +0200532 // Before sending the TMMBR check the received TMMBN, only an owner is
533 // allowed to raise the bitrate:
534 // * If the sender is an owner of the TMMBN -> send TMMBR
535 // * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
niklase@google.com470e71d2011-07-07 08:21:25 +0000536
Erik Språng61be2a42015-04-27 13:32:52 +0200537 // get current bounding set from RTCP receiver
danilchap2b616392016-08-18 06:17:42 -0700538 bool tmmbr_owner = false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000539
Erik Språng242e22b2015-05-11 10:17:43 +0200540 // holding critical_section_rtcp_sender_ while calling RTCPreceiver which
541 // will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
Erik Språng61be2a42015-04-27 13:32:52 +0200542 // since RTCPreceiver is not doing the reverse we should be fine
danilchap2b616392016-08-18 06:17:42 -0700543 std::vector<rtcp::TmmbItem> candidates =
544 ctx.feedback_state_.module->BoundingSet(&tmmbr_owner);
niklase@google.com470e71d2011-07-07 08:21:25 +0000545
danilchap2b616392016-08-18 06:17:42 -0700546 if (!candidates.empty()) {
547 for (const auto& candidate : candidates) {
548 if (candidate.bitrate_bps() == tmmbr_send_bps_ &&
549 candidate.packet_overhead() == packet_oh_send_) {
Erik Språngf7c57762015-12-04 10:40:35 +0100550 // Do not send the same tuple.
551 return nullptr;
Erik Språng61be2a42015-04-27 13:32:52 +0200552 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000553 }
danilchap2b616392016-08-18 06:17:42 -0700554 if (!tmmbr_owner) {
555 // Use received bounding set as candidate set.
556 // Add current tuple.
557 candidates.emplace_back(ssrc_, tmmbr_send_bps_, packet_oh_send_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000558
danilchap2b616392016-08-18 06:17:42 -0700559 // Find bounding set.
danilchap2f69ce92016-08-16 03:21:38 -0700560 std::vector<rtcp::TmmbItem> bounding =
561 TMMBRHelp::FindBoundingSet(std::move(candidates));
danilchap2b616392016-08-18 06:17:42 -0700562 tmmbr_owner = TMMBRHelp::IsOwner(bounding, ssrc_);
563 if (!tmmbr_owner) {
Erik Språngf7c57762015-12-04 10:40:35 +0100564 // Did not enter bounding set, no meaning to send this request.
565 return nullptr;
Erik Språng61be2a42015-04-27 13:32:52 +0200566 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000567 }
Erik Språng61be2a42015-04-27 13:32:52 +0200568 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000569
danilchap2b616392016-08-18 06:17:42 -0700570 if (!tmmbr_send_bps_)
Erik Språngf7c57762015-12-04 10:40:35 +0100571 return nullptr;
sprang81a3e602015-08-21 05:30:11 -0700572
Erik Språngf7c57762015-12-04 10:40:35 +0100573 rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr();
danilchap822a16f2016-09-27 09:27:47 -0700574 tmmbr->SetSenderSsrc(ssrc_);
danilchapf174e3a2016-02-05 04:56:36 -0800575 rtcp::TmmbItem request;
576 request.set_ssrc(remote_ssrc_);
danilchap2b616392016-08-18 06:17:42 -0700577 request.set_bitrate_bps(tmmbr_send_bps_);
danilchapf174e3a2016-02-05 04:56:36 -0800578 request.set_packet_overhead(packet_oh_send_);
danilchap822a16f2016-09-27 09:27:47 -0700579 tmmbr->AddTmmbr(request);
Erik Språngf7c57762015-12-04 10:40:35 +0100580
danilchap56036ff2016-03-22 11:14:09 -0700581 return std::unique_ptr<rtcp::RtcpPacket>(tmmbr);
Erik Språng61be2a42015-04-27 13:32:52 +0200582}
583
danilchap56036ff2016-03-22 11:14:09 -0700584std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN(
Erik Språngf7c57762015-12-04 10:40:35 +0100585 const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100586 rtcp::Tmmbn* tmmbn = new rtcp::Tmmbn();
danilchap822a16f2016-09-27 09:27:47 -0700587 tmmbn->SetSenderSsrc(ssrc_);
danilchap6eaa3a42016-05-09 10:59:50 -0700588 for (const rtcp::TmmbItem& tmmbr : tmmbn_to_send_) {
589 if (tmmbr.bitrate_bps() > 0) {
danilchap822a16f2016-09-27 09:27:47 -0700590 tmmbn->AddTmmbr(tmmbr);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000591 }
Erik Språng61be2a42015-04-27 13:32:52 +0200592 }
sprangd83df502015-08-27 01:05:08 -0700593
danilchap56036ff2016-03-22 11:14:09 -0700594 return std::unique_ptr<rtcp::RtcpPacket>(tmmbn);
niklase@google.com470e71d2011-07-07 08:21:25 +0000595}
596
danilchap56036ff2016-03-22 11:14:09 -0700597std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildAPP(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100598 rtcp::App* app = new rtcp::App();
danilchap822a16f2016-09-27 09:27:47 -0700599 app->SetSsrc(ssrc_);
600 app->SetSubType(app_sub_type_);
601 app->SetName(app_name_);
602 app->SetData(app_data_.get(), app_length_);
Erik Språng521875a2015-09-01 10:11:16 +0200603
danilchap56036ff2016-03-22 11:14:09 -0700604 return std::unique_ptr<rtcp::RtcpPacket>(app);
Erik Språng61be2a42015-04-27 13:32:52 +0200605}
606
danilchap56036ff2016-03-22 11:14:09 -0700607std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildNACK(
Erik Språngf7c57762015-12-04 10:40:35 +0100608 const RtcpContext& ctx) {
609 rtcp::Nack* nack = new rtcp::Nack();
danilchap822a16f2016-09-27 09:27:47 -0700610 nack->SetSenderSsrc(ssrc_);
611 nack->SetMediaSsrc(remote_ssrc_);
612 nack->SetPacketIds(ctx.nack_list_, ctx.nack_size_);
Erik Språng61be2a42015-04-27 13:32:52 +0200613
614 // Report stats.
615 NACKStringBuilder stringBuilder;
Erik Språngf7c57762015-12-04 10:40:35 +0100616 for (int idx = 0; idx < ctx.nack_size_; ++idx) {
617 stringBuilder.PushNACK(ctx.nack_list_[idx]);
618 nack_stats_.ReportRequest(ctx.nack_list_[idx]);
Erik Språng61be2a42015-04-27 13:32:52 +0200619 }
Erik Språng61be2a42015-04-27 13:32:52 +0200620 packet_type_counter_.nack_requests = nack_stats_.requests();
621 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests();
Erik Språng242e22b2015-05-11 10:17:43 +0200622
623 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
624 "RTCPSender::NACK", "nacks",
625 TRACE_STR_COPY(stringBuilder.GetResult().c_str()));
626 ++packet_type_counter_.nack_packets;
627 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_NACKCount",
628 ssrc_, packet_type_counter_.nack_packets);
629
danilchap56036ff2016-03-22 11:14:09 -0700630 return std::unique_ptr<rtcp::RtcpPacket>(nack);
Erik Språng61be2a42015-04-27 13:32:52 +0200631}
632
danilchap56036ff2016-03-22 11:14:09 -0700633std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildBYE(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100634 rtcp::Bye* bye = new rtcp::Bye();
danilchap822a16f2016-09-27 09:27:47 -0700635 bye->SetSenderSsrc(ssrc_);
636 bye->SetCsrcs(csrcs_);
sprangd8ee4f92015-08-24 03:25:19 -0700637
danilchap56036ff2016-03-22 11:14:09 -0700638 return std::unique_ptr<rtcp::RtcpPacket>(bye);
niklase@google.com470e71d2011-07-07 08:21:25 +0000639}
640
sprang5e38c962016-12-01 05:18:09 -0800641std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildExtendedReports(
Erik Språngf7c57762015-12-04 10:40:35 +0100642 const RtcpContext& ctx) {
sprang5e38c962016-12-01 05:18:09 -0800643 std::unique_ptr<rtcp::ExtendedReports> xr(new rtcp::ExtendedReports());
danilchap822a16f2016-09-27 09:27:47 -0700644 xr->SetSenderSsrc(ssrc_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000645
sprang5e38c962016-12-01 05:18:09 -0800646 if (!sending_ && xr_send_receiver_reference_time_enabled_) {
647 rtcp::Rrtr rrtr;
danilchap51813b32016-12-16 02:44:36 -0800648 rrtr.SetNtp(ctx.now_);
sprang5e38c962016-12-01 05:18:09 -0800649 xr->SetRrtr(rrtr);
650 }
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000651
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200652 for (const rtcp::ReceiveTimeInfo& rti : ctx.feedback_state_.last_xr_rtis) {
653 xr->AddDlrrItem(rti);
sprang5e38c962016-12-01 05:18:09 -0800654 }
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000655
sprang5e38c962016-12-01 05:18:09 -0800656 if (video_bitrate_allocation_) {
657 rtcp::TargetBitrate target_bitrate;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000658
sprang5e38c962016-12-01 05:18:09 -0800659 for (int sl = 0; sl < kMaxSpatialLayers; ++sl) {
660 for (int tl = 0; tl < kMaxTemporalStreams; ++tl) {
erikvarga@webrtc.org01f2ec32017-11-15 14:58:23 +0100661 if (video_bitrate_allocation_->HasBitrate(sl, tl)) {
662 target_bitrate.AddTargetBitrate(
663 sl, tl, video_bitrate_allocation_->GetBitrate(sl, tl) / 1000);
664 }
sprang5e38c962016-12-01 05:18:09 -0800665 }
666 }
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000667
sprang5e38c962016-12-01 05:18:09 -0800668 xr->SetTargetBitrate(target_bitrate);
669 video_bitrate_allocation_.reset();
670 }
Erik Språngca28fdc2015-08-31 14:00:50 +0200671
sprang5e38c962016-12-01 05:18:09 -0800672 if (xr_voip_metric_) {
673 rtcp::VoipMetric voip;
674 voip.SetMediaSsrc(remote_ssrc_);
675 voip.SetVoipMetric(*xr_voip_metric_);
676 xr_voip_metric_.reset();
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000677
sprang5e38c962016-12-01 05:18:09 -0800678 xr->SetVoipMetric(voip);
679 }
Erik Språngca28fdc2015-08-31 14:00:50 +0200680
sprang5e38c962016-12-01 05:18:09 -0800681 return std::move(xr);
niklase@google.com470e71d2011-07-07 08:21:25 +0000682}
683
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +0000684int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state,
Erik Språng242e22b2015-05-11 10:17:43 +0200685 RTCPPacketType packetType,
686 int32_t nack_size,
nissecd386eb2017-03-14 08:54:43 -0700687 const uint16_t* nack_list) {
Erik Språng242e22b2015-05-11 10:17:43 +0200688 return SendCompoundRTCP(
689 feedback_state, std::set<RTCPPacketType>(&packetType, &packetType + 1),
nissecd386eb2017-03-14 08:54:43 -0700690 nack_size, nack_list);
Erik Språng242e22b2015-05-11 10:17:43 +0200691}
692
693int32_t RTCPSender::SendCompoundRTCP(
694 const FeedbackState& feedback_state,
Erik Språngf7c57762015-12-04 10:40:35 +0100695 const std::set<RTCPPacketType>& packet_types,
Erik Språng242e22b2015-05-11 10:17:43 +0200696 int32_t nack_size,
nissecd386eb2017-03-14 08:54:43 -0700697 const uint16_t* nack_list) {
terelius429c3452016-01-21 05:42:04 -0800698 PacketContainer container(transport_, event_log_);
nisse6f142eb2017-02-21 07:32:47 -0800699 size_t max_packet_size;
700
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000701 {
danilchap56036ff2016-03-22 11:14:09 -0700702 rtc::CritScope lock(&critical_section_rtcp_sender_);
pbosda903ea2015-10-02 02:36:56 -0700703 if (method_ == RtcpMode::kOff) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100704 RTC_LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
Erik Språng61be2a42015-04-27 13:32:52 +0200705 return -1;
pwestin@webrtc.org8edb39d2011-12-22 07:40:33 +0000706 }
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200707 // Add all flags as volatile. Non volatile entries will not be overwritten.
708 // All new volatile flags added will be consumed by the end of this call.
709 SetFlags(packet_types, true);
710
711 // Prevent sending streams to send SR before any media has been sent.
712 const bool can_calculate_rtp_timestamp = (last_frame_capture_time_ms_ >= 0);
713 if (!can_calculate_rtp_timestamp) {
714 bool consumed_sr_flag = ConsumeFlag(kRtcpSr);
715 bool consumed_report_flag = sending_ && ConsumeFlag(kRtcpReport);
716 bool sender_report = consumed_report_flag || consumed_sr_flag;
717 if (sender_report && AllVolatileFlagsConsumed()) {
718 // This call was for Sender Report and nothing else.
719 return 0;
720 }
721 if (sending_ && method_ == RtcpMode::kCompound) {
722 // Not allowed to send any RTCP packet without sender report.
723 return -1;
724 }
725 }
726
727 if (packet_type_counter_.first_packet_time_ms == -1)
728 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds();
Erik Språngf7c57762015-12-04 10:40:35 +0100729
730 // We need to send our NTP even if we haven't received any reports.
nissecd386eb2017-03-14 08:54:43 -0700731 RtcpContext context(feedback_state, nack_size, nack_list,
danilchap37953762017-02-09 11:15:25 -0800732 clock_->CurrentNtpTime());
Erik Språngf7c57762015-12-04 10:40:35 +0100733
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200734 PrepareReport(feedback_state);
Erik Språngf7c57762015-12-04 10:40:35 +0100735
danilchap56036ff2016-03-22 11:14:09 -0700736 std::unique_ptr<rtcp::RtcpPacket> packet_bye;
aleungbroadsoft0e2e50c2016-02-18 08:33:26 -0800737
Erik Språngf7c57762015-12-04 10:40:35 +0100738 auto it = report_flags_.begin();
739 while (it != report_flags_.end()) {
740 auto builder_it = builders_.find(it->type);
sprang5e38c962016-12-01 05:18:09 -0800741 RTC_DCHECK(builder_it != builders_.end())
742 << "Could not find builder for packet type " << it->type;
Erik Språngf7c57762015-12-04 10:40:35 +0100743 if (it->is_volatile) {
744 report_flags_.erase(it++);
745 } else {
746 ++it;
747 }
748
749 BuilderFunc func = builder_it->second;
danilchap56036ff2016-03-22 11:14:09 -0700750 std::unique_ptr<rtcp::RtcpPacket> packet = (this->*func)(context);
Erik Språngf7c57762015-12-04 10:40:35 +0100751 if (packet.get() == nullptr)
752 return -1;
aleungbroadsoft0e2e50c2016-02-18 08:33:26 -0800753 // If there is a BYE, don't append now - save it and append it
754 // at the end later.
755 if (builder_it->first == kRtcpBye) {
756 packet_bye = std::move(packet);
757 } else {
758 container.Append(packet.release());
759 }
760 }
761
762 // Append the BYE now at the end
763 if (packet_bye) {
764 container.Append(packet_bye.release());
Erik Språngf7c57762015-12-04 10:40:35 +0100765 }
766
767 if (packet_type_counter_observer_ != nullptr) {
768 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated(
769 remote_ssrc_, packet_type_counter_);
770 }
771
772 RTC_DCHECK(AllVolatileFlagsConsumed());
nisse6f142eb2017-02-21 07:32:47 -0800773 max_packet_size = max_packet_size_;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000774 }
Erik Språng61be2a42015-04-27 13:32:52 +0200775
nisse6f142eb2017-02-21 07:32:47 -0800776 size_t bytes_sent = container.SendPackets(max_packet_size);
Erik Språngf7c57762015-12-04 10:40:35 +0100777 return bytes_sent == 0 ? -1 : 0;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000778}
779
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200780void RTCPSender::PrepareReport(const FeedbackState& feedback_state) {
Erik Språng242e22b2015-05-11 10:17:43 +0200781 bool generate_report;
782 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) {
783 // Report type already explicitly set, don't automatically populate.
784 generate_report = true;
henrikg91d6ede2015-09-17 00:24:34 -0700785 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false);
Erik Språng242e22b2015-05-11 10:17:43 +0200786 } else {
787 generate_report =
pbosda903ea2015-10-02 02:36:56 -0700788 (ConsumeFlag(kRtcpReport) && method_ == RtcpMode::kReducedSize) ||
789 method_ == RtcpMode::kCompound;
Erik Språng242e22b2015-05-11 10:17:43 +0200790 if (generate_report)
791 SetFlag(sending_ ? kRtcpSr : kRtcpRr, true);
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000792 }
793
Erik Språng0ea42d32015-06-25 14:46:16 +0200794 if (IsFlagPresent(kRtcpSr) || (IsFlagPresent(kRtcpRr) && !cname_.empty()))
Erik Språng242e22b2015-05-11 10:17:43 +0200795 SetFlag(kRtcpSdes, true);
796
Erik Språng242e22b2015-05-11 10:17:43 +0200797 if (generate_report) {
sprang5e38c962016-12-01 05:18:09 -0800798 if ((!sending_ && xr_send_receiver_reference_time_enabled_) ||
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200799 !feedback_state.last_xr_rtis.empty() || video_bitrate_allocation_) {
sprang5e38c962016-12-01 05:18:09 -0800800 SetFlag(kRtcpAnyExtendedReports, true);
801 }
Erik Språng242e22b2015-05-11 10:17:43 +0200802
803 // generate next time to send an RTCP report
Jiawei Ou3587b832018-01-31 22:08:26 -0800804 uint32_t minIntervalMs =
805 rtc::dchecked_cast<uint32_t>(interval_config_.audio_interval_ms);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000806
danilchap47a740b2015-12-15 00:30:07 -0800807 if (!audio_) {
Erik Språng242e22b2015-05-11 10:17:43 +0200808 if (sending_) {
Erik Språng61be2a42015-04-27 13:32:52 +0200809 // Calculate bandwidth for video; 360 / send bandwidth in kbit/s.
810 uint32_t send_bitrate_kbit = feedback_state.send_bitrate / 1000;
811 if (send_bitrate_kbit != 0)
812 minIntervalMs = 360000 / send_bitrate_kbit;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000813 }
Jiawei Ou3587b832018-01-31 22:08:26 -0800814 if (minIntervalMs >
815 rtc::dchecked_cast<uint32_t>(interval_config_.video_interval_ms)) {
816 minIntervalMs =
817 rtc::dchecked_cast<uint32_t>(interval_config_.video_interval_ms);
818 }
Erik Språng61be2a42015-04-27 13:32:52 +0200819 }
Jiawei Ou3587b832018-01-31 22:08:26 -0800820
danilchap47a740b2015-12-15 00:30:07 -0800821 // The interval between RTCP packets is varied randomly over the
822 // range [1/2,3/2] times the calculated interval.
823 uint32_t timeToNext =
824 random_.Rand(minIntervalMs * 1 / 2, minIntervalMs * 3 / 2);
Erik Språng242e22b2015-05-11 10:17:43 +0200825 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + timeToNext;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000826
danilchap96b69bd2017-07-25 09:15:14 -0700827 // RtcpSender expected to be used for sending either just sender reports
828 // or just receiver reports.
829 RTC_DCHECK(!(IsFlagPresent(kRtcpSr) && IsFlagPresent(kRtcpRr)));
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000830 }
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000831}
832
danilchap96b69bd2017-07-25 09:15:14 -0700833std::vector<rtcp::ReportBlock> RTCPSender::CreateReportBlocks(
834 const FeedbackState& feedback_state) {
835 std::vector<rtcp::ReportBlock> result;
836 if (!receive_statistics_)
837 return result;
danilchapa72e7342015-12-22 08:07:45 -0800838
danilchapf5f793c2017-07-27 04:44:18 -0700839 // TODO(danilchap): Support sending more than |RTCP_MAX_REPORT_BLOCKS| per
840 // compound rtcp packet when single rtcp module is used for multiple media
841 // streams.
842 result = receive_statistics_->RtcpReportBlocks(RTCP_MAX_REPORT_BLOCKS);
danilchap96b69bd2017-07-25 09:15:14 -0700843
844 if (!result.empty() && ((feedback_state.last_rr_ntp_secs != 0) ||
845 (feedback_state.last_rr_ntp_frac != 0))) {
846 // Get our NTP as late as possible to avoid a race.
847 uint32_t now = CompactNtp(clock_->CurrentNtpTime());
848
849 uint32_t receive_time = feedback_state.last_rr_ntp_secs & 0x0000FFFF;
850 receive_time <<= 16;
851 receive_time += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16;
852
853 uint32_t delay_since_last_sr = now - receive_time;
854 // TODO(danilchap): Instead of setting same value on all report blocks,
855 // set only when media_ssrc match sender ssrc of the sender report
856 // remote times were taken from.
857 for (auto& report_block : result) {
858 report_block.SetLastSr(feedback_state.remote_sr);
859 report_block.SetDelayLastSr(delay_since_last_sr);
860 }
danilchapa72e7342015-12-22 08:07:45 -0800861 }
danilchap96b69bd2017-07-25 09:15:14 -0700862 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000863}
864
pbos@webrtc.org9334ac22014-11-24 08:25:50 +0000865void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
kwiberg352444f2016-11-28 15:58:53 -0800866 RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize);
danilchap56036ff2016-03-22 11:14:09 -0700867 rtc::CritScope lock(&critical_section_rtcp_sender_);
pbos@webrtc.org9334ac22014-11-24 08:25:50 +0000868 csrcs_ = csrcs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000869}
870
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000871int32_t RTCPSender::SetApplicationSpecificData(uint8_t subType,
872 uint32_t name,
873 const uint8_t* data,
874 uint16_t length) {
Erik Språng61be2a42015-04-27 13:32:52 +0200875 if (length % 4 != 0) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100876 RTC_LOG(LS_ERROR) << "Failed to SetApplicationSpecificData.";
Erik Språng61be2a42015-04-27 13:32:52 +0200877 return -1;
878 }
danilchap56036ff2016-03-22 11:14:09 -0700879 rtc::CritScope lock(&critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000880
Erik Språng242e22b2015-05-11 10:17:43 +0200881 SetFlag(kRtcpApp, true);
882 app_sub_type_ = subType;
883 app_name_ = name;
884 app_data_.reset(new uint8_t[length]);
885 app_length_ = length;
886 memcpy(app_data_.get(), data, length);
Erik Språng61be2a42015-04-27 13:32:52 +0200887 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000888}
889
spranga790d832016-12-02 07:29:44 -0800890// TODO(sprang): Remove support for VoIP metrics? (Not used in receiver.)
Erik Språng61be2a42015-04-27 13:32:52 +0200891int32_t RTCPSender::SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) {
danilchap56036ff2016-03-22 11:14:09 -0700892 rtc::CritScope lock(&critical_section_rtcp_sender_);
sprang5e38c962016-12-01 05:18:09 -0800893 xr_voip_metric_.emplace(*VoIPMetric);
niklase@google.com470e71d2011-07-07 08:21:25 +0000894
sprang5e38c962016-12-01 05:18:09 -0800895 SetFlag(kRtcpAnyExtendedReports, true);
Erik Språng61be2a42015-04-27 13:32:52 +0200896 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000897}
898
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000899void RTCPSender::SendRtcpXrReceiverReferenceTime(bool enable) {
danilchap56036ff2016-03-22 11:14:09 -0700900 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200901 xr_send_receiver_reference_time_enabled_ = enable;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000902}
903
asapersson@webrtc.org8d02f5d2013-11-21 08:57:04 +0000904bool RTCPSender::RtcpXrReceiverReferenceTime() const {
danilchap56036ff2016-03-22 11:14:09 -0700905 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200906 return xr_send_receiver_reference_time_enabled_;
asapersson@webrtc.org8d02f5d2013-11-21 08:57:04 +0000907}
908
danilchap853ecb22016-08-22 08:26:15 -0700909void RTCPSender::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) {
danilchap56036ff2016-03-22 11:14:09 -0700910 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap853ecb22016-08-22 08:26:15 -0700911 tmmbn_to_send_ = std::move(bounding_set);
danilchap6eaa3a42016-05-09 10:59:50 -0700912 SetFlag(kRtcpTmmbn, true);
niklase@google.com470e71d2011-07-07 08:21:25 +0000913}
Erik Språng61be2a42015-04-27 13:32:52 +0200914
sprang5e38c962016-12-01 05:18:09 -0800915void RTCPSender::SetFlag(uint32_t type, bool is_volatile) {
916 if (type & kRtcpAnyExtendedReports) {
917 report_flags_.insert(ReportFlag(kRtcpAnyExtendedReports, is_volatile));
918 } else {
919 report_flags_.insert(ReportFlag(type, is_volatile));
920 }
Erik Språng242e22b2015-05-11 10:17:43 +0200921}
922
923void RTCPSender::SetFlags(const std::set<RTCPPacketType>& types,
924 bool is_volatile) {
925 for (RTCPPacketType type : types)
926 SetFlag(type, is_volatile);
927}
928
sprang5e38c962016-12-01 05:18:09 -0800929bool RTCPSender::IsFlagPresent(uint32_t type) const {
Erik Språng242e22b2015-05-11 10:17:43 +0200930 return report_flags_.find(ReportFlag(type, false)) != report_flags_.end();
931}
932
sprang5e38c962016-12-01 05:18:09 -0800933bool RTCPSender::ConsumeFlag(uint32_t type, bool forced) {
Erik Språng242e22b2015-05-11 10:17:43 +0200934 auto it = report_flags_.find(ReportFlag(type, false));
935 if (it == report_flags_.end())
936 return false;
937 if (it->is_volatile || forced)
938 report_flags_.erase((it));
939 return true;
940}
941
942bool RTCPSender::AllVolatileFlagsConsumed() const {
943 for (const ReportFlag& flag : report_flags_) {
944 if (flag.is_volatile)
945 return false;
946 }
947 return true;
948}
949
sprang5e38c962016-12-01 05:18:09 -0800950void RTCPSender::SetVideoBitrateAllocation(const BitrateAllocation& bitrate) {
951 rtc::CritScope lock(&critical_section_rtcp_sender_);
952 video_bitrate_allocation_.emplace(bitrate);
953 SetFlag(kRtcpAnyExtendedReports, true);
954}
955
sprang233bd872015-09-08 13:25:16 -0700956bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) {
nisse6f142eb2017-02-21 07:32:47 -0800957 size_t max_packet_size;
stefanb77c7162017-02-06 06:29:38 -0800958 {
959 rtc::CritScope lock(&critical_section_rtcp_sender_);
960 if (method_ == RtcpMode::kOff)
961 return false;
nisse6f142eb2017-02-21 07:32:47 -0800962 max_packet_size = max_packet_size_;
stefanb77c7162017-02-06 06:29:38 -0800963 }
964
nisse6f142eb2017-02-21 07:32:47 -0800965 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
Danil Chapovalov5c3cc412017-12-07 10:15:53 +0100966 bool send_failure = false;
967 auto callback = [&](rtc::ArrayView<const uint8_t> packet) {
968 if (transport_->SendRtcp(packet.data(), packet.size())) {
969 if (event_log_)
970 event_log_->Log(rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(packet));
971 } else {
972 send_failure = true;
973 }
974 };
975 return packet.Build(max_packet_size, callback) && !send_failure;
sprang233bd872015-09-08 13:25:16 -0700976}
977
Jiawei Ou3587b832018-01-31 22:08:26 -0800978int64_t RTCPSender::RtcpAudioReportInverval() const {
979 return interval_config_.audio_interval_ms;
980}
981
982int64_t RTCPSender::RtcpVideoReportInverval() const {
983 return interval_config_.video_interval_ms;
984}
985
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000986} // namespace webrtc