aboutsummaryrefslogtreecommitdiff
path: root/media/engine
diff options
context:
space:
mode:
authorErik Språng <sprang@webrtc.org>2018-04-23 12:32:22 +0200
committerCommit Bot <commit-bot@chromium.org>2018-04-23 15:31:27 +0000
commit566124a6df20995484868fdaef524c85e3faa7c5 (patch)
tree98dfcc64895d68b4d165bd1f48a5407a6baee9a2 /media/engine
parent5c14725d53a6bebbdc47fb88f7a1b2191cbe060f (diff)
downloadwebrtc-566124a6df20995484868fdaef524c85e3faa7c5.tar.gz
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}
Diffstat (limited to 'media/engine')
-rw-r--r--media/engine/fakewebrtcvideoengine.h2
-rw-r--r--media/engine/scopedvideoencoder.cc4
-rw-r--r--media/engine/simulcast_encoder_adapter.cc9
-rw-r--r--media/engine/simulcast_encoder_adapter.h2
-rw-r--r--media/engine/simulcast_encoder_adapter_unittest.cc14
-rw-r--r--media/engine/videoencodersoftwarefallbackwrapper.cc2
-rw-r--r--media/engine/videoencodersoftwarefallbackwrapper.h4
-rw-r--r--media/engine/videoencodersoftwarefallbackwrapper_unittest.cc4
-rw-r--r--media/engine/vp8_encoder_simulcast_proxy.cc2
-rw-r--r--media/engine/vp8_encoder_simulcast_proxy.h2
10 files changed, 23 insertions, 22 deletions
diff --git a/media/engine/fakewebrtcvideoengine.h b/media/engine/fakewebrtcvideoengine.h
index 2153f6be38..3705a83dfd 100644
--- a/media/engine/fakewebrtcvideoengine.h
+++ b/media/engine/fakewebrtcvideoengine.h
@@ -159,7 +159,7 @@ class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder {
return WEBRTC_VIDEO_CODEC_OK;
}
- int32_t SetRateAllocation(const webrtc::BitrateAllocation& allocation,
+ int32_t SetRateAllocation(const webrtc::VideoBitrateAllocation& allocation,
uint32_t framerate) override {
return WEBRTC_VIDEO_CODEC_OK;
}
diff --git a/media/engine/scopedvideoencoder.cc b/media/engine/scopedvideoencoder.cc
index 41d3bb05a5..2a1d93d3db 100644
--- a/media/engine/scopedvideoencoder.cc
+++ b/media/engine/scopedvideoencoder.cc
@@ -34,7 +34,7 @@ class ScopedVideoEncoder : public webrtc::VideoEncoder {
const std::vector<webrtc::FrameType>* frame_types) override;
int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
int32_t SetRates(uint32_t bitrate, uint32_t framerate) override;
- int32_t SetRateAllocation(const webrtc::BitrateAllocation& allocation,
+ int32_t SetRateAllocation(const webrtc::VideoBitrateAllocation& allocation,
uint32_t framerate) override;
ScalingSettings GetScalingSettings() const override;
bool SupportsNativeHandle() const override;
@@ -84,7 +84,7 @@ int32_t ScopedVideoEncoder::SetRates(uint32_t bitrate, uint32_t framerate) {
}
int32_t ScopedVideoEncoder::SetRateAllocation(
- const webrtc::BitrateAllocation& allocation,
+ const webrtc::VideoBitrateAllocation& allocation,
uint32_t framerate) {
return encoder_->SetRateAllocation(allocation, framerate);
}
diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc
index e33666f152..88c0a38470 100644
--- a/media/engine/simulcast_encoder_adapter.cc
+++ b/media/engine/simulcast_encoder_adapter.cc
@@ -178,7 +178,7 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst,
codec_ = *inst;
SimulcastRateAllocator rate_allocator(codec_);
- BitrateAllocation allocation = rate_allocator.GetAllocation(
+ VideoBitrateAllocation allocation = rate_allocator.GetAllocation(
codec_.startBitrate * 1000, codec_.maxFramerate);
std::vector<uint32_t> start_bitrates;
for (int i = 0; i < kMaxSimulcastStreams; ++i) {
@@ -367,8 +367,9 @@ int SimulcastEncoderAdapter::SetChannelParameters(uint32_t packet_loss,
return WEBRTC_VIDEO_CODEC_OK;
}
-int SimulcastEncoderAdapter::SetRateAllocation(const BitrateAllocation& bitrate,
- uint32_t new_framerate) {
+int SimulcastEncoderAdapter::SetRateAllocation(
+ const VideoBitrateAllocation& bitrate,
+ uint32_t new_framerate) {
RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_);
if (!Initialized()) {
@@ -410,7 +411,7 @@ int SimulcastEncoderAdapter::SetRateAllocation(const BitrateAllocation& bitrate,
// Slice the temporal layers out of the full allocation and pass it on to
// the encoder handling the current simulcast stream.
- BitrateAllocation stream_allocation;
+ VideoBitrateAllocation stream_allocation;
for (int i = 0; i < kMaxTemporalStreams; ++i) {
if (bitrate.HasBitrate(stream_idx, i)) {
stream_allocation.SetBitrate(0, i, bitrate.GetBitrate(stream_idx, i));
diff --git a/media/engine/simulcast_encoder_adapter.h b/media/engine/simulcast_encoder_adapter.h
index 240a621134..f3361501c4 100644
--- a/media/engine/simulcast_encoder_adapter.h
+++ b/media/engine/simulcast_encoder_adapter.h
@@ -47,7 +47,7 @@ class SimulcastEncoderAdapter : public VP8Encoder {
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;
// Eventual handler for the contained encoders' EncodedImageCallbacks, but
diff --git a/media/engine/simulcast_encoder_adapter_unittest.cc b/media/engine/simulcast_encoder_adapter_unittest.cc
index b3a6bd49c7..2930e25d66 100644
--- a/media/engine/simulcast_encoder_adapter_unittest.cc
+++ b/media/engine/simulcast_encoder_adapter_unittest.cc
@@ -150,7 +150,7 @@ class MockVideoEncoder : public VideoEncoder {
MOCK_METHOD0(Release, int32_t());
- int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
+ int32_t SetRateAllocation(const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) {
last_set_bitrate_ = bitrate_allocation;
return 0;
@@ -184,7 +184,7 @@ class MockVideoEncoder : public VideoEncoder {
init_encode_return_value_ = value;
}
- BitrateAllocation last_set_bitrate() const { return last_set_bitrate_; }
+ VideoBitrateAllocation last_set_bitrate() const { return last_set_bitrate_; }
MOCK_CONST_METHOD0(ImplementationName, const char*());
@@ -192,7 +192,7 @@ class MockVideoEncoder : public VideoEncoder {
MockVideoEncoderFactory* const factory_;
bool supports_native_handle_ = false;
int32_t init_encode_return_value_ = 0;
- BitrateAllocation last_set_bitrate_;
+ VideoBitrateAllocation last_set_bitrate_;
VideoCodec codec_;
EncodedImageCallback* callback_;
@@ -679,22 +679,22 @@ TEST_F(TestSimulcastEncoderAdapterFake, SetRatesUnderMinBitrate) {
rate_allocator_.reset(new SimulcastRateAllocator(codec_));
// Above min should be respected.
- BitrateAllocation target_bitrate =
+ VideoBitrateAllocation target_bitrate =
rate_allocator_->GetAllocation(codec_.minBitrate * 1000, 30);
adapter_->SetRateAllocation(target_bitrate, 30);
EXPECT_EQ(target_bitrate,
helper_->factory()->encoders()[0]->last_set_bitrate());
// Below min but non-zero should be replaced with the min bitrate.
- BitrateAllocation too_low_bitrate =
+ VideoBitrateAllocation too_low_bitrate =
rate_allocator_->GetAllocation((codec_.minBitrate - 1) * 1000, 30);
adapter_->SetRateAllocation(too_low_bitrate, 30);
EXPECT_EQ(target_bitrate,
helper_->factory()->encoders()[0]->last_set_bitrate());
// Zero should be passed on as is, since it means "pause".
- adapter_->SetRateAllocation(BitrateAllocation(), 30);
- EXPECT_EQ(BitrateAllocation(),
+ adapter_->SetRateAllocation(VideoBitrateAllocation(), 30);
+ EXPECT_EQ(VideoBitrateAllocation(),
helper_->factory()->encoders()[0]->last_set_bitrate());
}
diff --git a/media/engine/videoencodersoftwarefallbackwrapper.cc b/media/engine/videoencodersoftwarefallbackwrapper.cc
index 50bc3f2ab7..bc60fde030 100644
--- a/media/engine/videoencodersoftwarefallbackwrapper.cc
+++ b/media/engine/videoencodersoftwarefallbackwrapper.cc
@@ -203,7 +203,7 @@ int32_t VideoEncoderSoftwareFallbackWrapper::SetChannelParameters(
}
int32_t VideoEncoderSoftwareFallbackWrapper::SetRateAllocation(
- const BitrateAllocation& bitrate_allocation,
+ const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) {
rates_set_ = true;
bitrate_allocation_ = bitrate_allocation;
diff --git a/media/engine/videoencodersoftwarefallbackwrapper.h b/media/engine/videoencodersoftwarefallbackwrapper.h
index c54728e521..1c472d1e55 100644
--- a/media/engine/videoencodersoftwarefallbackwrapper.h
+++ b/media/engine/videoencodersoftwarefallbackwrapper.h
@@ -42,7 +42,7 @@ class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
const CodecSpecificInfo* codec_specific_info,
const std::vector<FrameType>* frame_types) override;
int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
- int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
+ int32_t SetRateAllocation(const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) override;
bool SupportsNativeHandle() const override;
ScalingSettings GetScalingSettings() const override;
@@ -80,7 +80,7 @@ class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
// The last bitrate/framerate set, and a flag for noting they are set.
bool rates_set_;
- BitrateAllocation bitrate_allocation_;
+ VideoBitrateAllocation bitrate_allocation_;
uint32_t framerate_;
// The last channel parameters set, and a flag for noting they are set.
diff --git a/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc b/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
index df04d8082b..07b569c681 100644
--- a/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
+++ b/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
@@ -84,7 +84,7 @@ class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test {
return WEBRTC_VIDEO_CODEC_OK;
}
- int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
+ int32_t SetRateAllocation(const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) override {
++set_rates_count_;
return WEBRTC_VIDEO_CODEC_OK;
@@ -283,7 +283,7 @@ TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
SetRatesForwardedDuringFallback) {
UtilizeFallbackEncoder();
EXPECT_EQ(1, fake_encoder_->set_rates_count_);
- fallback_wrapper_.SetRateAllocation(BitrateAllocation(), 1);
+ fallback_wrapper_.SetRateAllocation(VideoBitrateAllocation(), 1);
EXPECT_EQ(2, fake_encoder_->set_rates_count_);
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
}
diff --git a/media/engine/vp8_encoder_simulcast_proxy.cc b/media/engine/vp8_encoder_simulcast_proxy.cc
index 283f17bb94..94020c332d 100644
--- a/media/engine/vp8_encoder_simulcast_proxy.cc
+++ b/media/engine/vp8_encoder_simulcast_proxy.cc
@@ -59,7 +59,7 @@ int VP8EncoderSimulcastProxy::SetChannelParameters(uint32_t packet_loss,
}
int VP8EncoderSimulcastProxy::SetRateAllocation(
- const BitrateAllocation& bitrate,
+ const VideoBitrateAllocation& bitrate,
uint32_t new_framerate) {
return encoder_->SetRateAllocation(bitrate, new_framerate);
}
diff --git a/media/engine/vp8_encoder_simulcast_proxy.h b/media/engine/vp8_encoder_simulcast_proxy.h
index d32f9b22ed..7e9fd4effd 100644
--- a/media/engine/vp8_encoder_simulcast_proxy.h
+++ b/media/engine/vp8_encoder_simulcast_proxy.h
@@ -37,7 +37,7 @@ class VP8EncoderSimulcastProxy : public VP8Encoder {
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;
VideoEncoder::ScalingSettings GetScalingSettings() const override;