Remove deprecated SetRates/SetRateAllocation from VideoEncoder.
This CL removes two deprecated methods from the VideoEncoder interface:
* int32_t SetRates(uint32_t, uint32_t);
* int32_t SetRateAllocation(const VideoBitrateAllocation&, uint32_t);
These are no longer used, instead the new version must be implemented:
void SetRates(const RateControlParameters&) = 0;
Migrating is straight forward. For the old SetRates, simple replace:
int32_t MyEncoder::SetRates(uint32_t bitrate, uint32_t framerate) {
with
void MyEncoder::SetRates(const RateControlParameters& parameters) {
uint32_t bitrate = parameters.bitrate.get_sum_kbps();
uint32_t framerate =
static_cast<uint32_t>(parameters.framerate_fps + 0.5);
For SetRateAllocation, replace:
int32_t MyEncoder::SetRateAllocation(
const VideoBitrateAllocation& allocation,
uint32_t framerate) {
with
void MyEncoder::SetRates(const RateControlParameters& parameters) {
const VideoBitrateAllocation& allocation = parameters.bitrate;
uint32_t framerate =
static_cast<uint32_t>(parameters.framerate_fps + 0.5);
Two more things to note:
1. The new method is void. Previously the only use of the return value
in production code was to log a more or less generic error message.
Instead, log the actual error from the encoder when it happens,
then just return.
2. The new method is pure virtual; it must be overriden even in test.
This CL is intended to be landed two weeks after creation, on Thursday
May 9th 2019.
Bug: webrtc:10481
Change-Id: I61349571a280bd40cd100ca9f93c4aa7748ed30d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134214
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27926}
diff --git a/api/test/mock_video_encoder.h b/api/test/mock_video_encoder.h
index f99f7e3..9333b89 100644
--- a/api/test/mock_video_encoder.h
+++ b/api/test/mock_video_encoder.h
@@ -44,10 +44,6 @@
int32_t(EncodedImageCallback* callback));
MOCK_METHOD0(Release, int32_t());
MOCK_METHOD0(Reset, int32_t());
- MOCK_METHOD2(SetRates, int32_t(uint32_t newBitRate, uint32_t frameRate));
- MOCK_METHOD2(SetRateAllocation,
- int32_t(const VideoBitrateAllocation& newBitRate,
- uint32_t frameRate));
MOCK_METHOD1(SetRates, void(const RateControlParameters& parameters));
MOCK_CONST_METHOD0(GetEncoderInfo, EncoderInfo(void));
};
diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc
index e4dbd67..710d90d 100644
--- a/api/video_codecs/video_encoder.cc
+++ b/api/video_codecs/video_encoder.cc
@@ -118,22 +118,6 @@
VideoEncoder::RateControlParameters::~RateControlParameters() = default;
-int32_t VideoEncoder::SetRates(uint32_t bitrate, uint32_t framerate) {
- RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
- return -1;
-}
-
-int32_t VideoEncoder::SetRateAllocation(
- const VideoBitrateAllocation& allocation,
- uint32_t framerate) {
- return SetRates(allocation.get_sum_kbps(), framerate);
-}
-
-void VideoEncoder::SetRates(const RateControlParameters& parameters) {
- SetRateAllocation(parameters.bitrate,
- static_cast<uint32_t>(parameters.framerate_fps + 0.5));
-}
-
void VideoEncoder::OnPacketLossRateUpdate(float packet_loss_rate) {}
void VideoEncoder::OnRttUpdate(int64_t rtt_ms) {}
diff --git a/api/video_codecs/video_encoder.h b/api/video_codecs/video_encoder.h
index 3af7dfd..c01309f 100644
--- a/api/video_codecs/video_encoder.h
+++ b/api/video_codecs/video_encoder.h
@@ -289,26 +289,10 @@
virtual int32_t Encode(const VideoFrame& frame,
const std::vector<VideoFrameType>* frame_types) = 0;
- // DEPRECATED! Instead use the one below:
- // void SetRateAllocation(const VideoBitrateAllocation&, DataRate, uint32)
- // For now has a default implementation that call RTC_NOTREACHED().
- // TODO(bugs.webrtc.org/10481): Remove this once all usage is gone.
- virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate);
-
- // DEPRECATED! Instead, use void SetRates(const RateControlParameters&);
- // For now has a default implementation that calls
- // int32_t SetRates(uin32_t, uint32_t) with |allocation.get_sum_kbps()| and
- // |framerate| as arguments. This will be removed.
- // TODO(bugs.webrtc.org/10481): Remove this once all usage is gone.
- virtual int32_t SetRateAllocation(const VideoBitrateAllocation& allocation,
- uint32_t framerate);
-
// Sets rate control parameters: bitrate, framerate, etc. These settings are
// instantaneous (i.e. not moving averages) and should apply from now until
// the next call to SetRates().
- // Default implementation will call SetRateAllocation() with appropriate
- // members of |parameters| as parameters.
- virtual void SetRates(const RateControlParameters& parameters);
+ virtual void SetRates(const RateControlParameters& parameters) = 0;
// Inform the encoder when the packet loss rate changes.
//