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

@ -27,7 +27,6 @@
#include "webrtc/call/bitrate_allocator.h" #include "webrtc/call/bitrate_allocator.h"
#include "webrtc/call/congestion_controller.h" #include "webrtc/call/congestion_controller.h"
#include "webrtc/call/rtc_event_log.h" #include "webrtc/call/rtc_event_log.h"
#include "webrtc/common.h"
#include "webrtc/config.h" #include "webrtc/config.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/modules/pacing/paced_sender.h" #include "webrtc/modules/pacing/paced_sender.h"

View File

@ -18,7 +18,6 @@
#include "webrtc/base/thread_annotations.h" #include "webrtc/base/thread_annotations.h"
#include "webrtc/call.h" #include "webrtc/call.h"
#include "webrtc/call/transport_adapter.h" #include "webrtc/call/transport_adapter.h"
#include "webrtc/common.h"
#include "webrtc/config.h" #include "webrtc/config.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"

View File

@ -13,7 +13,6 @@
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
#include "webrtc/base/logging.h" #include "webrtc/base/logging.h"
#include "webrtc/base/thread_annotations.h" #include "webrtc/base/thread_annotations.h"
#include "webrtc/common.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/modules/pacing/paced_sender.h" #include "webrtc/modules/pacing/paced_sender.h"
#include "webrtc/modules/pacing/packet_router.h" #include "webrtc/modules/pacing/packet_router.h"

View File

@ -569,6 +569,7 @@ enum VP8ResilienceMode {
// within a frame. // within a frame.
}; };
class TemporalLayersFactory;
// VP8 specific // VP8 specific
struct VideoCodecVP8 { struct VideoCodecVP8 {
bool pictureLossIndicationOn; bool pictureLossIndicationOn;
@ -581,23 +582,7 @@ struct VideoCodecVP8 {
bool automaticResizeOn; bool automaticResizeOn;
bool frameDroppingOn; bool frameDroppingOn;
int keyFrameInterval; int keyFrameInterval;
const TemporalLayersFactory* tl_factory;
bool operator==(const VideoCodecVP8& other) const {
return pictureLossIndicationOn == other.pictureLossIndicationOn &&
feedbackModeOn == other.feedbackModeOn &&
complexity == other.complexity &&
resilience == other.resilience &&
numberOfTemporalLayers == other.numberOfTemporalLayers &&
denoisingOn == other.denoisingOn &&
errorConcealmentOn == other.errorConcealmentOn &&
automaticResizeOn == other.automaticResizeOn &&
frameDroppingOn == other.frameDroppingOn &&
keyFrameInterval == other.keyFrameInterval;
}
bool operator!=(const VideoCodecVP8& other) const {
return !(*this == other);
}
}; };
// VP9 specific. // VP9 specific.
@ -655,20 +640,6 @@ struct SimulcastStream {
unsigned int targetBitrate; // kilobits/sec. unsigned int targetBitrate; // kilobits/sec.
unsigned int minBitrate; // kilobits/sec. unsigned int minBitrate; // kilobits/sec.
unsigned int qpMax; // minimum quality unsigned int qpMax; // minimum quality
bool operator==(const SimulcastStream& other) const {
return width == other.width &&
height == other.height &&
numberOfTemporalLayers == other.numberOfTemporalLayers &&
maxBitrate == other.maxBitrate &&
targetBitrate == other.targetBitrate &&
minBitrate == other.minBitrate &&
qpMax == other.qpMax;
}
bool operator!=(const SimulcastStream& other) const {
return !(*this == other);
}
}; };
struct SpatialLayer { struct SpatialLayer {
@ -708,37 +679,8 @@ struct VideoCodec {
VideoCodecMode mode; VideoCodecMode mode;
// When using an external encoder/decoder this allows to pass bool operator==(const VideoCodec& other) const = delete;
// extra options without requiring webrtc to be aware of them. bool operator!=(const VideoCodec& other) const = delete;
Config* extra_options;
bool operator==(const VideoCodec& other) const {
bool ret = codecType == other.codecType &&
(STR_CASE_CMP(plName, other.plName) == 0) &&
plType == other.plType &&
width == other.width &&
height == other.height &&
startBitrate == other.startBitrate &&
maxBitrate == other.maxBitrate &&
minBitrate == other.minBitrate &&
targetBitrate == other.targetBitrate &&
maxFramerate == other.maxFramerate &&
qpMax == other.qpMax &&
numberOfSimulcastStreams == other.numberOfSimulcastStreams &&
mode == other.mode;
if (ret && codecType == kVideoCodecVP8) {
ret &= (codecSpecific.VP8 == other.codecSpecific.VP8);
}
for (unsigned char i = 0; i < other.numberOfSimulcastStreams && ret; ++i) {
ret &= (simulcastStream[i] == other.simulcastStream[i]);
}
return ret;
}
bool operator!=(const VideoCodec& other) const {
return !(*this == other);
}
}; };
// Bandwidth over-use detector options. These are used to drive // Bandwidth over-use detector options. These are used to drive

View File

@ -328,8 +328,7 @@ bool VCMCodecDataBase::RequiresEncoderReset(const VideoCodec& new_send_codec) {
new_send_codec.qpMax != send_codec_.qpMax || new_send_codec.qpMax != send_codec_.qpMax ||
new_send_codec.numberOfSimulcastStreams != new_send_codec.numberOfSimulcastStreams !=
send_codec_.numberOfSimulcastStreams || send_codec_.numberOfSimulcastStreams ||
new_send_codec.mode != send_codec_.mode || new_send_codec.mode != send_codec_.mode) {
new_send_codec.extra_options != send_codec_.extra_options) {
return true; return true;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,6 @@
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "webrtc/common.h"
#include "webrtc/common_video/include/video_image.h" #include "webrtc/common_video/include/video_image.h"
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
@ -26,15 +25,6 @@ class TemporalLayers {
public: public:
// Factory for TemporalLayer strategy. Default behaviour is a fixed pattern // Factory for TemporalLayer strategy. Default behaviour is a fixed pattern
// of temporal layers. See default_temporal_layers.cc // 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() {} virtual ~TemporalLayers() {}
// Returns the recommended VP8 encode flags needed. May refresh the decoder // 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; 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 // 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 // layers based on input framerate so that the base layer has an acceptable
// framerate. See realtime_temporal_layers.cc // framerate. See realtime_temporal_layers.cc
struct RealTimeTemporalLayersFactory : TemporalLayers::Factory { class RealTimeTemporalLayersFactory : public TemporalLayersFactory {
virtual ~RealTimeTemporalLayersFactory() {} public:
virtual TemporalLayers* Create(int num_temporal_layers, ~RealTimeTemporalLayersFactory() override {}
uint8_t initial_tl0_pic_idx) const; TemporalLayers* Create(int num_temporal_layers,
uint8_t initial_tl0_pic_idx) const override;
}; };
} // namespace webrtc } // namespace webrtc

View File

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

View File

@ -12,7 +12,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/scoped_ptr.h"
#include "webrtc/common.h"
#include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h" #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
@ -461,11 +460,9 @@ TEST_F(TestVideoSenderWithVp8, MAYBE_FixedTemporalLayersStrategy) {
#define MAYBE_RealTimeTemporalLayersStrategy RealTimeTemporalLayersStrategy #define MAYBE_RealTimeTemporalLayersStrategy RealTimeTemporalLayersStrategy
#endif #endif
TEST_F(TestVideoSenderWithVp8, MAYBE_RealTimeTemporalLayersStrategy) { TEST_F(TestVideoSenderWithVp8, MAYBE_RealTimeTemporalLayersStrategy) {
Config extra_options;
extra_options.Set<TemporalLayers::Factory>(
new RealTimeTemporalLayersFactory());
VideoCodec codec = MakeVp8VideoCodec(352, 288, 3); VideoCodec codec = MakeVp8VideoCodec(352, 288, 3);
codec.extra_options = &extra_options; RealTimeTemporalLayersFactory realtime_tl_factory;
codec.codecSpecific.VP8.tl_factory = &realtime_tl_factory;
codec.minBitrate = 10; codec.minBitrate = 10;
codec.startBitrate = codec_bitrate_kbps_; codec.startBitrate = codec_bitrate_kbps_;
codec.maxBitrate = codec_bitrate_kbps_; codec.maxBitrate = codec_bitrate_kbps_;

View File

@ -16,7 +16,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/scoped_ptr.h"
#include "webrtc/common.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/modules/pacing/paced_sender.h" #include "webrtc/modules/pacing/paced_sender.h"
#include "webrtc/modules/pacing/packet_router.h" #include "webrtc/modules/pacing/packet_router.h"

View File

@ -15,7 +15,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/event.h" #include "webrtc/base/event.h"
#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/scoped_ptr.h"
#include "webrtc/common.h"
#include "webrtc/modules/utility/include/mock/mock_process_thread.h" #include "webrtc/modules/utility/include/mock/mock_process_thread.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/ref_count.h" #include "webrtc/system_wrappers/include/ref_count.h"
@ -61,7 +60,6 @@ class VideoCaptureInputTest : public ::testing::Test {
.WillRepeatedly( .WillRepeatedly(
WithArg<0>(Invoke(this, &VideoCaptureInputTest::AddOutputFrame))); WithArg<0>(Invoke(this, &VideoCaptureInputTest::AddOutputFrame)));
Config config;
input_.reset(new internal::VideoCaptureInput( input_.reset(new internal::VideoCaptureInput(
mock_process_thread_.get(), mock_frame_callback_.get(), nullptr, mock_process_thread_.get(), mock_frame_callback_.get(), nullptr,
&stats_proxy_, nullptr, nullptr)); &stats_proxy_, nullptr, nullptr));

View File

@ -17,7 +17,6 @@
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
#include "webrtc/base/logging.h" #include "webrtc/base/logging.h"
#include "webrtc/base/platform_thread.h" #include "webrtc/base/platform_thread.h"
#include "webrtc/common.h"
#include "webrtc/common_video/include/incoming_video_stream.h" #include "webrtc/common_video/include/incoming_video_stream.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/frame_callback.h" #include "webrtc/frame_callback.h"

View File

@ -1,230 +0,0 @@
/*
* Copyright (c) 2014 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 "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_types.h"
namespace webrtc {
// Builds VP8 codec with 0 simulcast streams.
void BuildVP8Codec(webrtc::VideoCodec* video_codec) {
video_codec->codecType = kVideoCodecVP8;
strncpy(video_codec->plName, "VP8", 4);
video_codec->plType = 100;
video_codec->width = 1280;
video_codec->height = 720;
video_codec->startBitrate = 1000; // kbps
video_codec->maxBitrate = 2000; // kbps
video_codec->minBitrate = 1000; // kbps
video_codec->maxFramerate = 30;
video_codec->qpMax = 50;
video_codec->numberOfSimulcastStreams = 0;
video_codec->mode = kRealtimeVideo;
// Set VP8 codec specific info.
video_codec->codecSpecific.VP8.pictureLossIndicationOn = true;
video_codec->codecSpecific.VP8.feedbackModeOn = true;
video_codec->codecSpecific.VP8.complexity = kComplexityNormal;
video_codec->codecSpecific.VP8.resilience = kResilienceOff;
video_codec->codecSpecific.VP8.numberOfTemporalLayers = 0;
video_codec->codecSpecific.VP8.denoisingOn = true;
video_codec->codecSpecific.VP8.errorConcealmentOn = true;
video_codec->codecSpecific.VP8.automaticResizeOn = true;
video_codec->codecSpecific.VP8.frameDroppingOn = true;
video_codec->codecSpecific.VP8.keyFrameInterval = 200;
}
void SetSimulcastSettings(webrtc::VideoCodec* video_codec) {
// Simulcast settings.
video_codec->numberOfSimulcastStreams = 1;
video_codec->simulcastStream[0].width = 320;
video_codec->simulcastStream[0].height = 180;
video_codec->simulcastStream[0].numberOfTemporalLayers = 0;
video_codec->simulcastStream[0].maxBitrate = 100;
video_codec->simulcastStream[0].targetBitrate = 100;
video_codec->simulcastStream[0].minBitrate = 0;
video_codec->simulcastStream[0].qpMax = video_codec->qpMax;
}
// This test compares two VideoCodecInst objects except codec specific and
// simulcast streams.
TEST(ViECodecTest, TestCompareCodecs) {
VideoCodec codec1, codec2;
memset(&codec1, 0, sizeof(VideoCodec));
memset(&codec2, 0, sizeof(VideoCodec));
BuildVP8Codec(&codec1);
BuildVP8Codec(&codec2);
EXPECT_TRUE(codec1 == codec2);
EXPECT_FALSE(codec1 != codec2);
// plname is case insensitive.
strncpy(codec2.plName, "vp8", 4);
EXPECT_TRUE(codec1 == codec2);
codec2.codecType = kVideoCodecUnknown;
EXPECT_FALSE(codec1 == codec2);
// Modify pltype.
BuildVP8Codec(&codec2);
codec2.plType = 101;
EXPECT_FALSE(codec1 == codec2);
// Modifing height and width.
BuildVP8Codec(&codec2);
codec2.width = 640;
codec2.height = 480;
EXPECT_FALSE(codec1 == codec2);
// Modify framerate, default value is 30.
BuildVP8Codec(&codec2);
codec2.maxFramerate = 15;
EXPECT_FALSE(codec1 == codec2);
// Modifying startBitrate, default value is 1000 kbps.
BuildVP8Codec(&codec2);
codec2.startBitrate = 2000;
EXPECT_FALSE(codec1 == codec2);
// maxBitrate
BuildVP8Codec(&codec2);
codec2.startBitrate = 3000;
EXPECT_FALSE(codec1 == codec2);
// minBirate
BuildVP8Codec(&codec2);
codec2.startBitrate = 500;
EXPECT_FALSE(codec1 == codec2);
// Modify qpMax.
BuildVP8Codec(&codec2);
codec2.qpMax = 100;
EXPECT_FALSE(codec1 == codec2);
// Modify mode
BuildVP8Codec(&codec2);
codec2.mode = kScreensharing;
EXPECT_FALSE(codec1 == codec2);
}
// Test VP8 specific comparision.
TEST(ViECodecTest, TestCompareVP8CodecSpecific) {
VideoCodec codec1, codec2;
memset(&codec1, 0, sizeof(VideoCodec));
memset(&codec2, 0, sizeof(VideoCodec));
BuildVP8Codec(&codec1);
BuildVP8Codec(&codec2);
EXPECT_TRUE(codec1 == codec2);
// pictureLossIndicationOn
codec2.codecSpecific.VP8.pictureLossIndicationOn = false;
EXPECT_FALSE(codec1 == codec2);
// feedbackModeOn
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.feedbackModeOn = false;
EXPECT_FALSE(codec1 == codec2);
// complexity
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.complexity = kComplexityHigh;
EXPECT_FALSE(codec1 == codec2);
// resilience
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.resilience = kResilientStream;
EXPECT_FALSE(codec1 == codec2);
// numberOfTemporalLayers
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.numberOfTemporalLayers = 2;
EXPECT_FALSE(codec1 == codec2);
// denoisingOn
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.denoisingOn = false;
EXPECT_FALSE(codec1 == codec2);
// errorConcealmentOn
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.errorConcealmentOn = false;
EXPECT_FALSE(codec1 == codec2);
// pictureLossIndicationOn
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.automaticResizeOn = false;
EXPECT_FALSE(codec1 == codec2);
// frameDroppingOn
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.frameDroppingOn = false;
EXPECT_FALSE(codec1 == codec2);
// keyFrameInterval
BuildVP8Codec(&codec2);
codec2.codecSpecific.VP8.keyFrameInterval = 100;
EXPECT_FALSE(codec1 == codec2);
}
// This test compares simulcast stream information in VideoCodec.
TEST(ViECodecTest, TestCompareSimulcastStreams) {
VideoCodec codec1, codec2;
memset(&codec1, 0, sizeof(VideoCodec));
memset(&codec2, 0, sizeof(VideoCodec));
BuildVP8Codec(&codec1);
BuildVP8Codec(&codec2);
// Set simulacast settings.
SetSimulcastSettings(&codec1);
SetSimulcastSettings(&codec2);
EXPECT_TRUE(codec1 == codec2);
// Modify number of streams.
codec2.numberOfSimulcastStreams = 2;
EXPECT_FALSE(codec1 == codec2);
// Resetting steram count.
codec2.numberOfSimulcastStreams = 1;
// Modify height and width in codec2.
codec2.simulcastStream[0].width = 640;
codec2.simulcastStream[0].height = 480;
EXPECT_FALSE(codec1 == codec2);
// numberOfTemporalLayers
SetSimulcastSettings(&codec2);
codec2.simulcastStream[0].numberOfTemporalLayers = 2;
EXPECT_FALSE(codec1 == codec2);
// maxBitrate
SetSimulcastSettings(&codec2);
codec2.simulcastStream[0].maxBitrate = 1000;
EXPECT_FALSE(codec1 == codec2);
// targetBitrate
SetSimulcastSettings(&codec2);
codec2.simulcastStream[0].targetBitrate = 1000;
EXPECT_FALSE(codec1 == codec2);
// minBitrate
SetSimulcastSettings(&codec2);
codec2.simulcastStream[0].minBitrate = 50;
EXPECT_FALSE(codec1 == codec2);
// qpMax
SetSimulcastSettings(&codec2);
codec2.simulcastStream[0].qpMax = 100;
EXPECT_FALSE(codec1 == codec2);
}
} // namespace webrtc

View File

@ -177,7 +177,6 @@
'video/video_decoder_unittest.cc', 'video/video_decoder_unittest.cc',
'video/video_encoder_unittest.cc', 'video/video_encoder_unittest.cc',
'video/video_send_stream_tests.cc', 'video/video_send_stream_tests.cc',
'video/vie_codec_unittest.cc',
'video/vie_remb_unittest.cc', 'video/vie_remb_unittest.cc',
], ],
'dependencies': [ 'dependencies': [