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

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

Issue 2353033005: Refactoring: move ownership of RtcEventLog from Call to PeerConnection (Closed)
Patch Set: Moved the constructor Created 4 years, 2 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 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/arraysize.h" 16 #include "webrtc/base/arraysize.h"
17 #include "webrtc/base/gunit.h" 17 #include "webrtc/base/gunit.h"
18 #include "webrtc/base/stringutils.h" 18 #include "webrtc/base/stringutils.h"
19 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
19 #include "webrtc/media/base/testutils.h" 20 #include "webrtc/media/base/testutils.h"
20 #include "webrtc/media/base/videoengine_unittest.h" 21 #include "webrtc/media/base/videoengine_unittest.h"
21 #include "webrtc/media/engine/fakewebrtccall.h" 22 #include "webrtc/media/engine/fakewebrtccall.h"
22 #include "webrtc/media/engine/fakewebrtcvideoengine.h" 23 #include "webrtc/media/engine/fakewebrtcvideoengine.h"
23 #include "webrtc/media/engine/simulcast.h" 24 #include "webrtc/media/engine/simulcast.h"
24 #include "webrtc/media/engine/webrtcvideochannelfactory.h" 25 #include "webrtc/media/engine/webrtcvideochannelfactory.h"
25 #include "webrtc/media/engine/webrtcvideoengine2.h" 26 #include "webrtc/media/engine/webrtcvideoengine2.h"
26 #include "webrtc/media/engine/webrtcvoiceengine.h" 27 #include "webrtc/media/engine/webrtcvoiceengine.h"
27 #include "webrtc/test/field_trial.h" 28 #include "webrtc/test/field_trial.h"
28 #include "webrtc/video_encoder.h" 29 #include "webrtc/video_encoder.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 } 91 }
91 } // namespace 92 } // namespace
92 93
93 namespace cricket { 94 namespace cricket {
94 class WebRtcVideoEngine2Test : public ::testing::Test { 95 class WebRtcVideoEngine2Test : public ::testing::Test {
95 public: 96 public:
96 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test("") {} 97 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test("") {}
97 explicit WebRtcVideoEngine2Test(const char* field_trials) 98 explicit WebRtcVideoEngine2Test(const char* field_trials)
98 : override_field_trials_(field_trials), 99 : override_field_trials_(field_trials),
99 call_(webrtc::Call::Create(webrtc::Call::Config())), 100 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))),
100 engine_() { 101 engine_() {
101 std::vector<VideoCodec> engine_codecs = engine_.codecs(); 102 std::vector<VideoCodec> engine_codecs = engine_.codecs();
102 RTC_DCHECK(!engine_codecs.empty()); 103 RTC_DCHECK(!engine_codecs.empty());
103 bool codec_set = false; 104 bool codec_set = false;
104 for (size_t i = 0; i < engine_codecs.size(); ++i) { 105 for (size_t i = 0; i < engine_codecs.size(); ++i) {
105 if (engine_codecs[i].name == "red") { 106 if (engine_codecs[i].name == "red") {
106 default_red_codec_ = engine_codecs[i]; 107 default_red_codec_ = engine_codecs[i];
107 } else if (engine_codecs[i].name == "ulpfec") { 108 } else if (engine_codecs[i].name == "ulpfec") {
108 default_ulpfec_codec_ = engine_codecs[i]; 109 default_ulpfec_codec_ = engine_codecs[i];
109 } else if (engine_codecs[i].name == "rtx") { 110 } else if (engine_codecs[i].name == "rtx") {
(...skipping 16 matching lines...) Expand all
126 cricket::WebRtcVideoEncoderFactory* encoder_factory, 127 cricket::WebRtcVideoEncoderFactory* encoder_factory,
127 const std::vector<VideoCodec>& codecs); 128 const std::vector<VideoCodec>& codecs);
128 129
129 VideoMediaChannel* SetUpForExternalDecoderFactory( 130 VideoMediaChannel* SetUpForExternalDecoderFactory(
130 cricket::WebRtcVideoDecoderFactory* decoder_factory, 131 cricket::WebRtcVideoDecoderFactory* decoder_factory,
131 const std::vector<VideoCodec>& codecs); 132 const std::vector<VideoCodec>& codecs);
132 133
133 void TestExtendedEncoderOveruse(bool use_external_encoder); 134 void TestExtendedEncoderOveruse(bool use_external_encoder);
134 135
135 webrtc::test::ScopedFieldTrials override_field_trials_; 136 webrtc::test::ScopedFieldTrials override_field_trials_;
137 webrtc::RtcEventLogNullImpl event_log_;
136 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly 138 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly
137 // initialized when the constructor is called. 139 // initialized when the constructor is called.
138 std::unique_ptr<webrtc::Call> call_; 140 std::unique_ptr<webrtc::Call> call_;
139 WebRtcVideoEngine2 engine_; 141 WebRtcVideoEngine2 engine_;
140 VideoCodec default_codec_; 142 VideoCodec default_codec_;
141 VideoCodec default_red_codec_; 143 VideoCodec default_red_codec_;
142 VideoCodec default_ulpfec_codec_; 144 VideoCodec default_ulpfec_codec_;
143 std::map<int, int> default_apt_rtx_types_; 145 std::map<int, int> default_apt_rtx_types_;
144 }; 146 };
145 147
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 })); 407 }));
406 } 408 }
407 409
408 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse( 410 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse(
409 bool use_external_encoder) { 411 bool use_external_encoder) {
410 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 412 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
411 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 413 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
412 cricket::VideoSendParameters parameters; 414 cricket::VideoSendParameters parameters;
413 parameters.codecs.push_back(kVp8Codec); 415 parameters.codecs.push_back(kVp8Codec);
414 std::unique_ptr<VideoMediaChannel> channel; 416 std::unique_ptr<VideoMediaChannel> channel;
415 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); 417 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
416 call_.reset(fake_call); 418 call_.reset(fake_call);
417 if (use_external_encoder) { 419 if (use_external_encoder) {
418 channel.reset( 420 channel.reset(
419 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 421 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
420 } else { 422 } else {
421 engine_.Init(); 423 engine_.Init();
422 channel.reset( 424 channel.reset(
423 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions())); 425 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions()));
424 } 426 }
425 ASSERT_TRUE( 427 ASSERT_TRUE(
(...skipping 29 matching lines...) Expand all
455 EXPECT_TRUE( 457 EXPECT_TRUE(
456 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); 458 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
457 } 459 }
458 #endif // !defined(RTC_DISABLE_VP9) 460 #endif // !defined(RTC_DISABLE_VP9)
459 461
460 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) { 462 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) {
461 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 463 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
462 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 464 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
463 std::vector<cricket::VideoCodec> codecs; 465 std::vector<cricket::VideoCodec> codecs;
464 codecs.push_back(kVp8Codec); 466 codecs.push_back(kVp8Codec);
465 467 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
466 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
467 call_.reset(fake_call); 468 call_.reset(fake_call);
468 std::unique_ptr<VideoMediaChannel> channel( 469 std::unique_ptr<VideoMediaChannel> channel(
469 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 470 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
470 471
471 EXPECT_TRUE( 472 EXPECT_TRUE(
472 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 473 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
473 474
474 FakeVideoCapturer capturer; 475 FakeVideoCapturer capturer;
475 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer)); 476 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
476 capturer.Start(cricket::VideoFormat(1280, 720, 477 capturer.Start(cricket::VideoFormat(1280, 720,
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 codec.params[kCodecParamStartBitrate] = "1000000"; 874 codec.params[kCodecParamStartBitrate] = "1000000";
874 Base::TwoStreamsSendAndReceive(codec); 875 Base::TwoStreamsSendAndReceive(codec);
875 } 876 }
876 877
877 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { 878 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
878 public: 879 public:
879 WebRtcVideoChannel2Test() : WebRtcVideoChannel2Test("") {} 880 WebRtcVideoChannel2Test() : WebRtcVideoChannel2Test("") {}
880 explicit WebRtcVideoChannel2Test(const char* field_trials) 881 explicit WebRtcVideoChannel2Test(const char* field_trials)
881 : WebRtcVideoEngine2Test(field_trials), last_ssrc_(0) {} 882 : WebRtcVideoEngine2Test(field_trials), last_ssrc_(0) {}
882 void SetUp() override { 883 void SetUp() override {
883 fake_call_.reset(new FakeCall(webrtc::Call::Config())); 884 fake_call_.reset(new FakeCall(webrtc::Call::Config(&event_log_)));
884 engine_.Init(); 885 engine_.Init();
885 channel_.reset( 886 channel_.reset(
886 engine_.CreateChannel(fake_call_.get(), MediaConfig(), VideoOptions())); 887 engine_.CreateChannel(fake_call_.get(), MediaConfig(), VideoOptions()));
887 last_ssrc_ = 123; 888 last_ssrc_ = 123;
888 send_parameters_.codecs = engine_.codecs(); 889 send_parameters_.codecs = engine_.codecs();
889 recv_parameters_.codecs = engine_.codecs(); 890 recv_parameters_.codecs = engine_.codecs();
890 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); 891 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
891 } 892 }
892 893
893 protected: 894 protected:
(...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after
3717 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) { 3718 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) {
3718 TestReceiverLocalSsrcConfiguration(false); 3719 TestReceiverLocalSsrcConfiguration(false);
3719 } 3720 }
3720 3721
3721 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) { 3722 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) {
3722 TestReceiverLocalSsrcConfiguration(true); 3723 TestReceiverLocalSsrcConfiguration(true);
3723 } 3724 }
3724 3725
3725 class WebRtcVideoChannel2SimulcastTest : public testing::Test { 3726 class WebRtcVideoChannel2SimulcastTest : public testing::Test {
3726 public: 3727 public:
3727 WebRtcVideoChannel2SimulcastTest() : fake_call_(webrtc::Call::Config()) {} 3728 WebRtcVideoChannel2SimulcastTest()
3729 : fake_call_(webrtc::Call::Config(&event_log_)) {}
3728 3730
3729 void SetUp() override { 3731 void SetUp() override {
3730 engine_.Init(); 3732 engine_.Init();
3731 channel_.reset( 3733 channel_.reset(
3732 engine_.CreateChannel(&fake_call_, MediaConfig(), VideoOptions())); 3734 engine_.CreateChannel(&fake_call_, MediaConfig(), VideoOptions()));
3733 last_ssrc_ = 123; 3735 last_ssrc_ = 123;
3734 } 3736 }
3735 3737
3736 protected: 3738 protected:
3737 void VerifySimulcastSettings(const VideoCodec& codec, 3739 void VerifySimulcastSettings(const VideoCodec& codec,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3832 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { 3834 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) {
3833 size_t num_streams = 3835 size_t num_streams =
3834 fake_call_.GetVideoReceiveStreams().size(); 3836 fake_call_.GetVideoReceiveStreams().size();
3835 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3837 EXPECT_TRUE(channel_->AddRecvStream(sp));
3836 std::vector<FakeVideoReceiveStream*> streams = 3838 std::vector<FakeVideoReceiveStream*> streams =
3837 fake_call_.GetVideoReceiveStreams(); 3839 fake_call_.GetVideoReceiveStreams();
3838 EXPECT_EQ(num_streams + 1, streams.size()); 3840 EXPECT_EQ(num_streams + 1, streams.size());
3839 return streams[streams.size() - 1]; 3841 return streams[streams.size() - 1];
3840 } 3842 }
3841 3843
3844 webrtc::RtcEventLogNullImpl event_log_;
3842 FakeCall fake_call_; 3845 FakeCall fake_call_;
3843 WebRtcVideoEngine2 engine_; 3846 WebRtcVideoEngine2 engine_;
3844 std::unique_ptr<VideoMediaChannel> channel_; 3847 std::unique_ptr<VideoMediaChannel> channel_;
3845 uint32_t last_ssrc_; 3848 uint32_t last_ssrc_;
3846 }; 3849 };
3847 3850
3848 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { 3851 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
3849 VerifySimulcastSettings(kVp8Codec, 2, 2); 3852 VerifySimulcastSettings(kVp8Codec, 2, 2);
3850 } 3853 }
3851 3854
3852 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3855 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3853 VerifySimulcastSettings(kVp8Codec720p, 3, 3); 3856 VerifySimulcastSettings(kVp8Codec720p, 3, 3);
3854 } 3857 }
3855 3858
3856 // Test that we normalize send codec format size in simulcast. 3859 // Test that we normalize send codec format size in simulcast.
3857 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3860 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3858 cricket::VideoCodec codec(kVp8Codec270p); 3861 cricket::VideoCodec codec(kVp8Codec270p);
3859 codec.width += 1; 3862 codec.width += 1;
3860 codec.height += 1; 3863 codec.height += 1;
3861 VerifySimulcastSettings(codec, 2, 2); 3864 VerifySimulcastSettings(codec, 2, 2);
3862 } 3865 }
3863 } // namespace cricket 3866 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/fakewebrtccall.cc ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698