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

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

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove redundant reset(nullptr) Created 5 years, 3 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
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | talk/media/webrtc/webrtcvoiceengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 it->second == config.rtp.fec.red_rtx_payload_type); 103 it->second == config.rtp.fec.red_rtx_payload_type);
104 } 104 }
105 } 105 }
106 } // namespace 106 } // namespace
107 107
108 namespace cricket { 108 namespace cricket {
109 class WebRtcVideoEngine2Test : public ::testing::Test { 109 class WebRtcVideoEngine2Test : public ::testing::Test {
110 public: 110 public:
111 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test(nullptr) {} 111 WebRtcVideoEngine2Test() : WebRtcVideoEngine2Test(nullptr) {}
112 WebRtcVideoEngine2Test(WebRtcVoiceEngine* voice_engine) 112 WebRtcVideoEngine2Test(WebRtcVoiceEngine* voice_engine)
113 : engine_(voice_engine) { 113 : call_(webrtc::Call::Create(webrtc::Call::Config())),
114 engine_() {
114 std::vector<VideoCodec> engine_codecs = engine_.codecs(); 115 std::vector<VideoCodec> engine_codecs = engine_.codecs();
115 DCHECK(!engine_codecs.empty()); 116 DCHECK(!engine_codecs.empty());
116 bool codec_set = false; 117 bool codec_set = false;
117 for (size_t i = 0; i < engine_codecs.size(); ++i) { 118 for (size_t i = 0; i < engine_codecs.size(); ++i) {
118 if (engine_codecs[i].name == "red") { 119 if (engine_codecs[i].name == "red") {
119 default_red_codec_ = engine_codecs[i]; 120 default_red_codec_ = engine_codecs[i];
120 } else if (engine_codecs[i].name == "ulpfec") { 121 } else if (engine_codecs[i].name == "ulpfec") {
121 default_ulpfec_codec_ = engine_codecs[i]; 122 default_ulpfec_codec_ = engine_codecs[i];
122 } else if (engine_codecs[i].name == "rtx") { 123 } else if (engine_codecs[i].name == "rtx") {
123 int associated_payload_type; 124 int associated_payload_type;
124 if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType, 125 if (engine_codecs[i].GetParam(kCodecParamAssociatedPayloadType,
125 &associated_payload_type)) { 126 &associated_payload_type)) {
126 default_apt_rtx_types_[associated_payload_type] = engine_codecs[i].id; 127 default_apt_rtx_types_[associated_payload_type] = engine_codecs[i].id;
127 } 128 }
128 } else if (!codec_set) { 129 } else if (!codec_set) {
129 default_codec_ = engine_codecs[i]; 130 default_codec_ = engine_codecs[i];
130 codec_set = true; 131 codec_set = true;
131 } 132 }
132 } 133 }
133 134
134 DCHECK(codec_set); 135 DCHECK(codec_set);
135 } 136 }
136 137
137 protected: 138 protected:
138 class FakeCallFactory : public WebRtcCallFactory {
139 public:
140 FakeCallFactory() : fake_call_(NULL) {}
141 FakeCall* GetCall() { return fake_call_; }
142
143 private:
144 webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
145 DCHECK(fake_call_ == NULL);
146 fake_call_ = new FakeCall(config);
147 return fake_call_;
148 }
149
150 FakeCall* fake_call_;
151 };
152
153 VideoMediaChannel* SetUpForExternalEncoderFactory( 139 VideoMediaChannel* SetUpForExternalEncoderFactory(
154 cricket::WebRtcVideoEncoderFactory* encoder_factory, 140 cricket::WebRtcVideoEncoderFactory* encoder_factory,
155 const std::vector<VideoCodec>& codecs); 141 const std::vector<VideoCodec>& codecs);
156 142
157 VideoMediaChannel* SetUpForExternalDecoderFactory( 143 VideoMediaChannel* SetUpForExternalDecoderFactory(
158 cricket::WebRtcVideoDecoderFactory* decoder_factory, 144 cricket::WebRtcVideoDecoderFactory* decoder_factory,
159 const std::vector<VideoCodec>& codecs); 145 const std::vector<VideoCodec>& codecs);
160 146
161 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly 147 // Used in WebRtcVideoEngine2VoiceTest, but defined here so it's properly
162 // initialized when the constructor is called. 148 // initialized when the constructor is called.
149 rtc::scoped_ptr<webrtc::Call> call_;
163 WebRtcVoiceEngine voice_engine_; 150 WebRtcVoiceEngine voice_engine_;
164 WebRtcVideoEngine2 engine_; 151 WebRtcVideoEngine2 engine_;
165 VideoCodec default_codec_; 152 VideoCodec default_codec_;
166 VideoCodec default_red_codec_; 153 VideoCodec default_red_codec_;
167 VideoCodec default_ulpfec_codec_; 154 VideoCodec default_ulpfec_codec_;
168 std::map<int, int> default_apt_rtx_types_; 155 std::map<int, int> default_apt_rtx_types_;
169 }; 156 };
170 157
171 TEST_F(WebRtcVideoEngine2Test, FindCodec) { 158 TEST_F(WebRtcVideoEngine2Test, FindCodec) {
172 const std::vector<cricket::VideoCodec>& c = engine_.codecs(); 159 const std::vector<cricket::VideoCodec>& c = engine_.codecs();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 330
344 // Verify removing header extension turns on applying rotation. 331 // Verify removing header extension turns on applying rotation.
345 extensions.clear(); 332 extensions.clear();
346 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions)); 333 EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions));
347 EXPECT_TRUE(capturer.GetApplyRotation()); 334 EXPECT_TRUE(capturer.GetApplyRotation());
348 } 335 }
349 336
350 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) { 337 TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
351 engine_.Init(); 338 engine_.Init();
352 rtc::scoped_ptr<VideoMediaChannel> channel( 339 rtc::scoped_ptr<VideoMediaChannel> channel(
353 engine_.CreateChannel(cricket::VideoOptions(), NULL)); 340 engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
354 341
355 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); 342 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
356 343
357 EXPECT_FALSE(channel->SetSend(true)) 344 EXPECT_FALSE(channel->SetSend(true))
358 << "Channel should not start without codecs."; 345 << "Channel should not start without codecs.";
359 EXPECT_TRUE(channel->SetSend(false)) 346 EXPECT_TRUE(channel->SetSend(false))
360 << "Channel should be stoppable even without set codecs."; 347 << "Channel should be stoppable even without set codecs.";
361 } 348 }
362 349
363 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) { 350 TEST_F(WebRtcVideoEngine2Test, GetStatsWithoutSendCodecsSetDoesNotCrash) {
364 engine_.Init(); 351 engine_.Init();
365 rtc::scoped_ptr<VideoMediaChannel> channel( 352 rtc::scoped_ptr<VideoMediaChannel> channel(
366 engine_.CreateChannel(cricket::VideoOptions(), NULL)); 353 engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
367 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123))); 354 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
368 VideoMediaInfo info; 355 VideoMediaInfo info;
369 channel->GetStats(&info); 356 channel->GetStats(&info);
370 } 357 }
371 358
372 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) { 359 TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) {
373 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 360 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
374 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 361 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
375 std::vector<cricket::VideoCodec> codecs; 362 std::vector<cricket::VideoCodec> codecs;
376 codecs.push_back(kVp8Codec); 363 codecs.push_back(kVp8Codec);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_TRUE( 405 EXPECT_TRUE(
419 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc))); 406 channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
420 } 407 }
421 408
422 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) { 409 TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) {
423 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 410 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
424 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 411 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
425 std::vector<cricket::VideoCodec> codecs; 412 std::vector<cricket::VideoCodec> codecs;
426 codecs.push_back(kVp8Codec); 413 codecs.push_back(kVp8Codec);
427 414
428 FakeCallFactory factory; 415 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
429 engine_.SetCallFactory(&factory); 416 call_.reset(fake_call);
430 rtc::scoped_ptr<VideoMediaChannel> channel( 417 rtc::scoped_ptr<VideoMediaChannel> channel(
431 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 418 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
432 419
433 EXPECT_TRUE( 420 EXPECT_TRUE(
434 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 421 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
435 422
436 FakeVideoCapturer capturer; 423 FakeVideoCapturer capturer;
437 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 424 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
438 capturer.Start(cricket::VideoFormat(1280, 720, 425 capturer.Start(cricket::VideoFormat(1280, 720,
439 cricket::VideoFormat::FpsToInterval(60), 426 cricket::VideoFormat::FpsToInterval(60),
440 cricket::FOURCC_I420)); 427 cricket::FOURCC_I420));
441 channel->SetSend(true); 428 channel->SetSend(true);
442 429
443 FakeVideoSendStream* stream = factory.GetCall()->GetVideoSendStreams()[0]; 430 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
444
445 431
446 EXPECT_TRUE(capturer.CaptureFrame()); 432 EXPECT_TRUE(capturer.CaptureFrame());
447 int64_t last_timestamp = stream->GetLastTimestamp(); 433 int64_t last_timestamp = stream->GetLastTimestamp();
448 for (int i = 0; i < 10; i++) { 434 for (int i = 0; i < 10; i++) {
449 EXPECT_TRUE(capturer.CaptureFrame()); 435 EXPECT_TRUE(capturer.CaptureFrame());
450 int64_t timestamp = stream->GetLastTimestamp(); 436 int64_t timestamp = stream->GetLastTimestamp();
451 int64_t interval = timestamp - last_timestamp; 437 int64_t interval = timestamp - last_timestamp;
452 438
453 // Precision changes from nanosecond to millisecond. 439 // Precision changes from nanosecond to millisecond.
454 // Allow error to be no more than 1. 440 // Allow error to be no more than 1.
(...skipping 24 matching lines...) Expand all
479 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 465 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
480 } 466 }
481 467
482 TEST_F(WebRtcVideoEngine2Test, 468 TEST_F(WebRtcVideoEngine2Test,
483 ProducesIncreasingTimestampsWithResetInputSources) { 469 ProducesIncreasingTimestampsWithResetInputSources) {
484 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 470 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
485 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 471 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
486 std::vector<cricket::VideoCodec> codecs; 472 std::vector<cricket::VideoCodec> codecs;
487 codecs.push_back(kVp8Codec); 473 codecs.push_back(kVp8Codec);
488 474
489 FakeCallFactory factory; 475 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
490 engine_.SetCallFactory(&factory); 476 call_.reset(fake_call);
491 rtc::scoped_ptr<VideoMediaChannel> channel( 477 rtc::scoped_ptr<VideoMediaChannel> channel(
492 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 478 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
493 479
494 EXPECT_TRUE( 480 EXPECT_TRUE(
495 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 481 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
496 channel->SetSend(true); 482 channel->SetSend(true);
497 FakeVideoSendStream* stream = factory.GetCall()->GetVideoSendStreams()[0]; 483 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
498 484
499 FakeVideoCapturer capturer1; 485 FakeVideoCapturer capturer1;
500 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); 486 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1));
501 487
502 cricket::CapturedFrame frame; 488 cricket::CapturedFrame frame;
503 frame.width = 1280; 489 frame.width = 1280;
504 frame.height = 720; 490 frame.height = 720;
505 frame.fourcc = cricket::FOURCC_I420; 491 frame.fourcc = cricket::FOURCC_I420;
506 frame.data_size = static_cast<uint32>( 492 frame.data_size = static_cast<uint32>(
507 cricket::VideoFrame::SizeOf(frame.width, frame.height)); 493 cricket::VideoFrame::SizeOf(frame.width, frame.height));
(...skipping 29 matching lines...) Expand all
537 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 523 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
538 } 524 }
539 525
540 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( 526 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory(
541 cricket::WebRtcVideoEncoderFactory* encoder_factory, 527 cricket::WebRtcVideoEncoderFactory* encoder_factory,
542 const std::vector<VideoCodec>& codecs) { 528 const std::vector<VideoCodec>& codecs) {
543 engine_.SetExternalEncoderFactory(encoder_factory); 529 engine_.SetExternalEncoderFactory(encoder_factory);
544 engine_.Init(); 530 engine_.Init();
545 531
546 VideoMediaChannel* channel = 532 VideoMediaChannel* channel =
547 engine_.CreateChannel(cricket::VideoOptions(), NULL); 533 engine_.CreateChannel(call_.get(), cricket::VideoOptions());
548 EXPECT_TRUE(channel->SetSendCodecs(codecs)); 534 EXPECT_TRUE(channel->SetSendCodecs(codecs));
549 535
550 return channel; 536 return channel;
551 } 537 }
552 538
553 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory( 539 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalDecoderFactory(
554 cricket::WebRtcVideoDecoderFactory* decoder_factory, 540 cricket::WebRtcVideoDecoderFactory* decoder_factory,
555 const std::vector<VideoCodec>& codecs) { 541 const std::vector<VideoCodec>& codecs) {
556 engine_.SetExternalDecoderFactory(decoder_factory); 542 engine_.SetExternalDecoderFactory(decoder_factory);
557 engine_.Init(); 543 engine_.Init();
558 544
559 VideoMediaChannel* channel = 545 VideoMediaChannel* channel =
560 engine_.CreateChannel(cricket::VideoOptions(), NULL); 546 engine_.CreateChannel(call_.get(), cricket::VideoOptions());
561 EXPECT_TRUE(channel->SetRecvCodecs(codecs)); 547 EXPECT_TRUE(channel->SetRecvCodecs(codecs));
562 548
563 return channel; 549 return channel;
564 } 550 }
565 551
566 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { 552 TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) {
567 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 553 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
568 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 554 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
569 std::vector<cricket::VideoCodec> codecs; 555 std::vector<cricket::VideoCodec> codecs;
570 codecs.push_back(kVp8Codec); 556 codecs.push_back(kVp8Codec);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 EXPECT_TRUE(SetOneCodec(codec)); 887 EXPECT_TRUE(SetOneCodec(codec));
902 codec.width /= 2; 888 codec.width /= 2;
903 codec.height /= 2; 889 codec.height /= 2;
904 EXPECT_TRUE(SetSend(true)); 890 EXPECT_TRUE(SetSend(true));
905 EXPECT_TRUE(channel_->SetRender(true)); 891 EXPECT_TRUE(channel_->SetRender(true));
906 EXPECT_EQ(0, renderer_.num_rendered_frames()); 892 EXPECT_EQ(0, renderer_.num_rendered_frames());
907 EXPECT_TRUE(SendFrame()); 893 EXPECT_TRUE(SendFrame());
908 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); 894 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
909 } 895 }
910 896
911 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test, 897 class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
912 public WebRtcCallFactory {
913 public: 898 public:
914 WebRtcVideoChannel2Test() : fake_call_(NULL), last_ssrc_(0) {} 899 WebRtcVideoChannel2Test() : last_ssrc_(0) {}
915 void SetUp() override { 900 void SetUp() override {
916 engine_.SetCallFactory(this); 901 fake_call_.reset(new FakeCall(webrtc::Call::Config()));
917 engine_.Init(); 902 engine_.Init();
918 channel_.reset(engine_.CreateChannel(cricket::VideoOptions(), NULL)); 903 channel_.reset(
919 ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory."; 904 engine_.CreateChannel(fake_call_.get(), cricket::VideoOptions()));
920 last_ssrc_ = 123; 905 last_ssrc_ = 123;
921 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs())); 906 ASSERT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
922 } 907 }
923 908
924 protected: 909 protected:
925 virtual std::vector<cricket::VideoCodec> GetCodecs() { 910 virtual std::vector<cricket::VideoCodec> GetCodecs() {
926 return engine_.codecs(); 911 return engine_.codecs();
927 } 912 }
928 913
929 webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
930 DCHECK(fake_call_ == NULL);
931 fake_call_ = new FakeCall(config);
932 return fake_call_;
933 }
934
935 FakeVideoSendStream* AddSendStream() { 914 FakeVideoSendStream* AddSendStream() {
936 return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_)); 915 return AddSendStream(StreamParams::CreateLegacy(++last_ssrc_));
937 } 916 }
938 917
939 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { 918 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
940 size_t num_streams = fake_call_->GetVideoSendStreams().size(); 919 size_t num_streams = fake_call_->GetVideoSendStreams().size();
941 EXPECT_TRUE(channel_->AddSendStream(sp)); 920 EXPECT_TRUE(channel_->AddSendStream(sp));
942 std::vector<FakeVideoSendStream*> streams = 921 std::vector<FakeVideoSendStream*> streams =
943 fake_call_->GetVideoSendStreams(); 922 fake_call_->GetVideoSendStreams();
944 EXPECT_EQ(num_streams + 1, streams.size()); 923 EXPECT_EQ(num_streams + 1, streams.size());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 EXPECT_EQ(expected_min_bitrate_bps, 957 EXPECT_EQ(expected_min_bitrate_bps,
979 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); 958 fake_call_->GetConfig().bitrate_config.min_bitrate_bps);
980 EXPECT_EQ(expected_start_bitrate_bps, 959 EXPECT_EQ(expected_start_bitrate_bps,
981 fake_call_->GetConfig().bitrate_config.start_bitrate_bps); 960 fake_call_->GetConfig().bitrate_config.start_bitrate_bps);
982 EXPECT_EQ(expected_max_bitrate_bps, 961 EXPECT_EQ(expected_max_bitrate_bps,
983 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); 962 fake_call_->GetConfig().bitrate_config.max_bitrate_bps);
984 } 963 }
985 964
986 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext, 965 void TestSetSendRtpHeaderExtensions(const std::string& cricket_ext,
987 const std::string& webrtc_ext) { 966 const std::string& webrtc_ext) {
988 FakeCall* call = fake_call_;
989 // Enable extension. 967 // Enable extension.
990 const int id = 1; 968 const int id = 1;
991 std::vector<cricket::RtpHeaderExtension> extensions; 969 std::vector<cricket::RtpHeaderExtension> extensions;
992 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); 970 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id));
993 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 971 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
994 972
995 FakeVideoSendStream* send_stream = 973 FakeVideoSendStream* send_stream =
996 AddSendStream(cricket::StreamParams::CreateLegacy(123)); 974 AddSendStream(cricket::StreamParams::CreateLegacy(123));
997 975
998 // Verify the send extension id. 976 // Verify the send extension id.
999 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); 977 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size());
1000 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); 978 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id);
1001 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); 979 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name);
1002 // Verify call with same set of extensions returns true. 980 // Verify call with same set of extensions returns true.
1003 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 981 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
1004 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for 982 // Verify that SetSendRtpHeaderExtensions doesn't implicitly add them for
1005 // receivers. 983 // receivers.
1006 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123)) 984 EXPECT_TRUE(AddRecvStream(cricket::StreamParams::CreateLegacy(123))
1007 ->GetConfig() 985 ->GetConfig()
1008 .rtp.extensions.empty()); 986 .rtp.extensions.empty());
1009 987
1010 // Verify that existing RTP header extensions can be removed. 988 // Verify that existing RTP header extensions can be removed.
1011 std::vector<cricket::RtpHeaderExtension> empty_extensions; 989 std::vector<cricket::RtpHeaderExtension> empty_extensions;
1012 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); 990 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions));
1013 ASSERT_EQ(1u, call->GetVideoSendStreams().size()); 991 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1014 send_stream = call->GetVideoSendStreams()[0]; 992 send_stream = fake_call_->GetVideoSendStreams()[0];
1015 EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty()); 993 EXPECT_TRUE(send_stream->GetConfig().rtp.extensions.empty());
1016 994
1017 // Verify that adding receive RTP header extensions adds them for existing 995 // Verify that adding receive RTP header extensions adds them for existing
1018 // streams. 996 // streams.
1019 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 997 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
1020 send_stream = call->GetVideoSendStreams()[0]; 998 send_stream = fake_call_->GetVideoSendStreams()[0];
1021 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size()); 999 ASSERT_EQ(1u, send_stream->GetConfig().rtp.extensions.size());
1022 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id); 1000 EXPECT_EQ(id, send_stream->GetConfig().rtp.extensions[0].id);
1023 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name); 1001 EXPECT_EQ(webrtc_ext, send_stream->GetConfig().rtp.extensions[0].name);
1024 } 1002 }
1025 1003
1026 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext, 1004 void TestSetRecvRtpHeaderExtensions(const std::string& cricket_ext,
1027 const std::string& webrtc_ext) { 1005 const std::string& webrtc_ext) {
1028 FakeCall* call = fake_call_;
1029 // Enable extension. 1006 // Enable extension.
1030 const int id = 1; 1007 const int id = 1;
1031 std::vector<cricket::RtpHeaderExtension> extensions; 1008 std::vector<cricket::RtpHeaderExtension> extensions;
1032 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id)); 1009 extensions.push_back(cricket::RtpHeaderExtension(cricket_ext, id));
1033 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 1010 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
1034 1011
1035 FakeVideoReceiveStream* recv_stream = 1012 FakeVideoReceiveStream* recv_stream =
1036 AddRecvStream(cricket::StreamParams::CreateLegacy(123)); 1013 AddRecvStream(cricket::StreamParams::CreateLegacy(123));
1037 1014
1038 // Verify the recv extension id. 1015 // Verify the recv extension id.
1039 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); 1016 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size());
1040 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); 1017 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id);
1041 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); 1018 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name);
1042 // Verify call with same set of extensions returns true. 1019 // Verify call with same set of extensions returns true.
1043 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 1020 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
1044 1021
1045 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for 1022 // Verify that SetRecvRtpHeaderExtensions doesn't implicitly add them for
1046 // senders. 1023 // senders.
1047 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123)) 1024 EXPECT_TRUE(AddSendStream(cricket::StreamParams::CreateLegacy(123))
1048 ->GetConfig() 1025 ->GetConfig()
1049 .rtp.extensions.empty()); 1026 .rtp.extensions.empty());
1050 1027
1051 // Verify that existing RTP header extensions can be removed. 1028 // Verify that existing RTP header extensions can be removed.
1052 std::vector<cricket::RtpHeaderExtension> empty_extensions; 1029 std::vector<cricket::RtpHeaderExtension> empty_extensions;
1053 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); 1030 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions));
1054 ASSERT_EQ(1u, call->GetVideoReceiveStreams().size()); 1031 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size());
1055 recv_stream = call->GetVideoReceiveStreams()[0]; 1032 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
1056 EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty()); 1033 EXPECT_TRUE(recv_stream->GetConfig().rtp.extensions.empty());
1057 1034
1058 // Verify that adding receive RTP header extensions adds them for existing 1035 // Verify that adding receive RTP header extensions adds them for existing
1059 // streams. 1036 // streams.
1060 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 1037 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
1061 recv_stream = call->GetVideoReceiveStreams()[0]; 1038 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
1062 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size()); 1039 ASSERT_EQ(1u, recv_stream->GetConfig().rtp.extensions.size());
1063 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id); 1040 EXPECT_EQ(id, recv_stream->GetConfig().rtp.extensions[0].id);
1064 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); 1041 EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name);
1065 } 1042 }
1066 1043
1067 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); 1044 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare);
1068 void TestReceiverLocalSsrcConfiguration(bool receiver_first); 1045 void TestReceiverLocalSsrcConfiguration(bool receiver_first);
1069 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, 1046 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type,
1070 bool expect_created_receive_stream); 1047 bool expect_created_receive_stream);
1071 1048
(...skipping 17 matching lines...) Expand all
1089 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); 1066 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset);
1090 } 1067 }
1091 } 1068 }
1092 if (with_rtx) { 1069 if (with_rtx) {
1093 return AddSendStream( 1070 return AddSendStream(
1094 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1071 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1095 } 1072 }
1096 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); 1073 return AddSendStream(CreateSimStreamParams("cname", ssrcs));
1097 } 1074 }
1098 1075
1099 FakeCall* fake_call_; 1076 rtc::scoped_ptr<FakeCall> fake_call_;
1100 rtc::scoped_ptr<VideoMediaChannel> channel_; 1077 rtc::scoped_ptr<VideoMediaChannel> channel_;
1101 uint32 last_ssrc_; 1078 uint32 last_ssrc_;
1102 }; 1079 };
1103 1080
1104 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1081 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) {
1105 const uint32 kVideoSsrc = 123; 1082 const uint32 kVideoSsrc = 123;
1106 const std::string kSyncLabel = "AvSyncLabel"; 1083 const std::string kSyncLabel = "AvSyncLabel";
1107 1084
1108 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); 1085 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc);
1109 sp.sync_label = kSyncLabel; 1086 sp.sync_label = kSyncLabel;
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 } 2803 }
2827 2804
2828 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) { 2805 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrc) {
2829 TestReceiverLocalSsrcConfiguration(false); 2806 TestReceiverLocalSsrcConfiguration(false);
2830 } 2807 }
2831 2808
2832 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) { 2809 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) {
2833 TestReceiverLocalSsrcConfiguration(true); 2810 TestReceiverLocalSsrcConfiguration(true);
2834 } 2811 }
2835 2812
2836 class WebRtcVideoEngine2SimulcastTest : public testing::Test { 2813 class WebRtcVideoEngine2SimulcastTest : public testing::Test {};
2837 public:
2838 WebRtcVideoEngine2SimulcastTest() : engine_(nullptr) {}
2839
2840 protected:
2841 WebRtcVideoEngine2 engine_;
2842 };
2843 2814
2844 // Test that if we add a stream with RTX SSRC's, SSRC's get set correctly. 2815 // Test that if we add a stream with RTX SSRC's, SSRC's get set correctly.
2845 TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) { 2816 TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) {
2846 // TODO(pbos): Implement. 2817 // TODO(pbos): Implement.
2847 FAIL() << "Not implemented."; 2818 FAIL() << "Not implemented.";
2848 } 2819 }
2849 2820
2850 // Test that if we get too few ssrcs are given in AddSendStream(), 2821 // Test that if we get too few ssrcs are given in AddSendStream(),
2851 // only supported sub-streams will be added. 2822 // only supported sub-streams will be added.
2852 TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TooFewSimulcastSsrcs) { 2823 TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TooFewSimulcastSsrcs) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 // TODO(pbos): Implement. 2950 // TODO(pbos): Implement.
2980 FAIL() << "Not implemented."; 2951 FAIL() << "Not implemented.";
2981 } 2952 }
2982 2953
2983 TEST_F(WebRtcVideoEngine2SimulcastTest, 2954 TEST_F(WebRtcVideoEngine2SimulcastTest,
2984 DISABLED_DontUseSimulcastAdapterOnNonVp8Factory) { 2955 DISABLED_DontUseSimulcastAdapterOnNonVp8Factory) {
2985 // TODO(pbos): Implement. 2956 // TODO(pbos): Implement.
2986 FAIL() << "Not implemented."; 2957 FAIL() << "Not implemented.";
2987 } 2958 }
2988 2959
2989 class WebRtcVideoChannel2SimulcastTest : public WebRtcVideoEngine2SimulcastTest, 2960 class WebRtcVideoChannel2SimulcastTest : public testing::Test {
2990 public WebRtcCallFactory {
2991 public: 2961 public:
2992 WebRtcVideoChannel2SimulcastTest() : fake_call_(NULL) {} 2962 WebRtcVideoChannel2SimulcastTest() : fake_call_(webrtc::Call::Config()) {}
2993 2963
2994 void SetUp() override { 2964 void SetUp() override {
2995 engine_.SetCallFactory(this);
2996 engine_.Init(); 2965 engine_.Init();
2997 channel_.reset(engine_.CreateChannel(VideoOptions(), NULL)); 2966 channel_.reset(engine_.CreateChannel(&fake_call_, VideoOptions()));
2998 ASSERT_TRUE(fake_call_ != NULL) << "Call not created through factory.";
2999 last_ssrc_ = 123; 2967 last_ssrc_ = 123;
3000 } 2968 }
3001 2969
3002 protected: 2970 protected:
3003 webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
3004 DCHECK(fake_call_ == NULL);
3005 fake_call_ = new FakeCall(config);
3006 return fake_call_;
3007 }
3008
3009 void VerifySimulcastSettings(const VideoCodec& codec, 2971 void VerifySimulcastSettings(const VideoCodec& codec,
3010 VideoOptions::HighestBitrate bitrate_mode, 2972 VideoOptions::HighestBitrate bitrate_mode,
3011 size_t num_configured_streams, 2973 size_t num_configured_streams,
3012 size_t expected_num_streams, 2974 size_t expected_num_streams,
3013 SimulcastBitrateMode simulcast_bitrate_mode) { 2975 SimulcastBitrateMode simulcast_bitrate_mode) {
3014 cricket::VideoOptions options; 2976 cricket::VideoOptions options;
3015 options.video_highest_bitrate.Set(bitrate_mode); 2977 options.video_highest_bitrate.Set(bitrate_mode);
3016 EXPECT_TRUE(channel_->SetOptions(options)); 2978 EXPECT_TRUE(channel_->SetOptions(options));
3017 2979
3018 std::vector<VideoCodec> codecs; 2980 std::vector<VideoCodec> codecs;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 3054
3093 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), NULL)); 3055 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), NULL));
3094 } 3056 }
3095 3057
3096 FakeVideoSendStream* AddSendStream() { 3058 FakeVideoSendStream* AddSendStream() {
3097 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); 3059 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
3098 } 3060 }
3099 3061
3100 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { 3062 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
3101 size_t num_streams = 3063 size_t num_streams =
3102 fake_call_->GetVideoSendStreams().size(); 3064 fake_call_.GetVideoSendStreams().size();
3103 EXPECT_TRUE(channel_->AddSendStream(sp)); 3065 EXPECT_TRUE(channel_->AddSendStream(sp));
3104 std::vector<FakeVideoSendStream*> streams = 3066 std::vector<FakeVideoSendStream*> streams =
3105 fake_call_->GetVideoSendStreams(); 3067 fake_call_.GetVideoSendStreams();
3106 EXPECT_EQ(num_streams + 1, streams.size()); 3068 EXPECT_EQ(num_streams + 1, streams.size());
3107 return streams[streams.size() - 1]; 3069 return streams[streams.size() - 1];
3108 } 3070 }
3109 3071
3110 std::vector<FakeVideoSendStream*> GetFakeSendStreams() { 3072 std::vector<FakeVideoSendStream*> GetFakeSendStreams() {
3111 return fake_call_->GetVideoSendStreams(); 3073 return fake_call_.GetVideoSendStreams();
3112 } 3074 }
3113 3075
3114 FakeVideoReceiveStream* AddRecvStream() { 3076 FakeVideoReceiveStream* AddRecvStream() {
3115 return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++)); 3077 return AddRecvStream(StreamParams::CreateLegacy(last_ssrc_++));
3116 } 3078 }
3117 3079
3118 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { 3080 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) {
3119 size_t num_streams = 3081 size_t num_streams =
3120 fake_call_->GetVideoReceiveStreams().size(); 3082 fake_call_.GetVideoReceiveStreams().size();
3121 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3083 EXPECT_TRUE(channel_->AddRecvStream(sp));
3122 std::vector<FakeVideoReceiveStream*> streams = 3084 std::vector<FakeVideoReceiveStream*> streams =
3123 fake_call_->GetVideoReceiveStreams(); 3085 fake_call_.GetVideoReceiveStreams();
3124 EXPECT_EQ(num_streams + 1, streams.size()); 3086 EXPECT_EQ(num_streams + 1, streams.size());
3125 return streams[streams.size() - 1]; 3087 return streams[streams.size() - 1];
3126 } 3088 }
3127 3089
3128 FakeCall* fake_call_; 3090 FakeCall fake_call_;
3091 WebRtcVideoEngine2 engine_;
3129 rtc::scoped_ptr<VideoMediaChannel> channel_; 3092 rtc::scoped_ptr<VideoMediaChannel> channel_;
3130 uint32 last_ssrc_; 3093 uint32 last_ssrc_;
3131 }; 3094 };
3132 3095
3133 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { 3096 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
3134 VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); 3097 VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL);
3135 } 3098 }
3136 3099
3137 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3100 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3138 VerifySimulcastSettings( 3101 VerifySimulcastSettings(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 // Ensures that the correct settings are applied to the codec when two temporal 3207 // Ensures that the correct settings are applied to the codec when two temporal
3245 // layer screencasting is enabled, and that the correct simulcast settings are 3208 // layer screencasting is enabled, and that the correct simulcast settings are
3246 // reapplied when disabling screencasting. 3209 // reapplied when disabling screencasting.
3247 TEST_F(WebRtcVideoChannel2SimulcastTest, 3210 TEST_F(WebRtcVideoChannel2SimulcastTest,
3248 DISABLED_TwoTemporalLayerScreencastSettings) { 3211 DISABLED_TwoTemporalLayerScreencastSettings) {
3249 // TODO(pbos): Implement. 3212 // TODO(pbos): Implement.
3250 FAIL() << "Not implemented."; 3213 FAIL() << "Not implemented.";
3251 } 3214 }
3252 3215
3253 } // namespace cricket 3216 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | talk/media/webrtc/webrtcvoiceengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698