Convert BitrateAdjuster from webrtc::Clock to rtc::TimeMillis.
We can then also drop the system_wrappers dependency from the common_video build target. Bug: webrtc:6733 Change-Id: I501113d100322d1ebc51b2286970697a24b70a43 Reviewed-on: https://webrtc-review.googlesource.com/70381 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22934}
This commit is contained in:
parent
24ad720885
commit
2cb7b5ebef
@ -66,7 +66,6 @@ rtc_static_library("common_video") {
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_task_queue",
|
||||
"../rtc_base:safe_minmax",
|
||||
"../system_wrappers",
|
||||
"//third_party/libyuv",
|
||||
]
|
||||
}
|
||||
@ -114,7 +113,7 @@ if (rtc_include_tests) {
|
||||
"../modules/video_capture:video_capture",
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../system_wrappers:system_wrappers",
|
||||
"../rtc_base:rtc_base_tests_utils",
|
||||
"../test:fileutils",
|
||||
"../test:test_main",
|
||||
"../test:video_test_common",
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -30,11 +30,9 @@ const float BitrateAdjuster::kBitrateTolerancePct = .1f;
|
||||
|
||||
const float BitrateAdjuster::kBytesPerMsToBitsPerSecond = 8 * 1000;
|
||||
|
||||
BitrateAdjuster::BitrateAdjuster(Clock* clock,
|
||||
float min_adjusted_bitrate_pct,
|
||||
BitrateAdjuster::BitrateAdjuster(float min_adjusted_bitrate_pct,
|
||||
float max_adjusted_bitrate_pct)
|
||||
: clock_(clock),
|
||||
min_adjusted_bitrate_pct_(min_adjusted_bitrate_pct),
|
||||
: min_adjusted_bitrate_pct_(min_adjusted_bitrate_pct),
|
||||
max_adjusted_bitrate_pct_(max_adjusted_bitrate_pct),
|
||||
bitrate_tracker_(1.5 * kBitrateUpdateIntervalMs,
|
||||
kBytesPerMsToBitsPerSecond) {
|
||||
@ -72,12 +70,12 @@ uint32_t BitrateAdjuster::GetAdjustedBitrateBps() const {
|
||||
|
||||
rtc::Optional<uint32_t> BitrateAdjuster::GetEstimatedBitrateBps() {
|
||||
rtc::CritScope cs(&crit_);
|
||||
return bitrate_tracker_.Rate(clock_->TimeInMilliseconds());
|
||||
return bitrate_tracker_.Rate(rtc::TimeMillis());
|
||||
}
|
||||
|
||||
void BitrateAdjuster::Update(size_t frame_size) {
|
||||
rtc::CritScope cs(&crit_);
|
||||
uint32_t current_time_ms = clock_->TimeInMilliseconds();
|
||||
uint32_t current_time_ms = rtc::TimeMillis();
|
||||
bitrate_tracker_.Update(frame_size, current_time_ms);
|
||||
UpdateBitrate(current_time_ms);
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "common_video/include/bitrate_adjuster.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "rtc_base/fakeclock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -17,8 +17,7 @@ namespace webrtc {
|
||||
class BitrateAdjusterTest : public ::testing::Test {
|
||||
public:
|
||||
BitrateAdjusterTest()
|
||||
: clock_(0),
|
||||
adjuster_(&clock_, kMinAdjustedBitratePct, kMaxAdjustedBitratePct) {}
|
||||
: adjuster_(kMinAdjustedBitratePct, kMaxAdjustedBitratePct) {}
|
||||
|
||||
// Simulate an output bitrate for one update cycle of BitrateAdjuster.
|
||||
void SimulateBitrateBps(uint32_t bitrate_bps) {
|
||||
@ -33,7 +32,7 @@ class BitrateAdjusterTest : public ::testing::Test {
|
||||
const size_t frame_size_bytes =
|
||||
(bitrate_bps * frame_interval_ms) / (8 * 1000);
|
||||
for (size_t i = 0; i < update_frame_interval; ++i) {
|
||||
clock_.AdvanceTimeMilliseconds(frame_interval_ms);
|
||||
clock_.AdvanceTime(rtc::TimeDelta::FromMilliseconds(frame_interval_ms));
|
||||
adjuster_.Update(frame_size_bytes);
|
||||
}
|
||||
}
|
||||
@ -63,7 +62,7 @@ class BitrateAdjusterTest : public ::testing::Test {
|
||||
protected:
|
||||
static const float kMinAdjustedBitratePct;
|
||||
static const float kMaxAdjustedBitratePct;
|
||||
SimulatedClock clock_;
|
||||
rtc::ScopedFakeClock clock_;
|
||||
BitrateAdjuster adjuster_;
|
||||
};
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(nisse): Delete, together with the corresponding deprecated
|
||||
// constructor.
|
||||
class Clock;
|
||||
|
||||
// Certain hardware encoders tend to consistently overshoot the bitrate that
|
||||
@ -28,9 +30,14 @@ class BitrateAdjuster {
|
||||
// min_adjusted_bitrate_pct and max_adjusted_bitrate_pct are the lower and
|
||||
// upper bound outputted adjusted bitrates as a percentage of the target
|
||||
// bitrate.
|
||||
BitrateAdjuster(Clock* clock,
|
||||
float min_adjusted_bitrate_pct,
|
||||
BitrateAdjuster(float min_adjusted_bitrate_pct,
|
||||
float max_adjusted_bitrate_pct);
|
||||
// TODO(bugs.webrtc.org/6733): Deprecated, only for compatibility
|
||||
// with old code. Delete as soon as all users are updated.
|
||||
BitrateAdjuster(Clock*,
|
||||
float min_adjusted_bitrate_pct,
|
||||
float max_adjusted_bitrate_pct)
|
||||
: BitrateAdjuster(min_adjusted_bitrate_pct, max_adjusted_bitrate_pct) {}
|
||||
virtual ~BitrateAdjuster() {}
|
||||
|
||||
static const uint32_t kBitrateUpdateIntervalMs;
|
||||
@ -68,7 +75,6 @@ class BitrateAdjuster {
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||
|
||||
rtc::CriticalSection crit_;
|
||||
Clock* const clock_;
|
||||
const float min_adjusted_bitrate_pct_;
|
||||
const float max_adjusted_bitrate_pct_;
|
||||
// The bitrate we want.
|
||||
|
||||
@ -1093,7 +1093,6 @@ if (is_ios || is_mac) {
|
||||
"../modules/video_coding:video_coding_utility",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../system_wrappers",
|
||||
"//third_party/libyuv",
|
||||
]
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "third_party/libyuv/include/libyuv/convert_from.h"
|
||||
|
||||
@interface RTCVideoEncoderH264 ()
|
||||
@ -302,8 +301,7 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
|
||||
- (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo {
|
||||
if (self = [super init]) {
|
||||
_codecInfo = codecInfo;
|
||||
_bitrateAdjuster.reset(new webrtc::BitrateAdjuster(
|
||||
webrtc::Clock::GetRealTimeClock(), .5, .95));
|
||||
_bitrateAdjuster.reset(new webrtc::BitrateAdjuster(.5, .95));
|
||||
_packetizationMode = RTCH264PacketizationModeNonInterleaved;
|
||||
_profile = ExtractProfile([codecInfo nativeSdpVideoFormat]);
|
||||
RTC_LOG(LS_INFO) << "Using profile " << CFStringToString(_profile);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user