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

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

Issue 1838413002: Combining SetVideoSend and SetSource into one method. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 233 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
234 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 234 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
235 235
236 // Add CVO extension. 236 // Add CVO extension.
237 const int id = 1; 237 const int id = 1;
238 parameters.extensions.push_back( 238 parameters.extensions.push_back(
239 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); 239 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
240 EXPECT_TRUE(channel->SetSendParameters(parameters)); 240 EXPECT_TRUE(channel->SetSendParameters(parameters));
241 241
242 // Set capturer. 242 // Set capturer.
243 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 243 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
244 244
245 // Verify capturer has turned off applying rotation. 245 // Verify capturer has turned off applying rotation.
246 EXPECT_FALSE(capturer.GetApplyRotation()); 246 EXPECT_FALSE(capturer.GetApplyRotation());
247 247
248 // Verify removing header extension turns on applying rotation. 248 // Verify removing header extension turns on applying rotation.
249 parameters.extensions.clear(); 249 parameters.extensions.clear();
250 EXPECT_TRUE(channel->SetSendParameters(parameters)); 250 EXPECT_TRUE(channel->SetSendParameters(parameters));
251 EXPECT_TRUE(capturer.GetApplyRotation()); 251 EXPECT_TRUE(capturer.GetApplyRotation());
252 } 252 }
253 253
(...skipping 10 matching lines...) Expand all
264 std::unique_ptr<VideoMediaChannel> channel( 264 std::unique_ptr<VideoMediaChannel> channel(
265 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 265 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
266 // Add CVO extension. 266 // Add CVO extension.
267 const int id = 1; 267 const int id = 1;
268 parameters.extensions.push_back( 268 parameters.extensions.push_back(
269 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); 269 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
270 EXPECT_TRUE(channel->SetSendParameters(parameters)); 270 EXPECT_TRUE(channel->SetSendParameters(parameters));
271 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 271 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
272 272
273 // Set capturer. 273 // Set capturer.
274 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 274 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
275 275
276 // Verify capturer has turned off applying rotation. 276 // Verify capturer has turned off applying rotation.
277 EXPECT_FALSE(capturer.GetApplyRotation()); 277 EXPECT_FALSE(capturer.GetApplyRotation());
278 } 278 }
279 279
280 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { 280 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) {
281 cricket::FakeVideoCapturer capturer; 281 cricket::FakeVideoCapturer capturer;
282 282
283 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 283 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
284 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 284 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
285 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); 285 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
286 cricket::VideoSendParameters parameters; 286 cricket::VideoSendParameters parameters;
287 parameters.codecs.push_back(kVp8Codec); 287 parameters.codecs.push_back(kVp8Codec);
288 parameters.codecs.push_back(kVp9Codec); 288 parameters.codecs.push_back(kVp9Codec);
289 289
290 std::unique_ptr<VideoMediaChannel> channel( 290 std::unique_ptr<VideoMediaChannel> channel(
291 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 291 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
292 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 292 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
293 293
294 // Set capturer. 294 // Set capturer.
295 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 295 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
296 296
297 // Verify capturer has turned on applying rotation. 297 // Verify capturer has turned on applying rotation.
298 EXPECT_TRUE(capturer.GetApplyRotation()); 298 EXPECT_TRUE(capturer.GetApplyRotation());
299 299
300 // Add CVO extension. 300 // Add CVO extension.
301 const int id = 1; 301 const int id = 1;
302 parameters.extensions.push_back( 302 parameters.extensions.push_back(
303 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); 303 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
304 // Also remove the first codec to trigger a codec change as well. 304 // Also remove the first codec to trigger a codec change as well.
305 parameters.codecs.erase(parameters.codecs.begin()); 305 parameters.codecs.erase(parameters.codecs.begin());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 std::unique_ptr<VideoMediaChannel> channel( 345 std::unique_ptr<VideoMediaChannel> channel(
346 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 346 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
347 347
348 EXPECT_TRUE( 348 EXPECT_TRUE(
349 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 349 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
350 ASSERT_EQ(1u, encoder_factory.encoders().size()); 350 ASSERT_EQ(1u, encoder_factory.encoders().size());
351 EXPECT_TRUE(channel->SetSend(true)); 351 EXPECT_TRUE(channel->SetSend(true));
352 352
353 cricket::FakeVideoCapturer capturer; 353 cricket::FakeVideoCapturer capturer;
354 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 354 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
355 EXPECT_EQ(cricket::CS_RUNNING, 355 EXPECT_EQ(cricket::CS_RUNNING,
356 capturer.Start(capturer.GetSupportedFormats()->front())); 356 capturer.Start(capturer.GetSupportedFormats()->front()));
357 EXPECT_TRUE(capturer.CaptureFrame()); 357 EXPECT_TRUE(capturer.CaptureFrame());
358 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, 358 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0,
359 kTimeout); 359 kTimeout);
360 360
361 // Sending one frame will have reallocated the encoder since input size 361 // Sending one frame will have reallocated the encoder since input size
362 // changes from a small default to the actual frame width/height. 362 // changes from a small default to the actual frame width/height.
363 int num_created_encoders = encoder_factory.GetNumCreatedEncoders(); 363 int num_created_encoders = encoder_factory.GetNumCreatedEncoders();
364 EXPECT_EQ(num_created_encoders, 2); 364 EXPECT_EQ(num_created_encoders, 2);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); 432 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
433 call_.reset(fake_call); 433 call_.reset(fake_call);
434 std::unique_ptr<VideoMediaChannel> channel( 434 std::unique_ptr<VideoMediaChannel> channel(
435 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 435 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
436 436
437 EXPECT_TRUE( 437 EXPECT_TRUE(
438 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 438 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
439 439
440 FakeVideoCapturer capturer; 440 FakeVideoCapturer capturer;
441 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); 441 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
442 capturer.Start(cricket::VideoFormat(1280, 720, 442 capturer.Start(cricket::VideoFormat(1280, 720,
443 cricket::VideoFormat::FpsToInterval(60), 443 cricket::VideoFormat::FpsToInterval(60),
444 cricket::FOURCC_I420)); 444 cricket::FOURCC_I420));
445 channel->SetSend(true); 445 channel->SetSend(true);
446 446
447 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; 447 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
448 448
449 EXPECT_TRUE(capturer.CaptureFrame()); 449 EXPECT_TRUE(capturer.CaptureFrame());
450 int64_t last_timestamp = stream->GetLastTimestamp(); 450 int64_t last_timestamp = stream->GetLastTimestamp();
451 for (int i = 0; i < 10; i++) { 451 for (int i = 0; i < 10; i++) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 call_.reset(fake_call); 493 call_.reset(fake_call);
494 std::unique_ptr<VideoMediaChannel> channel( 494 std::unique_ptr<VideoMediaChannel> channel(
495 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 495 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
496 496
497 EXPECT_TRUE( 497 EXPECT_TRUE(
498 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 498 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
499 channel->SetSend(true); 499 channel->SetSend(true);
500 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; 500 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
501 501
502 FakeVideoCapturer capturer1; 502 FakeVideoCapturer capturer1;
503 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); 503 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer1));
504 504
505 cricket::CapturedFrame frame; 505 cricket::CapturedFrame frame;
506 frame.width = 1280; 506 frame.width = 1280;
507 frame.height = 720; 507 frame.height = 720;
508 frame.fourcc = cricket::FOURCC_I420; 508 frame.fourcc = cricket::FOURCC_I420;
509 frame.data_size = frame.width * frame.height + 509 frame.data_size = frame.width * frame.height +
510 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); 510 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2);
511 std::unique_ptr<char[]> data(new char[frame.data_size]); 511 std::unique_ptr<char[]> data(new char[frame.data_size]);
512 frame.data = data.get(); 512 frame.data = data.get();
513 memset(frame.data, 1, frame.data_size); 513 memset(frame.data, 1, frame.data_size);
514 const int kInitialTimestamp = 123456; 514 const int kInitialTimestamp = 123456;
515 frame.time_stamp = kInitialTimestamp; 515 frame.time_stamp = kInitialTimestamp;
516 516
517 // Deliver initial frame. 517 // Deliver initial frame.
518 capturer1.SignalCapturedFrame(&frame); 518 capturer1.SignalCapturedFrame(&frame);
519 // Deliver next frame 1 second later. 519 // Deliver next frame 1 second later.
520 frame.time_stamp += rtc::kNumNanosecsPerSec; 520 frame.time_stamp += rtc::kNumNanosecsPerSec;
521 rtc::Thread::Current()->SleepMs(1000); 521 rtc::Thread::Current()->SleepMs(1000);
522 capturer1.SignalCapturedFrame(&frame); 522 capturer1.SignalCapturedFrame(&frame);
523 523
524 int64_t capturer1_last_timestamp = stream->GetLastTimestamp(); 524 int64_t capturer1_last_timestamp = stream->GetLastTimestamp();
525 // Reset input source, should still be continuous even though input-frame 525 // Reset input source, should still be continuous even though input-frame
526 // timestamp is less than before. 526 // timestamp is less than before.
527 FakeVideoCapturer capturer2; 527 FakeVideoCapturer capturer2;
528 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer2)); 528 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer2));
529 529
530 rtc::Thread::Current()->SleepMs(1); 530 rtc::Thread::Current()->SleepMs(1);
531 // Deliver with a timestamp (10 seconds) before the previous initial one, 531 // Deliver with a timestamp (10 seconds) before the previous initial one,
532 // these should not be related at all anymore and it should still work fine. 532 // these should not be related at all anymore and it should still work fine.
533 frame.time_stamp = kInitialTimestamp - 10000; 533 frame.time_stamp = kInitialTimestamp - 10000;
534 capturer2.SignalCapturedFrame(&frame); 534 capturer2.SignalCapturedFrame(&frame);
535 535
536 // New timestamp should be at least 1ms in the future and not old. 536 // New timestamp should be at least 1ms in the future and not old.
537 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp); 537 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp);
538 538
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 std::unique_ptr<VideoMediaChannel> channel( 578 std::unique_ptr<VideoMediaChannel> channel(
579 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 579 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
580 580
581 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 581 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
582 582
583 EXPECT_TRUE( 583 EXPECT_TRUE(
584 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); 584 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs)));
585 EXPECT_TRUE(channel->SetSend(true)); 585 EXPECT_TRUE(channel->SetSend(true));
586 586
587 cricket::FakeVideoCapturer capturer; 587 cricket::FakeVideoCapturer capturer;
588 EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), &capturer)); 588 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
589 EXPECT_EQ(cricket::CS_RUNNING, 589 EXPECT_EQ(cricket::CS_RUNNING,
590 capturer.Start(capturer.GetSupportedFormats()->front())); 590 capturer.Start(capturer.GetSupportedFormats()->front()));
591 EXPECT_TRUE(capturer.CaptureFrame()); 591 EXPECT_TRUE(capturer.CaptureFrame());
592 592
593 EXPECT_GT(encoder_factory.encoders().size(), 1u); 593 EXPECT_GT(encoder_factory.encoders().size(), 1u);
594 594
595 // Verify that encoders are configured for simulcast through adapter 595 // Verify that encoders are configured for simulcast through adapter
596 // (increasing resolution and only configured to send one stream each). 596 // (increasing resolution and only configured to send one stream each).
597 int prev_width = -1; 597 int prev_width = -1;
598 for (size_t i = 0; i < encoder_factory.encoders().size(); ++i) { 598 for (size_t i = 0; i < encoder_factory.encoders().size(); ++i) {
599 webrtc::VideoCodec codec_settings = 599 webrtc::VideoCodec codec_settings =
600 encoder_factory.encoders()[i]->GetCodecSettings(); 600 encoder_factory.encoders()[i]->GetCodecSettings();
601 EXPECT_EQ(0, codec_settings.numberOfSimulcastStreams); 601 EXPECT_EQ(0, codec_settings.numberOfSimulcastStreams);
602 EXPECT_GT(codec_settings.width, prev_width); 602 EXPECT_GT(codec_settings.width, prev_width);
603 prev_width = codec_settings.width; 603 prev_width = codec_settings.width;
604 } 604 }
605 605
606 EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), NULL)); 606 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, nullptr));
607 607
608 channel.reset(); 608 channel.reset();
609 ASSERT_EQ(0u, encoder_factory.encoders().size()); 609 ASSERT_EQ(0u, encoder_factory.encoders().size());
610 } 610 }
611 611
612 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { 612 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) {
613 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 613 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
614 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); 614 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264");
615 std::vector<cricket::VideoCodec> codecs; 615 std::vector<cricket::VideoCodec> codecs;
616 codecs.push_back(kH264Codec); 616 codecs.push_back(kH264Codec);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 659 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
660 660
661 EXPECT_TRUE( 661 EXPECT_TRUE(
662 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); 662 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs)));
663 EXPECT_TRUE(channel->SetSend(true)); 663 EXPECT_TRUE(channel->SetSend(true));
664 664
665 // Send a fake frame, or else the media engine will configure the simulcast 665 // Send a fake frame, or else the media engine will configure the simulcast
666 // encoder adapter at a low-enough size that it'll only create a single 666 // encoder adapter at a low-enough size that it'll only create a single
667 // encoder layer. 667 // encoder layer.
668 cricket::FakeVideoCapturer capturer; 668 cricket::FakeVideoCapturer capturer;
669 EXPECT_TRUE(channel->SetCapturer(ssrcs.front(), &capturer)); 669 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
670 EXPECT_EQ(cricket::CS_RUNNING, 670 EXPECT_EQ(cricket::CS_RUNNING,
671 capturer.Start(capturer.GetSupportedFormats()->front())); 671 capturer.Start(capturer.GetSupportedFormats()->front()));
672 EXPECT_TRUE(capturer.CaptureFrame()); 672 EXPECT_TRUE(capturer.CaptureFrame());
673 673
674 ASSERT_GT(encoder_factory.encoders().size(), 1u); 674 ASSERT_GT(encoder_factory.encoders().size(), 1u);
675 EXPECT_EQ(webrtc::kVideoCodecVP8, 675 EXPECT_EQ(webrtc::kVideoCodecVP8,
676 encoder_factory.encoders()[0]->GetCodecSettings().codecType); 676 encoder_factory.encoders()[0]->GetCodecSettings().codecType);
677 677
678 channel.reset(); 678 channel.reset();
679 // Make sure DestroyVideoEncoder was called on the factory. 679 // Make sure DestroyVideoEncoder was called on the factory.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 713 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
714 714
715 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 715 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
716 EXPECT_TRUE( 716 EXPECT_TRUE(
717 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs))); 717 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs)));
718 718
719 // Send a frame of 720p. This should trigger a "real" encoder initialization. 719 // Send a frame of 720p. This should trigger a "real" encoder initialization.
720 cricket::VideoFormat format( 720 cricket::VideoFormat format(
721 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); 721 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420);
722 cricket::FakeVideoCapturer capturer; 722 cricket::FakeVideoCapturer capturer;
723 EXPECT_TRUE(channel->SetCapturer(ssrcs[0], &capturer)); 723 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, &capturer));
724 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format)); 724 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
725 EXPECT_TRUE(capturer.CaptureFrame()); 725 EXPECT_TRUE(capturer.CaptureFrame());
726 726
727 ASSERT_EQ(1u, encoder_factory.encoders().size()); 727 ASSERT_EQ(1u, encoder_factory.encoders().size());
728 FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0]; 728 FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0];
729 EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType); 729 EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType);
730 EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams); 730 EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams);
731 EXPECT_TRUE(channel->SetCapturer(ssrcs[0], nullptr)); 731 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr));
732 } 732 }
733 733
734 // Test that external codecs are added to the end of the supported codec list. 734 // Test that external codecs are added to the end of the supported codec list.
735 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { 735 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) {
736 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 736 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
737 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecUnknown, 737 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecUnknown,
738 "FakeExternalCodec"); 738 "FakeExternalCodec");
739 engine_.SetExternalEncoderFactory(&encoder_factory); 739 engine_.SetExternalEncoderFactory(&encoder_factory);
740 engine_.Init(); 740 engine_.Init();
741 741
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 void TestReceiverLocalSsrcConfiguration(bool receiver_first); 1042 void TestReceiverLocalSsrcConfiguration(bool receiver_first);
1043 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, 1043 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type,
1044 bool expect_created_receive_stream); 1044 bool expect_created_receive_stream);
1045 1045
1046 FakeVideoSendStream* SetDenoisingOption( 1046 FakeVideoSendStream* SetDenoisingOption(
1047 uint32_t ssrc, 1047 uint32_t ssrc,
1048 cricket::FakeVideoCapturer* capturer, 1048 cricket::FakeVideoCapturer* capturer,
1049 bool enabled) { 1049 bool enabled) {
1050 cricket::VideoOptions options; 1050 cricket::VideoOptions options;
1051 options.video_noise_reduction = rtc::Optional<bool>(enabled); 1051 options.video_noise_reduction = rtc::Optional<bool>(enabled);
1052 channel_->SetVideoSend(ssrc, true, &options); 1052 EXPECT_TRUE(channel_->SetVideoSend(ssrc, true, &options, capturer));
1053 // Options only take effect on the next frame. 1053 // Options only take effect on the next frame.
1054 EXPECT_TRUE(capturer->CaptureFrame()); 1054 EXPECT_TRUE(capturer->CaptureFrame());
1055 1055
1056 return fake_call_->GetVideoSendStreams().back(); 1056 return fake_call_->GetVideoSendStreams().back();
1057 } 1057 }
1058 1058
1059 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { 1059 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) {
1060 const int kRtxSsrcOffset = 0xDEADBEEF; 1060 const int kRtxSsrcOffset = 0xDEADBEEF;
1061 last_ssrc_ += 3; 1061 last_ssrc_ += 3;
1062 std::vector<uint32_t> ssrcs; 1062 std::vector<uint32_t> ssrcs;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 channel_->SetSend(false); 1530 channel_->SetSend(false);
1531 1531
1532 FakeVideoSendStream* stream = AddSendStream(); 1532 FakeVideoSendStream* stream = AddSendStream();
1533 1533
1534 // No frames entered, using default dimensions. 1534 // No frames entered, using default dimensions.
1535 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 1535 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
1536 EXPECT_EQ(176u, streams[0].width); 1536 EXPECT_EQ(176u, streams[0].width);
1537 EXPECT_EQ(144u, streams[0].height); 1537 EXPECT_EQ(144u, streams[0].height);
1538 1538
1539 cricket::FakeVideoCapturer capturer; 1539 cricket::FakeVideoCapturer capturer;
1540 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1540 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1541 EXPECT_EQ(cricket::CS_RUNNING, 1541 EXPECT_EQ(cricket::CS_RUNNING,
1542 capturer.Start(capturer.GetSupportedFormats()->front())); 1542 capturer.Start(capturer.GetSupportedFormats()->front()));
1543 EXPECT_TRUE(capturer.CaptureFrame()); 1543 EXPECT_TRUE(capturer.CaptureFrame());
1544 1544
1545 // Frame entered, should be reconfigured to new dimensions. 1545 // Frame entered, should be reconfigured to new dimensions.
1546 streams = stream->GetVideoStreams(); 1546 streams = stream->GetVideoStreams();
1547 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); 1547 EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
1548 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); 1548 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
1549 // No frames should have been actually put in there though. 1549 // No frames should have been actually put in there though.
1550 EXPECT_EQ(0, stream->GetNumberOfSwappedFrames()); 1550 EXPECT_EQ(0, stream->GetNumberOfSwappedFrames());
1551 1551
1552 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1552 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1553 } 1553 }
1554 1554
1555 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { 1555 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
1556 static const int kScreenshareMinBitrateKbps = 800; 1556 static const int kScreenshareMinBitrateKbps = 800;
1557 cricket::VideoCodec codec = kVp8Codec360p; 1557 cricket::VideoCodec codec = kVp8Codec360p;
1558 cricket::VideoSendParameters parameters; 1558 cricket::VideoSendParameters parameters;
1559 parameters.codecs.push_back(codec); 1559 parameters.codecs.push_back(codec);
1560 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1560 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1561 AddSendStream(); 1561 AddSendStream();
1562 1562
1563 cricket::FakeVideoCapturer capturer;
1563 VideoOptions min_bitrate_options; 1564 VideoOptions min_bitrate_options;
1564 min_bitrate_options.screencast_min_bitrate_kbps = 1565 min_bitrate_options.screencast_min_bitrate_kbps =
1565 rtc::Optional<int>(kScreenshareMinBitrateKbps); 1566 rtc::Optional<int>(kScreenshareMinBitrateKbps);
1566 channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options); 1567 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options,
1567 1568 &capturer));
1568 cricket::FakeVideoCapturer capturer;
1569 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1570 cricket::VideoFormat capture_format_hd = 1569 cricket::VideoFormat capture_format_hd =
1571 capturer.GetSupportedFormats()->front(); 1570 capturer.GetSupportedFormats()->front();
1572 EXPECT_EQ(1280, capture_format_hd.width); 1571 EXPECT_EQ(1280, capture_format_hd.width);
1573 EXPECT_EQ(720, capture_format_hd.height); 1572 EXPECT_EQ(720, capture_format_hd.height);
1574 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 1573 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
1575 1574
1576 EXPECT_TRUE(channel_->SetSend(true)); 1575 EXPECT_TRUE(channel_->SetSend(true));
1577 1576
1578 EXPECT_TRUE(capturer.CaptureFrame()); 1577 EXPECT_TRUE(capturer.CaptureFrame());
1579 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1578 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1580 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1579 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1581 1580
1582 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 1581 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1583 1582
1584 // Verify non-screencast settings. 1583 // Verify non-screencast settings.
1585 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); 1584 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
1586 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1585 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1587 encoder_config.content_type); 1586 encoder_config.content_type);
1588 EXPECT_EQ(codec.width, encoder_config.streams.front().width); 1587 EXPECT_EQ(codec.width, encoder_config.streams.front().width);
1589 EXPECT_EQ(codec.height, encoder_config.streams.front().height); 1588 EXPECT_EQ(codec.height, encoder_config.streams.front().height);
1590 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) 1589 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
1591 << "Non-screenshare shouldn't use min-transmit bitrate."; 1590 << "Non-screenshare shouldn't use min-transmit bitrate.";
1592 1591
1593 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); 1592 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1594 // Removing a capturer triggers a black frame to be sent. 1593 // Removing a capturer triggers a black frame to be sent.
1595 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 1594 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1596 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1597 VideoOptions screencast_options; 1595 VideoOptions screencast_options;
1598 screencast_options.is_screencast = rtc::Optional<bool>(true); 1596 screencast_options.is_screencast = rtc::Optional<bool>(true);
1599 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &screencast_options)); 1597 EXPECT_TRUE(
1598 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer));
1600 EXPECT_TRUE(capturer.CaptureFrame()); 1599 EXPECT_TRUE(capturer.CaptureFrame());
1601 // Send stream not recreated after option change. 1600 // Send stream not recreated after option change.
1602 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); 1601 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front());
1603 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 1602 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
1604 1603
1605 // Verify screencast settings. 1604 // Verify screencast settings.
1606 encoder_config = send_stream->GetEncoderConfig(); 1605 encoder_config = send_stream->GetEncoderConfig();
1607 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1606 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1608 encoder_config.content_type); 1607 encoder_config.content_type);
1609 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, 1608 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
1610 encoder_config.min_transmit_bitrate_bps); 1609 encoder_config.min_transmit_bitrate_bps);
1611 1610
1612 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width); 1611 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width);
1613 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); 1612 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
1614 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); 1613 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
1615 1614
1616 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1615 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1617 } 1616 }
1618 1617
1619 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { 1618 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) {
1620 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1619 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1621 ASSERT_TRUE( 1620 ASSERT_TRUE(
1622 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 1621 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
1623 EXPECT_TRUE(channel_->SetSend(true)); 1622 EXPECT_TRUE(channel_->SetSend(true));
1624 1623
1625 cricket::FakeVideoCapturer capturer; 1624 cricket::FakeVideoCapturer capturer;
1626 EXPECT_TRUE(channel_->SetCapturer(kSsrc, &capturer)); 1625 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, &capturer));
1627 EXPECT_EQ(cricket::CS_RUNNING, 1626 EXPECT_EQ(cricket::CS_RUNNING,
1628 capturer.Start(capturer.GetSupportedFormats()->front())); 1627 capturer.Start(capturer.GetSupportedFormats()->front()));
1629 EXPECT_TRUE(capturer.CaptureFrame()); 1628 EXPECT_TRUE(capturer.CaptureFrame());
1630 1629
1631 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1630 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1632 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front(); 1631 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front();
1633 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig(); 1632 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig();
1634 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1633 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1635 encoder_config.content_type); 1634 encoder_config.content_type);
1636 1635
1637 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames()); 1636 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames());
1638 1637
1639 /* Switch to screencast source. We expect a reconfigure of the 1638 /* Switch to screencast source. We expect a reconfigure of the
1640 * encoder, but no change of the send stream. */ 1639 * encoder, but no change of the send stream. */
1641 struct VideoOptions video_options; 1640 struct VideoOptions video_options;
1642 video_options.is_screencast = rtc::Optional<bool>(true); 1641 video_options.is_screencast = rtc::Optional<bool>(true);
1643 channel_->SetVideoSend(kSsrc, true, &video_options); 1642 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer));
1644 1643
1645 EXPECT_TRUE(capturer.CaptureFrame()); 1644 EXPECT_TRUE(capturer.CaptureFrame());
1646 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1645 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1647 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); 1646 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front());
1648 EXPECT_EQ(2, stream->GetNumberOfSwappedFrames()); 1647 EXPECT_EQ(2, stream->GetNumberOfSwappedFrames());
1649 1648
1650 encoder_config = stream->GetEncoderConfig(); 1649 encoder_config = stream->GetEncoderConfig();
1651 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1650 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1652 encoder_config.content_type); 1651 encoder_config.content_type);
1653 1652
1654 /* Switch back. */ 1653 /* Switch back. */
1655 video_options.is_screencast = rtc::Optional<bool>(false); 1654 video_options.is_screencast = rtc::Optional<bool>(false);
1656 channel_->SetVideoSend(kSsrc, true, &video_options); 1655 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer));
1657 1656
1658 EXPECT_TRUE(capturer.CaptureFrame()); 1657 EXPECT_TRUE(capturer.CaptureFrame());
1659 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1658 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1660 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); 1659 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front());
1661 EXPECT_EQ(3, stream->GetNumberOfSwappedFrames()); 1660 EXPECT_EQ(3, stream->GetNumberOfSwappedFrames());
1662 1661
1663 encoder_config = stream->GetEncoderConfig(); 1662 encoder_config = stream->GetEncoderConfig();
1664 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1663 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1665 encoder_config.content_type); 1664 encoder_config.content_type);
1666 1665
1667 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); 1666 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr));
1668 } 1667 }
1669 1668
1670 TEST_F(WebRtcVideoChannel2Test, 1669 TEST_F(WebRtcVideoChannel2Test,
1671 ConferenceModeScreencastConfiguresTemporalLayer) { 1670 ConferenceModeScreencastConfiguresTemporalLayer) {
1672 static const int kConferenceScreencastTemporalBitrateBps = 1671 static const int kConferenceScreencastTemporalBitrateBps =
1673 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; 1672 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000;
1674 send_parameters_.conference_mode = true; 1673 send_parameters_.conference_mode = true;
1675 channel_->SetSendParameters(send_parameters_); 1674 channel_->SetSendParameters(send_parameters_);
1676 1675
1677 AddSendStream(); 1676 AddSendStream();
1678 VideoOptions options; 1677 VideoOptions options;
1679 options.is_screencast = rtc::Optional<bool>(true); 1678 options.is_screencast = rtc::Optional<bool>(true);
1680 channel_->SetVideoSend(last_ssrc_, true, &options);
1681 cricket::FakeVideoCapturer capturer; 1679 cricket::FakeVideoCapturer capturer;
1682 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1680 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1683 cricket::VideoFormat capture_format_hd = 1681 cricket::VideoFormat capture_format_hd =
1684 capturer.GetSupportedFormats()->front(); 1682 capturer.GetSupportedFormats()->front();
1685 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 1683 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
1686 1684
1687 EXPECT_TRUE(channel_->SetSend(true)); 1685 EXPECT_TRUE(channel_->SetSend(true));
1688 1686
1689 EXPECT_TRUE(capturer.CaptureFrame()); 1687 EXPECT_TRUE(capturer.CaptureFrame());
1690 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1688 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1691 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1689 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1692 1690
1693 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); 1691 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
1694 1692
1695 // Verify screencast settings. 1693 // Verify screencast settings.
1696 encoder_config = send_stream->GetEncoderConfig(); 1694 encoder_config = send_stream->GetEncoderConfig();
1697 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1695 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1698 encoder_config.content_type); 1696 encoder_config.content_type);
1699 ASSERT_EQ(1u, encoder_config.streams.size()); 1697 ASSERT_EQ(1u, encoder_config.streams.size());
1700 ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size()); 1698 ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size());
1701 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, 1699 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
1702 encoder_config.streams[0].temporal_layer_thresholds_bps[0]); 1700 encoder_config.streams[0].temporal_layer_thresholds_bps[0]);
1703 1701
1704 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1702 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1705 } 1703 }
1706 1704
1707 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { 1705 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) {
1708 FakeVideoSendStream* stream = AddSendStream(); 1706 FakeVideoSendStream* stream = AddSendStream();
1709 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1707 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1710 } 1708 }
1711 1709
1712 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { 1710 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) {
1713 MediaConfig media_config = MediaConfig(); 1711 MediaConfig media_config = MediaConfig();
1714 media_config.video.suspend_below_min_bitrate = true; 1712 media_config.video.suspend_below_min_bitrate = true;
(...skipping 29 matching lines...) Expand all
1744 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1742 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1745 1743
1746 // Single-stream settings should apply with RTX as well (verifies that we 1744 // Single-stream settings should apply with RTX as well (verifies that we
1747 // check number of regular SSRCs and not StreamParams::ssrcs which contains 1745 // check number of regular SSRCs and not StreamParams::ssrcs which contains
1748 // both RTX and regular SSRCs). 1746 // both RTX and regular SSRCs).
1749 FakeVideoSendStream* stream = SetUpSimulcast(false, true); 1747 FakeVideoSendStream* stream = SetUpSimulcast(false, true);
1750 1748
1751 cricket::FakeVideoCapturer capturer; 1749 cricket::FakeVideoCapturer capturer;
1752 EXPECT_EQ(cricket::CS_RUNNING, 1750 EXPECT_EQ(cricket::CS_RUNNING,
1753 capturer.Start(capturer.GetSupportedFormats()->front())); 1751 capturer.Start(capturer.GetSupportedFormats()->front()));
1754 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1752 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1755 channel_->SetSend(true); 1753 channel_->SetSend(true);
1756 1754
1757 EXPECT_TRUE(capturer.CaptureFrame()); 1755 EXPECT_TRUE(capturer.CaptureFrame());
1758 1756
1759 webrtc::VideoCodecVP8 vp8_settings; 1757 webrtc::VideoCodecVP8 vp8_settings;
1760 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1758 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1761 EXPECT_TRUE(vp8_settings.denoisingOn) 1759 EXPECT_TRUE(vp8_settings.denoisingOn)
1762 << "VP8 denoising should be on by default."; 1760 << "VP8 denoising should be on by default.";
1763 1761
1764 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1762 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1765 1763
1766 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1764 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1767 EXPECT_FALSE(vp8_settings.denoisingOn); 1765 EXPECT_FALSE(vp8_settings.denoisingOn);
1768 EXPECT_TRUE(vp8_settings.automaticResizeOn); 1766 EXPECT_TRUE(vp8_settings.automaticResizeOn);
1769 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1767 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1770 1768
1771 stream = SetDenoisingOption(last_ssrc_, &capturer, true); 1769 stream = SetDenoisingOption(last_ssrc_, &capturer, true);
1772 1770
1773 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1771 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1774 EXPECT_TRUE(vp8_settings.denoisingOn); 1772 EXPECT_TRUE(vp8_settings.denoisingOn);
1775 EXPECT_TRUE(vp8_settings.automaticResizeOn); 1773 EXPECT_TRUE(vp8_settings.automaticResizeOn);
1776 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1774 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1777 1775
1778 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1776 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1779 stream = SetUpSimulcast(true, false); 1777 stream = SetUpSimulcast(true, false);
1780 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1778 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1781 channel_->SetSend(true); 1779 channel_->SetSend(true);
1782 EXPECT_TRUE(capturer.CaptureFrame()); 1780 EXPECT_TRUE(capturer.CaptureFrame());
1783 1781
1784 EXPECT_EQ(3, stream->GetVideoStreams().size()); 1782 EXPECT_EQ(3, stream->GetVideoStreams().size());
1785 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1783 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1786 // Autmatic resize off when using simulcast. 1784 // Autmatic resize off when using simulcast.
1787 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1785 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1788 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1786 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1789 1787
1790 // In screen-share mode, denoising is forced off and simulcast disabled. 1788 // In screen-share mode, denoising is forced off and simulcast disabled.
1791 VideoOptions options; 1789 VideoOptions options;
1792 options.is_screencast = rtc::Optional<bool>(true); 1790 options.is_screencast = rtc::Optional<bool>(true);
1793 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 1791 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1794 1792
1795 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1793 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1796 1794
1797 EXPECT_EQ(1, stream->GetVideoStreams().size()); 1795 EXPECT_EQ(1, stream->GetVideoStreams().size());
1798 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1796 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1799 EXPECT_FALSE(vp8_settings.denoisingOn); 1797 EXPECT_FALSE(vp8_settings.denoisingOn);
1800 // Resizing and frame dropping always off for screen sharing. 1798 // Resizing and frame dropping always off for screen sharing.
1801 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1799 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1802 EXPECT_FALSE(vp8_settings.frameDroppingOn); 1800 EXPECT_FALSE(vp8_settings.frameDroppingOn);
1803 1801
1804 stream = SetDenoisingOption(last_ssrc_, &capturer, true); 1802 stream = SetDenoisingOption(last_ssrc_, &capturer, true);
1805 1803
1806 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1804 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1807 EXPECT_FALSE(vp8_settings.denoisingOn); 1805 EXPECT_FALSE(vp8_settings.denoisingOn);
1808 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1806 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1809 EXPECT_FALSE(vp8_settings.frameDroppingOn); 1807 EXPECT_FALSE(vp8_settings.frameDroppingOn);
1810 1808
1811 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1809 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1812 } 1810 }
1813 1811
1814 class Vp9SettingsTest : public WebRtcVideoChannel2Test { 1812 class Vp9SettingsTest : public WebRtcVideoChannel2Test {
1815 public: 1813 public:
1816 Vp9SettingsTest() : Vp9SettingsTest("") {} 1814 Vp9SettingsTest() : Vp9SettingsTest("") {}
1817 explicit Vp9SettingsTest(const char* field_trials) 1815 explicit Vp9SettingsTest(const char* field_trials)
1818 : WebRtcVideoChannel2Test(field_trials) { 1816 : WebRtcVideoChannel2Test(field_trials) {
1819 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); 1817 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
1820 } 1818 }
1821 virtual ~Vp9SettingsTest() {} 1819 virtual ~Vp9SettingsTest() {}
(...skipping 17 matching lines...) Expand all
1839 TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { 1837 TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) {
1840 cricket::VideoSendParameters parameters; 1838 cricket::VideoSendParameters parameters;
1841 parameters.codecs.push_back(kVp9Codec); 1839 parameters.codecs.push_back(kVp9Codec);
1842 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1840 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1843 1841
1844 FakeVideoSendStream* stream = SetUpSimulcast(false, false); 1842 FakeVideoSendStream* stream = SetUpSimulcast(false, false);
1845 1843
1846 cricket::FakeVideoCapturer capturer; 1844 cricket::FakeVideoCapturer capturer;
1847 EXPECT_EQ(cricket::CS_RUNNING, 1845 EXPECT_EQ(cricket::CS_RUNNING,
1848 capturer.Start(capturer.GetSupportedFormats()->front())); 1846 capturer.Start(capturer.GetSupportedFormats()->front()));
1849 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1847 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1850 channel_->SetSend(true); 1848 channel_->SetSend(true);
1851 1849
1852 EXPECT_TRUE(capturer.CaptureFrame()); 1850 EXPECT_TRUE(capturer.CaptureFrame());
1853 1851
1854 webrtc::VideoCodecVP9 vp9_settings; 1852 webrtc::VideoCodecVP9 vp9_settings;
1855 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1853 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1856 EXPECT_FALSE(vp9_settings.denoisingOn) 1854 EXPECT_FALSE(vp9_settings.denoisingOn)
1857 << "VP9 denoising should be off by default."; 1855 << "VP9 denoising should be off by default.";
1858 1856
1859 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1857 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1860 1858
1861 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1859 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1862 EXPECT_FALSE(vp9_settings.denoisingOn); 1860 EXPECT_FALSE(vp9_settings.denoisingOn);
1863 // Frame dropping always on for real time video. 1861 // Frame dropping always on for real time video.
1864 EXPECT_TRUE(vp9_settings.frameDroppingOn); 1862 EXPECT_TRUE(vp9_settings.frameDroppingOn);
1865 1863
1866 stream = SetDenoisingOption(last_ssrc_, &capturer, true); 1864 stream = SetDenoisingOption(last_ssrc_, &capturer, true);
1867 1865
1868 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1866 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1869 EXPECT_TRUE(vp9_settings.denoisingOn); 1867 EXPECT_TRUE(vp9_settings.denoisingOn);
1870 EXPECT_TRUE(vp9_settings.frameDroppingOn); 1868 EXPECT_TRUE(vp9_settings.frameDroppingOn);
1871 1869
1872 // In screen-share mode, denoising is forced off. 1870 // In screen-share mode, denoising is forced off.
1873 VideoOptions options; 1871 VideoOptions options;
1874 options.is_screencast = rtc::Optional<bool>(true); 1872 options.is_screencast = rtc::Optional<bool>(true);
1875 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 1873 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1876 1874
1877 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1875 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1878 1876
1879 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1877 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1880 EXPECT_FALSE(vp9_settings.denoisingOn); 1878 EXPECT_FALSE(vp9_settings.denoisingOn);
1881 // Frame dropping always off for screen sharing. 1879 // Frame dropping always off for screen sharing.
1882 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1880 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1883 1881
1884 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1882 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1885 1883
1886 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1884 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1887 EXPECT_FALSE(vp9_settings.denoisingOn); 1885 EXPECT_FALSE(vp9_settings.denoisingOn);
1888 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1886 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1889 1887
1890 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1888 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1891 } 1889 }
1892 1890
1893 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest { 1891 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest {
1894 public: 1892 public:
1895 Vp9SettingsTestWithFieldTrial(const char* field_trials) 1893 Vp9SettingsTestWithFieldTrial(const char* field_trials)
1896 : Vp9SettingsTest(field_trials) {} 1894 : Vp9SettingsTest(field_trials) {}
1897 1895
1898 protected: 1896 protected:
1899 void VerifySettings(int num_spatial_layers, int num_temporal_layers) { 1897 void VerifySettings(int num_spatial_layers, int num_temporal_layers) {
1900 cricket::VideoSendParameters parameters; 1898 cricket::VideoSendParameters parameters;
1901 parameters.codecs.push_back(kVp9Codec); 1899 parameters.codecs.push_back(kVp9Codec);
1902 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1900 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1903 1901
1904 FakeVideoSendStream* stream = SetUpSimulcast(false, false); 1902 FakeVideoSendStream* stream = SetUpSimulcast(false, false);
1905 1903
1906 cricket::FakeVideoCapturer capturer; 1904 cricket::FakeVideoCapturer capturer;
1907 EXPECT_EQ(cricket::CS_RUNNING, 1905 EXPECT_EQ(cricket::CS_RUNNING,
1908 capturer.Start(capturer.GetSupportedFormats()->front())); 1906 capturer.Start(capturer.GetSupportedFormats()->front()));
1909 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1907 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1910 channel_->SetSend(true); 1908 channel_->SetSend(true);
1911 1909
1912 EXPECT_TRUE(capturer.CaptureFrame()); 1910 EXPECT_TRUE(capturer.CaptureFrame());
1913 1911
1914 webrtc::VideoCodecVP9 vp9_settings; 1912 webrtc::VideoCodecVP9 vp9_settings;
1915 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1913 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1916 EXPECT_EQ(num_spatial_layers, vp9_settings.numberOfSpatialLayers); 1914 EXPECT_EQ(num_spatial_layers, vp9_settings.numberOfSpatialLayers);
1917 EXPECT_EQ(num_temporal_layers, vp9_settings.numberOfTemporalLayers); 1915 EXPECT_EQ(num_temporal_layers, vp9_settings.numberOfTemporalLayers);
1918 1916
1919 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1917 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1920 } 1918 }
1921 }; 1919 };
1922 1920
1923 class Vp9SettingsTestWithNoFlag : public Vp9SettingsTestWithFieldTrial { 1921 class Vp9SettingsTestWithNoFlag : public Vp9SettingsTestWithFieldTrial {
1924 public: 1922 public:
1925 Vp9SettingsTestWithNoFlag() : Vp9SettingsTestWithFieldTrial("") {} 1923 Vp9SettingsTestWithNoFlag() : Vp9SettingsTestWithFieldTrial("") {}
1926 }; 1924 };
1927 1925
1928 TEST_F(Vp9SettingsTestWithNoFlag, VerifySettings) { 1926 TEST_F(Vp9SettingsTestWithNoFlag, VerifySettings) {
1929 const int kNumSpatialLayers = 1; 1927 const int kNumSpatialLayers = 1;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 parameters.codecs.push_back(codec); 1972 parameters.codecs.push_back(codec);
1975 1973
1976 MediaConfig media_config = MediaConfig(); 1974 MediaConfig media_config = MediaConfig();
1977 channel_.reset( 1975 channel_.reset(
1978 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 1976 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
1979 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1977 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1980 1978
1981 AddSendStream(); 1979 AddSendStream();
1982 1980
1983 cricket::FakeVideoCapturer capturer; 1981 cricket::FakeVideoCapturer capturer;
1984 ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1982 ASSERT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1985 ASSERT_EQ(cricket::CS_RUNNING, 1983 ASSERT_EQ(cricket::CS_RUNNING,
1986 capturer.Start(capturer.GetSupportedFormats()->front())); 1984 capturer.Start(capturer.GetSupportedFormats()->front()));
1987 ASSERT_TRUE(channel_->SetSend(true)); 1985 ASSERT_TRUE(channel_->SetSend(true));
1988 1986
1989 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1987 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1990 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1988 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1991 webrtc::LoadObserver* overuse_callback = 1989 webrtc::LoadObserver* overuse_callback =
1992 send_stream->GetConfig().overuse_callback; 1990 send_stream->GetConfig().overuse_callback;
1993 ASSERT_TRUE(overuse_callback != NULL); 1991 ASSERT_TRUE(overuse_callback != NULL);
1994 1992
(...skipping 29 matching lines...) Expand all
2024 EXPECT_EQ(1284 * 3 / 4, send_stream->GetLastWidth()); 2022 EXPECT_EQ(1284 * 3 / 4, send_stream->GetLastWidth());
2025 EXPECT_EQ(724 * 3 / 4, send_stream->GetLastHeight()); 2023 EXPECT_EQ(724 * 3 / 4, send_stream->GetLastHeight());
2026 2024
2027 // Trigger underuse which should go back up in resolution. 2025 // Trigger underuse which should go back up in resolution.
2028 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 2026 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
2029 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); 2027 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
2030 EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames()); 2028 EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames());
2031 EXPECT_EQ(1284, send_stream->GetLastWidth()); 2029 EXPECT_EQ(1284, send_stream->GetLastWidth());
2032 EXPECT_EQ(724, send_stream->GetLastHeight()); 2030 EXPECT_EQ(724, send_stream->GetLastHeight());
2033 2031
2034 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 2032 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2035 } 2033 }
2036 2034
2037 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 2035 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
2038 bool is_screenshare) { 2036 bool is_screenshare) {
2039 cricket::VideoCodec codec = kVp8Codec720p; 2037 cricket::VideoCodec codec = kVp8Codec720p;
2040 cricket::VideoSendParameters parameters; 2038 cricket::VideoSendParameters parameters;
2041 parameters.codecs.push_back(codec); 2039 parameters.codecs.push_back(codec);
2042 2040
2043 MediaConfig media_config = MediaConfig(); 2041 MediaConfig media_config = MediaConfig();
2044 if (!enable_overuse) { 2042 if (!enable_overuse) {
2045 media_config.video.enable_cpu_overuse_detection = false; 2043 media_config.video.enable_cpu_overuse_detection = false;
2046 } 2044 }
2047 channel_.reset( 2045 channel_.reset(
2048 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2046 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2049 2047
2050 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2048 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2051 2049
2052 AddSendStream(); 2050 AddSendStream();
2053 2051
2052 cricket::FakeVideoCapturer capturer;
2054 VideoOptions options; 2053 VideoOptions options;
2055 options.is_screencast = rtc::Optional<bool>(is_screenshare); 2054 options.is_screencast = rtc::Optional<bool>(is_screenshare);
2056 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 2055 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
2057
2058 cricket::FakeVideoCapturer capturer;
2059 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
2060 EXPECT_EQ(cricket::CS_RUNNING, 2056 EXPECT_EQ(cricket::CS_RUNNING,
2061 capturer.Start(capturer.GetSupportedFormats()->front())); 2057 capturer.Start(capturer.GetSupportedFormats()->front()));
2062 2058
2063 EXPECT_TRUE(channel_->SetSend(true)); 2059 EXPECT_TRUE(channel_->SetSend(true));
2064 2060
2065 // Trigger overuse. 2061 // Trigger overuse.
2066 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2062 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2067 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 2063 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
2068 webrtc::LoadObserver* overuse_callback = 2064 webrtc::LoadObserver* overuse_callback =
2069 send_stream->GetConfig().overuse_callback; 2065 send_stream->GetConfig().overuse_callback;
2070 2066
2071 if (!enable_overuse) { 2067 if (!enable_overuse) {
2072 ASSERT_TRUE(overuse_callback == NULL); 2068 ASSERT_TRUE(overuse_callback == NULL);
2073 2069
2074 EXPECT_TRUE(capturer.CaptureFrame()); 2070 EXPECT_TRUE(capturer.CaptureFrame());
2075 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2071 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2076 2072
2077 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 2073 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
2078 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 2074 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
2079 2075
2080 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 2076 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2081 return; 2077 return;
2082 } 2078 }
2083 2079
2084 ASSERT_TRUE(overuse_callback != NULL); 2080 ASSERT_TRUE(overuse_callback != NULL);
2085 EXPECT_TRUE(capturer.CaptureFrame()); 2081 EXPECT_TRUE(capturer.CaptureFrame());
2086 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2082 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2087 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2083 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2088 2084
2089 EXPECT_TRUE(capturer.CaptureFrame()); 2085 EXPECT_TRUE(capturer.CaptureFrame());
2090 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 2086 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
2091 2087
2092 if (is_screenshare) { 2088 if (is_screenshare) {
2093 // Do not adapt screen share. 2089 // Do not adapt screen share.
2094 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 2090 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
2095 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 2091 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
2096 } else { 2092 } else {
2097 EXPECT_LT(send_stream->GetLastWidth(), codec.width); 2093 EXPECT_LT(send_stream->GetLastWidth(), codec.width);
2098 EXPECT_LT(send_stream->GetLastHeight(), codec.height); 2094 EXPECT_LT(send_stream->GetLastHeight(), codec.height);
2099 } 2095 }
2100 2096
2101 // Trigger underuse which should go back to normal resolution. 2097 // Trigger underuse which should go back to normal resolution.
2102 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 2098 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
2103 EXPECT_TRUE(capturer.CaptureFrame()); 2099 EXPECT_TRUE(capturer.CaptureFrame());
2104 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 2100 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
2105 2101
2106 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 2102 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
2107 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 2103 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
2108 2104
2109 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 2105 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2110 } 2106 }
2111 2107
2112 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { 2108 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) {
2113 // Start at last timestamp to verify that wraparounds are estimated correctly. 2109 // Start at last timestamp to verify that wraparounds are estimated correctly.
2114 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; 2110 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu;
2115 static const int64_t kInitialNtpTimeMs = 1247891230; 2111 static const int64_t kInitialNtpTimeMs = 1247891230;
2116 static const int kFrameOffsetMs = 20; 2112 static const int kFrameOffsetMs = 20;
2117 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 2113 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2118 2114
2119 FakeVideoReceiveStream* stream = AddRecvStream(); 2115 FakeVideoReceiveStream* stream = AddRecvStream();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 2226
2231 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { 2227 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
2232 cricket::VideoSendParameters parameters; 2228 cricket::VideoSendParameters parameters;
2233 parameters.codecs.push_back(kVp8Codec720p); 2229 parameters.codecs.push_back(kVp8Codec720p);
2234 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2230 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2235 channel_->SetSend(true); 2231 channel_->SetSend(true);
2236 2232
2237 FakeVideoSendStream* stream = AddSendStream(); 2233 FakeVideoSendStream* stream = AddSendStream();
2238 2234
2239 cricket::FakeVideoCapturer capturer; 2235 cricket::FakeVideoCapturer capturer;
2240 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 2236 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2241 EXPECT_EQ(cricket::CS_RUNNING, 2237 EXPECT_EQ(cricket::CS_RUNNING,
2242 capturer.Start(capturer.GetSupportedFormats()->front())); 2238 capturer.Start(capturer.GetSupportedFormats()->front()));
2243 EXPECT_TRUE(capturer.CaptureFrame()); 2239 EXPECT_TRUE(capturer.CaptureFrame());
2244 2240
2245 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2241 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2246 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); 2242 EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
2247 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); 2243 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
2248 2244
2249 parameters.codecs.clear(); 2245 parameters.codecs.clear();
2250 parameters.codecs.push_back(kVp8Codec360p); 2246 parameters.codecs.push_back(kVp8Codec360p);
2251 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2247 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2252 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); 2248 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
2253 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); 2249 EXPECT_EQ(kVp8Codec360p.width, streams[0].width);
2254 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); 2250 EXPECT_EQ(kVp8Codec360p.height, streams[0].height);
2255 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 2251 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2256 } 2252 }
2257 2253
2258 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { 2254 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) {
2259 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 2255 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
2260 200000); 2256 200000);
2261 } 2257 }
2262 2258
2263 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { 2259 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) {
2264 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); 2260 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000);
2265 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); 2261 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 2305
2310 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { 2306 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) {
2311 cricket::VideoSendParameters parameters; 2307 cricket::VideoSendParameters parameters;
2312 parameters.codecs.push_back(kVp8Codec720p); 2308 parameters.codecs.push_back(kVp8Codec720p);
2313 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2309 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2314 channel_->SetSend(true); 2310 channel_->SetSend(true);
2315 2311
2316 FakeVideoSendStream* stream = AddSendStream(); 2312 FakeVideoSendStream* stream = AddSendStream();
2317 2313
2318 cricket::FakeVideoCapturer capturer; 2314 cricket::FakeVideoCapturer capturer;
2319 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 2315 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2320 EXPECT_EQ(cricket::CS_RUNNING, 2316 EXPECT_EQ(cricket::CS_RUNNING,
2321 capturer.Start(capturer.GetSupportedFormats()->front())); 2317 capturer.Start(capturer.GetSupportedFormats()->front()));
2322 2318
2323 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2319 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2324 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; 2320 int initial_max_bitrate_bps = streams[0].max_bitrate_bps;
2325 EXPECT_GT(initial_max_bitrate_bps, 0); 2321 EXPECT_GT(initial_max_bitrate_bps, 0);
2326 2322
2327 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; 2323 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
2328 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2324 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2329 // Insert a frame to update the encoder config. 2325 // Insert a frame to update the encoder config.
2330 EXPECT_TRUE(capturer.CaptureFrame()); 2326 EXPECT_TRUE(capturer.CaptureFrame());
2331 streams = stream->GetVideoStreams(); 2327 streams = stream->GetVideoStreams();
2332 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); 2328 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps);
2333 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); 2329 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2334 } 2330 }
2335 2331
2336 TEST_F(WebRtcVideoChannel2Test, 2332 TEST_F(WebRtcVideoChannel2Test,
2337 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { 2333 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) {
2338 cricket::VideoSendParameters parameters; 2334 cricket::VideoSendParameters parameters;
2339 parameters.codecs.push_back(kVp8Codec720p); 2335 parameters.codecs.push_back(kVp8Codec720p);
2340 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2336 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2341 channel_->SetSend(true); 2337 channel_->SetSend(true);
2342 2338
2343 FakeVideoSendStream* stream = AddSendStream( 2339 FakeVideoSendStream* stream = AddSendStream(
2344 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2340 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2345 2341
2346 // Send a frame to make sure this scales up to >1 stream (simulcast). 2342 // Send a frame to make sure this scales up to >1 stream (simulcast).
2347 cricket::FakeVideoCapturer capturer; 2343 cricket::FakeVideoCapturer capturer;
2348 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &capturer)); 2344 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &capturer));
2349 EXPECT_EQ(cricket::CS_RUNNING, 2345 EXPECT_EQ(cricket::CS_RUNNING,
2350 capturer.Start(capturer.GetSupportedFormats()->front())); 2346 capturer.Start(capturer.GetSupportedFormats()->front()));
2351 EXPECT_TRUE(capturer.CaptureFrame()); 2347 EXPECT_TRUE(capturer.CaptureFrame());
2352 2348
2353 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2349 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2354 ASSERT_GT(streams.size(), 1u) 2350 ASSERT_GT(streams.size(), 1u)
2355 << "Without simulcast this test doesn't make sense."; 2351 << "Without simulcast this test doesn't make sense.";
2356 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams); 2352 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2357 EXPECT_GT(initial_max_bitrate_bps, 0); 2353 EXPECT_GT(initial_max_bitrate_bps, 0);
2358 2354
2359 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; 2355 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
2360 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2356 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2361 // Insert a frame to update the encoder config. 2357 // Insert a frame to update the encoder config.
2362 EXPECT_TRUE(capturer.CaptureFrame()); 2358 EXPECT_TRUE(capturer.CaptureFrame());
2363 streams = stream->GetVideoStreams(); 2359 streams = stream->GetVideoStreams();
2364 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); 2360 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2365 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); 2361 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps);
2366 2362
2367 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); 2363 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2368 } 2364 }
2369 2365
2370 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { 2366 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) {
2371 static const char* kMaxQuantization = "21"; 2367 static const char* kMaxQuantization = "21";
2372 cricket::VideoSendParameters parameters; 2368 cricket::VideoSendParameters parameters;
2373 parameters.codecs.push_back(kVp8Codec); 2369 parameters.codecs.push_back(kVp8Codec);
2374 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; 2370 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization;
2375 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2371 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2376 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), 2372 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)),
2377 AddSendStream()->GetVideoStreams().back().max_qp); 2373 AddSendStream()->GetVideoStreams().back().max_qp);
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 2723
2728 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) { 2724 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) {
2729 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2725 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2730 2726
2731 // Capture format VGA. 2727 // Capture format VGA.
2732 cricket::FakeVideoCapturer video_capturer_vga; 2728 cricket::FakeVideoCapturer video_capturer_vga;
2733 const std::vector<cricket::VideoFormat>* formats = 2729 const std::vector<cricket::VideoFormat>* formats =
2734 video_capturer_vga.GetSupportedFormats(); 2730 video_capturer_vga.GetSupportedFormats();
2735 cricket::VideoFormat capture_format_vga = (*formats)[1]; 2731 cricket::VideoFormat capture_format_vga = (*formats)[1];
2736 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); 2732 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga));
2737 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga)); 2733 EXPECT_TRUE(
2734 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga));
2738 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2735 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2739 2736
2740 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); 2737 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
2741 cricket::VideoSendParameters parameters; 2738 cricket::VideoSendParameters parameters;
2742 parameters.codecs.push_back(send_codec); 2739 parameters.codecs.push_back(send_codec);
2743 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2740 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2744 EXPECT_TRUE(channel_->SetSend(true)); 2741 EXPECT_TRUE(channel_->SetSend(true));
2745 2742
2746 // Verify that the CpuOveruseObserver is registered and trigger downgrade. 2743 // Verify that the CpuOveruseObserver is registered and trigger downgrade.
2747 2744
(...skipping 17 matching lines...) Expand all
2765 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 2762 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
2766 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2763 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2767 info.Clear(); 2764 info.Clear();
2768 EXPECT_TRUE(channel_->GetStats(&info)); 2765 EXPECT_TRUE(channel_->GetStats(&info));
2769 ASSERT_EQ(1U, info.senders.size()); 2766 ASSERT_EQ(1U, info.senders.size());
2770 EXPECT_EQ(2, info.senders[0].adapt_changes); 2767 EXPECT_EQ(2, info.senders[0].adapt_changes);
2771 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_NONE, 2768 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_NONE,
2772 info.senders[0].adapt_reason); 2769 info.senders[0].adapt_reason);
2773 2770
2774 // No capturer (no adapter). Adapt changes from old adapter should be kept. 2771 // No capturer (no adapter). Adapt changes from old adapter should be kept.
2775 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], NULL)); 2772 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2776 info.Clear(); 2773 info.Clear();
2777 EXPECT_TRUE(channel_->GetStats(&info)); 2774 EXPECT_TRUE(channel_->GetStats(&info));
2778 ASSERT_EQ(1U, info.senders.size()); 2775 ASSERT_EQ(1U, info.senders.size());
2779 EXPECT_EQ(2, info.senders[0].adapt_changes); 2776 EXPECT_EQ(2, info.senders[0].adapt_changes);
2780 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_NONE, 2777 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_NONE,
2781 info.senders[0].adapt_reason); 2778 info.senders[0].adapt_reason);
2782 2779
2783 // Set new capturer, capture format HD. 2780 // Set new capturer, capture format HD.
2784 cricket::FakeVideoCapturer video_capturer_hd; 2781 cricket::FakeVideoCapturer video_capturer_hd;
2785 cricket::VideoFormat capture_format_hd = (*formats)[0]; 2782 cricket::VideoFormat capture_format_hd = (*formats)[0];
2786 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_hd.Start(capture_format_hd)); 2783 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_hd.Start(capture_format_hd));
2787 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_hd)); 2784 EXPECT_TRUE(
2785 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_hd));
2788 EXPECT_TRUE(video_capturer_hd.CaptureFrame()); 2786 EXPECT_TRUE(video_capturer_hd.CaptureFrame());
2789 2787
2790 // Trigger overuse, HD -> adapt (OnCpuResolutionRequest downgrade) -> HD/2. 2788 // Trigger overuse, HD -> adapt (OnCpuResolutionRequest downgrade) -> HD/2.
2791 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2789 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2792 EXPECT_TRUE(video_capturer_hd.CaptureFrame()); 2790 EXPECT_TRUE(video_capturer_hd.CaptureFrame());
2793 info.Clear(); 2791 info.Clear();
2794 EXPECT_TRUE(channel_->GetStats(&info)); 2792 EXPECT_TRUE(channel_->GetStats(&info));
2795 ASSERT_EQ(1U, info.senders.size()); 2793 ASSERT_EQ(1U, info.senders.size());
2796 EXPECT_EQ(3, info.senders[0].adapt_changes); 2794 EXPECT_EQ(3, info.senders[0].adapt_changes);
2797 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_CPU, 2795 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_CPU,
2798 info.senders[0].adapt_reason); 2796 info.senders[0].adapt_reason);
2799 2797
2800 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], NULL)); 2798 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2801 } 2799 }
2802 2800
2803 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) { 2801 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) {
2804 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2802 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2805 2803
2806 // Capture format VGA. 2804 // Capture format VGA.
2807 cricket::FakeVideoCapturer video_capturer_vga; 2805 cricket::FakeVideoCapturer video_capturer_vga;
2808 const std::vector<cricket::VideoFormat>* formats = 2806 const std::vector<cricket::VideoFormat>* formats =
2809 video_capturer_vga.GetSupportedFormats(); 2807 video_capturer_vga.GetSupportedFormats();
2810 cricket::VideoFormat capture_format_vga = (*formats)[1]; 2808 cricket::VideoFormat capture_format_vga = (*formats)[1];
2811 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); 2809 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga));
2812 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga)); 2810 EXPECT_TRUE(
2811 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga));
2813 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2812 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2814 2813
2815 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); 2814 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
2816 cricket::VideoSendParameters parameters; 2815 cricket::VideoSendParameters parameters;
2817 parameters.codecs.push_back(send_codec); 2816 parameters.codecs.push_back(send_codec);
2818 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2817 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2819 EXPECT_TRUE(channel_->SetSend(true)); 2818 EXPECT_TRUE(channel_->SetSend(true));
2820 2819
2821 // Verify that the CpuOveruseObserver is registered and trigger downgrade. 2820 // Verify that the CpuOveruseObserver is registered and trigger downgrade.
2822 2821
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2855 2854
2856 // Reset bandwidth limitation state -> adapt NONE. 2855 // Reset bandwidth limitation state -> adapt NONE.
2857 stats.bw_limited_resolution = false; 2856 stats.bw_limited_resolution = false;
2858 fake_call_->GetVideoSendStreams().front()->SetStats(stats); 2857 fake_call_->GetVideoSendStreams().front()->SetStats(stats);
2859 info.Clear(); 2858 info.Clear();
2860 EXPECT_TRUE(channel_->GetStats(&info)); 2859 EXPECT_TRUE(channel_->GetStats(&info));
2861 ASSERT_EQ(1U, info.senders.size()); 2860 ASSERT_EQ(1U, info.senders.size());
2862 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_NONE, 2861 EXPECT_EQ(CoordinatedVideoAdapter::ADAPTREASON_NONE,
2863 info.senders[0].adapt_reason); 2862 info.senders[0].adapt_reason);
2864 2863
2865 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], NULL)); 2864 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2866 } 2865 }
2867 2866
2868 TEST_F(WebRtcVideoChannel2Test, 2867 TEST_F(WebRtcVideoChannel2Test,
2869 GetStatsTranslatesBandwidthLimitedResolutionCorrectly) { 2868 GetStatsTranslatesBandwidthLimitedResolutionCorrectly) {
2870 FakeVideoSendStream* stream = AddSendStream(); 2869 FakeVideoSendStream* stream = AddSendStream();
2871 webrtc::VideoSendStream::Stats stats; 2870 webrtc::VideoSendStream::Stats stats;
2872 stats.bw_limited_resolution = true; 2871 stats.bw_limited_resolution = true;
2873 stream->SetStats(stats); 2872 stream->SetStats(stats);
2874 2873
2875 cricket::VideoMediaInfo info; 2874 cricket::VideoMediaInfo info;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 } 3216 }
3218 3217
3219 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { 3218 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) {
3220 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); 3219 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false);
3221 } 3220 }
3222 3221
3223 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { 3222 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
3224 AddSendStream(); 3223 AddSendStream();
3225 3224
3226 cricket::FakeVideoCapturer capturer; 3225 cricket::FakeVideoCapturer capturer;
3227 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 3226 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
3228 cricket::VideoFormat capture_format_hd = 3227 cricket::VideoFormat capture_format_hd =
3229 capturer.GetSupportedFormats()->front(); 3228 capturer.GetSupportedFormats()->front();
3230 EXPECT_EQ(1280, capture_format_hd.width); 3229 EXPECT_EQ(1280, capture_format_hd.width);
3231 EXPECT_EQ(720, capture_format_hd.height); 3230 EXPECT_EQ(720, capture_format_hd.height);
3232 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 3231 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
3233 EXPECT_TRUE(channel_->SetSend(true)); 3232 EXPECT_TRUE(channel_->SetSend(true));
3234 3233
3235 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); 3234 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer);
3236 EXPECT_TRUE(default_encoder_bitrate > 1000); 3235 EXPECT_TRUE(default_encoder_bitrate > 1000);
3237 3236
3238 // TODO(skvlad): Resolve the inconsistency between the interpretation 3237 // TODO(skvlad): Resolve the inconsistency between the interpretation
3239 // of the global bitrate limit for audio and video: 3238 // of the global bitrate limit for audio and video:
3240 // - Audio: max_bandwidth_bps = 0 - fail the operation, 3239 // - Audio: max_bandwidth_bps = 0 - fail the operation,
3241 // max_bandwidth_bps = -1 - remove the bandwidth limit 3240 // max_bandwidth_bps = -1 - remove the bandwidth limit
3242 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, 3241 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit,
3243 // max_bandwidth_bps = -1 - do not change the previously set 3242 // max_bandwidth_bps = -1 - do not change the previously set
3244 // limit. 3243 // limit.
3245 3244
3246 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000); 3245 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000);
3247 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); 3246 SetAndExpectMaxBitrate(capturer, 1000, 800, 800);
3248 SetAndExpectMaxBitrate(capturer, 600, 800, 600); 3247 SetAndExpectMaxBitrate(capturer, 600, 800, 600);
3249 SetAndExpectMaxBitrate(capturer, 0, 800, 800); 3248 SetAndExpectMaxBitrate(capturer, 0, 800, 800);
3250 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); 3249 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate);
3251 3250
3252 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 3251 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
3253 } 3252 }
3254 3253
3255 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { 3254 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
3256 webrtc::RtpParameters nonexistent_parameters = 3255 webrtc::RtpParameters nonexistent_parameters =
3257 channel_->GetRtpParameters(last_ssrc_); 3256 channel_->GetRtpParameters(last_ssrc_);
3258 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); 3257 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
3259 3258
3260 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3259 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3261 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); 3260 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters));
3262 } 3261 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 3375
3377 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 3376 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
3378 RTC_DCHECK(num_configured_streams <= ssrcs.size()); 3377 RTC_DCHECK(num_configured_streams <= ssrcs.size());
3379 ssrcs.resize(num_configured_streams); 3378 ssrcs.resize(num_configured_streams);
3380 3379
3381 FakeVideoSendStream* stream = 3380 FakeVideoSendStream* stream =
3382 AddSendStream(CreateSimStreamParams("cname", ssrcs)); 3381 AddSendStream(CreateSimStreamParams("cname", ssrcs));
3383 // Send a full-size frame to trigger a stream reconfiguration to use all 3382 // Send a full-size frame to trigger a stream reconfiguration to use all
3384 // expected simulcast layers. 3383 // expected simulcast layers.
3385 cricket::FakeVideoCapturer capturer; 3384 cricket::FakeVideoCapturer capturer;
3386 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), &capturer)); 3385 EXPECT_TRUE(
3386 channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
3387 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( 3387 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
3388 codec.width, codec.height, 3388 codec.width, codec.height,
3389 cricket::VideoFormat::FpsToInterval(30), 3389 cricket::VideoFormat::FpsToInterval(30),
3390 cricket::FOURCC_I420))); 3390 cricket::FOURCC_I420)));
3391 channel_->SetSend(true); 3391 channel_->SetSend(true);
3392 EXPECT_TRUE(capturer.CaptureFrame()); 3392 EXPECT_TRUE(capturer.CaptureFrame());
3393 3393
3394 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); 3394 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
3395 ASSERT_EQ(expected_num_streams, video_streams.size()); 3395 ASSERT_EQ(expected_num_streams, video_streams.size());
3396 3396
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3433 total_max_bitrate_bps += video_streams[i].max_bitrate_bps; 3433 total_max_bitrate_bps += video_streams[i].max_bitrate_bps;
3434 } else { 3434 } else {
3435 total_max_bitrate_bps += video_streams[i].target_bitrate_bps; 3435 total_max_bitrate_bps += video_streams[i].target_bitrate_bps;
3436 } 3436 }
3437 } 3437 }
3438 cricket::VideoMediaInfo info; 3438 cricket::VideoMediaInfo info;
3439 ASSERT_TRUE(channel_->GetStats(&info)); 3439 ASSERT_TRUE(channel_->GetStats(&info));
3440 ASSERT_EQ(1u, info.senders.size()); 3440 ASSERT_EQ(1u, info.senders.size());
3441 EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate); 3441 EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate);
3442 3442
3443 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), NULL)); 3443 EXPECT_TRUE(channel_->SetVideoSend(ssrcs.front(), true, nullptr, nullptr));
3444 } 3444 }
3445 3445
3446 FakeVideoSendStream* AddSendStream() { 3446 FakeVideoSendStream* AddSendStream() {
3447 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); 3447 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
3448 } 3448 }
3449 3449
3450 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { 3450 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
3451 size_t num_streams = 3451 size_t num_streams =
3452 fake_call_.GetVideoSendStreams().size(); 3452 fake_call_.GetVideoSendStreams().size();
3453 EXPECT_TRUE(channel_->AddSendStream(sp)); 3453 EXPECT_TRUE(channel_->AddSendStream(sp));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 } 3490 }
3491 3491
3492 // Test that we normalize send codec format size in simulcast. 3492 // Test that we normalize send codec format size in simulcast.
3493 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3493 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3494 cricket::VideoCodec codec(kVp8Codec270p); 3494 cricket::VideoCodec codec(kVp8Codec270p);
3495 codec.width += 1; 3495 codec.width += 1;
3496 codec.height += 1; 3496 codec.height += 1;
3497 VerifySimulcastSettings(codec, 2, 2); 3497 VerifySimulcastSettings(codec, 2, 2);
3498 } 3498 }
3499 } // namespace cricket 3499 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698