Remove extra_options from VideoCodec.

Constructing default options is racy when initializing multiple VP8
encoders in parallel. This is only used for VP8 temporal layers. Adding
TemporalLayerFactory to VP8 codec specifics instead of generic options.

Removes the last webrtc::Config uses/includes from video code.

Also removes VideoCodec equality operators which are no longer in use.

BUG=webrtc:5410
R=stefan@webrtc.org
TBR=mflodman@webrtc.org

Review URL: https://codereview.webrtc.org/1606613003 .

Cr-Commit-Position: refs/heads/master@{#11307}
This commit is contained in:
Peter Boström
2016-01-19 16:26:16 +01:00
parent ee5a309f12
commit 7b971e728b
19 changed files with 38 additions and 348 deletions

View File

@ -283,7 +283,7 @@ void DefaultTemporalLayers::PopulateCodecSpecific(
}
}
TemporalLayers* TemporalLayers::Factory::Create(
TemporalLayers* TemporalLayersFactory::Create(
int temporal_layers,
uint8_t initial_tl0_pic_idx) const {
return new DefaultTemporalLayers(temporal_layers, initial_tl0_pic_idx);

View File

@ -16,7 +16,6 @@
#include "libyuv/scale.h" // NOLINT
#include "webrtc/base/checks.h"
#include "webrtc/common.h"
#include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h"
namespace {
@ -95,7 +94,7 @@ int VerifyCodec(const webrtc::VideoCodec* inst) {
// TL1 FrameDropper's max time to drop frames.
const float kTl1MaxTimeToDropFrames = 20.0f;
struct ScreenshareTemporalLayersFactory : webrtc::TemporalLayers::Factory {
struct ScreenshareTemporalLayersFactory : webrtc::TemporalLayersFactory {
ScreenshareTemporalLayersFactory()
: tl1_frame_dropper_(kTl1MaxTimeToDropFrames) {}
@ -189,10 +188,8 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst,
// Special mode when screensharing on a single stream.
if (number_of_streams == 1 && inst->mode == kScreensharing) {
screensharing_extra_options_.reset(new Config());
screensharing_extra_options_->Set<TemporalLayers::Factory>(
new ScreenshareTemporalLayersFactory());
codec_.extra_options = screensharing_extra_options_.get();
screensharing_tl_factory_.reset(new ScreenshareTemporalLayersFactory());
codec_.codecSpecific.VP8.tl_factory = screensharing_tl_factory_.get();
}
// Create |number_of_streams| of encoder instances and init them.

View File

@ -110,7 +110,7 @@ class SimulcastEncoderAdapter : public VP8Encoder {
bool Initialized() const;
rtc::scoped_ptr<VideoEncoderFactory> factory_;
rtc::scoped_ptr<Config> screensharing_extra_options_;
rtc::scoped_ptr<TemporalLayersFactory> screensharing_tl_factory_;
VideoCodec codec_;
std::vector<StreamInfo> streaminfos_;
EncodedImageCallback* encoded_complete_callback_;

View File

@ -278,10 +278,11 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
target.codecSpecific.VP8.frameDroppingOn);
EXPECT_EQ(ref.codecSpecific.VP8.keyFrameInterval,
target.codecSpecific.VP8.keyFrameInterval);
EXPECT_EQ(ref.codecSpecific.VP8.tl_factory,
target.codecSpecific.VP8.tl_factory);
EXPECT_EQ(ref.qpMax, target.qpMax);
EXPECT_EQ(0, target.numberOfSimulcastStreams);
EXPECT_EQ(ref.mode, target.mode);
EXPECT_EQ(ref.extra_options, target.extra_options);
// No need to compare simulcastStream as numberOfSimulcastStreams should
// always be 0.

View File

@ -16,7 +16,6 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
@ -147,19 +146,16 @@ class SkipEncodingUnusedStreamsTest {
std::vector<unsigned int> RunTest(VP8Encoder* encoder,
VideoCodec* settings,
uint32_t target_bitrate) {
Config options;
SpyingTemporalLayersFactory* spy_factory =
new SpyingTemporalLayersFactory();
options.Set<TemporalLayers::Factory>(spy_factory);
settings->extra_options = &options;
SpyingTemporalLayersFactory spy_factory;
settings->codecSpecific.VP8.tl_factory = &spy_factory;
EXPECT_EQ(0, encoder->InitEncode(settings, 1, 1200));
encoder->SetRates(target_bitrate, 30);
std::vector<unsigned int> configured_bitrates;
for (std::vector<TemporalLayers*>::const_iterator it =
spy_factory->spying_layers_.begin();
it != spy_factory->spying_layers_.end(); ++it) {
spy_factory.spying_layers_.begin();
it != spy_factory.spying_layers_.end(); ++it) {
configured_bitrates.push_back(
static_cast<SpyingTemporalLayers*>(*it)->configured_bitrate_);
}
@ -206,13 +202,13 @@ class SkipEncodingUnusedStreamsTest {
TemporalLayers* layers_;
};
class SpyingTemporalLayersFactory : public TemporalLayers::Factory {
class SpyingTemporalLayersFactory : public TemporalLayersFactory {
public:
virtual ~SpyingTemporalLayersFactory() {}
TemporalLayers* Create(int temporal_layers,
uint8_t initial_tl0_pic_idx) const override {
SpyingTemporalLayers* layers =
new SpyingTemporalLayers(TemporalLayers::Factory::Create(
new SpyingTemporalLayers(TemporalLayersFactory::Create(
temporal_layers, initial_tl0_pic_idx));
spying_layers_.push_back(layers);
return layers;

View File

@ -14,7 +14,6 @@
#include "vpx/vpx_encoder.h"
#include "webrtc/common.h"
#include "webrtc/common_video/include/video_image.h"
#include "webrtc/typedefs.h"
@ -26,15 +25,6 @@ class TemporalLayers {
public:
// Factory for TemporalLayer strategy. Default behaviour is a fixed pattern
// of temporal layers. See default_temporal_layers.cc
struct Factory {
Factory() {}
virtual ~Factory() {}
virtual TemporalLayers* Create(int temporal_layers,
uint8_t initial_tl0_pic_idx) const;
static const ConfigOptionID identifier =
ConfigOptionID::kTemporalLayersFactory;
};
virtual ~TemporalLayers() {}
// Returns the recommended VP8 encode flags needed. May refresh the decoder
@ -57,13 +47,21 @@ class TemporalLayers {
virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0;
};
class TemporalLayersFactory {
public:
virtual ~TemporalLayersFactory() {}
virtual TemporalLayers* Create(int temporal_layers,
uint8_t initial_tl0_pic_idx) const;
};
// Factory for a temporal layers strategy that adaptively changes the number of
// layers based on input framerate so that the base layer has an acceptable
// framerate. See realtime_temporal_layers.cc
struct RealTimeTemporalLayersFactory : TemporalLayers::Factory {
virtual ~RealTimeTemporalLayersFactory() {}
virtual TemporalLayers* Create(int num_temporal_layers,
uint8_t initial_tl0_pic_idx) const;
class RealTimeTemporalLayersFactory : public TemporalLayersFactory {
public:
~RealTimeTemporalLayersFactory() override {}
TemporalLayers* Create(int num_temporal_layers,
uint8_t initial_tl0_pic_idx) const override;
};
} // namespace webrtc

View File

@ -21,7 +21,6 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/trace_event.h"
#include "webrtc/common.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/include/module_common_types.h"
@ -314,10 +313,10 @@ void VP8EncoderImpl::SetStreamState(bool send_stream,
void VP8EncoderImpl::SetupTemporalLayers(int num_streams,
int num_temporal_layers,
const VideoCodec& codec) {
const Config default_options;
const TemporalLayers::Factory& tl_factory =
(codec.extra_options ? codec.extra_options : &default_options)
->Get<TemporalLayers::Factory>();
TemporalLayersFactory default_factory;
const TemporalLayersFactory* tl_factory = codec.codecSpecific.VP8.tl_factory;
if (!tl_factory)
tl_factory = &default_factory;
if (num_streams == 1) {
if (codec.mode == kScreensharing) {
// Special mode when screensharing on a single stream.
@ -325,7 +324,7 @@ void VP8EncoderImpl::SetupTemporalLayers(int num_streams,
new ScreenshareLayers(num_temporal_layers, rand()));
} else {
temporal_layers_.push_back(
tl_factory.Create(num_temporal_layers, rand()));
tl_factory->Create(num_temporal_layers, rand()));
}
} else {
for (int i = 0; i < num_streams; ++i) {
@ -333,7 +332,7 @@ void VP8EncoderImpl::SetupTemporalLayers(int num_streams,
int layers = codec.simulcastStream[i].numberOfTemporalLayers;
if (layers < 1)
layers = 1;
temporal_layers_.push_back(tl_factory.Create(layers, rand()));
temporal_layers_.push_back(tl_factory->Create(layers, rand()));
}
}
}

View File

@ -25,7 +25,6 @@
#include "webrtc/base/keep_ref_until_done.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/trace_event.h"
#include "webrtc/common.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h"