Move BitrateAllocation to api/ and rename it VideoBitrateAllocation
Since the webrtc_common build target does not have visibility set, we
cannot easily use BitrateAllocation in other parts of Chromium.
This is currently blocking parts of chromium:794608, and I know of other
usage outside webrtc already, so moving it to api/ should be warranted.
Also, since there's some naming confusion and this class is video
specific rename it VideoBitrateAllocation. This also fits with the
standard interface for producing these: VideoBitrateAllocator.
Bug: chromium:794608
Change-Id: I4c0fae40f9365e860c605a76a4f67ecc9b9cf9fe
Reviewed-on: https://webrtc-review.googlesource.com/70783
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22986}
diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
index dffc348..02f93e1 100644
--- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc
+++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
@@ -288,7 +288,7 @@
}
int32_t H264EncoderImpl::SetRateAllocation(
- const BitrateAllocation& bitrate_allocation,
+ const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) {
if (bitrate_allocation.get_sum_bps() <= 0 || framerate <= 0)
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.h b/modules/video_coding/codecs/h264/h264_encoder_impl.h
index 20d5ea6..c48439b 100644
--- a/modules/video_coding/codecs/h264/h264_encoder_impl.h
+++ b/modules/video_coding/codecs/h264/h264_encoder_impl.h
@@ -44,7 +44,7 @@
int32_t RegisterEncodeCompleteCallback(
EncodedImageCallback* callback) override;
- int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
+ int32_t SetRateAllocation(const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) override;
// The result of encoding - an EncodedImage and RTPFragmentationHeader - are
diff --git a/modules/video_coding/codecs/multiplex/include/multiplex_encoder_adapter.h b/modules/video_coding/codecs/multiplex/include/multiplex_encoder_adapter.h
index cbdd6c3..7ce8615 100644
--- a/modules/video_coding/codecs/multiplex/include/multiplex_encoder_adapter.h
+++ b/modules/video_coding/codecs/multiplex/include/multiplex_encoder_adapter.h
@@ -46,7 +46,7 @@
const std::vector<FrameType>* frame_types) override;
int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override;
int SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
- int SetRateAllocation(const BitrateAllocation& bitrate,
+ int SetRateAllocation(const VideoBitrateAllocation& bitrate,
uint32_t new_framerate) override;
int Release() override;
const char* ImplementationName() const override;
diff --git a/modules/video_coding/codecs/multiplex/multiplex_encoder_adapter.cc b/modules/video_coding/codecs/multiplex/multiplex_encoder_adapter.cc
index 7eb0d50..dcf1b56 100644
--- a/modules/video_coding/codecs/multiplex/multiplex_encoder_adapter.cc
+++ b/modules/video_coding/codecs/multiplex/multiplex_encoder_adapter.cc
@@ -174,8 +174,9 @@
return WEBRTC_VIDEO_CODEC_OK;
}
-int MultiplexEncoderAdapter::SetRateAllocation(const BitrateAllocation& bitrate,
- uint32_t framerate) {
+int MultiplexEncoderAdapter::SetRateAllocation(
+ const VideoBitrateAllocation& bitrate,
+ uint32_t framerate) {
for (auto& encoder : encoders_) {
// TODO(emircan): |framerate| is used to calculate duration in encoder
// instances. We report the total frame rate to keep real time for now.
diff --git a/modules/video_coding/codecs/test/videoprocessor.h b/modules/video_coding/codecs/test/videoprocessor.h
index a56b83d..66e7525 100644
--- a/modules/video_coding/codecs/test/videoprocessor.h
+++ b/modules/video_coding/codecs/test/videoprocessor.h
@@ -188,7 +188,7 @@
webrtc::VideoEncoder* const encoder_;
VideoDecoderList* const decoders_;
const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_;
- BitrateAllocation bitrate_allocation_ RTC_GUARDED_BY(sequence_checker_);
+ VideoBitrateAllocation bitrate_allocation_ RTC_GUARDED_BY(sequence_checker_);
uint32_t framerate_fps_ RTC_GUARDED_BY(sequence_checker_);
// Adapters for the codec callbacks.
diff --git a/modules/video_coding/codecs/test/videoprocessor_unittest.cc b/modules/video_coding/codecs/test/videoprocessor_unittest.cc
index cb01459..baf97bf 100644
--- a/modules/video_coding/codecs/test/videoprocessor_unittest.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_unittest.cc
@@ -166,7 +166,7 @@
const int kFramerateFps = 17;
EXPECT_CALL(encoder_mock_,
SetRateAllocation(
- Property(&BitrateAllocation::get_sum_kbps, kBitrateKbps),
+ Property(&VideoBitrateAllocation::get_sum_kbps, kBitrateKbps),
kFramerateFps))
.Times(1);
DO_SYNC(q_, { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
@@ -174,9 +174,9 @@
const int kNewBitrateKbps = 456;
const int kNewFramerateFps = 34;
EXPECT_CALL(encoder_mock_,
- SetRateAllocation(
- Property(&BitrateAllocation::get_sum_kbps, kNewBitrateKbps),
- kNewFramerateFps))
+ SetRateAllocation(Property(&VideoBitrateAllocation::get_sum_kbps,
+ kNewBitrateKbps),
+ kNewFramerateFps))
.Times(1);
DO_SYNC(q_,
{ video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps); });
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index b1cecf0..d84d001 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -252,7 +252,7 @@
return ret_val;
}
-int LibvpxVp8Encoder::SetRateAllocation(const BitrateAllocation& bitrate,
+int LibvpxVp8Encoder::SetRateAllocation(const VideoBitrateAllocation& bitrate,
uint32_t new_framerate) {
if (!inited_)
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
@@ -512,7 +512,7 @@
// at position 0 and they have highest resolution at position 0.
int stream_idx = encoders_.size() - 1;
SimulcastRateAllocator init_allocator(codec_);
- BitrateAllocation allocation = init_allocator.GetAllocation(
+ VideoBitrateAllocation allocation = init_allocator.GetAllocation(
inst->startBitrate * 1000, inst->maxFramerate);
std::vector<uint32_t> stream_bitrates;
for (int i = 0; i == 0 || i < inst->numberOfSimulcastStreams; ++i) {
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
index f3e8c7a..4e9d374 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
@@ -46,7 +46,7 @@
int SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
- int SetRateAllocation(const BitrateAllocation& bitrate,
+ int SetRateAllocation(const VideoBitrateAllocation& bitrate,
uint32_t new_framerate) override;
ScalingSettings GetScalingSettings() const override;
diff --git a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc
index b819caa..5effa68 100644
--- a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc
+++ b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc
@@ -23,10 +23,10 @@
SimulcastRateAllocator::SimulcastRateAllocator(const VideoCodec& codec)
: codec_(codec) {}
-BitrateAllocation SimulcastRateAllocator::GetAllocation(
+VideoBitrateAllocation SimulcastRateAllocator::GetAllocation(
uint32_t total_bitrate_bps,
uint32_t framerate) {
- BitrateAllocation allocated_bitrates_bps;
+ VideoBitrateAllocation allocated_bitrates_bps;
DistributeAllocationToSimulcastLayers(total_bitrate_bps,
&allocated_bitrates_bps);
DistributeAllocationToTemporalLayers(framerate, &allocated_bitrates_bps);
@@ -35,7 +35,7 @@
void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
uint32_t total_bitrate_bps,
- BitrateAllocation* allocated_bitrates_bps) const {
+ VideoBitrateAllocation* allocated_bitrates_bps) const {
uint32_t left_to_allocate = total_bitrate_bps;
if (codec_.maxBitrate && codec_.maxBitrate * 1000 < left_to_allocate)
left_to_allocate = codec_.maxBitrate * 1000;
@@ -111,7 +111,7 @@
void SimulcastRateAllocator::DistributeAllocationToTemporalLayers(
uint32_t framerate,
- BitrateAllocation* allocated_bitrates_bps) const {
+ VideoBitrateAllocation* allocated_bitrates_bps) const {
const int num_spatial_streams =
std::max(1, static_cast<int>(codec_.numberOfSimulcastStreams));
diff --git a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h
index 23d158b..7cb1a8a 100644
--- a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h
+++ b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h
@@ -28,18 +28,18 @@
public:
explicit SimulcastRateAllocator(const VideoCodec& codec);
- BitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
- uint32_t framerate) override;
+ VideoBitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
+ uint32_t framerate) override;
uint32_t GetPreferredBitrateBps(uint32_t framerate) override;
const VideoCodec& GetCodec() const;
private:
void DistributeAllocationToSimulcastLayers(
uint32_t total_bitrate_bps,
- BitrateAllocation* allocated_bitrates_bps) const;
+ VideoBitrateAllocation* allocated_bitrates_bps) const;
void DistributeAllocationToTemporalLayers(
uint32_t framerate,
- BitrateAllocation* allocated_bitrates_bps) const;
+ VideoBitrateAllocation* allocated_bitrates_bps) const;
std::vector<uint32_t> DefaultTemporalLayerAllocation(int bitrate_kbps,
int max_bitrate_kbps,
int framerate,
diff --git a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
index 6db6b5b..ce4bb83 100644
--- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
+++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
@@ -85,7 +85,7 @@
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
const int kBitrateBps = 300000;
- BitrateAllocation bitrate_allocation;
+ VideoBitrateAllocation bitrate_allocation;
bitrate_allocation.SetBitrate(0, 0, kBitrateBps);
EXPECT_EQ(WEBRTC_VIDEO_CODEC_UNINITIALIZED,
encoder_->SetRateAllocation(bitrate_allocation,
diff --git a/modules/video_coding/codecs/vp9/svc_rate_allocator.cc b/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
index e335550..46caef4 100644
--- a/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
+++ b/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
@@ -27,9 +27,10 @@
RTC_DCHECK_EQ(codec.codecType, kVideoCodecVP9);
}
-BitrateAllocation SvcRateAllocator::GetAllocation(uint32_t total_bitrate_bps,
- uint32_t framerate_fps) {
- BitrateAllocation bitrate_allocation;
+VideoBitrateAllocation SvcRateAllocator::GetAllocation(
+ uint32_t total_bitrate_bps,
+ uint32_t framerate_fps) {
+ VideoBitrateAllocation bitrate_allocation;
size_t num_spatial_layers = codec_.VP9().numberOfSpatialLayers;
RTC_CHECK(num_spatial_layers > 0);
diff --git a/modules/video_coding/codecs/vp9/svc_rate_allocator.h b/modules/video_coding/codecs/vp9/svc_rate_allocator.h
index 24a3cab..cbf2096 100644
--- a/modules/video_coding/codecs/vp9/svc_rate_allocator.h
+++ b/modules/video_coding/codecs/vp9/svc_rate_allocator.h
@@ -23,8 +23,8 @@
public:
explicit SvcRateAllocator(const VideoCodec& codec);
- BitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
- uint32_t framerate_fps) override;
+ VideoBitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
+ uint32_t framerate_fps) override;
uint32_t GetPreferredBitrateBps(uint32_t framerate_fps) override;
private:
diff --git a/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc b/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc
index e894166..536950e 100644
--- a/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc
+++ b/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc
@@ -46,7 +46,7 @@
VideoCodec codec = Configure(320, 180, 3, 3);
SvcRateAllocator allocator = SvcRateAllocator(codec);
- BitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
+ VideoBitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_EQ(allocation.GetSpatialLayerSum(1), 0u);
@@ -56,7 +56,7 @@
VideoCodec codec = Configure(640, 360, 3, 3);
SvcRateAllocator allocator = SvcRateAllocator(codec);
- BitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
+ VideoBitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0u);
@@ -67,7 +67,7 @@
VideoCodec codec = Configure(1280, 720, 3, 3);
SvcRateAllocator allocator = SvcRateAllocator(codec);
- BitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
+ VideoBitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0u);
@@ -81,7 +81,7 @@
const SpatialLayer* layers = codec.spatialLayers;
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator.GetAllocation(layers[0].minBitrate * 1000 / 2, 30);
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
@@ -98,7 +98,7 @@
size_t min_bitrate_for_640x360_layer_kbps =
layers[0].minBitrate + layers[1].minBitrate;
- BitrateAllocation allocation = allocator.GetAllocation(
+ VideoBitrateAllocation allocation = allocator.GetAllocation(
min_bitrate_for_640x360_layer_kbps * 1000 - 1, 30);
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
@@ -114,7 +114,7 @@
size_t min_bitrate_for_1280x720_layer_kbps =
layers[0].minBitrate + layers[1].minBitrate + layers[2].minBitrate;
- BitrateAllocation allocation = allocator.GetAllocation(
+ VideoBitrateAllocation allocation = allocator.GetAllocation(
min_bitrate_for_1280x720_layer_kbps * 1000 - 1, 30);
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
@@ -129,7 +129,7 @@
const SpatialLayer* layers = codec.spatialLayers;
const uint32_t link_mbps = 100;
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator.GetAllocation(link_mbps * 1000000, 30);
EXPECT_EQ(allocation.get_sum_kbps(),
diff --git a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc
index b16419b..d060f5f 100644
--- a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc
+++ b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc
@@ -224,7 +224,7 @@
encoder_->InitEncode(&codec_settings_, 1 /* number of cores */,
0 /* max payload size (unused) */));
- BitrateAllocation bitrate_allocation;
+ VideoBitrateAllocation bitrate_allocation;
for (size_t sl_idx = 0; sl_idx < num_spatial_layers; ++sl_idx) {
bitrate_allocation.SetBitrate(sl_idx, 0,
layers[sl_idx].targetBitrate * 1000);
@@ -283,7 +283,7 @@
// Encode both base and upper layers. Check that end-of-superframe flag is
// set on upper layer frame but not on base layer frame.
- BitrateAllocation bitrate_allocation;
+ VideoBitrateAllocation bitrate_allocation;
bitrate_allocation.SetBitrate(0, 0, layers[0].targetBitrate * 1000);
bitrate_allocation.SetBitrate(1, 0, layers[1].targetBitrate * 1000);
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc
index 5ae44ed..5076af2 100644
--- a/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -123,7 +123,8 @@
return num_spatial_layers_ > 1 && codec_.spatialLayers[0].targetBitrate > 0;
}
-bool VP9EncoderImpl::SetSvcRates(const BitrateAllocation& bitrate_allocation) {
+bool VP9EncoderImpl::SetSvcRates(
+ const VideoBitrateAllocation& bitrate_allocation) {
uint8_t i = 0;
config_->rc_target_bitrate = bitrate_allocation.get_sum_kbps();
@@ -192,7 +193,7 @@
}
int VP9EncoderImpl::SetRateAllocation(
- const BitrateAllocation& bitrate_allocation,
+ const VideoBitrateAllocation& bitrate_allocation,
uint32_t frame_rate) {
if (!inited_) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
@@ -434,7 +435,7 @@
}
SvcRateAllocator init_allocator(codec_);
- BitrateAllocation allocation = init_allocator.GetAllocation(
+ VideoBitrateAllocation allocation = init_allocator.GetAllocation(
inst->startBitrate * 1000, inst->maxFramerate);
if (!SetSvcRates(allocation)) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
diff --git a/modules/video_coding/codecs/vp9/vp9_impl.h b/modules/video_coding/codecs/vp9/vp9_impl.h
index b158523..da86849 100644
--- a/modules/video_coding/codecs/vp9/vp9_impl.h
+++ b/modules/video_coding/codecs/vp9/vp9_impl.h
@@ -46,7 +46,7 @@
int SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
- int SetRateAllocation(const BitrateAllocation& bitrate_allocation,
+ int SetRateAllocation(const VideoBitrateAllocation& bitrate_allocation,
uint32_t frame_rate) override;
const char* ImplementationName() const override;
@@ -78,7 +78,7 @@
bool first_frame_in_picture);
bool ExplicitlyConfiguredSpatialLayers() const;
- bool SetSvcRates(const BitrateAllocation& bitrate_allocation);
+ bool SetSvcRates(const VideoBitrateAllocation& bitrate_allocation);
// Used for flexible mode to set the flags and buffer references used
// by the encoder. Also calculates the references used by the RTP
diff --git a/modules/video_coding/generic_encoder.cc b/modules/video_coding/generic_encoder.cc
index 1490882..f9d8234 100644
--- a/modules/video_coding/generic_encoder.cc
+++ b/modules/video_coding/generic_encoder.cc
@@ -38,8 +38,9 @@
: encoder_(encoder),
vcm_encoded_frame_callback_(encoded_frame_callback),
internal_source_(internal_source),
- encoder_params_({BitrateAllocation(), 0, 0, 0}),
- streams_or_svc_num_(0) {}
+ encoder_params_({VideoBitrateAllocation(), 0, 0, 0}),
+ streams_or_svc_num_(0),
+ codec_type_(VideoCodecType::kVideoCodecUnknown) {}
VCMGenericEncoder::~VCMGenericEncoder() {}
diff --git a/modules/video_coding/generic_encoder.h b/modules/video_coding/generic_encoder.h
index 4efd961..03de626 100644
--- a/modules/video_coding/generic_encoder.h
+++ b/modules/video_coding/generic_encoder.h
@@ -28,7 +28,7 @@
} // namespace media_optimization
struct EncoderParameters {
- BitrateAllocation target_bitrate;
+ VideoBitrateAllocation target_bitrate;
uint8_t loss_rate;
int64_t rtt;
uint32_t input_frame_rate;
diff --git a/modules/video_coding/include/mock/mock_video_codec_interface.h b/modules/video_coding/include/mock/mock_video_codec_interface.h
index e558b7c..82363f3 100644
--- a/modules/video_coding/include/mock/mock_video_codec_interface.h
+++ b/modules/video_coding/include/mock/mock_video_codec_interface.h
@@ -46,7 +46,7 @@
MOCK_METHOD2(SetChannelParameters, int32_t(uint32_t packetLoss, int64_t rtt));
MOCK_METHOD2(SetRates, int32_t(uint32_t newBitRate, uint32_t frameRate));
MOCK_METHOD2(SetRateAllocation,
- int32_t(const BitrateAllocation& newBitRate,
+ int32_t(const VideoBitrateAllocation& newBitRate,
uint32_t frameRate));
};
diff --git a/modules/video_coding/utility/default_video_bitrate_allocator.cc b/modules/video_coding/utility/default_video_bitrate_allocator.cc
index 0c4ae9b..0124ad1 100644
--- a/modules/video_coding/utility/default_video_bitrate_allocator.cc
+++ b/modules/video_coding/utility/default_video_bitrate_allocator.cc
@@ -20,10 +20,10 @@
DefaultVideoBitrateAllocator::~DefaultVideoBitrateAllocator() {}
-BitrateAllocation DefaultVideoBitrateAllocator::GetAllocation(
+VideoBitrateAllocation DefaultVideoBitrateAllocator::GetAllocation(
uint32_t total_bitrate_bps,
uint32_t framerate) {
- BitrateAllocation allocation;
+ VideoBitrateAllocation allocation;
if (total_bitrate_bps == 0 || !codec_.active)
return allocation;
diff --git a/modules/video_coding/utility/default_video_bitrate_allocator.h b/modules/video_coding/utility/default_video_bitrate_allocator.h
index 0ef709e..6ecd878 100644
--- a/modules/video_coding/utility/default_video_bitrate_allocator.h
+++ b/modules/video_coding/utility/default_video_bitrate_allocator.h
@@ -20,8 +20,8 @@
explicit DefaultVideoBitrateAllocator(const VideoCodec& codec);
~DefaultVideoBitrateAllocator() override;
- BitrateAllocation GetAllocation(uint32_t total_bitrate,
- uint32_t framerate) override;
+ VideoBitrateAllocation GetAllocation(uint32_t total_bitrate,
+ uint32_t framerate) override;
uint32_t GetPreferredBitrateBps(uint32_t framerate) override;
private:
diff --git a/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc b/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc
index e27b3d3..05b5a0a 100644
--- a/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc
+++ b/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc
@@ -41,19 +41,22 @@
};
TEST_F(DefaultVideoBitrateAllocatorTest, ZeroIsOff) {
- BitrateAllocation allocation = allocator_->GetAllocation(0, kMaxFramerate);
+ VideoBitrateAllocation allocation =
+ allocator_->GetAllocation(0, kMaxFramerate);
EXPECT_EQ(0u, allocation.get_sum_bps());
}
TEST_F(DefaultVideoBitrateAllocatorTest, Inactive) {
codec_.active = false;
allocator_.reset(new DefaultVideoBitrateAllocator(codec_));
- BitrateAllocation allocation = allocator_->GetAllocation(1, kMaxFramerate);
+ VideoBitrateAllocation allocation =
+ allocator_->GetAllocation(1, kMaxFramerate);
EXPECT_EQ(0u, allocation.get_sum_bps());
}
TEST_F(DefaultVideoBitrateAllocatorTest, CapsToMin) {
- BitrateAllocation allocation = allocator_->GetAllocation(1, kMaxFramerate);
+ VideoBitrateAllocation allocation =
+ allocator_->GetAllocation(1, kMaxFramerate);
EXPECT_EQ(kMinBitrateBps, allocation.get_sum_bps());
allocation = allocator_->GetAllocation(kMinBitrateBps - 1, kMaxFramerate);
@@ -64,7 +67,7 @@
}
TEST_F(DefaultVideoBitrateAllocatorTest, CapsToMax) {
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator_->GetAllocation(kMaxBitrateBps, kMaxFramerate);
EXPECT_EQ(kMaxBitrateBps, allocation.get_sum_bps());
@@ -77,7 +80,7 @@
}
TEST_F(DefaultVideoBitrateAllocatorTest, GoodInBetween) {
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator_->GetAllocation(kMinBitrateBps + 1, kMaxFramerate);
EXPECT_EQ(kMinBitrateBps + 1, allocation.get_sum_bps());
diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
index f986d3b..aa9b320 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
+++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
@@ -65,7 +65,8 @@
}
template <size_t S>
- void ExpectEqual(uint32_t (&expected)[S], const BitrateAllocation& actual) {
+ void ExpectEqual(uint32_t (&expected)[S],
+ const VideoBitrateAllocation& actual) {
// EXPECT_EQ(S, actual.size());
uint32_t sum = 0;
for (size_t i = 0; i < S; ++i) {
@@ -112,7 +113,7 @@
}
}
- BitrateAllocation GetAllocation(uint32_t target_bitrate) {
+ VideoBitrateAllocation GetAllocation(uint32_t target_bitrate) {
return allocator_->GetAllocation(target_bitrate * 1000U, kDefaultFrameRate);
}
@@ -138,7 +139,7 @@
}
TEST_F(SimulcastRateAllocatorTest, NoSimulcastNoMax) {
- const uint32_t kMax = BitrateAllocation::kMaxBitrateBps / 1000;
+ const uint32_t kMax = VideoBitrateAllocation::kMaxBitrateBps / 1000;
codec_.active = true;
codec_.maxBitrate = 0;
CreateAllocator();
@@ -528,7 +529,7 @@
SetupConferenceScreenshare(GetParam());
CreateAllocator();
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator_->GetAllocation(kTargetBitrateKbps * 1000, kFramerateFps);
// All allocation should go in TL0.
@@ -541,7 +542,7 @@
CreateAllocator();
uint32_t target_bitrate_kbps = (kTargetBitrateKbps + kMaxBitrateKbps) / 2;
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator_->GetAllocation(target_bitrate_kbps * 1000, kFramerateFps);
// Fill TL0, then put the rest in TL1.
@@ -555,7 +556,7 @@
SetupConferenceScreenshare(GetParam());
CreateAllocator();
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator_->GetAllocation(kMaxBitrateKbps * 2000, kFramerateFps);
// Fill both TL0 and TL1, but no more.
@@ -573,7 +574,7 @@
// Enough bitrate for TL0 and TL1.
uint32_t target_bitrate_kbps = (kTargetBitrateKbps + kMaxBitrateKbps) / 2;
- BitrateAllocation allocation =
+ VideoBitrateAllocation allocation =
allocator_->GetAllocation(target_bitrate_kbps * 1000, kFramerateFps);
EXPECT_EQ(0U, allocation.get_sum_kbps());
diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc
index 2bb67cb..2ef1159 100644
--- a/modules/video_coding/video_codec_initializer_unittest.cc
+++ b/modules/video_coding/video_codec_initializer_unittest.cc
@@ -135,8 +135,9 @@
streams_.push_back(DefaultStream());
EXPECT_TRUE(InitializeCodec());
- BitrateAllocation bitrate_allocation = bitrate_allocator_out_->GetAllocation(
- kDefaultTargetBitrateBps, kDefaultFrameRate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_out_->GetAllocation(kDefaultTargetBitrateBps,
+ kDefaultFrameRate);
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
EXPECT_EQ(kDefaultTargetBitrateBps, bitrate_allocation.get_sum_bps());
@@ -149,8 +150,9 @@
streams_.push_back(inactive_stream);
EXPECT_TRUE(InitializeCodec());
- BitrateAllocation bitrate_allocation = bitrate_allocator_out_->GetAllocation(
- kDefaultTargetBitrateBps, kDefaultFrameRate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_out_->GetAllocation(kDefaultTargetBitrateBps,
+ kDefaultFrameRate);
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
EXPECT_EQ(0U, bitrate_allocation.get_sum_bps());
@@ -163,8 +165,9 @@
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
EXPECT_EQ(2u, codec_out_.VP8()->numberOfTemporalLayers);
- BitrateAllocation bitrate_allocation = bitrate_allocator_out_->GetAllocation(
- kScreenshareCodecTargetBitrateBps, kScreenshareDefaultFramerate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_out_->GetAllocation(kScreenshareCodecTargetBitrateBps,
+ kScreenshareDefaultFramerate);
EXPECT_EQ(kScreenshareCodecTargetBitrateBps,
bitrate_allocation.get_sum_bps());
EXPECT_EQ(kScreenshareTl0BitrateBps, bitrate_allocation.GetBitrate(0, 0));
@@ -182,8 +185,9 @@
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
const uint32_t max_bitrate_bps =
streams_[0].target_bitrate_bps + streams_[1].max_bitrate_bps;
- BitrateAllocation bitrate_allocation = bitrate_allocator_out_->GetAllocation(
- max_bitrate_bps, kScreenshareDefaultFramerate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_out_->GetAllocation(max_bitrate_bps,
+ kScreenshareDefaultFramerate);
EXPECT_EQ(max_bitrate_bps, bitrate_allocation.get_sum_bps());
EXPECT_EQ(static_cast<uint32_t>(streams_[0].target_bitrate_bps),
bitrate_allocation.GetSpatialLayerSum(0));
@@ -206,8 +210,9 @@
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
const uint32_t target_bitrate =
streams_[0].target_bitrate_bps + streams_[1].target_bitrate_bps;
- BitrateAllocation bitrate_allocation = bitrate_allocator_out_->GetAllocation(
- target_bitrate, kScreenshareDefaultFramerate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_out_->GetAllocation(target_bitrate,
+ kScreenshareDefaultFramerate);
EXPECT_EQ(static_cast<uint32_t>(streams_[0].max_bitrate_bps),
bitrate_allocation.get_sum_bps());
EXPECT_EQ(static_cast<uint32_t>(streams_[0].max_bitrate_bps),
@@ -229,7 +234,7 @@
EXPECT_EQ(3u, codec_out_.VP8()->numberOfTemporalLayers);
const uint32_t max_bitrate_bps =
streams_[0].target_bitrate_bps + streams_[1].max_bitrate_bps;
- BitrateAllocation bitrate_allocation =
+ VideoBitrateAllocation bitrate_allocation =
bitrate_allocator_out_->GetAllocation(max_bitrate_bps, kDefaultFrameRate);
EXPECT_EQ(max_bitrate_bps, bitrate_allocation.get_sum_bps());
EXPECT_EQ(static_cast<uint32_t>(streams_[0].target_bitrate_bps),
diff --git a/modules/video_coding/video_sender.cc b/modules/video_coding/video_sender.cc
index 680b76f..c8150a8 100644
--- a/modules/video_coding/video_sender.cc
+++ b/modules/video_coding/video_sender.cc
@@ -35,7 +35,7 @@
_codecDataBase(&_encodedFrameCallback),
frame_dropper_enabled_(true),
current_codec_(),
- encoder_params_({BitrateAllocation(), 0, 0, 0}),
+ encoder_params_({VideoBitrateAllocation(), 0, 0, 0}),
encoder_has_internal_source_(false),
next_frame_types_(1, kVideoFrameDelta) {
_mediaOpt.Reset();
@@ -150,7 +150,7 @@
if (input_frame_rate == 0)
input_frame_rate = current_codec_.maxFramerate;
- BitrateAllocation bitrate_allocation;
+ VideoBitrateAllocation bitrate_allocation;
// Only call allocators if bitrate > 0 (ie, not suspended), otherwise they
// might cap the bitrate to the min bitrate configured.
if (target_bitrate_bps > 0) {
@@ -171,7 +171,7 @@
void VideoSender::UpdateChannelParameters(
VideoBitrateAllocator* bitrate_allocator,
VideoBitrateAllocationObserver* bitrate_updated_callback) {
- BitrateAllocation target_rate;
+ VideoBitrateAllocation target_rate;
{
rtc::CritScope cs(¶ms_crit_);
encoder_params_ =
diff --git a/modules/video_coding/video_sender_unittest.cc b/modules/video_coding/video_sender_unittest.cc
index 8e1330a..877eb99 100644
--- a/modules/video_coding/video_sender_unittest.cc
+++ b/modules/video_coding/video_sender_unittest.cc
@@ -306,7 +306,7 @@
const uint32_t new_bitrate_kbps = settings_.startBitrate + 300;
// Initial frame rate is taken from config, as we have no data yet.
- BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
+ VideoBitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
new_bitrate_kbps * 1000, settings_.maxFramerate);
EXPECT_CALL(encoder_,
SetRateAllocation(new_rate_allocation, settings_.maxFramerate))
@@ -351,7 +351,7 @@
// Update encoder bitrate parameters. We expect that to immediately call
// SetRates on the encoder without waiting for AddFrame processing.
const uint32_t new_bitrate_kbps = settings_.startBitrate + 300;
- BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
+ VideoBitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
new_bitrate_kbps * 1000, settings_.maxFramerate);
EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _))
.Times(1)
@@ -383,7 +383,7 @@
// Call to SetChannelParameters with changed bitrate should call encoder
// SetRates but not encoder SetChannelParameters (that are unchanged).
uint32_t new_bitrate_bps = 2 * settings_.startBitrate * 1000;
- BitrateAllocation new_rate_allocation =
+ VideoBitrateAllocation new_rate_allocation =
rate_allocator_->GetAllocation(new_bitrate_bps, kInputFps);
EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, kInputFps))
.Times(1)