2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-01-09 13:54:43 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
|
|
|
|
|
|
2013-05-29 14:27:38 +00:00
|
|
|
#include <string.h>
|
2013-01-16 10:27:33 +00:00
|
|
|
|
2017-07-06 04:38:06 -07:00
|
|
|
#include <algorithm>
|
2015-02-06 13:10:19 +00:00
|
|
|
#include <set>
|
2016-02-26 16:26:20 +01:00
|
|
|
#include <string>
|
2015-02-06 13:10:19 +00:00
|
|
|
|
2013-01-09 13:54:43 +00:00
|
|
|
#include "webrtc/common_types.h"
|
2016-02-26 16:26:20 +01:00
|
|
|
#include "webrtc/config.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/checks.h"
|
|
|
|
|
#include "webrtc/rtc_base/logging.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2013-01-16 10:27:33 +00:00
|
|
|
// Disable warning C4355: 'this' : used in base member initializer list.
|
2012-02-08 23:41:49 +00:00
|
|
|
#pragma warning(disable : 4355)
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
2017-07-06 04:38:06 -07:00
|
|
|
namespace {
|
|
|
|
|
const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5;
|
|
|
|
|
const int64_t kRtpRtcpRttProcessTimeMs = 1000;
|
|
|
|
|
const int64_t kRtpRtcpBitrateProcessTimeMs = 10;
|
|
|
|
|
} // namespace
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-02-26 16:26:20 +01:00
|
|
|
RTPExtensionType StringToRtpExtensionType(const std::string& extension) {
|
2016-05-26 11:24:55 -07:00
|
|
|
if (extension == RtpExtension::kTimestampOffsetUri)
|
2016-02-26 16:26:20 +01:00
|
|
|
return kRtpExtensionTransmissionTimeOffset;
|
2016-05-26 11:24:55 -07:00
|
|
|
if (extension == RtpExtension::kAudioLevelUri)
|
2016-02-26 16:26:20 +01:00
|
|
|
return kRtpExtensionAudioLevel;
|
2016-05-26 11:24:55 -07:00
|
|
|
if (extension == RtpExtension::kAbsSendTimeUri)
|
2016-02-26 16:26:20 +01:00
|
|
|
return kRtpExtensionAbsoluteSendTime;
|
2016-05-26 11:24:55 -07:00
|
|
|
if (extension == RtpExtension::kVideoRotationUri)
|
2016-02-26 16:26:20 +01:00
|
|
|
return kRtpExtensionVideoRotation;
|
2016-05-26 11:24:55 -07:00
|
|
|
if (extension == RtpExtension::kTransportSequenceNumberUri)
|
2016-02-26 16:26:20 +01:00
|
|
|
return kRtpExtensionTransportSequenceNumber;
|
2016-06-08 00:24:21 -07:00
|
|
|
if (extension == RtpExtension::kPlayoutDelayUri)
|
|
|
|
|
return kRtpExtensionPlayoutDelay;
|
2017-04-11 10:34:31 -07:00
|
|
|
if (extension == RtpExtension::kVideoContentTypeUri)
|
|
|
|
|
return kRtpExtensionVideoContentType;
|
2017-06-19 07:18:55 -07:00
|
|
|
if (extension == RtpExtension::kVideoTimingUri)
|
|
|
|
|
return kRtpExtensionVideoTiming;
|
2016-02-26 16:26:20 +01:00
|
|
|
RTC_NOTREACHED() << "Looking up unsupported RTP extension.";
|
|
|
|
|
return kRtpExtensionNone;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-25 04:20:12 -07:00
|
|
|
RtpRtcp::Configuration::Configuration() = default;
|
2013-01-14 10:01:55 +00:00
|
|
|
|
2012-05-11 11:08:54 +00:00
|
|
|
RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) {
|
|
|
|
|
if (configuration.clock) {
|
|
|
|
|
return new ModuleRtpRtcpImpl(configuration);
|
2012-02-15 23:54:59 +00:00
|
|
|
} else {
|
2014-07-11 15:36:26 +00:00
|
|
|
// No clock implementation provided, use default clock.
|
2012-05-11 11:08:54 +00:00
|
|
|
RtpRtcp::Configuration configuration_copy;
|
|
|
|
|
memcpy(&configuration_copy, &configuration,
|
|
|
|
|
sizeof(RtpRtcp::Configuration));
|
2013-01-17 14:01:20 +00:00
|
|
|
configuration_copy.clock = Clock::GetRealTimeClock();
|
2014-07-11 15:36:26 +00:00
|
|
|
return new ModuleRtpRtcpImpl(configuration_copy);
|
2012-05-11 11:08:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 03:36:05 -08:00
|
|
|
// Deprecated.
|
|
|
|
|
int32_t RtpRtcp::SetFecParameters(const FecProtectionParams* delta_params,
|
|
|
|
|
const FecProtectionParams* key_params) {
|
|
|
|
|
RTC_DCHECK(delta_params);
|
|
|
|
|
RTC_DCHECK(key_params);
|
|
|
|
|
return SetFecParameters(*delta_params, *key_params) ? 0 : -1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-11 11:08:54 +00:00
|
|
|
ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
2017-03-20 03:52:39 -07:00
|
|
|
: rtcp_sender_(configuration.audio,
|
2014-06-17 17:32:05 +00:00
|
|
|
configuration.clock,
|
2015-02-19 12:47:00 +00:00
|
|
|
configuration.receive_statistics,
|
2015-09-29 04:45:43 -07:00
|
|
|
configuration.rtcp_packet_type_counter_observer,
|
2016-01-21 05:42:04 -08:00
|
|
|
configuration.event_log,
|
2015-09-29 04:45:43 -07:00
|
|
|
configuration.outgoing_transport),
|
2015-09-17 23:03:57 +02:00
|
|
|
rtcp_receiver_(configuration.clock,
|
2015-04-23 17:53:17 +02:00
|
|
|
configuration.receiver_only,
|
2015-02-19 12:47:00 +00:00
|
|
|
configuration.rtcp_packet_type_counter_observer,
|
2015-02-25 13:50:10 +00:00
|
|
|
configuration.bandwidth_callback,
|
|
|
|
|
configuration.intra_frame_callback,
|
2015-09-24 15:06:57 +02:00
|
|
|
configuration.transport_feedback_callback,
|
2016-12-02 07:29:44 -08:00
|
|
|
configuration.bitrate_allocation_observer,
|
2015-02-19 12:47:00 +00:00
|
|
|
this),
|
2013-01-21 07:42:11 +00:00
|
|
|
clock_(configuration.clock),
|
2013-01-16 10:27:33 +00:00
|
|
|
audio_(configuration.audio),
|
2017-07-06 04:38:06 -07:00
|
|
|
keepalive_config_(configuration.keepalive_config),
|
|
|
|
|
last_bitrate_process_time_(clock_->TimeInMilliseconds()),
|
|
|
|
|
last_rtt_process_time_(clock_->TimeInMilliseconds()),
|
|
|
|
|
next_process_time_(clock_->TimeInMilliseconds() +
|
|
|
|
|
kRtpRtcpMaxIdleTimeProcessMs),
|
|
|
|
|
next_keepalive_time_(-1),
|
2016-05-02 23:44:01 -07:00
|
|
|
packet_overhead_(28), // IPV4 UDP.
|
2013-03-05 09:02:06 +00:00
|
|
|
nack_last_time_sent_full_(0),
|
2014-12-08 13:29:02 +00:00
|
|
|
nack_last_time_sent_full_prev_(0),
|
2013-01-16 10:27:33 +00:00
|
|
|
nack_last_seq_number_sent_(0),
|
2015-10-08 11:44:14 +02:00
|
|
|
key_frame_req_method_(kKeyFrameReqPliRtcp),
|
2012-11-26 12:40:15 +00:00
|
|
|
remote_bitrate_(configuration.remote_bitrate_estimator),
|
2013-11-20 12:46:11 +00:00
|
|
|
rtt_stats_(configuration.rtt_stats),
|
|
|
|
|
rtt_ms_(0) {
|
2017-03-20 03:52:39 -07:00
|
|
|
if (!configuration.receiver_only) {
|
|
|
|
|
rtp_sender_.reset(new RTPSender(
|
|
|
|
|
configuration.audio,
|
|
|
|
|
configuration.clock,
|
|
|
|
|
configuration.outgoing_transport,
|
|
|
|
|
configuration.paced_sender,
|
|
|
|
|
configuration.flexfec_sender,
|
|
|
|
|
configuration.transport_sequence_number_allocator,
|
|
|
|
|
configuration.transport_feedback_callback,
|
|
|
|
|
configuration.send_bitrate_observer,
|
|
|
|
|
configuration.send_frame_count_observer,
|
|
|
|
|
configuration.send_side_delay_observer,
|
|
|
|
|
configuration.event_log,
|
|
|
|
|
configuration.send_packet_observer,
|
|
|
|
|
configuration.retransmission_rate_limiter,
|
|
|
|
|
configuration.overhead_observer));
|
|
|
|
|
// Make sure rtcp sender use same timestamp offset as rtp sender.
|
|
|
|
|
rtcp_sender_.SetTimestampOffset(rtp_sender_->TimestampOffset());
|
2017-07-06 04:38:06 -07:00
|
|
|
|
|
|
|
|
if (keepalive_config_.timeout_interval_ms != -1) {
|
|
|
|
|
next_keepalive_time_ =
|
|
|
|
|
clock_->TimeInMilliseconds() + keepalive_config_.timeout_interval_ms;
|
|
|
|
|
}
|
2017-03-20 03:52:39 -07:00
|
|
|
}
|
2016-08-18 02:01:49 -07:00
|
|
|
|
|
|
|
|
// Set default packet size limit.
|
2017-01-10 08:58:32 -08:00
|
|
|
// TODO(nisse): Kind-of duplicates
|
|
|
|
|
// webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize.
|
|
|
|
|
const size_t kTcpOverIpv4HeaderSize = 40;
|
|
|
|
|
SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Returns the number of milliseconds until the module want a worker thread
|
|
|
|
|
// to call Process.
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() {
|
2017-07-06 04:38:06 -07:00
|
|
|
return std::max<int64_t>(0,
|
|
|
|
|
next_process_time_ - clock_->TimeInMilliseconds());
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Process any pending tasks such as timeouts (non time critical events).
|
2016-02-25 04:50:01 -08:00
|
|
|
void ModuleRtpRtcpImpl::Process() {
|
2013-08-15 23:38:54 +00:00
|
|
|
const int64_t now = clock_->TimeInMilliseconds();
|
2017-07-06 04:38:06 -07:00
|
|
|
next_process_time_ = now + kRtpRtcpMaxIdleTimeProcessMs;
|
2013-01-16 10:27:33 +00:00
|
|
|
|
2017-03-20 03:52:39 -07:00
|
|
|
if (rtp_sender_) {
|
|
|
|
|
if (now >= last_bitrate_process_time_ + kRtpRtcpBitrateProcessTimeMs) {
|
|
|
|
|
rtp_sender_->ProcessBitrate();
|
|
|
|
|
last_bitrate_process_time_ = now;
|
2017-07-06 04:38:06 -07:00
|
|
|
next_process_time_ =
|
|
|
|
|
std::min(next_process_time_, now + kRtpRtcpBitrateProcessTimeMs);
|
|
|
|
|
}
|
|
|
|
|
if (keepalive_config_.timeout_interval_ms > 0 &&
|
|
|
|
|
now >= next_keepalive_time_) {
|
|
|
|
|
int64_t last_send_time_ms = rtp_sender_->LastTimestampTimeMs();
|
|
|
|
|
// If no packet has been sent, |last_send_time_ms| will be 0, and so the
|
|
|
|
|
// keep-alive will be triggered as expected.
|
|
|
|
|
if (now >= last_send_time_ms + keepalive_config_.timeout_interval_ms) {
|
|
|
|
|
rtp_sender_->SendKeepAlive(keepalive_config_.payload_type);
|
|
|
|
|
next_keepalive_time_ = now + keepalive_config_.timeout_interval_ms;
|
|
|
|
|
} else {
|
|
|
|
|
next_keepalive_time_ =
|
|
|
|
|
last_send_time_ms + keepalive_config_.timeout_interval_ms;
|
|
|
|
|
}
|
|
|
|
|
next_process_time_ = std::min(next_process_time_, next_keepalive_time_);
|
2017-03-20 03:52:39 -07:00
|
|
|
}
|
2012-01-16 11:06:31 +00:00
|
|
|
}
|
2017-07-06 04:38:06 -07:00
|
|
|
|
2015-02-26 12:57:47 +00:00
|
|
|
bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs;
|
|
|
|
|
if (rtcp_sender_.Sending()) {
|
|
|
|
|
// Process RTT if we have received a receiver report and we haven't
|
|
|
|
|
// processed RTT for at least |kRtpRtcpRttProcessTimeMs| milliseconds.
|
|
|
|
|
if (rtcp_receiver_.LastReceivedReceiverReport() >
|
|
|
|
|
last_rtt_process_time_ && process_rtt) {
|
|
|
|
|
std::vector<RTCPReportBlock> receive_blocks;
|
|
|
|
|
rtcp_receiver_.StatisticsReceived(&receive_blocks);
|
|
|
|
|
int64_t max_rtt = 0;
|
|
|
|
|
for (std::vector<RTCPReportBlock>::iterator it = receive_blocks.begin();
|
|
|
|
|
it != receive_blocks.end(); ++it) {
|
|
|
|
|
int64_t rtt = 0;
|
|
|
|
|
rtcp_receiver_.RTT(it->remoteSSRC, &rtt, NULL, NULL, NULL);
|
|
|
|
|
max_rtt = (rtt > max_rtt) ? rtt : max_rtt;
|
2012-02-14 12:49:59 +00:00
|
|
|
}
|
2015-02-26 12:57:47 +00:00
|
|
|
// Report the rtt.
|
|
|
|
|
if (rtt_stats_ && max_rtt != 0)
|
|
|
|
|
rtt_stats_->OnRttUpdate(max_rtt);
|
|
|
|
|
}
|
2013-01-09 13:54:43 +00:00
|
|
|
|
2015-02-26 12:57:47 +00:00
|
|
|
// Verify receiver reports are delivered and the reported sequence number
|
|
|
|
|
// is increasing.
|
|
|
|
|
int64_t rtcp_interval = RtcpReportInterval();
|
|
|
|
|
if (rtcp_receiver_.RtcpRrTimeout(rtcp_interval)) {
|
|
|
|
|
LOG_F(LS_WARNING) << "Timeout: No RTCP RR received.";
|
|
|
|
|
} else if (rtcp_receiver_.RtcpRrSequenceNumberTimeout(rtcp_interval)) {
|
|
|
|
|
LOG_F(LS_WARNING) <<
|
|
|
|
|
"Timeout: No increase in RTCP RR extended highest sequence number.";
|
|
|
|
|
}
|
2013-01-09 13:54:43 +00:00
|
|
|
|
2015-02-26 12:57:47 +00:00
|
|
|
if (remote_bitrate_ && rtcp_sender_.TMMBR()) {
|
|
|
|
|
unsigned int target_bitrate = 0;
|
|
|
|
|
std::vector<unsigned int> ssrcs;
|
|
|
|
|
if (remote_bitrate_->LatestEstimate(&ssrcs, &target_bitrate)) {
|
|
|
|
|
if (!ssrcs.empty()) {
|
|
|
|
|
target_bitrate = target_bitrate / ssrcs.size();
|
2012-06-07 08:10:14 +00:00
|
|
|
}
|
2015-02-26 12:57:47 +00:00
|
|
|
rtcp_sender_.SetTargetBitrate(target_bitrate);
|
2013-10-31 12:14:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-26 12:57:47 +00:00
|
|
|
} else {
|
|
|
|
|
// Report rtt from receiver.
|
2013-10-31 12:14:34 +00:00
|
|
|
if (process_rtt) {
|
2015-02-26 12:57:47 +00:00
|
|
|
int64_t rtt_ms;
|
|
|
|
|
if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
|
|
|
|
|
rtt_stats_->OnRttUpdate(rtt_ms);
|
|
|
|
|
}
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2015-02-26 12:57:47 +00:00
|
|
|
}
|
2013-10-31 12:14:34 +00:00
|
|
|
|
2015-02-26 12:57:47 +00:00
|
|
|
// Get processed rtt.
|
|
|
|
|
if (process_rtt) {
|
|
|
|
|
last_rtt_process_time_ = now;
|
2017-07-06 04:38:06 -07:00
|
|
|
next_process_time_ = std::min(
|
|
|
|
|
next_process_time_, last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs);
|
2016-02-19 09:03:26 -08:00
|
|
|
if (rtt_stats_) {
|
|
|
|
|
// Make sure we have a valid RTT before setting.
|
|
|
|
|
int64_t last_rtt = rtt_stats_->LastProcessedRtt();
|
|
|
|
|
if (last_rtt >= 0)
|
|
|
|
|
set_rtt_ms(last_rtt);
|
|
|
|
|
}
|
2012-01-16 11:06:31 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-20 15:26:59 +02:00
|
|
|
if (rtcp_sender_.TimeToSendRTCPReport())
|
|
|
|
|
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
|
2015-02-26 12:57:47 +00:00
|
|
|
|
2017-02-20 06:03:01 -08:00
|
|
|
if (TMMBR() && rtcp_receiver_.UpdateTmmbrTimers()) {
|
|
|
|
|
rtcp_receiver_.NotifyTmmbrUpdated();
|
2012-01-16 11:06:31 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-13 14:15:15 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetRtxSendStatus(int mode) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetRtxStatus(mode);
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-13 14:15:15 +00:00
|
|
|
int ModuleRtpRtcpImpl::RtxSendStatus() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_ ? rtp_sender_->RtxStatus() : kRtxOff;
|
2014-06-05 08:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModuleRtpRtcpImpl::SetRtxSsrc(uint32_t ssrc) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetRtxSsrc(ssrc);
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-21 20:24:50 +08:00
|
|
|
void ModuleRtpRtcpImpl::SetRtxSendPayloadType(int payload_type,
|
|
|
|
|
int associated_payload_type) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetRtxPayloadType(payload_type, associated_payload_type);
|
2013-04-12 14:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
rtc::Optional<uint32_t> ModuleRtpRtcpImpl::FlexfecSsrc() const {
|
2017-07-03 06:02:53 -07:00
|
|
|
if (rtp_sender_)
|
|
|
|
|
return rtp_sender_->FlexfecSsrc();
|
|
|
|
|
return rtc::Optional<uint32_t>();
|
2016-11-14 05:14:50 -08:00
|
|
|
}
|
|
|
|
|
|
2013-05-29 12:12:51 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
|
|
|
|
|
const uint8_t* rtcp_packet,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t length) {
|
2016-08-29 11:08:47 -07:00
|
|
|
return rtcp_receiver_.IncomingPacket(rtcp_packet, length) ? 0 : -1;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
|
2013-01-16 10:27:33 +00:00
|
|
|
const CodecInst& voice_codec) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->RegisterPayload(
|
2016-07-28 15:19:10 -07:00
|
|
|
voice_codec.plname, voice_codec.pltype, voice_codec.plfreq,
|
|
|
|
|
voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate);
|
2011-10-13 15:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 08:22:50 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->RegisterPayload(video_codec.plName, video_codec.plType,
|
2016-02-16 17:59:27 +01:00
|
|
|
90000, 0, 0);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-26 16:31:37 +01:00
|
|
|
void ModuleRtpRtcpImpl::RegisterVideoSendPayload(int payload_type,
|
|
|
|
|
const char* payload_name) {
|
|
|
|
|
RTC_CHECK_EQ(
|
2017-03-20 03:52:39 -07:00
|
|
|
0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000, 0, 0));
|
2016-02-26 16:31:37 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 08:22:50 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::DeRegisterSendPayload(const int8_t payload_type) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->DeRegisterSendPayload(payload_type);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t ModuleRtpRtcpImpl::StartTimestamp() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->TimestampOffset();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Configure start timestamp, default is a random number.
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetStartTimestamp(const uint32_t timestamp) {
|
2016-08-18 02:01:49 -07:00
|
|
|
rtcp_sender_.SetTimestampOffset(timestamp);
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetTimestampOffset(timestamp);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t ModuleRtpRtcpImpl::SequenceNumber() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SequenceNumber();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Set SequenceNumber, default is a random number.
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetSequenceNumber(const uint16_t seq_num) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetSequenceNumber(seq_num);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-04-15 14:59:13 +02:00
|
|
|
void ModuleRtpRtcpImpl::SetRtpState(const RtpState& rtp_state) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetRtpState(rtp_state);
|
2016-08-18 02:01:49 -07:00
|
|
|
rtcp_sender_.SetTimestampOffset(rtp_state.start_timestamp);
|
2014-07-07 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
2016-04-15 14:59:13 +02:00
|
|
|
void ModuleRtpRtcpImpl::SetRtxState(const RtpState& rtp_state) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetRtxRtpState(rtp_state);
|
2016-04-15 14:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpState ModuleRtpRtcpImpl::GetRtpState() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->GetRtpState();
|
2016-04-15 14:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpState ModuleRtpRtcpImpl::GetRtxState() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->GetRtxRtpState();
|
2014-07-07 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t ModuleRtpRtcpImpl::SSRC() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtcp_sender_.SSRC();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-05 08:25:29 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) {
|
2017-03-20 03:52:39 -07:00
|
|
|
if (rtp_sender_) {
|
|
|
|
|
rtp_sender_->SetSSRC(ssrc);
|
|
|
|
|
}
|
2013-01-16 10:27:33 +00:00
|
|
|
rtcp_sender_.SetSSRC(ssrc);
|
2013-09-17 07:49:56 +00:00
|
|
|
SetRtcpReceiverSsrcs(ssrc);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-24 08:25:50 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetCsrcs(const std::vector<uint32_t>& csrcs) {
|
|
|
|
|
rtcp_sender_.SetCsrcs(csrcs);
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetCsrcs(csrcs);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-15 15:25:39 +00:00
|
|
|
// TODO(pbos): Handle media and RTX streams separately (separate RTCP
|
|
|
|
|
// feedbacks).
|
|
|
|
|
RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() {
|
|
|
|
|
RTCPSender::FeedbackState state;
|
2017-03-20 03:52:39 -07:00
|
|
|
// This is called also when receiver_only is true. Hence below
|
|
|
|
|
// checks that rtp_sender_ exists.
|
|
|
|
|
if (rtp_sender_) {
|
|
|
|
|
StreamDataCounters rtp_stats;
|
|
|
|
|
StreamDataCounters rtx_stats;
|
|
|
|
|
rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats);
|
|
|
|
|
state.packets_sent = rtp_stats.transmitted.packets +
|
|
|
|
|
rtx_stats.transmitted.packets;
|
|
|
|
|
state.media_bytes_sent = rtp_stats.transmitted.payload_bytes +
|
|
|
|
|
rtx_stats.transmitted.payload_bytes;
|
|
|
|
|
state.send_bitrate = rtp_sender_->BitrateSent();
|
|
|
|
|
}
|
2014-07-15 15:25:39 +00:00
|
|
|
state.module = this;
|
|
|
|
|
|
|
|
|
|
LastReceivedNTP(&state.last_rr_ntp_secs,
|
|
|
|
|
&state.last_rr_ntp_frac,
|
|
|
|
|
&state.remote_sr);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-09-28 02:54:25 -07:00
|
|
|
state.has_last_xr_rr =
|
|
|
|
|
rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&state.last_xr_rr);
|
2014-07-15 15:25:39 +00:00
|
|
|
|
|
|
|
|
return state;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-20 03:52:39 -07:00
|
|
|
// TODO(nisse): This method shouldn't be called for a receive-only
|
|
|
|
|
// stream. Delete rtp_sender_ check as soon as all applications are
|
|
|
|
|
// updated.
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
|
2013-01-16 10:27:33 +00:00
|
|
|
if (rtcp_sender_.Sending() != sending) {
|
|
|
|
|
// Sends RTCP BYE when going from true to false
|
2014-07-15 15:25:39 +00:00
|
|
|
if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) {
|
2014-04-08 11:06:12 +00:00
|
|
|
LOG(LS_WARNING) << "Failed to send RTCP BYE";
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2017-03-20 03:52:39 -07:00
|
|
|
if (sending && rtp_sender_) {
|
Reland of Delete class SSRCDatabase, and its global ssrc registry. (patchset #1 id:1 of https://codereview.webrtc.org/2700413002/ )
Reason for revert:
Intend to fix perf problem and reland.
Original issue's description:
> Revert of Delete class SSRCDatabase, and its global ssrc registry. (patchset #20 id:370001 of https://codereview.webrtc.org/2644303002/ )
>
> Reason for revert:
> Breaks webrtc_perf_tests reliably:
> https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/1780
> https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus4%29/builds/178
>
> We're actively working on getting a quick version of webrtc_perf_tests up on the trybots again to prevent breakages like this: https://bugs.chromium.org/p/webrtc/issues/detail?id=7101
>
> Original issue's description:
> > Delete class SSRCDatabase, and its global ssrc registry,
> > and the method RTPSender::GenerateNewSSRC.
> >
> > It's now mandatory for higher layers to call SetSSRC, RTPSender
> > no longer allocates any ssrc by default.
> >
> > BUG=webrtc:4306,webrtc:6887
> >
> > Review-Url: https://codereview.webrtc.org/2644303002
> > Cr-Commit-Position: refs/heads/master@{#16670}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/b78d4d13835f628e722a57abae2bf06ba3655921
>
> TBR=solenberg@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,ivoc@webrtc.org,nisse@webrtc.org
> NOTRY=True
> BUG=webrtc:4306,webrtc:6887
>
> Review-Url: https://codereview.webrtc.org/2700413002
> Cr-Commit-Position: refs/heads/master@{#16693}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b5848ecbf5f7b310108546ec6b858fe93452f58e
TBR=solenberg@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,ivoc@webrtc.org,kjellander@webrtc.org,kjellander@google.com
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:4306,webrtc:6887
Review-Url: https://codereview.webrtc.org/2702203002
Cr-Commit-Position: refs/heads/master@{#16737}
2017-02-21 03:40:24 -08:00
|
|
|
// Update Rtcp receiver config, to track Rtx config changes from
|
|
|
|
|
// the SetRtxStatus and SetRtxSsrc methods.
|
2017-03-20 03:52:39 -07:00
|
|
|
SetRtcpReceiverSsrcs(rtp_sender_->SSRC());
|
Reland of Delete class SSRCDatabase, and its global ssrc registry. (patchset #1 id:1 of https://codereview.webrtc.org/2700413002/ )
Reason for revert:
Intend to fix perf problem and reland.
Original issue's description:
> Revert of Delete class SSRCDatabase, and its global ssrc registry. (patchset #20 id:370001 of https://codereview.webrtc.org/2644303002/ )
>
> Reason for revert:
> Breaks webrtc_perf_tests reliably:
> https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/1780
> https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus4%29/builds/178
>
> We're actively working on getting a quick version of webrtc_perf_tests up on the trybots again to prevent breakages like this: https://bugs.chromium.org/p/webrtc/issues/detail?id=7101
>
> Original issue's description:
> > Delete class SSRCDatabase, and its global ssrc registry,
> > and the method RTPSender::GenerateNewSSRC.
> >
> > It's now mandatory for higher layers to call SetSSRC, RTPSender
> > no longer allocates any ssrc by default.
> >
> > BUG=webrtc:4306,webrtc:6887
> >
> > Review-Url: https://codereview.webrtc.org/2644303002
> > Cr-Commit-Position: refs/heads/master@{#16670}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/b78d4d13835f628e722a57abae2bf06ba3655921
>
> TBR=solenberg@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,ivoc@webrtc.org,nisse@webrtc.org
> NOTRY=True
> BUG=webrtc:4306,webrtc:6887
>
> Review-Url: https://codereview.webrtc.org/2700413002
> Cr-Commit-Position: refs/heads/master@{#16693}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b5848ecbf5f7b310108546ec6b858fe93452f58e
TBR=solenberg@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,ivoc@webrtc.org,kjellander@webrtc.org,kjellander@google.com
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:4306,webrtc:6887
Review-Url: https://codereview.webrtc.org/2702203002
Cr-Commit-Position: refs/heads/master@{#16737}
2017-02-21 03:40:24 -08:00
|
|
|
}
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
bool ModuleRtpRtcpImpl::Sending() const {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.Sending();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-20 03:52:39 -07:00
|
|
|
// TODO(nisse): This method shouldn't be called for a receive-only
|
|
|
|
|
// stream. Delete rtp_sender_ check as soon as all applications are
|
|
|
|
|
// updated.
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) {
|
2017-03-20 03:52:39 -07:00
|
|
|
if (rtp_sender_) {
|
|
|
|
|
rtp_sender_->SetSendingMediaStatus(sending);
|
|
|
|
|
} else {
|
|
|
|
|
RTC_DCHECK(!sending);
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-08 23:41:49 +00:00
|
|
|
bool ModuleRtpRtcpImpl::SendingMedia() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_ ? rtp_sender_->SendingMedia() : false;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-02 17:46:41 -07:00
|
|
|
bool ModuleRtpRtcpImpl::SendOutgoingData(
|
2013-01-16 10:27:33 +00:00
|
|
|
FrameType frame_type,
|
2013-04-08 11:08:41 +00:00
|
|
|
int8_t payload_type,
|
|
|
|
|
uint32_t time_stamp,
|
2012-07-03 13:21:22 +00:00
|
|
|
int64_t capture_time_ms,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t* payload_data,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t payload_size,
|
2012-02-08 23:41:49 +00:00
|
|
|
const RTPFragmentationHeader* fragmentation,
|
2016-08-02 17:46:41 -07:00
|
|
|
const RTPVideoHeader* rtp_video_header,
|
|
|
|
|
uint32_t* transport_frame_id_out) {
|
2015-02-06 13:10:19 +00:00
|
|
|
rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
|
2015-12-10 10:10:44 +01:00
|
|
|
// Make sure an RTCP report isn't queued behind a key frame.
|
2015-02-06 13:10:19 +00:00
|
|
|
if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) {
|
2014-07-15 15:25:39 +00:00
|
|
|
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SendOutgoingData(
|
2015-03-04 22:55:15 +00:00
|
|
|
frame_type, payload_type, time_stamp, capture_time_ms, payload_data,
|
2016-08-02 17:46:41 -07:00
|
|
|
payload_size, fragmentation, rtp_video_header, transport_frame_id_out);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-20 20:18:31 +00:00
|
|
|
bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc,
|
2012-11-13 21:12:39 +00:00
|
|
|
uint16_t sequence_number,
|
2013-11-13 15:29:21 +00:00
|
|
|
int64_t capture_time_ms,
|
2016-06-01 06:31:17 -07:00
|
|
|
bool retransmission,
|
2017-02-17 03:59:43 -08:00
|
|
|
const PacedPacketInfo& pacing_info) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->TimeToSendPacket(ssrc, sequence_number, capture_time_ms,
|
2017-02-23 02:56:13 -08:00
|
|
|
retransmission, pacing_info);
|
2013-06-17 12:53:37 +00:00
|
|
|
}
|
|
|
|
|
|
2017-02-17 03:59:43 -08:00
|
|
|
size_t ModuleRtpRtcpImpl::TimeToSendPadding(
|
|
|
|
|
size_t bytes,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->TimeToSendPadding(bytes, pacing_info);
|
2012-11-13 21:12:39 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 08:58:32 -08:00
|
|
|
size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->MaxRtpPacketSize();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 08:58:32 -08:00
|
|
|
void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) {
|
|
|
|
|
RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE)
|
|
|
|
|
<< "rtp packet size too large: " << rtp_packet_size;
|
|
|
|
|
RTC_DCHECK_GT(rtp_packet_size, packet_overhead_)
|
|
|
|
|
<< "rtp packet size too small: " << rtp_packet_size;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-01-10 08:58:32 -08:00
|
|
|
rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size);
|
2017-03-20 03:52:39 -07:00
|
|
|
if (rtp_sender_)
|
|
|
|
|
rtp_sender_->SetMaxRtpPacketSize(rtp_packet_size);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-02 02:36:56 -07:00
|
|
|
RtcpMode ModuleRtpRtcpImpl::RTCP() const {
|
2016-03-18 15:02:07 -07:00
|
|
|
return rtcp_sender_.Status();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Configure RTCP status i.e on/off.
|
2015-10-02 02:36:56 -07:00
|
|
|
void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) {
|
2014-12-19 13:49:55 +00:00
|
|
|
rtcp_sender_.SetRTCPStatus(method);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2011-10-13 15:19:55 +00:00
|
|
|
|
2015-06-01 14:12:28 +02:00
|
|
|
int32_t ModuleRtpRtcpImpl::SetCNAME(const char* c_name) {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.SetCNAME(c_name);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 14:46:16 +02:00
|
|
|
int32_t ModuleRtpRtcpImpl::AddMixedCNAME(uint32_t ssrc, const char* c_name) {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.AddMixedCNAME(ssrc, c_name);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RemoveMixedCNAME(const uint32_t ssrc) {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.RemoveMixedCNAME(ssrc);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RemoteCNAME(
|
|
|
|
|
const uint32_t remote_ssrc,
|
2013-01-16 10:27:33 +00:00
|
|
|
char c_name[RTCP_CNAME_SIZE]) const {
|
|
|
|
|
return rtcp_receiver_.CNAME(remote_ssrc, c_name);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RemoteNTP(
|
|
|
|
|
uint32_t* received_ntpsecs,
|
|
|
|
|
uint32_t* received_ntpfrac,
|
|
|
|
|
uint32_t* rtcp_arrival_time_secs,
|
|
|
|
|
uint32_t* rtcp_arrival_time_frac,
|
|
|
|
|
uint32_t* rtcp_timestamp) const {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_receiver_.NTP(received_ntpsecs,
|
|
|
|
|
received_ntpfrac,
|
|
|
|
|
rtcp_arrival_time_secs,
|
|
|
|
|
rtcp_arrival_time_frac,
|
2014-07-15 15:51:33 +00:00
|
|
|
rtcp_timestamp)
|
|
|
|
|
? 0
|
|
|
|
|
: -1;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Get RoundTripTime.
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RTT(const uint32_t remote_ssrc,
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t* rtt,
|
|
|
|
|
int64_t* avg_rtt,
|
|
|
|
|
int64_t* min_rtt,
|
|
|
|
|
int64_t* max_rtt) const {
|
2014-04-24 22:10:24 +00:00
|
|
|
int32_t ret = rtcp_receiver_.RTT(remote_ssrc, rtt, avg_rtt, min_rtt, max_rtt);
|
|
|
|
|
if (rtt && *rtt == 0) {
|
|
|
|
|
// Try to get RTT from RtcpRttStats class.
|
2015-01-12 21:51:21 +00:00
|
|
|
*rtt = rtt_ms();
|
2014-04-24 22:10:24 +00:00
|
|
|
}
|
|
|
|
|
return ret;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Force a send of an RTCP packet.
|
|
|
|
|
// Normal SR and RR are triggered via the process function.
|
2015-05-11 10:17:43 +02:00
|
|
|
int32_t ModuleRtpRtcpImpl::SendRTCP(RTCPPacketType packet_type) {
|
|
|
|
|
return rtcp_sender_.SendRTCP(GetFeedbackState(), packet_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Force a send of an RTCP packet.
|
|
|
|
|
// Normal SR and RR are triggered via the process function.
|
|
|
|
|
int32_t ModuleRtpRtcpImpl::SendCompoundRTCP(
|
|
|
|
|
const std::set<RTCPPacketType>& packet_types) {
|
|
|
|
|
return rtcp_sender_.SendCompoundRTCP(GetFeedbackState(), packet_types);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SetRTCPApplicationSpecificData(
|
|
|
|
|
const uint8_t sub_type,
|
|
|
|
|
const uint32_t name,
|
|
|
|
|
const uint8_t* data,
|
|
|
|
|
const uint16_t length) {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.SetApplicationSpecificData(sub_type, name, data, length);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// (XR) VOIP metric.
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SetRTCPVoIPMetrics(
|
2013-01-16 10:27:33 +00:00
|
|
|
const RTCPVoIPMetric* voip_metric) {
|
|
|
|
|
return rtcp_sender_.SetRTCPVoIPMetrics(voip_metric);
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-31 12:14:34 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetRtcpXrRrtrStatus(bool enable) {
|
2016-03-09 15:14:35 +01:00
|
|
|
rtcp_receiver_.SetRtcpXrRrtrStatus(enable);
|
|
|
|
|
rtcp_sender_.SendRtcpXrReceiverReferenceTime(enable);
|
2013-10-31 12:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-21 08:57:04 +00:00
|
|
|
bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const {
|
|
|
|
|
return rtcp_sender_.RtcpXrReceiverReferenceTime();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-09 09:47:53 +00:00
|
|
|
// TODO(asapersson): Replace this method with the one below.
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::DataCountersRTP(
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t* bytes_sent,
|
2013-08-15 23:38:54 +00:00
|
|
|
uint32_t* packets_sent) const {
|
2014-07-15 15:25:39 +00:00
|
|
|
StreamDataCounters rtp_stats;
|
|
|
|
|
StreamDataCounters rtx_stats;
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats);
|
2014-07-15 15:25:39 +00:00
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
if (bytes_sent) {
|
2015-01-22 09:39:59 +00:00
|
|
|
*bytes_sent = rtp_stats.transmitted.payload_bytes +
|
|
|
|
|
rtp_stats.transmitted.padding_bytes +
|
|
|
|
|
rtp_stats.transmitted.header_bytes +
|
|
|
|
|
rtx_stats.transmitted.payload_bytes +
|
|
|
|
|
rtx_stats.transmitted.padding_bytes +
|
|
|
|
|
rtx_stats.transmitted.header_bytes;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2013-01-16 10:27:33 +00:00
|
|
|
if (packets_sent) {
|
2015-01-22 09:39:59 +00:00
|
|
|
*packets_sent = rtp_stats.transmitted.packets +
|
|
|
|
|
rtx_stats.transmitted.packets;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2013-08-15 23:38:54 +00:00
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-09 09:47:53 +00:00
|
|
|
void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
|
|
|
|
|
StreamDataCounters* rtp_counters,
|
|
|
|
|
StreamDataCounters* rtx_counters) const {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->GetDataCounters(rtp_counters, rtx_counters);
|
2014-12-09 09:47:53 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-10 18:10:05 -07:00
|
|
|
void ModuleRtpRtcpImpl::GetRtpPacketLossStats(
|
|
|
|
|
bool outgoing,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
struct RtpPacketLossStats* loss_stats) const {
|
|
|
|
|
if (!loss_stats) return;
|
|
|
|
|
const PacketLossStats* stats_source = NULL;
|
|
|
|
|
if (outgoing) {
|
|
|
|
|
if (SSRC() == ssrc) {
|
|
|
|
|
stats_source = &send_loss_stats_;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (rtcp_receiver_.RemoteSSRC() == ssrc) {
|
|
|
|
|
stats_source = &receive_loss_stats_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (stats_source) {
|
|
|
|
|
loss_stats->single_packet_loss_count =
|
|
|
|
|
stats_source->GetSingleLossCount();
|
|
|
|
|
loss_stats->multiple_packet_loss_event_count =
|
|
|
|
|
stats_source->GetMultipleLossEventCount();
|
|
|
|
|
loss_stats->multiple_packet_loss_packet_count =
|
|
|
|
|
stats_source->GetMultipleLossPacketCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Received RTCP report.
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RemoteRTCPStat(
|
2013-01-16 10:27:33 +00:00
|
|
|
std::vector<RTCPReportBlock>* receive_blocks) const {
|
|
|
|
|
return rtcp_receiver_.StatisticsReceived(receive_blocks);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// (REMB) Receiver Estimated Max Bitrate.
|
2012-02-08 23:41:49 +00:00
|
|
|
bool ModuleRtpRtcpImpl::REMB() const {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.REMB();
|
2011-09-20 13:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetREMBStatus(const bool enable) {
|
|
|
|
|
rtcp_sender_.SetREMBStatus(enable);
|
2011-09-20 13:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate,
|
|
|
|
|
const std::vector<uint32_t>& ssrcs) {
|
|
|
|
|
rtcp_sender_.SetREMBData(bitrate, ssrcs);
|
2011-09-20 13:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension(
|
2013-01-16 10:27:33 +00:00
|
|
|
const RTPExtensionType type,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t id) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->RegisterRtpHeaderExtension(type, id);
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension(
|
2013-01-16 10:27:33 +00:00
|
|
|
const RTPExtensionType type) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->DeregisterRtpHeaderExtension(type);
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
2017-02-03 08:13:57 -08:00
|
|
|
bool ModuleRtpRtcpImpl::HasBweExtensions() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->IsRtpHeaderExtensionRegistered(
|
2017-02-03 08:13:57 -08:00
|
|
|
kRtpExtensionTransportSequenceNumber) ||
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->IsRtpHeaderExtensionRegistered(
|
2017-02-03 08:13:57 -08:00
|
|
|
kRtpExtensionAbsoluteSendTime) ||
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->IsRtpHeaderExtensionRegistered(
|
2017-02-03 08:13:57 -08:00
|
|
|
kRtpExtensionTransmissionTimeOffset);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// (TMMBR) Temporary Max Media Bit Rate.
|
2012-02-08 23:41:49 +00:00
|
|
|
bool ModuleRtpRtcpImpl::TMMBR() const {
|
2013-01-16 10:27:33 +00:00
|
|
|
return rtcp_sender_.TMMBR();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) {
|
|
|
|
|
rtcp_sender_.SetTMMBRStatus(enable);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-22 08:26:15 -07:00
|
|
|
void ModuleRtpRtcpImpl::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) {
|
|
|
|
|
rtcp_sender_.SetTmmbn(std::move(bounding_set));
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-22 12:52:41 +00:00
|
|
|
// Returns the currently configured retransmission mode.
|
|
|
|
|
int ModuleRtpRtcpImpl::SelectiveRetransmissions() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SelectiveRetransmissions();
|
2011-12-22 12:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enable or disable a retransmission mode, which decides which packets will
|
|
|
|
|
// be retransmitted if NACKed.
|
|
|
|
|
int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SetSelectiveRetransmissions(settings);
|
2011-12-22 12:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Send a Negative acknowledgment packet.
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list,
|
|
|
|
|
const uint16_t size) {
|
2015-07-10 18:10:05 -07:00
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
|
receive_loss_stats_.AddLostPacket(nack_list[i]);
|
|
|
|
|
}
|
2014-12-08 13:29:02 +00:00
|
|
|
uint16_t nack_length = size;
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t start_id = 0;
|
2014-12-08 13:29:02 +00:00
|
|
|
int64_t now = clock_->TimeInMilliseconds();
|
|
|
|
|
if (TimeToSendFullNackList(now)) {
|
2013-03-05 09:02:06 +00:00
|
|
|
nack_last_time_sent_full_ = now;
|
2014-12-08 13:29:02 +00:00
|
|
|
nack_last_time_sent_full_prev_ = now;
|
2012-02-08 23:41:49 +00:00
|
|
|
} else {
|
2014-12-08 13:29:02 +00:00
|
|
|
// Only send extended list.
|
2013-01-16 10:27:33 +00:00
|
|
|
if (nack_last_seq_number_sent_ == nack_list[size - 1]) {
|
2014-12-08 13:29:02 +00:00
|
|
|
// Last sequence number is the same, do not send list.
|
2012-02-08 23:41:49 +00:00
|
|
|
return 0;
|
2014-12-08 13:29:02 +00:00
|
|
|
}
|
|
|
|
|
// Send new sequence numbers.
|
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
|
if (nack_last_seq_number_sent_ == nack_list[i]) {
|
|
|
|
|
start_id = i + 1;
|
|
|
|
|
break;
|
2012-12-21 17:46:24 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2014-12-08 13:29:02 +00:00
|
|
|
nack_length = size - start_id;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2014-12-08 13:29:02 +00:00
|
|
|
|
2013-03-05 09:02:06 +00:00
|
|
|
// Our RTCP NACK implementation is limited to kRtcpMaxNackFields sequence
|
|
|
|
|
// numbers per RTCP packet.
|
2014-12-08 13:29:02 +00:00
|
|
|
if (nack_length > kRtcpMaxNackFields) {
|
|
|
|
|
nack_length = kRtcpMaxNackFields;
|
2013-03-05 09:02:06 +00:00
|
|
|
}
|
2014-12-08 13:29:02 +00:00
|
|
|
nack_last_seq_number_sent_ = nack_list[start_id + nack_length - 1];
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-03-12 03:30:23 -08:00
|
|
|
return rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpNack, nack_length,
|
|
|
|
|
&nack_list[start_id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModuleRtpRtcpImpl::SendNack(
|
|
|
|
|
const std::vector<uint16_t>& sequence_numbers) {
|
|
|
|
|
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpNack, sequence_numbers.size(),
|
|
|
|
|
sequence_numbers.data());
|
2014-12-08 13:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ModuleRtpRtcpImpl::TimeToSendFullNackList(int64_t now) const {
|
|
|
|
|
// Use RTT from RtcpRttStats class if provided.
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t rtt = rtt_ms();
|
2014-12-08 13:29:02 +00:00
|
|
|
if (rtt == 0) {
|
|
|
|
|
rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int64_t kStartUpRttMs = 100;
|
|
|
|
|
int64_t wait_time = 5 + ((rtt * 3) >> 1); // 5 + RTT * 1.5.
|
|
|
|
|
if (rtt == 0) {
|
|
|
|
|
wait_time = kStartUpRttMs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send a full NACK list once within every |wait_time|.
|
|
|
|
|
if (rtt_stats_) {
|
|
|
|
|
return now - nack_last_time_sent_full_ > wait_time;
|
|
|
|
|
}
|
|
|
|
|
return now - nack_last_time_sent_full_prev_ > wait_time;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-21 08:22:50 +00:00
|
|
|
// Store the sent packets, needed to answer to Negative acknowledgment requests.
|
2014-12-19 13:49:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetStorePacketsStatus(const bool enable,
|
|
|
|
|
const uint16_t number_to_store) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetStorePacketsStatus(enable, number_to_store);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
bool ModuleRtpRtcpImpl::StorePackets() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->StorePackets();
|
2013-07-16 19:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-18 13:50:16 +00:00
|
|
|
void ModuleRtpRtcpImpl::RegisterRtcpStatisticsCallback(
|
2013-12-05 09:48:44 +00:00
|
|
|
RtcpStatisticsCallback* callback) {
|
|
|
|
|
rtcp_receiver_.RegisterRtcpStatisticsCallback(callback);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-19 12:47:00 +00:00
|
|
|
RtcpStatisticsCallback* ModuleRtpRtcpImpl::GetRtcpStatisticsCallback() {
|
2013-12-05 09:48:44 +00:00
|
|
|
return rtcp_receiver_.GetRtcpStatisticsCallback();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 13:25:16 -07:00
|
|
|
bool ModuleRtpRtcpImpl::SendFeedbackPacket(
|
|
|
|
|
const rtcp::TransportFeedback& packet) {
|
|
|
|
|
return rtcp_sender_.SendFeedbackPacket(packet);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Send a TelephoneEvent tone using RFC 2833 (4733).
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband(
|
|
|
|
|
const uint8_t key,
|
|
|
|
|
const uint16_t time_ms,
|
|
|
|
|
const uint8_t level) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SendTelephoneEvent(key, time_ms, level);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SetAudioLevel(
|
|
|
|
|
const uint8_t level_d_bov) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SetAudioLevel(level_d_bov);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::SetKeyFrameRequestMethod(
|
2013-01-16 10:27:33 +00:00
|
|
|
const KeyFrameRequestMethod method) {
|
|
|
|
|
key_frame_req_method_ = method;
|
2012-02-08 23:41:49 +00:00
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ModuleRtpRtcpImpl::RequestKeyFrame() {
|
2013-01-16 10:27:33 +00:00
|
|
|
switch (key_frame_req_method_) {
|
2011-07-07 08:21:25 +00:00
|
|
|
case kKeyFrameReqPliRtcp:
|
2013-08-15 23:38:54 +00:00
|
|
|
return SendRTCP(kRtcpPli);
|
2012-02-10 12:13:12 +00:00
|
|
|
case kKeyFrameReqFirRtcp:
|
2013-08-15 23:38:54 +00:00
|
|
|
return SendRTCP(kRtcpFir);
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
|
|
|
|
return -1;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-07 03:05:06 -08:00
|
|
|
void ModuleRtpRtcpImpl::SetUlpfecConfig(int red_payload_type,
|
2016-11-07 02:08:51 -08:00
|
|
|
int ulpfec_payload_type) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-07 03:36:05 -08:00
|
|
|
bool ModuleRtpRtcpImpl::SetFecParameters(
|
|
|
|
|
const FecProtectionParams& delta_params,
|
|
|
|
|
const FecProtectionParams& key_params) {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->SetFecParameters(delta_params, key_params);
|
2011-07-15 21:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) {
|
2013-01-16 10:27:33 +00:00
|
|
|
// Inform about the incoming SSRC.
|
|
|
|
|
rtcp_sender_.SetRemoteSSRC(ssrc);
|
|
|
|
|
rtcp_receiver_.SetRemoteSSRC(ssrc);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate,
|
|
|
|
|
uint32_t* video_rate,
|
|
|
|
|
uint32_t* fec_rate,
|
|
|
|
|
uint32_t* nack_rate) const {
|
2017-03-20 03:52:39 -07:00
|
|
|
*total_rate = rtp_sender_->BitrateSent();
|
|
|
|
|
*video_rate = rtp_sender_->VideoBitrateSent();
|
|
|
|
|
*fec_rate = rtp_sender_->FecOverheadRate();
|
|
|
|
|
*nack_rate = rtp_sender_->NackOverheadRate();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-13 15:19:55 +00:00
|
|
|
void ModuleRtpRtcpImpl::OnRequestSendReport() {
|
2013-08-15 23:38:54 +00:00
|
|
|
SendRTCP(kRtcpSr);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-26 18:48:46 +02:00
|
|
|
void ModuleRtpRtcpImpl::OnReceivedNack(
|
|
|
|
|
const std::vector<uint16_t>& nack_sequence_numbers) {
|
2017-03-20 03:52:39 -07:00
|
|
|
if (!rtp_sender_)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-07-10 18:10:05 -07:00
|
|
|
for (uint16_t nack_sequence_number : nack_sequence_numbers) {
|
|
|
|
|
send_loss_stats_.AddLostPacket(nack_sequence_number);
|
|
|
|
|
}
|
2017-03-20 03:52:39 -07:00
|
|
|
if (!rtp_sender_->StorePackets() ||
|
2013-02-01 15:09:57 +00:00
|
|
|
nack_sequence_numbers.size() == 0) {
|
2012-02-08 23:41:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2013-12-16 14:40:36 +00:00
|
|
|
// Use RTT from RtcpRttStats class if provided.
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t rtt = rtt_ms();
|
2013-12-16 14:40:36 +00:00
|
|
|
if (rtt == 0) {
|
|
|
|
|
rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL);
|
|
|
|
|
}
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->OnReceivedNack(nack_sequence_numbers, rtt);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-08 00:24:21 -07:00
|
|
|
void ModuleRtpRtcpImpl::OnReceivedRtcpReportBlocks(
|
|
|
|
|
const ReportBlockList& report_blocks) {
|
2017-03-20 03:52:39 -07:00
|
|
|
if (rtp_sender_)
|
|
|
|
|
rtp_sender_->OnReceivedRtcpReportBlocks(report_blocks);
|
2016-06-08 00:24:21 -07:00
|
|
|
}
|
|
|
|
|
|
2014-07-15 15:25:39 +00:00
|
|
|
bool ModuleRtpRtcpImpl::LastReceivedNTP(
|
|
|
|
|
uint32_t* rtcp_arrival_time_secs, // When we got the last report.
|
|
|
|
|
uint32_t* rtcp_arrival_time_frac,
|
|
|
|
|
uint32_t* remote_sr) const {
|
2013-01-16 10:27:33 +00:00
|
|
|
// Remote SR: NTP inside the last received (mid 16 bits from sec and frac).
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t ntp_secs = 0;
|
|
|
|
|
uint32_t ntp_frac = 0;
|
2013-01-16 10:27:33 +00:00
|
|
|
|
2014-07-15 15:25:39 +00:00
|
|
|
if (!rtcp_receiver_.NTP(&ntp_secs,
|
|
|
|
|
&ntp_frac,
|
|
|
|
|
rtcp_arrival_time_secs,
|
|
|
|
|
rtcp_arrival_time_frac,
|
|
|
|
|
NULL)) {
|
|
|
|
|
return false;
|
2012-02-08 23:41:49 +00:00
|
|
|
}
|
2014-07-15 15:25:39 +00:00
|
|
|
*remote_sr =
|
|
|
|
|
((ntp_secs & 0x0000ffff) << 16) + ((ntp_frac & 0xffff0000) >> 16);
|
|
|
|
|
return true;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-16 10:27:33 +00:00
|
|
|
// Called from RTCPsender.
|
2016-08-18 06:17:42 -07:00
|
|
|
std::vector<rtcp::TmmbItem> ModuleRtpRtcpImpl::BoundingSet(bool* tmmbr_owner) {
|
|
|
|
|
return rtcp_receiver_.BoundingSet(tmmbr_owner);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2013-01-09 13:54:43 +00:00
|
|
|
|
|
|
|
|
int64_t ModuleRtpRtcpImpl::RtcpReportInterval() {
|
2013-01-16 10:27:33 +00:00
|
|
|
if (audio_)
|
2013-01-09 13:54:43 +00:00
|
|
|
return RTCP_INTERVAL_AUDIO_MS;
|
|
|
|
|
else
|
|
|
|
|
return RTCP_INTERVAL_VIDEO_MS;
|
|
|
|
|
}
|
2013-09-17 07:49:56 +00:00
|
|
|
|
|
|
|
|
void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) {
|
|
|
|
|
std::set<uint32_t> ssrcs;
|
|
|
|
|
ssrcs.insert(main_ssrc);
|
2017-03-20 03:52:39 -07:00
|
|
|
if (RtxSendStatus() != kRtxOff)
|
|
|
|
|
ssrcs.insert(rtp_sender_->RtxSsrc());
|
2017-07-03 06:02:53 -07:00
|
|
|
rtc::Optional<uint32_t> flexfec_ssrc = FlexfecSsrc();
|
|
|
|
|
if (flexfec_ssrc)
|
|
|
|
|
ssrcs.insert(*flexfec_ssrc);
|
2013-09-17 07:49:56 +00:00
|
|
|
rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-12 21:51:21 +00:00
|
|
|
void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) {
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope cs(&critical_section_rtt_);
|
2013-11-20 12:46:11 +00:00
|
|
|
rtt_ms_ = rtt_ms;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t ModuleRtpRtcpImpl::rtt_ms() const {
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope cs(&critical_section_rtt_);
|
2013-11-20 12:46:11 +00:00
|
|
|
return rtt_ms_;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 14:29:02 +00:00
|
|
|
void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback(
|
|
|
|
|
StreamDataCountersCallback* callback) {
|
2017-03-20 03:52:39 -07:00
|
|
|
rtp_sender_->RegisterRtpStatisticsCallback(callback);
|
2013-12-05 14:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamDataCountersCallback*
|
|
|
|
|
ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const {
|
2017-03-20 03:52:39 -07:00
|
|
|
return rtp_sender_->GetRtpStatisticsCallback();
|
2013-12-05 14:29:02 +00:00
|
|
|
}
|
2016-12-01 05:18:09 -08:00
|
|
|
|
|
|
|
|
void ModuleRtpRtcpImpl::SetVideoBitrateAllocation(
|
|
|
|
|
const BitrateAllocation& bitrate) {
|
|
|
|
|
rtcp_sender_.SetVideoBitrateAllocation(bitrate);
|
|
|
|
|
}
|
2015-02-06 13:10:19 +00:00
|
|
|
} // namespace webrtc
|