Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: talk/media/webrtc/webrtcvideoengine2_unittest.cc

Issue 1569853002: Measure encoding time on encode callbacks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: asapersson@ feedback Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 protected: 147 protected:
148 VideoMediaChannel* SetUpForExternalEncoderFactory( 148 VideoMediaChannel* SetUpForExternalEncoderFactory(
149 cricket::WebRtcVideoEncoderFactory* encoder_factory, 149 cricket::WebRtcVideoEncoderFactory* encoder_factory,
150 const std::vector<VideoCodec>& codecs); 150 const std::vector<VideoCodec>& codecs);
151 151
152 VideoMediaChannel* SetUpForExternalDecoderFactory( 152 VideoMediaChannel* SetUpForExternalDecoderFactory(
153 cricket::WebRtcVideoDecoderFactory* decoder_factory, 153 cricket::WebRtcVideoDecoderFactory* decoder_factory,
154 const std::vector<VideoCodec>& codecs); 154 const std::vector<VideoCodec>& codecs);
155 155
156 void TestExtendedEncoderOveruse(bool use_external_encoder);
157
156 webrtc::test::ScopedFieldTrials override_field_trials_; 158 webrtc::test::ScopedFieldTrials override_field_trials_;
157 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly 159 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly
158 // initialized when the constructor is called. 160 // initialized when the constructor is called.
159 rtc::scoped_ptr<webrtc::Call> call_; 161 rtc::scoped_ptr<webrtc::Call> call_;
160 WebRtcVoiceEngine voice_engine_; 162 WebRtcVoiceEngine voice_engine_;
161 WebRtcVideoEngine2 engine_; 163 WebRtcVideoEngine2 engine_;
162 VideoCodec default_codec_; 164 VideoCodec default_codec_;
163 VideoCodec default_red_codec_; 165 VideoCodec default_red_codec_;
164 VideoCodec default_ulpfec_codec_; 166 VideoCodec default_ulpfec_codec_;
165 std::map<int, int> default_apt_rtx_types_; 167 std::map<int, int> default_apt_rtx_types_;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Setting codecs of the same type should not reallocate any encoders 351 // Setting codecs of the same type should not reallocate any encoders
350 // (expecting a no-op). 352 // (expecting a no-op).
351 EXPECT_TRUE(channel->SetSendParameters(parameters)); 353 EXPECT_TRUE(channel->SetSendParameters(parameters));
352 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders()); 354 EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders());
353 355
354 // Remove stream previously added to free the external encoder instance. 356 // Remove stream previously added to free the external encoder instance.
355 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 357 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
356 EXPECT_EQ(0u, encoder_factory.encoders().size()); 358 EXPECT_EQ(0u, encoder_factory.encoders().size());
357 } 359 }
358 360
361 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse(
362 bool use_external_encoder) {
363 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
364 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
365 cricket::VideoSendParameters parameters;
366 parameters.codecs.push_back(kVp8Codec);
367 rtc::scoped_ptr<VideoMediaChannel> channel;
368 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
369 call_.reset(fake_call);
370 if (use_external_encoder) {
371 channel.reset(
372 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
373 } else {
374 engine_.Init();
375 channel.reset(engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
376 }
377 ASSERT_TRUE(
378 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
379 EXPECT_TRUE(channel->SetSendParameters(parameters));
380 EXPECT_TRUE(channel->SetSend(true));
381 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
382
383 EXPECT_EQ(use_external_encoder,
384 stream->GetConfig().encoder_settings.full_overuse_time);
385 // Remove stream previously added to free the external encoder instance.
386 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
387 }
388
389 TEST_F(WebRtcVideoEngine2Test, EnablesFullEncoderTimeForExternalEncoders) {
390 TestExtendedEncoderOveruse(true);
391 }
392
393 TEST_F(WebRtcVideoEngine2Test, DisablesFullEncoderTimeForNonExternalEncoders) {
394 TestExtendedEncoderOveruse(false);
395 }
396
359 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) { 397 TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) {
360 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 398 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
361 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); 399 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
362 std::vector<cricket::VideoCodec> codecs; 400 std::vector<cricket::VideoCodec> codecs;
363 codecs.push_back(kVp9Codec); 401 codecs.push_back(kVp9Codec);
364 402
365 rtc::scoped_ptr<VideoMediaChannel> channel( 403 rtc::scoped_ptr<VideoMediaChannel> channel(
366 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 404 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
367 405
368 EXPECT_TRUE( 406 EXPECT_TRUE(
(...skipping 2681 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 // Test that we normalize send codec format size in simulcast. 3088 // Test that we normalize send codec format size in simulcast.
3051 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3089 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3052 cricket::VideoCodec codec(kVp8Codec270p); 3090 cricket::VideoCodec codec(kVp8Codec270p);
3053 codec.width += 1; 3091 codec.width += 1;
3054 codec.height += 1; 3092 codec.height += 1;
3055 VerifySimulcastSettings(codec, 2, 2); 3093 VerifySimulcastSettings(codec, 2, 2);
3056 } 3094 }
3057 } // namespace cricket 3095 } // namespace cricket
3058 3096
3059 #endif // HAVE_WEBRTC_VIDEO 3097 #endif // HAVE_WEBRTC_VIDEO
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698