Add tests for r8811.

All these tests crashed before r8811. These tests should've been with
that change but r8811 was pushed in before to make bots green.

BUG=1788, 1667
R=stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/48669004

Cr-Commit-Position: refs/heads/master@{#8881}
This commit is contained in:
Peter Boström 2015-03-27 15:53:18 +01:00
parent b3fc48b28f
commit 53eda3dbd0
2 changed files with 145 additions and 80 deletions

View File

@ -589,6 +589,19 @@ TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) {
EXPECT_EQ(0u, encoder_factory.encoders().size()); EXPECT_EQ(0u, encoder_factory.encoders().size());
} }
TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) {
cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
std::vector<cricket::VideoCodec> codecs;
codecs.push_back(kVp9Codec);
rtc::scoped_ptr<VideoMediaChannel> channel(
SetUpForExternalEncoderFactory(&encoder_factory, codecs));
EXPECT_TRUE(
channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
}
VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory(
cricket::WebRtcVideoEncoderFactory* encoder_factory, cricket::WebRtcVideoEncoderFactory* encoder_factory,
const std::vector<VideoCodec>& codecs) { const std::vector<VideoCodec>& codecs) {

View File

@ -1342,16 +1342,20 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) {
RunBaseTest(&test); RunBaseTest(&test);
} }
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { static const size_t kVideoCodecConfigObserverNumberOfTemporalLayers = 4;
static const size_t kNumberOfTemporalLayers = 4; template <typename T>
class VideoCodecConfigObserver : public test::SendTest, class VideoCodecConfigObserver : public test::SendTest,
public test::FakeEncoder { public test::FakeEncoder {
public: public:
VideoCodecConfigObserver() VideoCodecConfigObserver(VideoCodecType video_codec_type,
: SendTest(kDefaultTimeoutMs), const char* codec_name)
: SendTest(VideoSendStreamTest::kDefaultTimeoutMs),
FakeEncoder(Clock::GetRealTimeClock()), FakeEncoder(Clock::GetRealTimeClock()),
video_codec_type_(video_codec_type),
codec_name_(codec_name),
num_initializations_(0) { num_initializations_(0) {
memset(&vp8_settings_, 0, sizeof(vp8_settings_)); memset(&encoder_settings_, 0, sizeof(encoder_settings_));
} }
private: private:
@ -1359,14 +1363,14 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
std::vector<VideoReceiveStream::Config>* receive_configs, std::vector<VideoReceiveStream::Config>* receive_configs,
VideoEncoderConfig* encoder_config) override { VideoEncoderConfig* encoder_config) override {
send_config->encoder_settings.encoder = this; send_config->encoder_settings.encoder = this;
send_config->encoder_settings.payload_name = "VP8"; send_config->encoder_settings.payload_name = codec_name_;
for (size_t i = 0; i < encoder_config->streams.size(); ++i) { for (size_t i = 0; i < encoder_config->streams.size(); ++i) {
encoder_config->streams[i].temporal_layer_thresholds_bps.resize( encoder_config->streams[i].temporal_layer_thresholds_bps.resize(
kNumberOfTemporalLayers - 1); kVideoCodecConfigObserverNumberOfTemporalLayers - 1);
} }
encoder_config->encoder_specific_settings = &vp8_settings_; encoder_config->encoder_specific_settings = &encoder_settings_;
encoder_config_ = *encoder_config; encoder_config_ = *encoder_config;
} }
@ -1379,33 +1383,18 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
int32_t InitEncode(const VideoCodec* config, int32_t InitEncode(const VideoCodec* config,
int32_t number_of_cores, int32_t number_of_cores,
size_t max_payload_size) override { size_t max_payload_size) override {
EXPECT_EQ(kVideoCodecVP8, config->codecType); EXPECT_EQ(video_codec_type_, config->codecType);
VerifyCodecSpecifics(*config);
// Check that the number of temporal layers has propagated properly to
// VideoCodec.
EXPECT_EQ(kNumberOfTemporalLayers,
config->codecSpecific.VP8.numberOfTemporalLayers);
for (unsigned char i = 0; i < config->numberOfSimulcastStreams; ++i) {
EXPECT_EQ(kNumberOfTemporalLayers,
config->simulcastStream[i].numberOfTemporalLayers);
}
// Set expected temporal layers as they should have been set when
// reconfiguring the encoder and not match the set config.
vp8_settings_.numberOfTemporalLayers = kNumberOfTemporalLayers;
EXPECT_EQ(0,
memcmp(&config->codecSpecific.VP8,
&vp8_settings_,
sizeof(vp8_settings_)));
++num_initializations_; ++num_initializations_;
return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size);
} }
void VerifyCodecSpecifics(const VideoCodec& config) const;
void PerformTest() override { void PerformTest() override {
EXPECT_EQ(1u, num_initializations_) << "VideoEncoder not initialized."; EXPECT_EQ(1u, num_initializations_) << "VideoEncoder not initialized.";
vp8_settings_.denoisingOn = true; encoder_settings_.frameDroppingOn = true;
stream_->ReconfigureVideoEncoder(encoder_config_); stream_->ReconfigureVideoEncoder(encoder_config_);
EXPECT_EQ(2u, num_initializations_) EXPECT_EQ(2u, num_initializations_)
<< "ReconfigureVideoEncoder did not reinitialize the encoder with " << "ReconfigureVideoEncoder did not reinitialize the encoder with "
@ -1419,12 +1408,75 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
return 0; return 0;
} }
VideoCodecVP8 vp8_settings_; T encoder_settings_;
const VideoCodecType video_codec_type_;
const char* const codec_name_;
size_t num_initializations_; size_t num_initializations_;
VideoSendStream* stream_; VideoSendStream* stream_;
VideoEncoderConfig encoder_config_; VideoEncoderConfig encoder_config_;
} test; };
template <>
void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics(
const VideoCodec& config) const {
EXPECT_EQ(0, memcmp(&config.codecSpecific.H264, &encoder_settings_,
sizeof(encoder_settings_)));
}
template <>
void VideoCodecConfigObserver<VideoCodecVP8>::VerifyCodecSpecifics(
const VideoCodec& config) const {
// Check that the number of temporal layers has propagated properly to
// VideoCodec.
EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers,
config.codecSpecific.VP8.numberOfTemporalLayers);
for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) {
EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers,
config.simulcastStream[i].numberOfTemporalLayers);
}
// Set expected temporal layers as they should have been set when
// reconfiguring the encoder and not match the set config.
VideoCodecVP8 encoder_settings = encoder_settings_;
encoder_settings.numberOfTemporalLayers =
kVideoCodecConfigObserverNumberOfTemporalLayers;
EXPECT_EQ(0, memcmp(&config.codecSpecific.VP8, &encoder_settings,
sizeof(encoder_settings_)));
}
template <>
void VideoCodecConfigObserver<VideoCodecVP9>::VerifyCodecSpecifics(
const VideoCodec& config) const {
// Check that the number of temporal layers has propagated properly to
// VideoCodec.
EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers,
config.codecSpecific.VP9.numberOfTemporalLayers);
for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) {
EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers,
config.simulcastStream[i].numberOfTemporalLayers);
}
// Set expected temporal layers as they should have been set when
// reconfiguring the encoder and not match the set config.
VideoCodecVP9 encoder_settings = encoder_settings_;
encoder_settings.numberOfTemporalLayers =
kVideoCodecConfigObserverNumberOfTemporalLayers;
EXPECT_EQ(0, memcmp(&config.codecSpecific.VP9, &encoder_settings,
sizeof(encoder_settings_)));
}
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8");
RunBaseTest(&test);
}
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) {
VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9");
RunBaseTest(&test);
}
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesH264Config) {
VideoCodecConfigObserver<VideoCodecH264> test(kVideoCodecH264, "H264");
RunBaseTest(&test); RunBaseTest(&test);
} }