blob: 80a22edaf8306f75338986ebf0f156821ba40b53 [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
Karl Wiberg918f50c2018-07-05 11:40:33 +020017#include "absl/memory/memory.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020018#include "common_types.h" // NOLINT(build/include)
Elad Alon4a87e1c2017-10-03 16:11:34 +020019#include "logging/rtc_event_log/events/rtc_event_rtcp_packet_outgoing.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "logging/rtc_event_log/rtc_event_log.h"
21#include "modules/rtp_rtcp/source/rtcp_packet/app.h"
22#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
23#include "modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
24#include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
25#include "modules/rtp_rtcp/source/rtcp_packet/fir.h"
26#include "modules/rtp_rtcp/source/rtcp_packet/nack.h"
27#include "modules/rtp_rtcp/source/rtcp_packet/pli.h"
28#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
29#include "modules/rtp_rtcp/source/rtcp_packet/remb.h"
30#include "modules/rtp_rtcp/source/rtcp_packet/sdes.h"
31#include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
32#include "modules/rtp_rtcp/source/rtcp_packet/tmmbn.h"
33#include "modules/rtp_rtcp/source/rtcp_packet/tmmbr.h"
34#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
35#include "modules/rtp_rtcp/source/rtp_rtcp_impl.h"
36#include "modules/rtp_rtcp/source/time_util.h"
37#include "modules/rtp_rtcp/source/tmmbr_help.h"
38#include "rtc_base/checks.h"
39#include "rtc_base/constructormagic.h"
40#include "rtc_base/logging.h"
Jiawei Ou3587b832018-01-31 22:08:26 -080041#include "rtc_base/numerics/safe_conversions.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 {
Niels Möller44b384d2018-10-05 11:15:57 +020047const uint32_t kRtcpAnyExtendedReports = kRtcpXrReceiverReferenceTime |
48 kRtcpXrDlrrReportBlock |
49 kRtcpXrTargetBitrate;
sprang5e38c962016-12-01 05:18:09 -080050} // namespace
51
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000052RTCPSender::FeedbackState::FeedbackState()
nisse40ba3ad2017-03-17 07:04:00 -070053 : packets_sent(0),
pbos@webrtc.org2f4b14e2014-07-15 15:25:39 +000054 media_bytes_sent(0),
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000055 send_bitrate(0),
56 last_rr_ntp_secs(0),
57 last_rr_ntp_frac(0),
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +000058 remote_sr(0),
danilchap162abd32015-12-10 02:39:40 -080059 module(nullptr) {}
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000060
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +020061RTCPSender::FeedbackState::FeedbackState(const FeedbackState&) = default;
62
63RTCPSender::FeedbackState::FeedbackState(FeedbackState&&) = default;
64
65RTCPSender::FeedbackState::~FeedbackState() = default;
66
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010067class PacketContainer : public rtcp::CompoundPacket {
Erik Språngf7c57762015-12-04 10:40:35 +010068 public:
terelius429c3452016-01-21 05:42:04 -080069 PacketContainer(Transport* transport, RtcEventLog* event_log)
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010070 : transport_(transport), event_log_(event_log) {}
Danil Chapovalov2a5ce2b2018-02-07 09:38:31 +010071 ~PacketContainer() override {
Erik Språngf7c57762015-12-04 10:40:35 +010072 for (RtcpPacket* packet : appended_packets_)
73 delete packet;
74 }
75
danilchap41befce2016-03-30 11:11:51 -070076 size_t SendPackets(size_t max_payload_length) {
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010077 size_t bytes_sent = 0;
78 Build(max_payload_length, [&](rtc::ArrayView<const uint8_t> packet) {
79 if (transport_->SendRtcp(packet.data(), packet.size())) {
80 bytes_sent += packet.size();
81 if (event_log_) {
Karl Wiberg918f50c2018-07-05 11:40:33 +020082 event_log_->Log(
83 absl::make_unique<RtcEventRtcpPacketOutgoing>(packet));
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010084 }
85 }
86 });
87 return bytes_sent;
Erik Språngf7c57762015-12-04 10:40:35 +010088 }
89
90 private:
91 Transport* transport_;
terelius429c3452016-01-21 05:42:04 -080092 RtcEventLog* const event_log_;
terelius429c3452016-01-21 05:42:04 -080093
94 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer);
Erik Språngf7c57762015-12-04 10:40:35 +010095};
96
97class RTCPSender::RtcpContext {
98 public:
Erik Språng242e22b2015-05-11 10:17:43 +020099 RtcpContext(const FeedbackState& feedback_state,
100 int32_t nack_size,
101 const uint16_t* nack_list,
danilchap51813b32016-12-16 02:44:36 -0800102 NtpTime now)
Erik Språngf7c57762015-12-04 10:40:35 +0100103 : feedback_state_(feedback_state),
104 nack_size_(nack_size),
105 nack_list_(nack_list),
danilchap51813b32016-12-16 02:44:36 -0800106 now_(now) {}
Erik Språng242e22b2015-05-11 10:17:43 +0200107
Erik Språngf7c57762015-12-04 10:40:35 +0100108 const FeedbackState& feedback_state_;
109 const int32_t nack_size_;
110 const uint16_t* nack_list_;
danilchap51813b32016-12-16 02:44:36 -0800111 const NtpTime now_;
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200112};
113
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000114RTCPSender::RTCPSender(
pbos@webrtc.org1d0fa5d2015-02-19 12:47:00 +0000115 bool audio,
116 Clock* clock,
danilchapf5f793c2017-07-27 04:44:18 -0700117 ReceiveStatisticsProvider* receive_statistics,
sprang86fd9ed2015-09-29 04:45:43 -0700118 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
terelius429c3452016-01-21 05:42:04 -0800119 RtcEventLog* event_log,
Jiawei Ou3587b832018-01-31 22:08:26 -0800120 Transport* outgoing_transport,
121 RtcpIntervalConfig interval_config)
Peter Boströmac547a62015-09-17 23:03:57 +0200122 : audio_(audio),
Erik Språng242e22b2015-05-11 10:17:43 +0200123 clock_(clock),
danilchap47a740b2015-12-15 00:30:07 -0800124 random_(clock_->TimeInMicroseconds()),
pbosda903ea2015-10-02 02:36:56 -0700125 method_(RtcpMode::kOff),
terelius429c3452016-01-21 05:42:04 -0800126 event_log_(event_log),
sprang86fd9ed2015-09-29 04:45:43 -0700127 transport_(outgoing_transport),
Jiawei Ou3587b832018-01-31 22:08:26 -0800128 interval_config_(interval_config),
Erik Språng242e22b2015-05-11 10:17:43 +0200129 using_nack_(false),
130 sending_(false),
Erik Språng242e22b2015-05-11 10:17:43 +0200131 next_time_to_send_rtcp_(0),
danilchap71fead22016-08-18 02:01:49 -0700132 timestamp_offset_(0),
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000133 last_rtp_timestamp_(0),
134 last_frame_capture_time_ms_(-1),
Erik Språng242e22b2015-05-11 10:17:43 +0200135 ssrc_(0),
136 remote_ssrc_(0),
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000137 receive_statistics_(receive_statistics),
niklase@google.com470e71d2011-07-07 08:21:25 +0000138
Erik Språng242e22b2015-05-11 10:17:43 +0200139 sequence_number_fir_(0),
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000140
Erik Språng242e22b2015-05-11 10:17:43 +0200141 remb_bitrate_(0),
niklase@google.com470e71d2011-07-07 08:21:25 +0000142
danilchap2b616392016-08-18 06:17:42 -0700143 tmmbr_send_bps_(0),
Erik Språng242e22b2015-05-11 10:17:43 +0200144 packet_oh_send_(0),
nisse284542b2017-01-10 08:58:32 -0800145 max_packet_size_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000146
Erik Språng242e22b2015-05-11 10:17:43 +0200147 app_sub_type_(0),
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200148 app_name_(0),
Erik Språng242e22b2015-05-11 10:17:43 +0200149 app_data_(nullptr),
150 app_length_(0),
niklase@google.com470e71d2011-07-07 08:21:25 +0000151
Erik Språng242e22b2015-05-11 10:17:43 +0200152 xr_send_receiver_reference_time_enabled_(false),
Erik Språng8782a582018-10-04 15:36:06 +0200153 packet_type_counter_observer_(packet_type_counter_observer),
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +0200154 send_video_bitrate_allocation_(false),
155 last_payload_type_(-1) {
sprang86fd9ed2015-09-29 04:45:43 -0700156 RTC_DCHECK(transport_ != nullptr);
Erik Språng242e22b2015-05-11 10:17:43 +0200157
158 builders_[kRtcpSr] = &RTCPSender::BuildSR;
159 builders_[kRtcpRr] = &RTCPSender::BuildRR;
Erik Språng0ea42d32015-06-25 14:46:16 +0200160 builders_[kRtcpSdes] = &RTCPSender::BuildSDES;
Erik Språng242e22b2015-05-11 10:17:43 +0200161 builders_[kRtcpPli] = &RTCPSender::BuildPLI;
162 builders_[kRtcpFir] = &RTCPSender::BuildFIR;
Erik Språng242e22b2015-05-11 10:17:43 +0200163 builders_[kRtcpRemb] = &RTCPSender::BuildREMB;
164 builders_[kRtcpBye] = &RTCPSender::BuildBYE;
165 builders_[kRtcpApp] = &RTCPSender::BuildAPP;
166 builders_[kRtcpTmmbr] = &RTCPSender::BuildTMMBR;
167 builders_[kRtcpTmmbn] = &RTCPSender::BuildTMMBN;
168 builders_[kRtcpNack] = &RTCPSender::BuildNACK;
sprang5e38c962016-12-01 05:18:09 -0800169 builders_[kRtcpAnyExtendedReports] = &RTCPSender::BuildExtendedReports;
niklase@google.com470e71d2011-07-07 08:21:25 +0000170}
171
danilchap162abd32015-12-10 02:39:40 -0800172RTCPSender::~RTCPSender() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000173
pbosda903ea2015-10-02 02:36:56 -0700174RtcpMode RTCPSender::Status() const {
danilchap56036ff2016-03-22 11:14:09 -0700175 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200176 return method_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000177}
178
skvlad1c392cc2016-04-01 14:46:44 -0700179void RTCPSender::SetRTCPStatus(RtcpMode new_method) {
danilchap56036ff2016-03-22 11:14:09 -0700180 rtc::CritScope lock(&critical_section_rtcp_sender_);
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000181
skvlad1c392cc2016-04-01 14:46:44 -0700182 if (method_ == RtcpMode::kOff && new_method != RtcpMode::kOff) {
183 // When switching on, reschedule the next packet
Jiawei Ou3587b832018-01-31 22:08:26 -0800184 int64_t interval_ms = audio_ ? interval_config_.audio_interval_ms
185 : interval_config_.video_interval_ms;
186 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + (interval_ms / 2);
skvlad1c392cc2016-04-01 14:46:44 -0700187 }
188 method_ = new_method;
niklase@google.com470e71d2011-07-07 08:21:25 +0000189}
190
Erik Språng61be2a42015-04-27 13:32:52 +0200191bool RTCPSender::Sending() const {
danilchap56036ff2016-03-22 11:14:09 -0700192 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200193 return sending_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000194}
195
Erik Språng61be2a42015-04-27 13:32:52 +0200196int32_t RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
197 bool sending) {
198 bool sendRTCPBye = false;
199 {
danilchap56036ff2016-03-22 11:14:09 -0700200 rtc::CritScope lock(&critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000201
pbosda903ea2015-10-02 02:36:56 -0700202 if (method_ != RtcpMode::kOff) {
Erik Språng242e22b2015-05-11 10:17:43 +0200203 if (sending == false && sending_ == true) {
Erik Språng61be2a42015-04-27 13:32:52 +0200204 // Trigger RTCP bye
205 sendRTCPBye = true;
206 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000207 }
Erik Språng242e22b2015-05-11 10:17:43 +0200208 sending_ = sending;
Erik Språng61be2a42015-04-27 13:32:52 +0200209 }
210 if (sendRTCPBye)
211 return SendRTCP(feedback_state, kRtcpBye);
212 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000213}
214
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100215void RTCPSender::SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
216 RTC_CHECK_GE(bitrate_bps, 0);
danilchap56036ff2016-03-22 11:14:09 -0700217 rtc::CritScope lock(&critical_section_rtcp_sender_);
Danil Chapovalov1de4b622017-12-13 13:35:10 +0100218 remb_bitrate_ = bitrate_bps;
219 remb_ssrcs_ = std::move(ssrcs);
stefan@webrtc.org4ef438e2014-07-11 09:55:30 +0000220
Danil Chapovalovf74d6412017-10-18 13:32:57 +0200221 SetFlag(kRtcpRemb, /*is_volatile=*/false);
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000222 // Send a REMB immediately if we have a new REMB. The frequency of REMBs is
223 // throttled by the caller.
Erik Språng242e22b2015-05-11 10:17:43 +0200224 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds();
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000225}
226
Danil Chapovalovf74d6412017-10-18 13:32:57 +0200227void RTCPSender::UnsetRemb() {
228 rtc::CritScope lock(&critical_section_rtcp_sender_);
229 // Stop sending REMB each report until it is reenabled and REMB data set.
230 ConsumeFlag(kRtcpRemb, /*forced=*/true);
231}
232
Erik Språng61be2a42015-04-27 13:32:52 +0200233bool RTCPSender::TMMBR() const {
danilchap56036ff2016-03-22 11:14:09 -0700234 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200235 return IsFlagPresent(RTCPPacketType::kRtcpTmmbr);
niklase@google.com470e71d2011-07-07 08:21:25 +0000236}
237
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000238void RTCPSender::SetTMMBRStatus(bool enable) {
danilchap56036ff2016-03-22 11:14:09 -0700239 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200240 if (enable) {
241 SetFlag(RTCPPacketType::kRtcpTmmbr, false);
242 } else {
243 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true);
244 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000245}
246
nisse284542b2017-01-10 08:58:32 -0800247void RTCPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
nisse6f142eb2017-02-21 07:32:47 -0800248 rtc::CritScope lock(&critical_section_rtcp_sender_);
nisse284542b2017-01-10 08:58:32 -0800249 max_packet_size_ = max_packet_size;
danilchap41befce2016-03-30 11:11:51 -0700250}
251
danilchap71fead22016-08-18 02:01:49 -0700252void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) {
danilchap56036ff2016-03-22 11:14:09 -0700253 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap71fead22016-08-18 02:01:49 -0700254 timestamp_offset_ = timestamp_offset;
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000255}
256
257void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +0200258 int64_t capture_time_ms,
259 int8_t payload_type) {
danilchap56036ff2016-03-22 11:14:09 -0700260 rtc::CritScope lock(&critical_section_rtcp_sender_);
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +0200261 // For compatibility with clients who don't set payload type correctly on all
262 // calls.
263 if (payload_type != -1) {
264 last_payload_type_ = payload_type;
265 }
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000266 last_rtp_timestamp_ = rtp_timestamp;
267 if (capture_time_ms < 0) {
268 // We don't currently get a capture time from VoiceEngine.
Erik Språng242e22b2015-05-11 10:17:43 +0200269 last_frame_capture_time_ms_ = clock_->TimeInMilliseconds();
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +0000270 } else {
271 last_frame_capture_time_ms_ = capture_time_ms;
272 }
273}
274
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +0200275void RTCPSender::SetRtpClockRate(int8_t payload_type, int rtp_clock_rate_hz) {
276 rtc::CritScope lock(&critical_section_rtcp_sender_);
277 rtp_clock_rates_khz_[payload_type] = rtp_clock_rate_hz / 1000;
278}
279
nisse14adba72017-03-20 03:52:39 -0700280uint32_t RTCPSender::SSRC() const {
281 rtc::CritScope lock(&critical_section_rtcp_sender_);
282 return ssrc_;
283}
284
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000285void RTCPSender::SetSSRC(uint32_t ssrc) {
danilchap56036ff2016-03-22 11:14:09 -0700286 rtc::CritScope lock(&critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000287
Erik Språng242e22b2015-05-11 10:17:43 +0200288 if (ssrc_ != 0) {
Erik Språng61be2a42015-04-27 13:32:52 +0200289 // not first SetSSRC, probably due to a collision
290 // schedule a new RTCP report
291 // make sure that we send a RTP packet
Erik Språng242e22b2015-05-11 10:17:43 +0200292 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + 100;
Erik Språng61be2a42015-04-27 13:32:52 +0200293 }
Erik Språng242e22b2015-05-11 10:17:43 +0200294 ssrc_ = ssrc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000295}
296
Erik Språng61be2a42015-04-27 13:32:52 +0200297void RTCPSender::SetRemoteSSRC(uint32_t ssrc) {
danilchap56036ff2016-03-22 11:14:09 -0700298 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200299 remote_ssrc_ = ssrc;
niklase@google.com470e71d2011-07-07 08:21:25 +0000300}
301
Peter Boström9ba52f82015-06-01 14:12:28 +0200302int32_t RTCPSender::SetCNAME(const char* c_name) {
303 if (!c_name)
tommi@webrtc.orga990e122012-04-26 15:28:22 +0000304 return -1;
305
kwiberg352444f2016-11-28 15:58:53 -0800306 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE);
danilchap56036ff2016-03-22 11:14:09 -0700307 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng0ea42d32015-06-25 14:46:16 +0200308 cname_ = c_name;
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +0000309 return 0;
310}
311
Erik Språng0ea42d32015-06-25 14:46:16 +0200312int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) {
danilchap56036ff2016-03-22 11:14:09 -0700313 RTC_DCHECK(c_name);
kwiberg352444f2016-11-28 15:58:53 -0800314 RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE);
danilchap56036ff2016-03-22 11:14:09 -0700315 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap74e8df8f2017-03-16 08:04:08 -0700316 // One spot is reserved for ssrc_/cname_.
317 // TODO(danilchap): Add support for more than 30 contributes by sending
318 // several sdes packets.
319 if (csrc_cnames_.size() >= rtcp::Sdes::kMaxNumberOfChunks - 1)
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000320 return -1;
Erik Språng0ea42d32015-06-25 14:46:16 +0200321
322 csrc_cnames_[SSRC] = c_name;
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000323 return 0;
324}
325
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000326int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) {
danilchap56036ff2016-03-22 11:14:09 -0700327 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng0ea42d32015-06-25 14:46:16 +0200328 auto it = csrc_cnames_.find(SSRC);
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000329
Erik Språng242e22b2015-05-11 10:17:43 +0200330 if (it == csrc_cnames_.end())
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000331 return -1;
Erik Språng61be2a42015-04-27 13:32:52 +0200332
Erik Språng242e22b2015-05-11 10:17:43 +0200333 csrc_cnames_.erase(it);
pwestin@webrtc.org26f8d9c2012-01-19 15:53:09 +0000334 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000335}
336
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000337bool RTCPSender::TimeToSendRTCPReport(bool sendKeyframeBeforeRTP) const {
danilchap162abd32015-12-10 02:39:40 -0800338 /*
Jiawei Ou3587b832018-01-31 22:08:26 -0800339 For audio we use a configurable interval (default: 5 seconds)
niklase@google.com470e71d2011-07-07 08:21:25 +0000340
Jiawei Ou3587b832018-01-31 22:08:26 -0800341 For video we use a configurable interval (default: 1 second) for a BW
342 smaller than 360 kbit/s, technicaly we break the max 5% RTCP BW for
343 video below 10 kbit/s but that should be extremely rare
niklase@google.com470e71d2011-07-07 08:21:25 +0000344
345
danilchap162abd32015-12-10 02:39:40 -0800346 From RFC 3550
niklase@google.com470e71d2011-07-07 08:21:25 +0000347
danilchap162abd32015-12-10 02:39:40 -0800348 MAX RTCP BW is 5% if the session BW
349 A send report is approximately 65 bytes inc CNAME
350 A receiver report is approximately 28 bytes
niklase@google.com470e71d2011-07-07 08:21:25 +0000351
danilchap162abd32015-12-10 02:39:40 -0800352 The RECOMMENDED value for the reduced minimum in seconds is 360
353 divided by the session bandwidth in kilobits/second. This minimum
354 is smaller than 5 seconds for bandwidths greater than 72 kb/s.
niklase@google.com470e71d2011-07-07 08:21:25 +0000355
danilchap162abd32015-12-10 02:39:40 -0800356 If the participant has not yet sent an RTCP packet (the variable
Jiawei Ou3587b832018-01-31 22:08:26 -0800357 initial is true), the constant Tmin is set to half of the configured
358 interval.
niklase@google.com470e71d2011-07-07 08:21:25 +0000359
danilchap162abd32015-12-10 02:39:40 -0800360 The interval between RTCP packets is varied randomly over the
361 range [0.5,1.5] times the calculated interval to avoid unintended
362 synchronization of all participants
niklase@google.com470e71d2011-07-07 08:21:25 +0000363
danilchap162abd32015-12-10 02:39:40 -0800364 if we send
365 If the participant is a sender (we_sent true), the constant C is
366 set to the average RTCP packet size (avg_rtcp_size) divided by 25%
367 of the RTCP bandwidth (rtcp_bw), and the constant n is set to the
368 number of senders.
niklase@google.com470e71d2011-07-07 08:21:25 +0000369
danilchap162abd32015-12-10 02:39:40 -0800370 if we receive only
371 If we_sent is not true, the constant C is set
372 to the average RTCP packet size divided by 75% of the RTCP
373 bandwidth. The constant n is set to the number of receivers
374 (members - senders). If the number of senders is greater than
375 25%, senders and receivers are treated together.
niklase@google.com470e71d2011-07-07 08:21:25 +0000376
danilchap162abd32015-12-10 02:39:40 -0800377 reconsideration NOT required for peer-to-peer
378 "timer reconsideration" is
379 employed. This algorithm implements a simple back-off mechanism
380 which causes users to hold back RTCP packet transmission if the
381 group sizes are increasing.
niklase@google.com470e71d2011-07-07 08:21:25 +0000382
danilchap162abd32015-12-10 02:39:40 -0800383 n = number of members
384 C = avg_size/(rtcpBW/4)
niklase@google.com470e71d2011-07-07 08:21:25 +0000385
danilchap162abd32015-12-10 02:39:40 -0800386 3. The deterministic calculated interval Td is set to max(Tmin, n*C).
niklase@google.com470e71d2011-07-07 08:21:25 +0000387
danilchap162abd32015-12-10 02:39:40 -0800388 4. The calculated interval T is set to a number uniformly distributed
389 between 0.5 and 1.5 times the deterministic calculated interval.
niklase@google.com470e71d2011-07-07 08:21:25 +0000390
danilchap162abd32015-12-10 02:39:40 -0800391 5. The resulting value of T is divided by e-3/2=1.21828 to compensate
392 for the fact that the timer reconsideration algorithm converges to
393 a value of the RTCP bandwidth below the intended average
394 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000395
Erik Språng242e22b2015-05-11 10:17:43 +0200396 int64_t now = clock_->TimeInMilliseconds();
xians@webrtc.org8738d272011-11-25 13:43:53 +0000397
danilchap56036ff2016-03-22 11:14:09 -0700398 rtc::CritScope lock(&critical_section_rtcp_sender_);
xians@webrtc.org8738d272011-11-25 13:43:53 +0000399
pbosda903ea2015-10-02 02:36:56 -0700400 if (method_ == RtcpMode::kOff)
niklase@google.com470e71d2011-07-07 08:21:25 +0000401 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000402
Erik Språng242e22b2015-05-11 10:17:43 +0200403 if (!audio_ && sendKeyframeBeforeRTP) {
Erik Språng61be2a42015-04-27 13:32:52 +0200404 // for video key-frames we want to send the RTCP before the large key-frame
405 // if we have a 100 ms margin
406 now += RTCP_SEND_BEFORE_KEY_FRAME_MS;
407 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000408
Erik Språng242e22b2015-05-11 10:17:43 +0200409 if (now >= next_time_to_send_rtcp_) {
Erik Språng61be2a42015-04-27 13:32:52 +0200410 return true;
411 } else if (now < 0x0000ffff &&
Erik Språng242e22b2015-05-11 10:17:43 +0200412 next_time_to_send_rtcp_ > 0xffff0000) { // 65 sec margin
Erik Språng61be2a42015-04-27 13:32:52 +0200413 // wrap
414 return true;
415 }
416 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000417}
418
danilchap56036ff2016-03-22 11:14:09 -0700419std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSR(const RtcpContext& ctx) {
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200420 // Timestamp shouldn't be estimated before first media frame.
421 RTC_DCHECK_GE(last_frame_capture_time_ms_, 0);
Erik Språng61be2a42015-04-27 13:32:52 +0200422 // The timestamp of this RTCP packet should be estimated as the timestamp of
423 // the frame being captured at this moment. We are calculating that
424 // timestamp as the last frame's timestamp + the time since the last frame
425 // was captured.
Ilya Nikolaevskiy5e58bcb2018-10-24 13:34:32 +0200426 int rtp_rate = rtp_clock_rates_khz_[last_payload_type_];
427 if (rtp_rate <= 0) {
428 rtp_rate =
429 (audio_ ? kBogusRtpRateForAudioRtcp : kVideoPayloadTypeFrequency) /
430 1000;
431 }
Erik Språngbdc0b0d2015-06-22 15:21:24 +0200432 uint32_t rtp_timestamp =
danilchap71fead22016-08-18 02:01:49 -0700433 timestamp_offset_ + last_rtp_timestamp_ +
solenbergb19d2882016-10-03 06:22:25 -0700434 (clock_->TimeInMilliseconds() - last_frame_capture_time_ms_) * rtp_rate;
niklase@google.com470e71d2011-07-07 08:21:25 +0000435
Erik Språngf7c57762015-12-04 10:40:35 +0100436 rtcp::SenderReport* report = new rtcp::SenderReport();
danilchap822a16f2016-09-27 09:27:47 -0700437 report->SetSenderSsrc(ssrc_);
danilchap51813b32016-12-16 02:44:36 -0800438 report->SetNtp(ctx.now_);
danilchap822a16f2016-09-27 09:27:47 -0700439 report->SetRtpTimestamp(rtp_timestamp);
440 report->SetPacketCount(ctx.feedback_state_.packets_sent);
441 report->SetOctetCount(ctx.feedback_state_.media_bytes_sent);
danilchap96b69bd2017-07-25 09:15:14 -0700442 report->SetReportBlocks(CreateReportBlocks(ctx.feedback_state_));
Erik Språngf7c57762015-12-04 10:40:35 +0100443
danilchap56036ff2016-03-22 11:14:09 -0700444 return std::unique_ptr<rtcp::RtcpPacket>(report);
niklase@google.com470e71d2011-07-07 08:21:25 +0000445}
446
danilchap56036ff2016-03-22 11:14:09 -0700447std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES(
Erik Språngf7c57762015-12-04 10:40:35 +0100448 const RtcpContext& ctx) {
Erik Språng0ea42d32015-06-25 14:46:16 +0200449 size_t length_cname = cname_.length();
kwiberg352444f2016-11-28 15:58:53 -0800450 RTC_CHECK_LT(length_cname, RTCP_CNAME_SIZE);
niklase@google.com470e71d2011-07-07 08:21:25 +0000451
Erik Språngf7c57762015-12-04 10:40:35 +0100452 rtcp::Sdes* sdes = new rtcp::Sdes();
danilchap822a16f2016-09-27 09:27:47 -0700453 sdes->AddCName(ssrc_, cname_);
Erik Språng0ea42d32015-06-25 14:46:16 +0200454
danilchap74e8df8f2017-03-16 08:04:08 -0700455 for (const auto& it : csrc_cnames_)
456 RTC_CHECK(sdes->AddCName(it.first, it.second));
Erik Språng0ea42d32015-06-25 14:46:16 +0200457
danilchap56036ff2016-03-22 11:14:09 -0700458 return std::unique_ptr<rtcp::RtcpPacket>(sdes);
niklase@google.com470e71d2011-07-07 08:21:25 +0000459}
460
danilchap56036ff2016-03-22 11:14:09 -0700461std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildRR(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100462 rtcp::ReceiverReport* report = new rtcp::ReceiverReport();
danilchap822a16f2016-09-27 09:27:47 -0700463 report->SetSenderSsrc(ssrc_);
danilchap96b69bd2017-07-25 09:15:14 -0700464 report->SetReportBlocks(CreateReportBlocks(ctx.feedback_state_));
Erik Språng61be2a42015-04-27 13:32:52 +0200465
danilchap56036ff2016-03-22 11:14:09 -0700466 return std::unique_ptr<rtcp::RtcpPacket>(report);
niklase@google.com470e71d2011-07-07 08:21:25 +0000467}
468
danilchap56036ff2016-03-22 11:14:09 -0700469std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildPLI(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100470 rtcp::Pli* pli = new rtcp::Pli();
danilchap822a16f2016-09-27 09:27:47 -0700471 pli->SetSenderSsrc(ssrc_);
472 pli->SetMediaSsrc(remote_ssrc_);
Erik Språng61be2a42015-04-27 13:32:52 +0200473
Erik Språng242e22b2015-05-11 10:17:43 +0200474 ++packet_type_counter_.pli_packets;
Erik Språng242e22b2015-05-11 10:17:43 +0200475
danilchap56036ff2016-03-22 11:14:09 -0700476 return std::unique_ptr<rtcp::RtcpPacket>(pli);
Erik Språng61be2a42015-04-27 13:32:52 +0200477}
478
danilchap56036ff2016-03-22 11:14:09 -0700479std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildFIR(const RtcpContext& ctx) {
danilchap498ee8e2017-02-08 05:24:31 -0800480 ++sequence_number_fir_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000481
Erik Språngf7c57762015-12-04 10:40:35 +0100482 rtcp::Fir* fir = new rtcp::Fir();
danilchap822a16f2016-09-27 09:27:47 -0700483 fir->SetSenderSsrc(ssrc_);
484 fir->AddRequestTo(remote_ssrc_, sequence_number_fir_);
Erik Språng242e22b2015-05-11 10:17:43 +0200485
Erik Språng242e22b2015-05-11 10:17:43 +0200486 ++packet_type_counter_.fir_packets;
Erik Språng242e22b2015-05-11 10:17:43 +0200487
danilchap56036ff2016-03-22 11:14:09 -0700488 return std::unique_ptr<rtcp::RtcpPacket>(fir);
niklase@google.com470e71d2011-07-07 08:21:25 +0000489}
490
danilchap56036ff2016-03-22 11:14:09 -0700491std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildREMB(
Erik Språngf7c57762015-12-04 10:40:35 +0100492 const RtcpContext& ctx) {
493 rtcp::Remb* remb = new rtcp::Remb();
danilchap822a16f2016-09-27 09:27:47 -0700494 remb->SetSenderSsrc(ssrc_);
495 remb->SetBitrateBps(remb_bitrate_);
496 remb->SetSsrcs(remb_ssrcs_);
Erik Språng61be2a42015-04-27 13:32:52 +0200497
danilchap56036ff2016-03-22 11:14:09 -0700498 return std::unique_ptr<rtcp::RtcpPacket>(remb);
pwestin@webrtc.org741da942011-09-20 13:52:04 +0000499}
500
Erik Språng61be2a42015-04-27 13:32:52 +0200501void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) {
danilchap56036ff2016-03-22 11:14:09 -0700502 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap2b616392016-08-18 06:17:42 -0700503 tmmbr_send_bps_ = target_bitrate;
mflodman@webrtc.org117c1192012-01-13 08:52:58 +0000504}
505
danilchap56036ff2016-03-22 11:14:09 -0700506std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
Erik Språngf7c57762015-12-04 10:40:35 +0100507 const RtcpContext& ctx) {
508 if (ctx.feedback_state_.module == nullptr)
509 return nullptr;
Erik Språng61be2a42015-04-27 13:32:52 +0200510 // Before sending the TMMBR check the received TMMBN, only an owner is
511 // allowed to raise the bitrate:
512 // * If the sender is an owner of the TMMBN -> send TMMBR
513 // * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
niklase@google.com470e71d2011-07-07 08:21:25 +0000514
Erik Språng61be2a42015-04-27 13:32:52 +0200515 // get current bounding set from RTCP receiver
danilchap2b616392016-08-18 06:17:42 -0700516 bool tmmbr_owner = false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000517
Erik Språng242e22b2015-05-11 10:17:43 +0200518 // holding critical_section_rtcp_sender_ while calling RTCPreceiver which
519 // will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
Erik Språng61be2a42015-04-27 13:32:52 +0200520 // since RTCPreceiver is not doing the reverse we should be fine
danilchap2b616392016-08-18 06:17:42 -0700521 std::vector<rtcp::TmmbItem> candidates =
522 ctx.feedback_state_.module->BoundingSet(&tmmbr_owner);
niklase@google.com470e71d2011-07-07 08:21:25 +0000523
danilchap2b616392016-08-18 06:17:42 -0700524 if (!candidates.empty()) {
525 for (const auto& candidate : candidates) {
526 if (candidate.bitrate_bps() == tmmbr_send_bps_ &&
527 candidate.packet_overhead() == packet_oh_send_) {
Erik Språngf7c57762015-12-04 10:40:35 +0100528 // Do not send the same tuple.
529 return nullptr;
Erik Språng61be2a42015-04-27 13:32:52 +0200530 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000531 }
danilchap2b616392016-08-18 06:17:42 -0700532 if (!tmmbr_owner) {
533 // Use received bounding set as candidate set.
534 // Add current tuple.
535 candidates.emplace_back(ssrc_, tmmbr_send_bps_, packet_oh_send_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000536
danilchap2b616392016-08-18 06:17:42 -0700537 // Find bounding set.
danilchap2f69ce92016-08-16 03:21:38 -0700538 std::vector<rtcp::TmmbItem> bounding =
539 TMMBRHelp::FindBoundingSet(std::move(candidates));
danilchap2b616392016-08-18 06:17:42 -0700540 tmmbr_owner = TMMBRHelp::IsOwner(bounding, ssrc_);
541 if (!tmmbr_owner) {
Erik Språngf7c57762015-12-04 10:40:35 +0100542 // Did not enter bounding set, no meaning to send this request.
543 return nullptr;
Erik Språng61be2a42015-04-27 13:32:52 +0200544 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000545 }
Erik Språng61be2a42015-04-27 13:32:52 +0200546 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000547
danilchap2b616392016-08-18 06:17:42 -0700548 if (!tmmbr_send_bps_)
Erik Språngf7c57762015-12-04 10:40:35 +0100549 return nullptr;
sprang81a3e602015-08-21 05:30:11 -0700550
Erik Språngf7c57762015-12-04 10:40:35 +0100551 rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr();
danilchap822a16f2016-09-27 09:27:47 -0700552 tmmbr->SetSenderSsrc(ssrc_);
danilchapf174e3a2016-02-05 04:56:36 -0800553 rtcp::TmmbItem request;
554 request.set_ssrc(remote_ssrc_);
danilchap2b616392016-08-18 06:17:42 -0700555 request.set_bitrate_bps(tmmbr_send_bps_);
danilchapf174e3a2016-02-05 04:56:36 -0800556 request.set_packet_overhead(packet_oh_send_);
danilchap822a16f2016-09-27 09:27:47 -0700557 tmmbr->AddTmmbr(request);
Erik Språngf7c57762015-12-04 10:40:35 +0100558
danilchap56036ff2016-03-22 11:14:09 -0700559 return std::unique_ptr<rtcp::RtcpPacket>(tmmbr);
Erik Språng61be2a42015-04-27 13:32:52 +0200560}
561
danilchap56036ff2016-03-22 11:14:09 -0700562std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN(
Erik Språngf7c57762015-12-04 10:40:35 +0100563 const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100564 rtcp::Tmmbn* tmmbn = new rtcp::Tmmbn();
danilchap822a16f2016-09-27 09:27:47 -0700565 tmmbn->SetSenderSsrc(ssrc_);
danilchap6eaa3a42016-05-09 10:59:50 -0700566 for (const rtcp::TmmbItem& tmmbr : tmmbn_to_send_) {
567 if (tmmbr.bitrate_bps() > 0) {
danilchap822a16f2016-09-27 09:27:47 -0700568 tmmbn->AddTmmbr(tmmbr);
asapersson@webrtc.org2dd31342014-10-29 12:42:30 +0000569 }
Erik Språng61be2a42015-04-27 13:32:52 +0200570 }
sprangd83df502015-08-27 01:05:08 -0700571
danilchap56036ff2016-03-22 11:14:09 -0700572 return std::unique_ptr<rtcp::RtcpPacket>(tmmbn);
niklase@google.com470e71d2011-07-07 08:21:25 +0000573}
574
danilchap56036ff2016-03-22 11:14:09 -0700575std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildAPP(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100576 rtcp::App* app = new rtcp::App();
danilchap822a16f2016-09-27 09:27:47 -0700577 app->SetSsrc(ssrc_);
578 app->SetSubType(app_sub_type_);
579 app->SetName(app_name_);
580 app->SetData(app_data_.get(), app_length_);
Erik Språng521875a2015-09-01 10:11:16 +0200581
danilchap56036ff2016-03-22 11:14:09 -0700582 return std::unique_ptr<rtcp::RtcpPacket>(app);
Erik Språng61be2a42015-04-27 13:32:52 +0200583}
584
danilchap56036ff2016-03-22 11:14:09 -0700585std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildNACK(
Erik Språngf7c57762015-12-04 10:40:35 +0100586 const RtcpContext& ctx) {
587 rtcp::Nack* nack = new rtcp::Nack();
danilchap822a16f2016-09-27 09:27:47 -0700588 nack->SetSenderSsrc(ssrc_);
589 nack->SetMediaSsrc(remote_ssrc_);
590 nack->SetPacketIds(ctx.nack_list_, ctx.nack_size_);
Erik Språng61be2a42015-04-27 13:32:52 +0200591
592 // Report stats.
Erik Språngf7c57762015-12-04 10:40:35 +0100593 for (int idx = 0; idx < ctx.nack_size_; ++idx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100594 nack_stats_.ReportRequest(ctx.nack_list_[idx]);
Erik Språng61be2a42015-04-27 13:32:52 +0200595 }
Erik Språng61be2a42015-04-27 13:32:52 +0200596 packet_type_counter_.nack_requests = nack_stats_.requests();
597 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests();
Erik Språng242e22b2015-05-11 10:17:43 +0200598
Erik Språng242e22b2015-05-11 10:17:43 +0200599 ++packet_type_counter_.nack_packets;
Erik Språng242e22b2015-05-11 10:17:43 +0200600
danilchap56036ff2016-03-22 11:14:09 -0700601 return std::unique_ptr<rtcp::RtcpPacket>(nack);
Erik Språng61be2a42015-04-27 13:32:52 +0200602}
603
danilchap56036ff2016-03-22 11:14:09 -0700604std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildBYE(const RtcpContext& ctx) {
Erik Språngf7c57762015-12-04 10:40:35 +0100605 rtcp::Bye* bye = new rtcp::Bye();
danilchap822a16f2016-09-27 09:27:47 -0700606 bye->SetSenderSsrc(ssrc_);
607 bye->SetCsrcs(csrcs_);
sprangd8ee4f92015-08-24 03:25:19 -0700608
danilchap56036ff2016-03-22 11:14:09 -0700609 return std::unique_ptr<rtcp::RtcpPacket>(bye);
niklase@google.com470e71d2011-07-07 08:21:25 +0000610}
611
sprang5e38c962016-12-01 05:18:09 -0800612std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildExtendedReports(
Erik Språngf7c57762015-12-04 10:40:35 +0100613 const RtcpContext& ctx) {
sprang5e38c962016-12-01 05:18:09 -0800614 std::unique_ptr<rtcp::ExtendedReports> xr(new rtcp::ExtendedReports());
danilchap822a16f2016-09-27 09:27:47 -0700615 xr->SetSenderSsrc(ssrc_);
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000616
sprang5e38c962016-12-01 05:18:09 -0800617 if (!sending_ && xr_send_receiver_reference_time_enabled_) {
618 rtcp::Rrtr rrtr;
danilchap51813b32016-12-16 02:44:36 -0800619 rrtr.SetNtp(ctx.now_);
sprang5e38c962016-12-01 05:18:09 -0800620 xr->SetRrtr(rrtr);
621 }
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000622
Mirta Dvornicicb1f063d2018-04-16 11:16:21 +0200623 for (const rtcp::ReceiveTimeInfo& rti : ctx.feedback_state_.last_xr_rtis) {
624 xr->AddDlrrItem(rti);
sprang5e38c962016-12-01 05:18:09 -0800625 }
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000626
Erik Språng8782a582018-10-04 15:36:06 +0200627 if (send_video_bitrate_allocation_) {
sprang5e38c962016-12-01 05:18:09 -0800628 rtcp::TargetBitrate target_bitrate;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000629
sprang5e38c962016-12-01 05:18:09 -0800630 for (int sl = 0; sl < kMaxSpatialLayers; ++sl) {
631 for (int tl = 0; tl < kMaxTemporalStreams; ++tl) {
Erik Språng8782a582018-10-04 15:36:06 +0200632 if (video_bitrate_allocation_.HasBitrate(sl, tl)) {
erikvarga@webrtc.org01f2ec32017-11-15 14:58:23 +0100633 target_bitrate.AddTargetBitrate(
Erik Språng8782a582018-10-04 15:36:06 +0200634 sl, tl, video_bitrate_allocation_.GetBitrate(sl, tl) / 1000);
erikvarga@webrtc.org01f2ec32017-11-15 14:58:23 +0100635 }
sprang5e38c962016-12-01 05:18:09 -0800636 }
637 }
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000638
sprang5e38c962016-12-01 05:18:09 -0800639 xr->SetTargetBitrate(target_bitrate);
Erik Språng8782a582018-10-04 15:36:06 +0200640 send_video_bitrate_allocation_ = false;
sprang5e38c962016-12-01 05:18:09 -0800641 }
Erik Språngca28fdc2015-08-31 14:00:50 +0200642
sprang5e38c962016-12-01 05:18:09 -0800643 return std::move(xr);
niklase@google.com470e71d2011-07-07 08:21:25 +0000644}
645
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +0000646int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state,
Erik Språng242e22b2015-05-11 10:17:43 +0200647 RTCPPacketType packetType,
648 int32_t nack_size,
nissecd386eb2017-03-14 08:54:43 -0700649 const uint16_t* nack_list) {
Erik Språng242e22b2015-05-11 10:17:43 +0200650 return SendCompoundRTCP(
651 feedback_state, std::set<RTCPPacketType>(&packetType, &packetType + 1),
nissecd386eb2017-03-14 08:54:43 -0700652 nack_size, nack_list);
Erik Språng242e22b2015-05-11 10:17:43 +0200653}
654
655int32_t RTCPSender::SendCompoundRTCP(
656 const FeedbackState& feedback_state,
Erik Språngf7c57762015-12-04 10:40:35 +0100657 const std::set<RTCPPacketType>& packet_types,
Erik Språng242e22b2015-05-11 10:17:43 +0200658 int32_t nack_size,
nissecd386eb2017-03-14 08:54:43 -0700659 const uint16_t* nack_list) {
terelius429c3452016-01-21 05:42:04 -0800660 PacketContainer container(transport_, event_log_);
nisse6f142eb2017-02-21 07:32:47 -0800661 size_t max_packet_size;
662
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000663 {
danilchap56036ff2016-03-22 11:14:09 -0700664 rtc::CritScope lock(&critical_section_rtcp_sender_);
pbosda903ea2015-10-02 02:36:56 -0700665 if (method_ == RtcpMode::kOff) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100666 RTC_LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
Erik Språng61be2a42015-04-27 13:32:52 +0200667 return -1;
pwestin@webrtc.org8edb39d2011-12-22 07:40:33 +0000668 }
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200669 // Add all flags as volatile. Non volatile entries will not be overwritten.
670 // All new volatile flags added will be consumed by the end of this call.
671 SetFlags(packet_types, true);
672
673 // Prevent sending streams to send SR before any media has been sent.
674 const bool can_calculate_rtp_timestamp = (last_frame_capture_time_ms_ >= 0);
675 if (!can_calculate_rtp_timestamp) {
676 bool consumed_sr_flag = ConsumeFlag(kRtcpSr);
677 bool consumed_report_flag = sending_ && ConsumeFlag(kRtcpReport);
678 bool sender_report = consumed_report_flag || consumed_sr_flag;
679 if (sender_report && AllVolatileFlagsConsumed()) {
680 // This call was for Sender Report and nothing else.
681 return 0;
682 }
683 if (sending_ && method_ == RtcpMode::kCompound) {
684 // Not allowed to send any RTCP packet without sender report.
685 return -1;
686 }
687 }
688
689 if (packet_type_counter_.first_packet_time_ms == -1)
690 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds();
Erik Språngf7c57762015-12-04 10:40:35 +0100691
692 // We need to send our NTP even if we haven't received any reports.
nissecd386eb2017-03-14 08:54:43 -0700693 RtcpContext context(feedback_state, nack_size, nack_list,
danilchap37953762017-02-09 11:15:25 -0800694 clock_->CurrentNtpTime());
Erik Språngf7c57762015-12-04 10:40:35 +0100695
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200696 PrepareReport(feedback_state);
Erik Språngf7c57762015-12-04 10:40:35 +0100697
danilchap56036ff2016-03-22 11:14:09 -0700698 std::unique_ptr<rtcp::RtcpPacket> packet_bye;
aleungbroadsoft0e2e50c2016-02-18 08:33:26 -0800699
Erik Språngf7c57762015-12-04 10:40:35 +0100700 auto it = report_flags_.begin();
701 while (it != report_flags_.end()) {
702 auto builder_it = builders_.find(it->type);
sprang5e38c962016-12-01 05:18:09 -0800703 RTC_DCHECK(builder_it != builders_.end())
704 << "Could not find builder for packet type " << it->type;
Erik Språngf7c57762015-12-04 10:40:35 +0100705 if (it->is_volatile) {
706 report_flags_.erase(it++);
707 } else {
708 ++it;
709 }
710
711 BuilderFunc func = builder_it->second;
danilchap56036ff2016-03-22 11:14:09 -0700712 std::unique_ptr<rtcp::RtcpPacket> packet = (this->*func)(context);
Erik Språngf7c57762015-12-04 10:40:35 +0100713 if (packet.get() == nullptr)
714 return -1;
aleungbroadsoft0e2e50c2016-02-18 08:33:26 -0800715 // If there is a BYE, don't append now - save it and append it
716 // at the end later.
717 if (builder_it->first == kRtcpBye) {
718 packet_bye = std::move(packet);
719 } else {
720 container.Append(packet.release());
721 }
722 }
723
724 // Append the BYE now at the end
725 if (packet_bye) {
726 container.Append(packet_bye.release());
Erik Språngf7c57762015-12-04 10:40:35 +0100727 }
728
729 if (packet_type_counter_observer_ != nullptr) {
730 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated(
731 remote_ssrc_, packet_type_counter_);
732 }
733
734 RTC_DCHECK(AllVolatileFlagsConsumed());
nisse6f142eb2017-02-21 07:32:47 -0800735 max_packet_size = max_packet_size_;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000736 }
Erik Språng61be2a42015-04-27 13:32:52 +0200737
nisse6f142eb2017-02-21 07:32:47 -0800738 size_t bytes_sent = container.SendPackets(max_packet_size);
Erik Språngf7c57762015-12-04 10:40:35 +0100739 return bytes_sent == 0 ? -1 : 0;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000740}
741
Danil Chapovalov70ffead2016-07-20 15:26:59 +0200742void RTCPSender::PrepareReport(const FeedbackState& feedback_state) {
Erik Språng242e22b2015-05-11 10:17:43 +0200743 bool generate_report;
744 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) {
745 // Report type already explicitly set, don't automatically populate.
746 generate_report = true;
henrikg91d6ede2015-09-17 00:24:34 -0700747 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false);
Erik Språng242e22b2015-05-11 10:17:43 +0200748 } else {
749 generate_report =
pbosda903ea2015-10-02 02:36:56 -0700750 (ConsumeFlag(kRtcpReport) && method_ == RtcpMode::kReducedSize) ||
751 method_ == RtcpMode::kCompound;
Erik Språng242e22b2015-05-11 10:17:43 +0200752 if (generate_report)
753 SetFlag(sending_ ? kRtcpSr : kRtcpRr, true);
asapersson@webrtc.orgd08d3892014-12-16 12:03:11 +0000754 }
755
Erik Språng0ea42d32015-06-25 14:46:16 +0200756 if (IsFlagPresent(kRtcpSr) || (IsFlagPresent(kRtcpRr) && !cname_.empty()))
Erik Språng242e22b2015-05-11 10:17:43 +0200757 SetFlag(kRtcpSdes, true);
758
Erik Språng242e22b2015-05-11 10:17:43 +0200759 if (generate_report) {
sprang5e38c962016-12-01 05:18:09 -0800760 if ((!sending_ && xr_send_receiver_reference_time_enabled_) ||
Erik Språng8782a582018-10-04 15:36:06 +0200761 !feedback_state.last_xr_rtis.empty() ||
762 send_video_bitrate_allocation_) {
sprang5e38c962016-12-01 05:18:09 -0800763 SetFlag(kRtcpAnyExtendedReports, true);
764 }
Erik Språng242e22b2015-05-11 10:17:43 +0200765
766 // generate next time to send an RTCP report
Jiawei Ou3587b832018-01-31 22:08:26 -0800767 uint32_t minIntervalMs =
768 rtc::dchecked_cast<uint32_t>(interval_config_.audio_interval_ms);
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000769
danilchap47a740b2015-12-15 00:30:07 -0800770 if (!audio_) {
Erik Språng242e22b2015-05-11 10:17:43 +0200771 if (sending_) {
Erik Språng61be2a42015-04-27 13:32:52 +0200772 // Calculate bandwidth for video; 360 / send bandwidth in kbit/s.
773 uint32_t send_bitrate_kbit = feedback_state.send_bitrate / 1000;
774 if (send_bitrate_kbit != 0)
775 minIntervalMs = 360000 / send_bitrate_kbit;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000776 }
Jiawei Ou3587b832018-01-31 22:08:26 -0800777 if (minIntervalMs >
778 rtc::dchecked_cast<uint32_t>(interval_config_.video_interval_ms)) {
779 minIntervalMs =
780 rtc::dchecked_cast<uint32_t>(interval_config_.video_interval_ms);
781 }
Erik Språng61be2a42015-04-27 13:32:52 +0200782 }
Jiawei Ou3587b832018-01-31 22:08:26 -0800783
danilchap47a740b2015-12-15 00:30:07 -0800784 // The interval between RTCP packets is varied randomly over the
785 // range [1/2,3/2] times the calculated interval.
786 uint32_t timeToNext =
787 random_.Rand(minIntervalMs * 1 / 2, minIntervalMs * 3 / 2);
Erik Språng242e22b2015-05-11 10:17:43 +0200788 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds() + timeToNext;
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000789
danilchap96b69bd2017-07-25 09:15:14 -0700790 // RtcpSender expected to be used for sending either just sender reports
791 // or just receiver reports.
792 RTC_DCHECK(!(IsFlagPresent(kRtcpSr) && IsFlagPresent(kRtcpRr)));
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000793 }
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +0000794}
795
danilchap96b69bd2017-07-25 09:15:14 -0700796std::vector<rtcp::ReportBlock> RTCPSender::CreateReportBlocks(
797 const FeedbackState& feedback_state) {
798 std::vector<rtcp::ReportBlock> result;
799 if (!receive_statistics_)
800 return result;
danilchapa72e7342015-12-22 08:07:45 -0800801
danilchapf5f793c2017-07-27 04:44:18 -0700802 // TODO(danilchap): Support sending more than |RTCP_MAX_REPORT_BLOCKS| per
803 // compound rtcp packet when single rtcp module is used for multiple media
804 // streams.
805 result = receive_statistics_->RtcpReportBlocks(RTCP_MAX_REPORT_BLOCKS);
danilchap96b69bd2017-07-25 09:15:14 -0700806
807 if (!result.empty() && ((feedback_state.last_rr_ntp_secs != 0) ||
808 (feedback_state.last_rr_ntp_frac != 0))) {
809 // Get our NTP as late as possible to avoid a race.
810 uint32_t now = CompactNtp(clock_->CurrentNtpTime());
811
812 uint32_t receive_time = feedback_state.last_rr_ntp_secs & 0x0000FFFF;
813 receive_time <<= 16;
814 receive_time += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16;
815
816 uint32_t delay_since_last_sr = now - receive_time;
817 // TODO(danilchap): Instead of setting same value on all report blocks,
818 // set only when media_ssrc match sender ssrc of the sender report
819 // remote times were taken from.
820 for (auto& report_block : result) {
821 report_block.SetLastSr(feedback_state.remote_sr);
822 report_block.SetDelayLastSr(delay_since_last_sr);
823 }
danilchapa72e7342015-12-22 08:07:45 -0800824 }
danilchap96b69bd2017-07-25 09:15:14 -0700825 return result;
niklase@google.com470e71d2011-07-07 08:21:25 +0000826}
827
pbos@webrtc.org9334ac22014-11-24 08:25:50 +0000828void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
kwiberg352444f2016-11-28 15:58:53 -0800829 RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize);
danilchap56036ff2016-03-22 11:14:09 -0700830 rtc::CritScope lock(&critical_section_rtcp_sender_);
pbos@webrtc.org9334ac22014-11-24 08:25:50 +0000831 csrcs_ = csrcs;
niklase@google.com470e71d2011-07-07 08:21:25 +0000832}
833
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000834int32_t RTCPSender::SetApplicationSpecificData(uint8_t subType,
835 uint32_t name,
836 const uint8_t* data,
837 uint16_t length) {
Erik Språng61be2a42015-04-27 13:32:52 +0200838 if (length % 4 != 0) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100839 RTC_LOG(LS_ERROR) << "Failed to SetApplicationSpecificData.";
Erik Språng61be2a42015-04-27 13:32:52 +0200840 return -1;
841 }
danilchap56036ff2016-03-22 11:14:09 -0700842 rtc::CritScope lock(&critical_section_rtcp_sender_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000843
Erik Språng242e22b2015-05-11 10:17:43 +0200844 SetFlag(kRtcpApp, true);
845 app_sub_type_ = subType;
846 app_name_ = name;
847 app_data_.reset(new uint8_t[length]);
848 app_length_ = length;
849 memcpy(app_data_.get(), data, length);
Erik Språng61be2a42015-04-27 13:32:52 +0200850 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000851}
852
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000853void RTCPSender::SendRtcpXrReceiverReferenceTime(bool enable) {
danilchap56036ff2016-03-22 11:14:09 -0700854 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200855 xr_send_receiver_reference_time_enabled_ = enable;
asapersson@webrtc.org8469f7b2013-10-02 13:15:34 +0000856}
857
asapersson@webrtc.org8d02f5d2013-11-21 08:57:04 +0000858bool RTCPSender::RtcpXrReceiverReferenceTime() const {
danilchap56036ff2016-03-22 11:14:09 -0700859 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng242e22b2015-05-11 10:17:43 +0200860 return xr_send_receiver_reference_time_enabled_;
asapersson@webrtc.org8d02f5d2013-11-21 08:57:04 +0000861}
862
danilchap853ecb22016-08-22 08:26:15 -0700863void RTCPSender::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) {
danilchap56036ff2016-03-22 11:14:09 -0700864 rtc::CritScope lock(&critical_section_rtcp_sender_);
danilchap853ecb22016-08-22 08:26:15 -0700865 tmmbn_to_send_ = std::move(bounding_set);
danilchap6eaa3a42016-05-09 10:59:50 -0700866 SetFlag(kRtcpTmmbn, true);
niklase@google.com470e71d2011-07-07 08:21:25 +0000867}
Erik Språng61be2a42015-04-27 13:32:52 +0200868
sprang5e38c962016-12-01 05:18:09 -0800869void RTCPSender::SetFlag(uint32_t type, bool is_volatile) {
870 if (type & kRtcpAnyExtendedReports) {
871 report_flags_.insert(ReportFlag(kRtcpAnyExtendedReports, is_volatile));
872 } else {
873 report_flags_.insert(ReportFlag(type, is_volatile));
874 }
Erik Språng242e22b2015-05-11 10:17:43 +0200875}
876
877void RTCPSender::SetFlags(const std::set<RTCPPacketType>& types,
878 bool is_volatile) {
879 for (RTCPPacketType type : types)
880 SetFlag(type, is_volatile);
881}
882
sprang5e38c962016-12-01 05:18:09 -0800883bool RTCPSender::IsFlagPresent(uint32_t type) const {
Erik Språng242e22b2015-05-11 10:17:43 +0200884 return report_flags_.find(ReportFlag(type, false)) != report_flags_.end();
885}
886
sprang5e38c962016-12-01 05:18:09 -0800887bool RTCPSender::ConsumeFlag(uint32_t type, bool forced) {
Erik Språng242e22b2015-05-11 10:17:43 +0200888 auto it = report_flags_.find(ReportFlag(type, false));
889 if (it == report_flags_.end())
890 return false;
891 if (it->is_volatile || forced)
892 report_flags_.erase((it));
893 return true;
894}
895
896bool RTCPSender::AllVolatileFlagsConsumed() const {
897 for (const ReportFlag& flag : report_flags_) {
898 if (flag.is_volatile)
899 return false;
900 }
901 return true;
902}
903
Erik Språng566124a2018-04-23 12:32:22 +0200904void RTCPSender::SetVideoBitrateAllocation(
905 const VideoBitrateAllocation& bitrate) {
sprang5e38c962016-12-01 05:18:09 -0800906 rtc::CritScope lock(&critical_section_rtcp_sender_);
Erik Språng8782a582018-10-04 15:36:06 +0200907 // Check if this allocation is first ever, or has a different set of
908 // spatial/temporal layers signaled and enabled, if so trigger an rtcp report
909 // as soon as possible.
Erik Språng1cd73912018-10-05 12:57:59 +0200910 absl::optional<VideoBitrateAllocation> new_bitrate =
911 CheckAndUpdateLayerStructure(bitrate);
912 if (new_bitrate) {
913 video_bitrate_allocation_ = *new_bitrate;
Erik Språng8782a582018-10-04 15:36:06 +0200914 next_time_to_send_rtcp_ = clock_->TimeInMilliseconds();
Erik Språng1cd73912018-10-05 12:57:59 +0200915 } else {
916 video_bitrate_allocation_ = bitrate;
Erik Språng8782a582018-10-04 15:36:06 +0200917 }
918
Erik Språng8782a582018-10-04 15:36:06 +0200919 send_video_bitrate_allocation_ = true;
sprang5e38c962016-12-01 05:18:09 -0800920 SetFlag(kRtcpAnyExtendedReports, true);
921}
922
Erik Språng1cd73912018-10-05 12:57:59 +0200923absl::optional<VideoBitrateAllocation> RTCPSender::CheckAndUpdateLayerStructure(
Erik Språng8782a582018-10-04 15:36:06 +0200924 const VideoBitrateAllocation& bitrate) const {
Erik Språng1cd73912018-10-05 12:57:59 +0200925 absl::optional<VideoBitrateAllocation> updated_bitrate;
Erik Språng8782a582018-10-04 15:36:06 +0200926 for (size_t si = 0; si < kMaxSpatialLayers; ++si) {
927 for (size_t ti = 0; ti < kMaxTemporalStreams; ++ti) {
Erik Språng1cd73912018-10-05 12:57:59 +0200928 if (!updated_bitrate &&
929 (bitrate.HasBitrate(si, ti) !=
930 video_bitrate_allocation_.HasBitrate(si, ti) ||
931 (bitrate.GetBitrate(si, ti) == 0) !=
932 (video_bitrate_allocation_.GetBitrate(si, ti) == 0))) {
933 updated_bitrate = bitrate;
934 }
935 if (video_bitrate_allocation_.GetBitrate(si, ti) > 0 &&
936 bitrate.GetBitrate(si, ti) == 0) {
937 // Make sure this stream disabling is explicitly signaled.
938 updated_bitrate->SetBitrate(si, ti, 0);
Erik Språng8782a582018-10-04 15:36:06 +0200939 }
940 }
941 }
942
Erik Språng1cd73912018-10-05 12:57:59 +0200943 return updated_bitrate;
Erik Språng8782a582018-10-04 15:36:06 +0200944}
945
sprang233bd872015-09-08 13:25:16 -0700946bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) {
nisse6f142eb2017-02-21 07:32:47 -0800947 size_t max_packet_size;
stefanb77c7162017-02-06 06:29:38 -0800948 {
949 rtc::CritScope lock(&critical_section_rtcp_sender_);
950 if (method_ == RtcpMode::kOff)
951 return false;
nisse6f142eb2017-02-21 07:32:47 -0800952 max_packet_size = max_packet_size_;
stefanb77c7162017-02-06 06:29:38 -0800953 }
954
nisse6f142eb2017-02-21 07:32:47 -0800955 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
Danil Chapovalov5c3cc412017-12-07 10:15:53 +0100956 bool send_failure = false;
957 auto callback = [&](rtc::ArrayView<const uint8_t> packet) {
958 if (transport_->SendRtcp(packet.data(), packet.size())) {
959 if (event_log_)
Karl Wiberg918f50c2018-07-05 11:40:33 +0200960 event_log_->Log(absl::make_unique<RtcEventRtcpPacketOutgoing>(packet));
Danil Chapovalov5c3cc412017-12-07 10:15:53 +0100961 } else {
962 send_failure = true;
963 }
964 };
965 return packet.Build(max_packet_size, callback) && !send_failure;
sprang233bd872015-09-08 13:25:16 -0700966}
967
Jiawei Ou3587b832018-01-31 22:08:26 -0800968int64_t RTCPSender::RtcpAudioReportInverval() const {
969 return interval_config_.audio_interval_ms;
970}
971
972int64_t RTCPSender::RtcpVideoReportInverval() const {
973 return interval_config_.video_interval_ms;
974}
975
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000976} // namespace webrtc