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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_sender.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 05:05:27 -08:00
|
|
|
#include <algorithm>
|
2018-09-13 15:36:20 +02:00
|
|
|
#include <limits>
|
2018-03-22 15:17:27 -07:00
|
|
|
#include <string>
|
2015-04-21 20:24:50 +08:00
|
|
|
#include <utility>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2018-11-02 10:54:56 +01:00
|
|
|
#include "absl/strings/match.h"
|
2018-12-21 09:23:38 -08:00
|
|
|
#include "api/array_view.h"
|
2017-10-03 16:11:34 +02:00
|
|
|
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_event_log.h"
|
|
|
|
|
#include "modules/rtp_rtcp/include/rtp_cvo.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/byte_io.h"
|
2018-09-26 12:25:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor_extension.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/time_util.h"
|
|
|
|
|
#include "rtc_base/arraysize.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/logging.h"
|
2017-11-22 10:42:26 +01:00
|
|
|
#include "rtc_base/numerics/safe_minmax.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/rate_limiter.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/time_utils.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-01-25 10:53:38 +00:00
|
|
|
|
2013-04-09 19:54:10 +00:00
|
|
|
namespace {
|
2016-08-03 18:27:40 +02:00
|
|
|
// Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
|
|
|
|
|
constexpr size_t kMaxPaddingLength = 224;
|
2017-02-03 08:13:57 -08:00
|
|
|
constexpr size_t kMinAudioPaddingLength = 50;
|
2016-08-03 18:27:40 +02:00
|
|
|
constexpr int kSendSideDelayWindowMs = 1000;
|
|
|
|
|
constexpr size_t kRtpHeaderLength = 12;
|
|
|
|
|
constexpr uint16_t kMaxInitRtpSeqNumber = 32767; // 2^15 -1.
|
|
|
|
|
constexpr uint32_t kTimestampTicksPerMs = 90;
|
|
|
|
|
constexpr int kBitrateStatisticsWindowMs = 1000;
|
2015-03-04 22:55:15 +00:00
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
constexpr size_t kMinFlexfecPacketsToStoreForPacing = 50;
|
|
|
|
|
|
2017-05-17 05:08:38 -07:00
|
|
|
template <typename Extension>
|
|
|
|
|
constexpr RtpExtensionSize CreateExtensionSize() {
|
|
|
|
|
return {Extension::kId, Extension::kValueSizeBytes};
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-21 09:23:38 -08:00
|
|
|
template <typename Extension>
|
|
|
|
|
constexpr RtpExtensionSize CreateMaxExtensionSize() {
|
|
|
|
|
return {Extension::kId, Extension::kMaxValueSizeBytes};
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-17 05:08:38 -07:00
|
|
|
// Size info for header extensions that might be used in padding or FEC packets.
|
2018-03-15 15:46:17 +01:00
|
|
|
constexpr RtpExtensionSize kFecOrPaddingExtensionSizes[] = {
|
2017-05-17 05:08:38 -07:00
|
|
|
CreateExtensionSize<AbsoluteSendTime>(),
|
|
|
|
|
CreateExtensionSize<TransmissionOffset>(),
|
|
|
|
|
CreateExtensionSize<TransportSequenceNumber>(),
|
|
|
|
|
CreateExtensionSize<PlayoutDelayLimits>(),
|
2018-12-21 09:23:38 -08:00
|
|
|
CreateMaxExtensionSize<RtpMid>(),
|
2017-05-17 05:08:38 -07:00
|
|
|
};
|
|
|
|
|
|
2018-03-15 15:46:17 +01:00
|
|
|
// Size info for header extensions that might be used in video packets.
|
|
|
|
|
constexpr RtpExtensionSize kVideoExtensionSizes[] = {
|
|
|
|
|
CreateExtensionSize<AbsoluteSendTime>(),
|
|
|
|
|
CreateExtensionSize<TransmissionOffset>(),
|
|
|
|
|
CreateExtensionSize<TransportSequenceNumber>(),
|
|
|
|
|
CreateExtensionSize<PlayoutDelayLimits>(),
|
|
|
|
|
CreateExtensionSize<VideoOrientation>(),
|
|
|
|
|
CreateExtensionSize<VideoContentTypeExtension>(),
|
|
|
|
|
CreateExtensionSize<VideoTimingExtension>(),
|
2018-12-21 09:23:38 -08:00
|
|
|
CreateMaxExtensionSize<RtpStreamId>(),
|
|
|
|
|
CreateMaxExtensionSize<RepairedRtpStreamId>(),
|
|
|
|
|
CreateMaxExtensionSize<RtpMid>(),
|
2019-02-19 13:01:31 +01:00
|
|
|
{RtpGenericFrameDescriptorExtension00::kId,
|
|
|
|
|
RtpGenericFrameDescriptorExtension00::kMaxSizeBytes},
|
|
|
|
|
{RtpGenericFrameDescriptorExtension01::kId,
|
|
|
|
|
RtpGenericFrameDescriptorExtension01::kMaxSizeBytes},
|
2018-03-15 15:46:17 +01:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 19:54:10 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
2015-09-21 15:11:14 -07:00
|
|
|
RTPSender::RTPSender(
|
|
|
|
|
bool audio,
|
|
|
|
|
Clock* clock,
|
|
|
|
|
Transport* transport,
|
|
|
|
|
RtpPacketSender* paced_sender,
|
2019-02-06 22:48:11 +01:00
|
|
|
absl::optional<uint32_t> flexfec_ssrc,
|
2015-09-21 15:11:14 -07:00
|
|
|
TransportSequenceNumberAllocator* sequence_number_allocator,
|
|
|
|
|
TransportFeedbackObserver* transport_feedback_observer,
|
|
|
|
|
BitrateStatisticsObserver* bitrate_callback,
|
2016-01-21 05:42:04 -08:00
|
|
|
SendSideDelayObserver* send_side_delay_observer,
|
2016-05-02 23:44:01 -07:00
|
|
|
RtcEventLog* event_log,
|
2016-07-13 09:11:28 -07:00
|
|
|
SendPacketObserver* send_packet_observer,
|
2016-11-17 01:38:43 -08:00
|
|
|
RateLimiter* retransmission_rate_limiter,
|
2018-02-07 14:37:37 +01:00
|
|
|
OverheadObserver* overhead_observer,
|
2018-10-17 17:27:25 -07:00
|
|
|
bool populate_network2_timestamp,
|
|
|
|
|
FrameEncryptorInterface* frame_encryptor,
|
2018-10-29 11:22:05 +01:00
|
|
|
bool require_frame_encryption,
|
2019-02-21 07:55:59 +01:00
|
|
|
bool extmap_allow_mixed,
|
|
|
|
|
const WebRtcKeyValueConfig& field_trials)
|
2013-12-13 09:46:59 +00:00
|
|
|
: clock_(clock),
|
2015-12-15 00:30:07 -08:00
|
|
|
random_(clock_->TimeInMicroseconds()),
|
2013-12-13 09:46:59 +00:00
|
|
|
audio_configured_(audio),
|
2019-02-06 22:48:11 +01:00
|
|
|
flexfec_ssrc_(flexfec_ssrc),
|
2013-12-13 09:46:59 +00:00
|
|
|
paced_sender_(paced_sender),
|
2015-09-21 15:11:14 -07:00
|
|
|
transport_sequence_number_allocator_(sequence_number_allocator),
|
2015-09-14 06:42:43 -07:00
|
|
|
transport_feedback_observer_(transport_feedback_observer),
|
2013-12-13 09:46:59 +00:00
|
|
|
transport_(transport),
|
2018-10-10 09:58:08 +02:00
|
|
|
sending_media_(true), // Default to sending media.
|
|
|
|
|
force_part_of_allocation_(false),
|
2017-01-10 08:58:32 -08:00
|
|
|
max_packet_size_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP.
|
2018-03-22 10:13:07 +01:00
|
|
|
last_payload_type_(-1),
|
2018-10-29 11:22:05 +01:00
|
|
|
rtp_header_extension_map_(extmap_allow_mixed),
|
2013-12-04 10:24:26 +00:00
|
|
|
packet_history_(clock),
|
2016-11-14 05:14:50 -08:00
|
|
|
flexfec_packet_history_(clock),
|
2013-01-25 10:53:38 +00:00
|
|
|
// Statistics
|
2018-09-26 09:57:48 +02:00
|
|
|
send_delays_(),
|
|
|
|
|
max_delay_it_(send_delays_.end()),
|
|
|
|
|
sum_delays_ms_(0),
|
2019-05-16 18:38:20 +02:00
|
|
|
total_packet_send_delay_ms_(0),
|
2016-07-13 09:11:28 -07:00
|
|
|
rtp_stats_callback_(nullptr),
|
|
|
|
|
total_bitrate_sent_(kBitrateStatisticsWindowMs,
|
|
|
|
|
RateStatistics::kBpsScale),
|
|
|
|
|
nack_bitrate_sent_(kBitrateStatisticsWindowMs, RateStatistics::kBpsScale),
|
2014-07-11 13:44:02 +00:00
|
|
|
send_side_delay_observer_(send_side_delay_observer),
|
2016-01-21 05:42:04 -08:00
|
|
|
event_log_(event_log),
|
2016-05-02 23:44:01 -07:00
|
|
|
send_packet_observer_(send_packet_observer),
|
2016-07-13 09:11:28 -07:00
|
|
|
bitrate_callback_(bitrate_callback),
|
2013-12-05 14:29:02 +00:00
|
|
|
// RTP variables
|
2013-12-13 09:46:59 +00:00
|
|
|
sequence_number_forced_(false),
|
2016-08-22 03:39:23 -07:00
|
|
|
last_rtp_timestamp_(0),
|
2013-12-13 09:46:59 +00:00
|
|
|
capture_time_ms_(0),
|
|
|
|
|
last_timestamp_time_ms_(0),
|
2014-07-17 16:10:14 +00:00
|
|
|
media_has_been_sent_(false),
|
2013-12-13 09:46:59 +00:00
|
|
|
last_packet_marker_bit_(false),
|
|
|
|
|
csrcs_(),
|
|
|
|
|
rtx_(kRtxOff),
|
2016-11-17 01:38:43 -08:00
|
|
|
rtp_overhead_bytes_per_packet_(0),
|
|
|
|
|
retransmission_rate_limiter_(retransmission_rate_limiter),
|
2017-01-26 02:46:55 -08:00
|
|
|
overhead_observer_(overhead_observer),
|
2018-02-07 14:37:37 +01:00
|
|
|
populate_network2_timestamp_(populate_network2_timestamp),
|
2017-01-26 02:46:55 -08:00
|
|
|
send_side_bwe_with_overhead_(
|
2019-02-21 07:55:59 +01:00
|
|
|
field_trials.Lookup("WebRTC-SendSideBwe-WithOverhead")
|
2019-05-03 10:58:50 -04:00
|
|
|
.find("Enabled") == 0),
|
|
|
|
|
legacy_packet_history_storage_mode_(
|
|
|
|
|
field_trials.Lookup("WebRTC-UseRtpPacketHistoryLegacyStorageMode")
|
2019-02-21 07:55:59 +01:00
|
|
|
.find("Enabled") == 0) {
|
2016-08-18 02:01:49 -07:00
|
|
|
// This random initialization is not intended to be cryptographic strong.
|
|
|
|
|
timestamp_offset_ = random_.Rand<uint32_t>();
|
2013-03-15 23:21:52 +00:00
|
|
|
// Random start, 16 bits. Can't be 0.
|
2015-12-15 00:30:07 -08:00
|
|
|
sequence_number_rtx_ = random_.Rand(1, kMaxInitRtpSeqNumber);
|
|
|
|
|
sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber);
|
2016-11-14 05:14:50 -08:00
|
|
|
|
|
|
|
|
// Store FlexFEC packets in the packet history data structure, so they can
|
|
|
|
|
// be found when paced.
|
2019-02-06 22:48:11 +01:00
|
|
|
if (flexfec_ssrc_) {
|
2019-05-03 10:58:50 -04:00
|
|
|
RtpPacketHistory::StorageMode storage_mode =
|
|
|
|
|
legacy_packet_history_storage_mode_
|
|
|
|
|
? RtpPacketHistory::StorageMode::kStore
|
|
|
|
|
: RtpPacketHistory::StorageMode::kStoreAndCull;
|
|
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
flexfec_packet_history_.SetStorePacketsStatus(
|
2019-05-03 10:58:50 -04:00
|
|
|
storage_mode, kMinFlexfecPacketsToStoreForPacing);
|
2016-11-14 05:14:50 -08:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-19 15:56:10 +00:00
|
|
|
RTPSender::~RTPSender() {
|
2016-02-02 08:31:45 -08:00
|
|
|
// TODO(tommi): Use a thread checker to ensure the object is created and
|
|
|
|
|
// deleted on the same thread. At the moment this isn't possible due to
|
|
|
|
|
// voe::ChannelOwner in voice engine. To reproduce, run:
|
|
|
|
|
// voe_auto_test --automated --gtest_filter=*MixManyChannelsForStressOpus
|
|
|
|
|
|
|
|
|
|
// TODO(tommi,holmer): We don't grab locks in the dtor before accessing member
|
|
|
|
|
// variables but we grab them in all other methods. (what's the design?)
|
|
|
|
|
// Start documenting what thread we're on in what method so that it's easier
|
|
|
|
|
// to understand performance attributes and possibly remove locks.
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-17 05:08:38 -07:00
|
|
|
rtc::ArrayView<const RtpExtensionSize> RTPSender::FecExtensionSizes() {
|
2018-03-15 15:46:17 +01:00
|
|
|
return rtc::MakeArrayView(kFecOrPaddingExtensionSizes,
|
|
|
|
|
arraysize(kFecOrPaddingExtensionSizes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::ArrayView<const RtpExtensionSize> RTPSender::VideoExtensionSizes() {
|
|
|
|
|
return rtc::MakeArrayView(kVideoExtensionSizes,
|
|
|
|
|
arraysize(kVideoExtensionSizes));
|
2017-05-17 05:08:38 -07:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t RTPSender::ActualSendBitrateKbit() const {
|
2016-07-13 09:11:28 -07:00
|
|
|
rtc::CritScope cs(&statistics_crit_);
|
|
|
|
|
return static_cast<uint16_t>(
|
|
|
|
|
total_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0) /
|
|
|
|
|
1000);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t RTPSender::NackOverheadRate() const {
|
2016-07-13 09:11:28 -07:00
|
|
|
rtc::CritScope cs(&statistics_crit_);
|
|
|
|
|
return nack_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0);
|
2011-10-14 14:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-29 11:22:05 +01:00
|
|
|
void RTPSender::SetExtmapAllowMixed(bool extmap_allow_mixed) {
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
rtp_header_extension_map_.SetExtmapAllowMixed(extmap_allow_mixed);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
|
|
|
|
|
uint8_t id) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2017-04-04 02:33:48 -07:00
|
|
|
return rtp_header_extension_map_.RegisterByType(id, type) ? 0 : -1;
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
2018-09-14 18:29:32 +02:00
|
|
|
bool RTPSender::RegisterRtpHeaderExtension(const std::string& uri, int id) {
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
return rtp_header_extension_map_.RegisterByUri(id, uri);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-03 08:13:57 -08:00
|
|
|
bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2015-03-04 22:55:15 +00:00
|
|
|
return rtp_header_extension_map_.IsRegistered(type);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2013-01-25 10:53:38 +00:00
|
|
|
return rtp_header_extension_map_.Deregister(type);
|
2011-12-16 14:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 08:58:32 -08:00
|
|
|
void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
|
2017-08-09 17:22:01 -07:00
|
|
|
RTC_DCHECK_GE(max_packet_size, 100);
|
|
|
|
|
RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2017-01-10 08:58:32 -08:00
|
|
|
max_packet_size_ = max_packet_size;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 08:58:32 -08:00
|
|
|
size_t RTPSender::MaxRtpPacketSize() const {
|
|
|
|
|
return max_packet_size_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-13 14:15:15 +00:00
|
|
|
void RTPSender::SetRtxStatus(int mode) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2013-03-15 23:21:52 +00:00
|
|
|
rtx_ = mode;
|
2014-06-05 08:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-13 14:15:15 +00:00
|
|
|
int RTPSender::RtxStatus() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2015-01-13 14:15:15 +00:00
|
|
|
return rtx_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 08:25:29 +00:00
|
|
|
void RTPSender::SetRtxSsrc(uint32_t ssrc) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
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
|
|
|
ssrc_rtx_.emplace(ssrc);
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-07 13:06:48 +00:00
|
|
|
uint32_t RTPSender::RtxSsrc() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
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
|
|
|
RTC_DCHECK(ssrc_rtx_);
|
|
|
|
|
return *ssrc_rtx_;
|
2014-07-07 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-21 20:24:50 +08:00
|
|
|
void RTPSender::SetRtxPayloadType(int payload_type,
|
|
|
|
|
int associated_payload_type) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_LE(payload_type, 127);
|
|
|
|
|
RTC_DCHECK_LE(associated_payload_type, 127);
|
2015-04-21 20:24:50 +08:00
|
|
|
if (payload_type < 0) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_ERROR) << "Invalid RTX payload type: " << payload_type << ".";
|
2015-04-21 20:24:50 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtx_payload_type_map_[associated_payload_type] = payload_type;
|
2015-04-13 17:48:08 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-01 06:31:17 -07:00
|
|
|
size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send,
|
2017-02-23 02:56:13 -08:00
|
|
|
const PacedPacketInfo& pacing_info) {
|
2014-08-14 08:24:47 +00:00
|
|
|
{
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2016-02-19 16:14:37 +01:00
|
|
|
if (!sending_media_)
|
|
|
|
|
return 0;
|
2014-08-14 08:24:47 +00:00
|
|
|
if ((rtx_ & kRtxRedundantPayloads) == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
int bytes_left = static_cast<int>(bytes_to_send);
|
2013-12-04 10:24:26 +00:00
|
|
|
while (bytes_left > 0) {
|
2016-08-03 18:27:40 +02:00
|
|
|
std::unique_ptr<RtpPacketToSend> packet =
|
|
|
|
|
packet_history_.GetBestFittingPacket(bytes_left);
|
|
|
|
|
if (!packet)
|
2013-12-04 10:24:26 +00:00
|
|
|
break;
|
2016-08-03 18:27:40 +02:00
|
|
|
size_t payload_size = packet->payload_size();
|
2017-02-23 02:56:13 -08:00
|
|
|
if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info))
|
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
|
|
|
break;
|
2016-08-03 18:27:40 +02:00
|
|
|
bytes_left -= payload_size;
|
2013-12-04 10:24:26 +00:00
|
|
|
}
|
|
|
|
|
return bytes_to_send - bytes_left;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 02:56:13 -08:00
|
|
|
size_t RTPSender::SendPadData(size_t bytes,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
2017-02-03 08:13:57 -08:00
|
|
|
size_t padding_bytes_in_packet;
|
2017-05-17 07:50:17 -07:00
|
|
|
size_t max_payload_size = max_packet_size_ - RtpHeaderLength();
|
2017-05-17 05:08:38 -07:00
|
|
|
|
2017-02-03 08:13:57 -08:00
|
|
|
if (audio_configured_) {
|
|
|
|
|
// Allow smaller padding packets for audio.
|
2017-06-12 11:40:47 -07:00
|
|
|
padding_bytes_in_packet = rtc::SafeClamp<size_t>(
|
|
|
|
|
bytes, kMinAudioPaddingLength,
|
|
|
|
|
rtc::SafeMin(max_payload_size, kMaxPaddingLength));
|
2017-02-03 08:13:57 -08:00
|
|
|
} else {
|
|
|
|
|
// Always send full padding packets. This is accounted for by the
|
|
|
|
|
// RtpPacketSender, which will make sure we don't send too much padding even
|
|
|
|
|
// if a single packet is larger than requested.
|
|
|
|
|
// We do this to avoid frequently sending small packets on higher bitrates.
|
2017-06-12 11:40:47 -07:00
|
|
|
padding_bytes_in_packet =
|
|
|
|
|
rtc::SafeMin<size_t>(max_payload_size, kMaxPaddingLength);
|
2017-02-03 08:13:57 -08:00
|
|
|
}
|
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 = 0;
|
2016-12-14 06:16:33 -08:00
|
|
|
while (bytes_sent < bytes) {
|
|
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
2013-06-19 14:13:42 +00:00
|
|
|
uint32_t ssrc;
|
2016-12-14 06:16:33 -08:00
|
|
|
uint32_t timestamp;
|
|
|
|
|
int64_t capture_time_ms;
|
2013-06-19 14:13:42 +00:00
|
|
|
uint16_t sequence_number;
|
2014-08-14 08:24:47 +00:00
|
|
|
int payload_type;
|
2014-07-16 09:37:29 +00:00
|
|
|
bool over_rtx;
|
2013-06-19 14:13:42 +00:00
|
|
|
{
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2016-02-19 16:14:37 +01:00
|
|
|
if (!sending_media_)
|
2016-12-14 06:16:33 -08:00
|
|
|
break;
|
|
|
|
|
timestamp = last_rtp_timestamp_;
|
|
|
|
|
capture_time_ms = capture_time_ms_;
|
2013-06-19 14:13:42 +00:00
|
|
|
if (rtx_ == kRtxOff) {
|
2018-03-22 10:13:07 +01:00
|
|
|
if (last_payload_type_ == -1)
|
2017-02-03 08:13:57 -08:00
|
|
|
break;
|
2014-07-16 09:37:29 +00:00
|
|
|
// Without RTX we can't send padding in the middle of frames.
|
2017-02-03 08:13:57 -08:00
|
|
|
// For audio marker bits doesn't mark the end of a frame and frames
|
|
|
|
|
// are usually a single packet, so for now we don't apply this rule
|
|
|
|
|
// for audio.
|
|
|
|
|
if (!audio_configured_ && !last_packet_marker_bit_) {
|
2016-12-14 06:16:33 -08:00
|
|
|
break;
|
2017-02-03 08:13:57 -08:00
|
|
|
}
|
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
|
|
|
if (!ssrc_) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_ERROR) << "SSRC unset.";
|
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
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RTC_DCHECK(ssrc_);
|
|
|
|
|
ssrc = *ssrc_;
|
|
|
|
|
|
2013-06-19 14:13:42 +00:00
|
|
|
sequence_number = sequence_number_;
|
|
|
|
|
++sequence_number_;
|
2018-03-22 10:13:07 +01:00
|
|
|
payload_type = last_payload_type_;
|
2014-07-16 09:37:29 +00:00
|
|
|
over_rtx = false;
|
2013-06-19 14:13:42 +00:00
|
|
|
} else {
|
2016-01-27 12:58:51 +01:00
|
|
|
// Without abs-send-time or transport sequence number a media packet
|
|
|
|
|
// must be sent before padding so that the timestamps used for
|
|
|
|
|
// estimation are correct.
|
|
|
|
|
if (!media_has_been_sent_ &&
|
2016-12-14 06:16:33 -08:00
|
|
|
!(rtp_header_extension_map_.IsRegistered(AbsoluteSendTime::kId) ||
|
|
|
|
|
(rtp_header_extension_map_.IsRegistered(
|
|
|
|
|
TransportSequenceNumber::kId) &&
|
|
|
|
|
transport_sequence_number_allocator_))) {
|
|
|
|
|
break;
|
2016-01-27 12:58:51 +01:00
|
|
|
}
|
2015-09-18 11:14:31 +02:00
|
|
|
// Only change change the timestamp of padding packets sent over RTX.
|
|
|
|
|
// Padding only packets over RTP has to be sent as part of a media
|
|
|
|
|
// frame (and therefore the same timestamp).
|
|
|
|
|
if (last_timestamp_time_ms_ > 0) {
|
|
|
|
|
timestamp +=
|
2016-12-14 06:16:33 -08:00
|
|
|
(now_ms - last_timestamp_time_ms_) * kTimestampTicksPerMs;
|
|
|
|
|
capture_time_ms += (now_ms - last_timestamp_time_ms_);
|
2015-09-18 11:14:31 +02:00
|
|
|
}
|
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
|
|
|
if (!ssrc_rtx_) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_ERROR) << "RTX SSRC unset.";
|
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
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
RTC_DCHECK(ssrc_rtx_);
|
|
|
|
|
ssrc = *ssrc_rtx_;
|
2013-06-19 14:13:42 +00:00
|
|
|
sequence_number = sequence_number_rtx_;
|
|
|
|
|
++sequence_number_rtx_;
|
2016-02-03 13:29:59 +01:00
|
|
|
payload_type = rtx_payload_type_map_.begin()->second;
|
2014-07-16 09:37:29 +00:00
|
|
|
over_rtx = true;
|
2013-06-19 14:13:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-07-07 13:06:48 +00:00
|
|
|
|
2016-12-14 06:16:33 -08:00
|
|
|
RtpPacketToSend padding_packet(&rtp_header_extension_map_);
|
2016-08-03 18:27:40 +02:00
|
|
|
padding_packet.SetPayloadType(payload_type);
|
|
|
|
|
padding_packet.SetMarker(false);
|
|
|
|
|
padding_packet.SetSequenceNumber(sequence_number);
|
|
|
|
|
padding_packet.SetTimestamp(timestamp);
|
|
|
|
|
padding_packet.SetSsrc(ssrc);
|
2014-07-10 16:24:54 +00:00
|
|
|
|
|
|
|
|
if (capture_time_ms > 0) {
|
2016-08-03 18:27:40 +02:00
|
|
|
padding_packet.SetExtension<TransmissionOffset>(
|
2016-12-14 06:16:33 -08:00
|
|
|
(now_ms - capture_time_ms) * kTimestampTicksPerMs);
|
2012-01-05 10:54:44 +00:00
|
|
|
}
|
2017-06-12 15:43:55 +02:00
|
|
|
padding_packet.SetExtension<AbsoluteSendTime>(
|
|
|
|
|
AbsoluteSendTime::MsTo24Bits(now_ms));
|
2015-10-02 03:39:33 -07:00
|
|
|
PacketOptions options;
|
2018-05-29 08:43:35 +02:00
|
|
|
// Padding packets are never retransmissions.
|
|
|
|
|
options.is_retransmit = false;
|
2018-10-09 18:27:36 +02:00
|
|
|
bool has_transport_seq_num;
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
has_transport_seq_num =
|
|
|
|
|
UpdateTransportSequenceNumber(&padding_packet, &options.packet_id);
|
2018-10-10 09:58:08 +02:00
|
|
|
options.included_in_allocation =
|
|
|
|
|
has_transport_seq_num || force_part_of_allocation_;
|
|
|
|
|
options.included_in_feedback = has_transport_seq_num;
|
2018-10-09 18:27:36 +02:00
|
|
|
}
|
2018-10-10 14:56:01 +02:00
|
|
|
padding_packet.SetPadding(padding_bytes_in_packet);
|
2016-11-17 01:38:43 -08:00
|
|
|
if (has_transport_seq_num) {
|
|
|
|
|
AddPacketToTransportFeedback(options.packet_id, padding_packet,
|
2017-02-23 02:56:13 -08:00
|
|
|
pacing_info);
|
2016-11-17 01:38:43 -08:00
|
|
|
}
|
2016-08-03 18:27:40 +02:00
|
|
|
|
2017-02-27 02:18:46 -08:00
|
|
|
if (!SendPacketToNetwork(padding_packet, options, pacing_info))
|
2015-10-27 08:29:42 -07:00
|
|
|
break;
|
|
|
|
|
|
2013-06-17 12:53:37 +00:00
|
|
|
bytes_sent += padding_bytes_in_packet;
|
2016-08-03 18:27:40 +02:00
|
|
|
UpdateRtpStats(padding_packet, over_rtx, false);
|
2012-01-05 10:54:44 +00:00
|
|
|
}
|
2014-07-10 16:24:54 +00:00
|
|
|
|
2013-06-17 12:53:37 +00:00
|
|
|
return bytes_sent;
|
2012-01-05 10:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) {
|
2019-05-03 10:58:50 -04:00
|
|
|
RtpPacketHistory::StorageMode mode;
|
|
|
|
|
if (enable) {
|
|
|
|
|
mode = legacy_packet_history_storage_mode_
|
|
|
|
|
? RtpPacketHistory::StorageMode::kStore
|
|
|
|
|
: RtpPacketHistory::StorageMode::kStoreAndCull;
|
|
|
|
|
} else {
|
|
|
|
|
mode = RtpPacketHistory::StorageMode::kDisabled;
|
|
|
|
|
}
|
2018-03-14 12:39:24 +01:00
|
|
|
packet_history_.SetStorePacketsStatus(mode, number_to_store);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-27 00:41:08 +00:00
|
|
|
bool RTPSender::StorePackets() const {
|
2018-03-14 12:39:24 +01:00
|
|
|
return packet_history_.GetStorageMode() !=
|
|
|
|
|
RtpPacketHistory::StorageMode::kDisabled;
|
2013-04-27 00:41:08 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2018-03-14 12:39:24 +01:00
|
|
|
int32_t RTPSender::ReSendPacket(uint16_t packet_id) {
|
|
|
|
|
// Try to find packet in RTP packet history. Also verify RTT here, so that we
|
|
|
|
|
// don't retransmit too often.
|
2018-06-14 12:59:38 +02:00
|
|
|
absl::optional<RtpPacketHistory::PacketState> stored_packet =
|
2018-10-16 11:01:05 +02:00
|
|
|
packet_history_.GetPacketState(packet_id);
|
2019-05-08 10:15:05 -07:00
|
|
|
if (!stored_packet || stored_packet->pending_transmission) {
|
|
|
|
|
// Packet not found or already queued for retransmission, ignore.
|
2012-04-23 12:43:05 +00:00
|
|
|
return 0;
|
2012-01-16 11:06:31 +00:00
|
|
|
}
|
2018-03-09 12:27:24 +00:00
|
|
|
|
2019-02-20 13:14:34 +01:00
|
|
|
const int32_t packet_size = static_cast<int32_t>(stored_packet->packet_size);
|
2018-03-14 12:39:24 +01:00
|
|
|
|
2018-09-11 14:28:19 +02:00
|
|
|
// Skip retransmission rate check if not configured.
|
|
|
|
|
if (retransmission_rate_limiter_) {
|
|
|
|
|
// Check if we're overusing retransmission bitrate.
|
|
|
|
|
// TODO(sprang): Add histograms for nack success or failure reasons.
|
2018-10-10 15:17:39 +02:00
|
|
|
if (!retransmission_rate_limiter_->TryUseRate(packet_size)) {
|
2018-09-11 14:28:19 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
2018-03-14 12:39:24 +01:00
|
|
|
}
|
2018-03-09 09:52:59 +01:00
|
|
|
|
2018-03-09 12:27:24 +00:00
|
|
|
if (paced_sender_) {
|
2019-05-08 10:15:05 -07:00
|
|
|
// Mark packet as being in pacer queue again, to prevent duplicates.
|
|
|
|
|
if (!packet_history_.SetPendingTransmission(packet_id)) {
|
|
|
|
|
// Packet has already been removed from history, return early.
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-14 12:39:24 +01:00
|
|
|
paced_sender_->InsertPacket(
|
|
|
|
|
RtpPacketSender::kNormalPriority, stored_packet->ssrc,
|
2019-05-14 15:57:19 +02:00
|
|
|
stored_packet->rtp_sequence_number, stored_packet->capture_time_ms,
|
2019-02-20 13:14:34 +01:00
|
|
|
stored_packet->packet_size, true);
|
2018-03-09 12:27:24 +00:00
|
|
|
|
2018-03-14 12:39:24 +01:00
|
|
|
return packet_size;
|
2018-03-09 12:27:24 +00:00
|
|
|
}
|
2018-03-14 12:39:24 +01:00
|
|
|
|
|
|
|
|
std::unique_ptr<RtpPacketToSend> packet =
|
2018-10-16 11:01:05 +02:00
|
|
|
packet_history_.GetPacketAndSetSendTime(packet_id);
|
2018-03-14 12:39:24 +01:00
|
|
|
if (!packet) {
|
|
|
|
|
// Packet could theoretically time out between the first check and this one.
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool rtx = (RtxStatus() & kRtxRetransmitted) > 0;
|
2017-02-23 02:56:13 -08:00
|
|
|
if (!PrepareAndSendPacket(std::move(packet), rtx, true, PacedPacketInfo()))
|
2015-08-03 04:38:41 -07:00
|
|
|
return -1;
|
2018-03-14 12:39:24 +01:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
return packet_size;
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
bool RTPSender::SendPacketToNetwork(const RtpPacketToSend& packet,
|
2017-02-27 02:18:46 -08:00
|
|
|
const PacketOptions& options,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
2013-04-27 00:41:08 +00:00
|
|
|
int bytes_sent = -1;
|
2013-01-25 10:53:38 +00:00
|
|
|
if (transport_) {
|
2016-11-17 01:38:43 -08:00
|
|
|
UpdateRtpOverhead(packet);
|
2016-08-03 18:27:40 +02:00
|
|
|
bytes_sent = transport_->SendRtp(packet.data(), packet.size(), options)
|
|
|
|
|
? static_cast<int>(packet.size())
|
2015-10-02 03:39:33 -07:00
|
|
|
: -1;
|
2016-01-21 05:42:04 -08:00
|
|
|
if (event_log_ && bytes_sent > 0) {
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
event_log_->Log(absl::make_unique<RtcEventRtpPacketOutgoing>(
|
2017-10-03 16:11:34 +02:00
|
|
|
packet, pacing_info.probe_cluster_id));
|
2016-01-21 05:42:04 -08:00
|
|
|
}
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
2014-04-08 11:06:12 +00:00
|
|
|
// TODO(pwestin): Add a separate bitrate for sent bitrate after pacer.
|
2012-01-16 11:06:31 +00:00
|
|
|
if (bytes_sent <= 0) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Transport failed to send packet.";
|
2013-04-27 00:41:08 +00:00
|
|
|
return false;
|
2012-01-10 14:09:18 +00:00
|
|
|
}
|
2013-04-27 00:41:08 +00:00
|
|
|
return true;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-26 18:48:46 +02:00
|
|
|
void RTPSender::OnReceivedNack(
|
|
|
|
|
const std::vector<uint16_t>& nack_sequence_numbers,
|
|
|
|
|
int64_t avg_rtt) {
|
2018-03-14 12:39:24 +01:00
|
|
|
packet_history_.SetRtt(5 + avg_rtt);
|
2016-07-13 09:11:28 -07:00
|
|
|
for (uint16_t seq_no : nack_sequence_numbers) {
|
2018-03-14 12:39:24 +01:00
|
|
|
const int32_t bytes_sent = ReSendPacket(seq_no);
|
2016-07-13 09:11:28 -07:00
|
|
|
if (bytes_sent < 0) {
|
2012-01-10 14:09:18 +00:00
|
|
|
// Failed to send one Sequence number. Give up the rest in this nack.
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed resending RTP packet " << seq_no
|
|
|
|
|
<< ", Discard rest of packets.";
|
2012-01-10 14:09:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-27 00:41:08 +00:00
|
|
|
// Called from pacer when we can send the packet.
|
2019-05-10 08:29:01 -07:00
|
|
|
RtpPacketSendResult RTPSender::TimeToSendPacket(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
uint16_t sequence_number,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
bool retransmission,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
|
|
|
|
if (!SendingMedia()) {
|
|
|
|
|
return RtpPacketSendResult::kPacketNotFound;
|
|
|
|
|
}
|
2016-11-14 05:14:50 -08:00
|
|
|
|
|
|
|
|
std::unique_ptr<RtpPacketToSend> packet;
|
|
|
|
|
if (ssrc == SSRC()) {
|
2018-10-16 11:01:05 +02:00
|
|
|
packet = packet_history_.GetPacketAndSetSendTime(sequence_number);
|
2016-11-14 05:14:50 -08:00
|
|
|
} else if (ssrc == FlexfecSsrc()) {
|
2018-10-16 11:01:05 +02:00
|
|
|
packet = flexfec_packet_history_.GetPacketAndSetSendTime(sequence_number);
|
2016-11-14 05:14:50 -08:00
|
|
|
}
|
|
|
|
|
|
2016-08-23 17:51:42 +02:00
|
|
|
if (!packet) {
|
2019-05-10 08:29:01 -07:00
|
|
|
// Packet cannot be found or was resent too recently.
|
|
|
|
|
return RtpPacketSendResult::kPacketNotFound;
|
2016-08-23 17:51:42 +02:00
|
|
|
}
|
2016-05-02 23:44:01 -07:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
return PrepareAndSendPacket(
|
2019-05-10 08:29:01 -07:00
|
|
|
std::move(packet),
|
|
|
|
|
retransmission && (RtxStatus() & kRtxRetransmitted) > 0,
|
|
|
|
|
retransmission, pacing_info)
|
|
|
|
|
? RtpPacketSendResult::kSuccess
|
|
|
|
|
: RtpPacketSendResult::kTransportUnavailable;
|
2013-12-04 10:24:26 +00:00
|
|
|
}
|
2012-01-16 11:06:31 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
bool RTPSender::PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet,
|
2014-03-19 18:14:52 +00:00
|
|
|
bool send_over_rtx,
|
2016-06-01 06:31:17 -07:00
|
|
|
bool is_retransmit,
|
2017-02-23 02:56:13 -08:00
|
|
|
const PacedPacketInfo& pacing_info) {
|
2016-08-03 18:27:40 +02:00
|
|
|
RTC_DCHECK(packet);
|
|
|
|
|
int64_t capture_time_ms = packet->capture_time_ms();
|
|
|
|
|
RtpPacketToSend* packet_to_send = packet.get();
|
2013-12-04 10:24:26 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
std::unique_ptr<RtpPacketToSend> packet_rtx;
|
2013-12-04 10:24:26 +00:00
|
|
|
if (send_over_rtx) {
|
2016-08-03 18:27:40 +02:00
|
|
|
packet_rtx = BuildRtxPacket(*packet);
|
|
|
|
|
if (!packet_rtx)
|
2016-08-01 06:58:34 -07:00
|
|
|
return false;
|
2016-08-03 18:27:40 +02:00
|
|
|
packet_to_send = packet_rtx.get();
|
2013-11-13 15:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 08:23:19 -07:00
|
|
|
// Bug webrtc:7859. While FEC is invoked from rtp_sender_video, and not after
|
|
|
|
|
// the pacer, these modifications of the header below are happening after the
|
|
|
|
|
// FEC protection packets are calculated. This will corrupt recovered packets
|
|
|
|
|
// at the same place. It's not an issue for extensions, which are present in
|
|
|
|
|
// all the packets (their content just may be incorrect on recovered packets).
|
|
|
|
|
// In case of VideoTimingExtension, since it's present not in every packet,
|
|
|
|
|
// data after rtp header may be corrupted if these packets are protected by
|
|
|
|
|
// the FEC.
|
2013-05-16 11:10:31 +00:00
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
|
|
|
|
int64_t diff_ms = now_ms - capture_time_ms;
|
2016-08-03 18:27:40 +02:00
|
|
|
packet_to_send->SetExtension<TransmissionOffset>(kTimestampTicksPerMs *
|
|
|
|
|
diff_ms);
|
2017-06-12 15:43:55 +02:00
|
|
|
packet_to_send->SetExtension<AbsoluteSendTime>(
|
|
|
|
|
AbsoluteSendTime::MsTo24Bits(now_ms));
|
2015-08-03 04:38:41 -07:00
|
|
|
|
2018-02-07 14:37:37 +01:00
|
|
|
if (packet_to_send->HasExtension<VideoTimingExtension>()) {
|
|
|
|
|
if (populate_network2_timestamp_) {
|
|
|
|
|
packet_to_send->set_network2_time_ms(now_ms);
|
|
|
|
|
} else {
|
|
|
|
|
packet_to_send->set_pacer_exit_time_ms(now_ms);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-19 07:18:55 -07:00
|
|
|
|
2015-10-02 03:39:33 -07:00
|
|
|
PacketOptions options;
|
2018-05-29 08:43:35 +02:00
|
|
|
// If we are sending over RTX, it also means this is a retransmission.
|
|
|
|
|
// E.g. RTPSender::TrySendRedundantPayloads calls PrepareAndSendPacket with
|
|
|
|
|
// send_over_rtx = true but is_retransmit = false.
|
|
|
|
|
options.is_retransmit = is_retransmit || send_over_rtx;
|
2018-10-09 18:27:36 +02:00
|
|
|
bool has_transport_seq_num;
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
has_transport_seq_num =
|
|
|
|
|
UpdateTransportSequenceNumber(packet_to_send, &options.packet_id);
|
2018-10-10 09:58:08 +02:00
|
|
|
options.included_in_allocation =
|
|
|
|
|
has_transport_seq_num || force_part_of_allocation_;
|
|
|
|
|
options.included_in_feedback = has_transport_seq_num;
|
2018-10-09 18:27:36 +02:00
|
|
|
}
|
|
|
|
|
if (has_transport_seq_num) {
|
2016-11-17 01:38:43 -08:00
|
|
|
AddPacketToTransportFeedback(options.packet_id, *packet_to_send,
|
2017-02-23 02:56:13 -08:00
|
|
|
pacing_info);
|
2015-08-03 04:38:41 -07:00
|
|
|
}
|
2018-02-22 14:18:06 +01:00
|
|
|
options.application_data.assign(packet_to_send->application_data().begin(),
|
|
|
|
|
packet_to_send->application_data().end());
|
2015-08-03 04:38:41 -07:00
|
|
|
|
2016-05-02 23:44:01 -07:00
|
|
|
if (!is_retransmit && !send_over_rtx) {
|
2016-08-03 18:27:40 +02:00
|
|
|
UpdateDelayStatistics(packet->capture_time_ms(), now_ms);
|
|
|
|
|
UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(),
|
|
|
|
|
packet->Ssrc());
|
2015-10-27 08:29:42 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 02:18:46 -08:00
|
|
|
if (!SendPacketToNetwork(*packet_to_send, options, pacing_info))
|
2016-08-03 18:27:40 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
{
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2014-07-17 16:10:14 +00:00
|
|
|
media_has_been_sent_ = true;
|
|
|
|
|
}
|
2016-08-03 18:27:40 +02:00
|
|
|
UpdateRtpStats(*packet_to_send, send_over_rtx, is_retransmit);
|
|
|
|
|
return true;
|
2013-12-05 14:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
void RTPSender::UpdateRtpStats(const RtpPacketToSend& packet,
|
2013-12-05 14:29:02 +00:00
|
|
|
bool is_rtx,
|
|
|
|
|
bool is_retransmit) {
|
2016-07-13 09:11:28 -07:00
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
2014-01-27 13:20:36 +00:00
|
|
|
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope lock(&statistics_crit_);
|
2016-09-20 15:48:09 +02:00
|
|
|
StreamDataCounters* counters = is_rtx ? &rtx_rtp_stats_ : &rtp_stats_;
|
2013-12-05 14:29:02 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
total_bitrate_sent_.Update(packet.size(), now_ms);
|
2015-02-04 08:34:47 +00:00
|
|
|
|
2016-09-20 15:48:09 +02:00
|
|
|
if (counters->first_packet_time_ms == -1)
|
|
|
|
|
counters->first_packet_time_ms = now_ms;
|
|
|
|
|
|
2019-01-28 12:52:43 +01:00
|
|
|
if (packet.is_fec())
|
2018-11-15 08:05:16 +01:00
|
|
|
counters->fec.AddPacket(packet);
|
2016-09-20 15:48:09 +02:00
|
|
|
|
2013-12-05 14:29:02 +00:00
|
|
|
if (is_retransmit) {
|
2018-11-15 08:05:16 +01:00
|
|
|
counters->retransmitted.AddPacket(packet);
|
2016-08-03 18:27:40 +02:00
|
|
|
nack_bitrate_sent_.Update(packet.size(), now_ms);
|
2015-02-04 08:34:47 +00:00
|
|
|
}
|
2018-11-15 08:05:16 +01:00
|
|
|
counters->transmitted.AddPacket(packet);
|
2016-07-13 09:11:28 -07:00
|
|
|
|
2016-09-20 15:48:09 +02:00
|
|
|
if (rtp_stats_callback_)
|
|
|
|
|
rtp_stats_callback_->DataCountersUpdated(*counters, packet.Ssrc());
|
2013-12-05 14:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
2017-02-23 02:56:13 -08:00
|
|
|
size_t RTPSender::TimeToSendPadding(size_t bytes,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
2017-02-03 08:13:57 -08:00
|
|
|
if (bytes == 0)
|
2015-07-01 06:31:06 -07:00
|
|
|
return 0;
|
2017-02-23 02:56:13 -08:00
|
|
|
size_t bytes_sent = TrySendRedundantPayloads(bytes, pacing_info);
|
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
|
|
|
if (bytes_sent < bytes)
|
2017-02-23 02:56:13 -08:00
|
|
|
bytes_sent += SendPadData(bytes - bytes_sent, pacing_info);
|
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
|
|
|
return bytes_sent;
|
2013-06-17 12:53:37 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet,
|
|
|
|
|
StorageType storage,
|
|
|
|
|
RtpPacketSender::Priority priority) {
|
|
|
|
|
RTC_DCHECK(packet);
|
2013-05-16 11:10:31 +00:00
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
|
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
uint32_t ssrc = packet->Ssrc();
|
2015-10-08 11:44:14 +02:00
|
|
|
if (paced_sender_) {
|
2016-08-03 18:27:40 +02:00
|
|
|
uint16_t seq_no = packet->SequenceNumber();
|
2019-05-14 15:57:19 +02:00
|
|
|
int64_t capture_time_ms = packet->capture_time_ms();
|
2019-02-20 12:06:17 +01:00
|
|
|
size_t packet_size =
|
|
|
|
|
send_side_bwe_with_overhead_ ? packet->size() : packet->payload_size();
|
2019-02-06 22:48:11 +01:00
|
|
|
if (ssrc == FlexfecSsrc()) {
|
2016-11-14 05:14:50 -08:00
|
|
|
// Store FlexFEC packets in the history here, so they can be found
|
|
|
|
|
// when the pacer calls TimeToSendPacket.
|
2018-03-14 12:39:24 +01:00
|
|
|
flexfec_packet_history_.PutRtpPacket(std::move(packet), storage,
|
2018-06-14 12:59:38 +02:00
|
|
|
absl::nullopt);
|
2016-11-14 05:14:50 -08:00
|
|
|
} else {
|
2018-06-14 12:59:38 +02:00
|
|
|
packet_history_.PutRtpPacket(std::move(packet), storage, absl::nullopt);
|
2016-11-14 05:14:50 -08:00
|
|
|
}
|
2016-08-03 18:27:40 +02:00
|
|
|
|
2019-05-14 15:57:19 +02:00
|
|
|
paced_sender_->InsertPacket(priority, ssrc, seq_no, capture_time_ms,
|
2019-02-20 12:06:17 +01:00
|
|
|
packet_size, false);
|
2016-08-02 17:46:41 -07:00
|
|
|
return true;
|
2012-07-03 13:21:22 +00:00
|
|
|
}
|
2016-01-27 12:58:51 +01:00
|
|
|
|
|
|
|
|
PacketOptions options;
|
2018-05-29 08:43:35 +02:00
|
|
|
options.is_retransmit = false;
|
2018-10-09 18:27:36 +02:00
|
|
|
|
2018-11-27 10:48:27 +01:00
|
|
|
// |capture_time_ms| <= 0 is considered invalid.
|
|
|
|
|
// TODO(holmer): This should be changed all over Video Engine so that negative
|
|
|
|
|
// time is consider invalid, while 0 is considered a valid time.
|
|
|
|
|
if (packet->capture_time_ms() > 0) {
|
|
|
|
|
packet->SetExtension<TransmissionOffset>(
|
|
|
|
|
kTimestampTicksPerMs * (now_ms - packet->capture_time_ms()));
|
|
|
|
|
|
|
|
|
|
if (populate_network2_timestamp_ &&
|
|
|
|
|
packet->HasExtension<VideoTimingExtension>()) {
|
|
|
|
|
packet->set_network2_time_ms(now_ms);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
packet->SetExtension<AbsoluteSendTime>(AbsoluteSendTime::MsTo24Bits(now_ms));
|
|
|
|
|
|
2018-10-09 18:27:36 +02:00
|
|
|
bool has_transport_seq_num;
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
has_transport_seq_num =
|
|
|
|
|
UpdateTransportSequenceNumber(packet.get(), &options.packet_id);
|
2018-10-10 09:58:08 +02:00
|
|
|
options.included_in_allocation =
|
|
|
|
|
has_transport_seq_num || force_part_of_allocation_;
|
|
|
|
|
options.included_in_feedback = has_transport_seq_num;
|
2018-10-09 18:27:36 +02:00
|
|
|
}
|
|
|
|
|
if (has_transport_seq_num) {
|
2016-11-17 01:38:43 -08:00
|
|
|
AddPacketToTransportFeedback(options.packet_id, *packet.get(),
|
2017-02-23 02:56:13 -08:00
|
|
|
PacedPacketInfo());
|
2016-01-27 12:58:51 +01:00
|
|
|
}
|
2018-02-22 14:18:06 +01:00
|
|
|
options.application_data.assign(packet->application_data().begin(),
|
|
|
|
|
packet->application_data().end());
|
2016-01-27 12:58:51 +01:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
UpdateDelayStatistics(packet->capture_time_ms(), now_ms);
|
|
|
|
|
UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(),
|
|
|
|
|
packet->Ssrc());
|
|
|
|
|
|
2017-02-27 02:18:46 -08:00
|
|
|
bool sent = SendPacketToNetwork(*packet, options, PacedPacketInfo());
|
2016-08-03 18:27:40 +02:00
|
|
|
|
|
|
|
|
if (sent) {
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
media_has_been_sent_ = true;
|
|
|
|
|
}
|
|
|
|
|
UpdateRtpStats(*packet, false, false);
|
|
|
|
|
}
|
2015-02-02 13:08:02 +00:00
|
|
|
|
2016-11-14 05:14:50 -08:00
|
|
|
// To support retransmissions, we store the media packet as sent in the
|
|
|
|
|
// packet history (even if send failed).
|
|
|
|
|
if (storage == kAllowRetransmission) {
|
2017-12-27 11:32:50 +01:00
|
|
|
RTC_DCHECK_EQ(ssrc, SSRC());
|
2018-03-14 12:39:24 +01:00
|
|
|
packet_history_.PutRtpPacket(std::move(packet), storage, now_ms);
|
2016-11-14 05:14:50 -08:00
|
|
|
}
|
2015-02-02 13:08:02 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
return sent;
|
2011-12-22 12:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
2018-09-26 09:57:48 +02:00
|
|
|
void RTPSender::RecomputeMaxSendDelay() {
|
|
|
|
|
max_delay_it_ = send_delays_.begin();
|
|
|
|
|
for (auto it = send_delays_.begin(); it != send_delays_.end(); ++it) {
|
|
|
|
|
if (it->second >= max_delay_it_->second) {
|
|
|
|
|
max_delay_it_ = it;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 14:05:07 +00:00
|
|
|
void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) {
|
2016-05-02 23:44:01 -07:00
|
|
|
if (!send_side_delay_observer_ || capture_time_ms <= 0)
|
2015-05-28 14:45:36 +02:00
|
|
|
return;
|
|
|
|
|
|
2014-07-11 13:44:02 +00:00
|
|
|
uint32_t ssrc;
|
2018-09-26 09:57:48 +02:00
|
|
|
int avg_delay_ms = 0;
|
2014-07-11 13:44:02 +00:00
|
|
|
int max_delay_ms = 0;
|
2019-05-16 18:38:20 +02:00
|
|
|
uint64_t total_packet_send_delay_ms = 0;
|
2014-07-11 13:44:02 +00:00
|
|
|
{
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
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
|
|
|
if (!ssrc_)
|
|
|
|
|
return;
|
|
|
|
|
ssrc = *ssrc_;
|
2014-07-11 13:44:02 +00:00
|
|
|
}
|
|
|
|
|
{
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope cs(&statistics_crit_);
|
2018-09-26 09:57:48 +02:00
|
|
|
// Compute the max and average of the recent capture-to-send delays.
|
|
|
|
|
// The time complexity of the current approach depends on the distribution
|
|
|
|
|
// of the delay values. This could be done more efficiently.
|
|
|
|
|
|
|
|
|
|
// Remove elements older than kSendSideDelayWindowMs.
|
|
|
|
|
auto lower_bound =
|
|
|
|
|
send_delays_.lower_bound(now_ms - kSendSideDelayWindowMs);
|
|
|
|
|
for (auto it = send_delays_.begin(); it != lower_bound; ++it) {
|
|
|
|
|
if (max_delay_it_ == it) {
|
|
|
|
|
max_delay_it_ = send_delays_.end();
|
|
|
|
|
}
|
|
|
|
|
sum_delays_ms_ -= it->second;
|
|
|
|
|
}
|
|
|
|
|
send_delays_.erase(send_delays_.begin(), lower_bound);
|
|
|
|
|
if (max_delay_it_ == send_delays_.end()) {
|
|
|
|
|
// Removed the previous max. Need to recompute.
|
|
|
|
|
RecomputeMaxSendDelay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add the new element.
|
2018-09-13 15:36:20 +02:00
|
|
|
RTC_DCHECK_GE(now_ms, static_cast<int64_t>(0));
|
|
|
|
|
RTC_DCHECK_LE(now_ms, std::numeric_limits<int64_t>::max() / 2);
|
|
|
|
|
RTC_DCHECK_GE(capture_time_ms, static_cast<int64_t>(0));
|
|
|
|
|
RTC_DCHECK_LE(capture_time_ms, std::numeric_limits<int64_t>::max() / 2);
|
|
|
|
|
int64_t diff_ms = now_ms - capture_time_ms;
|
|
|
|
|
RTC_DCHECK_GE(diff_ms, static_cast<int64_t>(0));
|
|
|
|
|
RTC_DCHECK_LE(diff_ms,
|
|
|
|
|
static_cast<int64_t>(std::numeric_limits<int>::max()));
|
2018-09-26 09:57:48 +02:00
|
|
|
int new_send_delay = rtc::dchecked_cast<int>(now_ms - capture_time_ms);
|
|
|
|
|
SendDelayMap::iterator it;
|
|
|
|
|
bool inserted;
|
|
|
|
|
std::tie(it, inserted) =
|
|
|
|
|
send_delays_.insert(std::make_pair(now_ms, new_send_delay));
|
|
|
|
|
if (!inserted) {
|
|
|
|
|
// TODO(terelius): If we have multiple delay measurements during the same
|
|
|
|
|
// millisecond then we keep the most recent one. It is not clear that this
|
|
|
|
|
// is the right decision, but it preserves an earlier behavior.
|
|
|
|
|
int previous_send_delay = it->second;
|
|
|
|
|
sum_delays_ms_ -= previous_send_delay;
|
|
|
|
|
it->second = new_send_delay;
|
|
|
|
|
if (max_delay_it_ == it && new_send_delay < previous_send_delay) {
|
|
|
|
|
RecomputeMaxSendDelay();
|
|
|
|
|
}
|
2018-08-29 17:27:31 +02:00
|
|
|
}
|
2018-09-26 09:57:48 +02:00
|
|
|
if (max_delay_it_ == send_delays_.end() ||
|
|
|
|
|
it->second >= max_delay_it_->second) {
|
|
|
|
|
max_delay_it_ = it;
|
|
|
|
|
}
|
|
|
|
|
sum_delays_ms_ += new_send_delay;
|
2019-05-16 18:38:20 +02:00
|
|
|
total_packet_send_delay_ms_ += new_send_delay;
|
|
|
|
|
total_packet_send_delay_ms = total_packet_send_delay_ms_;
|
2018-09-26 09:57:48 +02:00
|
|
|
|
|
|
|
|
size_t num_delays = send_delays_.size();
|
|
|
|
|
RTC_DCHECK(max_delay_it_ != send_delays_.end());
|
|
|
|
|
max_delay_ms = rtc::dchecked_cast<int>(max_delay_it_->second);
|
|
|
|
|
int64_t avg_ms = (sum_delays_ms_ + num_delays / 2) / num_delays;
|
|
|
|
|
RTC_DCHECK_GE(avg_ms, static_cast<int64_t>(0));
|
|
|
|
|
RTC_DCHECK_LE(avg_ms,
|
|
|
|
|
static_cast<int64_t>(std::numeric_limits<int>::max()));
|
|
|
|
|
avg_delay_ms =
|
|
|
|
|
rtc::dchecked_cast<int>((sum_delays_ms_ + num_delays / 2) / num_delays);
|
2014-07-11 13:44:02 +00:00
|
|
|
}
|
2019-05-16 18:38:20 +02:00
|
|
|
send_side_delay_observer_->SendSideDelayUpdated(
|
|
|
|
|
avg_delay_ms, max_delay_ms, total_packet_send_delay_ms, ssrc);
|
2013-12-05 14:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 23:44:01 -07:00
|
|
|
void RTPSender::UpdateOnSendPacket(int packet_id,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
uint32_t ssrc) {
|
|
|
|
|
if (!send_packet_observer_ || capture_time_ms <= 0 || packet_id == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
send_packet_observer_->OnSendPacket(packet_id, capture_time_ms, ssrc);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-07 17:01:04 +00:00
|
|
|
void RTPSender::ProcessBitrate() {
|
2016-07-13 09:11:28 -07:00
|
|
|
if (!bitrate_callback_)
|
2012-11-07 17:01:04 +00:00
|
|
|
return;
|
2016-07-13 09:11:28 -07:00
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
|
|
|
|
uint32_t ssrc;
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
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
|
|
|
if (!ssrc_)
|
|
|
|
|
return;
|
|
|
|
|
ssrc = *ssrc_;
|
2012-11-07 17:01:04 +00:00
|
|
|
}
|
2016-07-13 09:11:28 -07:00
|
|
|
|
|
|
|
|
rtc::CritScope lock(&statistics_crit_);
|
|
|
|
|
bitrate_callback_->Notify(total_bitrate_sent_.Rate(now_ms).value_or(0),
|
|
|
|
|
nack_bitrate_sent_.Rate(now_ms).value_or(0), ssrc);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-08 00:24:21 -07:00
|
|
|
size_t RTPSender::RtpHeaderLength() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2015-03-04 22:55:15 +00:00
|
|
|
size_t rtp_header_length = kRtpHeaderLength;
|
2014-11-24 08:25:50 +00:00
|
|
|
rtp_header_length += sizeof(uint32_t) * csrcs_.size();
|
2018-10-03 10:15:36 +02:00
|
|
|
rtp_header_length += RtpHeaderExtensionSize(kFecOrPaddingExtensionSizes,
|
|
|
|
|
rtp_header_extension_map_);
|
2013-01-25 10:53:38 +00:00
|
|
|
return rtp_header_length;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-14 21:28:08 +02:00
|
|
|
uint16_t RTPSender::AllocateSequenceNumber(uint16_t packets_to_send) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2015-04-14 21:28:08 +02:00
|
|
|
uint16_t first_allocated_sequence_number = sequence_number_;
|
|
|
|
|
sequence_number_ += packets_to_send;
|
|
|
|
|
return first_allocated_sequence_number;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-15 15:25:39 +00:00
|
|
|
void RTPSender::GetDataCounters(StreamDataCounters* rtp_stats,
|
|
|
|
|
StreamDataCounters* rtx_stats) const {
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope lock(&statistics_crit_);
|
2014-07-15 15:25:39 +00:00
|
|
|
*rtp_stats = rtp_stats_;
|
|
|
|
|
*rtx_stats = rtx_rtp_stats_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-02 19:15:59 +02:00
|
|
|
std::unique_ptr<RtpPacketToSend> RTPSender::AllocatePacket() const {
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2018-10-12 12:50:43 +02:00
|
|
|
// TODO(danilchap): Find better motivator and value for extra capacity.
|
|
|
|
|
// RtpPacketizer might slightly miscalulate needed size,
|
|
|
|
|
// SRTP may benefit from extra space in the buffer and do encryption in place
|
|
|
|
|
// saving reallocation.
|
|
|
|
|
// While sending slightly oversized packet increase chance of dropped packet,
|
|
|
|
|
// it is better than crash on drop packet without trying to send it.
|
|
|
|
|
static constexpr int kExtraCapacity = 16;
|
|
|
|
|
auto packet = absl::make_unique<RtpPacketToSend>(
|
|
|
|
|
&rtp_header_extension_map_, max_packet_size_ + kExtraCapacity);
|
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
|
|
|
RTC_DCHECK(ssrc_);
|
|
|
|
|
packet->SetSsrc(*ssrc_);
|
2016-09-02 19:15:59 +02:00
|
|
|
packet->SetCsrcs(csrcs_);
|
|
|
|
|
// Reserve extensions, if registered, RtpSender set in SendToNetwork.
|
|
|
|
|
packet->ReserveExtension<AbsoluteSendTime>();
|
|
|
|
|
packet->ReserveExtension<TransmissionOffset>();
|
|
|
|
|
packet->ReserveExtension<TransportSequenceNumber>();
|
2019-01-31 08:56:26 +01:00
|
|
|
|
2018-04-06 11:09:46 -07:00
|
|
|
if (!mid_.empty()) {
|
2018-03-22 15:17:27 -07:00
|
|
|
// This is a no-op if the MID header extension is not registered.
|
2018-04-06 11:09:46 -07:00
|
|
|
packet->SetExtension<RtpMid>(mid_);
|
2018-03-22 15:17:27 -07:00
|
|
|
}
|
2018-12-21 09:23:38 -08:00
|
|
|
if (!rid_.empty()) {
|
|
|
|
|
// This is a no-op if the RID header extension is not registered.
|
|
|
|
|
packet->SetExtension<RtpStreamId>(rid_);
|
|
|
|
|
}
|
2016-09-02 19:15:59 +02:00
|
|
|
return packet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RTPSender::AssignSequenceNumber(RtpPacketToSend* packet) {
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
if (!sending_media_)
|
|
|
|
|
return false;
|
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
|
|
|
RTC_DCHECK(packet->Ssrc() == ssrc_);
|
2016-09-02 19:15:59 +02:00
|
|
|
packet->SetSequenceNumber(sequence_number_++);
|
|
|
|
|
|
|
|
|
|
// Remember marker bit to determine if padding can be inserted with
|
|
|
|
|
// sequence number following |packet|.
|
|
|
|
|
last_packet_marker_bit_ = packet->Marker();
|
2018-03-22 10:13:07 +01:00
|
|
|
// Remember payload type to use in the padding packet if rtx is disabled.
|
|
|
|
|
last_payload_type_ = packet->PayloadType();
|
2016-09-02 19:15:59 +02:00
|
|
|
// Save timestamps to generate timestamp field and extensions for the padding.
|
|
|
|
|
last_rtp_timestamp_ = packet->Timestamp();
|
|
|
|
|
last_timestamp_time_ms_ = clock_->TimeInMilliseconds();
|
|
|
|
|
capture_time_ms_ = packet->capture_time_ms();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
bool RTPSender::UpdateTransportSequenceNumber(RtpPacketToSend* packet,
|
2018-10-09 18:27:36 +02:00
|
|
|
int* packet_id) {
|
2016-08-03 18:27:40 +02:00
|
|
|
RTC_DCHECK(packet);
|
|
|
|
|
RTC_DCHECK(packet_id);
|
|
|
|
|
if (!rtp_header_extension_map_.IsRegistered(TransportSequenceNumber::kId))
|
2016-07-28 07:56:38 -07:00
|
|
|
return false;
|
|
|
|
|
|
2016-05-02 23:44:01 -07:00
|
|
|
if (!transport_sequence_number_allocator_)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*packet_id = transport_sequence_number_allocator_->AllocateSequenceNumber();
|
2016-08-03 18:27:40 +02:00
|
|
|
|
|
|
|
|
if (!packet->SetExtension<TransportSequenceNumber>(*packet_id))
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-05-02 23:44:01 -07:00
|
|
|
return true;
|
2015-08-03 04:38:41 -07:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 13:49:55 +00:00
|
|
|
void RTPSender::SetSendingMediaStatus(bool enabled) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2013-01-25 10:53:38 +00:00
|
|
|
sending_media_ = enabled;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-07 17:01:04 +00:00
|
|
|
bool RTPSender::SendingMedia() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2013-01-25 10:53:38 +00:00
|
|
|
return sending_media_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-10 09:58:08 +02:00
|
|
|
void RTPSender::SetAsPartOfAllocation(bool part_of_allocation) {
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
force_part_of_allocation_ = part_of_allocation;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-18 02:01:49 -07:00
|
|
|
void RTPSender::SetTimestampOffset(uint32_t timestamp) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2016-08-18 02:01:49 -07:00
|
|
|
timestamp_offset_ = timestamp;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-18 02:01:49 -07:00
|
|
|
uint32_t RTPSender::TimestampOffset() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2016-08-18 02:01:49 -07:00
|
|
|
return timestamp_offset_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
void RTPSender::SetSSRC(uint32_t ssrc) {
|
2013-01-25 10:53:38 +00:00
|
|
|
// This is configured via the API.
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
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
|
|
|
if (ssrc_ == ssrc) {
|
2013-01-25 10:53:38 +00:00
|
|
|
return; // Since it's same ssrc, don't reset anything.
|
2012-11-07 17:01:04 +00:00
|
|
|
}
|
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
|
|
|
ssrc_.emplace(ssrc);
|
2013-01-25 10:53:38 +00:00
|
|
|
if (!sequence_number_forced_) {
|
2015-12-15 00:30:07 -08:00
|
|
|
sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber);
|
2012-11-07 17:01:04 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint32_t RTPSender::SSRC() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
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
|
|
|
RTC_DCHECK(ssrc_);
|
|
|
|
|
return *ssrc_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2018-12-21 09:23:38 -08:00
|
|
|
void RTPSender::SetRid(const std::string& rid) {
|
|
|
|
|
// RID is used in simulcast scenario when multiple layers share the same mid.
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
RTC_DCHECK_LE(rid.length(), RtpStreamId::kMaxValueSizeBytes);
|
|
|
|
|
rid_ = rid;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 15:17:27 -07:00
|
|
|
void RTPSender::SetMid(const std::string& mid) {
|
|
|
|
|
// This is configured via the API.
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2018-04-06 11:09:46 -07:00
|
|
|
mid_ = mid;
|
2018-03-22 15:17:27 -07:00
|
|
|
}
|
|
|
|
|
|
2018-06-14 12:59:38 +02:00
|
|
|
absl::optional<uint32_t> RTPSender::FlexfecSsrc() const {
|
2019-02-06 22:48:11 +01:00
|
|
|
return flexfec_ssrc_;
|
2016-11-14 05:14:50 -08:00
|
|
|
}
|
|
|
|
|
|
2014-11-24 08:25:50 +00:00
|
|
|
void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
|
2017-09-04 07:23:56 -07:00
|
|
|
RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize);
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2014-11-24 08:25:50 +00:00
|
|
|
csrcs_ = csrcs;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
void RTPSender::SetSequenceNumber(uint16_t seq) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2013-01-25 10:53:38 +00:00
|
|
|
sequence_number_forced_ = true;
|
|
|
|
|
sequence_number_ = seq;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t RTPSender::SequenceNumber() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2013-01-25 10:53:38 +00:00
|
|
|
return sequence_number_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-11 11:30:03 +01:00
|
|
|
static void CopyHeaderAndExtensionsToRtxPacket(const RtpPacketToSend& packet,
|
|
|
|
|
RtpPacketToSend* rtx_packet) {
|
2018-12-21 09:23:38 -08:00
|
|
|
// Set the relevant fixed packet headers. The following are not set:
|
|
|
|
|
// * Payload type - it is replaced in rtx packets.
|
|
|
|
|
// * Sequence number - RTX has a separate sequence numbering.
|
|
|
|
|
// * SSRC - RTX stream has its own SSRC.
|
|
|
|
|
rtx_packet->SetMarker(packet.Marker());
|
|
|
|
|
rtx_packet->SetTimestamp(packet.Timestamp());
|
|
|
|
|
|
|
|
|
|
// Set the variable fields in the packet header:
|
|
|
|
|
// * CSRCs - must be set before header extensions.
|
|
|
|
|
// * Header extensions - replace Rid header with RepairedRid header.
|
|
|
|
|
const std::vector<uint32_t> csrcs = packet.Csrcs();
|
|
|
|
|
rtx_packet->SetCsrcs(csrcs);
|
|
|
|
|
for (int extension = kRtpExtensionNone + 1;
|
|
|
|
|
extension < kRtpExtensionNumberOfExtensions; ++extension) {
|
|
|
|
|
RTPExtensionType source_extension =
|
|
|
|
|
static_cast<RTPExtensionType>(extension);
|
|
|
|
|
// Rid header should be replaced with RepairedRid header
|
|
|
|
|
RTPExtensionType destination_extension =
|
|
|
|
|
source_extension == kRtpExtensionRtpStreamId
|
|
|
|
|
? kRtpExtensionRepairedRtpStreamId
|
|
|
|
|
: source_extension;
|
|
|
|
|
|
|
|
|
|
// Empty extensions should be supported, so not checking |source.empty()|.
|
|
|
|
|
if (!packet.HasExtension(source_extension)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtc::ArrayView<const uint8_t> source =
|
|
|
|
|
packet.FindExtension(source_extension);
|
|
|
|
|
|
|
|
|
|
rtc::ArrayView<uint8_t> destination =
|
|
|
|
|
rtx_packet->AllocateExtension(destination_extension, source.size());
|
|
|
|
|
|
|
|
|
|
// Could happen if any:
|
|
|
|
|
// 1. Extension has 0 length.
|
|
|
|
|
// 2. Extension is not registered in destination.
|
|
|
|
|
// 3. Allocating extension in destination failed.
|
|
|
|
|
if (destination.empty() || source.size() != destination.size()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::memcpy(destination.begin(), source.begin(), destination.size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
|
|
|
|
|
const RtpPacketToSend& packet) {
|
2019-02-11 11:30:03 +01:00
|
|
|
std::unique_ptr<RtpPacketToSend> rtx_packet;
|
2018-12-21 09:23:38 -08:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
// Add original RTP header.
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
if (!sending_media_)
|
|
|
|
|
return nullptr;
|
2013-03-15 23:21:52 +00:00
|
|
|
|
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
|
|
|
RTC_DCHECK(ssrc_rtx_);
|
|
|
|
|
|
Remove RED/RTX workaround from sender/receiver and VideoEngine2.
In older Chrome versions, the associated payload type in the RTX header
of retransmitted packets was always set to be the original media payload type,
regardless of the actual payload type of the packet. This meant that packets
encapsulated with RED headers had incorrect payload type information in the
RTX header. Due to an assumption in the receiver, this incorrect payload type
information would effectively be undone, leading to a working system.
Albeit working, this behaviour was undesired, and thus removed. In the interim,
several workarounds were introduced to not destroy interop between old and
new Chrome versions:
(1) https://codereview.webrtc.org/1649493004
- If no payload type mapping existed for RED over RTX, the payload type
of the underlying media would be used.
- If RED had been negotiated, received RTX packets would always be
assumed to contain RED.
(2) https://codereview.webrtc.org/1964473002
- If RED was removed from the remote description answer, it would be
disabled in the local receiver as well.
(3) https://codereview.webrtc.org/2033763002
- If RED was negotiated in the SDP, it would always be used, regardless
if ULPFEC was negotiated and used, or not.
Since the Chrome versions that exhibited the original bug now are very old,
this CL removes the workarounds from (1) and (2). In particular, after this
change, we will have the following behaviour:
- We assume that a payload type mapping for RED over RTX always is set.
If this is not the case, the RTX packet is not sent.
- The associated payload type of received RTX packets will always be obeyed.
- The (non)-existence of RED in the remote description does not affect the
local receiver.
The workaround in (3) still needs to exist, in order to interop with receivers
that did not have the workarounds in (1) and (2) removed. The change in (3)
can be removed in a couple of Chrome versions.
TESTED=Using AppRTC between patched Chrome (connected to ethernet) and standard Chrome M54 (connected to lossy internal Google WiFi), with and without FEC turned off using AppRTC flag. Also using "Munge SDP" sample on patched Chrome over loopback interface, with 100ms delay and 5% packet loss simulated using tc.
BUG=webrtc:6650
Review-Url: https://codereview.webrtc.org/2469093003
Cr-Commit-Position: refs/heads/master@{#15038}
2016-11-11 03:28:30 -08:00
|
|
|
// Replace payload type.
|
|
|
|
|
auto kv = rtx_payload_type_map_.find(packet.PayloadType());
|
2016-08-03 18:27:40 +02:00
|
|
|
if (kv == rtx_payload_type_map_.end())
|
Remove RED/RTX workaround from sender/receiver and VideoEngine2.
In older Chrome versions, the associated payload type in the RTX header
of retransmitted packets was always set to be the original media payload type,
regardless of the actual payload type of the packet. This meant that packets
encapsulated with RED headers had incorrect payload type information in the
RTX header. Due to an assumption in the receiver, this incorrect payload type
information would effectively be undone, leading to a working system.
Albeit working, this behaviour was undesired, and thus removed. In the interim,
several workarounds were introduced to not destroy interop between old and
new Chrome versions:
(1) https://codereview.webrtc.org/1649493004
- If no payload type mapping existed for RED over RTX, the payload type
of the underlying media would be used.
- If RED had been negotiated, received RTX packets would always be
assumed to contain RED.
(2) https://codereview.webrtc.org/1964473002
- If RED was removed from the remote description answer, it would be
disabled in the local receiver as well.
(3) https://codereview.webrtc.org/2033763002
- If RED was negotiated in the SDP, it would always be used, regardless
if ULPFEC was negotiated and used, or not.
Since the Chrome versions that exhibited the original bug now are very old,
this CL removes the workarounds from (1) and (2). In particular, after this
change, we will have the following behaviour:
- We assume that a payload type mapping for RED over RTX always is set.
If this is not the case, the RTX packet is not sent.
- The associated payload type of received RTX packets will always be obeyed.
- The (non)-existence of RED in the remote description does not affect the
local receiver.
The workaround in (3) still needs to exist, in order to interop with receivers
that did not have the workarounds in (1) and (2) removed. The change in (3)
can be removed in a couple of Chrome versions.
TESTED=Using AppRTC between patched Chrome (connected to ethernet) and standard Chrome M54 (connected to lossy internal Google WiFi), with and without FEC turned off using AppRTC flag. Also using "Munge SDP" sample on patched Chrome over loopback interface, with 100ms delay and 5% packet loss simulated using tc.
BUG=webrtc:6650
Review-Url: https://codereview.webrtc.org/2469093003
Cr-Commit-Position: refs/heads/master@{#15038}
2016-11-11 03:28:30 -08:00
|
|
|
return nullptr;
|
2019-02-11 11:30:03 +01:00
|
|
|
|
|
|
|
|
rtx_packet = absl::make_unique<RtpPacketToSend>(&rtp_header_extension_map_,
|
|
|
|
|
max_packet_size_);
|
|
|
|
|
|
Remove RED/RTX workaround from sender/receiver and VideoEngine2.
In older Chrome versions, the associated payload type in the RTX header
of retransmitted packets was always set to be the original media payload type,
regardless of the actual payload type of the packet. This meant that packets
encapsulated with RED headers had incorrect payload type information in the
RTX header. Due to an assumption in the receiver, this incorrect payload type
information would effectively be undone, leading to a working system.
Albeit working, this behaviour was undesired, and thus removed. In the interim,
several workarounds were introduced to not destroy interop between old and
new Chrome versions:
(1) https://codereview.webrtc.org/1649493004
- If no payload type mapping existed for RED over RTX, the payload type
of the underlying media would be used.
- If RED had been negotiated, received RTX packets would always be
assumed to contain RED.
(2) https://codereview.webrtc.org/1964473002
- If RED was removed from the remote description answer, it would be
disabled in the local receiver as well.
(3) https://codereview.webrtc.org/2033763002
- If RED was negotiated in the SDP, it would always be used, regardless
if ULPFEC was negotiated and used, or not.
Since the Chrome versions that exhibited the original bug now are very old,
this CL removes the workarounds from (1) and (2). In particular, after this
change, we will have the following behaviour:
- We assume that a payload type mapping for RED over RTX always is set.
If this is not the case, the RTX packet is not sent.
- The associated payload type of received RTX packets will always be obeyed.
- The (non)-existence of RED in the remote description does not affect the
local receiver.
The workaround in (3) still needs to exist, in order to interop with receivers
that did not have the workarounds in (1) and (2) removed. The change in (3)
can be removed in a couple of Chrome versions.
TESTED=Using AppRTC between patched Chrome (connected to ethernet) and standard Chrome M54 (connected to lossy internal Google WiFi), with and without FEC turned off using AppRTC flag. Also using "Munge SDP" sample on patched Chrome over loopback interface, with 100ms delay and 5% packet loss simulated using tc.
BUG=webrtc:6650
Review-Url: https://codereview.webrtc.org/2469093003
Cr-Commit-Position: refs/heads/master@{#15038}
2016-11-11 03:28:30 -08:00
|
|
|
rtx_packet->SetPayloadType(kv->second);
|
2013-03-15 23:21:52 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
// Replace sequence number.
|
|
|
|
|
rtx_packet->SetSequenceNumber(sequence_number_rtx_++);
|
2013-03-15 23:21:52 +00:00
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
// Replace 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
|
|
|
rtx_packet->SetSsrc(*ssrc_rtx_);
|
2018-03-22 15:17:27 -07:00
|
|
|
|
2019-02-11 11:30:03 +01:00
|
|
|
CopyHeaderAndExtensionsToRtxPacket(packet, rtx_packet.get());
|
|
|
|
|
|
2018-12-21 09:23:38 -08:00
|
|
|
// The spec indicates that it is possible for a sender to stop sending mids
|
|
|
|
|
// once the SSRCs have been bound on the receiver. As a result the source
|
|
|
|
|
// rtp packet might not have the MID header extension set.
|
|
|
|
|
// However, the SSRC of the RTX stream might not have been bound on the
|
|
|
|
|
// receiver. This means that we should include it here.
|
|
|
|
|
// The same argument goes for the Repaired RID extension.
|
2018-04-06 11:09:46 -07:00
|
|
|
if (!mid_.empty()) {
|
2018-03-22 15:17:27 -07:00
|
|
|
// This is a no-op if the MID header extension is not registered.
|
2018-04-06 11:09:46 -07:00
|
|
|
rtx_packet->SetExtension<RtpMid>(mid_);
|
2018-03-22 15:17:27 -07:00
|
|
|
}
|
2018-12-21 09:23:38 -08:00
|
|
|
if (!rid_.empty()) {
|
|
|
|
|
// This is a no-op if the Repaired-RID header extension is not registered.
|
|
|
|
|
// rtx_packet->SetExtension<RepairedRtpStreamId>(rid_);
|
|
|
|
|
}
|
2016-08-03 18:27:40 +02:00
|
|
|
}
|
2019-02-11 11:30:03 +01:00
|
|
|
RTC_DCHECK(rtx_packet);
|
2016-08-03 18:27:40 +02:00
|
|
|
|
|
|
|
|
uint8_t* rtx_payload =
|
|
|
|
|
rtx_packet->AllocatePayload(packet.payload_size() + kRtxHeaderSize);
|
2019-02-11 11:30:03 +01:00
|
|
|
if (rtx_payload == nullptr)
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
2013-03-15 23:21:52 +00:00
|
|
|
// Add OSN (original sequence number).
|
2016-08-03 18:27:40 +02:00
|
|
|
ByteWriter<uint16_t>::WriteBigEndian(rtx_payload, packet.SequenceNumber());
|
2013-03-15 23:21:52 +00:00
|
|
|
|
|
|
|
|
// Add original payload data.
|
2016-11-21 01:35:29 -08:00
|
|
|
auto payload = packet.payload();
|
|
|
|
|
memcpy(rtx_payload + kRtxHeaderSize, payload.data(), payload.size());
|
2016-08-03 18:27:40 +02:00
|
|
|
|
2018-02-22 14:18:06 +01:00
|
|
|
// Add original application data.
|
|
|
|
|
rtx_packet->set_application_data(packet.application_data());
|
|
|
|
|
|
2016-08-03 18:27:40 +02:00
|
|
|
return rtx_packet;
|
2013-03-15 23:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-05 14:29:02 +00:00
|
|
|
void RTPSender::RegisterRtpStatisticsCallback(
|
|
|
|
|
StreamDataCountersCallback* callback) {
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope cs(&statistics_crit_);
|
2013-12-05 14:29:02 +00:00
|
|
|
rtp_stats_callback_ = callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamDataCountersCallback* RTPSender::GetRtpStatisticsCallback() const {
|
2016-04-14 03:05:31 -07:00
|
|
|
rtc::CritScope cs(&statistics_crit_);
|
2013-12-05 14:29:02 +00:00
|
|
|
return rtp_stats_callback_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-05 14:05:29 +00:00
|
|
|
uint32_t RTPSender::BitrateSent() const {
|
2016-07-13 09:11:28 -07:00
|
|
|
rtc::CritScope cs(&statistics_crit_);
|
|
|
|
|
return total_bitrate_sent_.Rate(clock_->TimeInMilliseconds()).value_or(0);
|
2013-12-13 09:46:59 +00:00
|
|
|
}
|
2014-07-07 13:06:48 +00:00
|
|
|
|
|
|
|
|
void RTPSender::SetRtpState(const RtpState& rtp_state) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2014-07-07 13:06:48 +00:00
|
|
|
sequence_number_ = rtp_state.sequence_number;
|
|
|
|
|
sequence_number_forced_ = true;
|
2016-08-18 02:01:49 -07:00
|
|
|
timestamp_offset_ = rtp_state.start_timestamp;
|
2016-08-22 03:39:23 -07:00
|
|
|
last_rtp_timestamp_ = rtp_state.timestamp;
|
2014-07-07 13:06:48 +00:00
|
|
|
capture_time_ms_ = rtp_state.capture_time_ms;
|
|
|
|
|
last_timestamp_time_ms_ = rtp_state.last_timestamp_time_ms;
|
2014-07-17 16:10:14 +00:00
|
|
|
media_has_been_sent_ = rtp_state.media_has_been_sent;
|
2014-07-07 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpState RTPSender::GetRtpState() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2014-07-07 13:06:48 +00:00
|
|
|
|
|
|
|
|
RtpState state;
|
|
|
|
|
state.sequence_number = sequence_number_;
|
2016-08-18 02:01:49 -07:00
|
|
|
state.start_timestamp = timestamp_offset_;
|
2016-08-22 03:39:23 -07:00
|
|
|
state.timestamp = last_rtp_timestamp_;
|
2014-07-07 13:06:48 +00:00
|
|
|
state.capture_time_ms = capture_time_ms_;
|
|
|
|
|
state.last_timestamp_time_ms = last_timestamp_time_ms_;
|
2014-07-17 16:10:14 +00:00
|
|
|
state.media_has_been_sent = media_has_been_sent_;
|
2014-07-07 13:06:48 +00:00
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTPSender::SetRtxRtpState(const RtpState& rtp_state) {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2014-07-07 13:06:48 +00:00
|
|
|
sequence_number_rtx_ = rtp_state.sequence_number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpState RTPSender::GetRtxRtpState() const {
|
2016-02-02 08:31:45 -08:00
|
|
|
rtc::CritScope lock(&send_critsect_);
|
2014-07-07 13:06:48 +00:00
|
|
|
|
|
|
|
|
RtpState state;
|
|
|
|
|
state.sequence_number = sequence_number_rtx_;
|
2016-08-18 02:01:49 -07:00
|
|
|
state.start_timestamp = timestamp_offset_;
|
2014-07-07 13:06:48 +00:00
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 02:56:13 -08:00
|
|
|
void RTPSender::AddPacketToTransportFeedback(
|
|
|
|
|
uint16_t packet_id,
|
|
|
|
|
const RtpPacketToSend& packet,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
2016-11-17 01:38:43 -08:00
|
|
|
if (transport_feedback_observer_) {
|
2019-04-23 12:00:11 +02:00
|
|
|
size_t packet_size = packet.payload_size() + packet.padding_size();
|
|
|
|
|
if (send_side_bwe_with_overhead_) {
|
|
|
|
|
packet_size = packet.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpPacketSendInfo packet_info;
|
|
|
|
|
packet_info.ssrc = SSRC();
|
|
|
|
|
packet_info.transport_sequence_number = packet_id;
|
2019-05-07 09:29:15 -07:00
|
|
|
packet_info.has_rtp_sequence_number = true;
|
2019-04-23 12:00:11 +02:00
|
|
|
packet_info.rtp_sequence_number = packet.SequenceNumber();
|
|
|
|
|
packet_info.length = packet_size;
|
|
|
|
|
packet_info.pacing_info = pacing_info;
|
|
|
|
|
transport_feedback_observer_->OnAddPacket(packet_info);
|
2016-11-17 01:38:43 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RTPSender::UpdateRtpOverhead(const RtpPacketToSend& packet) {
|
|
|
|
|
if (!overhead_observer_)
|
|
|
|
|
return;
|
2017-01-10 08:58:32 -08:00
|
|
|
size_t overhead_bytes_per_packet;
|
2016-11-17 01:38:43 -08:00
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
rtp_overhead_bytes_per_packet_ = packet.headers_size();
|
2017-01-10 08:58:32 -08:00
|
|
|
overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_;
|
2016-11-17 01:38:43 -08:00
|
|
|
}
|
|
|
|
|
overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-06 04:38:06 -07:00
|
|
|
int64_t RTPSender::LastTimestampTimeMs() const {
|
|
|
|
|
rtc::CritScope lock(&send_critsect_);
|
|
|
|
|
return last_timestamp_time_ms_;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-18 11:58:05 -08:00
|
|
|
void RTPSender::SetRtt(int64_t rtt_ms) {
|
|
|
|
|
packet_history_.SetRtt(rtt_ms);
|
|
|
|
|
flexfec_packet_history_.SetRtt(rtt_ms);
|
|
|
|
|
}
|
2019-05-07 09:29:15 -07:00
|
|
|
|
|
|
|
|
void RTPSender::OnPacketsAcknowledged(
|
|
|
|
|
rtc::ArrayView<const uint16_t> sequence_numbers) {
|
|
|
|
|
packet_history_.CullAcknowledgedPackets(sequence_numbers);
|
|
|
|
|
}
|
2012-11-07 17:01:04 +00:00
|
|
|
} // namespace webrtc
|