mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-19 16:47:50 +01:00

This is a no-op change because rtc::Optional is an alias to absl::optional This CL generated by running script from modules with parameters 'pacing video_coding congestion_controller remote_bitrate_estimator': find $@ -type f \( -name \*.h -o -name \*.cc \) \ -exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \ -exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \ -exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+ find $@ -type f -name BUILD.gn \ -exec sed -r -i 's|"(../)*api:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+; git cl format Bug: webrtc:9078 Change-Id: I8ea501d7f1ee36e8d8cd3ed37e6b763c7fe29118 Reviewed-on: https://webrtc-review.googlesource.com/83900 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23640}
67 lines
2.3 KiB
C++
67 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include "modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
|
#include "rtc_base/numerics/safe_conversions.h"
|
|
#include "rtc_base/ptr_util.h"
|
|
|
|
namespace webrtc {
|
|
|
|
namespace {
|
|
bool IsInSendTimeHistory(const PacketFeedback& packet) {
|
|
return packet.send_time_ms != PacketFeedback::kNoSendTime;
|
|
}
|
|
} // namespace
|
|
|
|
AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator()
|
|
: AcknowledgedBitrateEstimator(rtc::MakeUnique<BitrateEstimator>()) {}
|
|
|
|
AcknowledgedBitrateEstimator::~AcknowledgedBitrateEstimator() {}
|
|
|
|
AcknowledgedBitrateEstimator::AcknowledgedBitrateEstimator(
|
|
std::unique_ptr<BitrateEstimator> bitrate_estimator)
|
|
: bitrate_estimator_(std::move(bitrate_estimator)) {}
|
|
|
|
void AcknowledgedBitrateEstimator::IncomingPacketFeedbackVector(
|
|
const std::vector<PacketFeedback>& packet_feedback_vector) {
|
|
RTC_DCHECK(std::is_sorted(packet_feedback_vector.begin(),
|
|
packet_feedback_vector.end(),
|
|
PacketFeedbackComparator()));
|
|
for (const auto& packet : packet_feedback_vector) {
|
|
if (IsInSendTimeHistory(packet)) {
|
|
MaybeExpectFastRateChange(packet.send_time_ms);
|
|
bitrate_estimator_->Update(packet.arrival_time_ms,
|
|
rtc::dchecked_cast<int>(packet.payload_size));
|
|
}
|
|
}
|
|
}
|
|
|
|
absl::optional<uint32_t> AcknowledgedBitrateEstimator::bitrate_bps() const {
|
|
return bitrate_estimator_->bitrate_bps();
|
|
}
|
|
|
|
void AcknowledgedBitrateEstimator::SetAlrEndedTimeMs(
|
|
int64_t alr_ended_time_ms) {
|
|
alr_ended_time_ms_.emplace(alr_ended_time_ms);
|
|
}
|
|
|
|
void AcknowledgedBitrateEstimator::MaybeExpectFastRateChange(
|
|
int64_t packet_send_time_ms) {
|
|
if (alr_ended_time_ms_ && packet_send_time_ms > *alr_ended_time_ms_) {
|
|
bitrate_estimator_->ExpectFastRateChange();
|
|
alr_ended_time_ms_.reset();
|
|
}
|
|
}
|
|
|
|
} // namespace webrtc
|