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

This reverts commit 3e335d1423.

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_);

View file

@ -40,7 +40,6 @@ class ScopedVideoEncoder : public webrtc::VideoEncoder {
ScalingSettings GetScalingSettings() const override;
bool SupportsNativeHandle() const override;
const char* ImplementationName() const override;
bool HasTrustedRateController() const override;
~ScopedVideoEncoder() override;
@ -104,10 +103,6 @@ const char* ScopedVideoEncoder::ImplementationName() const {
return encoder_->ImplementationName();
}
bool ScopedVideoEncoder::HasTrustedRateController() const {
return encoder_->HasTrustedRateController();
}
ScopedVideoEncoder::~ScopedVideoEncoder() {
factory_->DestroyVideoEncoder(encoder_);
}

View file

@ -128,8 +128,7 @@ SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory,
video_format_(format),
encoded_complete_callback_(nullptr),
implementation_name_("SimulcastEncoderAdapter"),
experimental_boosted_screenshare_qp_(GetScreenshareBoostedQpValue()),
trusted_rate_controller_(false) {
experimental_boosted_screenshare_qp_(GetScreenshareBoostedQpValue()) {
RTC_DCHECK(factory_);
// The adapter is typically created on the worker thread, but operated on
@ -205,7 +204,6 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst,
}
std::string implementation_name;
trusted_rate_controller_ = true;
// Create |number_of_streams| of encoder instances and init them.
for (int i = 0; i < number_of_streams; ++i) {
VideoCodec stream_codec;
@ -252,7 +250,6 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst,
std::unique_ptr<EncodedImageCallback> callback(
new AdapterEncodedImageCallback(this, i));
encoder->RegisterEncodeCompleteCallback(callback.get());
trusted_rate_controller_ &= encoder->HasTrustedRateController();
streaminfos_.emplace_back(std::move(encoder), std::move(callback),
stream_codec.width, stream_codec.height,
send_stream);
@ -548,9 +545,4 @@ const char* SimulcastEncoderAdapter::ImplementationName() const {
return implementation_name_.c_str();
}
bool SimulcastEncoderAdapter::HasTrustedRateController() const {
RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_);
return trusted_rate_controller_;
}
} // namespace webrtc

View file

@ -65,7 +65,6 @@ class SimulcastEncoderAdapter : public VideoEncoder {
bool SupportsNativeHandle() const override;
const char* ImplementationName() const override;
bool HasTrustedRateController() const override;
private:
struct StreamInfo {
@ -115,7 +114,6 @@ class SimulcastEncoderAdapter : public VideoEncoder {
std::stack<std::unique_ptr<VideoEncoder>> stored_encoders_;
const absl::optional<unsigned int> experimental_boosted_screenshare_qp_;
bool trusted_rate_controller_;
};
} // namespace webrtc

View file

@ -242,8 +242,6 @@ class MockVideoEncoder : public VideoEncoder {
MOCK_CONST_METHOD0(ImplementationName, const char*());
MOCK_CONST_METHOD0(HasTrustedRateController, bool(void));
private:
MockVideoEncoderFactory* const factory_;
bool supports_native_handle_ = false;
@ -956,58 +954,5 @@ TEST_F(TestSimulcastEncoderAdapterFake, ActivatesCorrectStreamsInInitEncode) {
frame_types.resize(3, kVideoFrameKey);
EXPECT_EQ(0, adapter_->Encode(input_frame, nullptr, &frame_types));
}
TEST_F(TestSimulcastEncoderAdapterFake, TrustedRateControl) {
// Set up common settings for three streams.
SimulcastTestFixtureImpl::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile),
kVideoCodecVP8);
rate_allocator_.reset(new SimulcastRateAllocator(codec_));
adapter_->RegisterEncodeCompleteCallback(this);
// Only enough start bitrate for the lowest stream.
ASSERT_EQ(3u, codec_.numberOfSimulcastStreams);
codec_.startBitrate = codec_.simulcastStream[0].targetBitrate +
codec_.simulcastStream[1].minBitrate - 1;
// Input data.
rtc::scoped_refptr<VideoFrameBuffer> buffer(I420Buffer::Create(1280, 720));
VideoFrame input_frame(buffer, 100, 1000, kVideoRotation_180);
// No encoder trusted, so simulcast adapter should not be either.
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
EXPECT_FALSE(adapter_->HasTrustedRateController());
// Encode with three streams.
std::vector<MockVideoEncoder*> original_encoders =
helper_->factory()->encoders();
{
// All encoders are trusted, so simulcast adapter should be too.
EXPECT_CALL(*original_encoders[0], HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_CALL(*original_encoders[1], HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_CALL(*original_encoders[2], HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
EXPECT_TRUE(adapter_->HasTrustedRateController());
}
{
// One encoder not trusted, so simulcast adapter should not be either.
EXPECT_CALL(*original_encoders[0], HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_CALL(*original_encoders[1], HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_CALL(*original_encoders[2], HasTrustedRateController())
.WillRepeatedly(Return(false));
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
EXPECT_FALSE(adapter_->HasTrustedRateController());
}
}
} // namespace test
} // namespace webrtc

View file

@ -81,8 +81,4 @@ const char* VP8EncoderSimulcastProxy::ImplementationName() const {
return encoder_->ImplementationName();
}
bool VP8EncoderSimulcastProxy::HasTrustedRateController() const {
return encoder_->HasTrustedRateController();
}
} // namespace webrtc

View file

@ -50,7 +50,6 @@ class VP8EncoderSimulcastProxy : public VideoEncoder {
bool SupportsNativeHandle() const override;
const char* ImplementationName() const override;
bool HasTrustedRateController() const override;
private:
VideoEncoderFactory* const factory_;

View file

@ -55,8 +55,6 @@ class MockEncoder : public VideoEncoder {
MOCK_METHOD2(SetChannelParameters, int32_t(uint32_t packetLoss, int64_t rtt));
MOCK_CONST_METHOD0(ImplementationName, const char*());
MOCK_CONST_METHOD0(HasTrustedRateController, bool(void));
};
TEST(VP8EncoderSimulcastProxy, ChoosesCorrectImplementation) {
@ -155,29 +153,5 @@ TEST(VP8EncoderSimulcastProxy, ChoosesCorrectImplementation) {
simulcast_disabled_proxy.Release();
}
TEST(VP8EncoderSimulcastProxy, ForwardsTrustedSetting) {
NiceMock<MockEncoder>* mock_encoder = new NiceMock<MockEncoder>();
NiceMock<MockVideoEncoderFactory> simulcast_factory;
EXPECT_CALL(*mock_encoder, InitEncode(_, _, _))
.WillOnce(Return(WEBRTC_VIDEO_CODEC_OK));
EXPECT_CALL(simulcast_factory, CreateVideoEncoderProxy(_))
.Times(1)
.WillOnce(Return(mock_encoder));
VP8EncoderSimulcastProxy simulcast_enabled_proxy(&simulcast_factory,
SdpVideoFormat("VP8"));
VideoCodec codec_settings;
webrtc::test::CodecSettings(kVideoCodecVP8, &codec_settings);
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
simulcast_enabled_proxy.InitEncode(&codec_settings, 4, 1200));
EXPECT_CALL(*mock_encoder, HasTrustedRateController())
.WillRepeatedly(Return(true));
EXPECT_TRUE(simulcast_enabled_proxy.HasTrustedRateController());
}
} // namespace testing
} // namespace webrtc

View file

@ -577,7 +577,6 @@ if (rtc_include_tests) {
":video_coding",
":video_coding_utility",
"../../:webrtc_common",
"../../api:mock_video_encoder",
"../../api:simulcast_test_fixture_api",
"../../api/video:encoded_image",
"../../api/video:video_frame",
@ -736,7 +735,6 @@ if (rtc_include_tests) {
"../..:webrtc_common",
"../../api:create_videocodec_test_fixture_api",
"../../api:mock_video_codec_factory",
"../../api:mock_video_encoder",
"../../api:videocodec_test_fixture_api",
"../../api/video:video_frame",
"../../api/video:video_frame_i420",
@ -855,7 +853,6 @@ if (rtc_include_tests) {
"..:module_api",
"../..:webrtc_common",
"../../api:create_simulcast_test_fixture_api",
"../../api:mock_video_encoder",
"../../api:simulcast_test_fixture_api",
"../../api:videocodec_test_fixture_api",
"../../api/video:video_bitrate_allocator",

View file

@ -51,7 +51,6 @@ class MultiplexEncoderAdapter : public VideoEncoder {
uint32_t new_framerate) override;
int Release() override;
const char* ImplementationName() const override;
bool HasTrustedRateController() const override;
EncodedImageCallback::Result OnEncodedImage(
AlphaCodecStream stream_idx,
@ -82,8 +81,6 @@ class MultiplexEncoderAdapter : public VideoEncoder {
const bool supports_augmented_data_;
int augmenting_data_size_ = 0;
bool has_trusted_rate_controllers_;
};
} // namespace webrtc

View file

@ -53,8 +53,7 @@ MultiplexEncoderAdapter::MultiplexEncoderAdapter(
: factory_(factory),
associated_format_(associated_format),
encoded_complete_callback_(nullptr),
supports_augmented_data_(supports_augmented_data),
has_trusted_rate_controllers_(false) {}
supports_augmented_data_(supports_augmented_data) {}
MultiplexEncoderAdapter::~MultiplexEncoderAdapter() {
Release();
@ -93,7 +92,6 @@ int MultiplexEncoderAdapter::InitEncode(const VideoCodec* inst,
break;
}
has_trusted_rate_controllers_ = true;
for (size_t i = 0; i < kAlphaCodecStreams; ++i) {
std::unique_ptr<VideoEncoder> encoder =
factory_->CreateVideoEncoder(associated_format_);
@ -103,7 +101,6 @@ int MultiplexEncoderAdapter::InitEncode(const VideoCodec* inst,
RTC_LOG(LS_ERROR) << "Failed to create multiplex codec index " << i;
return rv;
}
has_trusted_rate_controllers_ &= encoder->HasTrustedRateController();
adapter_callbacks_.emplace_back(new AdapterEncodedImageCallback(
this, static_cast<AlphaCodecStream>(i)));
encoder->RegisterEncodeCompleteCallback(adapter_callbacks_.back().get());
@ -245,10 +242,6 @@ const char* MultiplexEncoderAdapter::ImplementationName() const {
return "MultiplexEncoderAdapter";
}
bool MultiplexEncoderAdapter::HasTrustedRateController() const {
return has_trusted_rate_controllers_;
}
EncodedImageCallback::Result MultiplexEncoderAdapter::OnEncodedImage(
AlphaCodecStream stream_idx,
const EncodedImage& encodedImage,

View file

@ -11,7 +11,6 @@
#include <memory>
#include "absl/memory/memory.h"
#include "api/test/mock_video_encoder.h"
#include "api/test/videocodec_test_fixture.h"
#include "api/video/i420_buffer.h"
#include "common_types.h" // NOLINT(build/include)

View file

@ -28,8 +28,6 @@
namespace webrtc {
namespace {
const char kVp8GfBoostFieldTrial[] = "WebRTC-VP8-GfBoost";
const char kVp8TrustedRateControllerFieldTrial[] =
"WebRTC-Vp8TrustedRateController";
// QP is obtained from VP8-bitstream for HW, so the QP corresponds to the
// bitstream range of [0, 127] and not the user-level range of [0,63].
@ -160,8 +158,6 @@ LibvpxVp8Encoder::LibvpxVp8Encoder()
LibvpxVp8Encoder::LibvpxVp8Encoder(std::unique_ptr<LibvpxInterface> interface)
: libvpx_(std::move(interface)),
use_gf_boost_(webrtc::field_trial::IsEnabled(kVp8GfBoostFieldTrial)),
trusted_rate_controller_(
webrtc::field_trial::IsEnabled(kVp8TrustedRateControllerFieldTrial)),
encoded_complete_callback_(nullptr),
inited_(false),
timestamp_(0),
@ -286,10 +282,6 @@ const char* LibvpxVp8Encoder::ImplementationName() const {
return "libvpx";
}
bool LibvpxVp8Encoder::HasTrustedRateController() const {
return trusted_rate_controller_;
}
void LibvpxVp8Encoder::SetStreamState(bool send_stream, int stream_idx) {
if (send_stream && !send_stream_[stream_idx]) {
// Need a key frame if we have not sent this stream before.

View file

@ -56,8 +56,6 @@ class LibvpxVp8Encoder : public VideoEncoder {
const char* ImplementationName() const override;
bool HasTrustedRateController() const override;
static vpx_enc_frame_flags_t EncodeFlags(
const TemporalLayers::FrameConfig& references);
@ -90,7 +88,6 @@ class LibvpxVp8Encoder : public VideoEncoder {
const std::unique_ptr<LibvpxInterface> libvpx_;
const bool use_gf_boost_;
const bool trusted_rate_controller_;
EncodedImageCallback* encoded_complete_callback_;
VideoCodec codec_;

View file

@ -12,7 +12,6 @@
#include <memory>
#include "api/test/mock_video_encoder.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_coding/codecs/test/video_codec_unittest.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"

View file

@ -169,11 +169,6 @@ bool VCMGenericEncoder::SupportsNativeHandle() const {
return encoder_->SupportsNativeHandle();
}
bool VCMGenericEncoder::HasTrustedRateController() const {
RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
return encoder_->HasTrustedRateController();
}
VCMEncodedFrameCallback::VCMEncodedFrameCallback(
EncodedImageCallback* post_encode_callback,
media_optimization::MediaOptimization* media_opt)

View file

@ -147,7 +147,6 @@ class VCMGenericEncoder {
int32_t RequestFrame(const std::vector<FrameType>& frame_types);
bool InternalSource() const;
bool SupportsNativeHandle() const;
bool HasTrustedRateController() const;
private:
rtc::RaceChecker race_checker_;

View file

@ -19,6 +19,36 @@
namespace webrtc {
class MockEncodedImageCallback : public EncodedImageCallback {
public:
MOCK_METHOD3(OnEncodedImage,
Result(const EncodedImage& encodedImage,
const CodecSpecificInfo* codecSpecificInfo,
const RTPFragmentationHeader* fragmentation));
};
class MockVideoEncoder : public VideoEncoder {
public:
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));
};
class MockDecodedImageCallback : public DecodedImageCallback {
public:
MOCK_METHOD1(Decoded, int32_t(VideoFrame& decodedImage)); // NOLINT

View file

@ -14,15 +14,14 @@
#include <memory>
#include <vector>
#include "api/test/mock_video_encoder.h"
#include "api/test/simulcast_test_fixture.h"
#include "api/video/i420_buffer.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/video_coding/include/mock/mock_video_codec_interface.h"
#include "modules/video_coding/utility/simulcast_rate_allocator.h"
#include "modules/video_coding/include/mock/mock_video_codec_interface.h"
namespace webrtc {
namespace test {

View file

@ -96,15 +96,10 @@ int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec,
numLayers = 1;
}
// Disable frame dropper if either:
// * We have screensharing with layers.
// * "WebRTC-FrameDropper" field trial is "Disabled".
// * Encoder has a trusted rate controller.
// If we have screensharing and we have layers, we disable frame dropper.
const bool disable_frame_dropper =
field_trial::IsDisabled(kFrameDropperFieldTrial) ||
(numLayers > 1 && sendCodec->mode == VideoCodecMode::kScreensharing) ||
_encoder->HasTrustedRateController();
(numLayers > 1 && sendCodec->mode == VideoCodecMode::kScreensharing);
if (disable_frame_dropper) {
_mediaOpt.EnableFrameDropper(false);
} else if (frame_dropper_enabled_) {

View file

@ -11,7 +11,6 @@
#include <memory>
#include <vector>
#include "api/test/mock_video_encoder.h"
#include "api/video/i420_buffer.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "modules/video_coding/codecs/vp8/include/vp8_temporal_layers.h"
@ -393,17 +392,6 @@ TEST_F(TestVideoSenderWithMockEncoder,
AddFrame();
}
TEST_F(TestVideoSenderWithMockEncoder, ChecksTrustedRateController) {
// Checks that encoder is asked if rate controller is trusted.
EXPECT_CALL(encoder_, HasTrustedRateController())
.Times(1)
.WillOnce(Return(true));
VideoCodec codec;
webrtc::test::CodecSettings(kVideoCodecVP8, &codec);
EXPECT_EQ(0, sender_->RegisterSendCodec(&codec, 1, 1200));
}
class TestVideoSenderWithVp8 : public TestVideoSender {
public:
TestVideoSenderWithVp8()

View file

@ -49,8 +49,6 @@ namespace {
static const int kFullStackTestDurationSecs = 45;
const char kPacerPushBackExperiment[] =
"WebRTC-PacerPushbackExperiment/Enabled/";
const char kVp8TrustedRateControllerFieldTrial[] =
"WebRTC-Vp8TrustedRateController/Enabled/";
struct ParamsWithLogging : public VideoQualityTest::Params {
public:
@ -234,25 +232,6 @@ TEST_P(GenericDescriptorTest, ForemanCif30kbpsWithoutPacketLoss) {
fixture->RunWithAnalyzer(foreman_cif);
}
// TODO(webrtc:9722): Remove when experiment is cleaned up.
TEST_P(GenericDescriptorTest,
ForemanCif30kbpsWithoutPacketLossTrustedRateControl) {
test::ScopedFieldTrials override_field_trials(
AppendFieldTrials(kVp8TrustedRateControllerFieldTrial));
auto fixture = CreateVideoQualityTestFixture();
ParamsWithLogging foreman_cif;
foreman_cif.call.send_side_bwe = true;
foreman_cif.video[0] = {true, 352, 288, 10, 30000, 30000, 30000,
false, "VP8", 1, 0, 0, false, false,
false, "foreman_cif"};
foreman_cif.analyzer = {
GetTestName("foreman_cif_30kbps_net_delay_0_0_plr_0_trusted_rate_ctrl"),
0.0, 0.0, kFullStackTestDurationSecs};
foreman_cif.call.generic_descriptor = GenericDescriptorEnabled();
fixture->RunWithAnalyzer(foreman_cif);
}
// Link capacity below default start rate. Automatic down scaling enabled.
TEST(FullStackTest, ForemanCifLink150kbpsWithoutPacketLoss) {
auto fixture = CreateVideoQualityTestFixture();
@ -384,9 +363,9 @@ TEST_P(GenericDescriptorTest, ForemanCifPlr5H264) {
}
TEST(FullStackTest, ForemanCifPlr5H264SpsPpsIdrIsKeyframe) {
auto fixture = CreateVideoQualityTestFixture();
test::ScopedFieldTrials override_field_trials(
AppendFieldTrials("WebRTC-SpsPpsIdrIsH264Keyframe/Enabled/"));
auto fixture = CreateVideoQualityTestFixture();
ParamsWithLogging foreman_cif;
foreman_cif.call.send_side_bwe = true;
@ -540,21 +519,16 @@ TEST(FullStackTest, ConferenceMotionHd2000kbps100msLimitedQueue) {
fixture->RunWithAnalyzer(conf_motion_hd);
}
// TODO(webrtc:9722): Remove when experiment is cleaned up.
TEST(FullStackTest, ConferenceMotionHd1TLModerateLimitsWhitelistVp8) {
test::ScopedFieldTrials override_field_trials(
AppendFieldTrials(kVp8TrustedRateControllerFieldTrial));
TEST(FullStackTest, ConferenceMotionHd1TLModerateLimits) {
auto fixture = CreateVideoQualityTestFixture();
ParamsWithLogging conf_motion_hd;
conf_motion_hd.call.send_side_bwe = true;
conf_motion_hd.video[0] = {
true, 1280, 720, 50, 30000,
3000000, 3000000, false, "VP8", 1,
-1, 0, false, false, false, "ConferenceMotion_1280_720_50"};
conf_motion_hd.analyzer = {
"conference_motion_hd_1tl_moderate_limits_trusted_rate_ctrl", 0.0, 0.0,
kFullStackTestDurationSecs};
conf_motion_hd.analyzer = {"conference_motion_hd_1tl_moderate_limits", 0.0,
0.0, kFullStackTestDurationSecs};
conf_motion_hd.config->queue_length_packets = 50;
conf_motion_hd.config->loss_percent = 3;
conf_motion_hd.config->queue_delay_ms = 100;
@ -616,9 +590,9 @@ TEST(FullStackTest, ConferenceMotionHd4TLModerateLimits) {
}
TEST(FullStackTest, ConferenceMotionHd3TLModerateLimitsAltTLPattern) {
auto fixture = CreateVideoQualityTestFixture();
test::ScopedFieldTrials field_trial(
AppendFieldTrials("WebRTC-UseShortVP8TL3Pattern/Enabled/"));
auto fixture = CreateVideoQualityTestFixture();
ParamsWithLogging conf_motion_hd;
conf_motion_hd.call.send_side_bwe = true;
conf_motion_hd.video[0] = {
@ -672,9 +646,8 @@ const char kScreenshareSimulcastExperiment[] =
"WebRTC-SimulcastScreenshare/Enabled/";
TEST(FullStackTest, ScreenshareSlidesVP8_3TL_Simulcast) {
test::ScopedFieldTrials field_trial(
AppendFieldTrials(kScreenshareSimulcastExperiment));
auto fixture = CreateVideoQualityTestFixture();
test::ScopedFieldTrials field_trial(kScreenshareSimulcastExperiment);
ParamsWithLogging screenshare;
screenshare.call.send_side_bwe = true;
screenshare.screenshare[0] = {true, false, 10};

View file

@ -177,9 +177,6 @@ class QualityTestVideoEncoder : public VideoEncoder,
const char* ImplementationName() const override {
return encoder_->ImplementationName();
}
bool HasTrustedRateController() const override {
return encoder_->HasTrustedRateController();
}
private:
// Implement EncodedImageCallback

View file

@ -363,8 +363,6 @@ VideoStreamEncoder::VideoStreamEncoder(
max_framerate_(-1),
pending_encoder_reconfiguration_(false),
pending_encoder_creation_(false),
crop_width_(0),
crop_height_(0),
encoder_start_bitrate_bps_(0),
max_data_payload_length_(0),
last_observed_bitrate_bps_(0),
@ -378,7 +376,6 @@ VideoStreamEncoder::VideoStreamEncoder(
last_frame_log_ms_(clock_->TimeInMilliseconds()),
captured_frame_count_(0),
dropped_frame_count_(0),
pending_frame_post_time_us_(0),
bitrate_observer_(nullptr),
encoder_queue_("EncoderQueue") {
RTC_DCHECK(encoder_stats_observer);