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

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: Fixing comments and other minor things Created 4 years, 7 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 234 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
235 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 235 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
236 236
237 // Add CVO extension. 237 // Add CVO extension.
238 const int id = 1; 238 const int id = 1;
239 parameters.extensions.push_back( 239 parameters.extensions.push_back(
240 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); 240 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
241 EXPECT_TRUE(channel->SetSendParameters(parameters)); 241 EXPECT_TRUE(channel->SetSendParameters(parameters));
242 242
243 // Set capturer. 243 // Set capturer.
244 channel->SetSource(kSsrc, &capturer); 244 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
245 245
246 // Verify capturer has turned off applying rotation. 246 // Verify capturer has turned off applying rotation.
247 EXPECT_FALSE(capturer.GetApplyRotation()); 247 EXPECT_FALSE(capturer.GetApplyRotation());
248 248
249 // Verify removing header extension turns on applying rotation. 249 // Verify removing header extension turns on applying rotation.
250 parameters.extensions.clear(); 250 parameters.extensions.clear();
251 EXPECT_TRUE(channel->SetSendParameters(parameters)); 251 EXPECT_TRUE(channel->SetSendParameters(parameters));
252 EXPECT_TRUE(capturer.GetApplyRotation()); 252 EXPECT_TRUE(capturer.GetApplyRotation());
253 } 253 }
254 254
(...skipping 10 matching lines...) Expand all
265 std::unique_ptr<VideoMediaChannel> channel( 265 std::unique_ptr<VideoMediaChannel> channel(
266 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 266 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
267 // Add CVO extension. 267 // Add CVO extension.
268 const int id = 1; 268 const int id = 1;
269 parameters.extensions.push_back( 269 parameters.extensions.push_back(
270 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); 270 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
271 EXPECT_TRUE(channel->SetSendParameters(parameters)); 271 EXPECT_TRUE(channel->SetSendParameters(parameters));
272 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 272 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
273 273
274 // Set capturer. 274 // Set capturer.
275 channel->SetSource(kSsrc, &capturer); 275 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
276 276
277 // Verify capturer has turned off applying rotation. 277 // Verify capturer has turned off applying rotation.
278 EXPECT_FALSE(capturer.GetApplyRotation()); 278 EXPECT_FALSE(capturer.GetApplyRotation());
279 } 279 }
280 280
281 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) { 281 TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) {
282 cricket::FakeVideoCapturer capturer; 282 cricket::FakeVideoCapturer capturer;
283 283
284 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 284 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
285 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); 285 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
286 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); 286 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
287 cricket::VideoSendParameters parameters; 287 cricket::VideoSendParameters parameters;
288 parameters.codecs.push_back(kVp8Codec); 288 parameters.codecs.push_back(kVp8Codec);
289 parameters.codecs.push_back(kVp9Codec); 289 parameters.codecs.push_back(kVp9Codec);
290 290
291 std::unique_ptr<VideoMediaChannel> channel( 291 std::unique_ptr<VideoMediaChannel> channel(
292 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 292 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
293 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc))); 293 EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
294 294
295 // Set capturer. 295 // Set capturer.
296 channel->SetSource(kSsrc, &capturer); 296 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
297 297
298 // Verify capturer has turned on applying rotation. 298 // Verify capturer has turned on applying rotation.
299 EXPECT_TRUE(capturer.GetApplyRotation()); 299 EXPECT_TRUE(capturer.GetApplyRotation());
300 300
301 // Add CVO extension. 301 // Add CVO extension.
302 const int id = 1; 302 const int id = 1;
303 parameters.extensions.push_back( 303 parameters.extensions.push_back(
304 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id)); 304 cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
305 // Also remove the first codec to trigger a codec change as well. 305 // Also remove the first codec to trigger a codec change as well.
306 parameters.codecs.erase(parameters.codecs.begin()); 306 parameters.codecs.erase(parameters.codecs.begin());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 std::unique_ptr<VideoMediaChannel> channel( 346 std::unique_ptr<VideoMediaChannel> channel(
347 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs)); 347 SetUpForExternalEncoderFactory(&encoder_factory, parameters.codecs));
348 348
349 EXPECT_TRUE( 349 EXPECT_TRUE(
350 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 350 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
351 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1)); 351 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1));
352 ASSERT_EQ(1u, encoder_factory.encoders().size()); 352 ASSERT_EQ(1u, encoder_factory.encoders().size());
353 EXPECT_TRUE(channel->SetSend(true)); 353 EXPECT_TRUE(channel->SetSend(true));
354 354
355 cricket::FakeVideoCapturer capturer; 355 cricket::FakeVideoCapturer capturer;
356 channel->SetSource(kSsrc, &capturer); 356 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
357 EXPECT_EQ(cricket::CS_RUNNING, 357 EXPECT_EQ(cricket::CS_RUNNING,
358 capturer.Start(capturer.GetSupportedFormats()->front())); 358 capturer.Start(capturer.GetSupportedFormats()->front()));
359 EXPECT_TRUE(capturer.CaptureFrame()); 359 EXPECT_TRUE(capturer.CaptureFrame());
360 // Sending one frame will have reallocated the encoder since input size 360 // Sending one frame will have reallocated the encoder since input size
361 // changes from a small default to the actual frame width/height. Wait for 361 // changes from a small default to the actual frame width/height. Wait for
362 // that to happen then for the frame to be sent. 362 // that to happen then for the frame to be sent.
363 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2)); 363 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
364 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0, 364 EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0,
365 kTimeout); 365 kTimeout);
366 366
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 435
436 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); 436 FakeCall* fake_call = new FakeCall(webrtc::Call::Config());
437 call_.reset(fake_call); 437 call_.reset(fake_call);
438 std::unique_ptr<VideoMediaChannel> channel( 438 std::unique_ptr<VideoMediaChannel> channel(
439 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 439 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
440 440
441 EXPECT_TRUE( 441 EXPECT_TRUE(
442 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 442 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
443 443
444 FakeVideoCapturer capturer; 444 FakeVideoCapturer capturer;
445 channel->SetSource(kSsrc, &capturer); 445 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
446 capturer.Start(cricket::VideoFormat(1280, 720, 446 capturer.Start(cricket::VideoFormat(1280, 720,
447 cricket::VideoFormat::FpsToInterval(60), 447 cricket::VideoFormat::FpsToInterval(60),
448 cricket::FOURCC_I420)); 448 cricket::FOURCC_I420));
449 channel->SetSend(true); 449 channel->SetSend(true);
450 450
451 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; 451 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
452 452
453 EXPECT_TRUE(capturer.CaptureFrame()); 453 EXPECT_TRUE(capturer.CaptureFrame());
454 int64_t last_timestamp = stream->GetLastTimestamp(); 454 int64_t last_timestamp = stream->GetLastTimestamp();
455 for (int i = 0; i < 10; i++) { 455 for (int i = 0; i < 10; i++) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 call_.reset(fake_call); 497 call_.reset(fake_call);
498 std::unique_ptr<VideoMediaChannel> channel( 498 std::unique_ptr<VideoMediaChannel> channel(
499 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 499 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
500 500
501 EXPECT_TRUE( 501 EXPECT_TRUE(
502 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 502 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
503 channel->SetSend(true); 503 channel->SetSend(true);
504 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; 504 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0];
505 505
506 FakeVideoCapturer capturer1; 506 FakeVideoCapturer capturer1;
507 channel->SetSource(kSsrc, &capturer1); 507 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer1));
508 508
509 cricket::CapturedFrame frame; 509 cricket::CapturedFrame frame;
510 frame.width = 1280; 510 frame.width = 1280;
511 frame.height = 720; 511 frame.height = 720;
512 frame.fourcc = cricket::FOURCC_I420; 512 frame.fourcc = cricket::FOURCC_I420;
513 frame.data_size = frame.width * frame.height + 513 frame.data_size = frame.width * frame.height +
514 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); 514 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2);
515 std::unique_ptr<char[]> data(new char[frame.data_size]); 515 std::unique_ptr<char[]> data(new char[frame.data_size]);
516 frame.data = data.get(); 516 frame.data = data.get();
517 memset(frame.data, 1, frame.data_size); 517 memset(frame.data, 1, frame.data_size);
518 int64_t initial_timestamp = rtc::TimeNanos(); 518 int64_t initial_timestamp = rtc::TimeNanos();
519 frame.time_stamp = initial_timestamp; 519 frame.time_stamp = initial_timestamp;
520 520
521 // Deliver initial frame. 521 // Deliver initial frame.
522 capturer1.SignalCapturedFrame(&frame); 522 capturer1.SignalCapturedFrame(&frame);
523 // Deliver next frame 1 second later. 523 // Deliver next frame 1 second later.
524 frame.time_stamp += rtc::kNumNanosecsPerSec; 524 frame.time_stamp += rtc::kNumNanosecsPerSec;
525 rtc::Thread::Current()->SleepMs(1000); 525 rtc::Thread::Current()->SleepMs(1000);
526 capturer1.SignalCapturedFrame(&frame); 526 capturer1.SignalCapturedFrame(&frame);
527 527
528 int64_t capturer1_last_timestamp = stream->GetLastTimestamp(); 528 int64_t capturer1_last_timestamp = stream->GetLastTimestamp();
529 // Reset input source, should still be continuous even though input-frame 529 // Reset input source, should still be continuous even though input-frame
530 // timestamp is less than before. 530 // timestamp is less than before.
531 FakeVideoCapturer capturer2; 531 FakeVideoCapturer capturer2;
532 channel->SetSource(kSsrc, &capturer2); 532 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer2));
533 533
534 rtc::Thread::Current()->SleepMs(1); 534 rtc::Thread::Current()->SleepMs(1);
535 // Deliver with a timestamp (10 seconds) before the previous initial one, 535 // Deliver with a timestamp (10 seconds) before the previous initial one,
536 // these should not be related at all anymore and it should still work fine. 536 // these should not be related at all anymore and it should still work fine.
537 frame.time_stamp = initial_timestamp - 10 * rtc::kNumNanosecsPerSec; 537 frame.time_stamp = initial_timestamp - 10 * rtc::kNumNanosecsPerSec;
538 capturer2.SignalCapturedFrame(&frame); 538 capturer2.SignalCapturedFrame(&frame);
539 539
540 // New timestamp should be at least 1ms in the future and not old. 540 // New timestamp should be at least 1ms in the future and not old.
541 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp); 541 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp);
542 542
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 std::unique_ptr<VideoMediaChannel> channel( 582 std::unique_ptr<VideoMediaChannel> channel(
583 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 583 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
584 584
585 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 585 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
586 586
587 EXPECT_TRUE( 587 EXPECT_TRUE(
588 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); 588 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs)));
589 EXPECT_TRUE(channel->SetSend(true)); 589 EXPECT_TRUE(channel->SetSend(true));
590 590
591 cricket::FakeVideoCapturer capturer; 591 cricket::FakeVideoCapturer capturer;
592 channel->SetSource(ssrcs.front(), &capturer); 592 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
593 EXPECT_EQ(cricket::CS_RUNNING, 593 EXPECT_EQ(cricket::CS_RUNNING,
594 capturer.Start(capturer.GetSupportedFormats()->front())); 594 capturer.Start(capturer.GetSupportedFormats()->front()));
595 EXPECT_TRUE(capturer.CaptureFrame()); 595 EXPECT_TRUE(capturer.CaptureFrame());
596 596
597 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2)); 597 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
598 598
599 // Verify that encoders are configured for simulcast through adapter 599 // Verify that encoders are configured for simulcast through adapter
600 // (increasing resolution and only configured to send one stream each). 600 // (increasing resolution and only configured to send one stream each).
601 int prev_width = -1; 601 int prev_width = -1;
602 for (size_t i = 0; i < encoder_factory.encoders().size(); ++i) { 602 for (size_t i = 0; i < encoder_factory.encoders().size(); ++i) {
603 ASSERT_TRUE(encoder_factory.encoders()[i]->WaitForInitEncode()); 603 ASSERT_TRUE(encoder_factory.encoders()[i]->WaitForInitEncode());
604 webrtc::VideoCodec codec_settings = 604 webrtc::VideoCodec codec_settings =
605 encoder_factory.encoders()[i]->GetCodecSettings(); 605 encoder_factory.encoders()[i]->GetCodecSettings();
606 EXPECT_EQ(0, codec_settings.numberOfSimulcastStreams); 606 EXPECT_EQ(0, codec_settings.numberOfSimulcastStreams);
607 EXPECT_GT(codec_settings.width, prev_width); 607 EXPECT_GT(codec_settings.width, prev_width);
608 prev_width = codec_settings.width; 608 prev_width = codec_settings.width;
609 } 609 }
610 610
611 channel->SetSource(ssrcs.front(), NULL); 611 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, nullptr));
612 612
613 channel.reset(); 613 channel.reset();
614 ASSERT_EQ(0u, encoder_factory.encoders().size()); 614 ASSERT_EQ(0u, encoder_factory.encoders().size());
615 } 615 }
616 616
617 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) { 617 TEST_F(WebRtcVideoEngine2Test, ChannelWithExternalH264CanChangeToInternalVp8) {
618 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 618 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
619 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264"); 619 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264, "H264");
620 std::vector<cricket::VideoCodec> codecs; 620 std::vector<cricket::VideoCodec> codecs;
621 codecs.push_back(kH264Codec); 621 codecs.push_back(kH264Codec);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 664 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
665 665
666 EXPECT_TRUE( 666 EXPECT_TRUE(
667 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); 667 channel->AddSendStream(CreateSimStreamParams("cname", ssrcs)));
668 EXPECT_TRUE(channel->SetSend(true)); 668 EXPECT_TRUE(channel->SetSend(true));
669 669
670 // Send a fake frame, or else the media engine will configure the simulcast 670 // Send a fake frame, or else the media engine will configure the simulcast
671 // encoder adapter at a low-enough size that it'll only create a single 671 // encoder adapter at a low-enough size that it'll only create a single
672 // encoder layer. 672 // encoder layer.
673 cricket::FakeVideoCapturer capturer; 673 cricket::FakeVideoCapturer capturer;
674 channel->SetSource(ssrcs.front(), &capturer); 674 EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
675 EXPECT_EQ(cricket::CS_RUNNING, 675 EXPECT_EQ(cricket::CS_RUNNING,
676 capturer.Start(capturer.GetSupportedFormats()->front())); 676 capturer.Start(capturer.GetSupportedFormats()->front()));
677 EXPECT_TRUE(capturer.CaptureFrame()); 677 EXPECT_TRUE(capturer.CaptureFrame());
678 678
679 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2)); 679 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
680 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); 680 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
681 EXPECT_EQ(webrtc::kVideoCodecVP8, 681 EXPECT_EQ(webrtc::kVideoCodecVP8,
682 encoder_factory.encoders()[0]->GetCodecSettings().codecType); 682 encoder_factory.encoders()[0]->GetCodecSettings().codecType);
683 683
684 channel.reset(); 684 channel.reset();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); 720 SetUpForExternalEncoderFactory(&encoder_factory, codecs));
721 721
722 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 722 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
723 EXPECT_TRUE( 723 EXPECT_TRUE(
724 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs))); 724 channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs)));
725 725
726 // Send a frame of 720p. This should trigger a "real" encoder initialization. 726 // Send a frame of 720p. This should trigger a "real" encoder initialization.
727 cricket::VideoFormat format( 727 cricket::VideoFormat format(
728 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); 728 1280, 720, cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420);
729 cricket::FakeVideoCapturer capturer; 729 cricket::FakeVideoCapturer capturer;
730 channel->SetSource(ssrcs[0], &capturer); 730 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, &capturer));
731 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format)); 731 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
732 EXPECT_TRUE(capturer.CaptureFrame()); 732 EXPECT_TRUE(capturer.CaptureFrame());
733 733
734 ASSERT_EQ(1u, encoder_factory.encoders().size()); 734 ASSERT_EQ(1u, encoder_factory.encoders().size());
735 FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0]; 735 FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0];
736 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode()); 736 ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
737 EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType); 737 EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType);
738 EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams); 738 EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams);
739 channel->SetSource(ssrcs[0], nullptr); 739 EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr));
740 } 740 }
741 741
742 // Test that external codecs are added to the end of the supported codec list. 742 // Test that external codecs are added to the end of the supported codec list.
743 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) { 743 TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) {
744 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 744 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
745 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecUnknown, 745 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecUnknown,
746 "FakeExternalCodec"); 746 "FakeExternalCodec");
747 engine_.SetExternalEncoderFactory(&encoder_factory); 747 engine_.SetExternalEncoderFactory(&encoder_factory);
748 engine_.Init(); 748 engine_.Init();
749 749
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 void TestReceiverLocalSsrcConfiguration(bool receiver_first); 1055 void TestReceiverLocalSsrcConfiguration(bool receiver_first);
1056 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, 1056 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type,
1057 bool expect_created_receive_stream); 1057 bool expect_created_receive_stream);
1058 1058
1059 FakeVideoSendStream* SetDenoisingOption( 1059 FakeVideoSendStream* SetDenoisingOption(
1060 uint32_t ssrc, 1060 uint32_t ssrc,
1061 cricket::FakeVideoCapturer* capturer, 1061 cricket::FakeVideoCapturer* capturer,
1062 bool enabled) { 1062 bool enabled) {
1063 cricket::VideoOptions options; 1063 cricket::VideoOptions options;
1064 options.video_noise_reduction = rtc::Optional<bool>(enabled); 1064 options.video_noise_reduction = rtc::Optional<bool>(enabled);
1065 channel_->SetVideoSend(ssrc, true, &options); 1065 EXPECT_TRUE(channel_->SetVideoSend(ssrc, true, &options, capturer));
1066 // Options only take effect on the next frame. 1066 // Options only take effect on the next frame.
1067 EXPECT_TRUE(capturer->CaptureFrame()); 1067 EXPECT_TRUE(capturer->CaptureFrame());
1068 1068
1069 return fake_call_->GetVideoSendStreams().back(); 1069 return fake_call_->GetVideoSendStreams().back();
1070 } 1070 }
1071 1071
1072 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { 1072 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) {
1073 const int kRtxSsrcOffset = 0xDEADBEEF; 1073 const int kRtxSsrcOffset = 0xDEADBEEF;
1074 last_ssrc_ += 3; 1074 last_ssrc_ += 3;
1075 std::vector<uint32_t> ssrcs; 1075 std::vector<uint32_t> ssrcs;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 channel_->SetSend(false); 1545 channel_->SetSend(false);
1546 1546
1547 FakeVideoSendStream* stream = AddSendStream(); 1547 FakeVideoSendStream* stream = AddSendStream();
1548 1548
1549 // No frames entered, using default dimensions. 1549 // No frames entered, using default dimensions.
1550 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 1550 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
1551 EXPECT_EQ(176u, streams[0].width); 1551 EXPECT_EQ(176u, streams[0].width);
1552 EXPECT_EQ(144u, streams[0].height); 1552 EXPECT_EQ(144u, streams[0].height);
1553 1553
1554 cricket::FakeVideoCapturer capturer; 1554 cricket::FakeVideoCapturer capturer;
1555 channel_->SetSource(last_ssrc_, &capturer); 1555 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1556 EXPECT_EQ(cricket::CS_RUNNING, 1556 EXPECT_EQ(cricket::CS_RUNNING,
1557 capturer.Start(capturer.GetSupportedFormats()->front())); 1557 capturer.Start(capturer.GetSupportedFormats()->front()));
1558 EXPECT_TRUE(capturer.CaptureFrame()); 1558 EXPECT_TRUE(capturer.CaptureFrame());
1559 1559
1560 // Frame entered, should be reconfigured to new dimensions. 1560 // Frame entered, should be reconfigured to new dimensions.
1561 streams = stream->GetVideoStreams(); 1561 streams = stream->GetVideoStreams();
1562 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); 1562 EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
1563 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); 1563 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
1564 // No frames should have been actually put in there though. 1564 // No frames should have been actually put in there though.
1565 EXPECT_EQ(0, stream->GetNumberOfSwappedFrames()); 1565 EXPECT_EQ(0, stream->GetNumberOfSwappedFrames());
1566 1566
1567 channel_->SetSource(last_ssrc_, NULL); 1567 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1568 } 1568 }
1569 1569
1570 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { 1570 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
1571 static const int kScreenshareMinBitrateKbps = 800; 1571 static const int kScreenshareMinBitrateKbps = 800;
1572 cricket::VideoCodec codec = kVp8Codec360p; 1572 cricket::VideoCodec codec = kVp8Codec360p;
1573 cricket::VideoSendParameters parameters; 1573 cricket::VideoSendParameters parameters;
1574 parameters.codecs.push_back(codec); 1574 parameters.codecs.push_back(codec);
1575 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1575 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1576 AddSendStream(); 1576 AddSendStream();
1577 1577
1578 cricket::FakeVideoCapturer capturer;
1578 VideoOptions min_bitrate_options; 1579 VideoOptions min_bitrate_options;
1579 min_bitrate_options.screencast_min_bitrate_kbps = 1580 min_bitrate_options.screencast_min_bitrate_kbps =
1580 rtc::Optional<int>(kScreenshareMinBitrateKbps); 1581 rtc::Optional<int>(kScreenshareMinBitrateKbps);
1581 channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options); 1582 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options,
1582 1583 &capturer));
1583 cricket::FakeVideoCapturer capturer;
1584 channel_->SetSource(last_ssrc_, &capturer);
1585 cricket::VideoFormat capture_format_hd = 1584 cricket::VideoFormat capture_format_hd =
1586 capturer.GetSupportedFormats()->front(); 1585 capturer.GetSupportedFormats()->front();
1587 EXPECT_EQ(1280, capture_format_hd.width); 1586 EXPECT_EQ(1280, capture_format_hd.width);
1588 EXPECT_EQ(720, capture_format_hd.height); 1587 EXPECT_EQ(720, capture_format_hd.height);
1589 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 1588 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
1590 1589
1591 EXPECT_TRUE(channel_->SetSend(true)); 1590 EXPECT_TRUE(channel_->SetSend(true));
1592 1591
1593 EXPECT_TRUE(capturer.CaptureFrame()); 1592 EXPECT_TRUE(capturer.CaptureFrame());
1594 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1593 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1595 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1594 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1596 1595
1597 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 1596 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1598 1597
1599 // Verify non-screencast settings. 1598 // Verify non-screencast settings.
1600 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); 1599 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
1601 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1600 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1602 encoder_config.content_type); 1601 encoder_config.content_type);
1603 EXPECT_EQ(codec.width, encoder_config.streams.front().width); 1602 EXPECT_EQ(codec.width, encoder_config.streams.front().width);
1604 EXPECT_EQ(codec.height, encoder_config.streams.front().height); 1603 EXPECT_EQ(codec.height, encoder_config.streams.front().height);
1605 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) 1604 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
1606 << "Non-screenshare shouldn't use min-transmit bitrate."; 1605 << "Non-screenshare shouldn't use min-transmit bitrate.";
1607 1606
1608 channel_->SetSource(last_ssrc_, nullptr); 1607 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1609 // Removing a capturer triggers a black frame to be sent. 1608 // Removing a capturer triggers a black frame to be sent.
1610 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 1609 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1611 channel_->SetSource(last_ssrc_, &capturer);
1612 VideoOptions screencast_options; 1610 VideoOptions screencast_options;
1613 screencast_options.is_screencast = rtc::Optional<bool>(true); 1611 screencast_options.is_screencast = rtc::Optional<bool>(true);
1614 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &screencast_options)); 1612 EXPECT_TRUE(
1613 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer));
1615 EXPECT_TRUE(capturer.CaptureFrame()); 1614 EXPECT_TRUE(capturer.CaptureFrame());
1616 // Send stream not recreated after option change. 1615 // Send stream not recreated after option change.
1617 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); 1616 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front());
1618 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 1617 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
1619 1618
1620 // Verify screencast settings. 1619 // Verify screencast settings.
1621 encoder_config = send_stream->GetEncoderConfig(); 1620 encoder_config = send_stream->GetEncoderConfig();
1622 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1621 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1623 encoder_config.content_type); 1622 encoder_config.content_type);
1624 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, 1623 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
1625 encoder_config.min_transmit_bitrate_bps); 1624 encoder_config.min_transmit_bitrate_bps);
1626 1625
1627 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width); 1626 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width);
1628 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); 1627 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
1629 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); 1628 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
1630 1629
1631 channel_->SetSource(last_ssrc_, NULL); 1630 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1632 } 1631 }
1633 1632
1634 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { 1633 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) {
1635 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1634 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1636 ASSERT_TRUE( 1635 ASSERT_TRUE(
1637 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 1636 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
1638 EXPECT_TRUE(channel_->SetSend(true)); 1637 EXPECT_TRUE(channel_->SetSend(true));
1639 1638
1640 cricket::FakeVideoCapturer capturer; 1639 cricket::FakeVideoCapturer capturer;
1641 channel_->SetSource(kSsrc, &capturer); 1640 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, &capturer));
1642 EXPECT_EQ(cricket::CS_RUNNING, 1641 EXPECT_EQ(cricket::CS_RUNNING,
1643 capturer.Start(capturer.GetSupportedFormats()->front())); 1642 capturer.Start(capturer.GetSupportedFormats()->front()));
1644 EXPECT_TRUE(capturer.CaptureFrame()); 1643 EXPECT_TRUE(capturer.CaptureFrame());
1645 1644
1646 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1645 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1647 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front(); 1646 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front();
1648 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig(); 1647 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig();
1649 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1648 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1650 encoder_config.content_type); 1649 encoder_config.content_type);
1651 1650
1652 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames()); 1651 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames());
1653 1652
1654 /* Switch to screencast source. We expect a reconfigure of the 1653 /* Switch to screencast source. We expect a reconfigure of the
1655 * encoder, but no change of the send stream. */ 1654 * encoder, but no change of the send stream. */
1656 struct VideoOptions video_options; 1655 struct VideoOptions video_options;
1657 video_options.is_screencast = rtc::Optional<bool>(true); 1656 video_options.is_screencast = rtc::Optional<bool>(true);
1658 channel_->SetVideoSend(kSsrc, true, &video_options); 1657 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer));
1659 1658
1660 EXPECT_TRUE(capturer.CaptureFrame()); 1659 EXPECT_TRUE(capturer.CaptureFrame());
1661 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1660 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1662 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); 1661 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front());
1663 EXPECT_EQ(2, stream->GetNumberOfSwappedFrames()); 1662 EXPECT_EQ(2, stream->GetNumberOfSwappedFrames());
1664 1663
1665 encoder_config = stream->GetEncoderConfig(); 1664 encoder_config = stream->GetEncoderConfig();
1666 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1665 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1667 encoder_config.content_type); 1666 encoder_config.content_type);
1668 1667
1669 /* Switch back. */ 1668 /* Switch back. */
1670 video_options.is_screencast = rtc::Optional<bool>(false); 1669 video_options.is_screencast = rtc::Optional<bool>(false);
1671 channel_->SetVideoSend(kSsrc, true, &video_options); 1670 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer));
1672 1671
1673 EXPECT_TRUE(capturer.CaptureFrame()); 1672 EXPECT_TRUE(capturer.CaptureFrame());
1674 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1673 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1675 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); 1674 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front());
1676 EXPECT_EQ(3, stream->GetNumberOfSwappedFrames()); 1675 EXPECT_EQ(3, stream->GetNumberOfSwappedFrames());
1677 1676
1678 encoder_config = stream->GetEncoderConfig(); 1677 encoder_config = stream->GetEncoderConfig();
1679 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1678 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1680 encoder_config.content_type); 1679 encoder_config.content_type);
1681 1680
1682 channel_->SetSource(kSsrc, NULL); 1681 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr));
1683 } 1682 }
1684 1683
1685 TEST_F(WebRtcVideoChannel2Test, 1684 TEST_F(WebRtcVideoChannel2Test,
1686 ConferenceModeScreencastConfiguresTemporalLayer) { 1685 ConferenceModeScreencastConfiguresTemporalLayer) {
1687 static const int kConferenceScreencastTemporalBitrateBps = 1686 static const int kConferenceScreencastTemporalBitrateBps =
1688 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; 1687 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000;
1689 send_parameters_.conference_mode = true; 1688 send_parameters_.conference_mode = true;
1690 channel_->SetSendParameters(send_parameters_); 1689 channel_->SetSendParameters(send_parameters_);
1691 1690
1692 AddSendStream(); 1691 AddSendStream();
1693 VideoOptions options; 1692 VideoOptions options;
1694 options.is_screencast = rtc::Optional<bool>(true); 1693 options.is_screencast = rtc::Optional<bool>(true);
1695 channel_->SetVideoSend(last_ssrc_, true, &options);
1696 cricket::FakeVideoCapturer capturer; 1694 cricket::FakeVideoCapturer capturer;
1697 channel_->SetSource(last_ssrc_, &capturer); 1695 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1698 cricket::VideoFormat capture_format_hd = 1696 cricket::VideoFormat capture_format_hd =
1699 capturer.GetSupportedFormats()->front(); 1697 capturer.GetSupportedFormats()->front();
1700 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 1698 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
1701 1699
1702 EXPECT_TRUE(channel_->SetSend(true)); 1700 EXPECT_TRUE(channel_->SetSend(true));
1703 1701
1704 EXPECT_TRUE(capturer.CaptureFrame()); 1702 EXPECT_TRUE(capturer.CaptureFrame());
1705 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1703 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1706 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1704 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1707 1705
1708 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); 1706 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
1709 1707
1710 // Verify screencast settings. 1708 // Verify screencast settings.
1711 encoder_config = send_stream->GetEncoderConfig(); 1709 encoder_config = send_stream->GetEncoderConfig();
1712 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1710 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1713 encoder_config.content_type); 1711 encoder_config.content_type);
1714 ASSERT_EQ(1u, encoder_config.streams.size()); 1712 ASSERT_EQ(1u, encoder_config.streams.size());
1715 ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size()); 1713 ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size());
1716 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, 1714 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
1717 encoder_config.streams[0].temporal_layer_thresholds_bps[0]); 1715 encoder_config.streams[0].temporal_layer_thresholds_bps[0]);
1718 1716
1719 channel_->SetSource(last_ssrc_, NULL); 1717 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1720 } 1718 }
1721 1719
1722 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { 1720 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) {
1723 FakeVideoSendStream* stream = AddSendStream(); 1721 FakeVideoSendStream* stream = AddSendStream();
1724 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1722 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1725 } 1723 }
1726 1724
1727 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { 1725 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) {
1728 MediaConfig media_config = MediaConfig(); 1726 MediaConfig media_config = MediaConfig();
1729 media_config.video.suspend_below_min_bitrate = true; 1727 media_config.video.suspend_below_min_bitrate = true;
(...skipping 29 matching lines...) Expand all
1759 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1757 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1760 1758
1761 // Single-stream settings should apply with RTX as well (verifies that we 1759 // Single-stream settings should apply with RTX as well (verifies that we
1762 // check number of regular SSRCs and not StreamParams::ssrcs which contains 1760 // check number of regular SSRCs and not StreamParams::ssrcs which contains
1763 // both RTX and regular SSRCs). 1761 // both RTX and regular SSRCs).
1764 FakeVideoSendStream* stream = SetUpSimulcast(false, true); 1762 FakeVideoSendStream* stream = SetUpSimulcast(false, true);
1765 1763
1766 cricket::FakeVideoCapturer capturer; 1764 cricket::FakeVideoCapturer capturer;
1767 EXPECT_EQ(cricket::CS_RUNNING, 1765 EXPECT_EQ(cricket::CS_RUNNING,
1768 capturer.Start(capturer.GetSupportedFormats()->front())); 1766 capturer.Start(capturer.GetSupportedFormats()->front()));
1769 channel_->SetSource(last_ssrc_, &capturer); 1767 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1770 channel_->SetSend(true); 1768 channel_->SetSend(true);
1771 1769
1772 EXPECT_TRUE(capturer.CaptureFrame()); 1770 EXPECT_TRUE(capturer.CaptureFrame());
1773 1771
1774 webrtc::VideoCodecVP8 vp8_settings; 1772 webrtc::VideoCodecVP8 vp8_settings;
1775 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1773 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1776 EXPECT_TRUE(vp8_settings.denoisingOn) 1774 EXPECT_TRUE(vp8_settings.denoisingOn)
1777 << "VP8 denoising should be on by default."; 1775 << "VP8 denoising should be on by default.";
1778 1776
1779 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1777 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1780 1778
1781 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1779 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1782 EXPECT_FALSE(vp8_settings.denoisingOn); 1780 EXPECT_FALSE(vp8_settings.denoisingOn);
1783 EXPECT_TRUE(vp8_settings.automaticResizeOn); 1781 EXPECT_TRUE(vp8_settings.automaticResizeOn);
1784 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1782 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1785 1783
1786 stream = SetDenoisingOption(last_ssrc_, &capturer, true); 1784 stream = SetDenoisingOption(last_ssrc_, &capturer, true);
1787 1785
1788 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1786 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1789 EXPECT_TRUE(vp8_settings.denoisingOn); 1787 EXPECT_TRUE(vp8_settings.denoisingOn);
1790 EXPECT_TRUE(vp8_settings.automaticResizeOn); 1788 EXPECT_TRUE(vp8_settings.automaticResizeOn);
1791 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1789 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1792 1790
1793 channel_->SetSource(last_ssrc_, NULL); 1791 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1794 stream = SetUpSimulcast(true, false); 1792 stream = SetUpSimulcast(true, false);
1795 channel_->SetSource(last_ssrc_, &capturer); 1793 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1796 channel_->SetSend(true); 1794 channel_->SetSend(true);
1797 EXPECT_TRUE(capturer.CaptureFrame()); 1795 EXPECT_TRUE(capturer.CaptureFrame());
1798 1796
1799 EXPECT_EQ(3, stream->GetVideoStreams().size()); 1797 EXPECT_EQ(3, stream->GetVideoStreams().size());
1800 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1798 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1801 // Autmatic resize off when using simulcast. 1799 // Autmatic resize off when using simulcast.
1802 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1800 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1803 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1801 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1804 1802
1805 // In screen-share mode, denoising is forced off and simulcast disabled. 1803 // In screen-share mode, denoising is forced off and simulcast disabled.
1806 VideoOptions options; 1804 VideoOptions options;
1807 options.is_screencast = rtc::Optional<bool>(true); 1805 options.is_screencast = rtc::Optional<bool>(true);
1808 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 1806 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1809 1807
1810 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1808 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1811 1809
1812 EXPECT_EQ(1, stream->GetVideoStreams().size()); 1810 EXPECT_EQ(1, stream->GetVideoStreams().size());
1813 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1811 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1814 EXPECT_FALSE(vp8_settings.denoisingOn); 1812 EXPECT_FALSE(vp8_settings.denoisingOn);
1815 // Resizing and frame dropping always off for screen sharing. 1813 // Resizing and frame dropping always off for screen sharing.
1816 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1814 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1817 EXPECT_FALSE(vp8_settings.frameDroppingOn); 1815 EXPECT_FALSE(vp8_settings.frameDroppingOn);
1818 1816
1819 stream = SetDenoisingOption(last_ssrc_, &capturer, true); 1817 stream = SetDenoisingOption(last_ssrc_, &capturer, true);
1820 1818
1821 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1819 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1822 EXPECT_FALSE(vp8_settings.denoisingOn); 1820 EXPECT_FALSE(vp8_settings.denoisingOn);
1823 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1821 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1824 EXPECT_FALSE(vp8_settings.frameDroppingOn); 1822 EXPECT_FALSE(vp8_settings.frameDroppingOn);
1825 1823
1826 channel_->SetSource(last_ssrc_, NULL); 1824 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1827 } 1825 }
1828 1826
1829 // Test that setting the same options doesn't result in the encoder being 1827 // Test that setting the same options doesn't result in the encoder being
1830 // reconfigured. 1828 // reconfigured.
1831 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { 1829 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) {
1832 VideoOptions options; 1830 VideoOptions options;
1833 cricket::FakeVideoCapturer capturer; 1831 cricket::FakeVideoCapturer capturer;
1834 1832
1835 FakeVideoSendStream* send_stream = AddSendStream(); 1833 FakeVideoSendStream* send_stream = AddSendStream();
1836 channel_->SetSource(last_ssrc_, &capturer);
1837 EXPECT_EQ(cricket::CS_RUNNING, 1834 EXPECT_EQ(cricket::CS_RUNNING,
1838 capturer.Start(capturer.GetSupportedFormats()->front())); 1835 capturer.Start(capturer.GetSupportedFormats()->front()));
1839 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 1836 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1840 EXPECT_TRUE(capturer.CaptureFrame()); 1837 EXPECT_TRUE(capturer.CaptureFrame());
1841 // Expect 2 reconfigurations at this point, from the initial configuration 1838 // Expect 2 reconfigurations at this point, from the initial configuration
1842 // and from the dimensions of the first frame. 1839 // and from the dimensions of the first frame.
1843 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); 1840 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
1844 1841
1845 // Set the options one more time and expect no additional reconfigurations. 1842 // Set the options one more time and expect no additional reconfigurations.
1846 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 1843 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1847 EXPECT_TRUE(capturer.CaptureFrame()); 1844 EXPECT_TRUE(capturer.CaptureFrame());
1848 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); 1845 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
1849 1846
1850 channel_->SetSource(last_ssrc_, nullptr); 1847 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1851 } 1848 }
1852 1849
1853 class Vp9SettingsTest : public WebRtcVideoChannel2Test { 1850 class Vp9SettingsTest : public WebRtcVideoChannel2Test {
1854 public: 1851 public:
1855 Vp9SettingsTest() : Vp9SettingsTest("") {} 1852 Vp9SettingsTest() : Vp9SettingsTest("") {}
1856 explicit Vp9SettingsTest(const char* field_trials) 1853 explicit Vp9SettingsTest(const char* field_trials)
1857 : WebRtcVideoChannel2Test(field_trials) { 1854 : WebRtcVideoChannel2Test(field_trials) {
1858 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9"); 1855 encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
1859 } 1856 }
1860 virtual ~Vp9SettingsTest() {} 1857 virtual ~Vp9SettingsTest() {}
(...skipping 17 matching lines...) Expand all
1878 TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { 1875 TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) {
1879 cricket::VideoSendParameters parameters; 1876 cricket::VideoSendParameters parameters;
1880 parameters.codecs.push_back(kVp9Codec); 1877 parameters.codecs.push_back(kVp9Codec);
1881 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1878 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1882 1879
1883 FakeVideoSendStream* stream = SetUpSimulcast(false, false); 1880 FakeVideoSendStream* stream = SetUpSimulcast(false, false);
1884 1881
1885 cricket::FakeVideoCapturer capturer; 1882 cricket::FakeVideoCapturer capturer;
1886 EXPECT_EQ(cricket::CS_RUNNING, 1883 EXPECT_EQ(cricket::CS_RUNNING,
1887 capturer.Start(capturer.GetSupportedFormats()->front())); 1884 capturer.Start(capturer.GetSupportedFormats()->front()));
1888 channel_->SetSource(last_ssrc_, &capturer); 1885 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1889 channel_->SetSend(true); 1886 channel_->SetSend(true);
1890 1887
1891 EXPECT_TRUE(capturer.CaptureFrame()); 1888 EXPECT_TRUE(capturer.CaptureFrame());
1892 1889
1893 webrtc::VideoCodecVP9 vp9_settings; 1890 webrtc::VideoCodecVP9 vp9_settings;
1894 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1891 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1895 EXPECT_FALSE(vp9_settings.denoisingOn) 1892 EXPECT_FALSE(vp9_settings.denoisingOn)
1896 << "VP9 denoising should be off by default."; 1893 << "VP9 denoising should be off by default.";
1897 1894
1898 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1895 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1899 1896
1900 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1897 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1901 EXPECT_FALSE(vp9_settings.denoisingOn); 1898 EXPECT_FALSE(vp9_settings.denoisingOn);
1902 // Frame dropping always on for real time video. 1899 // Frame dropping always on for real time video.
1903 EXPECT_TRUE(vp9_settings.frameDroppingOn); 1900 EXPECT_TRUE(vp9_settings.frameDroppingOn);
1904 1901
1905 stream = SetDenoisingOption(last_ssrc_, &capturer, true); 1902 stream = SetDenoisingOption(last_ssrc_, &capturer, true);
1906 1903
1907 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1904 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1908 EXPECT_TRUE(vp9_settings.denoisingOn); 1905 EXPECT_TRUE(vp9_settings.denoisingOn);
1909 EXPECT_TRUE(vp9_settings.frameDroppingOn); 1906 EXPECT_TRUE(vp9_settings.frameDroppingOn);
1910 1907
1911 // In screen-share mode, denoising is forced off. 1908 // In screen-share mode, denoising is forced off.
1912 VideoOptions options; 1909 VideoOptions options;
1913 options.is_screencast = rtc::Optional<bool>(true); 1910 options.is_screencast = rtc::Optional<bool>(true);
1914 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 1911 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1915 1912
1916 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1913 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1917 1914
1918 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1915 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1919 EXPECT_FALSE(vp9_settings.denoisingOn); 1916 EXPECT_FALSE(vp9_settings.denoisingOn);
1920 // Frame dropping always off for screen sharing. 1917 // Frame dropping always off for screen sharing.
1921 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1918 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1922 1919
1923 stream = SetDenoisingOption(last_ssrc_, &capturer, false); 1920 stream = SetDenoisingOption(last_ssrc_, &capturer, false);
1924 1921
1925 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1922 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1926 EXPECT_FALSE(vp9_settings.denoisingOn); 1923 EXPECT_FALSE(vp9_settings.denoisingOn);
1927 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1924 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1928 1925
1929 channel_->SetSource(last_ssrc_, NULL); 1926 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1930 } 1927 }
1931 1928
1932 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest { 1929 class Vp9SettingsTestWithFieldTrial : public Vp9SettingsTest {
1933 public: 1930 public:
1934 Vp9SettingsTestWithFieldTrial(const char* field_trials) 1931 Vp9SettingsTestWithFieldTrial(const char* field_trials)
1935 : Vp9SettingsTest(field_trials) {} 1932 : Vp9SettingsTest(field_trials) {}
1936 1933
1937 protected: 1934 protected:
1938 void VerifySettings(int num_spatial_layers, int num_temporal_layers) { 1935 void VerifySettings(int num_spatial_layers, int num_temporal_layers) {
1939 cricket::VideoSendParameters parameters; 1936 cricket::VideoSendParameters parameters;
1940 parameters.codecs.push_back(kVp9Codec); 1937 parameters.codecs.push_back(kVp9Codec);
1941 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1938 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1942 1939
1943 FakeVideoSendStream* stream = SetUpSimulcast(false, false); 1940 FakeVideoSendStream* stream = SetUpSimulcast(false, false);
1944 1941
1945 cricket::FakeVideoCapturer capturer; 1942 cricket::FakeVideoCapturer capturer;
1946 EXPECT_EQ(cricket::CS_RUNNING, 1943 EXPECT_EQ(cricket::CS_RUNNING,
1947 capturer.Start(capturer.GetSupportedFormats()->front())); 1944 capturer.Start(capturer.GetSupportedFormats()->front()));
1948 channel_->SetSource(last_ssrc_, &capturer); 1945 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1949 channel_->SetSend(true); 1946 channel_->SetSend(true);
1950 1947
1951 EXPECT_TRUE(capturer.CaptureFrame()); 1948 EXPECT_TRUE(capturer.CaptureFrame());
1952 1949
1953 webrtc::VideoCodecVP9 vp9_settings; 1950 webrtc::VideoCodecVP9 vp9_settings;
1954 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1951 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1955 EXPECT_EQ(num_spatial_layers, vp9_settings.numberOfSpatialLayers); 1952 EXPECT_EQ(num_spatial_layers, vp9_settings.numberOfSpatialLayers);
1956 EXPECT_EQ(num_temporal_layers, vp9_settings.numberOfTemporalLayers); 1953 EXPECT_EQ(num_temporal_layers, vp9_settings.numberOfTemporalLayers);
1957 1954
1958 channel_->SetSource(last_ssrc_, NULL); 1955 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1959 } 1956 }
1960 }; 1957 };
1961 1958
1962 class Vp9SettingsTestWithNoFlag : public Vp9SettingsTestWithFieldTrial { 1959 class Vp9SettingsTestWithNoFlag : public Vp9SettingsTestWithFieldTrial {
1963 public: 1960 public:
1964 Vp9SettingsTestWithNoFlag() : Vp9SettingsTestWithFieldTrial("") {} 1961 Vp9SettingsTestWithNoFlag() : Vp9SettingsTestWithFieldTrial("") {}
1965 }; 1962 };
1966 1963
1967 TEST_F(Vp9SettingsTestWithNoFlag, VerifySettings) { 1964 TEST_F(Vp9SettingsTestWithNoFlag, VerifySettings) {
1968 const int kNumSpatialLayers = 1; 1965 const int kNumSpatialLayers = 1;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 parameters.codecs.push_back(codec); 2010 parameters.codecs.push_back(codec);
2014 2011
2015 MediaConfig media_config = MediaConfig(); 2012 MediaConfig media_config = MediaConfig();
2016 channel_.reset( 2013 channel_.reset(
2017 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2014 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2018 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2015 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2019 2016
2020 AddSendStream(); 2017 AddSendStream();
2021 2018
2022 cricket::FakeVideoCapturer capturer; 2019 cricket::FakeVideoCapturer capturer;
2023 channel_->SetSource(last_ssrc_, &capturer); 2020 ASSERT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2024 ASSERT_EQ(cricket::CS_RUNNING, 2021 ASSERT_EQ(cricket::CS_RUNNING,
2025 capturer.Start(capturer.GetSupportedFormats()->front())); 2022 capturer.Start(capturer.GetSupportedFormats()->front()));
2026 ASSERT_TRUE(channel_->SetSend(true)); 2023 ASSERT_TRUE(channel_->SetSend(true));
2027 2024
2028 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2025 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2029 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 2026 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
2030 webrtc::LoadObserver* overuse_callback = 2027 webrtc::LoadObserver* overuse_callback =
2031 send_stream->GetConfig().overuse_callback; 2028 send_stream->GetConfig().overuse_callback;
2032 ASSERT_TRUE(overuse_callback != NULL); 2029 ASSERT_TRUE(overuse_callback != NULL);
2033 2030
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 EXPECT_EQ(1284 * 3 / 4, send_stream->GetLastWidth()); 2068 EXPECT_EQ(1284 * 3 / 4, send_stream->GetLastWidth());
2072 EXPECT_EQ(724 * 3 / 4, send_stream->GetLastHeight()); 2069 EXPECT_EQ(724 * 3 / 4, send_stream->GetLastHeight());
2073 2070
2074 // Trigger underuse which should go back up in resolution. 2071 // Trigger underuse which should go back up in resolution.
2075 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 2072 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
2076 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); 2073 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
2077 EXPECT_EQ(7, send_stream->GetNumberOfSwappedFrames()); 2074 EXPECT_EQ(7, send_stream->GetNumberOfSwappedFrames());
2078 EXPECT_EQ(1284, send_stream->GetLastWidth()); 2075 EXPECT_EQ(1284, send_stream->GetLastWidth());
2079 EXPECT_EQ(724, send_stream->GetLastHeight()); 2076 EXPECT_EQ(724, send_stream->GetLastHeight());
2080 2077
2081 channel_->SetSource(last_ssrc_, NULL); 2078 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2082 } 2079 }
2083 2080
2084 TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) { 2081 TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) {
2085 cricket::VideoCodec codec = kVp8Codec720p; 2082 cricket::VideoCodec codec = kVp8Codec720p;
2086 cricket::VideoSendParameters parameters; 2083 cricket::VideoSendParameters parameters;
2087 parameters.codecs.push_back(codec); 2084 parameters.codecs.push_back(codec);
2088 2085
2089 MediaConfig media_config = MediaConfig(); 2086 MediaConfig media_config = MediaConfig();
2090 channel_.reset( 2087 channel_.reset(
2091 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2088 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2092 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2089 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2093 2090
2094 AddSendStream(); 2091 AddSendStream();
2095 2092
2096 cricket::FakeVideoCapturer capturer; 2093 cricket::FakeVideoCapturer capturer;
2097 channel_->SetSource(last_ssrc_, &capturer);
2098 ASSERT_EQ(cricket::CS_RUNNING, 2094 ASSERT_EQ(cricket::CS_RUNNING,
2099 capturer.Start(capturer.GetSupportedFormats()->front())); 2095 capturer.Start(capturer.GetSupportedFormats()->front()));
2100 ASSERT_TRUE(channel_->SetSend(true)); 2096 ASSERT_TRUE(channel_->SetSend(true));
2101 cricket::VideoOptions camera_options; 2097 cricket::VideoOptions camera_options;
2102 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options); 2098 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options,
2099 &capturer);
2103 2100
2104 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2101 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2105 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 2102 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
2106 webrtc::LoadObserver* overuse_callback = 2103 webrtc::LoadObserver* overuse_callback =
2107 send_stream->GetConfig().overuse_callback; 2104 send_stream->GetConfig().overuse_callback;
2108 ASSERT_TRUE(overuse_callback != NULL); 2105 ASSERT_TRUE(overuse_callback != NULL);
2109 2106
2110 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2107 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2111 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2108 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2112 EXPECT_EQ(1280, send_stream->GetLastWidth()); 2109 EXPECT_EQ(1280, send_stream->GetLastWidth());
2113 EXPECT_EQ(720, send_stream->GetLastHeight()); 2110 EXPECT_EQ(720, send_stream->GetLastHeight());
2114 2111
2115 // Trigger overuse. 2112 // Trigger overuse.
2116 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2113 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2117 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2114 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2118 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 2115 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
2119 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); 2116 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
2120 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); 2117 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
2121 2118
2122 // Switch to screen share. Expect no CPU adaptation. 2119 // Switch to screen share. Expect no CPU adaptation.
2123 cricket::FakeVideoCapturer screen_share(true); 2120 cricket::FakeVideoCapturer screen_share(true);
2124 ASSERT_EQ(cricket::CS_RUNNING, 2121 ASSERT_EQ(cricket::CS_RUNNING,
2125 screen_share.Start(screen_share.GetSupportedFormats()->front())); 2122 screen_share.Start(screen_share.GetSupportedFormats()->front()));
2126 channel_->SetSource(last_ssrc_, &screen_share);
2127 cricket::VideoOptions screenshare_options; 2123 cricket::VideoOptions screenshare_options;
2128 screenshare_options.is_screencast = rtc::Optional<bool>(true); 2124 screenshare_options.is_screencast = rtc::Optional<bool>(true);
2129 channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options); 2125 channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options,
2126 &screen_share);
2130 EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); 2127 EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
2131 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 2128 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
2132 EXPECT_EQ(1284, send_stream->GetLastWidth()); 2129 EXPECT_EQ(1284, send_stream->GetLastWidth());
2133 EXPECT_EQ(724, send_stream->GetLastHeight()); 2130 EXPECT_EQ(724, send_stream->GetLastHeight());
2134 2131
2135 // Switch back to the normal capturer. Expect the frame to be CPU adapted. 2132 // Switch back to the normal capturer. Expect the frame to be CPU adapted.
2136 channel_->SetSource(last_ssrc_, &capturer); 2133 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options,
2137 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options); 2134 &capturer);
2138 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2135 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2139 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames()); 2136 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames());
2140 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); 2137 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
2141 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); 2138 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
2142 2139
2143 channel_->SetSource(last_ssrc_, NULL); 2140 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2144 } 2141 }
2145 2142
2146 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 2143 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
2147 bool is_screenshare) { 2144 bool is_screenshare) {
2148 cricket::VideoCodec codec = kVp8Codec720p; 2145 cricket::VideoCodec codec = kVp8Codec720p;
2149 cricket::VideoSendParameters parameters; 2146 cricket::VideoSendParameters parameters;
2150 parameters.codecs.push_back(codec); 2147 parameters.codecs.push_back(codec);
2151 2148
2152 MediaConfig media_config = MediaConfig(); 2149 MediaConfig media_config = MediaConfig();
2153 if (!enable_overuse) { 2150 if (!enable_overuse) {
2154 media_config.video.enable_cpu_overuse_detection = false; 2151 media_config.video.enable_cpu_overuse_detection = false;
2155 } 2152 }
2156 channel_.reset( 2153 channel_.reset(
2157 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2154 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2158 2155
2159 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2156 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2160 2157
2161 AddSendStream(); 2158 AddSendStream();
2162 2159
2160 cricket::FakeVideoCapturer capturer;
2163 VideoOptions options; 2161 VideoOptions options;
2164 options.is_screencast = rtc::Optional<bool>(is_screenshare); 2162 options.is_screencast = rtc::Optional<bool>(is_screenshare);
2165 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options)); 2163 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
2166
2167 cricket::FakeVideoCapturer capturer;
2168 channel_->SetSource(last_ssrc_, &capturer);
2169 EXPECT_EQ(cricket::CS_RUNNING, 2164 EXPECT_EQ(cricket::CS_RUNNING,
2170 capturer.Start(capturer.GetSupportedFormats()->front())); 2165 capturer.Start(capturer.GetSupportedFormats()->front()));
2171 2166
2172 EXPECT_TRUE(channel_->SetSend(true)); 2167 EXPECT_TRUE(channel_->SetSend(true));
2173 2168
2174 // Trigger overuse. 2169 // Trigger overuse.
2175 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2170 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2176 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 2171 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
2177 webrtc::LoadObserver* overuse_callback = 2172 webrtc::LoadObserver* overuse_callback =
2178 send_stream->GetConfig().overuse_callback; 2173 send_stream->GetConfig().overuse_callback;
2179 2174
2180 if (!enable_overuse) { 2175 if (!enable_overuse) {
2181 ASSERT_TRUE(overuse_callback == NULL); 2176 ASSERT_TRUE(overuse_callback == NULL);
2182 2177
2183 EXPECT_TRUE(capturer.CaptureFrame()); 2178 EXPECT_TRUE(capturer.CaptureFrame());
2184 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2179 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2185 2180
2186 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 2181 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
2187 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 2182 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
2188 2183
2189 channel_->SetSource(last_ssrc_, NULL); 2184 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2190 return; 2185 return;
2191 } 2186 }
2192 2187
2193 ASSERT_TRUE(overuse_callback != NULL); 2188 ASSERT_TRUE(overuse_callback != NULL);
2194 EXPECT_TRUE(capturer.CaptureFrame()); 2189 EXPECT_TRUE(capturer.CaptureFrame());
2195 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2190 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2196 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2191 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2197 2192
2198 EXPECT_TRUE(capturer.CaptureFrame()); 2193 EXPECT_TRUE(capturer.CaptureFrame());
2199 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 2194 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
2200 2195
2201 if (is_screenshare) { 2196 if (is_screenshare) {
2202 // Do not adapt screen share. 2197 // Do not adapt screen share.
2203 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 2198 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
2204 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 2199 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
2205 } else { 2200 } else {
2206 EXPECT_LT(send_stream->GetLastWidth(), codec.width); 2201 EXPECT_LT(send_stream->GetLastWidth(), codec.width);
2207 EXPECT_LT(send_stream->GetLastHeight(), codec.height); 2202 EXPECT_LT(send_stream->GetLastHeight(), codec.height);
2208 } 2203 }
2209 2204
2210 // Trigger underuse which should go back to normal resolution. 2205 // Trigger underuse which should go back to normal resolution.
2211 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 2206 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
2212 EXPECT_TRUE(capturer.CaptureFrame()); 2207 EXPECT_TRUE(capturer.CaptureFrame());
2213 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 2208 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
2214 2209
2215 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 2210 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
2216 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 2211 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
2217 2212
2218 channel_->SetSource(last_ssrc_, NULL); 2213 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2219 } 2214 }
2220 2215
2221 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { 2216 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) {
2222 // Start at last timestamp to verify that wraparounds are estimated correctly. 2217 // Start at last timestamp to verify that wraparounds are estimated correctly.
2223 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; 2218 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu;
2224 static const int64_t kInitialNtpTimeMs = 1247891230; 2219 static const int64_t kInitialNtpTimeMs = 1247891230;
2225 static const int kFrameOffsetMs = 20; 2220 static const int kFrameOffsetMs = 20;
2226 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 2221 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2227 2222
2228 FakeVideoReceiveStream* stream = AddRecvStream(); 2223 FakeVideoReceiveStream* stream = AddRecvStream();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 2334
2340 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { 2335 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
2341 cricket::VideoSendParameters parameters; 2336 cricket::VideoSendParameters parameters;
2342 parameters.codecs.push_back(kVp8Codec720p); 2337 parameters.codecs.push_back(kVp8Codec720p);
2343 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2338 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2344 channel_->SetSend(true); 2339 channel_->SetSend(true);
2345 2340
2346 FakeVideoSendStream* stream = AddSendStream(); 2341 FakeVideoSendStream* stream = AddSendStream();
2347 2342
2348 cricket::FakeVideoCapturer capturer; 2343 cricket::FakeVideoCapturer capturer;
2349 channel_->SetSource(last_ssrc_, &capturer); 2344 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2350 EXPECT_EQ(cricket::CS_RUNNING, 2345 EXPECT_EQ(cricket::CS_RUNNING,
2351 capturer.Start(capturer.GetSupportedFormats()->front())); 2346 capturer.Start(capturer.GetSupportedFormats()->front()));
2352 EXPECT_TRUE(capturer.CaptureFrame()); 2347 EXPECT_TRUE(capturer.CaptureFrame());
2353 2348
2354 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2349 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2355 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); 2350 EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
2356 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); 2351 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
2357 2352
2358 parameters.codecs.clear(); 2353 parameters.codecs.clear();
2359 parameters.codecs.push_back(kVp8Codec360p); 2354 parameters.codecs.push_back(kVp8Codec360p);
2360 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2355 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2361 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); 2356 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
2362 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); 2357 EXPECT_EQ(kVp8Codec360p.width, streams[0].width);
2363 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); 2358 EXPECT_EQ(kVp8Codec360p.height, streams[0].height);
2364 channel_->SetSource(last_ssrc_, NULL); 2359 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2365 } 2360 }
2366 2361
2367 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { 2362 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) {
2368 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 2363 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
2369 200000); 2364 200000);
2370 } 2365 }
2371 2366
2372 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { 2367 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) {
2373 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); 2368 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000);
2374 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); 2369 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 2450
2456 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { 2451 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) {
2457 cricket::VideoSendParameters parameters; 2452 cricket::VideoSendParameters parameters;
2458 parameters.codecs.push_back(kVp8Codec720p); 2453 parameters.codecs.push_back(kVp8Codec720p);
2459 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2454 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2460 channel_->SetSend(true); 2455 channel_->SetSend(true);
2461 2456
2462 FakeVideoSendStream* stream = AddSendStream(); 2457 FakeVideoSendStream* stream = AddSendStream();
2463 2458
2464 cricket::FakeVideoCapturer capturer; 2459 cricket::FakeVideoCapturer capturer;
2465 channel_->SetSource(last_ssrc_, &capturer); 2460 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2466 EXPECT_EQ(cricket::CS_RUNNING, 2461 EXPECT_EQ(cricket::CS_RUNNING,
2467 capturer.Start(capturer.GetSupportedFormats()->front())); 2462 capturer.Start(capturer.GetSupportedFormats()->front()));
2468 2463
2469 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2464 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2470 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; 2465 int initial_max_bitrate_bps = streams[0].max_bitrate_bps;
2471 EXPECT_GT(initial_max_bitrate_bps, 0); 2466 EXPECT_GT(initial_max_bitrate_bps, 0);
2472 2467
2473 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; 2468 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
2474 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2469 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2475 // Insert a frame to update the encoder config. 2470 // Insert a frame to update the encoder config.
2476 EXPECT_TRUE(capturer.CaptureFrame()); 2471 EXPECT_TRUE(capturer.CaptureFrame());
2477 streams = stream->GetVideoStreams(); 2472 streams = stream->GetVideoStreams();
2478 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); 2473 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps);
2479 channel_->SetSource(last_ssrc_, nullptr); 2474 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2480 } 2475 }
2481 2476
2482 TEST_F(WebRtcVideoChannel2Test, 2477 TEST_F(WebRtcVideoChannel2Test,
2483 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { 2478 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) {
2484 cricket::VideoSendParameters parameters; 2479 cricket::VideoSendParameters parameters;
2485 parameters.codecs.push_back(kVp8Codec720p); 2480 parameters.codecs.push_back(kVp8Codec720p);
2486 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2481 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2487 channel_->SetSend(true); 2482 channel_->SetSend(true);
2488 2483
2489 FakeVideoSendStream* stream = AddSendStream( 2484 FakeVideoSendStream* stream = AddSendStream(
2490 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2485 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2491 2486
2492 // Send a frame to make sure this scales up to >1 stream (simulcast). 2487 // Send a frame to make sure this scales up to >1 stream (simulcast).
2493 cricket::FakeVideoCapturer capturer; 2488 cricket::FakeVideoCapturer capturer;
2494 channel_->SetSource(kSsrcs3[0], &capturer); 2489 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &capturer));
2495 EXPECT_EQ(cricket::CS_RUNNING, 2490 EXPECT_EQ(cricket::CS_RUNNING,
2496 capturer.Start(capturer.GetSupportedFormats()->front())); 2491 capturer.Start(capturer.GetSupportedFormats()->front()));
2497 EXPECT_TRUE(capturer.CaptureFrame()); 2492 EXPECT_TRUE(capturer.CaptureFrame());
2498 2493
2499 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2494 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2500 ASSERT_GT(streams.size(), 1u) 2495 ASSERT_GT(streams.size(), 1u)
2501 << "Without simulcast this test doesn't make sense."; 2496 << "Without simulcast this test doesn't make sense.";
2502 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams); 2497 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2503 EXPECT_GT(initial_max_bitrate_bps, 0); 2498 EXPECT_GT(initial_max_bitrate_bps, 0);
2504 2499
2505 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; 2500 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
2506 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2501 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2507 // Insert a frame to update the encoder config. 2502 // Insert a frame to update the encoder config.
2508 EXPECT_TRUE(capturer.CaptureFrame()); 2503 EXPECT_TRUE(capturer.CaptureFrame());
2509 streams = stream->GetVideoStreams(); 2504 streams = stream->GetVideoStreams();
2510 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); 2505 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2511 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); 2506 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps);
2512 2507
2513 channel_->SetSource(kSsrcs3[0], nullptr); 2508 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2514 } 2509 }
2515 2510
2516 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { 2511 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) {
2517 static const char* kMaxQuantization = "21"; 2512 static const char* kMaxQuantization = "21";
2518 cricket::VideoSendParameters parameters; 2513 cricket::VideoSendParameters parameters;
2519 parameters.codecs.push_back(kVp8Codec); 2514 parameters.codecs.push_back(kVp8Codec);
2520 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; 2515 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization;
2521 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2516 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2522 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)), 2517 EXPECT_EQ(static_cast<unsigned int>(atoi(kMaxQuantization)),
2523 AddSendStream()->GetVideoStreams().back().max_qp); 2518 AddSendStream()->GetVideoStreams().back().max_qp);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 2887
2893 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) { 2888 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) {
2894 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2889 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2895 2890
2896 // Capture format VGA. 2891 // Capture format VGA.
2897 cricket::FakeVideoCapturer video_capturer_vga; 2892 cricket::FakeVideoCapturer video_capturer_vga;
2898 const std::vector<cricket::VideoFormat>* formats = 2893 const std::vector<cricket::VideoFormat>* formats =
2899 video_capturer_vga.GetSupportedFormats(); 2894 video_capturer_vga.GetSupportedFormats();
2900 cricket::VideoFormat capture_format_vga = (*formats)[1]; 2895 cricket::VideoFormat capture_format_vga = (*formats)[1];
2901 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); 2896 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga));
2902 channel_->SetSource(kSsrcs3[0], &video_capturer_vga); 2897 EXPECT_TRUE(
2898 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga));
2903 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2899 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2904 2900
2905 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30); 2901 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30);
2906 cricket::VideoSendParameters parameters; 2902 cricket::VideoSendParameters parameters;
2907 parameters.codecs.push_back(send_codec); 2903 parameters.codecs.push_back(send_codec);
2908 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2904 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2909 EXPECT_TRUE(channel_->SetSend(true)); 2905 EXPECT_TRUE(channel_->SetSend(true));
2910 2906
2911 // Verify that the CpuOveruseObserver is registered and trigger downgrade. 2907 // Verify that the CpuOveruseObserver is registered and trigger downgrade.
2912 2908
(...skipping 16 matching lines...) Expand all
2929 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 2925 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
2930 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2926 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2931 info.Clear(); 2927 info.Clear();
2932 EXPECT_TRUE(channel_->GetStats(&info)); 2928 EXPECT_TRUE(channel_->GetStats(&info));
2933 ASSERT_EQ(1U, info.senders.size()); 2929 ASSERT_EQ(1U, info.senders.size());
2934 EXPECT_EQ(2, info.senders[0].adapt_changes); 2930 EXPECT_EQ(2, info.senders[0].adapt_changes);
2935 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE, 2931 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE,
2936 info.senders[0].adapt_reason); 2932 info.senders[0].adapt_reason);
2937 2933
2938 // No capturer (no adapter). Adapt changes from old adapter should be kept. 2934 // No capturer (no adapter). Adapt changes from old adapter should be kept.
2939 channel_->SetSource(kSsrcs3[0], NULL); 2935 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2940 info.Clear(); 2936 info.Clear();
2941 EXPECT_TRUE(channel_->GetStats(&info)); 2937 EXPECT_TRUE(channel_->GetStats(&info));
2942 ASSERT_EQ(1U, info.senders.size()); 2938 ASSERT_EQ(1U, info.senders.size());
2943 EXPECT_EQ(2, info.senders[0].adapt_changes); 2939 EXPECT_EQ(2, info.senders[0].adapt_changes);
2944 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE, 2940 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE,
2945 info.senders[0].adapt_reason); 2941 info.senders[0].adapt_reason);
2946 2942
2947 // Set new capturer, capture format HD. 2943 // Set new capturer, capture format HD.
2948 cricket::FakeVideoCapturer video_capturer_hd; 2944 cricket::FakeVideoCapturer video_capturer_hd;
2949 cricket::VideoFormat capture_format_hd = (*formats)[0]; 2945 cricket::VideoFormat capture_format_hd = (*formats)[0];
2950 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_hd.Start(capture_format_hd)); 2946 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_hd.Start(capture_format_hd));
2951 channel_->SetSource(kSsrcs3[0], &video_capturer_hd); 2947 EXPECT_TRUE(
2948 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_hd));
2952 EXPECT_TRUE(video_capturer_hd.CaptureFrame()); 2949 EXPECT_TRUE(video_capturer_hd.CaptureFrame());
2953 2950
2954 // Trigger overuse, HD -> adapt (OnCpuResolutionRequest downgrade) -> HD/2. 2951 // Trigger overuse, HD -> adapt (OnCpuResolutionRequest downgrade) -> HD/2.
2955 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2952 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2956 EXPECT_TRUE(video_capturer_hd.CaptureFrame()); 2953 EXPECT_TRUE(video_capturer_hd.CaptureFrame());
2957 info.Clear(); 2954 info.Clear();
2958 EXPECT_TRUE(channel_->GetStats(&info)); 2955 EXPECT_TRUE(channel_->GetStats(&info));
2959 ASSERT_EQ(1U, info.senders.size()); 2956 ASSERT_EQ(1U, info.senders.size());
2960 EXPECT_EQ(3, info.senders[0].adapt_changes); 2957 EXPECT_EQ(3, info.senders[0].adapt_changes);
2961 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_CPU, info.senders[0].adapt_reason); 2958 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_CPU, info.senders[0].adapt_reason);
2962 2959
2963 channel_->SetSource(kSsrcs3[0], NULL); 2960 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
2964 } 2961 }
2965 2962
2966 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) { 2963 TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) {
2967 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); 2964 AddSendStream(cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)));
2968 2965
2969 // Capture format VGA. 2966 // Capture format VGA.
2970 cricket::FakeVideoCapturer video_capturer_vga; 2967 cricket::FakeVideoCapturer video_capturer_vga;
2971 const std::vector<cricket::VideoFormat>* formats = 2968 const std::vector<cricket::VideoFormat>* formats =
2972 video_capturer_vga.GetSupportedFormats(); 2969 video_capturer_vga.GetSupportedFormats();
2973 cricket::VideoFormat capture_format_vga = (*formats)[1]; 2970 cricket::VideoFormat capture_format_vga = (*formats)[1];
2974 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); 2971 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga));
2975 channel_->SetSource(kSsrcs3[0], &video_capturer_vga); 2972 EXPECT_TRUE(
2973 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga));
2976 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2974 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2977 2975
2978 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30); 2976 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30);
2979 cricket::VideoSendParameters parameters; 2977 cricket::VideoSendParameters parameters;
2980 parameters.codecs.push_back(send_codec); 2978 parameters.codecs.push_back(send_codec);
2981 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2979 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2982 EXPECT_TRUE(channel_->SetSend(true)); 2980 EXPECT_TRUE(channel_->SetSend(true));
2983 2981
2984 // Verify that the CpuOveruseObserver is registered and trigger downgrade. 2982 // Verify that the CpuOveruseObserver is registered and trigger downgrade.
2985 2983
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 3015
3018 // Reset bandwidth limitation state -> adapt NONE. 3016 // Reset bandwidth limitation state -> adapt NONE.
3019 stats.bw_limited_resolution = false; 3017 stats.bw_limited_resolution = false;
3020 fake_call_->GetVideoSendStreams().front()->SetStats(stats); 3018 fake_call_->GetVideoSendStreams().front()->SetStats(stats);
3021 info.Clear(); 3019 info.Clear();
3022 EXPECT_TRUE(channel_->GetStats(&info)); 3020 EXPECT_TRUE(channel_->GetStats(&info));
3023 ASSERT_EQ(1U, info.senders.size()); 3021 ASSERT_EQ(1U, info.senders.size());
3024 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE, 3022 EXPECT_EQ(WebRtcVideoChannel2::ADAPTREASON_NONE,
3025 info.senders[0].adapt_reason); 3023 info.senders[0].adapt_reason);
3026 3024
3027 channel_->SetSource(kSsrcs3[0], NULL); 3025 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, nullptr));
3028 } 3026 }
3029 3027
3030 TEST_F(WebRtcVideoChannel2Test, 3028 TEST_F(WebRtcVideoChannel2Test,
3031 GetStatsTranslatesBandwidthLimitedResolutionCorrectly) { 3029 GetStatsTranslatesBandwidthLimitedResolutionCorrectly) {
3032 FakeVideoSendStream* stream = AddSendStream(); 3030 FakeVideoSendStream* stream = AddSendStream();
3033 webrtc::VideoSendStream::Stats stats; 3031 webrtc::VideoSendStream::Stats stats;
3034 stats.bw_limited_resolution = true; 3032 stats.bw_limited_resolution = true;
3035 stream->SetStats(stats); 3033 stream->SetStats(stats);
3036 3034
3037 cricket::VideoMediaInfo info; 3035 cricket::VideoMediaInfo info;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 } 3381 }
3384 3382
3385 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { 3383 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) {
3386 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); 3384 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false);
3387 } 3385 }
3388 3386
3389 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { 3387 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
3390 AddSendStream(); 3388 AddSendStream();
3391 3389
3392 cricket::FakeVideoCapturer capturer; 3390 cricket::FakeVideoCapturer capturer;
3393 channel_->SetSource(last_ssrc_, &capturer); 3391 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
3394 cricket::VideoFormat capture_format_hd = 3392 cricket::VideoFormat capture_format_hd =
3395 capturer.GetSupportedFormats()->front(); 3393 capturer.GetSupportedFormats()->front();
3396 EXPECT_EQ(1280, capture_format_hd.width); 3394 EXPECT_EQ(1280, capture_format_hd.width);
3397 EXPECT_EQ(720, capture_format_hd.height); 3395 EXPECT_EQ(720, capture_format_hd.height);
3398 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 3396 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
3399 EXPECT_TRUE(channel_->SetSend(true)); 3397 EXPECT_TRUE(channel_->SetSend(true));
3400 3398
3401 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); 3399 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer);
3402 EXPECT_TRUE(default_encoder_bitrate > 1000); 3400 EXPECT_TRUE(default_encoder_bitrate > 1000);
3403 3401
3404 // TODO(skvlad): Resolve the inconsistency between the interpretation 3402 // TODO(skvlad): Resolve the inconsistency between the interpretation
3405 // of the global bitrate limit for audio and video: 3403 // of the global bitrate limit for audio and video:
3406 // - Audio: max_bandwidth_bps = 0 - fail the operation, 3404 // - Audio: max_bandwidth_bps = 0 - fail the operation,
3407 // max_bandwidth_bps = -1 - remove the bandwidth limit 3405 // max_bandwidth_bps = -1 - remove the bandwidth limit
3408 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, 3406 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit,
3409 // max_bandwidth_bps = -1 - do not change the previously set 3407 // max_bandwidth_bps = -1 - do not change the previously set
3410 // limit. 3408 // limit.
3411 3409
3412 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000); 3410 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000);
3413 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); 3411 SetAndExpectMaxBitrate(capturer, 1000, 800, 800);
3414 SetAndExpectMaxBitrate(capturer, 600, 800, 600); 3412 SetAndExpectMaxBitrate(capturer, 600, 800, 600);
3415 SetAndExpectMaxBitrate(capturer, 0, 800, 800); 3413 SetAndExpectMaxBitrate(capturer, 0, 800, 800);
3416 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); 3414 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate);
3417 3415
3418 channel_->SetSource(last_ssrc_, NULL); 3416 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
3419 } 3417 }
3420 3418
3421 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { 3419 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
3422 webrtc::RtpParameters nonexistent_parameters = 3420 webrtc::RtpParameters nonexistent_parameters =
3423 channel_->GetRtpParameters(last_ssrc_); 3421 channel_->GetRtpParameters(last_ssrc_);
3424 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); 3422 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
3425 3423
3426 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3424 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3427 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); 3425 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters));
3428 } 3426 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 3577
3580 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 3578 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
3581 RTC_DCHECK(num_configured_streams <= ssrcs.size()); 3579 RTC_DCHECK(num_configured_streams <= ssrcs.size());
3582 ssrcs.resize(num_configured_streams); 3580 ssrcs.resize(num_configured_streams);
3583 3581
3584 FakeVideoSendStream* stream = 3582 FakeVideoSendStream* stream =
3585 AddSendStream(CreateSimStreamParams("cname", ssrcs)); 3583 AddSendStream(CreateSimStreamParams("cname", ssrcs));
3586 // Send a full-size frame to trigger a stream reconfiguration to use all 3584 // Send a full-size frame to trigger a stream reconfiguration to use all
3587 // expected simulcast layers. 3585 // expected simulcast layers.
3588 cricket::FakeVideoCapturer capturer; 3586 cricket::FakeVideoCapturer capturer;
3589 channel_->SetSource(ssrcs.front(), &capturer); 3587 EXPECT_TRUE(
3588 channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
3590 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( 3589 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
3591 codec.width, codec.height, 3590 codec.width, codec.height,
3592 cricket::VideoFormat::FpsToInterval(30), 3591 cricket::VideoFormat::FpsToInterval(30),
3593 cricket::FOURCC_I420))); 3592 cricket::FOURCC_I420)));
3594 channel_->SetSend(true); 3593 channel_->SetSend(true);
3595 EXPECT_TRUE(capturer.CaptureFrame()); 3594 EXPECT_TRUE(capturer.CaptureFrame());
3596 3595
3597 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); 3596 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
3598 ASSERT_EQ(expected_num_streams, video_streams.size()); 3597 ASSERT_EQ(expected_num_streams, video_streams.size());
3599 3598
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3636 total_max_bitrate_bps += video_streams[i].max_bitrate_bps; 3635 total_max_bitrate_bps += video_streams[i].max_bitrate_bps;
3637 } else { 3636 } else {
3638 total_max_bitrate_bps += video_streams[i].target_bitrate_bps; 3637 total_max_bitrate_bps += video_streams[i].target_bitrate_bps;
3639 } 3638 }
3640 } 3639 }
3641 cricket::VideoMediaInfo info; 3640 cricket::VideoMediaInfo info;
3642 ASSERT_TRUE(channel_->GetStats(&info)); 3641 ASSERT_TRUE(channel_->GetStats(&info));
3643 ASSERT_EQ(1u, info.senders.size()); 3642 ASSERT_EQ(1u, info.senders.size());
3644 EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate); 3643 EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate);
3645 3644
3646 channel_->SetSource(ssrcs.front(), NULL); 3645 EXPECT_TRUE(channel_->SetVideoSend(ssrcs.front(), true, nullptr, nullptr));
3647 } 3646 }
3648 3647
3649 FakeVideoSendStream* AddSendStream() { 3648 FakeVideoSendStream* AddSendStream() {
3650 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); 3649 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++));
3651 } 3650 }
3652 3651
3653 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { 3652 FakeVideoSendStream* AddSendStream(const StreamParams& sp) {
3654 size_t num_streams = 3653 size_t num_streams =
3655 fake_call_.GetVideoSendStreams().size(); 3654 fake_call_.GetVideoSendStreams().size();
3656 EXPECT_TRUE(channel_->AddSendStream(sp)); 3655 EXPECT_TRUE(channel_->AddSendStream(sp));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 } 3692 }
3694 3693
3695 // Test that we normalize send codec format size in simulcast. 3694 // Test that we normalize send codec format size in simulcast.
3696 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3695 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3697 cricket::VideoCodec codec(kVp8Codec270p); 3696 cricket::VideoCodec codec(kVp8Codec270p);
3698 codec.width += 1; 3697 codec.width += 1;
3699 codec.height += 1; 3698 codec.height += 1;
3700 VerifySimulcastSettings(codec, 2, 2); 3699 VerifySimulcastSettings(codec, 2, 2);
3701 } 3700 }
3702 } // namespace cricket 3701 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698