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}
This commit is contained in:
@ -51,6 +51,7 @@ 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,
|
||||
@ -81,6 +82,8 @@ class MultiplexEncoderAdapter : public VideoEncoder {
|
||||
|
||||
const bool supports_augmented_data_;
|
||||
int augmenting_data_size_ = 0;
|
||||
|
||||
bool has_trusted_rate_controllers_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -53,7 +53,8 @@ MultiplexEncoderAdapter::MultiplexEncoderAdapter(
|
||||
: factory_(factory),
|
||||
associated_format_(associated_format),
|
||||
encoded_complete_callback_(nullptr),
|
||||
supports_augmented_data_(supports_augmented_data) {}
|
||||
supports_augmented_data_(supports_augmented_data),
|
||||
has_trusted_rate_controllers_(false) {}
|
||||
|
||||
MultiplexEncoderAdapter::~MultiplexEncoderAdapter() {
|
||||
Release();
|
||||
@ -92,6 +93,7 @@ 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_);
|
||||
@ -101,6 +103,7 @@ 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());
|
||||
@ -242,6 +245,10 @@ 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,
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#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)
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
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].
|
||||
@ -158,6 +160,8 @@ 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),
|
||||
@ -282,6 +286,10 @@ 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.
|
||||
|
||||
@ -56,6 +56,8 @@ class LibvpxVp8Encoder : public VideoEncoder {
|
||||
|
||||
const char* ImplementationName() const override;
|
||||
|
||||
bool HasTrustedRateController() const override;
|
||||
|
||||
static vpx_enc_frame_flags_t EncodeFlags(
|
||||
const TemporalLayers::FrameConfig& references);
|
||||
|
||||
@ -88,6 +90,7 @@ 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_;
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#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"
|
||||
|
||||
Reference in New Issue
Block a user