Revert "Add ability to specify if rate controller of video encoder is trusted."

This reverts commit 3e335d1423cab06cca8cdb4f1fadb0b16c9e7d38.

Reason for revert: breaks downstream project

Original change's description:
> Add ability to specify if rate controller of video encoder is trusted.
>
> If rate controller is trusted, we disable the frame dropper in the
> media optimization module.
>
> Bug: webrtc:9722
> Change-Id: I821f21fd74a400ee9d5aa3f6b42d4e569033acbe
> Reviewed-on: https://webrtc-review.googlesource.com/c/105020
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Per Kjellander <perkj@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25107}

TBR=brandtr@webrtc.org,ilnik@webrtc.org,nisse@webrtc.org,sprang@webrtc.org,perkj@webrtc.org

Change-Id: Ifdb0aae684894854a184ec1e7423a7c62e7ba237
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9722
Reviewed-on: https://webrtc-review.googlesource.com/c/105360
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25117}
This commit is contained in:
Oleh Prypin
2018-10-11 14:33:39 +00:00
committed by Commit Bot
parent cdc959fb42
commit a1d9ca47f9
31 changed files with 42 additions and 406 deletions

View File

@ -515,19 +515,6 @@ if (rtc_include_tests) {
]
}
rtc_source_set("mock_video_encoder") {
testonly = true
sources = [
"test/mock_video_encoder.cc",
"test/mock_video_encoder.h",
]
deps = [
"../api/video_codecs:video_codecs_api",
"../test:test_support",
]
}
rtc_source_set("rtc_api_unittests") {
testonly = true

View File

@ -1,20 +0,0 @@
/*
* Copyright (c) 2018 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 "api/test/mock_video_encoder.h"
namespace webrtc {
MockEncodedImageCallback::MockEncodedImageCallback() = default;
MockEncodedImageCallback::~MockEncodedImageCallback() = default;
MockVideoEncoder::MockVideoEncoder() = default;
MockVideoEncoder::~MockVideoEncoder() = default;
} // namespace webrtc

View File

@ -1,58 +0,0 @@
/*
* Copyright (c) 2018 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.
*/
#ifndef API_TEST_MOCK_VIDEO_ENCODER_H_
#define API_TEST_MOCK_VIDEO_ENCODER_H_
#include <vector>
#include "api/video_codecs/video_encoder.h"
#include "test/gmock.h"
namespace webrtc {
class MockEncodedImageCallback : public EncodedImageCallback {
public:
MockEncodedImageCallback();
~MockEncodedImageCallback();
MOCK_METHOD3(OnEncodedImage,
Result(const EncodedImage& encodedImage,
const CodecSpecificInfo* codecSpecificInfo,
const RTPFragmentationHeader* fragmentation));
};
class MockVideoEncoder : public VideoEncoder {
public:
MockVideoEncoder();
~MockVideoEncoder();
MOCK_CONST_METHOD2(Version, int32_t(int8_t* version, int32_t length));
MOCK_METHOD3(InitEncode,
int32_t(const VideoCodec* codecSettings,
int32_t numberOfCores,
size_t maxPayloadSize));
MOCK_METHOD3(Encode,
int32_t(const VideoFrame& inputImage,
const CodecSpecificInfo* codecSpecificInfo,
const std::vector<FrameType>* frame_types));
MOCK_METHOD1(RegisterEncodeCompleteCallback,
int32_t(EncodedImageCallback* callback));
MOCK_METHOD0(Release, int32_t());
MOCK_METHOD0(Reset, int32_t());
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 VideoBitrateAllocation& newBitRate,
uint32_t frameRate));
MOCK_CONST_METHOD0(HasTrustedRateController, bool(void));
};
} // namespace webrtc
#endif // API_TEST_MOCK_VIDEO_ENCODER_H_

View File

@ -21,7 +21,6 @@ if (rtc_include_tests) {
"..:builtin_video_encoder_factory",
"..:rtc_software_fallback_wrappers",
"..:video_codecs_api",
"../../../api:mock_video_encoder",
"../../../modules/video_coding:video_codec_interface",
"../../../modules/video_coding:video_coding_utility",
"../../../modules/video_coding:webrtc_vp8",

View File

@ -12,7 +12,6 @@
#include <utility>
#include "api/test/mock_video_encoder.h"
#include "api/video/i420_buffer.h"
#include "api/video/video_bitrate_allocation.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
@ -23,12 +22,9 @@
#include "rtc_base/checks.h"
#include "rtc_base/fakeclock.h"
#include "test/field_trial.h"
#include "test/gmock.h"
#include "test/gtest.h"
namespace webrtc {
using ::testing::Return;
namespace {
const int kWidth = 320;
const int kHeight = 240;
@ -533,88 +529,4 @@ TEST_F(ForcedFallbackTestEnabled, ScalingDisabledIfResizeOff) {
EXPECT_FALSE(settings.thresholds.has_value());
}
TEST(SoftwareFallbackEncoderTest, BothRateControllersNotTrusted) {
auto* sw_encoder = new testing::NiceMock<MockVideoEncoder>();
auto* hw_encoder = new testing::NiceMock<MockVideoEncoder>();
EXPECT_CALL(*sw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(false));
EXPECT_CALL(*hw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(false));
std::unique_ptr<VideoEncoder> wrapper =
CreateVideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<VideoEncoder>(sw_encoder),
std::unique_ptr<VideoEncoder>(hw_encoder));
EXPECT_FALSE(wrapper->HasTrustedRateController());
}
TEST(SoftwareFallbackEncoderTest, SwRateControllerTrusted) {
auto* sw_encoder = new testing::NiceMock<MockVideoEncoder>();
auto* hw_encoder = new testing::NiceMock<MockVideoEncoder>();
EXPECT_CALL(*sw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_CALL(*hw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(false));
std::unique_ptr<VideoEncoder> wrapper =
CreateVideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<VideoEncoder>(sw_encoder),
std::unique_ptr<VideoEncoder>(hw_encoder));
EXPECT_FALSE(wrapper->HasTrustedRateController());
}
TEST(SoftwareFallbackEncoderTest, SwRateControllerTrustedNoHw) {
auto* sw_encoder = new testing::NiceMock<MockVideoEncoder>();
EXPECT_CALL(*sw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
std::unique_ptr<VideoEncoder> wrapper =
CreateVideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<VideoEncoder>(sw_encoder),
std::unique_ptr<VideoEncoder>());
EXPECT_TRUE(wrapper->HasTrustedRateController());
}
TEST(SoftwareFallbackEncoderTest, HwRateControllerTrusted) {
auto* sw_encoder = new testing::NiceMock<MockVideoEncoder>();
auto* hw_encoder = new testing::NiceMock<MockVideoEncoder>();
EXPECT_CALL(*sw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(false));
EXPECT_CALL(*hw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
std::unique_ptr<VideoEncoder> wrapper =
CreateVideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<VideoEncoder>(sw_encoder),
std::unique_ptr<VideoEncoder>(hw_encoder));
EXPECT_FALSE(wrapper->HasTrustedRateController());
}
TEST(SoftwareFallbackEncoderTest, HwRateControllerTrustedNoSw) {
auto* hw_encoder = new testing::NiceMock<MockVideoEncoder>();
EXPECT_CALL(*hw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
std::unique_ptr<VideoEncoder> wrapper =
CreateVideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<VideoEncoder>(),
std::unique_ptr<VideoEncoder>(hw_encoder));
EXPECT_TRUE(wrapper->HasTrustedRateController());
}
TEST(SoftwareFallbackEncoderTest, BothRateControllersTrusted) {
auto* sw_encoder = new testing::NiceMock<MockVideoEncoder>();
auto* hw_encoder = new testing::NiceMock<MockVideoEncoder>();
EXPECT_CALL(*sw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_CALL(*hw_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
std::unique_ptr<VideoEncoder> wrapper =
CreateVideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<VideoEncoder>(sw_encoder),
std::unique_ptr<VideoEncoder>(hw_encoder));
EXPECT_TRUE(wrapper->HasTrustedRateController());
}
} // namespace webrtc

View File

@ -101,8 +101,4 @@ bool VideoEncoder::SupportsNativeHandle() const {
const char* VideoEncoder::ImplementationName() const {
return "unknown";
}
bool VideoEncoder::HasTrustedRateController() const {
return false;
}
} // namespace webrtc

View File

@ -202,21 +202,6 @@ class VideoEncoder {
virtual bool SupportsNativeHandle() const;
virtual const char* ImplementationName() const;
// If this method returns true, the encoder rate controller must perform well
// even in difficult situations, and produce close to the specified target
// bitrate seen over a reasonable time window, drop frames if necessary in
// order to keep the rate correct, and react quickly to changing bitrate
// targets.
// If this method returns true, we disable the frame dropper in the media
// optimization module and rely entirely on the encoder to produce media at a
// bitrate that closely matches the target. Any overshooting may result in
// delay buildup.
// If this method returns false (default behavior), the media opt frame
// dropper will drop input frames if it suspect encoder misbehavior.
// Misbehavior is common, especially in hardware codecs. Disable media opt at
// your own risk.
virtual bool HasTrustedRateController() const;
};
} // namespace webrtc
#endif // API_VIDEO_CODECS_VIDEO_ENCODER_H_

View File

@ -93,7 +93,6 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder {
bool SupportsNativeHandle() const override;
ScalingSettings GetScalingSettings() const override;
const char* ImplementationName() const override;
bool HasTrustedRateController() const override;
private:
bool InitFallbackEncoder();
@ -143,8 +142,6 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder {
bool forced_fallback_possible_;
ForcedFallbackParams forced_fallback_;
const bool trust_rate_controller_;
};
VideoEncoderSoftwareFallbackWrapper::VideoEncoderSoftwareFallbackWrapper(
@ -161,11 +158,7 @@ VideoEncoderSoftwareFallbackWrapper::VideoEncoderSoftwareFallbackWrapper(
encoder_(std::move(hw_encoder)),
fallback_encoder_(std::move(sw_encoder)),
callback_(nullptr),
forced_fallback_possible_(EnableForcedFallback()),
trust_rate_controller_(
(encoder_ ? encoder_->HasTrustedRateController() : true) &&
(fallback_encoder_ ? fallback_encoder_->HasTrustedRateController()
: true)) {
forced_fallback_possible_(EnableForcedFallback()) {
if (forced_fallback_possible_) {
GetForcedFallbackParamsFromFieldTrialGroup(
&forced_fallback_.min_pixels_, &forced_fallback_.max_pixels_,
@ -326,10 +319,6 @@ const char* VideoEncoderSoftwareFallbackWrapper::ImplementationName() const {
: encoder_->ImplementationName();
}
bool VideoEncoderSoftwareFallbackWrapper::HasTrustedRateController() const {
return trust_rate_controller_;
}
bool VideoEncoderSoftwareFallbackWrapper::IsForcedFallbackActive() const {
return (forced_fallback_possible_ && use_fallback_encoder_ &&
forced_fallback_.active_);